import{k as $,f as A,h as M,d as pt,a as B,m as mt,y as ft,b as tt,z as F,e as G,w as V,A as H,t as et,$ as it,g as X,u as U,j as Y,a0 as st}from"./index-B_cVej0C.js";function _(u,t,e,i){return new(e||(e=Promise))((function(s,n){function r(o){try{l(i.next(o))}catch(h){n(h)}}function a(o){try{l(i.throw(o))}catch(h){n(h)}}function l(o){var h;o.done?s(o.value):(h=o.value,h instanceof e?h:new e((function(p){p(h)}))).then(r,a)}l((i=i.apply(u,t||[])).next())}))}class j{constructor(){this.listeners={}}on(t,e,i){if(this.listeners[t]||(this.listeners[t]=new Set),i==null?void 0:i.once){const s=(...n)=>{this.un(t,s),e(...n)};return this.listeners[t].add(s),()=>this.un(t,s)}return this.listeners[t].add(e),()=>this.un(t,e)}un(t,e){var i;(i=this.listeners[t])===null||i===void 0||i.delete(e)}once(t,e){return this.on(t,e,{once:!0})}unAll(){this.listeners={}}emit(t,...e){this.listeners[t]&&this.listeners[t].forEach((i=>i(...e)))}}const q={decode:function(u,t){return _(this,void 0,void 0,(function*(){const e=new AudioContext({sampleRate:t});try{return yield e.decodeAudioData(u)}finally{e.close()}}))},createBuffer:function(u,t){if(!u||u.length===0)throw new Error("channelData must be a non-empty array");if(t<=0)throw new Error("duration must be greater than 0");if(typeof u[0]=="number"&&(u=[u]),!u[0]||u[0].length===0)throw new Error("channelData must contain non-empty channel arrays");(function(i){const s=i[0];if(s.some((n=>n>1||n<-1))){const n=s.length;let r=0;for(let a=0;ar&&(r=l)}for(const a of i)for(let l=0;li instanceof Float32Array?i:Float32Array.from(i)));return{duration:t,length:e[0].length,sampleRate:e[0].length/t,numberOfChannels:e.length,getChannelData:i=>{const s=e[i];if(!s)throw new Error(`Channel ${i} not found`);return s},copyFromChannel:AudioBuffer.prototype.copyFromChannel,copyToChannel:AudioBuffer.prototype.copyToChannel}}};function lt(u,t){const e=t.xmlns?document.createElementNS(t.xmlns,u):document.createElement(u);for(const[i,s]of Object.entries(t))if(i==="children"&&s)for(const[n,r]of Object.entries(s))r instanceof Node?e.appendChild(r):typeof r=="string"?e.appendChild(document.createTextNode(r)):e.appendChild(lt(n,r));else i==="style"?Object.assign(e.style,s):i==="textContent"?e.textContent=s:e.setAttribute(i,s.toString());return e}function nt(u,t,e){const i=lt(u,t||{});return e==null||e.appendChild(i),i}var vt=Object.freeze({__proto__:null,createElement:nt,default:nt});const gt={fetchBlob:function(u,t,e){return _(this,void 0,void 0,(function*(){const i=yield fetch(u,e);if(i.status>=400)throw new Error(`Failed to fetch ${u}: ${i.status} (${i.statusText})`);return(function(s,n){_(this,void 0,void 0,(function*(){if(!s.body||!s.headers)return;const r=s.body.getReader(),a=Number(s.headers.get("Content-Length"))||0;let l=0;const o=h=>{l+=(h==null?void 0:h.length)||0;const p=Math.round(l/a*100);n(p)};try{for(;;){const h=yield r.read();if(h.done)break;o(h.value)}}catch(h){console.warn("Progress tracking error:",h)}}))})(i.clone(),t),i.blob()}))}};function E(u){let t=u;const e=new Set;return{get value(){return t},set(i){Object.is(t,i)||(t=i,e.forEach((s=>s(t))))},update(i){this.set(i(t))},subscribe:i=>(e.add(i),()=>e.delete(i))}}function z(u,t){const e=E(u());return t.forEach((i=>i.subscribe((()=>{const s=u();Object.is(e.value,s)||e.set(s)})))),{get value(){return e.value},subscribe:i=>e.subscribe(i)}}function N(u,t){let e;const i=()=>{e&&(e(),e=void 0),e=u()},s=t.map((n=>n.subscribe(i)));return i(),()=>{e&&(e(),e=void 0),s.forEach((n=>n()))}}class bt extends j{get isPlayingSignal(){return this._isPlaying}get currentTimeSignal(){return this._currentTime}get durationSignal(){return this._duration}get volumeSignal(){return this._volume}get mutedSignal(){return this._muted}get playbackRateSignal(){return this._playbackRate}get seekingSignal(){return this._seeking}constructor(t){super(),this.isExternalMedia=!1,this.reactiveMediaEventCleanups=[],t.media?(this.media=t.media,this.isExternalMedia=!0):this.media=document.createElement("audio"),this._isPlaying=E(!1),this._currentTime=E(0),this._duration=E(0),this._volume=E(this.media.volume),this._muted=E(this.media.muted),this._playbackRate=E(this.media.playbackRate||1),this._seeking=E(!1),this.setupReactiveMediaEvents(),t.mediaControls&&(this.media.controls=!0),t.autoplay&&(this.media.autoplay=!0),t.playbackRate!=null&&this.onMediaEvent("canplay",(()=>{t.playbackRate!=null&&(this.media.playbackRate=t.playbackRate)}),{once:!0})}setupReactiveMediaEvents(){this.reactiveMediaEventCleanups.push(this.onMediaEvent("play",(()=>{this._isPlaying.set(!0)}))),this.reactiveMediaEventCleanups.push(this.onMediaEvent("pause",(()=>{this._isPlaying.set(!1)}))),this.reactiveMediaEventCleanups.push(this.onMediaEvent("ended",(()=>{this._isPlaying.set(!1)}))),this.reactiveMediaEventCleanups.push(this.onMediaEvent("timeupdate",(()=>{this._currentTime.set(this.media.currentTime)}))),this.reactiveMediaEventCleanups.push(this.onMediaEvent("durationchange",(()=>{this._duration.set(this.media.duration||0)}))),this.reactiveMediaEventCleanups.push(this.onMediaEvent("loadedmetadata",(()=>{this._duration.set(this.media.duration||0)}))),this.reactiveMediaEventCleanups.push(this.onMediaEvent("seeking",(()=>{this._seeking.set(!0)}))),this.reactiveMediaEventCleanups.push(this.onMediaEvent("seeked",(()=>{this._seeking.set(!1)}))),this.reactiveMediaEventCleanups.push(this.onMediaEvent("volumechange",(()=>{this._volume.set(this.media.volume),this._muted.set(this.media.muted)}))),this.reactiveMediaEventCleanups.push(this.onMediaEvent("ratechange",(()=>{this._playbackRate.set(this.media.playbackRate)})))}onMediaEvent(t,e,i){return this.media.addEventListener(t,e,i),()=>this.media.removeEventListener(t,e,i)}getSrc(){return this.media.currentSrc||this.media.src||""}revokeSrc(){const t=this.getSrc();t.startsWith("blob:")&&URL.revokeObjectURL(t)}canPlayType(t){return this.media.canPlayType(t)!==""}setSrc(t,e){const i=this.getSrc();if(t&&i===t)return;this.revokeSrc();const s=e instanceof Blob&&(this.canPlayType(e.type)||!t)?URL.createObjectURL(e):t;if(i&&this.media.removeAttribute("src"),s||t)try{this.media.src=s}catch(n){this.media.src=t}}destroy(){this.reactiveMediaEventCleanups.forEach((t=>t())),this.reactiveMediaEventCleanups=[],this.isExternalMedia||(this.media.pause(),this.revokeSrc(),this.media.removeAttribute("src"),this.media.load(),this.media.remove())}setMediaElement(t){this.reactiveMediaEventCleanups.forEach((e=>e())),this.reactiveMediaEventCleanups=[],this.media=t,this.setupReactiveMediaEvents()}play(){return _(this,void 0,void 0,(function*(){try{return yield this.media.play()}catch(t){if(t instanceof DOMException&&t.name==="AbortError")return;throw t}}))}pause(){this.media.pause()}isPlaying(){return!this.media.paused&&!this.media.ended}setTime(t){this.media.currentTime=Math.max(0,Math.min(t,this.getDuration()))}getDuration(){return this.media.duration}getCurrentTime(){return this.media.currentTime}getVolume(){return this.media.volume}setVolume(t){this.media.volume=t}getMuted(){return this.media.muted}setMuted(t){this.media.muted=t}getPlaybackRate(){return this.media.playbackRate}isSeeking(){return this.media.seeking}setPlaybackRate(t,e){e!=null&&(this.media.preservesPitch=e),this.media.playbackRate=t}getMediaElement(){return this.media}setSinkId(t){return this.media.setSinkId(t)}}function yt({maxTop:u,maxBottom:t,halfHeight:e,vScale:i,barMinHeight:s=0,barAlign:n}){let r=Math.round(u*e*i),a=r+Math.round(t*e*i)||1;return a(function(n){const{scrollLeft:r,scrollWidth:a,clientWidth:l}=n;if(a===0)return{startX:0,endX:1};const o=r/a,h=(r+l)/a;return{startX:Math.max(0,Math.min(1,o)),endX:Math.max(0,Math.min(1,h))}})(t.value)),[t]),i=z((()=>(function(n){return{left:n.scrollLeft,right:n.scrollLeft+n.clientWidth}})(t.value)),[t]),s=()=>{t.set({scrollLeft:u.scrollLeft,scrollWidth:u.scrollWidth,clientWidth:u.clientWidth})};return u.addEventListener("scroll",s,{passive:!0}),{scrollData:t,percentages:e,bounds:i,cleanup:()=>{u.removeEventListener("scroll",s),ut(t)}}}class St extends j{constructor(t,e){super(),this.timeouts=[],this.isScrollable=!1,this.audioData=null,this.resizeObserver=null,this.lastContainerWidth=0,this.isDragging=!1,this.subscriptions=[],this.unsubscribeOnScroll=[],this.dragStream=null,this.scrollStream=null,this.subscriptions=[],this.options=t;const i=this.parentFromOptionsContainer(t.container);this.parent=i;const[s,n]=this.initHtml();i.appendChild(s),this.container=s,this.scrollContainer=n.querySelector(".scroll"),this.wrapper=n.querySelector(".wrapper"),this.canvasWrapper=n.querySelector(".canvases"),this.progressWrapper=n.querySelector(".progress"),this.cursor=n.querySelector(".cursor"),e&&n.appendChild(e),this.initEvents()}parentFromOptionsContainer(t){let e;if(typeof t=="string"?e=document.querySelector(t):t instanceof HTMLElement&&(e=t),!e)throw new Error("Container not found");return e}initEvents(){this.wrapper.addEventListener("click",(e=>{const i=this.wrapper.getBoundingClientRect(),[s,n]=rt(i,e.clientX,e.clientY);this.emit("click",s,n)})),this.wrapper.addEventListener("dblclick",(e=>{const i=this.wrapper.getBoundingClientRect(),[s,n]=rt(i,e.clientX,e.clientY);this.emit("dblclick",s,n)})),this.options.dragToSeek!==!0&&typeof this.options.dragToSeek!="object"||this.initDrag(),this.scrollStream=wt(this.scrollContainer);const t=N((()=>{const{startX:e,endX:i}=this.scrollStream.percentages.value,{left:s,right:n}=this.scrollStream.bounds.value;this.emit("scroll",e,i,s,n)}),[this.scrollStream.percentages,this.scrollStream.bounds]);if(this.subscriptions.push(t),typeof ResizeObserver=="function"){const e=this.createDelay(100);this.resizeObserver=new ResizeObserver((()=>{e().then((()=>this.onContainerResize())).catch((()=>{}))})),this.resizeObserver.observe(this.scrollContainer)}}onContainerResize(){const t=this.parent.clientWidth;t===this.lastContainerWidth&&this.options.height!=="auto"||(this.lastContainerWidth=t,this.reRender(),this.emit("resize"))}initDrag(){if(this.dragStream)return;this.dragStream=(function(e,i={}){const{threshold:s=3,mouseButton:n=0,touchDelay:r=100}=i,a=E(null),l=new Map,o=matchMedia("(pointer: coarse)").matches;let h=()=>{};const p=d=>{if(d.button!==n||(l.set(d.pointerId,d),l.size>1))return;let m=d.clientX,c=d.clientY,f=!1;const v=Date.now(),y=e.getBoundingClientRect(),{left:S,top:C}=y,w=b=>{if(b.defaultPrevented||l.size>1||o&&Date.now()-vs||Math.abs(L)>s)&&(b.preventDefault(),b.stopPropagation(),f||(a.set({type:"start",x:m-S,y:c-C}),f=!0),a.set({type:"move",x:R-S,y:D-C,deltaX:W,deltaY:L}),m=R,c=D)},P=b=>{if(l.delete(b.pointerId),f){const R=b.clientX,D=b.clientY;a.set({type:"end",x:R-S,y:D-C})}h()},x=b=>{l.delete(b.pointerId),b.relatedTarget&&b.relatedTarget!==document.documentElement||P(b)},k=b=>{f&&(b.stopPropagation(),b.preventDefault())},T=b=>{b.defaultPrevented||l.size>1||f&&b.preventDefault()};document.addEventListener("pointermove",w),document.addEventListener("pointerup",P),document.addEventListener("pointerout",x),document.addEventListener("pointercancel",x),document.addEventListener("touchmove",T,{passive:!1}),document.addEventListener("click",k,{capture:!0}),h=()=>{document.removeEventListener("pointermove",w),document.removeEventListener("pointerup",P),document.removeEventListener("pointerout",x),document.removeEventListener("pointercancel",x),document.removeEventListener("touchmove",T),setTimeout((()=>{document.removeEventListener("click",k,{capture:!0})}),10)}};return e.addEventListener("pointerdown",p),{signal:a,cleanup:()=>{h(),e.removeEventListener("pointerdown",p),l.clear(),ut(a)}}})(this.wrapper);const t=N((()=>{const e=this.dragStream.signal.value;if(!e)return;const i=this.wrapper.getBoundingClientRect().width,s=(n=e.x/i)<0?0:n>1?1:n;var n;e.type==="start"?(this.isDragging=!0,this.emit("dragstart",s)):e.type==="move"?this.emit("drag",s):e.type==="end"&&(this.isDragging=!1,this.emit("dragend",s))}),[this.dragStream.signal]);this.subscriptions.push(t)}initHtml(){const t=document.createElement("div"),e=t.attachShadow({mode:"open"}),i=this.options.cspNonce&&typeof this.options.cspNonce=="string"?this.options.cspNonce.replace(/"/g,""):"";return e.innerHTML=` :host { user-select: none; min-width: 1px; } :host audio { display: block; width: 100%; } :host .scroll { overflow-x: auto; overflow-y: hidden; width: 100%; position: relative; } :host .noScrollbar { scrollbar-color: transparent; scrollbar-width: none; } :host .noScrollbar::-webkit-scrollbar { display: none; -webkit-appearance: none; } :host .wrapper { position: relative; overflow: visible; z-index: 2; } :host .canvases { min-height: ${this.getHeight(this.options.height,this.options.splitChannels)}px; pointer-events: none; } :host .canvases > div { position: relative; } :host canvas { display: block; position: absolute; top: 0; image-rendering: pixelated; } :host .progress { pointer-events: none; position: absolute; z-index: 2; top: 0; left: 0; width: 0; height: 100%; overflow: hidden; } :host .progress > div { position: relative; } :host .cursor { pointer-events: none; position: absolute; z-index: 5; top: 0; left: 0; height: 100%; border-radius: 2px; }
`,[t,e]}setOptions(t){if(this.options.container!==t.container){const e=this.parentFromOptionsContainer(t.container);e.appendChild(this.container),this.parent=e}t.dragToSeek!==!0&&typeof this.options.dragToSeek!="object"||this.initDrag(),this.options=t,this.reRender()}getWrapper(){return this.wrapper}getWidth(){return this.scrollContainer.clientWidth}getScroll(){return this.scrollContainer.scrollLeft}setScroll(t){this.scrollContainer.scrollLeft=t}setScrollPercentage(t){const{scrollWidth:e}=this.scrollContainer,i=e*t;this.setScroll(i)}destroy(){var t;this.subscriptions.forEach((e=>e())),this.container.remove(),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),(t=this.unsubscribeOnScroll)===null||t===void 0||t.forEach((e=>e())),this.unsubscribeOnScroll=[],this.dragStream&&(this.dragStream.cleanup(),this.dragStream=null),this.scrollStream&&(this.scrollStream.cleanup(),this.scrollStream=null)}createDelay(t=10){let e,i;const s=()=>{e&&(clearTimeout(e),e=void 0),i&&(i(),i=void 0)};return this.timeouts.push(s),()=>new Promise(((n,r)=>{s(),i=r,e=setTimeout((()=>{e=void 0,i=void 0,n()}),t)}))}getHeight(t,e){var i;const s=((i=this.audioData)===null||i===void 0?void 0:i.numberOfChannels)||1;return(function({optionsHeight:n,optionsSplitChannels:r,parentHeight:a,numberOfChannels:l,defaultHeight:o=128}){if(n==null)return o;const h=Number(n);if(!isNaN(h))return h;if(n==="auto"){const p=a||o;return r!=null&&r.every((d=>!d.overlay))?p/l:p}return o})({optionsHeight:t,optionsSplitChannels:e,parentHeight:this.parent.clientHeight,numberOfChannels:s,defaultHeight:128})}convertColorValues(t,e){return(function(i,s,n){if(!Array.isArray(i))return i||"";if(i.length===0)return"#999";if(i.length<2)return i[0]||"";const r=document.createElement("canvas"),a=r.getContext("2d"),l=n!=null?n:r.height*s,o=a.createLinearGradient(0,0,0,l||s),h=1/(i.length-1);return i.forEach(((p,d)=>{o.addColorStop(d*h,p)})),o})(t,this.getPixelRatio(),e==null?void 0:e.canvas.height)}getPixelRatio(){return t=window.devicePixelRatio,Math.max(1,t||1);var t}renderBarWaveform(t,e,i,s){const{width:n,height:r}=i.canvas,{halfHeight:a,barWidth:l,barRadius:o,barIndexScale:h,barSpacing:p,barMinHeight:d}=(function({width:c,height:f,length:v,options:y,pixelRatio:S}){const C=f/2,w=y.barWidth?y.barWidth*S:1,P=y.barGap?y.barGap*S:y.barWidth?w/2:0,x=w+P||1;return{halfHeight:C,barWidth:w,barGap:P,barRadius:y.barRadius||0,barMinHeight:y.barMinHeight?y.barMinHeight*S:0,barIndexScale:v>0?c/x/v:0,barSpacing:x}})({width:n,height:r,length:(t[0]||[]).length,options:e,pixelRatio:this.getPixelRatio()}),m=(function({channelData:c,barIndexScale:f,barSpacing:v,barWidth:y,halfHeight:S,vScale:C,canvasHeight:w,barAlign:P,barMinHeight:x}){const k=c[0]||[],T=c[1]||k,b=k.length,R=[];let D=0,W=0,L=0;for(let g=0;g<=b;g++){const O=Math.round(g*f);if(O>D){const{topHeight:ct,totalHeight:Q}=yt({maxTop:W,maxBottom:L,halfHeight:S,vScale:C,barMinHeight:x,barAlign:P}),dt=Ct({barAlign:P,halfHeight:S,topHeight:ct,totalHeight:Q,canvasHeight:w});R.push({x:D*v,y:dt,width:y,height:Q}),D=O,W=0,L=0}const J=Math.abs(k[g]||0),K=Math.abs(T[g]||0);J>W&&(W=J),K>L&&(L=K)}return R})({channelData:t,barIndexScale:h,barSpacing:p,barWidth:l,halfHeight:a,vScale:s,canvasHeight:r,barAlign:e.barAlign,barMinHeight:d});i.beginPath();for(const c of m)o&&"roundRect"in i?i.roundRect(c.x,c.y,c.width,c.height,o):i.rect(c.x,c.y,c.width,c.height);i.fill(),i.closePath()}renderLineWaveform(t,e,i,s){const{width:n,height:r}=i.canvas,a=(function({channelData:l,width:o,height:h,vScale:p}){const d=h/2,m=l[0]||[];return[m,l[1]||m].map(((c,f)=>{const v=c.length,y=v?o/v:0,S=d,C=f===0?-1:1,w=[{x:0,y:S}];let P=0,x=0;for(let k=0;k<=v;k++){const T=Math.round(k*y);if(T>P){const R=S+(Math.round(x*d*p)||1)*C;w.push({x:P,y:R}),P=T,x=0}const b=Math.abs(c[k]||0);b>x&&(x=b)}return w.push({x:P,y:S}),w}))})({channelData:t,width:n,height:r,vScale:s});i.beginPath();for(const l of a)if(l.length){i.moveTo(l[0].x,l[0].y);for(let o=1;od&&(d=f)}return d?h/d:h})({channelData:t,barHeight:e.barHeight,normalize:e.normalize,maxPeak:e.maxPeak});ht(e)?this.renderBarWaveform(t,e,i,s):this.renderLineWaveform(t,e,i,s)}renderSingleCanvas(t,e,i,s,n,r,a){const l=this.getPixelRatio(),o=document.createElement("canvas");o.width=Math.round(i*l),o.height=Math.round(s*l),o.style.width=`${i}px`,o.style.height=`${s}px`,o.style.left=`${Math.round(n)}px`,r.appendChild(o);const h=o.getContext("2d");if(e.renderFunction?(h.fillStyle=this.convertColorValues(e.waveColor,h),e.renderFunction(t,h)):this.renderWaveform(t,e,h),o.width>0&&o.height>0){const p=o.cloneNode(),d=p.getContext("2d");d.drawImage(o,0,0),d.globalCompositeOperation="source-in",d.fillStyle=this.convertColorValues(e.progressColor,d),d.fillRect(0,0,o.width,o.height),a.appendChild(p)}}renderMultiCanvas(t,e,i,s,n,r){const a=this.getPixelRatio(),{clientWidth:l}=this.scrollContainer,o=i/a,h=(function({clientWidth:c,totalWidth:f,options:v}){return ot(Math.min(8e3,c,f),v)})({clientWidth:l,totalWidth:o,options:e});let p={};if(h===0)return;const d=c=>{if(c<0||c>=m||p[c])return;p[c]=!0;const f=c*h;let v=Math.min(o-f,h);if(v=ot(v,e),v<=0)return;const y=(function({channelData:S,offset:C,clampedWidth:w,totalWidth:P}){return S.map((x=>{const k=Math.floor(C/P*x.length),T=Math.floor((C+w)/P*x.length);return x.slice(k,T)}))})({channelData:t,offset:f,clampedWidth:v,totalWidth:o});this.renderSingleCanvas(y,e,v,s,f,n,r)},m=Math.ceil(o/h);if(!this.isScrollable){for(let c=0;cd(c))),m>1){const c=this.on("scroll",(()=>{const{scrollLeft:f}=this.scrollContainer;Object.keys(p).length>10&&(n.innerHTML="",r.innerHTML="",p={}),at({scrollLeft:f,totalWidth:o,numCanvases:m}).forEach((v=>d(v)))}));this.unsubscribeOnScroll.push(c)}}renderChannel(t,e,i,s){var{overlay:n}=e,r=(function(h,p){var d={};for(var m in h)Object.prototype.hasOwnProperty.call(h,m)&&p.indexOf(m)<0&&(d[m]=h[m]);if(h!=null&&typeof Object.getOwnPropertySymbols=="function"){var c=0;for(m=Object.getOwnPropertySymbols(h);c0&&(a.style.marginTop=`-${l}px`),this.canvasWrapper.style.minHeight=`${l}px`,this.canvasWrapper.appendChild(a);const o=a.cloneNode();this.progressWrapper.appendChild(o),this.renderMultiCanvas(t,r,i,l,a,o)}render(t){return _(this,void 0,void 0,(function*(){var e;this.timeouts.forEach((o=>o())),this.timeouts=[],this.canvasWrapper.innerHTML="",this.progressWrapper.innerHTML="",this.options.width!=null&&(this.scrollContainer.style.width=typeof this.options.width=="number"?`${this.options.width}px`:this.options.width);const i=this.getPixelRatio(),s=this.scrollContainer.clientWidth,{scrollWidth:n,isScrollable:r,useParentWidth:a,width:l}=(function({duration:o,minPxPerSec:h=0,parentWidth:p,fillParent:d,pixelRatio:m}){const c=Math.ceil(o*h),f=c>p,v=!!(d&&!f);return{scrollWidth:c,isScrollable:f,useParentWidth:v,width:(v?p:c)*m}})({duration:t.duration,minPxPerSec:this.options.minPxPerSec||0,parentWidth:s,fillParent:this.options.fillParent,pixelRatio:i});if(this.isScrollable=r,this.wrapper.style.width=a?"100%":`${n}px`,this.scrollContainer.style.overflowX=this.isScrollable?"auto":"hidden",this.scrollContainer.classList.toggle("noScrollbar",!!this.options.hideScrollbar),this.cursor.style.backgroundColor=`${this.options.cursorColor||this.options.progressColor}`,this.cursor.style.width=`${this.options.cursorWidth}px`,this.audioData=t,this.emit("render"),this.options.splitChannels)for(let o=0;o1&&o.push(t.getChannelData(1)),this.renderChannel(o,this.options,l,0)}Promise.resolve().then((()=>this.emit("rendered")))}))}reRender(){if(this.unsubscribeOnScroll.forEach((i=>i())),this.unsubscribeOnScroll=[],!this.audioData)return;const{scrollWidth:t}=this.scrollContainer,{right:e}=this.progressWrapper.getBoundingClientRect();if(this.render(this.audioData),this.isScrollable&&t!==this.scrollContainer.scrollWidth){const{right:i}=this.progressWrapper.getBoundingClientRect(),s=(function(n){const r=2*n;return(r<0?Math.floor(r):Math.ceil(r))/2})(i-e);this.scrollContainer.scrollLeft+=s}}zoom(t){this.options.minPxPerSec=t,this.reRender()}scrollIntoView(t,e=!1){const{scrollLeft:i,scrollWidth:s,clientWidth:n}=this.scrollContainer,r=t*s,a=i,l=i+n,o=n/2;if(this.isDragging)r+30>l?this.scrollContainer.scrollLeft+=30:r-30l)&&(this.scrollContainer.scrollLeft=r-(this.options.autoCenter?o:0));const h=r-i-o;e&&this.options.autoCenter&&h>0&&(this.scrollContainer.scrollLeft+=h)}}renderProgress(t,e){if(isNaN(t))return;const i=100*t;this.canvasWrapper.style.clipPath=`polygon(${i}% 0%, 100% 0%, 100% 100%, ${i}% 100%)`,this.progressWrapper.style.width=`${i}%`,this.cursor.style.left=`${i}%`,this.cursor.style.transform=this.options.cursorWidth?`translateX(-${t*this.options.cursorWidth}px)`:"",this.isScrollable&&this.options.autoScroll&&this.audioData&&this.audioData.duration>0&&this.scrollIntoView(t,e)}exportImage(t,e,i){return _(this,void 0,void 0,(function*(){const s=this.canvasWrapper.querySelectorAll("canvas");if(!s.length)throw new Error("No waveform data");if(i==="dataURL"){const n=Array.from(s).map((r=>r.toDataURL(t,e)));return Promise.resolve(n)}return Promise.all(Array.from(s).map((n=>new Promise(((r,a)=>{n.toBlob((l=>{l?r(l):a(new Error("Could not export image"))}),t,e)})))))}))}}class xt extends j{constructor(){super(...arguments),this.animationFrameId=null,this.isRunning=!1}start(){if(this.isRunning)return;this.isRunning=!0;const t=()=>{this.isRunning&&(this.emit("tick"),this.animationFrameId=requestAnimationFrame(t))};t()}stop(){this.isRunning=!1,this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}destroy(){this.stop()}}class Z extends j{constructor(t=new AudioContext){super(),this.bufferNode=null,this.playStartTime=0,this.playedDuration=0,this._muted=!1,this._playbackRate=1,this._duration=void 0,this.buffer=null,this.currentSrc="",this.paused=!0,this.crossOrigin=null,this.seeking=!1,this.autoplay=!1,this.addEventListener=this.on,this.removeEventListener=this.un,this.audioContext=t,this.gainNode=this.audioContext.createGain(),this.gainNode.connect(this.audioContext.destination)}load(){return _(this,void 0,void 0,(function*(){}))}get src(){return this.currentSrc}set src(t){if(this.currentSrc=t,this._duration=void 0,!t)return this.buffer=null,void this.emit("emptied");fetch(t).then((e=>{if(e.status>=400)throw new Error(`Failed to fetch ${t}: ${e.status} (${e.statusText})`);return e.arrayBuffer()})).then((e=>this.currentSrc!==t?null:this.audioContext.decodeAudioData(e))).then((e=>{this.currentSrc===t&&(this.buffer=e,this.emit("loadedmetadata"),this.emit("canplay"),this.autoplay&&this.play())})).catch((e=>{console.error("WebAudioPlayer load error:",e)}))}_play(){if(!this.paused)return;this.paused=!1,this.bufferNode&&(this.bufferNode.onended=null,this.bufferNode.disconnect()),this.bufferNode=this.audioContext.createBufferSource(),this.buffer&&(this.bufferNode.buffer=this.buffer),this.bufferNode.playbackRate.value=this._playbackRate,this.bufferNode.connect(this.gainNode);let t=this.playedDuration*this._playbackRate;(t>=this.duration||t<0)&&(t=0,this.playedDuration=0),this.bufferNode.start(this.audioContext.currentTime,t),this.playStartTime=this.audioContext.currentTime,this.bufferNode.onended=()=>{this.currentTime>=this.duration&&(this.pause(),this.emit("ended"))}}_pause(){var t;this.paused=!0,(t=this.bufferNode)===null||t===void 0||t.stop(),this.playedDuration+=this.audioContext.currentTime-this.playStartTime}play(){return _(this,void 0,void 0,(function*(){this.paused&&(this._play(),this.emit("play"))}))}pause(){this.paused||(this._pause(),this.emit("pause"))}stopAt(t){const e=t-this.currentTime,i=this.bufferNode;i==null||i.stop(this.audioContext.currentTime+e),i==null||i.addEventListener("ended",(()=>{i===this.bufferNode&&(this.bufferNode=null,this.pause())}),{once:!0})}setSinkId(t){return _(this,void 0,void 0,(function*(){return this.audioContext.setSinkId(t)}))}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate=t,this.bufferNode&&(this.bufferNode.playbackRate.value=t)}get currentTime(){return(this.paused?this.playedDuration:this.playedDuration+(this.audioContext.currentTime-this.playStartTime))*this._playbackRate}set currentTime(t){const e=!this.paused;e&&this._pause(),this.playedDuration=t/this._playbackRate,e&&this._play(),this.emit("seeking"),this.emit("timeupdate")}get duration(){var t,e;return(t=this._duration)!==null&&t!==void 0?t:((e=this.buffer)===null||e===void 0?void 0:e.duration)||0}set duration(t){this._duration=t}get volume(){return this.gainNode.gain.value}set volume(t){this.gainNode.gain.value=t,this.emit("volumechange")}get muted(){return this._muted}set muted(t){this._muted!==t&&(this._muted=t,this._muted?this.gainNode.disconnect():this.gainNode.connect(this.audioContext.destination))}canPlayType(t){return/^(audio|video)\//.test(t)}getGainNode(){return this.gainNode}getChannelData(){const t=[];if(!this.buffer)return t;const e=this.buffer.numberOfChannels;for(let i=0;i!v.value),[v]),R=z((()=>w.value!==null),[w]),D=z((()=>R.value&&f.value>0),[R,f]),W=z((()=>c.value),[c]),L=z((()=>f.value>0?c.value/f.value:0),[c,f]);return{state:{currentTime:c,duration:f,isPlaying:v,isPaused:b,isSeeking:y,volume:S,playbackRate:C,audioBuffer:w,peaks:P,url:x,zoom:k,scrollPosition:T,canPlay:R,isReady:D,progress:W,progressPercent:L},actions:{setCurrentTime:g=>{const O=Math.max(0,Math.min(f.value||1/0,g));c.set(O)},setDuration:g=>{f.set(Math.max(0,g))},setPlaying:g=>{v.set(g)},setSeeking:g=>{y.set(g)},setVolume:g=>{const O=Math.max(0,Math.min(1,g));S.set(O)},setPlaybackRate:g=>{const O=Math.max(.1,Math.min(16,g));C.set(O)},setAudioBuffer:g=>{w.set(g),g&&f.set(g.duration)},setPeaks:g=>{P.set(g)},setUrl:g=>{x.set(g)},setZoom:g=>{k.set(Math.max(0,g))},setScrollPosition:g=>{T.set(Math.max(0,g))}}}})({isPlaying:this.isPlayingSignal,currentTime:this.currentTimeSignal,duration:this.durationSignal,volume:this.volumeSignal,playbackRate:this.playbackRateSignal,isSeeking:this.seekingSignal});this.wavesurferState=i,this.wavesurferActions=s,this.timer=new xt;const n=e?void 0:this.getMediaElement();this.renderer=new St(this.options,n),this.initPlayerEvents(),this.initRendererEvents(),this.initTimerEvents(),this.initReactiveState(),this.initPlugins();const r=this.options.url||this.getSrc()||"";Promise.resolve().then((()=>{this.emit("init");const{peaks:a,duration:l}=this.options;(r||a&&l)&&this.load(r,a,l).catch((o=>{this.emit("error",o instanceof Error?o:new Error(String(o)))}))}))}updateProgress(t=this.getCurrentTime()){return this.renderer.renderProgress(t/this.getDuration(),this.isPlaying()),t}initTimerEvents(){this.subscriptions.push(this.timer.on("tick",(()=>{if(!this.isSeeking()){const t=this.updateProgress();this.emit("timeupdate",t),this.emit("audioprocess",t),this.stopAtPosition!=null&&this.isPlaying()&&t>=this.stopAtPosition&&this.pause()}})))}initReactiveState(){this.reactiveCleanups.push((function(t,e){const i=[];i.push(N((()=>{const r=t.isPlaying.value;e.emit(r?"play":"pause")}),[t.isPlaying])),i.push(N((()=>{const r=t.currentTime.value;e.emit("timeupdate",r),t.isPlaying.value&&e.emit("audioprocess",r)}),[t.currentTime,t.isPlaying])),i.push(N((()=>{t.isSeeking.value&&e.emit("seeking",t.currentTime.value)}),[t.isSeeking,t.currentTime]));let s=!1;i.push(N((()=>{t.isReady.value&&!s&&(s=!0,e.emit("ready",t.duration.value))}),[t.isReady,t.duration]));let n=!1;return i.push(N((()=>{const r=t.isPlaying.value,a=t.currentTime.value,l=t.duration.value,o=l>0&&a>=l;n&&!r&&o&&e.emit("finish"),n=r&&o}),[t.isPlaying,t.currentTime,t.duration])),i.push(N((()=>{const r=t.zoom.value;r>0&&e.emit("zoom",r)}),[t.zoom])),()=>{i.forEach((r=>r()))}})(this.wavesurferState,{emit:this.emit.bind(this)}))}initPlayerEvents(){this.isPlaying()&&(this.emit("play"),this.timer.start()),this.mediaSubscriptions.push(this.onMediaEvent("timeupdate",(()=>{const t=this.updateProgress();this.emit("timeupdate",t)})),this.onMediaEvent("play",(()=>{this.emit("play"),this.timer.start()})),this.onMediaEvent("pause",(()=>{this.emit("pause"),this.timer.stop(),this.stopAtPosition=null})),this.onMediaEvent("emptied",(()=>{this.timer.stop(),this.stopAtPosition=null})),this.onMediaEvent("ended",(()=>{this.emit("timeupdate",this.getDuration()),this.emit("finish"),this.stopAtPosition=null})),this.onMediaEvent("seeking",(()=>{this.emit("seeking",this.getCurrentTime())})),this.onMediaEvent("error",(()=>{var t;this.emit("error",(t=this.getMediaElement().error)!==null&&t!==void 0?t:new Error("Media error")),this.stopAtPosition=null})))}initRendererEvents(){this.subscriptions.push(this.renderer.on("click",((t,e)=>{this.options.interact&&(this.seekTo(t),this.emit("interaction",t*this.getDuration()),this.emit("click",t,e))})),this.renderer.on("dblclick",((t,e)=>{this.emit("dblclick",t,e)})),this.renderer.on("scroll",((t,e,i,s)=>{const n=this.getDuration();this.emit("scroll",t*n,e*n,i,s)})),this.renderer.on("render",(()=>{this.emit("redraw")})),this.renderer.on("rendered",(()=>{this.emit("redrawcomplete")})),this.renderer.on("dragstart",(t=>{this.emit("dragstart",t)})),this.renderer.on("dragend",(t=>{this.emit("dragend",t)})),this.renderer.on("resize",(()=>{this.emit("resize")})));{let t;const e=this.renderer.on("drag",(i=>{var s;if(!this.options.interact)return;this.renderer.renderProgress(i),clearTimeout(t);let n=0;const r=this.options.dragToSeek;this.isPlaying()?n=0:r===!0?n=200:r&&typeof r=="object"&&(n=(s=r.debounceTime)!==null&&s!==void 0?s:200),t=setTimeout((()=>{this.seekTo(i)}),n),this.emit("interaction",i*this.getDuration()),this.emit("drag",i)}));this.subscriptions.push((()=>{clearTimeout(t),e()}))}}initPlugins(){var t;!((t=this.options.plugins)===null||t===void 0)&&t.length&&this.options.plugins.forEach((e=>{this.registerPlugin(e)}))}unsubscribePlayerEvents(){this.mediaSubscriptions.forEach((t=>t())),this.mediaSubscriptions=[]}setOptions(t){this.options=Object.assign({},this.options,t),t.duration&&!t.peaks&&(this.decodedData=q.createBuffer(this.exportPeaks(),t.duration)),t.peaks&&t.duration&&(this.decodedData=q.createBuffer(t.peaks,t.duration)),this.renderer.setOptions(this.options),t.audioRate&&this.setPlaybackRate(t.audioRate),t.mediaControls!=null&&(this.getMediaElement().controls=t.mediaControls)}registerPlugin(t){if(this.plugins.includes(t))return t;t._init(this),this.plugins.push(t);const e=t.once("destroy",(()=>{this.plugins=this.plugins.filter((i=>i!==t)),this.subscriptions=this.subscriptions.filter((i=>i!==e))}));return this.subscriptions.push(e),t}unregisterPlugin(t){this.plugins=this.plugins.filter((e=>e!==t)),t.destroy()}getWrapper(){return this.renderer.getWrapper()}getWidth(){return this.renderer.getWidth()}getScroll(){return this.renderer.getScroll()}setScroll(t){return this.renderer.setScroll(t)}setScrollTime(t){const e=t/this.getDuration();this.renderer.setScrollPercentage(e)}getActivePlugins(){return this.plugins}loadAudio(t,e,i,s){return _(this,void 0,void 0,(function*(){var n;if(this.emit("load",t),!this.options.media&&this.isPlaying()&&this.pause(),this.decodedData=null,this.stopAtPosition=null,(n=this.abortController)===null||n===void 0||n.abort(),this.abortController=null,!e&&!i){const a=this.options.fetchParams||{};window.AbortController&&!a.signal&&(this.abortController=new AbortController,a.signal=this.abortController.signal);const l=h=>this.emit("loading",h);e=yield gt.fetchBlob(t,l,a);const o=this.options.blobMimeType;o&&(e=new Blob([e],{type:o}))}this.setSrc(t,e);const r=yield new Promise((a=>{const l=s||this.getDuration();l?a(l):this.mediaSubscriptions.push(this.onMediaEvent("loadedmetadata",(()=>a(this.getDuration())),{once:!0}))}));if(!t&&!e){const a=this.getMediaElement();a instanceof Z&&(a.duration=r)}if(i)this.decodedData=q.createBuffer(i,r||0);else if(e){const a=yield e.arrayBuffer();this.decodedData=yield q.decode(a,this.options.sampleRate)}this.decodedData&&(this.emit("decode",this.getDuration()),this.renderer.render(this.decodedData)),this.emit("ready",this.getDuration())}))}load(t,e,i){return _(this,void 0,void 0,(function*(){try{return yield this.loadAudio(t,void 0,e,i)}catch(s){throw this.emit("error",s),s}}))}loadBlob(t,e,i){return _(this,void 0,void 0,(function*(){try{return yield this.loadAudio("",t,e,i)}catch(s){throw this.emit("error",s),s}}))}zoom(t){if(!this.decodedData)throw new Error("No audio loaded");this.renderer.zoom(t),this.emit("zoom",t)}getDecodedData(){return this.decodedData}exportPeaks({channels:t=2,maxLength:e=8e3,precision:i=1e4}={}){if(!this.decodedData)throw new Error("The audio has not been decoded yet");const s=Math.min(t,this.decodedData.numberOfChannels),n=[];for(let r=0;rMath.abs(d)&&(d=c)}l.push(Math.round(d*i)/i)}n.push(l)}return n}getDuration(){let t=super.getDuration()||0;return t!==0&&t!==1/0||!this.decodedData||(t=this.decodedData.duration),t}toggleInteraction(t){this.options.interact=t}setTime(t){this.stopAtPosition=null,super.setTime(t),this.updateProgress(t),this.emit("timeupdate",t)}seekTo(t){const e=this.getDuration()*t;this.setTime(e)}play(t,e){const i=Object.create(null,{play:{get:()=>super.play}});return _(this,void 0,void 0,(function*(){t!=null&&this.setTime(t);const s=yield i.play.call(this);return e!=null&&(this.media instanceof Z?this.media.stopAt(e):this.stopAtPosition=e),s}))}playPause(){return _(this,void 0,void 0,(function*(){return this.isPlaying()?this.pause():this.play()}))}stop(){this.pause(),this.setTime(0)}skip(t){this.setTime(this.getCurrentTime()+t)}empty(){this.load("",[[0]],.001)}setMediaElement(t){this.unsubscribePlayerEvents(),super.setMediaElement(t),this.initPlayerEvents()}exportImage(){return _(this,arguments,void 0,(function*(t="image/png",e=1,i="dataURL"){return this.renderer.exportImage(t,e,i)}))}destroy(){var t;this.emit("destroy"),(t=this.abortController)===null||t===void 0||t.abort(),this.plugins.forEach((e=>e.destroy())),this.subscriptions.forEach((e=>e())),this.unsubscribePlayerEvents(),this.reactiveCleanups.forEach((e=>e())),this.reactiveCleanups=[],this.timer.destroy(),this.renderer.destroy(),super.destroy()}}I.BasePlugin=class extends j{constructor(u){super(),this.subscriptions=[],this.isDestroyed=!1,this.options=u}onInit(){}_init(u){this.isDestroyed&&(this.subscriptions=[],this.isDestroyed=!1),this.wavesurfer=u,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach((u=>u())),this.subscriptions=[],this.isDestroyed=!0,this.wavesurfer=void 0}},I.dom=vt;const Pt={xmlns:"http://www.w3.org/2000/svg",width:"40",height:"40",class:"icon",viewBox:"0 0 1024 1024"};function Mt(u,t){return A(),$("svg",Pt,[...t[0]||(t[0]=[M("path",{fill:"#409eff",d:"M512 0C229.227 0 0 229.227 0 512s229.227 512 512 512 512-229.227 512-512S794.773 0 512 0m-33.023 704.742c0 34.191-25.028 62.18-55.617 62.18s-55.618-27.975-55.618-62.18V319.258c0-34.19 25.028-62.18 55.618-62.18s55.617 27.975 55.617 62.18zm170.328 0c0 34.191-25.027 62.18-55.617 62.18s-55.617-27.975-55.617-62.18V319.258c0-34.19 25.027-62.18 55.617-62.18s55.617 27.975 55.617 62.18z"},null,-1)])])}const kt={render:Mt},_t={xmlns:"http://www.w3.org/2000/svg",width:"40",height:"40",class:"icon",viewBox:"0 0 1024 1024"};function Rt(u,t){return A(),$("svg",_t,[...t[0]||(t[0]=[M("path",{fill:"#f56c6c",d:"M512 42.667C252.793 42.667 42.667 252.793 42.667 512S252.793 981.333 512 981.333 981.333 771.207 981.333 512 771.207 42.667 512 42.667M708.547 543.16l-266.667 176A37.333 37.333 0 0 1 384 688V336.033a37.333 37.333 0 0 1 57.893-31.16l266.667 176a37.333 37.333 0 0 1 0 62.32z"},null,-1)])])}const Tt={render:Rt},Dt={xmlns:"http://www.w3.org/2000/svg",width:"32",height:"32",class:"icon",viewBox:"0 0 1024 1024"};function Wt(u,t){return A(),$("svg",Dt,[...t[0]||(t[0]=[M("path",{fill:"#409EFF",d:"M515.5 91.5C747.4 91.5 936 280.1 936 512S747.4 932.5 515.5 932.5 95 743.9 95 512 283.6 91.5 515.5 91.5m0-87C235.2 4.5 8 231.7 8 512s227.2 507.5 507.5 507.5S1023 792.3 1023 512 795.8 4.5 515.5 4.5"},null,-1),M("path",{fill:"#81888f",d:"m337.7 450.8 84.1 61.2-84.1 61.2zm-28.8-115c-30.1 0-58.2 23.8-58.2 58.1v236.2c0 34.3 28.1 58.1 58.2 58.1 11.5 0 23.3-3.5 33.9-11.2l162.4-118.1c31.9-23.2 31.9-70.7 0-93.8L342.8 347c-10.6-7.7-22.4-11.2-33.9-11.2"},null,-1),M("path",{fill:"#81888f",d:"m529.1 450.8 84.1 61.2-84.1 61.2zm-28.8-115c-30.1 0-58.2 23.8-58.2 58.1v236.2c0 34.3 28.1 58.1 58.2 58.1 11.5 0 23.3-3.5 33.9-11.2l162.4-118.1c31.9-23.2 31.9-70.7 0-93.8L534.2 347c-10.6-7.7-22.4-11.2-33.9-11.2"},null,-1),M("path",{fill:"#81888f",d:"M736.8 367c-24 0-43.5 19.5-43.5 43.5v203c0 24 19.5 43.5 43.5 43.5s43.5-19.5 43.5-43.5v-203c0-24-19.5-43.5-43.5-43.5"},null,-1)])])}const Lt={render:Wt},At={xmlns:"http://www.w3.org/2000/svg",width:"32",height:"32",class:"icon",viewBox:"0 0 1024 1024"};function Ot(u,t){return A(),$("svg",At,[...t[0]||(t[0]=[M("path",{fill:"#409EFF",d:"M512 90.3c231.9 0 420.5 188.6 420.5 420.5S743.9 931.3 512 931.3 91.5 742.7 91.5 510.8 280.1 90.3 512 90.3m0-87C231.7 3.3 4.5 230.5 4.5 510.8s227.2 507.5 507.5 507.5 507.5-227.2 507.5-507.5S792.3 3.3 512 3.3"},null,-1),M("path",{fill:"#81888f",d:"M689.8 449.7V572l-84.1-61.2zm28.8-115.1c-11.5 0-23.3 3.5-33.9 11.2L522.3 463.9c-31.9 23.2-31.9 70.6 0 93.8l162.4 118.1c10.6 7.7 22.4 11.2 33.9 11.2 30.1 0 58.2-23.8 58.2-58.1V392.7c0-34.3-28.1-58.1-58.2-58.1"},null,-1),M("path",{fill:"#81888f",d:"M498.4 449.7V572l-84.1-61.2zm28.8-115.1c-11.5 0-23.3 3.5-33.9 11.2L330.9 463.9c-31.9 23.2-31.9 70.6 0 93.8l162.4 118.1c10.6 7.7 22.4 11.2 33.9 11.2 30.1 0 58.2-23.8 58.2-58.1V392.7c0-34.3-28.1-58.1-58.2-58.1"},null,-1),M("path",{fill:"#81888f",d:"M290.7 365.8c-24 0-43.5 19.5-43.5 43.5v203c0 24 19.5 43.5 43.5 43.5s43.5-19.5 43.5-43.5v-203c0-24-19.5-43.5-43.5-43.5"},null,-1)])])}const Ht={render:Ot},Nt={VITE_PUBLIC_PATH:"/vue-pure-admin/"},Bt={class:"card-header"},zt={class:"font-medium"},$t={class:"w-8/12 m-auto! mt-[20px]!","element-loading-background":"transparent"},It={class:"flex justify-between"},jt={class:"text-4xl mt-2!"},Ft={class:"text-[#81888f]"},Vt={class:"flex mt-2 w-[180px] justify-around m-auto"},Ut=pt({name:"Wavesurfer",__name:"index",setup(u){const t=B(!0),e=B(null),i=B(),s=B(),n=B(),r=B(),a=B(!1),{VITE_PUBLIC_PATH:l}=Nt,o=`${l}audio/海阔天空.mp3`;function h(){e.value=I.create({container:i.value,height:"auto",waveColor:"rgb(200, 0, 200)",progressColor:"rgb(100, 0, 100)",cursorColor:"rgb(64, 158, 255)",cursorWidth:4,url:o}),e.value.on("decode",()=>t.value=!1),e.value.on("ready",()=>{if(!e.value)return;const{decodedData:p}=e.value;n.value=p.duration;const{m:d,s:m}=st(p.duration);s.value=`${d}:${m}`,e.value.setTime(p.duration/2)}),e.value.on("timeupdate",p=>{if(p>n.value)return;const{m:d,s:m}=st(p);r.value=`${d}:${m}`}),e.value.on("play",()=>a.value=!0),e.value.on("pause",()=>a.value=!1)}return mt(h),ft(()=>{e.value&&(e.value.destroy(),e.value=null)}),(p,d)=>{const m=tt("el-link"),c=tt("el-card"),f=F("tippy"),v=F("longpress"),y=F("motion-pop"),S=F("loading");return A(),G(c,{shadow:"never"},{header:V(()=>[M("div",Bt,[M("span",zt,[d[2]||(d[2]=Y(" 音频可视化,采用开源的 ",-1)),X(m,{href:"https://wavesurfer-js.org/",target:"_blank",style:{margin:"0 4px 5px","font-size":"16px"}},{default:V(()=>[...d[1]||(d[1]=[Y(" wavesurfer.js ",-1)])]),_:1}),d[3]||(d[3]=M("span",{class:"text-[red]"}," (温馨提示:音频默认最大声音,播放时请调低电脑声音,以免影响到您) ",-1))])]),X(m,{class:"mt-2",href:"https://github.com/pure-admin/vue-pure-admin/blob/main/src/views/able/wavesurfer",target:"_blank"},{default:V(()=>[...d[4]||(d[4]=[Y(" 代码位置 src/views/able/wavesurfer ",-1)])]),_:1})]),default:V(()=>[H((A(),$("div",$t,[M("div",{ref_key:"wavesurferRef",ref:i},null,512),H(M("div",It,[d[5]||(d[5]=M("span",{class:"text-[#81888f]"},"00:00",-1)),M("h1",jt,et(r.value),1),M("span",Ft,et(s.value),1)],512),[[it,s.value]]),H(M("div",Vt,[H(X(U(Ht),{class:"cursor-pointer"},null,512),[[f,{content:"快退(可长按)",placement:"bottom"}],[v,()=>{var C;return(C=e.value)==null?void 0:C.skip(-1)},"0:100"]]),H((A(),$("div",{class:"cursor-pointer",onClick:d[0]||(d[0]=C=>{var w;return(w=e.value)==null?void 0:w.playPause()})},[a.value?H((A(),G(U(kt),{key:0},null,512)),[[y]]):H((A(),G(U(Tt),{key:1},null,512)),[[y]])])),[[f,{content:a.value?"暂停":"播放",placement:"bottom"}]]),H(X(U(Lt),{class:"cursor-pointer"},null,512),[[f,{content:"快进(可长按)",placement:"bottom"}],[v,()=>{var C;return(C=e.value)==null?void 0:C.skip(1)},"0:100"]])],512),[[it,s.value]])])),[[S,t.value]])]),_:1})}}});export{Ut as default};