PageSourceSearch

https://mimbres-yourmt3.hf.space/assets/StaticAudio-BTlfLZqT.js

js mimbres-yourmt3.hf.space collected 2026-10-03 10:19:45 UTC 67,185 bytes, 104 lines download raw bytes

vendor: 13,078 bytes, lines 1-17
1import{I as jt}from"./Index-p668Ffoz.js";import{f as He,u as qt}from"./Blocks-BPGBf-rO.js";import{B as Bt}from"./BlockLabel-CeTEM5TI.js";import{E as zt}from"./Empty-tho4TGhF.js";import{S as It}from"./ShareButton-lGFMmkjf.js";import{D as Ut}from"./Download-DVtk-Jv3.js";import{M as nt}from"./Music-CDm0RGMk.js";import{a as xt,P as Ft,T as Xt}from"./Trim-UKwaW4UI.js";import{U as Gt}from"./Undo-CpmTQw3B.js";import{r as ht}from"./file-url-DJfnsB4M.js";import{D as Zt}from"./DownloadLink-CFyuUXrs.js";const{SvelteComponent:Yt,append:Jt,attr:x,detach:Kt,init:Qt,insert:ei,noop:Ue,safe_not_equal:ti,svg_element:ft}=window.__gradio__svelte__internal;function ii(s){let e,t;return{c(){e=ft("svg"),t=ft("path"),x(t,"stroke","currentColor"),x(t,"stroke-width","1.5"),x(t,"stroke-linecap","round"),x(t,"stroke-linejoin","round"),x(t,"d","M21.044 5.704a.6.6 0 0 1 .956.483v11.626a.6.6 0 0 1-.956.483l-7.889-5.813a.6.6 0 0 1 0-.966l7.89-5.813ZM10.044 5.704a.6.6 0 0 1 .956.483v11.626a.6.6 0 0 1-.956.483l-7.888-5.813a.6.6 0 0 1 0-.966l7.888-5.813Z"),x(e,"xmlns","http://www.w3.org/2000/svg"),x(e,"width","24px"),x(e,"height","24px"),x(e,"fill","currentColor"),x(e,"stroke-width","1.5"),x(e,"viewBox","0 0 24 24"),x(e,"color","currentColor")},m(i,n){ei(i,e,n),Jt(e,t)},p:Ue,i:Ue,o:Ue,d(i){i&&Kt(e)}}}class ni extends Yt{constructor(e){super(),Qt(this,e,null,ii,ti,{})}}const{SvelteComponent:si,append:ri,attr:F,detach:oi,init:li,insert:ai,noop:xe,safe_not_equal:ui,svg_element:mt}=window.__gradio__svelte__internal;function di(s){let e,t;return{c(){e=mt("svg"),t=mt("path"),F(t,"stroke","currentColor"),F(t,"stroke-width","1.5"),F(t,"stroke-linecap","round"),F(t,"stroke-linejoin","round"),F(t,"d","M2.956 5.704A.6.6 0 0 0 2 6.187v11.626a.6.6 0 0 0 .956.483l7.889-5.813a.6.6 0 0 0 0-.966l-7.89-5.813ZM13.956 5.704a.6.6 0 0 0-.956.483v11.626a.6.6 0 0 0 .956.483l7.889-5.813a.6.6 0 0 0 0-.966l-7.89-5.813Z"),F(e,"xmlns","http://www.w3.org/2000/svg"),F(e,"width","24px"),F(e,"height","24px"),F(e,"fill","currentColor"),F(e,"stroke-width","1.5"),F(e,"viewBox","0 0 24 24"),F(e,"color","currentColor")},m(i,n){ai(i,e,n),ri(e,t)},p:xe,i:xe,o:xe,d(i){i&&oi(e)}}}class ci extends si{constructor(e){super(),li(this,e,null,di,ui,{})}}const{SvelteComponent:hi,append:Ae,attr:j,detach:fi,init:mi,insert:_i,noop:Fe,safe_not_equal:pi,svg_element:We,text:gi}=window.__gradio__svelte__internal;function vi(s){let e,t,i,n,r;return{c(){e=We("svg"),t=We("title"),i=gi("Low volume"),n=We("path"),r=We("path"),j(n,"d","M19.5 7.5C19.5 7.5 21 9 21 11.5C21 14 19.5 15.5 19.5 15.5"),j(n,"stroke-width","1.5"),j(n,"stroke-linecap","round"),j(n,"stroke-linejoin","round"),j(r,"d","M2 13.8571V10.1429C2 9.03829 2.89543 8.14286 4 8.14286H6.9C7.09569 8.14286 7.28708 8.08544 7.45046 7.97772L13.4495 4.02228C14.1144 3.5839 15 4.06075 15 4.85714V19.1429C15 19.9392 14.1144 20.4161 13.4495 19.9777L7.45046 16.0223C7.28708 15.9146 7.09569 15.8571 6.9 15.8571H4C2.89543 15.8571 2 14.9617 2 13.8571Z"),j(r,"stroke-width","1.5"),j(e,"width","100%"),j(e,"height","100%"),j(e,"viewBox","0 0 24 24"),j(e,"stroke-width","1.5"),j(e,"fill","none"),j(e,"xmlns","http://www.w3.org/2000/svg"),j(e,"stroke","currentColor"),j(e,"color","currentColor")},m(o,u){_i(o,e,u),Ae(e,t),Ae(t,i),Ae(e,n),Ae(e,r)},p:Fe,i:Fe,o:Fe,d(o){o&&fi(e)}}}class bi extends hi{constructor(e){super(),mi(this,e,null,vi,pi,{})}}const{SvelteComponent:wi,append:Le,attr:A,detach:yi,init:ki,insert:Ci,noop:Xe,safe_not_equal:Ei,svg_element:$e,text:Si}=window.__gradio__svelte__internal;function Li(s){let e,t,i,n,r,o;return{c(){e=$e("svg"),t=$e("title"),i=Si("High volume"),n=$e("path"),r=$e("path"),o=$e("path"),A(n,"d","M1 13.8571V10.1429C1 9.03829 1.89543 8.14286 3 8.14286H5.9C6.09569 8.14286 6.28708 8.08544 6.45046 7.97772L12.4495 4.02228C13.1144 3.5839 14 4.06075 14 4.85714V19.1429C14 19.9392 13.1144 20.4161 12.4495 19.9777L6.45046 16.0223C6.28708 15.9146 6.09569 15.8571 5.9 15.8571H3C1.89543 15.8571 1 14.9617 1 13.8571Z"),A(n,"stroke-width","1.5"),A(r,"d","M17.5 7.5C17.5 7.5 19 9 19 11.5C19 14 17.5 15.5 17.5 15.5"),A(r,"stroke-width","1.5"),A(r,"stroke-linecap","round"),A(r,"stroke-linejoin","round"),A(o,"d","M20.5 4.5C20.5 4.5 23 7 23 11.5C23 16 20.5 18.5 20.5 18.5"),A(o,"stroke-width","1.5"),A(o,"stroke-linecap","round"),A(o,"stroke-linejoin","round"),A(e,"width","100%"),A(e,"height","100%"),A(e,"viewBox","0 0 24 24"),A(e,"stroke-width","1.5"),A(e,"fill","none"),A(e,"stroke","currentColor"),A(e,"xmlns","http://www.w3.org/2000/svg"),A(e,"color","currentColor")},m(u,a){Ci(u,e,a),Le(e,t),Le(t,i),Le(e,n),Le(e,r),Le(e,o)},p:Xe,i:Xe,o:Xe,d(u){u&&yi(e)}}}class $i extends wi{constructor(e){super(),ki(this,e,null,Li,Ei,{})}}const{SvelteComponent:Mi,append:ee,attr:T,detach:Di,init:Ri,insert:Pi,noop:Ge,safe_not_equal:Ti,svg_element:te,text:Ai}=window.__gradio__svelte__internal;function Wi(s){let e,t,i,n,r,o,u,a,d;return{c(){e=te("svg"),t=te("title"),i=Ai("Muted volume"),n=te("g"),r=te("path"),o=te("path"),u=te("defs"),a=te("clipPath"),d=te("rect"),T(r,"d","M18 14L20.0005 12M22 10L20.0005 12M20.0005 12L18 10M20.0005 12L22 14"),T(r,"stroke-width","1.5"),T(r,"stroke-linecap","round"),T(r,"stroke-linejoin","round"),T(o,"d","M2 13.8571V10.1429C2 9.03829 2.89543 8.14286 4 8.14286H6.9C7.09569 8.14286 7.28708 8.08544 7.45046 7.97772L13.4495 4.02228C14.1144 3.5839 15 4.06075 15 4.85714V19.1429C15 19.9392 14.1144 20.4161 13.4495 19.9777L7.45046 16.0223C7.28708 15.9146 7.09569 15.8571 6.9 15.8571H4C2.89543 15.8571 2 14.9617 2 13.8571Z"),T(o,"stroke-width","1.5"),T(n,"clip-path","url(#clip0_3173_16686)"),T(d,"width","24"),T(d,"height","24"),T(d,"fill","white"),T(a,"id","clip0_3173_16686"),T(e,"width","100%"),T(e,"height","100%"),T(e,"viewBox","0 0 24 24"),T(e,"stroke-width","1.5"),T(e,"fill","none"),T(e,"xmlns","http://www.w3.org/2000/svg"),T(e,"stroke","currentColor"),T(e,"color","currentColor")},m(l,c){Pi(l,e,c),ee(e,t),ee(t,i),ee(e,n),ee(n,r),ee(n,o),ee(e,u),ee(u,a),ee(a,d)},p:Ge,i:Ge,o:Ge,d(l){l&&Di(e)}}}class zi extends Mi{constructor(e){super(),Ri(this,e,null,Wi,Ti,{})}}var Oi=function(s,e,t,i){function n(r){return r instanceof t?r:new t(function(o){o(r)})}return new(t||(t=Promise))(function(r,o){function u(l){try{d(i.next(l))}catch(c){o(c)}}function a(l){try{d(i.throw(l))}catch(c){o(c)}}function d(l){l.done?r(l.value):n(l.value).then(u,a)}d((i=i.apply(s,e||[])).next())})};function Hi(s,e){return Oi(this,void 0,void 0,function*(){const t=new AudioContext({sampleRate:e});return t.decodeAudioData(s).finally(()=>t.close())})}function Vi(s){const e=s[0];if(e.some(t=>t>1||t<-1)){const t=e.length;let i=0;for(let n=0;n<t;n++){const r=Math.abs(e[n]);r>i&&(i=r)}for(const n of s)for(let r=0;r<t;r++)n[r]/=i}return s}function Ni(s,e){return typeof s[0]=="number"&&(s=[s]),Vi(s),{duration:e,length:s[0].length,sampleRate:s[0].length/e,numberOfChannels:s.length,getChannelData:t=>s?.[t],copyFromChannel:AudioBuffer.prototype.copyFromChannel,copyToChannel:AudioBuffer.prototype.copyToChannel}}const Ze={decode:Hi,createBuffer:Ni};var _t=function(s,e,t,i){function n(r){return r instanceof t?r:new t(function(o){o(r)})}return new(t||(t=Promise))(function(r,o){function u(l){try{d(i.next(l))}catch(c){o(c)}}function a(l){try{d(i.throw(l))}catch(c){o(c)}}function d(l){l.done?r(l.value):n(l.value).then(u,a)}d((i=i.apply(s,e||[])).next())})};function ji(s,e,t){var i,n;return _t(this,void 0,void 0,function*(){const r=yield fetch(s,t);{const o=(i=r.clone().body)===null||i===void 0?void 0:i.getReader(),u=Number((n=r.headers)===null||n===void 0?void 0:n.get("Content-Length"));let a=0;const d=(l,c)=>_t(this,void 0,void 0,function*(){if(l)return;a+=c?.length||0;const m=Math.round(a/u*100);return e(m),o?.read().then(({done:p,value:_})=>d(p,_))});o?.read().then(({done:l,value:c})=>d(l,c))}return r.blob()})}const qi={fetchBlob:ji};class je{constructor(){this.listeners={},this.on=this.addEventListener,this.un=this.removeEventListener}addEventListener(e,t,i){if(this.listeners[e]||(this.listeners[e]=new Set),this.listeners[e].add(t),i?.once){const n=()=>{this.removeEventListener(e,n),this.removeEventListener(e,t)};return this.addEventListener(e,n),n}return()=>this.removeEventListener(e,t)}removeEventListener(e,t){var i;(i=this.listeners[e])===null||i===void 0||i.delete(t)}once(e,t){return this.on(e,t,{once:!0})}unAll(){this.listeners={}}emit(e,...t){this.listeners[e]&&this.listeners[e].forEach(i=>i(...t))}}class Bi extends je{constructor(e){super(),this.isExternalMedia=!1,e.media?(this.media=e.media,this.isExternalMedia=!0):this.media=document.createElement("audio"),e.mediaControls&&(this.media.controls=!0),e.autoplay&&(this.media.autoplay=!0),e.playbackRate!=null&&this.onceMediaEvent("canplay",()=>{e.playbackRate!=null&&(this.media.playbackRate=e.playbackRate)})}onMediaEvent(e,t,i){return this.media.addEventListener(e,t,i),()=>this.media.removeEventListener(e,t)}onceMediaEvent(e,t){return this.onMediaEvent(e,t,{once:!0})}getSrc(){return this.media.currentSrc||this.media.src||""}revokeSrc(){const e=this.getSrc();e.startsWith("blob:")&&URL.revokeObjectURL(e)}setSrc(e,t){if(this.getSrc()===e)return;this.revokeSrc();const n=t instanceof Blob?URL.createObjectURL(t):e;this.media.src=n,this.media.load()}destroy(){this.media.pause(),!this.isExternalMedia&&(this.media.remove(),this.revokeSrc(),this.media.src="",this.media.load())}setMediaElement(e){this.media=e}play(){return this.media.play()}pause(){this.media.pause()}isPlaying(){return!this.media.paused&&!this.media.ended}setTime(e){this.media.currentTime=e}getDuration(){return this.media.duration}getCurrentTime(){return this.media.currentTime}getVolume(){return this.media.volume}setVolume(e){this.media.volume=e}getMuted(){return this.media.muted}setMuted(e){this.media.muted=e}getPlaybackRate(){return this.media.playbackRate}setPlaybackRate(e,t){t!=null&&(this.media.preservesPitch=t),this.media.playbackRate=e}getMediaElement(){return this.media}setSinkId(e){return this.media.setSinkId(e)}}function Ii(s,e,t,i,n=5){let r=()=>{};if(!s)return r;const o=u=>{if(u.button===2)return;u.preventDefault(),u.stopPropagation(),s.style.touchAction="none";let a=u.clientX,d=u.clientY,l=!1;const c=_=>{_.preventDefault(),_.stopPropagation();const g=_.clientX,w=_.clientY;if(l||Math.abs(g-a)>=n||Math.abs(w-d)>=n){const{left:b,top:C}=s.getBoundingClientRect();l||(l=!0,t?.(a-b,d-C)),e(g-a,w-d,g-b,w-C),a=g,d=w}},m=_=>{l&&(_.preventDefault(),_.stopPropagation())},p=()=>{s.style.touchAction="",l&&i?.(),r()};document.addEventListener("pointermove",c),document.addEventListener("pointerup",p),document.addEventListener("pointerleave",p),document.addEventListener("click",m,!0),r=()=>{document.removeEventListener("pointermove",c),document.removeEventListener("pointerup",p),document.removeEventListener("pointerleave",p),setTimeout(()=>{document.removeEventListener("click",m,!0)},10)}};return s.addEventListener("pointerdown",o),()=>{r(),s.removeEventListener("pointerdown",o)}}class qe extends je{constructor(e,t){super(),this.timeouts=[],this.isScrolling=!1,this.audioData=null,this.resizeObserver=null,this.isDragging=!1,this.options=e;const i=this.parentFromOptionsContainer(e.container);this.parent=i;const[n,r]=this.initHtml();i.appendChild(n),this.container=n,this.scrollContainer=r.querySelector(".scroll"),this.wrapper=r.querySelector(".wrapper"),this.canvasWrapper=r.querySelector(".canvases"),this.progressWrapper=r.querySelector(".progress"),this.cursor=r.querySelector(".cursor"),t&&r.appendChild(t),this.initEvents()}parentFromOptionsContainer(e){let t;if(typeof e=="string"?t=document.querySelector(e):e instanceof HTMLElement&&(t=e),!t)throw new Error("Container not found");return t}initEvents(){const e=i=>{const n=this.wrapper.getBoundingClientRect(),r=i.clientX-n.left,o=i.clientX-n.left,u=r/n.width,a=o/n.height;return[u,a]};this.wrapper.addEventListener("click",i=>{const[n,r]=e(i);this.emit("click",n,r)}),this.wrapper.addEventListener("dblclick",i=>{const[n,r]=e(i);this.emit("dblclick",n,r)}),this.options.dragToSeek&&this.initDrag(),this.scrollContainer.addEventListener("scroll",()=>{const{scrollLeft:i,scrollWidth:n,clientWidth:r}=this.scrollContainer,o=i/n,u=(i+r)/n;this.emit("scroll",o,u)});const t=this.createDelay(100);this.resizeObserver=new ResizeObserver(()=>{t(()=>this.reRender())}),this.resizeObserver.observe(this.scrollContainer)}initDrag(){Ii(this.wrapper,(e,t,i)=>{this.emit("drag",Math.max(0,Math.min(1,i/this.wrapper.getBoundingClientRect().width)))},()=>this.isDragging=!0,()=>this.isDragging=!1)}getHeight(){return this.options.height==null?128:isNaN(Number(this.options.height))?this.options.height==="auto"&&this.parent.clientHeight||128:Number(this.options.height)}initHtml(){const e=document.createElement("div"),t=e.attachShadow({mode:"open"});return t.innerHTML=`
2      <style>
3        :host {
4          user-select: none;
5          min-width: 1px;
6        }
7        :host audio {
8          display: block;
9          width: 100%;
10        }
11        :host .scroll {
12          overflow-x: auto;
13          overflow-y: hidden;
14          width: 100%;
15          position: relative;
16        }
17        :host .noScrollbar {
18          scrollbar-color: transparent;
19          scrollbar-width: none;
20        }
21        :host .noScrollbar::-webkit-scrollbar {
22          display: none;
23          -webkit-appearance: none;
24        }
25        :host .wrapper {
26          position: relative;
27          overflow: visible;
28          z-index: 2;
29        }
30        :host .canvases {
31          min-height: ${this.getHeight()}px;
32        }
33        :host .canvases > div {
34          position: relative;
35        }
36        :host canvas {
37          display: block;
38          position: absolute;
39          top: 0;
40          image-rendering: pixelated;
41        }
42        :host .progress {
43          pointer-events: none;
44          position: absolute;
45          z-index: 2;
46          top: 0;
47          left: 0;
48          width: 0;
49          height: 100%;
50          overflow: hidden;
51        }
52        :host .progress > div {
53          position: relative;
54        }
55        :host .cursor {
56          pointer-events: none;
57          position: absolute;
58          z-index: 5;
59          top: 0;
60          left: 0;
61          height: 100%;
62          border-radius: 2px;
63        }
64      </style>
65
66      <div class="scroll" part="scroll">
67        <div class="wrapper" part="wrapper">
68          <div class="canvases"></div>
69          <div class="progress" part="progress"></div>
70          <div class="cursor" part="cursor"></div>
71        </div>
72      </div>
73    `,[e,t]}setOptions(e){if(this.options.container!==e.container){const t=this.parentFromOptionsContainer(e.container);t.appendChild(this.container),this.parent=t}e.dragToSeek&&!this.options.dragToSeek&&this.initDrag(),this.options=e,this.reRender()}getWrapper(){return this.wrapper}getScroll(){return this.scrollContainer.scrollLeft}destroy(){var e;this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect()}createDelay(e=10){const t={};return this.timeouts.push(t),i=>{t.timeout&&clearTimeout(t.timeout),t.timeout=setTimeout(i,e)}}convertColorValues(e){if(!Array.isArray(e))return e||"";if(e.length<2)return e[0]||"";const t=document.createElement("canvas"),n=t.getContext("2d").createLinearGradient(0,0,0,t.height),r=1/(e.length-1);return e.forEach((o,u)=>{const a=u*r;n.addColorStop(a,o)}),n}renderBarWaveform(e,t,i,n){const r=e[0],o=e[1]||e[0],u=r.length,{width:a,height:d}=i.canvas,l=d/2,c=window.devicePixelRatio||1,m=t.barWidth?t.barWidth*c:1,p=t.barGap?t.barGap*c:t.barWidth?m/2:0,_=t.barRadius||0,g=a/(m+p)/u,w=_&&"roundRect"in i?"roundRect":"rect";i.beginPath();let b=0,C=0,E=0;for(let k=0;k<=u;k++){const h=Math.round(k*g);if(h>b){const D=Math.round(C*l*n),U=Math.round(E*l*n),J=D+U||1;let B=l-D;t.barAlign==="top"?B=0:t.barAlign==="bottom"&&(B=d-J),i[w](b*(m+p),B,m,J,_),b=h,C=0,E=0}const S=Math.abs(r[k]||0),L=Math.abs(o[k]||0);S>C&&(C=S),L>E&&(E=L)}i.fill(),i.closePath()}renderLineWaveform(e,t,i,n){const r=o=>{const u=e[o]||e[0],a=u.length,{height:d}=i.canvas,l=d/2,c=i.canvas.width/a;i.moveTo(0,l);let m=0,p=0;for(let _=0;_<=a;_++){const g=Math.round(_*c);if(g>m){const b=Math.round(p*l*n)||1,C=l+b*(o===0?-1:1);i.lineTo(m,C),m=g,p=0}const w=Math.abs(u[_]||0);w>p&&(p=w)}i.lineTo(m,l)};i.beginPath(),r(0),r(1),i.fill(),i.closePath()}renderWaveform(e,t,i){if(i.fillStyle=this.convertColorValues(t.waveColor),t.renderFunction){t.renderFunction(e,i);return}let n=t.barHeight||1;if(t.normalize){const r=Array.from(e[0]).reduce((o,u)=>Math.max(o,Math.abs(u)),0);n=r?1/r:1}if(t.barWidth||t.barGap||t.barAlign){this.renderBarWaveform(e,t,i,n);return}this.renderLineWaveform(e,t,i,n)}renderSingleCanvas(e,t,i,n,r,o,u,a){const d=window.devicePixelRatio||1,l=document.createElement("canvas"),c=e[0].length;l.width=Math.round(i*(o-r)/c),l.height=n*d,l.style.width=`${Math.floor(l.width/d)}px`,l.style.height=`${n}px`,l.style.left=`${Math.floor(r*i/d/c)}px`,u.appendChild(l);const m=l.getContext("2d");if(this.renderWaveform(e.map(p=>p.slice(r,o)),t,m),l.width>0&&l.height>0){const p=l.cloneNode(),_=p.getContext("2d");_.drawImage(l,0,0),_.globalCompositeOperation="source-in",_.fillStyle=this.convertColorValues(t.progressColor),_.fillRect(0,0,l.width,l.height),a.appendChild(p)}}renderChannel(e,t,i){const n=document.createElement("div"),r=this.getHeight();n.style.height=`${r}px`,this.canvasWrapper.style.minHeight=`${r}px`,this.canvasWrapper.appendChild(n);const o=n.cloneNode();this.progressWrapper.appendChild(o);const{scrollLeft:u,scrollWidth:a,clientWidth:d}=this.scrollContainer,l=e[0].length,c=l/a;let m=Math.min(qe.MAX_CANVAS_WIDTH,d);if(t.barWidth||t.barGap){const h=t.barWidth||.5,S=t.barGap||h/2,L=h+S;m%L!==0&&(m=Math.floor(m/L)*L)}const p=Math.floor(Math.abs(u)*c),_=Math.floor(p+m*c),g=_-p,w=(h,S)=>{this.renderSingleCanvas(e,t,i,r,Math.max(0,h),Math.min(S,l),n,o)},b=this.createDelay(),C=this.createDelay(),E=(h,S)=>
vendor: 35,751 bytes, lines 73-103
73{w(h,S),h>0&&b(()=>{E(h-g,S-g)})},k=(h,S)=>{w(h,S),S<l&&C(()=>{k(h+g,S+g)})};E(p,_),_<l&&k(_,_+g)}render(e){this.timeouts.forEach(u=>u.timeout&&clearTimeout(u.timeout)),this.timeouts=[],this.canvasWrapper.innerHTML="",this.progressWrapper.innerHTML="",this.wrapper.style.width="",this.options.width!=null&&(this.scrollContainer.style.width=typeof this.options.width=="number"?`${this.options.width}px`:this.options.width);const t=window.devicePixelRatio||1,i=this.scrollContainer.clientWidth,n=Math.ceil(e.duration*(this.options.minPxPerSec||0));this.isScrolling=n>i;const r=this.options.fillParent&&!this.isScrolling,o=(r?i:n)*t;if(this.wrapper.style.width=r?"100%":`${n}px`,this.scrollContainer.style.overflowX=this.isScrolling?"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.options.splitChannels)for(let u=0;u<e.numberOfChannels;u++){const a=Object.assign(Object.assign({},this.options),this.options.splitChannels[u]);this.renderChannel([e.getChannelData(u)],a,o)}else{const u=[e.getChannelData(0)];e.numberOfChannels>1&&u.push(e.getChannelData(1)),this.renderChannel(u,this.options,o)}this.audioData=e,this.emit("render")}reRender(){if(!this.audioData)return;const e=this.progressWrapper.clientWidth;this.render(this.audioData);const t=this.progressWrapper.clientWidth;this.scrollContainer.scrollLeft+=t-e}zoom(e){this.options.minPxPerSec=e,this.reRender()}scrollIntoView(e,t=!1){const{clientWidth:i,scrollLeft:n,scrollWidth:r}=this.scrollContainer,o=r*e,u=i/2,a=t&&this.options.autoCenter&&!this.isDragging?u:i;if(o>n+a||o<n)if(this.options.autoCenter&&!this.isDragging){const d=u/20;o-(n+u)>=d&&o<n+i?this.scrollContainer.scrollLeft+=d:this.scrollContainer.scrollLeft=o-u}else this.isDragging?this.scrollContainer.scrollLeft=o<n?o-10:o-i+10:this.scrollContainer.scrollLeft=o;{const{scrollLeft:d}=this.scrollContainer,l=d/r,c=(d+i)/r;this.emit("scroll",l,c)}}renderProgress(e,t){if(isNaN(e))return;const i=e*100;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.marginLeft=Math.round(i)===100?`-${this.options.cursorWidth}px`:"",this.isScrolling&&this.options.autoScroll&&this.scrollIntoView(e,t)}}qe.MAX_CANVAS_WIDTH=4e3;class Ui extends je{constructor(){super(...arguments),this.unsubscribe=()=>{}}start(){this.unsubscribe=this.on("tick",()=>{requestAnimationFrame(()=>{this.emit("tick")})}),this.emit("tick")}stop(){this.unsubscribe()}destroy(){this.unsubscribe()}}var Ye=function(s,e,t,i){function n(r){return r instanceof t?r:new t(function(o){o(r)})}return new(t||(t=Promise))(function(r,o){function u(l){try{d(i.next(l))}catch(c){o(c)}}function a(l){try{d(i.throw(l))}catch(c){o(c)}}function d(l){l.done?r(l.value):n(l.value).then(u,a)}d((i=i.apply(s,e||[])).next())})};class xi extends je{constructor(e=new AudioContext){super(),this.bufferNode=null,this.autoplay=!1,this.playStartTime=0,this.playedDuration=0,this._muted=!1,this.buffer=null,this.currentSrc="",this.paused=!0,this.crossOrigin=null,this.audioContext=e,this.gainNode=this.audioContext.createGain(),this.gainNode.connect(this.audioContext.destination)}load(){return Ye(this,void 0,void 0,function*(){})}get src(){return this.currentSrc}set src(e){this.currentSrc=e,fetch(e).then(t=>t.arrayBuffer()).then(t=>this.audioContext.decodeAudioData(t)).then(t=>{this.buffer=t,this.emit("loadedmetadata"),this.emit("canplay"),this.autoplay&&this.play()})}_play(){var e;this.paused&&(this.paused=!1,(e=this.bufferNode)===null||e===void 0||e.disconnect(),this.bufferNode=this.audioContext.createBufferSource(),this.bufferNode.buffer=this.buffer,this.bufferNode.connect(this.gainNode),this.playedDuration>=this.duration&&(this.playedDuration=0),this.bufferNode.start(this.audioContext.currentTime,this.playedDuration),this.playStartTime=this.audioContext.currentTime,this.bufferNode.onended=()=>{this.currentTime>=this.duration&&(this.pause(),this.emit("ended"))})}_pause(){var e;this.paused||(this.paused=!0,(e=this.bufferNode)===null||e===void 0||e.stop(),this.playedDuration+=this.audioContext.currentTime-this.playStartTime)}play(){return Ye(this,void 0,void 0,function*(){this._play(),this.emit("play")})}pause(){this._pause(),this.emit("pause")}setSinkId(e){return Ye(this,void 0,void 0,function*(){return this.audioContext.setSinkId(e)})}get playbackRate(){var e,t;return(t=(e=this.bufferNode)===null||e===void 0?void 0:e.playbackRate.value)!==null&&t!==void 0?t:1}set playbackRate(e){this.bufferNode&&(this.bufferNode.playbackRate.value=e)}get currentTime(){return this.paused?this.playedDuration:this.playedDuration+this.audioContext.currentTime-this.playStartTime}set currentTime(e){this.emit("seeking"),this.paused?this.playedDuration=e:(this._pause(),this.playedDuration=e,this._play()),this.emit("timeupdate")}get duration(){var e;return((e=this.buffer)===null||e===void 0?void 0:e.duration)||0}get volume(){return this.gainNode.gain.value}set volume(e){this.gainNode.gain.value=e,this.emit("volumechange")}get muted(){return this._muted}set muted(e){this._muted!==e&&(this._muted=e,this._muted?this.gainNode.disconnect():this.gainNode.connect(this.audioContext.destination))}getGainNode(){return this.gainNode}}var be=function(s,e,t,i){function n(r){return r instanceof t?r:new t(function(o){o(r)})}return new(t||(t=Promise))(function(r,o){function u(l){try{d(i.next(l))}catch(c){o(c)}}function a(l){try{d(i.throw(l))}catch(c){o(c)}}function d(l){l.done?r(l.value):n(l.value).then(u,a)}d((i=i.apply(s,e||[])).next())})};const Fi={waveColor:"#999",progressColor:"#555",cursorWidth:1,minPxPerSec:0,fillParent:!0,interact:!0,dragToSeek:!1,autoScroll:!0,autoCenter:!0,sampleRate:8e3};class st extends Bi{static create(e){return new st(e)}constructor(e){const t=e.media||(e.backend==="WebAudio"?new xi:void 0);super({media:t,mediaControls:e.mediaControls,autoplay:e.autoplay,playbackRate:e.audioRate}),this.plugins=[],this.decodedData=null,this.subscriptions=[],this.mediaSubscriptions=[],this.options=Object.assign({},Fi,e),this.timer=new Ui;const i=t?void 0:this.getMediaElement();this.renderer=new qe(this.options,i),this.initPlayerEvents(),this.initRendererEvents(),this.initTimerEvents(),this.initPlugins();const n=this.options.url||this.getSrc();n?this.load(n,this.options.peaks,this.options.duration):this.options.peaks&&this.options.duration&&this.loadPredecoded()}initTimerEvents(){this.subscriptions.push(this.timer.on("tick",()=>{const e=this.getCurrentTime();this.renderer.renderProgress(e/this.getDuration(),!0),this.emit("timeupdate",e),this.emit("audioprocess",e)}))}initPlayerEvents(){this.mediaSubscriptions.push(this.onMediaEvent("timeupdate",()=>{const e=this.getCurrentTime();this.renderer.renderProgress(e/this.getDuration(),this.isPlaying()),this.emit("timeupdate",e)}),this.onMediaEvent("play",()=>{this.emit("play"),this.timer.start()}),this.onMediaEvent("pause",()=>{this.emit("pause"),this.timer.stop()}),this.onMediaEvent("emptied",()=>{this.timer.stop()}),this.onMediaEvent("ended",()=>{this.emit("finish")}),this.onMediaEvent("seeking",()=>{this.emit("seeking",this.getCurrentTime())}))}initRendererEvents(){this.subscriptions.push(this.renderer.on("click",(e,t)=>{this.options.interact&&(this.seekTo(e),this.emit("interaction",e*this.getDuration()),this.emit("click",e,t))}),this.renderer.on("dblclick",(e,t)=>{this.emit("dblclick",e,t)}),this.renderer.on("scroll",(e,t)=>{const i=this.getDuration();this.emit("scroll",e*i,t*i)}),this.renderer.on("render",()=>{this.emit("redraw")}));{let e;this.subscriptions.push(this.renderer.on("drag",t=>{this.options.interact&&(this.renderer.renderProgress(t),clearTimeout(e),e=setTimeout(()=>{this.seekTo(t)},this.isPlaying()?0:200),this.emit("interaction",t*this.getDuration()),this.emit("drag",t))}))}}initPlugins(){var e;!((e=this.options.plugins)===null||e===void 0)&&e.length&&this.options.plugins.forEach(t=>{this.registerPlugin(t)})}unsubscribePlayerEvents(){this.mediaSubscriptions.forEach(e=>e()),this.mediaSubscriptions=[]}setOptions(e){this.options=Object.assign({},this.options,e),this.renderer.setOptions(this.options),e.audioRate&&this.setPlaybackRate(e.audioRate),e.mediaControls!=null&&(this.getMediaElement().controls=e.mediaControls)}registerPlugin(e){return e.init(this),this.plugins.push(e),this.subscriptions.push(e.once("destroy",()=>{this.plugins=this.plugins.filter(t=>t!==e)})),e}getWrapper(){return this.renderer.getWrapper()}getScroll(){return this.renderer.getScroll()}getActivePlugins(){return this.plugins}loadPredecoded(){return be(this,void 0,void 0,function*(){this.options.peaks&&this.options.duration&&(this.decodedData=Ze.createBuffer(this.options.peaks,this.options.duration),yield Promise.resolve(),this.renderDecoded())})}renderDecoded(){return be(this,void 0,void 0,function*(){this.decodedData&&(this.emit("decode",this.getDuration()),this.renderer.render(this.decodedData))})}loadAudio(e,t,i,n){return be(this,void 0,void 0,function*(){if(this.emit("load",e),!this.options.media&&this.isPlaying()&&this.pause(),this.decodedData=null,!t&&!i){const r=o=>this.emit("loading",o);t=yield qi.fetchBlob(e,r,this.options.fetchParams)}if(this.setSrc(e,t),n=(yield Promise.resolve(n||this.getDuration()))||(yield new Promise(r=>{this.onceMediaEvent("loadedmetadata",()=>r(this.getDuration()))}))||(yield Promise.resolve(0)),i)this.decodedData=Ze.createBuffer(i,n);else if(t){const r=yield t.arrayBuffer();this.decodedData=yield Ze.decode(r,this.options.sampleRate)}this.renderDecoded(),this.emit("ready",this.getDuration())})}load(e,t,i){return be(this,void 0,void 0,function*(){yield this.loadAudio(e,void 0,t,i)})}loadBlob(e,t,i){return be(this,void 0,void 0,function*(){yield this.loadAudio("blob",e,t,i)})}zoom(e){if(!this.decodedData)throw new Error("No audio loaded");this.renderer.zoom(e),this.emit("zoom",e)}getDecodedData(){return this.decodedData}exportPeaks({channels:e=2,maxLength:t=8e3,precision:i=1e4}={}){if(!this.decodedData)throw new Error("The audio has not been decoded yet");const n=Math.min(e,this.decodedData.numberOfChannels),r=[];for(let o=0;o<n;o++){const u=this.decodedData.getChannelData(o),a=[],d=Math.round(u.length/t);for(let l=0;l<t;l++){const c=u.slice(l*d,(l+1)*d),m=Math.max(...c);a.push(Math.round(m*i)/i)}r.push(a)}return r}getDuration(){let e=super.getDuration()||0;return(e===0||e===1/0)&&this.decodedData&&(e=this.decodedData.duration),e}toggleInteraction(e){this.options.interact=e}seekTo(e){const t=this.getDuration()*e;this.setTime(t)}playPause(){return be(this,void 0,void 0,function*(){return this.isPlaying()?this.pause():this.play()})}stop(){this.pause(),this.setTime(0)}skip(e){this.setTime(this.getCurrentTime()+e)}empty(){this.load("",[[0]],.001)}setMediaElement(e){this.unsubscribePlayerEvents(),super.setMediaElement(e),this.initPlayerEvents()}destroy(){this.emit("destroy"),this.plugins.forEach(e=>e.destroy()),this.subscriptions.forEach(e=>e()),this.unsubscribePlayerEvents(),this.timer.destroy(),this.renderer.destroy(),super.destroy()}}function Xi(s){const e=s.numberOfChannels,t=s.length*e*2+44,i=new ArrayBuffer(t),n=new DataView(i);let r=0;const o=function(u,a,d){for(let l=0;l<d.length;l++)u.setUint8(a+l,d.charCodeAt(l))};o(n,r,"RIFF"),r+=4,n.setUint32(r,t-8,!0),r+=4,o(n,r,"WAVE"),r+=4,o(n,r,"fmt "),r+=4,n.setUint32(r,16,!0),r+=4,n.setUint16(r,1,!0),r+=2,n.setUint16(r,e,!0),r+=2,n.setUint32(r,s.sampleRate,!0),r+=4,n.setUint32(r,s.sampleRate*2*e,!0),r+=4,n.setUint16(r,e*2,!0),r+=2,n.setUint16(r,16,!0),r+=2,o(n,r,"data"),r+=4,n.setUint32(r,s.length*e*2,!0),r+=4;for(let u=0;u<s.length;u++)for(let a=0;a<e;a++){const d=Math.max(-1,Math.min(1,s.getChannelData(a)[u]));n.setInt16(r,d*32767,!0),r+=2}return new Uint8Array(i)}const Gi=async(s,e,t,i)=>{const n=new AudioContext({sampleRate:i||s.sampleRate}),r=s.numberOfChannels,o=i||s.sampleRate;let u=s.length,a=0;e&&t&&(a=Math.round(e*o),u=Math.round(t*o)-a);const d=n.createBuffer(r,u,o);for(let l=0;l<r;l++){const c=s.getChannelData(l),m=d.getChannelData(l);for(let p=0;p<u;p++)m[p]=c[a+p]}return Xi(d)},pt=(s,e)=>{s&&s.skip(e)},ke=(s,e)=>(e||(e=5),s/100*e||5);class Ot{constructor(){this.listeners={},this.on=this.addEventListener,this.un=this.removeEventListener}addEventListener(e,t,i){if(this.listeners[e]||(this.listeners[e]=new Set),this.listeners[e].add(t),i?.once){const n=()=>{this.removeEventListener(e,n),this.removeEventListener(e,t)};return this.addEventListener(e,n),n}return()=>this.removeEventListener(e,t)}removeEventListener(e,t){var i;(i=this.listeners[e])===null||i===void 0||i.delete(t)}once(e,t){return this.on(e,t,{once:!0})}unAll(){this.listeners={}}emit(e,...t){this.listeners[e]&&this.listeners[e].forEach(i=>i(...t))}}class Zi extends Ot{constructor(e){super(),this.subscriptions=[],this.options=e}onInit(){}init(e){this.wavesurfer=e,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach(e=>e())}}function Oe(s,e,t,i,n=5){let r=()=>{};if(!s)return r;const o=u=>{if(u.button===2)return;u.preventDefault(),u.stopPropagation(),s.style.touchAction="none";let a=u.clientX,d=u.clientY,l=!1;const c=_=>{_.preventDefault(),_.stopPropagation();const g=_.clientX,w=_.clientY;if(l||Math.abs(g-a)>=n||Math.abs(w-d)>=n){const{left:b,top:C}=s.getBoundingClientRect();l||(l=!0,t?.(a-b,d-C)),e(g-a,w-d,g-b,w-C),a=g,d=w}},m=_=>{l&&(_.preventDefault(),_.stopPropagation())},p=()=>{s.style.touchAction="",l&&i?.(),r()};document.addEventListener("pointermove",c),document.addEventListener("pointerup",p),document.addEventListener("pointerleave",p),document.addEventListener("click",m,!0),r=()=>{document.removeEventListener("pointermove",c),document.removeEventListener("pointerup",p),document.removeEventListener("pointerleave",p),setTimeout(()=>{document.removeEventListener("click",m,!0)},10)}};return s.addEventListener("pointerdown",o),()=>{r(),s.removeEventListener("pointerdown",o)}}class gt extends Ot{constructor(e,t,i=0){var n,r,o,u,a,d,l;super(),this.totalDuration=t,this.numberOfChannels=i,this.minLength=0,this.maxLength=1/0,this.id=e.id||`region-${Math.random().toString(32).slice(2)}`,this.start=this.clampPosition(e.start),this.end=this.clampPosition((n=e.end)!==null&&n!==void 0?n:e.start),this.drag=(r=e.drag)===null||r===void 0||r,this.resize=(o=e.resize)===null||o===void 0||o,this.color=(u=e.color)!==null&&u!==void 0?u:"rgba(0, 0, 0, 0.1)",this.minLength=(a=e.minLength)!==null&&a!==void 0?a:this.minLength,this.maxLength=(d=e.maxLength)!==null&&d!==void 0?d:this.maxLength,this.channelIdx=(l=e.channelIdx)!==null&&l!==void 0?l:-1,this.element=this.initElement(),this.setContent(e.content),this.setPart(),this.renderPosition(),this.initMouseEvents()}clampPosition(e){return Math.max(0,Math.min(this.totalDuration,e))}setPart(){const e=this.start===this.end;this.element.setAttribute("part",`${e?"marker":"region"} ${this.id}`)}addResizeHandles(e){const t=document.createElement("div");t.setAttribute("data-resize","left"),t.setAttribute("style",`
74        position: absolute;
75        z-index: 2;
76        width: 6px;
77        height: 100%;
78        top: 0;
79        left: 0;
80        border-left: 2px solid rgba(0, 0, 0, 0.5);
81        border-radius: 2px 0 0 2px;
82        cursor: ew-resize;
83        word-break: keep-all;
84      `),t.setAttribute("part","region-handle region-handle-left");const i=t.cloneNode();i.setAttribute("data-resize","right"),i.style.left="",i.style.right="0",i.style.borderRight=i.style.borderLeft,i.style.borderLeft="",i.style.borderRadius="0 2px 2px 0",i.setAttribute("part","region-handle region-handle-right"),e.appendChild(t),e.appendChild(i),Oe(t,n=>this.onResize(n,"start"),()=>null,()=>this.onEndResizing(),1),Oe(i,n=>this.onResize(n,"end"),()=>null,()=>this.onEndResizing(),1)}removeResizeHandles(e){const t=e.querySelector('[data-resize="left"]'),i=e.querySelector('[data-resize="right"]');t&&e.removeChild(t),i&&e.removeChild(i)}initElement(){const e=document.createElement("div"),t=this.start===this.end;let i=0,n=100;return this.channelIdx>=0&&this.channelIdx<this.numberOfChannels&&(n=100/this.numberOfChannels,i=n*this.channelIdx),e.setAttribute("style",`
85      position: absolute;
86      top: ${i}%;
87      height: ${n}%;
88      background-color: ${t?"none":this.color};
89      border-left: ${t?"2px solid "+this.color:"none"};
90      border-radius: 2px;
91      box-sizing: border-box;
92      transition: background-color 0.2s ease;
93      cursor: ${this.drag?"grab":"default"};
94      pointer-events: all;
95    `),!t&&this.resize&&this.addResizeHandles(e),e}renderPosition(){const e=this.start/this.totalDuration,t=(this.totalDuration-this.end)/this.totalDuration;this.element.style.left=100*e+"%",this.element.style.right=100*t+"%"}initMouseEvents(){const{element:e}=this;e&&(e.addEventListener("click",t=>this.emit("click",t)),e.addEventListener("mouseenter",t=>this.emit("over",t)),e.addEventListener("mouseleave",t=>this.emit("leave",t)),e.addEventListener("dblclick",t=>this.emit("dblclick",t)),Oe(e,t=>this.onMove(t),()=>this.onStartMoving(),()=>this.onEndMoving()))}onStartMoving(){this.drag&&(this.element.style.cursor="grabbing")}onEndMoving(){this.drag&&(this.element.style.cursor="grab",this.emit("update-end"))}_onUpdate(e,t){if(!this.element.parentElement)return;const i=e/this.element.parentElement.clientWidth*this.totalDuration,n=t&&t!=="start"?this.start:this.start+i,r=t&&t!=="end"?this.end:this.end+i,o=r-n;n>=0&&r<=this.totalDuration&&n<=r&&o>=this.minLength&&o<=this.maxLength&&(this.start=n,this.end=r,this.renderPosition(),this.emit("update"))}onMove(e){this.drag&&this._onUpdate(e)}onResize(e,t){this.resize&&this._onUpdate(e,t)}onEndResizing(){this.resize&&this.emit("update-end")}_setTotalDuration(e){this.totalDuration=e,this.renderPosition()}play(){this.emit("play")}setContent(e){var t;if((t=this.content)===null||t===void 0||t.remove(),e){if(typeof e=="string"){this.content=document.createElement("div");const i=this.start===this.end;this.content.style.padding=`0.2em ${i?.2:.4}em`,this.content.textContent=e}else this.content=e;this.content.setAttribute("part","region-content"),this.element.appendChild(this.content)}else this.content=void 0}setOptions(e){var t,i;if(e.color&&(this.color=e.color,this.element.style.backgroundColor=this.color),e.drag!==void 0&&(this.drag=e.drag,this.element.style.cursor=this.drag?"grab":"default"),e.start!==void 0||e.end!==void 0){const n=this.start===this.end;this.start=this.clampPosition((t=e.start)!==null&&t!==void 0?t:this.start),this.end=this.clampPosition((i=e.end)!==null&&i!==void 0?i:n?this.start:this.end),this.renderPosition(),this.setPart()}if(e.content&&this.setContent(e.content),e.id&&(this.id=e.id,this.setPart()),e.resize!==void 0&&e.resize!==this.resize){const n=this.start===this.end;this.resize=e.resize,this.resize&&!n?this.addResizeHandles(this.element):this.removeResizeHandles(this.element)}}remove(){this.emit("remove"),this.element.remove(),this.element=null}}class rt extends Zi{constructor(e){super(e),this.regions=[],this.regionsContainer=this.initRegionsContainer()}static create(e){return new rt(e)}onInit(){if(!this.wavesurfer)throw Error("WaveSurfer is not initialized");this.wavesurfer.getWrapper().appendChild(this.regionsContainer);let e=[];this.subscriptions.push(this.wavesurfer.on("timeupdate",t=>{const i=this.regions.filter(n=>n.start<=t&&n.end>=t);i.forEach(n=>{e.includes(n)||this.emit("region-in",n)}),e.forEach(n=>{i.includes(n)||this.emit("region-out",n)}),e=i}))}initRegionsContainer(){const e=document.createElement("div");return e.setAttribute("style",`
96      position: absolute;
97      top: 0;
98      left: 0;
99      width: 100%;
100      height: 100%;
101      z-index: 3;
102      pointer-events: none;
103    `),e}getRegions(){return this.regions}avoidOverlapping(e){if(!e.content)return;const t=e.content,i=t.getBoundingClientRect().left,n=e.element.scrollWidth,r=this.regions.filter(o=>{if(o===e||!o.content)return!1;const u=o.content.getBoundingClientRect().left,a=o.element.scrollWidth;return i<u+a&&u<i+n}).map(o=>{var u;return((u=o.content)===null||u===void 0?void 0:u.getBoundingClientRect().height)||0}).reduce((o,u)=>o+u,0);t.style.marginTop=`${r}px`}saveRegion(e){this.regionsContainer.appendChild(e.element),this.avoidOverlapping(e),this.regions.push(e);const t=[e.on("update-end",()=>{this.avoidOverlapping(e),this.emit("region-updated",e)}),e.on("play",()=>{var i,n;(i=this.wavesurfer)===null||i===void 0||i.play(),(n=this.wavesurfer)===null||n===void 0||n.setTime(e.start)}),e.on("click",i=>{this.emit("region-clicked",e,i)}),e.on("dblclick",i=>{this.emit("region-double-clicked",e,i)}),e.once("remove",()=>{t.forEach(i=>i()),this.regions=this.regions.filter(i=>i!==e)})];this.subscriptions.push(...t),this.emit("region-created",e)}addRegion(e){var t,i;if(!this.wavesurfer)throw Error("WaveSurfer is not initialized");const n=this.wavesurfer.getDuration(),r=(i=(t=this.wavesurfer)===null||t===void 0?void 0:t.getDecodedData())===null||i===void 0?void 0:i.numberOfChannels,o=new gt(e,n,r);return n?this.saveRegion(o):this.subscriptions.push(this.wavesurfer.once("ready",u=>{o._setTotalDuration(u),this.saveRegion(o)})),o}enableDragSelection(e){var t,i;const n=(i=(t=this.wavesurfer)===null||t===void 0?void 0:t.getWrapper())===null||i===void 0?void 0:i.querySelector("div");if(!n)return()=>{};let r=null,o=0;return Oe(n,(u,a,d)=>{r&&r._onUpdate(u,d>o?"end":"start")},u=>{var a,d;if(o=u,!this.wavesurfer)return;const l=this.wavesurfer.getDuration(),c=(d=(a=this.wavesurfer)===null||a===void 0?void 0:a.getDecodedData())===null||d===void 0?void 0:d.numberOfChannels,m=this.wavesurfer.getWrapper().clientWidth,p=u/m*l,_=(u+5)/m*l;r=new gt(Object.assign(Object.assign({},e),{start:p,end:_}),l,c),this.regionsContainer.appendChild(r.element)},()=>{r&&(this.saveRegion(r),r=null)})}clearRegions(){this.regions.forEach(e=>e.remove())}destroy(){this.clearRegions(),super.destroy()}}const{SvelteComponent:Yi,check_outros:Ji,create_component:ot,destroy_component:lt,detach:Ki,empty:Qi,flush:en,group_outros:tn,init:nn,insert:sn,mount_component:at,safe_not_equal:rn,transition_in:Pe,transition_out:Te}=window.__gradio__svelte__internal;function on(s){let e,t;return e=new $i({}),{c(){ot(e.$$.fragment)},m(i,n){at(e,i,n),t=!0},i(i){t||(Pe(e.$$.fragment,i),t=!0)},o(i){Te(e.$$.fragment,i),t=!1},d(i){lt(e,i)}}}function ln(s){let e,t;return e=new bi({}),{c(){ot(e.$$.fragment)},m(i,n){at(e,i,n),t=!0},i(i){t||(Pe(e.$$.fragment,i),t=!0)},o(i){Te(e.$$.fragment,i),t=!1},d(i){lt(e,i)}}}function an(s){let e,t;return e=new zi({}),{c(){ot(e.$$.fragment)},m(i,n){at(e,i,n),t=!0},i(i){t||(Pe(e.$$.fragment,i),t=!0)},o(i){Te(e.$$.fragment,i),t=!1},d(i){lt(e,i)}}}function un(s){let e,t,i,n;const r=[an,ln,on],o=[];function u(a,d){return a[0]==0?0:a[0]<.5?1:a[0]>=.5?2:-1}return~(e=u(s))&&(t=o[e]=r[e](s)),{c(){t&&t.c(),i=Qi()},m(a,d){~e&&o[e].m(a,d),sn(a,i,d),n=!0},p(a,[d]){let l=e;e=u(a),e!==l&&(t&&(tn(),Te(o[l],1,1,()=>{o[l]=null}),Ji()),~e?(t=o[e],t||(t=o[e]=r[e](a),t.c()),Pe(t,1),t.m(i.parentNode,i)):t=null)},i(a){n||(Pe(t),n=!0)},o(a){Te(t),n=!1},d(a){a&&Ki(i),~e&&o[e].d(a)}}}function dn(s,e,t){let{currentVolume:i}=e;return s.$$set=n=>{"currentVolume"in n&&t(0,i=n.currentVolume)},[i]}class cn extends Yi{constructor(e){super(),nn(this,e,dn,un,rn,{currentVolume:0})}get currentVolume(){return this.$$.ctx[0]}set currentVolume(e){this.$$set({currentVolume:e}),en()}}const{SvelteComponent:hn,attr:we,binding_callbacks:fn,detach:mn,element:_n,flush:Je,init:pn,insert:gn,listen:vt,noop:bt,run_all:vn,safe_not_equal:bn}=window.__gradio__svelte__internal,{onMount:wn}=window.__gradio__svelte__internal;function yn(s){let e,t,i;return{c(){e=_n("input"),we(e,"id","volume"),we(e,"class","volume-slider svelte-wuo8j5"),we(e,"type","range"),we(e,"min","0"),we(e,"max","1"),we(e,"step","0.01"),e.value=s[0]},m(n,r){gn(n,e,r),s[4](e),t||(i=[vt(e,"focusout",s[5]),vt(e,"input",s[6])],t=!0)},p(n,[r]){r&1&&(e.value=n[0])},i:bt,o:bt,d(n){n&&mn(e),s[4](null),t=!1,vn(i)}}}function kn(s,e,t){let{currentVolume:i=1}=e,{show_volume_slider:n=!1}=e,{waveform:r}=e,o;wn(()=>{u()});const u=()=>{let c=o;c&&(c.style.background=`linear-gradient(to right, var(--color-accent) ${i*100}%, var(--neutral-400) ${i*100}%)`)};function a(c){fn[c?"unshift":"push"](()=>{o=c,t(3,o)})}const d=()=>t(1,n=!1),l=c=>{c.target instanceof HTMLInputElement&&(t(0,i=parseFloat(c.target.value)),r.setVolume(i))};return s.$$set=c=>{"currentVolume"in c&&t(0,i=c.currentVolume),"show_volume_slider"in c&&t(1,n=c.show_volume_slider),"waveform"in c&&t(2,r=c.waveform)},s.$$.update=()=>{s.$$.dirty&1&&u()},[i,n,r,o,a,d,l]}class Cn extends hn{constructor(e){super(),pn(this,e,kn,yn,bn,{currentVolume:0,show_volume_slider:1,waveform:2})}get currentVolume(){return this.$$.ctx[0]}set currentVolume(e){this.$$set({currentVolume:e}),Je()}get show_volume_slider(){return this.$$.ctx[1]}set show_volume_slider(e){this.$$set({show_volume_slider:e}),Je()}get waveform(){return this.$$.ctx[2]}set waveform(e){this.$$set({waveform:e}),Je()}}const{SvelteComponent:En,add_flush_callback:wt,append:z,attr:$,bind:yt,binding_callbacks:kt,check_outros:Me,create_component:ne,destroy_component:se,detach:re,element:q,empty:Sn,flush:V,group_outros:De,init:Ln,insert:oe,listen:Q,mount_component:le,noop:Re,run_all:Ht,safe_not_equal:$n,set_data:Mn,set_style:Ct,space:ie,text:Et,toggle_class:St,transition_in:R,transition_out:W}=window.__gradio__svelte__internal;function Lt(s){let e,t,i,n;function r(a){s[27](a)}function o(a){s[28](a)}let u={waveform:s[2]};return s[12]!==void 0&&(u.currentVolume=s[12]),s[1]!==void 0&&(u.show_volume_slider=s[1]),e=new Cn({props:u}),kt.push(()=>yt(e,"currentVolume",r)),kt.push(()=>yt(e,"show_volume_slider",o)),{c(){ne(e.$$.fragment)},m(a,d){le(e,a,d),n=!0},p(a,d){const l={};d[0]&4&&(l.waveform=a[2]),!t&&d[0]&4096&&(t=!0,l.currentVolume=a[12],wt(()=>t=!1)),!i&&d[0]&2&&(i=!0,l.show_volume_slider=a[1],wt(()=>i=!1)),e.$set(l)},i(a){n||(R(e.$$.fragment,a),n=!0)},o(a){W(e.$$.fragment,a),n=!1},d(a){se(e,a)}}}function Dn(s){let e,t;return e=new xt({}),{c(){ne(e.$$.fragment)},m(i,n){le(e,i,n),t=!0},i(i){t||(R(e.$$.fragment,i),t=!0)},o(i){W(e.$$.fragment,i),t=!1},d(i){se(e,i)}}}function Rn(s){let e,t;return e=new Ft({}),{c(){ne(e.$$.fragment)},m(i,n){le(e,i,n),t=!0},i(i){t||(R(e.$$.fragment,i),t=!0)},o(i){W(e.$$.fragment,i),t=!1},d(i){se(e,i)}}}function $t(s){let e,t,i,n,r,o=s[6]&&s[0]===""&&Mt(s);const u=[Tn,Pn],a=[];function d(l,c){return l[0]===""?0:1}return t=d(s),i=a[t]=u[t](s),{c(){o&&o.c(),e=ie(),i.c(),n=Sn()},m(l,c){o&&o.m(l,c),oe(l,e,c),a[t].m(l,c),oe(l,n,c),r=!0},p(l,c){l[6]&&l[0]===""?o?(o.p(l,c),c[0]&65&&R(o,1)):(o=Mt(l),o.c(),R(o,1),o.m(e.parentNode,e)):o&&(De(),W(o,1,1,()=>{o=null}),Me());let m=t;t=d(l),t===m?a[t].p(l,c):(De(),W(a[m],1,1,()=>{a[m]=null}),Me(),i=a[t],i?i.p(l,c):(i=a[t]=u[t](l),i.c()),R(i,1),i.m(n.parentNode,n))},i(l){r||(R(o),R(i),r=!0)},o(l){W(o),W(i),r=!1},d(l){l&&(re(e),re(n)),o&&o.d(l),a[t].d(l)}}}function Mt(s){let e,t,i,n,r;return t=new Gt({}),{c(){e=q("button"),ne(t.$$.fragment),$(e,"class","action icon svelte-ije4bl"),$(e,"aria-label","Reset audio")},m(o,u){oe(o,e,u),le(t,e,null),i=!0,n||(r=Q(e,"click",s[33]),n=!0)},p:Re,i(o){i||(R(t.$$.fragment,o),i=!0)},o(o){W(t.$$.fragment,o),i=!1},d(o){o&&re(e),se(t),n=!1,r()}}}function Pn(s){let e,t,i,n,r;return{c(){e=q("button"),e.textContent="Trim",t=ie(),i=q("button"),i.textContent="Cancel",$(e,"class","text-button svelte-ije4bl"),$(i,"class","text-button svelte-ije4bl")},m(o,u){oe(o,e,u),oe(o,t,u),oe(o,i,u),n||(r=[Q(e,"click",s[14]),Q(i,"click",s[16])],n=!0)},p:Re,i:Re,o:Re,d(o){o&&(re(e),re(t),re(i)),n=!1,Ht(r)}}}function Tn(s){let e,t,i,n,r;return t=new Xt({}),{c(){e=q("button"),ne(t.$$.fragment),$(e,"class","action icon svelte-ije4bl"),$(e,"aria-label","Trim audio to selection")},m(o,u){oe(o,e,u),le(t,e,null),i=!0,n||(r=Q(e,"click",s[16]),n=!0)},p:Re,i(o){i||(R(t.$$.fragment,o),i=!0)},o(o){W(t.$$.fragment,o),i=!1},d(o){o&&re(e),se(t),n=!1,r()}}}function An(s){let e,t,i,n,r,o,u,a,d,l,c,m,p,_,g,w,b,C,E,k,h,S,L,D,U,J,B,O,ue,de;n=new cn({props:{currentVolume:s[12]}});let M=s[1]&&Lt(s);g=new ni({});const _e=[Rn,Dn],G=[];function pe(y,P){return y[5]?0:1}E=pe(s),k=G[E]=_e[E](s),D=new ci({});let f=s[10]&&s[7]&&$t(s);return{c(){e=q("div"),t=q("div"),i=q("button"),ne(n.$$.fragment),r=ie(),M&&M.c(),o=ie(),u=q("button"),a=q("span"),d=Et(s[11]),l=Et("x"),m=ie(),p=q("div"),_=q("button"),ne(g.$$.fragment),b=ie(),C=q("button"),k.c(),S=ie(),L=q("button"),ne(D.$$.fragment),J=ie(),B=q("div"),f&&f.c(),$(i,"class","action icon volume svelte-ije4bl"),$(i,"aria-label","Adjust volume"),Ct(i,"color",s[1]?"var(--color-accent)":"var(--neutral-400)"),$(u,"class","playback icon svelte-ije4bl"),$(u,"aria-label",c=`Adjust playback speed to ${s[13][(s[13].indexOf(s[11])+1)%s[13].length]}x`),St(u,"hidden",s[1]),$(t,"class","control-wrapper svelte-ije4bl"),$(_,"class","rewind icon svelte-ije4bl"),$(_,"aria-label",w=`Skip backwards by ${ke(s[3],s[9].skip_length)} seconds`),$(C,"class","play-pause-button icon svelte-ije4bl"),$(C,"aria-label",h=s[5]?s[4]("audio.pause"):s[4]("audio.play")),$(L,"class","skip icon svelte-ije4bl"),$(L,"aria-label",U="Skip forward by "+ke(s[3],s[9].skip_length)+" seconds"),$(p,"class","play-pause-wrapper svelte-ije4bl"),$(B,"class","settings-wrapper svelte-ije4bl"),$(e,"class","controls svelte-ije4bl"),$(e,"data-testid","waveform-controls")},m(y,P){oe(y,e,P),z(e,t),z(t,i),le(n,i,null),z(t,r),M&&M.m(t,null),z(t,o),z(t,u),z(u,a),z(a,d),z(a,l),z(e,m),z(e,p),z(p,_),le(g,_,null),z(p,b),z(p,C),G[E].m(C,null),z(p,S),z(p,L),le(D,L,null),z(e,J),z(e,B),f&&f.m(B,null),O=!0,ue||(de=[Q(i,"click",s[26]),Q(u,"click",s[29]),Q(_,"click",s[30]),Q(C,"click",s[31]),Q(L,"click",s[32])],ue=!0)},p(y,P){const ge={};P[0]&4096&&(ge.currentVolume=y[12]),n.$set(ge),P[0]&2&&Ct(i,"color",y[1]?"var(--color-accent)":"var(--neutral-400)"),y[1]?M?(M.p(y,P),P[0]&2&&R(M,1)):(M=Lt(y),M.c(),R(M,1),M.m(t,o)):M&&(De(),W(M,1,1,()=>{M=null}),Me()),(!O||P[0]&2048)&&Mn(d,y[11]),(!O||P[0]&2048&&c!==(c=`Adjust playback speed to ${y[13][(y[13].indexOf(y[11])+1)%y[13].length]}x`))&&$(u,"aria-label",c),(!O||P[0]&2)&&St(u,"hidden",y[1]),(!O||P[0]&520&&w!==(w=`Skip backwards by ${ke(y[3],y[9].skip_length)} seconds`))&&$(_,"aria-label",w);let v=E;E=pe(y),E!==v&&(De(),W(G[v],1,1,()=>{G[v]=null}),Me(),k=G[E],k||(k=G[E]=_e[E](y),k.c()),R(k,1),k.m(C,null)),(!O||P[0]&48&&h!==(h=y[5]?y[4]("audio.pause"):y[4]("audio.play")))&&$(C,"aria-label",h),(!O||P[0]&520&&U!==(U="Skip forward by "+ke(y[3],y[9].skip_length)+" seconds"))&&$(L,"aria-label",U),y[10]&&y[7]?f?(f.p(y,P),P[0]&1152&&R(f,1)):(f=$t(y),f.c(),R(f,1),f.m(B,null)):f&&(De(),W(f,1,1,()=>{f=null}),Me())},i(y){O||(R(n.$$.fragment,y),R(M),R(g.$$.fragment,y),R(k),R(D.$$.fragment,y),R(f),O=!0)},o(y){W(n.$$.fragment,y),W(M),W(g.$$.fragment,y),W(k),W(D.$$.fragment,y),W(f),O=!1},d(y){y&&re(e),se(n),M&&M.d(),se(g),G[E].d(),se(D),f&&f.d(),ue=!1,Ht(de)}}}function Wn(s,e,t){let{waveform:i}=e,{audio_duration:n}=e,{i18n:r}=e,{playing:o}=e,{show_redo:u=!1}=e,{interactive:a=!1}=e,{handle_trim_audio:d}=e,{mode:l=""}=e,{container:c}=e,{handle_reset_value:m}=e,{waveform_options:p={}}=e,{trim_region_settings:_={}}=e,{show_volume_slider:g=!1}=e,{editable:w=!0}=e,{trimDuration:b=0}=e,C=[.5,1,1.5,2],E=C[1],k,h=null,S,L,D="",U=1;const J=()=>{t(22,h=k.addRegion({start:n/4,end:n/2,..._})),t(17,b=h.end-h.start)},B=()=>{if(i&&k&&h){const v=h.start,ve=h.end;d(v,ve),t(0,l=""),t(22,h=null)}},O=()=>{k?.getRegions().forEach(v=>{v.remove()}),k?.clearRegions()},ue=()=>{O(),l==="edit"?t(0,l=""):(t(0,l="edit"),J())},de=(v,ve)=>{let Ee,Se;h&&(v==="left"?ve==="ArrowLeft"?(Ee=h.start-.05,Se=h.end):(Ee=h.start+.05,Se=h.end):ve==="ArrowLeft"?(Ee=h.start,Se=h.end-.05):(Ee=h.start,Se=h.end+.05),h.setOptions({start:Ee,end:Se}),t(17,b=h.end-h.start))},M=()=>t(1,g=!g);function _e(v){U=v,t(12,U)}function G(v){g=v,t(1,g)}const pe=()=>{t(11,E=C[(C.indexOf(E)+1)%C.length]),i.setPlaybackRate(E)},f=()=>i.skip(ke(n,p.skip_length)*-1),y=()=>i.playPause(),P=()=>i.skip(ke(n,p.skip_length)),ge=()=>{m(),O(),t(0,l="")};return s.$$set=v=>{"waveform"in v&&t(2,i=v.waveform),"audio_duration"in v&&t(3,n=v.audio_duration),"i18n"in v&&t(4,r=v.i18n),"playing"in v&&t(5,o=v.playing),"show_redo"in v&&t(6,u=v.show_redo),"interactive"in v&&t(7,a=v.interactive),"handle_trim_audio"in v&&t(18,d=v.handle_trim_audio),"mode"in v&&t(0,l=v.mode),"container"in v&&t(19,c=v.container),"handle_reset_value"in v&&t(8,m=v.handle_reset_value),"waveform_options"in v&&t(9,p=v.waveform_options),"trim_region_settings"in v&&t(20,_=v.trim_region_settings),"show_volume_slider"in v&&t(1,g=v.show_volume_slider),"editable"in v&&t(10,w=v.editable),"trimDuration"in v&&t(17,b=v.trimDuration)},s.$$.update=()=>{if(s.$$.dirty[0]&4&&t(21,k=i.registerPlugin(rt.create())),s.$$.dirty[0]&2097152&&k?.on("region-out",v=>{v.play()}),s.$$.dirty[0]&2097152&&k?.on("region-updated",v=>{t(17,b=v.end-v.start)}),s.$$.dirty[0]&2097152&&k?.on("region-clicked",(v,ve)=>{ve.stopPropagation(),t(22,h=v),v.play()}),s.$$.dirty[0]&31981568&&h){const v=c.children[0].shadowRoot;t(24,L=v.querySelector('[data-resize="right"]')),t(23,S=v.querySelector('[data-resize="left"]')),S&&L&&(S.setAttribute("role","button"),L.setAttribute("role","button"),S?.setAttribute("aria-label","Drag to adjust start time"),L?.setAttribute("aria-label","Drag to adjust end time"),S?.setAttribute("tabindex","0"),L?.setAttribute("tabindex","0"),S.addEventListener("focus",()=>{k&&t(25,D="left")}),L.addEventListener("focus",()=>{k&&t(25,D="right")}))}s.$$.dirty[0]&35651584&&k&&window.addEventListener("keydown",v=>{v.key==="ArrowLeft"?de(D,"ArrowLeft"):v.key==="ArrowRight"&&de(D,"ArrowRight")})},[l,g,i,n,r,o,u,a,m,p,w,E,U,C,B,O,ue,b,d,c,_,k,h,S,L,D,M,_e,G,pe,f,y,P,ge]}class zn extends En{constructor(e){super(),Ln(this,e,Wn,An,$n,{waveform:2,audio_duration:3,i18n:4,playing:5,show_redo:6,interactive:7,handle_trim_audio:18,mode:0,container:19,handle_reset_value:8,waveform_options:9,trim_region_settings:20,show_volume_slider:1,editable:10,trimDuration:17},null,[-1,-1])}get waveform(){return this.$$.ctx[2]}set waveform(e){this.$$set({waveform:e}),V()}get audio_duration(){return this.$$.ctx[3]}set audio_duration(e){this.$$set({audio_duration:e}),V()}get i18n(){return this.$$.ctx[4]}set i18n(e){this.$$set({i18n:e}),V()}get playing(){return this.$$.ctx[5]}set playing(e){this.$$set({playing:e}),V()}get show_redo(){return this.$$.ctx[6]}set show_redo(e){this.$$set({show_redo:e}),V()}get interactive(){return this.$$.ctx[7]}set interactive(e){this.$$set({interactive:e}),V()}get handle_trim_audio(){return this.$$.ctx[18]}set handle_trim_audio(e){this.$$set({handle_trim_audio:e}),V()}get mode(){return this.$$.ctx[0]}set mode(e){this.$$set({mode:e}),V()}get container(){return this.$$.ctx[19]}set container(e){this.$$set({container:e}),V()}get handle_reset_value(){return this.$$.ctx[8]}set handle_reset_value(e){this.$$set({handle_reset_value:e}),V()}get waveform_options(){return this.$$.ctx[9]}set waveform_options(e){this.$$set({waveform_options:e}),V()}get trim_region_settings(){return this.$$.ctx[20]}set trim_region_settings(e){this.$$set({trim_region_settings:e}),V()}get show_volume_slider(){return this.$$.ctx[1]}set show_volume_slider(e){this.$$set({show_volume_slider:e}),V()}get editable(){return this.$$.ctx[10]}set editable(e){this.$$set({editable:e}),V()}get trimDuration(){return this.$$.ctx[17]}set trimDuration(e){this.$$set({trimDuration:e}),V()}}const{SvelteComponent:On,add_flush_callback:Ke,append:Z,attr:H,bind:Qe,binding_callbacks:Ce,bubble:Hn,check_outros:Vt,create_component:ut,destroy_component:dt,detach:Be,element:K,empty:Vn,flush:X,group_outros:Nt,init:Nn,insert:Ie,listen:jn,mount_component:ct,
103noop:Dt,safe_not_equal:qn,set_data:Bn,space:ze,src_url_equal:Rt,text:In,transition_in:ae,transition_out:ce}=window.__gradio__svelte__internal,{onMount:Un}=window.__gradio__svelte__internal,{createEventDispatcher:xn}=window.__gradio__svelte__internal;function Fn(s){let e,t,i,n,r,o,u,a,d,l,c,m,p,_=s[0]==="edit"&&s[17]>0&&Pt(s),g=s[12]&&Tt(s);return{c(){e=K("div"),t=K("div"),i=K("div"),n=ze(),r=K("div"),o=K("time"),o.textContent="0:00",u=ze(),a=K("div"),_&&_.c(),d=ze(),l=K("time"),l.textContent="0:00",c=ze(),g&&g.c(),H(i,"id","waveform"),H(i,"class","svelte-1ark3ru"),H(t,"class","waveform-container svelte-1ark3ru"),H(o,"id","time"),H(o,"class","svelte-1ark3ru"),H(l,"id","duration"),H(l,"class","svelte-1ark3ru"),H(r,"class","timestamps svelte-1ark3ru"),H(e,"class","component-wrapper svelte-1ark3ru"),H(e,"data-testid",m=s[2]?"waveform-"+s[2]:"unlabelled-audio")},m(w,b){Ie(w,e,b),Z(e,t),Z(t,i),s[23](i),Z(e,n),Z(e,r),Z(r,o),s[24](o),Z(r,u),Z(r,a),_&&_.m(a,null),Z(a,d),Z(a,l),s[25](l),Z(e,c),g&&g.m(e,null),p=!0},p(w,b){w[0]==="edit"&&w[17]>0?_?_.p(w,b):(_=Pt(w),_.c(),_.m(a,d)):_&&(_.d(1),_=null),w[12]?g?(g.p(w,b),b[0]&4096&&ae(g,1)):(g=Tt(w),g.c(),ae(g,1),g.m(e,null)):g&&(Nt(),ce(g,1,1,()=>{g=null}),Vt()),(!p||b[0]&4&&m!==(m=w[2]?"waveform-"+w[2]:"unlabelled-audio"))&&H(e,"data-testid",m)},i(w){p||(ae(g),p=!0)},o(w){ce(g),p=!1},d(w){w&&Be(e),s[23](null),s[24](null),_&&_.d(),s[25](null),g&&g.d()}}}function Xn(s){let e,t,i,n,r;return{c(){e=K("audio"),H(e,"class","standard-player svelte-1ark3ru"),Rt(e.src,t=s[1].url)||H(e,"src",t),e.controls=!0,e.autoplay=i=s[7].autoplay,e.loop=s[9]},m(o,u){Ie(o,e,u),n||(r=jn(e,"load",s[22]),n=!0)},p(o,u){u[0]&2&&!Rt(e.src,t=o[1].url)&&H(e,"src",t),u[0]&128&&i!==(i=o[7].autoplay)&&(e.autoplay=i),u[0]&512&&(e.loop=o[9])},i:Dt,o:Dt,d(o){o&&Be(e),n=!1,r()}}}function Gn(s){let e,t;return e=new zt({props:{size:"small",$$slots:{default:[Zn]},$$scope:{ctx:s}}}),{c(){ut(e.$$.fragment)},m(i,n){ct(e,i,n),t=!0},p(i,n){const r={};n[1]&2&&(r.$$scope={dirty:n,ctx:i}),e.$set(r)},i(i){t||(ae(e.$$.fragment,i),t=!0)},o(i){ce(e.$$.fragment,i),t=!1},d(i){dt(e,i)}}}function Pt(s){let e,t=He(s[17])+"",i;return{c(){e=K("time"),i=In(t),H(e,"id","trim-duration"),H(e,"class","svelte-1ark3ru")},m(n,r){Ie(n,e,r),Z(e,i)},p(n,r){r[0]&131072&&t!==(t=He(n[17])+"")&&Bn(i,t)},d(n){n&&Be(e)}}}function Tt(s){let e,t,i,n,r;function o(l){s[26](l)}function u(l){s[27](l)}function a(l){s[28](l)}let d={container:s[11],waveform:s[12],playing:s[15],audio_duration:s[16],i18n:s[3],interactive:s[4],handle_trim_audio:s[19],show_redo:s[4],handle_reset_value:s[10],waveform_options:s[8],trim_region_settings:s[6],editable:s[5]};return s[0]!==void 0&&(d.mode=s[0]),s[17]!==void 0&&(d.trimDuration=s[17]),s[18]!==void 0&&(d.show_volume_slider=s[18]),e=new zn({props:d}),Ce.push(()=>Qe(e,"mode",o)),Ce.push(()=>Qe(e,"trimDuration",u)),Ce.push(()=>Qe(e,"show_volume_slider",a)),{c(){ut(e.$$.fragment)},m(l,c){ct(e,l,c),r=!0},p(l,c){const m={};c[0]&2048&&(m.container=l[11]),c[0]&4096&&(m.waveform=l[12]),c[0]&32768&&(m.playing=l[15]),c[0]&65536&&(m.audio_duration=l[16]),c[0]&8&&(m.i18n=l[3]),c[0]&16&&(m.interactive=l[4]),c[0]&16&&(m.show_redo=l[4]),c[0]&1024&&(m.handle_reset_value=l[10]),c[0]&256&&(m.waveform_options=l[8]),c[0]&64&&(m.trim_region_settings=l[6]),c[0]&32&&(m.editable=l[5]),!t&&c[0]&1&&(t=!0,m.mode=l[0],Ke(()=>t=!1)),!i&&c[0]&131072&&(i=!0,m.trimDuration=l[17],Ke(()=>i=!1)),!n&&c[0]&262144&&(n=!0,m.show_volume_slider=l[18],Ke(()=>n=!1)),e.$set(m)},i(l){r||(ae(e.$$.fragment,l),r=!0)},o(l){ce(e.$$.fragment,l),r=!1},d(l){dt(e,l)}}}function Zn(s){let e,t;return e=new nt({}),{c(){ut(e.$$.fragment)},m(i,n){ct(e,i,n),t=!0},i(i){t||(ae(e.$$.fragment,i),t=!0)},o(i){ce(e.$$.fragment,i),t=!1},d(i){dt(e,i)}}}function Yn(s){let e,t,i,n;const r=[Gn,Xn,Fn],o=[];function u(a,d){return a[1]===null?0:a[1].is_stream?1:2}return e=u(s),t=o[e]=r[e](s),{c(){t.c(),i=Vn()},m(a,d){o[e].m(a,d),Ie(a,i,d),n=!0},p(a,d){let l=e;e=u(a),e===l?o[e].p(a,d):(Nt(),ce(o[l],1,1,()=>{o[l]=null}),Vt(),t=o[e],t?t.p(a,d):(t=o[e]=r[e](a),t.c()),ae(t,1),t.m(i.parentNode,i))},i(a){n||(ae(t),n=!0)},o(a){ce(t),n=!1},d(a){a&&Be(i),o[e].d(a)}}}function Jn(s,e,t){let i,{value:n=null}=e,{label:r}=e,{i18n:o}=e,{dispatch_blob:u=()=>Promise.resolve()}=e,{interactive:a=!1}=e,{editable:d=!0}=e,{trim_region_settings:l={}}=e,{waveform_settings:c}=e,{waveform_options:m}=e,{mode:p=""}=e,{loop:_}=e,{handle_reset_value:g=()=>{}}=e,w,b,C=!1,E,k,h,S=0,L=!1;const D=xn(),U=()=>{t(12,b=st.create({container:w,...c})),ht(n?.url).then(f=>{if(f&&b)return b.load(f)})},J=async(f,y)=>{t(0,p="");const P=b?.getDecodedData();P&&await Gi(P,f,y,c.sampleRate).then(async ge=>{await u([ge],"change"),b?.destroy(),t(11,w.innerHTML="",w)}),D("edit")};async function B(f){await ht(f).then(y=>{if(!(!y||n?.is_stream))return b?.load(y)})}Un(()=>{window.addEventListener("keydown",f=>{!b||L||(f.key==="ArrowRight"&&p!=="edit"?pt(b,.1):f.key==="ArrowLeft"&&p!=="edit"&&pt(b,-.1))})});function O(f){Hn.call(this,s,f)}function ue(f){Ce[f?"unshift":"push"](()=>{w=f,t(11,w),t(12,b)})}function de(f){Ce[f?"unshift":"push"](()=>{E=f,t(13,E),t(12,b)})}function M(f){Ce[f?"unshift":"push"](()=>{k=f,t(14,k),t(12,b)})}function _e(f){p=f,t(0,p)}function G(f){S=f,t(17,S)}function pe(f){L=f,t(18,L)}return s.$$set=f=>{"value"in f&&t(1,n=f.value),"label"in f&&t(2,r=f.label),"i18n"in f&&t(3,o=f.i18n),"dispatch_blob"in f&&t(20,u=f.dispatch_blob),"interactive"in f&&t(4,a=f.interactive),"editable"in f&&t(5,d=f.editable),"trim_region_settings"in f&&t(6,l=f.trim_region_settings),"waveform_settings"in f&&t(7,c=f.waveform_settings),"waveform_options"in f&&t(8,m=f.waveform_options),"mode"in f&&t(0,p=f.mode),"loop"in f&&t(9,_=f.loop),"handle_reset_value"in f&&t(10,g=f.handle_reset_value)},s.$$.update=()=>{s.$$.dirty[0]&2&&t(21,i=n?.url),s.$$.dirty[0]&6144&&w!==void 0&&(b!==void 0&&b.destroy(),t(11,w.innerHTML="",w),U(),t(15,C=!1)),s.$$.dirty[0]&20480&&b?.on("decode",f=>{t(16,h=f),k&&t(14,k.textContent=He(f),k)}),s.$$.dirty[0]&12288&&b?.on("timeupdate",f=>E&&t(13,E.textContent=He(f),E)),s.$$.dirty[0]&4224&&b?.on("ready",()=>{c.autoplay?b?.play():b?.stop()}),s.$$.dirty[0]&4608&&b?.on("finish",()=>{_?b?.play():(t(15,C=!1),D("stop"))}),s.$$.dirty[0]&4096&&b?.on("pause",()=>{t(15,C=!1),D("pause")}),s.$$.dirty[0]&4096&&b?.on("play",()=>{t(15,C=!0),D("play")}),s.$$.dirty[0]&4096&&b?.on("load",()=>{D("load")}),s.$$.dirty[0]&2097152&&i&&B(i)},[p,n,r,o,a,d,l,c,m,_,g,w,b,E,k,C,h,S,L,J,u,i,O,ue,de,M,_e,G,pe]}class Kn extends On{constructor(e){super(),Nn(this,e,Jn,Yn,qn,{value:1,label:2,i18n:3,dis
103patch_blob:20,interactive:4,editable:5,trim_region_settings:6,waveform_settings:7,waveform_options:8,mode:0,loop:9,handle_reset_value:10},null,[-1,-1])}get value(){return this.$$.ctx[1]}set value(e){this.$$set({value:e}),X()}get label(){return this.$$.ctx[2]}set label(e){this.$$set({label:e}),X()}get i18n(){return this.$$.ctx[3]}set i18n(e){this.$$set({i18n:e}),X()}get dispatch_blob(){return this.$$.ctx[20]}set dispatch_blob(e){this.$$set({dispatch_blob:e}),X()}get interactive(){return this.$$.ctx[4]}set interactive(e){this.$$set({interactive:e}),X()}get editable(){return this.$$.ctx[5]}set editable(e){this.$$set({editable:e}),X()}get trim_region_settings(){return this.$$.ctx[6]}set trim_region_settings(e){this.$$set({trim_region_settings:e}),X()}get waveform_settings(){return this.$$.ctx[7]}set waveform_settings(e){this.$$set({waveform_settings:e}),X()}get waveform_options(){return this.$$.ctx[8]}set waveform_options(e){this.$$set({waveform_options:e}),X()}get mode(){return this.$$.ctx[0]}set mode(e){this.$$set({mode:e}),X()}get loop(){return this.$$.ctx[9]}set loop(e){this.$$set({loop:e}),X()}get handle_reset_value(){return this.$$.ctx[10]}set handle_reset_value(e){this.$$set({handle_reset_value:e}),X()}}const Qn=Kn,{SvelteComponent:es,append:ts,attr:is,bubble:ye,check_outros:et,create_component:he,destroy_component:fe,detach:Ve,element:ns,empty:ss,flush:Y,group_outros:tt,init:rs,insert:Ne,mount_component:me,safe_not_equal:os,space:it,transition_in:N,transition_out:I}=window.__gradio__svelte__internal,{createEventDispatcher:ls}=window.__gradio__svelte__internal;function as(s){let e,t;return e=new zt({props:{size:"small",$$slots:{default:[ds]},$$scope:{ctx:s}}}),{c(){he(e.$$.fragment)},m(i,n){me(e,i,n),t=!0},p(i,n){const r={};n&262144&&(r.$$scope={dirty:n,ctx:i}),e.$set(r)},i(i){t||(N(e.$$.fragment,i),t=!0)},o(i){I(e.$$.fragment,i),t=!1},d(i){fe(e,i)}}}function us(s){let e,t,i,n,r,o=s[3]&&At(s),u=s[4]&&Wt(s);return n=new Qn({props:{value:s[0],label:s[1],i18n:s[5],waveform_settings:s[6],waveform_options:s[7],editable:s[8],loop:s[9]}}),n.$on("pause",s[13]),n.$on("play",s[14]),n.$on("stop",s[15]),n.$on("load",s[16]),{c(){e=ns("div"),o&&o.c(),t=it(),u&&u.c(),i=it(),he(n.$$.fragment),is(e,"class","icon-buttons svelte-rvdo70")},m(a,d){Ne(a,e,d),o&&o.m(e,null),ts(e,t),u&&u.m(e,null),Ne(a,i,d),me(n,a,d),r=!0},p(a,d){a[3]?o?(o.p(a,d),d&8&&N(o,1)):(o=At(a),o.c(),N(o,1),o.m(e,t)):o&&(tt(),I(o,1,1,()=>{o=null}),et()),a[4]?u?(u.p(a,d),d&16&&N(u,1)):(u=Wt(a),u.c(),N(u,1),u.m(e,null)):u&&(tt(),I(u,1,1,()=>{u=null}),et());const l={};d&1&&(l.value=a[0]),d&2&&(l.label=a[1]),d&32&&(l.i18n=a[5]),d&64&&(l.waveform_settings=a[6]),d&128&&(l.waveform_options=a[7]),d&256&&(l.editable=a[8]),d&512&&(l.loop=a[9]),n.$set(l)},i(a){r||(N(o),N(u),N(n.$$.fragment,a),r=!0)},o(a){I(o),I(u),I(n.$$.fragment,a),r=!1},d(a){a&&(Ve(e),Ve(i)),o&&o.d(),u&&u.d(),fe(n,a)}}}function ds(s){let e,t;return e=new nt({}),{c(){he(e.$$.fragment)},m(i,n){me(e,i,n),t=!0},i(i){t||(N(e.$$.fragment,i),t=!0)},o(i){I(e.$$.fragment,i),t=!1},d(i){fe(e,i)}}}function At(s){let e,t;return e=new Zt({props:{href:s[0].url,download:s[0].orig_name||s[0].path,$$slots:{default:[cs]},$$scope:{ctx:s}}}),{c(){he(e.$$.fragment)},m(i,n){me(e,i,n),t=!0},p(i,n){const r={};n&1&&(r.href=i[0].url),n&1&&(r.download=i[0].orig_name||i[0].path),n&262176&&(r.$$scope={dirty:n,ctx:i}),e.$set(r)},i(i){t||(N(e.$$.fragment,i),t=!0)},o(i){I(e.$$.fragment,i),t=!1},d(i){fe(e,i)}}}function cs(s){let e,t;return e=new jt({props:{Icon:Ut,label:s[5]("common.download")}}),{c(){he(e.$$.fragment)},m(i,n){me(e,i,n),t=!0},p(i,n){const r={};n&32&&(r.label=i[5]("common.download")),e.$set(r)},i(i){t||(N(e.$$.fragment,i),t=!0)},o(i){I(e.$$.fragment,i),t=!1},d(i){fe(e,i)}}}function Wt(s){let e,t;return e=new It({props:{i18n:s[5],formatter:s[10],value:s[0]}}),e.$on("error",s[11]),e.$on("share",s[12]),{c(){he(e.$$.fragment)},m(i,n){me(e,i,n),t=!0},p(i,n){const r={};n&32&&(r.i18n=i[5]),n&1&&(r.value=i[0]),e.$set(r)},i(i){t||(N(e.$$.fragment,i),t=!0)},o(i){I(e.$$.fragment,i),t=!1},d(i){fe(e,i)}}}function hs(s){let e,t,i,n,r,o;e=new Bt({props:{show_label:s[2],Icon:nt,float:!1,label:s[1]||s[5]("audio.audio")}});const u=[us,as],a=[];function d(l,c){return l[0]!==null?0:1}return i=d(s),n=a[i]=u[i](s),{c(){he(e.$$.fragment),t=it(),n.c(),r=ss()},m(l,c){me(e,l,c),Ne(l,t,c),a[i].m(l,c),Ne(l,r,c),o=!0},p(l,[c]){const m={};c&4&&(m.show_label=l[2]),c&34&&(m.label=l[1]||l[5]("audio.audio")),e.$set(m);let p=i;i=d(l),i===p?a[i].p(l,c):(tt(),I(a[p],1,1,()=>{a[p]=null}),et(),n=a[i],n?n.p(l,c):(n=a[i]=u[i](l),n.c()),N(n,1),n.m(r.parentNode,r))},i(l){o||(N(e.$$.fragment,l),N(n),o=!0)},o(l){I(e.$$.fragment,l),I(n),o=!1},d(l){l&&(Ve(t),Ve(r)),fe(e,l),a[i].d(l)}}}function fs(s,e,t){let{value:i=null}=e,{label:n}=e,{show_label:r=!0}=e,{show_download_button:o=!0}=e,{show_share_button:u=!1}=e,{i18n:a}=e,{waveform_settings:d}=e,{waveform_options:l}=e,{editable:c=!0}=e,{loop:m}=e;const p=ls(),_=async h=>h?`<audio controls src="${await qt(h.url)}"></audio>`:"";function g(h){ye.call(this,s,h)}function w(h){ye.call(this,s,h)}function b(h){ye.call(this,s,h)}function C(h){ye.call(this,s,h)}function E(h){ye.call(this,s,h)}function k(h){ye.call(this,s,h)}return s.$$set=h=>{"value"in h&&t(0,i=h.value),"label"in h&&t(1,n=h.label),"show_label"in h&&t(2,r=h.show_label),"show_download_button"in h&&t(3,o=h.show_download_button),"show_share_button"in h&&t(4,u=h.show_share_button),"i18n"in h&&t(5,a=h.i18n),"w
103aveform_settings"in h&&t(6,d=h.waveform_settings),"waveform_options"in h&&t(7,l=h.waveform_options),"editable"in h&&t(8,c=h.editable),"loop"in h&&t(9,m=h.loop)},s.$$.update=()=>{s.$$.dirty&1&&i&&p("change",i)},[i,n,r,o,u,a,d,l,c,m,_,g,w,b,C,E,k]}class ms extends es{constructor(e){super(),rs(this,e,fs,hs,os,{value:0,label:1,show_label:2,show_download_button:3,show_share_button:4,i18n:5,waveform_settings:6,waveform_options:7,editable:8,loop:9})}get value(){return this.$$.ctx[0]}set value(e){this.$$set({value:e}),Y()}get label(){return this.$$.ctx[1]}set label(e){this.$$set({label:e}),Y()}get show_label(){return this.$$.ctx[2]}set show_label(e){this.$$set({show_label:e}),Y()}get show_download_button(){return this.$$.ctx[3]}set show_download_button(e){this.$$set({show_download_button:e}),Y()}get show_share_button(){return this.$$.ctx[4]}set show_share_button(e){this.$$set({show_share_button:e}),Y()}get i18n(){return this.$$.ctx[5]}set i18n(e){this.$$set({i18n:e}),Y()}get waveform_settings(){return this.$$.ctx[6]}set waveform_settings(e){this.$$set({waveform_settings:e}),Y()}get waveform_options(){return this.$$.ctx[7]}set waveform_options(e){this.$$set({waveform_options:e}),Y()}get editable(){return this.$$.ctx[8]}set editable(e){this.$$set({editable:e}),Y()}get loop(){return this.$$.ctx[9]}set loop(e){this.$$set({loop:e}),Y()}}const Ls=Object.freeze(Object.defineProperty({__proto__:null,default:ms},Symbol.toStringTag,{value:"Module"}));export{Qn as A,ms as S,zn as W,st as a,Ls as b,Gi as p,pt as s};
104//# sourceMappingURL=StaticAudio-BTlfLZqT.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.