"use strict";const e=require("../../../../../common/vendor.js");require("../../../../adapter-vue.js");const o=require("../../../common/Toast/index.js"),t=require("../../../../../common/assets.js");Math||n();const n=()=>"../../../common/Icon.js",u=e.defineComponent({__name:"message-audio",props:{broadcastNewAudioSrc:{},messageItem:{default:()=>({})},content:{default:()=>({})}},emits:["getGlobalAudioContext","setAudioPlayed"],setup(n,{emit:u}){const a=u,s=n,c=new Map,r=e.ref(!1);function i(){if(a("getGlobalAudioContext",c,{newAudioSrc:s.content.url}),s.messageItem.hasRiskContent||!s.content.url)return void o.Toast({message:"暂不支持播放"});v()||(c.set("audio",e.index.createInnerAudioContext()),e.index.setInnerAudioOption({obeyMuteSwitch:!1}),function(){const e=v();if(!e)return;e.src=s.content.url,r.value=!1,e.onPlay(l),e.onStop(m),e.onEnded(f),e.onError(p)}()),r.value?d():function(){const e=v();e&&(e.play(),"in"===s.messageItem.flow&&a("setAudioPlayed",s.messageItem.ID))}()}function d(){const e=v();if(e)try{e.stop()}catch{}}function l(){r.value=!0}function m(){r.value=!1}function f(){r.value=!1}function p(){console.warn("audio played error")}function v(){return c.get("audio")}return e.onUnmounted((()=>{var e;const o=v();r.value&&d(),null==(e=null==o?void 0:o.destroy)||e.call(o),c.delete("audio")})),e.watch((()=>s.broadcastNewAudioSrc),(e=>{e!==s.content.url&&r.value&&(d(),r.value=!1)})),(o,n)=>({a:e.unref(r)?1:"",b:e.p({width:"15px",height:"20px",file:e.unref(t.audioIcon)}),c:e.t(s.content.second||1),d:5*s.content.second+"px",e:"out"===s.messageItem.flow?1:"",f:e.o$1(i)})}}),a=e._export_sfc(u,[["__scopeId","data-v-2cea66cb"]]);wx.createComponent(a);
