PageSourceSearch

https://ank0x0-toon3d.hf.space/assets/index-3744e2a9.js

js ank0x0-toon3d.hf.space collected 2026-10-03 10:18:08 UTC 111,543 bytes, 104 lines download raw bytes

vendor: 13,684 bytes, lines 1-17
1import{B as yi}from"./SelectSource.svelte_svelte_type_style_lang-50df0b5e.js";import{f as de,u as ts}from"./utils-572af92b.js";import{B as Ci}from"./BlockLabel-9907c55f.js";import{I as ns}from"./IconButton-3a75fcd3.js";import{E as Ei}from"./Empty-46e88333.js";import{S as is}from"./ShareButton-6d6936ed.js";import{D as ss,a as os}from"./DownloadLink-586904b2.js";import{S as Ri}from"./Index-3441375f.js";import{M as qt}from"./Music-755043aa.js";import{a as rs,P as Di,T as ls}from"./Trim-1b343e72.js";import{U as as}from"./Undo-b088de14.js";import{r as An}from"./file-url-3794127d.js";import{_ as Tn,p as us,u as cs}from"./index-df998e04.js";import{U as ds}from"./ModifyUpload.svelte_svelte_type_style_lang-999f7850.js";import{M as Si}from"./ModifyUpload-57409bb4.js";import{S as hs}from"./SelectSource-3aa7c7c1.js";import{U as fs}from"./UploadText-d9b96f23.js";import{default as Ba}from"./Example-fea4e4a6.js";import"./svelte/svelte.js";import"./Clear-2c7bae91.js";import"./Upload-351cc897.js";const{SvelteComponent:_s,append:ms,attr:ae,detach:gs,init:ps,insert:vs,noop:sn,safe_not_equal:bs,svg_element:zn}=window.__gradio__svelte__internal;function ws(i){let e,t;return{c(){e=zn("svg"),t=zn("path"),ae(t,"stroke","currentColor"),ae(t,"stroke-width","1.5"),ae(t,"stroke-linecap","round"),ae(t,"stroke-linejoin","round"),ae(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"),ae(e,"xmlns","http://www.w3.org/2000/svg"),ae(e,"width","24px"),ae(e,"height","24px"),ae(e,"fill","currentColor"),ae(e,"stroke-width","1.5"),ae(e,"viewBox","0 0 24 24"),ae(e,"color","currentColor")},m(n,s){vs(n,e,s),ms(e,t)},p:sn,i:sn,o:sn,d(n){n&&gs(e)}}}class ks extends _s{constructor(e){super(),ps(this,e,null,ws,bs,{})}}const{SvelteComponent:ys,append:Cs,attr:ue,detach:Es,init:Rs,insert:Ds,noop:on,safe_not_equal:Ss,svg_element:$n}=window.__gradio__svelte__internal;function Ls(i){let e,t;return{c(){e=$n("svg"),t=$n("path"),ue(t,"stroke","currentColor"),ue(t,"stroke-width","1.5"),ue(t,"stroke-linecap","round"),ue(t,"stroke-linejoin","round"),ue(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"),ue(e,"xmlns","http://www.w3.org/2000/svg"),ue(e,"width","24px"),ue(e,"height","24px"),ue(e,"fill","currentColor"),ue(e,"stroke-width","1.5"),ue(e,"viewBox","0 0 24 24"),ue(e,"color","currentColor")},m(n,s){Ds(n,e,s),Cs(e,t)},p:on,i:on,o:on,d(n){n&&Es(e)}}}class Ms extends ys{constructor(e){super(),Rs(this,e,null,Ls,Ss,{})}}const{SvelteComponent:Ps,append:Rt,attr:se,detach:As,init:Ts,insert:zs,noop:rn,safe_not_equal:$s,svg_element:Dt,text:Ws}=window.__gradio__svelte__internal;function qs(i){let e,t,n,s,o;return{c(){e=Dt("svg"),t=Dt("title"),n=Ws("Low volume"),s=Dt("path"),o=Dt("path"),se(s,"d","M19.5 7.5C19.5 7.5 21 9 21 11.5C21 14 19.5 15.5 19.5 15.5"),se(s,"stroke-width","1.5"),se(s,"stroke-linecap","round"),se(s,"stroke-linejoin","round"),se(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"),se(o,"stroke-width","1.5"),se(e,"width","100%"),se(e,"height","100%"),se(e,"viewBox","0 0 24 24"),se(e,"stroke-width","1.5"),se(e,"fill","none"),se(e,"xmlns","http://www.w3.org/2000/svg"),se(e,"stroke","currentColor"),se(e,"color","currentColor")},m(r,u){zs(r,e,u),Rt(e,t),Rt(t,n),Rt(e,s),Rt(e,o)},p:rn,i:rn,o:rn,d(r){r&&As(e)}}}class Os extends Ps{constructor(e){super(),Ts(this,e,null,qs,$s,{})}}const{SvelteComponent:Bs,append:ct,attr:j,detach:Hs,init:Vs,insert:Ns,noop:ln,safe_not_equal:Is,svg_element:dt,text:Us}=window.__gradio__svelte__internal;function js(i){let e,t,n,s,o,r;return{c(){e=dt("svg"),t=dt("title"),n=Us("High volume"),s=dt("path"),o=dt("path"),r=dt("path"),j(s,"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"),j(s,"stroke-width","1.5"),j(o,"d","M17.5 7.5C17.5 7.5 19 9 19 11.5C19 14 17.5 15.5 17.5 15.5"),j(o,"stroke-width","1.5"),j(o,"stroke-linecap","round"),j(o,"stroke-linejoin","round"),j(r,"d","M20.5 4.5C20.5 4.5 23 7 23 11.5C23 16 20.5 18.5 20.5 18.5"),j(r,"stroke-width","1.5"),j(r,"stroke-linecap","round"),j(r,"stroke-linejoin","round"),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,"stroke","currentColor"),j(e,"xmlns","http://www.w3.org/2000/svg"),j(e,"color","currentColor")},m(u,a){Ns(u,e,a),ct(e,t),ct(t,n),ct(e,s),ct(e,o),ct(e,r)},p:ln,i:ln,o:ln,d(u){u&&Hs(e)}}}class Fs extends Bs{constructor(e){super(),Vs(this,e,null,js,Is,{})}}const{SvelteComponent:Xs,append:Ee,attr:U,detach:Gs,init:Ys,insert:Zs,noop:an,safe_not_equal:Js,svg_element:Re,text:Ks}=window.__gradio__svelte__internal;function Qs(i){let e,t,n,s,o,r,u,a,d;return{c(){e=Re("svg"),t=Re("title"),n=Ks("Muted volume"),s=Re("g"),o=Re("path"),r=Re("path"),u=Re("defs"),a=Re("clipPath"),d=Re("rect"),U(o,"d","M18 14L20.0005 12M22 10L20.0005 12M20.0005 12L18 10M20.0005 12L22 14"),U(o,"stroke-width","1.5"),U(o,"stroke-linecap","round"),U(o,"stroke-linejoin","round"),U(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"),U(r,"stroke-width","1.5"),U(s,"clip-path","url(#clip0_3173_16686)"),U(d,"width","24"),U(d,"height","24"),U(d,"fill","white"),U(a,"id","clip0_3173_16686"),U(e,"width","100%"),U(e,"height","100%"),U(e,"viewBox","0 0 24 24"),U(e,"stroke-width","1.5"),U(e,"fill","none"),U(e,"xmlns","http://www.w3.org/2000/svg"),U(e,"stroke","currentColor"),U(e,"color","currentColor")},m(l,c){Zs(l,e,c),Ee(e,t),Ee(t,n),Ee(e,s),Ee(s,o),Ee(s,r),Ee(e,u),Ee(u,a),Ee(a,d)},p:an,i:an,o:an,d(l){l&&Gs(e)}}}class xs extends Xs{constructor(e){super(),Ys(this,e,null,Qs,Js,{})}}var eo=globalThis&&globalThis.__awaiter||function(i,e,t,n){function s(o){return o instanceof t?o:new t(function(r){r(o)})}return new(t||(t=Promise))(function(o,r){function u(l){try{d(n.next(l))}catch(c){r(c)}}function a(l){try{d(n.throw(l))}catch(c){r(c)}}function d(l){l.done?o(l.value):s(l.value).then(u,a)}d((n=n.apply(i,e||[])).next())})};function to(i,e){return eo(this,void 0,void 0,function*(){const t=new AudioContext({sampleRate:e});return t.decodeAudioData(i).finally(()=>t.close())})}function no(i){const e=i[0];if(e.some(t=>t>1||t<-1)){const t=e.length;let n=0;for(let s=0;s<t;s++){const o=Math.abs(e[s]);o>n&&(n=o)}for(const s of i)for(let o=0;o<t;o++)s[o]/=n}return i}function io(i,e){return typeof i[0]=="number"&&(i=[i]),no(i),{duration:e,length:i[0].length,sampleRate:i[0].length/e,numberOfChannels:i.length,getChannelData:t=>i?.[t],copyFromChannel:AudioBuffer.prototype.copyFromChannel,copyToChannel:AudioBuffer.prototype.copyToChannel}}const un={decode:to,createBuffer:io};var Wn=globalThis&&globalThis.__awaiter||function(i,e,t,n){function s(o){return o instanceof t?o:new t(function(r){r(o)})}return new(t||(t=Promise))(function(o,r){function u(l){try{d(n.next(l))}catch(c){r(c)}}function a(l){try{d(n.throw(l))}catch(c){r(c)}}function d(l){l.done?o(l.value):s(l.value).then(u,a)}d((n=n.apply(i,e||[])).next())})};function so(i,e,t){var n,s;return Wn(this,void 0,void 0,function*(){const o=yield fetch(i,t);{const r=(n=o.clone().body)===null||n===void 0?void 0:n.getReader(),u=Number((s=o.headers)===null||s===void 0?void 0:s.get("Content-Length"));let a=0;const d=(l,c)=>Wn(this,void 0,void 0,function*(){if(l)return;a+=c?.length||0;const h=Math.round(a/u*100);return e(h),r?.read().then(({done:_,value:m})=>d(_,m))});r?.read().then(({done:l,value:c})=>d(l,c))}return o.blob()})}const oo={fetchBlob:so};class Ot{constructor(){this.listeners={},this.on=this.addEventListener,this.un=this.removeEventListener}addEventListener(e,t,n){if(this.listeners[e]||(this.listeners[e]=new Set),this.listeners[e].add(t),n?.once){const s=()=>{this.removeEventListener(e,s),this.removeEventListener(e,t)};return this.addEventListener(e,s),s}return()=>this.removeEventListener(e,t)}removeEventListener(e,t){var n;(n=this.listeners[e])===null||n===void 0||n.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(n=>n(...t))}}class ro extends Ot{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,n){return this.media.addEventListener(e,t,n),()=>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 s=t instanceof Blob?URL.createObjectURL(t):e;this.media.src=s,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 lo(i,e,t,n,s=5){let o=()=>{};if(!i)return o;const r=u=>{if(u.button===2)return;u.preventDefault(),u.stopPropagation(),i.style.touchAction="none";let a=u.clientX,d=u.clientY,l=!1;const c=m=>{m.preventDefault(),m.stopPropagation();const f=m.clientX,g=m.clientY;if(l||Math.abs(f-a)>=s||Math.abs(g-d)>=s){const{left:k,top:E}=i.getBoundingClientRect();l||(l=!0,t?.(a-k,d-E)),e(f-a,g-d,f-k,g-E),a=f,d=g}},h=m=>{l&&(m.preventDefault(),m.stopPropagation())},_=()=>{i.style.touchAction="",l&&n?.(),o()};document.addEventListener("pointermove",c),document.addEventListener("pointerup",_),document.addEventListener("pointerleave",_),document.addEventListener("click",h,!0),o=()=>{document.removeEventListener("pointermove",c),document.removeEventListener("pointerup",_),document.removeEventListener("pointerleave",_),setTimeout(()=>{document.removeEventListener("click",h,!0)},10)}};return i.addEventListener("pointerdown",r),()=>{o(),i.removeEventListener("pointerdown",r)}}class Bt extends Ot{constructor(e,t){super(),this.timeouts=[],this.isScrolling=!1,this.audioData=null,this.resizeObserver=null,this.isDragging=!1,this.options=e;const n=this.parentFromOptionsContainer(e.container);this.parent=n;const[s,o]=this.initHtml();n.appendChild(s),this.container=s,this.scrollContainer=o.querySelector(".scroll"),this.wrapper=o.querySelector(".wrapper"),this.canvasWrapper=o.querySelector(".canvases"),this.progressWrapper=o.querySelector(".progress"),this.cursor=o.querySelector(".cursor"),t&&o.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=n=>{const s=this.wrapper.getBoundingClientRect(),o=n.clientX-s.left,r=n.clientX-s.left,u=o/s.width,a=r/s.height;return[u,a]};this.wrapper.addEventListener("click",n=>{const[s,o]=e(n);this.emit("click",s,o)}),this.wrapper.addEventListener("dblclick",n=>{const[s,o]=e(n);this.emit("dblclick",s,o)}),this.options.dragToSeek&&this.initDrag(),this.scrollContainer.addEventListener("scroll",()=>{const{scrollLeft:n,scrollWidth:s,clientWidth:o}=this.scrollContainer,r=n/s,u=(n+o)/s;this.emit("scroll",r,u)});const t=this.createDelay(100);this.resizeObserver=new ResizeObserver(()=>{t(()=>this.reRender())}),this.resizeObserver.observe(this.scrollContainer)}initDrag(){lo(this.wrapper,(e,t,n)=>{this.emit("drag",Math.max(0,Math.min(1,n/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),n=>{t.timeout&&clearTimeout(t.timeout),t.timeout=setTimeout(n,e)}}convertColorValues(e){if(!Array.isArray(e))return e||"";if(e.length<2)return e[0]||"";const t=document.createElement("canvas"),s=t.getContext("2d").createLinearGradient(0,0,0,t.height),o=1/(e.length-1);return e.forEach((r,u)=>{const a=u*o;s.addColorStop(a,r)}),s}renderBarWaveform(e,t,n,s){const o=e[0],r=e[1]||e[0],u=o.length,{width:a,height:d}=n.canvas,l=d/2,c=window.devicePixelRatio||1,h=t.barWidth?t.barWidth*c:1,_=t.barGap?t.barGap*c:t.barWidth?h/2:0,m=t.barRadius||0,f=a/(h+_)/u,g=m&&"roundRect"in n?"roundRect":"rect";n.beginPath();let k=0,E=0,p=0;for(let L=0;L<=u;L++){const R=Math.round(L*f);if(R>k){const T=Math.round(E*l*s),D=Math.round(p*l*s),z=T+D||1;let B=l-T;t.barAlign==="top"?B=0:t.barAlign==="bottom"&&(B=d-z),n[g](k*(h+_),B,h,z,m),k=R,E=0,p=0}const A=Math.abs(o[L]||0),C=Math.abs(r[L]||0);A>E&&(E=A),C>p&&(p=C)}n.fill(),n.closePath()}renderLineWaveform(e,t,n,s){const o=r=>{const u=e[r]||e[0],a=u.length,{height:d}=n.canvas,l=d/2,c=n.canvas.width/a;n.moveTo(0,l);let h=0,_=0;for(let m=0;m<=a;m++){const f=Math.round(m*c);if(f>h){const k=Math.round(_*l*s)||1,E=l+k*(r===0?-1:1);n.lineTo(h,E),h=f,_=0}const g=Math.abs(u[m]||0);g>_&&(_=g)}n.lineTo(h,l)};n.beginPath(),o(0),o(1),n.fill(),n.closePath()}renderWaveform(e,t,n){if(n.fillStyle=this.convertColorValues(t.waveColor),t.renderFunction){t.renderFunction(e,n);return}let s=t.barHeight||1;if(t.normalize){const o=Array.from(e[0]).reduce((r,u)=>Math.max(r,Math.abs(u)),0);s=o?1/o:1}if(t.barWidth||t.barGap||t.barAlign){this.renderBarWaveform(e,t,n,s);return}this.renderLineWaveform(e,t,n,s)}renderSingleCanvas(e,t,n,s,o,r,u,a){const d=window.devicePixelRatio||1,l=document.createElement("canvas"),c=e[0].length;l.width=Math.round(n*(r-o)/c),l.height=s*d,l.style.width=`${Math.floor(l.width/d)}px`,l.style.height=`${s}px`,l.style.left=`${Math.floor(o*n/d/c)}px`,u.appendChild(l);const h=l.getContext("2d");if(this.renderWaveform(e.map(_=>_.slice(o,r)),t,h),l.width>0&&l.height>0){const _=l.cloneNode(),m=_.getContext("2d");m.drawImage(l,0,0),m.globalCompositeOperation="source-in",m.fillStyle=this.convertColorValues(t.progressColor),m.fillRect(0,0,l.width,l.height),a.appendChild(_)}}renderChannel(e,t,n){const s=document.createElement("div"),o=this.getHeight();s.style.height=`${o}px`,this.canvasWrapper.style.minHeight=`${o}px`,this.canvasWrapper.appendChild(s);const r=s.cloneNode();this.progressWrapper.appendChild(r);const{scrollLeft:u,scrollWidth:a,clientWidth:d}=this.scrollContainer,l=e[0].length,c=l/a;let h=Math.min(Bt.MAX_CANVAS_WIDTH,d);if(t.barWidth||t.barGap){const R=t.barWidth||.5,A=t.barGap||R/2,C=R+A;h%C!==0&&(h=Math.floor(h/C)*C)}const _=Math.floor(Math.abs(u)*c),m=Math.floor(_+h*c),f=m-_,g=(R,A)=>{this.renderSingleCanvas(e,t,n,o,Math.max(0,R),Math.min(A,l),s,r)},k=this.createDelay(),E=this.createDelay(),p=(R,A)=>{g(R,A),R>0&&k(()=>{p(R-f,A-f)}
vendor: 29,513 bytes, lines 73-103
73)},L=(R,A)=>{g(R,A),A<l&&E(()=>{L(R+f,A+f)})};p(_,m),m<l&&L(m,m+f)}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,n=this.scrollContainer.clientWidth,s=Math.ceil(e.duration*(this.options.minPxPerSec||0));this.isScrolling=s>n;const o=this.options.fillParent&&!this.isScrolling,r=(o?n:s)*t;if(this.wrapper.style.width=o?"100%":`${s}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,r)}else{const u=[e.getChannelData(0)];e.numberOfChannels>1&&u.push(e.getChannelData(1)),this.renderChannel(u,this.options,r)}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:n,scrollLeft:s,scrollWidth:o}=this.scrollContainer,r=o*e,u=n/2,a=t&&this.options.autoCenter&&!this.isDragging?u:n;if(r>s+a||r<s)if(this.options.autoCenter&&!this.isDragging){const d=u/20;r-(s+u)>=d&&r<s+n?this.scrollContainer.scrollLeft+=d:this.scrollContainer.scrollLeft=r-u}else this.isDragging?this.scrollContainer.scrollLeft=r<s?r-10:r-n+10:this.scrollContainer.scrollLeft=r;{const{scrollLeft:d}=this.scrollContainer,l=d/o,c=(d+n)/o;this.emit("scroll",l,c)}}renderProgress(e,t){if(isNaN(e))return;const n=e*100;this.canvasWrapper.style.clipPath=`polygon(${n}% 0, 100% 0, 100% 100%, ${n}% 100%)`,this.progressWrapper.style.width=`${n}%`,this.cursor.style.left=`${n}%`,this.cursor.style.marginLeft=Math.round(n)===100?`-${this.options.cursorWidth}px`:"",this.isScrolling&&this.options.autoScroll&&this.scrollIntoView(e,t)}}Bt.MAX_CANVAS_WIDTH=4e3;class ao extends Ot{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 cn=globalThis&&globalThis.__awaiter||function(i,e,t,n){function s(o){return o instanceof t?o:new t(function(r){r(o)})}return new(t||(t=Promise))(function(o,r){function u(l){try{d(n.next(l))}catch(c){r(c)}}function a(l){try{d(n.throw(l))}catch(c){r(c)}}function d(l){l.done?o(l.value):s(l.value).then(u,a)}d((n=n.apply(i,e||[])).next())})};class uo extends Ot{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 cn(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 cn(this,void 0,void 0,function*(){this._play(),this.emit("play")})}pause(){this._pause(),this.emit("pause")}setSinkId(e){return cn(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 Qe=globalThis&&globalThis.__awaiter||function(i,e,t,n){function s(o){return o instanceof t?o:new t(function(r){r(o)})}return new(t||(t=Promise))(function(o,r){function u(l){try{d(n.next(l))}catch(c){r(c)}}function a(l){try{d(n.throw(l))}catch(c){r(c)}}function d(l){l.done?o(l.value):s(l.value).then(u,a)}d((n=n.apply(i,e||[])).next())})};const co={waveColor:"#999",progressColor:"#555",cursorWidth:1,minPxPerSec:0,fillParent:!0,interact:!0,dragToSeek:!1,autoScroll:!0,autoCenter:!0,sampleRate:8e3};class rt extends ro{static create(e){return new rt(e)}constructor(e){const t=e.media||(e.backend==="WebAudio"?new uo: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({},co,e),this.timer=new ao;const n=t?void 0:this.getMediaElement();this.renderer=new Bt(this.options,n),this.initPlayerEvents(),this.initRendererEvents(),this.initTimerEvents(),this.initPlugins();const s=this.options.url||this.getSrc();s?this.load(s,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 n=this.getDuration();this.emit("scroll",e*n,t*n)}),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 Qe(this,void 0,void 0,function*(){this.options.peaks&&this.options.duration&&(this.decodedData=un.createBuffer(this.options.peaks,this.options.duration),yield Promise.resolve(),this.renderDecoded())})}renderDecoded(){return Qe(this,void 0,void 0,function*(){this.decodedData&&(this.emit("decode",this.getDuration()),this.renderer.render(this.decodedData))})}loadAudio(e,t,n,s){return Qe(this,void 0,void 0,function*(){if(this.emit("load",e),!this.options.media&&this.isPlaying()&&this.pause(),this.decodedData=null,!t&&!n){const o=r=>this.emit("loading",r);t=yield oo.fetchBlob(e,o,this.options.fetchParams)}if(this.setSrc(e,t),s=(yield Promise.resolve(s||this.getDuration()))||(yield new Promise(o=>{this.onceMediaEvent("loadedmetadata",()=>o(this.getDuration()))}))||(yield Promise.resolve(0)),n)this.decodedData=un.createBuffer(n,s);else if(t){const o=yield t.arrayBuffer();this.decodedData=yield un.decode(o,this.options.sampleRate)}this.renderDecoded(),this.emit("ready",this.getDuration())})}load(e,t,n){return Qe(this,void 0,void 0,function*(){yield this.loadAudio(e,void 0,t,n)})}loadBlob(e,t,n){return Qe(this,void 0,void 0,function*(){yield this.loadAudio("blob",e,t,n)})}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:n=1e4}={}){if(!this.decodedData)throw new Error("The audio has not been decoded yet");const s=Math.min(e,this.decodedData.numberOfChannels),o=[];for(let r=0;r<s;r++){const u=this.decodedData.getChannelData(r),a=[],d=Math.round(u.length/t);for(let l=0;l<t;l++){const c=u.slice(l*d,(l+1)*d),h=Math.max(...c);a.push(Math.round(h*n)/n)}o.push(a)}return o}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 Qe(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 ho(i){const e=i.numberOfChannels,t=i.length*e*2+44,n=new ArrayBuffer(t),s=new DataView(n);let o=0;const r=function(u,a,d){for(let l=0;l<d.length;l++)u.setUint8(a+l,d.charCodeAt(l))};r(s,o,"RIFF"),o+=4,s.setUint32(o,t-8,!0),o+=4,r(s,o,"WAVE"),o+=4,r(s,o,"fmt "),o+=4,s.setUint32(o,16,!0),o+=4,s.setUint16(o,1,!0),o+=2,s.setUint16(o,e,!0),o+=2,s.setUint32(o,i.sampleRate,!0),o+=4,s.setUint32(o,i.sampleRate*2*e,!0),o+=4,s.setUint16(o,e*2,!0),o+=2,s.setUint16(o,16,!0),o+=2,r(s,o,"data"),o+=4,s.setUint32(o,i.length*e*2,!0),o+=4;for(let u=0;u<i.length;u++)for(let a=0;a<e;a++){const d=Math.max(-1,Math.min(1,i.getChannelData(a)[u]));s.setInt16(o,d*32767,!0),o+=2}return new Uint8Array(n)}const mn=async(i,e,t,n)=>{const s=new AudioContext({sampleRate:n||i.sampleRate}),o=i.numberOfChannels,r=n||i.sampleRate;let u=i.length,a=0;e&&t&&(a=Math.round(e*r),u=Math.round(t*r)-a);const d=s.createBuffer(o,u,r);for(let l=0;l<o;l++){const c=i.getChannelData(l),h=d.getChannelData(l);for(let _=0;_<u;_++)h[_]=c[a+_]}return ho(d)},At=(i,e)=>{i&&i.skip(e)},nt=(i,e)=>(e||(e=5),i/100*e||5);let Li=class{constructor(){this.listeners={},this.on=this.addEventListener,this.un=this.removeEventListener}addEventListener(e,t,n){if(this.listeners[e]||(this.listeners[e]=new Set),this.listeners[e].add(t),n?.once){const s=()=>{this.removeEventListener(e,s),this.removeEventListener(e,t)};return this.addEventListener(e,s),s}return()=>this.removeEventListener(e,t)}removeEventListener(e,t){var n;(n=this.listeners[e])===null||n===void 0||n.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(n=>n(...t))}},fo=class extends Li{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 Lt(i,e,t,n,s=5){let o=()=>{};if(!i)return o;const r=u=>{if(u.button===2)return;u.preventDefault(),u.stopPropagation(),i.style.touchAction="none";let a=u.clientX,d=u.clientY,l=!1;const c=m=>{m.preventDefault(),m.stopPropagation();const f=m.clientX,g=m.clientY;if(l||Math.abs(f-a)>=s||Math.abs(g-d)>=s){const{left:k,top:E}=i.getBoundingClientRect();l||(l=!0,t?.(a-k,d-E)),e(f-a,g-d,f-k,g-E),a=f,d=g}},h=m=>{l&&(m.preventDefault(),m.stopPropagation())},_=()=>{i.style.touchAction="",l&&n?.(),o()};document.addEventListener("pointermove",c),document.addEventListener("pointerup",_),document.addEventListener("pointerleave",_),document.addEventListener("click",h,!0),o=()=>{document.removeEventListener("pointermove",c),document.removeEventListener("pointerup",_),document.removeEventListener("pointerleave",_),setTimeout(()=>{document.removeEventListener("click",h,!0)},10)}};return i.addEventListener("pointerdown",r),()=>{o(),i.removeEventListener("pointerdown",r)}}class qn extends Li{constructor(e,t,n=0){var s,o,r,u,a,d,l;super(),this.totalDuration=t,this.numberOfChannels=n,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((s=e.end)!==null&&s!==void 0?s:e.start),this.drag=(o=e.drag)===null||o===void 0||o,this.resize=(r=e.resize)===null||r===void 0||r,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 n=t.cloneNode();n.setAttribute("data-resize","right"),n.style.left="",n.style.right="0",n.style.borderRight=n.style.borderLeft,n.style.borderLeft="",n.style.borderRadius="0 2px 2px 0",n.setAttribute("part","region-handle region-handle-right"),e.appendChild(t),e.appendChild(n),Lt(t,s=>this.onResize(s,"start"),()=>null,()=>this.onEndResizing(),1),Lt(n,s=>this.onResize(s,"end"),()=>null,()=>this.onEndResizing(),1)}removeResizeHandles(e){const t=e.querySelector('[data-resize="left"]'),n=e.querySelector('[data-resize="right"]');t&&e.removeChild(t),n&&e.removeChild(n)}initElement(){const e=document.createElement("div"),t=this.start===this.end;let n=0,s=100;return this.channelIdx>=0&&this.channelIdx<this.numberOfChannels&&(s=100/this.numberOfChannels,n=s*this.channelIdx),e.setAttribute("style",`
85      position: absolute;
86      top: ${n}%;
87      height: ${s}%;
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)),Lt(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 n=e/this.element.parentElement.clientWidth*this.totalDuration,s=t&&t!=="start"?this.start:this.start+n,o=t&&t!=="end"?this.end:this.end+n,r=o-s;s>=0&&o<=this.totalDuration&&s<=o&&r>=this.minLength&&r<=this.maxLength&&(this.start=s,this.end=o,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 n=this.start===this.end;this.content.style.padding=`0.2em ${n?.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,n;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 s=this.start===this.end;this.start=this.clampPosition((t=e.start)!==null&&t!==void 0?t:this.start),this.end=this.clampPosition((n=e.end)!==null&&n!==void 0?n:s?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 s=this.start===this.end;this.resize=e.resize,this.resize&&!s?this.addResizeHandles(this.element):this.removeResizeHandles(this.element)}}remove(){this.emit("remove"),this.element.remove(),this.element=null}}let _o=class Mi extends fo{constructor(e){super(e),this.regions=[],this.regionsContainer=this.initRegionsContainer()}static create(e){return new Mi(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 n=this.regions.filter(s=>s.start<=t&&s.end>=t);n.forEach(s=>{e.includes(s)||this.emit("region-in",s)}),e.forEach(s=>{n.includes(s)||this.emit("region-out",s)}),e=n}))}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,n=t.getBoundingClientRect().left,s=e.element.scrollWidth,o=this.regions.filter(r=>{if(r===e||!r.content)return!1;const u=r.content.getBoundingClientRect().left,a=r.element.scrollWidth;return n<u+a&&u<n+s}).map(r=>{var u;return((u=r.content)===null||u===void 0?void 0:u.getBoundingClientRect().height)||0}).reduce((r,u)=>r+u,0);t.style.marginTop=`${o}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 n,s;(n=this.wavesurfer)===null||n===void 0||n.play(),(s=this.wavesurfer)===null||s===void 0||s.setTime(e.start)}),e.on("click",n=>{this.emit("region-clicked",e,n)}),e.on("dblclick",n=>{this.emit("region-double-clicked",e,n)}),e.once("remove",()=>{t.forEach(n=>n()),this.regions=this.regions.filter(n=>n!==e)})];this.subscriptions.push(...t),this.emit("region-created",e)}addRegion(e){var t,n;if(!this.wavesurfer)throw Error("WaveSurfer is not initialized");const s=this.wavesurfer.getDuration(),o=(n=(t=this.wavesurfer)===null||t===void 0?void 0:t.getDecodedData())===null||n===void 0?void 0:n.numberOfChannels,r=new qn(e,s,o);return s?this.saveRegion(r):this.subscriptions.push(this.wavesurfer.once("ready",u=>{r._setTotalDuration(u),this.saveRegion(r)})),r}enableDragSelection(e){var t,n;const s=(n=(t=this.wavesurfer)===null||t===void 0?void 0:t.getWrapper())===null||n===void 0?void 0:n.querySelector("div");if(!s)return()=>{};let o=null,r=0;return Lt(s,(u,a,d)=>{o&&o._onUpdate(u,d>r?"end":"start")},u=>{var a,d;if(r=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,h=this.wavesurfer.getWrapper().clientWidth,_=u/h*l,m=(u+5)/h*l;o=new qn(Object.assign(Object.assign({},e),{start:_,end:m}),l,c),this.regionsContainer.appendChild(o.element)},()=>{o&&(this.saveRegion(o),o=null)})}clearRegions(){this.regions.forEach(e=>e.remove())}destroy(){this.clearRegions(),super.destroy()}};const{SvelteComponent:mo,check_outros:go,create_component:wn,destroy_component:kn,detach:po,empty:vo,flush:bo,group_outros:wo,init:ko,insert:yo,mount_component:yn,safe_not_equal:Co,transition_in:wt,transition_out:kt}=window.__gradio__svelte__internal;function Eo(i){let e,t;return e=new Fs({}),{c(){wn(e.$$.fragment)},m(n,s){yn(e,n,s),t=!0},i(n){t||(wt(e.$$.fragment,n),t=!0)},o(n){kt(e.$$.fragment,n),t=!1},d(n){kn(e,n)}}}function Ro(i){let e,t;return e=new Os({}),{c(){wn(e.$$.fragment)},m(n,s){yn(e,n,s),t=!0},i(n){t||(wt(e.$$.fragment,n),t=!0)},o(n){kt(e.$$.fragment,n),t=!1},d(n){kn(e,n)}}}function Do(i){let e,t;return e=new xs({}),{c(){wn(e.$$.fragment)},m(n,s){yn(e,n,s),t=!0},i(n){t||(wt(e.$$.fragment,n),t=!0)},o(n){kt(e.$$.fragment,n),t=!1},d(n){kn(e,n)}}}function So(i){let e,t,n,s;const o=[Do,Ro,Eo],r=[];function u(a,d){return a[0]==0?0:a[0]<.5?1:a[0]>=.5?2:-1}return~(e=u(i))&&(t=r[e]=o[e](i)),{c(){t&&t.c(),n=vo()},m(a,d){~e&&r[e].m(a,d),yo(a,n,d),s=!0},p(a,[d]){let l=e;e=u(a),e!==l&&(t&&(wo(),kt(r[l],1,1,()=>{r[l]=null}),go()),~e?(t=r[e],t||(t=r[e]=o[e](a),t.c()),wt(t,1),t.m(n.parentNode,n)):t=null)},i(a){s||(wt(t),s=!0)},o(a){kt(t),s=!1},d(a){a&&po(n),~e&&r[e].d(a)}}}function Lo(i,e,t){let{currentVolume:n}=e;return i.$$set=s=>{"currentVolume"in s&&t(0,n=s.currentVolume)},[n]}class Mo extends mo{constructor(e){super(),ko(this,e,Lo,So,Co,{currentVolume:0})}get currentVolume(){return this.$$.ctx[0]}set currentVolume(e){this.$$set({currentVolume:e}),bo()}}const{SvelteComponent:Po,attr:xe,binding_callbacks:Ao,detach:To,element:zo,flush:dn,init:$o,insert:Wo,listen:On,noop:Bn,run_all:qo,safe_not_equal:Oo}=window.__gradio__svelte__internal,{onMount:Bo}=window.__gradio__svelte__internal;function Ho(i){let e,t,n;return{c(){e=zo("input"),xe(e,"id","volume"),xe(e,"class","volume-slider svelte-wuo8j5"),xe(e,"type","range"),xe(e,"min","0"),xe(e,"max","1"),xe(e,"step","0.01"),e.value=i[0]},m(s,o){Wo(s,e,o),i[4](e),t||(n=[On(e,"focusout",i[5]),On(e,"input",i[6])],t=!0)},p(s,[o]){o&1&&(e.value=s[0])},i:Bn,o:Bn,d(s){s&&To(e),i[4](null),t=!1,qo(n)}}}function Vo(i,e,t){let{currentVolume:n=1}=e,{show_volume_slider:s=!1}=e,{waveform:o}=e,r;Bo(()=>{u()});const u=()=>{let c=r;c&&(c.style.background=`linear-gradient(to right, var(--color-accent) ${n*100}%, var(--neutral-400) ${n*100}%)`)};function a(c){Ao[c?"unshift":"push"](()=>{r=c,t(3,r)})}const d=()=>t(1,s=!1),l=c=>{c.target instanceof HTMLInputElement&&(t(0,n=parseFloat(c.target.value)),o.setVolume(n))};return i.$$set=c=>{"currentVolume"in c&&t(0,n=c.currentVolume),"show_volume_slider"in c&&t(1,s=c.show_volume_slider),"waveform"in c&&t(2,o=c.waveform)},i.$$.update=()=>{i.$$.dirty&1&&u()},[n,s,o,r,a,d,l]}class No extends Po{constructor(e){super(),$o(this,e,Vo,Ho,Oo,{currentVolume:0,show_volume_slider:1,waveform:2})}get currentVolume(){return this.$$.ctx[0]}set currentVolume(e){this.$$set({currentVolume:e}),dn()}get show_volume_slider(){return this.$$.ctx[1]}set show_volume_slider(e){this.$$set({show_volume_slider:e}),dn()}get waveform(){return this.$$.ctx[2]}set waveform(e){this.$$set({waveform:e}),dn()}}const{SvelteComponent:Io,add_flush_callback:Hn,append:Y,attr:H,bind:Vn,binding_callbacks:Nn,check_outros:pt,create_component:Pe,destroy_component:Ae,detach:Te,element:oe,empty:Uo,flush:ee,group_outros:vt,init:jo,insert:ze,listen:ve,mount_component:$e,noop:bt,run_all:Pi,safe_not_equal:Fo,set_data:Xo,set_style:In,space:Se,text:Un,toggle_class:jn,transition_in:N,transition_out:F}=window.__gradio__svelte__internal;function Fn(i){let e,t,n,s;function o(a){i[27](a)}function r(a){i[28](a)}let u={waveform:i[2]};return i[12]!==void 0&&(u.currentVolume=i[12]),i[1]!==void 0&&(u.show_volume_slider=i[1]),e=new No({props:u}),Nn.push(()=>Vn(e,"currentVolume",o)),Nn.push(()=>Vn(e,"show_volume_slider",r)),{c(){Pe(e.$$.fragment)},m(a,d){$e(e,a,d),s=!0},p(a,d){const l={};d[0]&4&&(l.waveform=a[2]),!t&&d[0]&4096&&(t=!0,l.currentVolume=a[12],Hn(()=>t=!1)),!n&&d[0]&2&&(n=!0,l.show_volume_slider=a[1],Hn(()=>n=!1)),e.$set(l)},i(a){s||(N(e.$$.fragment,a),s=!0)},o(a){F(e.$$.fragment,a),s=!1},d(a){Ae(e,a)}}}function Go(i){let e,t;return e=new rs({}),{c(){Pe(e.$$.fragment)},m(n,s){$e(e,n,s),t=!0},i(n){t||(N(e.$$.fragment,n),t=!0)},o(n){F(e.$$.fragment,n),t=!1},d(n){Ae(e,n)}}}function Yo(i){let e,t;return e=new Di({}),{c(){Pe(e.$$.fragment)},m(n,s){$e(e,n,s),t=!0},i(n){t||(N(e.$$.fragment,n),t=!0)},o(n){F(e.$$.fragment,n),t=!1},d(n){Ae(e,n)}}}function Xn(i){let e,t,n,s,o,r=i[6]&&i[0]===""&&Gn(i);const u=[Jo,Zo],a=[];function d(l,c){return l[0]===""?0:1}return t=d(i),n=a[t]=u[t](i),{c(){r&&r.c(),e=Se(),n.c(),s=Uo()},m(l,c){r&&r.m(l,c),ze(l,e,c),a[t].m(l,c),ze(l,s,c),o=!0},p(l,c){l[6]&&l[0]===""?r?(r.p(l,c),c[0]&65&&N(r,1)):(r=Gn(l),r.c(),N(r,1),r.m(e.parentNode,e)):r&&(vt(),F(r,1,1,()=>{r=null}),pt());let h=t;t=d(l),t===h?a[t].p(l,c):(vt(),F(a[h],1,1,()=>{a[h]=null}),pt(),n=a[t],n?n.p(l,c):(n=a[t]=u[t](l),n.c()),N(n,1),n.m(s.parentNode,s))},i(l){o||(N(r),N(n),o=!0)},o(l){F(r),F(n),o=!1},d(l){l&&(Te(e),Te(s)),r&&r.d(l),a[t].d(l)}}}function Gn(i){let e,t,n,s,o;return t=new as({}),{c(){e=oe("button"),Pe(t.$$.fragment),H(e,"class","action icon svelte-16ezq5z"),H(e,"aria-label","Reset audio")},m(r,u){ze(r,e,u),$e(t,e,null),n=!0,s||(o=ve(e,"click",i[33]),s=!0)},p:bt,i(r){n||(N(t.$$.fragment,r),n=!0)},o(r){F(t.$$.fragment,r),n=!1},d(r){r&&Te(e),Ae(t),s=!1,o()}}}function Zo(i){let e,t,n,s,o;return{c(){e=oe("button"),e.textContent="Trim",t=Se(),n=oe("button"),n.textContent="Cancel",H(e,"class","text-button svelte-16ezq5z"),H(n,"class","text-button svelte-16ezq5z")},m(r,u){ze(r,e,u),ze(r,t,u),ze(r,n,u),s||(o=[ve(e,"click",i[14]),ve(n,"click",i[16])],s=!0)},p:bt,i:bt,o:bt,d(r){r&&(Te(e),Te(t),Te(n)),s=!1,Pi(o)}}}function Jo(i){let e,t,n,s,o;return t=new ls({}),{c(){e=oe("button"),Pe(t.$$.fragment),H(e,"class","action icon svelte-16ezq5z"),H(e,"aria-label","Trim audio to selection")},m(r,u){ze(r,e,u),$e(t,e,null),n=!0,s||(o=ve(e,"click",i[16]),s=!0)},p:bt,i(r){n||(N(t.$$.fragment,r),n=!0)},o(r){F(t.$$.fragment,r),n=!1},d(r){r&&Te(e),Ae(t),s=!1,o()}}}function Ko(i){let e,t,n,s,o,r,u,a,d,l,c,h,_,m,f,g,k,E,p,L,R,A,C,T,D,z,B,q,$,X;s=new Mo({props:{currentVolume:i[12]}});let W=i[1]&&Fn(i);f=new ks({});const M=[Yo,Go],v=[];function I(P,b){return P[5]?0:1}p=I(i),L=v[p]=M[p](i),T=new Ms({});let O=i[10]&&i[7]&&Xn(i);return{c(){e=oe("div"),t=oe("div"),n=oe("button"),Pe(s.$$.fragment),o=Se(),W&&W.c(),r=Se(),u=oe("button"),a=oe("span"),d=Un(i[11]),l=Un("x"),h=Se(),_=oe("div"),m=oe("button"),Pe(f.$$.fragment),k=Se(),E=oe("button"),L.c(),A=Se(),C=oe("button"),Pe(T.$$.fragment),z=Se(),B=oe("div"),O&&O.c(),H(n,"class","action icon volume svelte-16ezq5z"),H(n,"aria-label","Adjust volume"),In(n,"color",i[1]?"var(--color-accent)":"var(--neutral-400)"),H(u,"class","playback icon svelte-16ezq5z"),H(u,"aria-label",c=`Adjust playback speed to ${i[13][(i[13].indexOf(i[11])+1)%i[13].length]}x`),jn(u,"hidden",i[1]),H(t,"class","control-wrapper svelte-16ezq5z"),H(m,"class","rewind icon svelte-16ezq5z"),H(m,"aria-label",g=`Skip backwards by ${nt(i[3],i[9].skip_length)} seconds`),H(E,"class","play-pause-button icon svelte-16ezq5z"),H(E,"aria-label",R=i[5]?i[4]("audio.pause"):i[4]("audio.play")),H(C,"class","skip icon svelte-16ezq5z"),H(C,"aria-label",D="Skip forward by "+nt(i[3],i[9].skip_length)+" seconds"),H(_,"class","play-pause-wrapper svelte-16ezq5z"),H(B,"class","settings-wrapper svelte-16ezq5z"),H(e,"class","controls svelte-16ezq5z"),H(e,"data-testid","waveform-control
103s")},m(P,b){ze(P,e,b),Y(e,t),Y(t,n),$e(s,n,null),Y(t,o),W&&W.m(t,null),Y(t,r),Y(t,u),Y(u,a),Y(a,d),Y(a,l),Y(e,h),Y(e,_),Y(_,m),$e(f,m,null),Y(_,k),Y(_,E),v[p].m(E,null),Y(_,A),Y(_,C),$e(T,C,null),Y(e,z),Y(e,B),O&&O.m(B,null),q=!0,$||(X=[ve(n,"click",i[26]),ve(u,"click",i[29]),ve(m,"click",i[30]),ve(E,"click",i[31]),ve(C,"click",i[32])],$=!0)},p(P,b){const G={};b[0]&4096&&(G.currentVolume=P[12]),s.$set(G),b[0]&2&&In(n,"color",P[1]?"var(--color-accent)":"var(--neutral-400)"),P[1]?W?(W.p(P,b),b[0]&2&&N(W,1)):(W=Fn(P),W.c(),N(W,1),W.m(t,r)):W&&(vt(),F(W,1,1,()=>{W=null}),pt()),(!q||b[0]&2048)&&Xo(d,P[11]),(!q||b[0]&2048&&c!==(c=`Adjust playback speed to ${P[13][(P[13].indexOf(P[11])+1)%P[13].length]}x`))&&H(u,"aria-label",c),(!q||b[0]&2)&&jn(u,"hidden",P[1]),(!q||b[0]&520&&g!==(g=`Skip backwards by ${nt(P[3],P[9].skip_length)} seconds`))&&H(m,"aria-label",g);let y=p;p=I(P),p!==y&&(vt(),F(v[y],1,1,()=>{v[y]=null}),pt(),L=v[p],L||(L=v[p]=M[p](P),L.c()),N(L,1),L.m(E,null)),(!q||b[0]&48&&R!==(R=P[5]?P[4]("audio.pause"):P[4]("audio.play")))&&H(E,"aria-label",R),(!q||b[0]&520&&D!==(D="Skip forward by "+nt(P[3],P[9].skip_length)+" seconds"))&&H(C,"aria-label",D),P[10]&&P[7]?O?(O.p(P,b),b[0]&1152&&N(O,1)):(O=Xn(P),O.c(),N(O,1),O.m(B,null)):O&&(vt(),F(O,1,1,()=>{O=null}),pt())},i(P){q||(N(s.$$.fragment,P),N(W),N(f.$$.fragment,P),N(L),N(T.$$.fragment,P),N(O),q=!0)},o(P){F(s.$$.fragment,P),F(W),F(f.$$.fragment,P),F(L),F(T.$$.fragment,P),F(O),q=!1},d(P){P&&Te(e),Ae(s),W&&W.d(),Ae(f),v[p].d(),Ae(T),O&&O.d(),$=!1,Pi(X)}}}function Qo(i,e,t){let{waveform:n}=e,{audio_duration:s}=e,{i18n:o}=e,{playing:r}=e,{show_redo:u=!1}=e,{interactive:a=!1}=e,{handle_trim_audio:d}=e,{mode:l=""}=e,{container:c}=e,{handle_reset_value:h}=e,{waveform_options:_={}}=e,{trim_region_settings:m={}}=e,{show_volume_slider:f=!1}=e,{editable:g=!0}=e,{trimDuration:k=0}=e,E=[.5,1,1.5,2],p=E[1],L,R=null,A,C,T="",D=1;const z=()=>{t(22,R=L.addRegion({start:s/4,end:s/2,...m})),t(17,k=R.end-R.start)},B=()=>{if(n&&L&&R){const y=R.start,J=R.end;d(y,J),t(0,l=""),t(22,R=null)}},q=()=>{L?.getRegions().forEach(y=>{y.remove()}),L?.clearRegions()},$=()=>{q(),l==="edit"?t(0,l=""):(t(0,l="edit"),z())},X=(y,J)=>{let le,me;R&&(y==="left"?J==="ArrowLeft"?(le=R.start-.05,me=R.end):(le=R.start+.05,me=R.end):J==="ArrowLeft"?(le=R.start,me=R.end-.05):(le=R.start,me=R.end+.05),R.setOptions({start:le,end:me}),t(17,k=R.end-R.start))},W=()=>t(1,f=!f);function M(y){D=y,t(12,D)}function v(y){f=y,t(1,f)}const I=()=>{t(11,p=E[(E.indexOf(p)+1)%E.length]),n.setPlaybackRate(p)},O=()=>n.skip(nt(s,_.skip_length)*-1),P=()=>n.playPause(),b=()=>n.skip(nt(s,_.skip_length)),G=()=>{h(),q(),t(0,l="")};return i.$$set=y=>{"waveform"in y&&t(2,n=y.waveform),"audio_duration"in y&&t(3,s=y.audio_duration),"i18n"in y&&t(4,o=y.i18n),"playing"in y&&t(5,r=y.playing),"show_redo"in y&&t(6,u=y.show_redo),"interactive"in y&&t(7,a=y.interactive),"handle_trim_audio"in y&&t(18,d=y.handle_trim_audio),"mode"in y&&t(0,l=y.mode),"container"in y&&t(19,c=y.container),"handle_reset_value"in y&&t(8,h=y.handle_reset_value),"waveform_options"in y&&t(9,_=y.waveform_options),"trim_region_settings"in y&&t(20,m=y.trim_region_settings),"show_volume_slider"in y&&t(1,f=y.show_volume_slider),"editable"in y&&t(10,g=y.editable),"trimDuration"in y&&t(17,k=y.trimDuration)},i.$$.update=()=>{if(i.$$.dirty[0]&4&&t(21,L=n.registerPlugin(_o.create())),i.$$.dirty[0]&2097152&&L?.on("region-out",y=>{y.play()}),i.$$.dirty[0]&2097152&&L?.on("region-updated",y=>{t(17,k=y.end-y.start)}),i.$$.dirty[0]&2097152&&L?.on("region-clicked",(y,J)=>{J.stopPropagation(),t(22,R=y),y.play()}),i.$$.dirty[0]&31981568&&R){const y=c.children[0].shadowRoot;t(24,C=y.querySelector('[data-resize="right"]')),t(23,A=y.querySelector('[data-resize="left"]')),A&&C&&(A.setAttribute("role","button"),C.setAttribute("role","button"),A?.setAttribute("aria-label","Drag to adjust start time"),C?.setAttribute("aria-label","Drag to adjust end time"),A?.setAttribute("tabindex","0"),C?.setAttribute("tabindex","0"),A.addEventListener("focus",()=>{L&&t(25,T="left")}),C.addEventListener("focus",()=>{L&&t(25,T="right")}))}i.$$.dirty[0]&35651584&&L&&window.addEventListener("keydown",y=>{y.key==="ArrowLeft"?X(T,"ArrowLeft"):y.key==="ArrowRight"&&X(T,"ArrowRight")})}
103,[l,f,n,s,o,r,u,a,h,_,g,p,D,E,B,q,$,k,d,c,m,L,R,A,C,T,W,M,v,I,O,P,b,G]}class Ai extends Io{constructor(e){super(),jo(this,e,Qo,Ko,Fo,{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}),ee()}get audio_duration(){return this.$$.ctx[3]}set audio_duration(e){this.$$set({audio_duration:e}),ee()}get i18n(){return this.$$.ctx[4]}set i18n(e){this.$$set({i18n:e}),ee()}get playing(){return this.$$.ctx[5]}set playing(e){this.$$set({playing:e}),ee()}get show_redo(){return this.$$.ctx[6]}set show_redo(e){this.$$set({show_redo:e}),ee()}get interactive(){return this.$$.ctx[7]}set interactive(e){this.$$set({interactive:e}),ee()}get handle_trim_audio(){return this.$$.ctx[18]}set handle_trim_audio(e){this.$$set({handle_trim_audio:e}),ee()}get mode(){return this.$$.ctx[0]}set mode(e){this.$$set({mode:e}),ee()}get container(){return this.$$.ctx[19]}set container(e){this.$$set({container:e}),ee()}get handle_reset_value(){return this.$$.ctx[8]}set handle_reset_value(e){this.$$set({handle_reset_value:e}),ee()}get waveform_options(){return this.$$.ctx[9]}set waveform_options(e){this.$$set({waveform_options:e}),ee()}get trim_region_settings(){return this.$$.ctx[20]}set trim_region_settings(e){this.$$set({trim_region_settings:e}),ee()}get show_volume_slider(){return this.$$.ctx[1]}set show_volume_slider(e){this.$$set({show_volume_slider:e}),ee()}get editable(){return this.$$.ctx[10]}set editable(e){this.$$set({editable:e}),ee()}get trimDuration(){return this.$$.ctx[17]}set trimDuration(e){this.$$set({trimDuration:e}),ee()}}const{SvelteComponent:xo,add_flush_callback:hn,append:fe,attr:x,bind:fn,binding_callbacks:ot,check_outros:Ti,create_component:Cn,destroy_component:En,detach:Ht,element:pe,empty:er,flush:he,group_outros:zi,init:tr,insert:Vt,mount_component:Rn,noop:Yn,safe_not_equal:nr,set_data:ir,space:St,src_url_equal:Zn,text:sr,transition_in:We,transition_out:je}=window.__gradio__svelte__internal,{onMount:or}=window.__gradio__svelte__internal,{createEventDispatcher:rr}=window.__gradio__svelte__internal;function lr(i){let e,t,n,s,o,r,u,a,d,l,c,h,_,m=i[0]==="edit"&&i[16]>0&&Jn(i),f=i[11]&&Kn(i);return{c(){e=pe("div"),t=pe("div"),n=pe("div"),s=St(),o=pe("div"),r=pe("time"),r.textContent="0:00",u=St(),a=pe("div"),m&&m.c(),d=St(),l=pe("time"),l.textContent="0:00",c=St(),f&&f.c(),x(n,"id","waveform"),x(n,"class","svelte-1ark3ru"),x(t,"class","waveform-container svelte-1ark3ru"),x(r,"id","time"),x(r,"class","svelte-1ark3ru"),x(l,"id","duration"),x(l,"class","svelte-1ark3ru"),x(o,"class","timestamps svelte-1ark3ru"),x(e,"class","component-wrapper svelte-1ark3ru"),x(e,"data-testid",h=i[2]?"waveform-"+i[2]:"unlabelled-audio")},m(g,k){Vt(g,e,k),fe(e,t),fe(t,n),i[21](n),fe(e,s),fe(e,o),fe(o,r),i[22](r),fe(o,u),fe(o,a),m&&m.m(a,null),fe(a,d),fe(a,l),i[23](l),fe(e,c),f&&f.m(e,null),_=!0},p(g,k){g[0]==="edit"&&g[16]>0?m?m.p(g,k):(m=Jn(g),m.c(),m.m(a,d)):m&&(m.d(1),m=null),g[11]?f?(f.p(g,k),k&2048&&We(f,1)):(f=Kn(g),f.c(),We(f,1),f.m(e,null)):f&&(zi(),je(f,1,1,()=>{f=null}),Ti()),(!_||k&4&&h!==(h=g[2]?"waveform-"+g[2]:"unlabelled-audio"))&&x(e,"data-testid",h)},i(g){_||(We(f),_=!0)},o(g){je(f),_=!1},d(g){g&&Ht(e),i[21](null),i[22](null),m&&m.d(),i[23](null),f&&f.d()}}}function ar(i){let e,t,n;return{c(){e=pe("audio"),x(e,"class","standard-player svelte-1ark3ru"),Zn(e.src,t=i[1].url)||x(e,"src",t),e.controls=!0,e.autoplay=n=i[7].autoplay},m(s,o){Vt(s,e,o)},p(s,o){o&2&&!Zn(e.src,t=s[1].url)&&x(e,"src",t),o&128&&n!==(n=s[7].autoplay)&&(e.autoplay=n)},i:Yn,o:Yn,d(s){s&&Ht(e)}}}function ur(i){let e,t;return e=new Ei({props:{size:"small",$$slots:{default:[cr]},$$scope:{ctx:i}}}),{c(){Cn(e.$$.fragment)},m(n,s){Rn(e,n,s),t=!0},p(n,s){const o={};s&1073741824&&(o.$$scope={dirty:s,ctx:n}),e.$set(o)},i(n){t||(We(e.$$.fragment,n),t=!0)},o(n){je(e.$$.fragment,n),t=!1},d(n){En(e,n)}}}function Jn(i){let e,t=de(i[16])+"",n;return{c(){e=pe("time"),n=sr(t),x(e,"id","trim-duration"),x(e,"class","svelte-1ark3ru")},m(s,o){Vt(s,e,o),fe(e,n)},p(s,o){o&65536&&t!==(t=de(s[16])+"")&&ir(n,t)},d(s){s&&Ht(e)}}}function Kn(i){let e,t,n,s,o;function r(l){i[24](l)}function u(l){i[25](l)}function a(l){i[26](l)}let d={container:i[10],waveform:i[11],playing:i[14],audio_duration:i[15],i18n:i[3],interactive:i[4],handle_trim_audio:i[18],show_redo:i[4],handle_reset_value:i[9],waveform_options:i[8],trim_region_settings:i[6],editable:i[5]};return i[0]!==void 0&&(d.mode=i[0]),i[16]!==void 0&&(d.trimDuration=i[16]),i[17]!==void 0&&(d.show_volume_slider=i[17]),e=new Ai({props:d}),ot.push(()=>fn(e,"mode",r)),ot.push(()=>fn(e,"trimDuration",u)),ot.push(()=>fn(e,"show_volume_slider",a)),{c(){Cn(e.$$.fragment)},m(l,c){Rn(e,l,c),o=!0},p(l,c){const h={};c&1024&&(h.container=l[10]),c&2048&&(h.waveform=l[11]),c&16384&&(h.playing=l[14]),c&32768&&(h.audio_duration=l[15]),c&8&&(h.i18n=l[3]),c&16&&(h.interactive=l[4]),c&16&&(h.show_redo=l[4]),c&512&&(h.handle_reset_value=l[9]),c&256&&(h.waveform_options=l[8]),c&64&&(h.trim_region_settings=l[6]),c&32&&(h.editable=l[5]),!t&&c&1&&(t=!0,h.mode=l[0],hn(()=>t=!1)),!n&&c&65536&&(n=!0,h.trimDuration=l[16],hn(()=>n=!1)),!s&&c&131072&&(s=!0,h.show_volume_slider=l[17],hn(()=>s=!1)),e.$set(h)},i(l){o||(We(e.$$.fragment,l),o=!0)},o(l){je(e.$$.fragment,l),o=!1},d(l){En(e,l)}}}function cr(i){let e,t;return e=new qt({}),{c(){Cn(e.$$.fragment)},m(n,s){Rn(e,n,s),t=!0},i(n){t||(We(e.$$.fragment,n),t=!0)},o(n){je(e.$$.fragment,n),t=!1},d(n){En(e,n)}}}function dr(i){let e,t,n,s;const o=[ur,ar,lr],r=[];function u(a,d){return a[1]===null?0:a[1].is_stream?1:2}return e=u(i),t=r[e]=o[e](i),{c(){t.c(),n=er()},m(a,d){r[e].m(a,d),Vt(a,n,d),s=!0},p(a,[d]){let l=e;e=u(a),e===l?r[e].p(a,d):(zi(),je(r[l],1,1,()=>{r[l]=null}),Ti(),t=r[e],t?t.p(a,d):(t=r[e]=o[e](a),t.c()),We(t,1),t.m(n.parentNode,n))},i(a){s||(We(t),s=!0)},o(a){je(t),s=!1},d(a){a&&Ht(n),r[e].d(a)}}}function hr(i,e,t){let n,{value:s=null}=e,{label:o}=e,{i18n:r}=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:h}=e,{mode:_=""}=e,{handle_reset_value:m=()=>{}}=e,f,g,k=!1,E,p,L,R=0,A=!1;const C=rr(),T=()=>{t(11,g=rt.create({container:f,...c})),An(s?.url).then(v=>{if(v&&g)return g.load(v)})},D=async(v,I)=>{t(0,_="");const O=g?.getDecodedData();O&&await mn(O,v,I,c.sampleRate).then(async P=>{await u([P],"change"),g?.destroy(),t(10,f.innerHTML="",f)}),C("edit")};async function z(v){await An(v).then(I=>
103{if(!(!I||s?.is_stream))return g?.load(I)})}or(()=>{window.addEventListener("keydown",v=>{!g||A||(v.key==="ArrowRight"&&_!=="edit"?At(g,.1):v.key==="ArrowLeft"&&_!=="edit"&&At(g,-.1))})});function B(v){ot[v?"unshift":"push"](()=>{f=v,t(10,f),t(11,g)})}function q(v){ot[v?"unshift":"push"](()=>{E=v,t(12,E),t(11,g)})}function $(v){ot[v?"unshift":"push"](()=>{p=v,t(13,p),t(11,g)})}function X(v){_=v,t(0,_)}function W(v){R=v,t(16,R)}function M(v){A=v,t(17,A)}return i.$$set=v=>{"value"in v&&t(1,s=v.value),"label"in v&&t(2,o=v.label),"i18n"in v&&t(3,r=v.i18n),"dispatch_blob"in v&&t(19,u=v.dispatch_blob),"interactive"in v&&t(4,a=v.interactive),"editable"in v&&t(5,d=v.editable),"trim_region_settings"in v&&t(6,l=v.trim_region_settings),"waveform_settings"in v&&t(7,c=v.waveform_settings),"waveform_options"in v&&t(8,h=v.waveform_options),"mode"in v&&t(0,_=v.mode),"handle_reset_value"in v&&t(9,m=v.handle_reset_value)},i.$$.update=()=>{i.$$.dirty&2&&t(20,n=s?.url),i.$$.dirty&3072&&f!==void 0&&(g!==void 0&&g.destroy(),t(10,f.innerHTML="",f),T(),t(14,k=!1)),i.$$.dirty&10240&&g?.on("decode",v=>{t(15,L=v),p&&t(13,p.textContent=de(v),p)}),i.$$.dirty&6144&&g?.on("timeupdate",v=>E&&t(12,E.textContent=de(v),E)),i.$$.dirty&2176&&g?.on("ready",()=>{c.autoplay?g?.play():g?.stop()}),i.$$.dirty&2048&&g?.on("finish",()=>{t(14,k=!1),C("stop")}),i.$$.dirty&2048&&g?.on("pause",()=>{t(14,k=!1),C("pause")}),i.$$.dirty&2048&&g?.on("play",()=>{t(14,k=!0),C("play")}),i.$$.dirty&1048576&&n&&z(n)},[_,s,o,r,a,d,l,c,h,m,f,g,E,p,k,L,R,A,D,u,n,B,q,$,X,W,M]}class fr extends xo{constructor(e){super(),tr(this,e,hr,dr,nr,{value:1,label:2,i18n:3,dispatch_blob:19,interactive:4,editable:5,trim_region_settings:6,waveform_settings:7,waveform_options:8,mode:0,handle_reset_value:9})}get value(){return this.$$.ctx[1]}set value(e){this.$$set({value:e}),he()}get label(){return this.$$.ctx[2]}set label(e){this.$$set({label:e}),he()}get i18n(){return this.$$.ctx[3]}set i18n(e){this.$$set({i18n:e}),he()}get dispatch_blob(){return this.$$.ctx[19]}set dispatch_blob(e){this.$$set({dispatch_blob:e}),he()}get interactive(){return this.$$.ctx[4]}set interactive(e){this.$$set({interactive:e}),he()}get editable(){return this.$$.ctx[5]}set editable(e){this.$$set({editable:e}),he()}get trim_region_settings(){return this.$$.ctx[6]}set trim_region_settings(e){this.$$set({trim_region_settings:e}),he()}get waveform_settings(){return this.$$.ctx[7]}set waveform_settings(e){this.$$set({waveform_settings:e}),he()}get waveform_options(){return this.$$.ctx[8]}set waveform_options(e){this.$$set({waveform_options:e}),he()}get mode(){return this.$$.ctx[0]}set mode(e){this.$$set({mode:e}),he()}get handle_reset_value(){return this.$$.ctx[9]}set handle_reset_value(e){this.$$set({handle_reset_value:e}),he()}}const $i=fr;const{SvelteComponent:_r,append:mr,attr:gr,bubble:ht,check_outros:gn,create_component:Ze,destroy_component:Je,detach:Tt,element:pr,empty:vr,flush:ge,group_outros:pn,init:br,insert:zt,mount_component:Ke,safe_not_equal:wr,space:vn,transition_in:te,transition_out:re}=window.__gradio__svelte__internal,{createEventDispatcher:kr}=window.__gradio__svelte__internal;function yr(i){let e,t;return e=new Ei({props:{size:"small",$$slots:{default:[Er]},$$scope:{ctx:i}}}),{c(){Ze(e.$$.fragment)},m(n,s){Ke(e,n,s),t=!0},p(n,s){const o={};s&65536&&(o.$$scope={dirty:s,ctx:n}),e.$set(o)},i(n){t||(te(e.$$.fragment,n),t=!0)},o(n){re(e.$$.fragment,n),t=!1},d(n){Je(e,n)}}}function Cr(i){let e,t,n,s,o,r=i[3]&&Qn(i),u=i[4]&&xn(i);return s=new $i({props:{value:i[0],label:i[1],i18n:i[5],waveform_settings:i[6],waveform_options:i[7],editable:i[8]}}),s.$on("pause",i[12]),s.$on("play",i[13]),s.$on("stop",i[14]),{c(){e=pr("div"),r&&r.c(),t=vn(),u&&u.c(),n=vn(),Ze(s.$$.fragment),gr(e,"class","icon-buttons svelte-rvdo70")},m(a,d){zt(a,e,d),r&&r.m(e,null),mr(e,t),u&&u.m(e,null),zt(a,n,d),Ke(s,a,d),o=!0},p(a,d){a[3]?r?(r.p(a,d),d&8&&te(r,1)):(r=Qn(a),r.c(),te(r,1),r.m(e,t)):r&&(pn(),re(r,1,1,()=>{r=null}),gn()),a[4]?u?(u.p(a,d),d&16&&te(u,1)):(u=xn(a),u.c(),te(u,1),u.m(e,null)):u&&(pn(),re(u,1,1,()=>{u=null}),gn());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]),s.$set(l)},i(a){o||(te(r),te(u),te(s.$$.fragment,a),o=!0)},o(a){re(r),re(u),re(s.$$.fragment,a),o=!1},d(a){a&&(Tt(e),Tt(n)),r&&r.d(),u&&u.d(),Je(s,a)}}}function Er(i){let e,t;return e=new qt({}),{c(){Ze(e.$$.fragment)},m(n,s){Ke(e,n,s),t=!0},i(n){t||(te(e.$$.fragment,n),t=!0)},o(n){re(e.$$.fragment,n),t=!1},d(n){Je(e,n)}}}function Qn(i){let e,t;return e=new ss({props:{href:i[0].url,download:i[0].orig_name||i[0].path,$$slots:{default:[Rr]},$$scope:{ctx:i}}}),{c(){Ze(e.$$.fragment)},m(n,s){Ke(e,n,s),t=!0},p(n,s){const o={};s&1&&(o.href=n[0].url),s&1&&(o.download=n[0].orig_name||n[0].path),s&65568&&(o.$$scope={dirty:s,ctx:n}),e.$set(o)},i(n){t||(te(e.$$.fragment,n),t=!0)},o(n){re(e.$$.fragment,n),t=!1},d(n){Je(e,n)}}}function Rr(i){let e,t;return e=new ns({props:{Icon:os,label:i[5]("common.download")}}),{c(){Ze(e.$$.fragment)},m(n,s){Ke(e,n,s),t=!0},p(n,s){const o={};s&32&&(o.label=n[5]("common.download")),e.$set(o)},i(n){t||(te(e.$$.fragment,n),t=!0)},o(n){re(e.$$.fragment,n),t=!1},d(n){Je(e,n)}}}function xn(i){let e,t;return e=new is({props:{i18n:i[5],formatter:i[9],value:i[0]}}
103),e.$on("error",i[10]),e.$on("share",i[11]),{c(){Ze(e.$$.fragment)},m(n,s){Ke(e,n,s),t=!0},p(n,s){const o={};s&32&&(o.i18n=n[5]),s&1&&(o.value=n[0]),e.$set(o)},i(n){t||(te(e.$$.fragment,n),t=!0)},o(n){re(e.$$.fragment,n),t=!1},d(n){Je(e,n)}}}function Dr(i){let e,t,n,s,o,r;e=new Ci({props:{show_label:i[2],Icon:qt,float:!1,label:i[1]||i[5]("audio.audio")}});const u=[Cr,yr],a=[];function d(l,c){return l[0]!==null?0:1}return n=d(i),s=a[n]=u[n](i),{c(){Ze(e.$$.fragment),t=vn(),s.c(),o=vr()},m(l,c){Ke(e,l,c),zt(l,t,c),a[n].m(l,c),zt(l,o,c),r=!0},p(l,[c]){const h={};c&4&&(h.show_label=l[2]),c&34&&(h.label=l[1]||l[5]("audio.audio")),e.$set(h);let _=n;n=d(l),n===_?a[n].p(l,c):(pn(),re(a[_],1,1,()=>{a[_]=null}),gn(),s=a[n],s?s.p(l,c):(s=a[n]=u[n](l),s.c()),te(s,1),s.m(o.parentNode,o))},i(l){r||(te(e.$$.fragment,l),te(s),r=!0)},o(l){re(e.$$.fragment,l),re(s),r=!1},d(l){l&&(Tt(t),Tt(o)),Je(e,l),a[n].d(l)}}}function Sr(i,e,t){let{value:n=null}=e,{label:s}=e,{show_label:o=!0}=e,{show_download_button:r=!0}=e,{show_share_button:u=!1}=e,{i18n:a}=e,{waveform_settings:d}=e,{waveform_options:l}=e,{editable:c=!0}=e;const h=kr(),_=async p=>p?`<audio controls src="${await ts(p.url,"url")}"></audio>`:"";function m(p){ht.call(this,i,p)}function f(p){ht.call(this,i,p)}function g(p){ht.call(this,i,p)}function k(p){ht.call(this,i,p)}function E(p){ht.call(this,i,p)}return i.$$set=p=>{"value"in p&&t(0,n=p.value),"label"in p&&t(1,s=p.label),"show_label"in p&&t(2,o=p.show_label),"show_download_button"in p&&t(3,r=p.show_download_button),"show_share_button"in p&&t(4,u=p.show_share_button),"i18n"in p&&t(5,a=p.i18n),"waveform_settings"in p&&t(6,d=p.waveform_settings),"waveform_options"in p&&t(7,l=p.waveform_options),"editable"in p&&t(8,c=p.editable)},i.$$.update=()=>{i.$$.dirty&1&&n&&h("change",n)},[n,s,o,r,u,a,d,l,c,_,m,f,g,k,E]}class Lr extends _r{constructor(e){super(),br(this,e,Sr,Dr,wr,{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})}get value(){return this.$$.ctx[0]}set value(e){this.$$set({value:e}),ge()}get label(){return this.$$.ctx[1]}set label(e){this.$$set({label:e}),ge()}get show_label(){return this.$$.ctx[2]}set show_label(e){this.$$set({show_label:e}),ge()}get show_download_button(){return this.$$.ctx[3]}set show_download_button(e){this.$$set({show_download_button:e}),ge()}get show_share_button(){return this.$$.ctx[4]}set show_share_button(e){this.$$set({show_share_button:e}),ge()}get i18n(){return this.$$.ctx[5]}set i18n(e){this.$$set({i18n:e}),ge()}get waveform_settings(){return this.$$.ctx[6]}set waveform_settings(e){this.$$set({waveform_settings:e}),ge()}get waveform_options(){return this.$$.ctx[7]}set waveform_options(e){this.$$set({waveform_options:e}),ge()}get editable(){return this.$$.ctx[8]}set editable(e){this.$$set({editable:e}),ge()}}const Mr=Lr;function _n(i,e,t,n){return new(t||(t=Promise))(function(s,o){function r(d){try{a(n.next(d))}catch(l){o(l)}}function u(d){try{a(n.throw(d))}catch(l){o(l)}}function a(d){var l;d.done?s(d.value):(l=d.value,l instanceof t?l:new t(function(c){c(l)})).then(r,u)}a((n=n.apply(i,e||[])).next())})}class Pr{constructor(){this.listeners={},this.on=this.addEventListener,this.un=this.removeEventListener}addEventListener(e,t,n){if(this.listeners[e]||(this.listeners[e]=new Set),this.listeners[e].add(t),n?.once){const s=()=>{this.removeEventListener(e,s),this.removeEventListener(e,t)};return this.addEventListener(e,s),s}return()=>this.removeEventListener(e,t)}removeEventListener(e,t){var n;(n=this.listeners[e])===null||n===void 0||n.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(n=>n(...t))}}class Ar extends Pr{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())}}const Tr=["audio/webm","audio/wav","audio/mpeg","audio/mp4","audio/mp3"];class yt extends Ar{constructor(e){var t;super(Object.assign(Object.assign({},e),{audioBitsPerSecond:(t=e.audioBitsPerSecond)!==null&&t!==void 0?t:128e3})),this.stream=null,this.mediaRecorder=null}static create(e){return new yt(e||{})}renderMicStream(e){const t=new AudioContext,n=t.createMediaStreamSource(e),s=t.createAnalyser();n.connect(s);const o=s.frequencyBinCount,r=new Float32Array(o),u=o/t.sampleRate;let a;const d=()=>{s.getFloatTimeDomainData(r),this.wavesurfer&&(this.wavesurfer.options.cursorWidth=0,this.wavesurfer.options.interact=!1,this.wavesurfer.load("",[r],u)),a=requestAnimationFrame(d)};return d(),()=>{cancelAnimationFrame(a),n?.disconnect(),t?.close()}}startMic(e){return _n(this,void 0,void 0,function*(){let t;try{t=yield navigator.mediaDevices.getUserMedia({audio:!e?.deviceId||{deviceId:e.deviceId}})}catch(s){throw new Error("Error accessing the microphone: "+s.message)}const n=this.renderMicStream(t);return this.subscriptions.push(this.once("destroy",n)),this.stream=t,t})}
vendor: 24,625 bytes, line 103
103stopMic(){this.stream&&(this.stream.getTracks().forEach(e=>e.stop()),this.stream=null,this.mediaRecorder=null)}startRecording(e){return _n(this,void 0,void 0,function*(){const t=this.stream||(yield this.startMic(e)),n=this.mediaRecorder||new MediaRecorder(t,{mimeType:this.options.mimeType||Tr.find(o=>MediaRecorder.isTypeSupported(o)),audioBitsPerSecond:this.options.audioBitsPerSecond});this.mediaRecorder=n,this.stopRecording();const s=[];n.ondataavailable=o=>{o.data.size>0&&s.push(o.data)},n.onstop=()=>{var o;const r=new Blob(s,{type:n.mimeType});this.emit("record-end",r),this.options.renderRecordedAudio!==!1&&((o=this.wavesurfer)===null||o===void 0||o.load(URL.createObjectURL(r)))},n.start(),this.emit("record-start")})}isRecording(){var e;return((e=this.mediaRecorder)===null||e===void 0?void 0:e.state)==="recording"}isPaused(){var e;return((e=this.mediaRecorder)===null||e===void 0?void 0:e.state)==="paused"}stopRecording(){var e;this.isRecording()&&((e=this.mediaRecorder)===null||e===void 0||e.stop())}pauseRecording(){var e;this.isRecording()&&((e=this.mediaRecorder)===null||e===void 0||e.pause(),this.emit("record-pause"))}resumeRecording(){var e;this.isPaused()&&((e=this.mediaRecorder)===null||e===void 0||e.resume(),this.emit("record-resume"))}static getAvailableAudioDevices(){return _n(this,void 0,void 0,function*(){return navigator.mediaDevices.enumerateDevices().then(e=>e.filter(t=>t.kind==="audioinput"))})}destroy(){super.destroy(),this.stopRecording(),this.stopMic()}}const{SvelteComponent:zr,append:Wi,attr:ei,destroy_each:$r,detach:Nt,element:Dn,empty:Wr,ensure_array_like:ti,flush:ni,init:qr,insert:It,noop:ii,safe_not_equal:Or,set_data:qi,set_input_value:bn,text:Oi}=window.__gradio__svelte__internal,{createEventDispatcher:Br}=window.__gradio__svelte__internal;function si(i,e,t){const n=i.slice();return n[3]=e[t],n}function Hr(i){let e,t=ti(i[0]),n=[];for(let s=0;s<t.length;s+=1)n[s]=oi(si(i,t,s));return{c(){for(let s=0;s<n.length;s+=1)n[s].c();e=Wr()},m(s,o){for(let r=0;r<n.length;r+=1)n[r]&&n[r].m(s,o);It(s,e,o)},p(s,o){if(o&1){t=ti(s[0]);let r;for(r=0;r<t.length;r+=1){const u=si(s,t,r);n[r]?n[r].p(u,o):(n[r]=oi(u),n[r].c(),n[r].m(e.parentNode,e))}for(;r<n.length;r+=1)n[r].d(1);n.length=t.length}},d(s){s&&Nt(e),$r(n,s)}}}function Vr(i){let e,t=i[1]("audio.no_microphone")+"",n;return{c(){e=Dn("option"),n=Oi(t),e.__value="",bn(e,e.__value)},m(s,o){It(s,e,o),Wi(e,n)},p(s,o){o&2&&t!==(t=s[1]("audio.no_microphone")+"")&&qi(n,t)},d(s){s&&Nt(e)}}}function oi(i){let e,t=i[3].label+"",n,s;return{c(){e=Dn("option"),n=Oi(t),e.__value=s=i[3].deviceId,bn(e,e.__value)},m(o,r){It(o,e,r),Wi(e,n)},p(o,r){r&1&&t!==(t=o[3].label+"")&&qi(n,t),r&1&&s!==(s=o[3].deviceId)&&(e.__value=s,bn(e,e.__value))},d(o){o&&Nt(e)}}}function Nr(i){let e,t;function n(r,u){return r[0].length===0?Vr:Hr}let s=n(i),o=s(i);return{c(){e=Dn("select"),o.c(),ei(e,"class","mic-select svelte-1v4948z"),ei(e,"aria-label","Select input device"),e.disabled=t=i[0].length===0},m(r,u){It(r,e,u),o.m(e,null)},p(r,[u]){s===(s=n(r))&&o?o.p(r,u):(o.d(1),o=s(r),o&&(o.c(),o.m(e,null))),u&1&&t!==(t=r[0].length===0)&&(e.disabled=t)},i:ii,o:ii,d(r){r&&Nt(e),o.d()}}}function Ir(i,e,t){let{i18n:n}=e,{micDevices:s=[]}=e;const o=Br();return i.$$set=r=>{"i18n"in r&&t(1,n=r.i18n),"micDevices"in r&&t(0,s=r.micDevices)},i.$$.update=()=>{if(i.$$.dirty&2)try{let r=[];yt.getAvailableAudioDevices().then(u=>{t(0,s=u),u.forEach(a=>{a.deviceId&&r.push(a)}),t(0,s=r)})}catch(r){throw r instanceof DOMException&&r.name=="NotAllowedError"&&o("error",n("audio.allow_recording_access")),r}},[s,n]}class Bi extends zr{constructor(e){super(),qr(this,e,Ir,Nr,Or,{i18n:1,micDevices:0})}get i18n(){return this.$$.ctx[1]}set i18n(e){this.$$set({i18n:e}),ni()}get micDevices(){return this.$$.ctx[0]}set micDevices(e){this.$$set({micDevices:e}),ni()}}const{SvelteComponent:Ur,add_flush_callback:jr,append:Z,attr:_e,bind:Fr,binding_callbacks:tt,create_component:ri,destroy_component:li,detach:Hi,element:De,flush:ft,init:Xr,insert:Vi,listen:_t,mount_component:ai,run_all:Gr,safe_not_equal:Yr,set_data:mt,space:et,text:gt,transition_in:ui,transition_out:ci}=window.__gradio__svelte__internal;function di(i){let e,t;return{c(){e=De("time"),t=gt(i[2]),_e(e,"class","duration-button duration svelte-1d9m1oy")},m(n,s){Vi(n,e,s),Z(e,t)},p(n,s){s&4&&mt(t,n[2])},d(n){n&&Hi(e)}}}function Zr(i){let e,t,n,s=i[1]("audio.record")+"",o,r,u,a=i[1]("audio.stop")+"",d,l,c,h,_=i[1]("audio.stop")+"",m,f,g,k,E,p,L=i[1]("audio.resume")+"",R,A,C,T,D,z,B,q;k=new Di({});let $=i[4]&&!i[3]&&di(i);function X(M){i[21](M)}let W={i18n:i[1]};return i[5]!==void 0&&(W.micDevices=i[5]),T=new Bi({props:W}),tt.push(()=>Fr(T,"micDevices",X)),{c(){e=De("div"),t=De("div"),n=De("button"),o=gt(s),r=et(),u=De("button"),d=gt(a),c=et(),h=De("button"),m=gt(_),f=et(),g=De("button"),ri(k.$$.fragment),E=et(),p=De("button"),R=gt(L),A=et(),$&&$.c(),C=et(),ri(T.$$.fragment),_e(n,"class","record record-button svelte-1d9m1oy"),_e(u,"class",l="stop-button "+(i[0].isPaused()?"stop-button-paused":"")+" svelte-1d9m1oy"),_e(h,"id","stop-paused"),_e(h,"class","stop-button-paused svelte-1d9m1oy"),_e(g,"aria-label","pause"),_e(g,"class","pause-button svelte-1d9m1oy"),_e(p,"class","resume-button svelte-1d9m1oy"),_e(t,"class","wrapper svelte-1d9m1oy"),_e(e,"class","controls svelte-1d9m1oy")},m(M,v){Vi(M,e,v),Z(e,t),Z(t,n),Z(n,o),i[11](n),Z(t,r),Z(t,u),Z(u,d),i[13](u),Z(t,c),Z(t,h),Z(h,m),i[15](h),Z(t,f),Z(t,g),ai(k,g,null),i[17](g),Z(t,E),Z(t,p),Z(p,R),i[19](p),Z(t,A),$&&$.m(t,null),Z(e,C),ai(T,e,null),z=!0,B||(q=[_t(n,"click",i[12]),_t(u,"click",i[14]),_t(h,"click",i[16]),_t(g,"click",i[18]),_t(p,"click",i[20])],B=!0)},p(M,[v]){(!z||v&2)&&s!==(s=M[1]("audio.record")+"")&&mt(o,s),(!z||v&2)&&a!==(a=M[1]("audio.stop")+"")&&mt(d,a),(!z||v&1&&l!==(l="stop-button "+(M[0].isPaused()?"stop-button-paused":"")+" svelte-1d9m1oy"))&&_e(u,"class",l),(!z||v&2)&&_!==(_=M[1]("audio.stop")+"")&&mt(m,_),(!z||v&2)&&L!==(L=M[1]("audio.resume")+"")&&mt(R,L),M[4]&&!M[3]?$?$.p(M,v):($=di(M),$.c(),$.m(t,null)):$&&($.d(1),$=null);const I={};v&2&&(I.i18n=M[1]),!D&&v&32&&(D=!0,I.micDevices=M[5],jr(()=>D=!1)),T.$set(I)},i(M){z||(ui(k.$$.fragment,M),ui(T.$$.fragment,M),z=!0)},o(M){ci(k.$$.fragment,M),ci(T.$$.fragment,M),z=!1},d(M){M&&Hi(e),i[11](null),i[13](null),i[15](null),li(k),i[17](null),i[19](null),$&&$.d(),li(T),B=!1,Gr(q)}}}function Jr(i,e,t){let{record:n}=e,{i18n:s}=e,o=[],r,u,a,d,l,{record_time:c}=e,{show_recording_waveform:h}=e,{timing:_=!1}=e;function m(D){tt[D?"unshift":"push"](()=>{r=D,t(6,r),t(0,n)})}const f=()=>n.startRecording();function g(D){tt[D?"unshift":"push"](()=>{d=D,t(9,d),t(0,n)})}const k=()=>{n.isPaused()&&(n.resumeRecording(),n.stopRecording()),n.stopRecording()};function E(D){tt[D?"unshift":"push"](()=>{l=D,t(10,l),t(0,n)})}const p=()=>{n.isPaused()&&(n.resumeRecording(),n.stopRecording()),n.stopRecording()};function L(D){tt[D?"unshift":"push"](()=>{u=D,t(7,u),t(0,n)})}const R=()=>n.pauseRecording();function A(D){tt[D?"unshift":"push"](()=>{a=D,t(8,a),t(0,n)})}const C=()=>n.resumeRecording();function T(D){o=D,t(5,o)}return i.$$set=D=>{"record"in D&&t(0,n=D.record),"i18n"in D&&t(1,s=D.i18n),"record_time"in D&&t(2,c=D.record_time),"show_recording_waveform"in D&&t(3,h=D.show_recording_waveform),"timing"in D&&t(4,_=D.timing)},i.$$.update=()=>{i.$$.dirty&1&&n.on("record-start",()=>{n.startMic(),t(6,r.style.display="none",r),t(9,d.style.display="flex",d),t(7,u.style.display="block",u)}),i.$$.dirty&1&&n.on("record-end",()=>{n.isPaused()&&(n.resumeRecording(),n.stopRecording()),n.stopMic(),t(6,r.style.display="flex",r),t(9,d.style.display="none",d),t(7,u.style.display="none",u),t(6,r.disabled=!1,r)}),i.$$.dirty&1&&n.on("record-pause",()=>{t(7,u.style.display="none",u),t(8,a.style.display="block",a),t(9,d.style.display="none",d),t(10,l.style.display="flex",l)}),i.$$.dirty&1&&n.on("record-resume",()=>{t(7,u.style.display="block",u),t(8,a.style.display="none",a),t(6,r.style.display="none",r),t(9,d.style.display="flex",d),t(10,l.style.display="none",l)})},[n,s,c,h,_,o,r,u,a,d,l,m,f,g,k,E,p,L,R,A,C,T]}class Kr extends Ur{constructor(e){super(),Xr(this,e,Jr,Zr,Yr,{record:0,i18n:1,record_time:2,show_recording_waveform:3,timing:4})}get record(){return this.$$.ctx[0]}set record(e){this.$$set({record:e}),ft()}get i18n(){return this.$$.ctx[1]}set i18n(e){this.$$set({i18n:e}),ft()}get record_time(){return this.$$.ctx[2]}set record_time(e){this.$$set({record_time:e}),ft()}get show_recording_waveform(){return this.$$.ctx[3]}set show_recording_waveform(e){this.$$set({show_recording_waveform:e}),ft()}get timing(){return this.$$.ctx[4]}set timing(e){this.$$set({timing:e}),ft()}}const{SvelteComponent:Qr,add_flush_callback:Mt,append:ce,attr:be,bind:Pt,binding_callbacks:Me,check_outros:hi,create_component:Ni,destroy_component:Ii,detach:Ct,element:we,flush:Ve,group_outros:fi,init:xr,insert:Et,mount_component:Ui,noop:el,safe_not_equal:tl,set_data:ji,space:it,text:Fi,transition_in:Le,transition_out:st}=window.__gradio__svelte__internal,{onMount:nl}=window.__gradio__svelte__internal,{createEventDispatcher:il}=window.__gradio__svelte__internal;function _i(i){let e,t,n,s,o,r=i[0]==="edit"&&i[16]>0&&mi(i);function u(l,c){return l[15]?ol:sl}let a=u(i),d=a(i);return{c(){e=we("div"),t=we("time"),t.textContent="0:00",n=it(),s=we("div"),r&&r.c(),o=it(),d.c(),be(t,"class","time svelte-9n45fh"),be(e,"class","timestamps svelte-9n45fh")},m(l,c){Et(l,e,c),ce(e,t),i[23](t),ce(e,n),ce(e,s),r&&r.m(s,null),ce(s,o),d.m(s,null)},p(l,c){l[0]==="edit"&&l[16]>0?r?r.p(l,c):(r=mi(l),r.c(),r.m(s,o)):r&&(r.d(1),r=null),a===(a=u(l))&&d?d.p(l,c):(d.d(1),d=a(l),d&&(d.c(),d.m(s,null)))},d(l){l&&Ct(e),i[23](null),r&&r.d(),d.d()}}}function mi(i){let e,t=de(i[16])+"",n;return{c(){e=we("time"),n=Fi(t),be(e,"class","trim-duration svelte-9n45fh")},m(s,o){Et(s,e,o),ce(e,n)},p(s,o){o[0]&65536&&t!==(t=de(s[16])+"")&&ji(n,t)},d(s){s&&Ct(e)}}}function sl(i){let e;return{c(){e=we("time"),e.textContent="0:00",be(e,"class","duration svelte-9n45fh")},m(t,n){Et(t,e,n),i[24](e)},p:el,d(t){t&&Ct(e),i[24](null)}}}function ol(i){let e,t=de(i[14])+"",n;return{c(){e=we("time"),n=Fi(t),be(e,"class","duration svelte-9n45fh")},m(s,o){Et(s,e,o),ce(e,n)},p(s,o){o[0]&16384&&t!==(t=de(s[14])+"")&&ji(n,t)},d(s){s&&Ct(e)}}}function gi(i){let e,t,n;function s(r){i[25](r)}let o={i18n:i[1],timing:i[15],show_recording_waveform:i[2].show_recording_waveform,record_time:de(i[14])};return i[8]!==void 0&&(o.record=i[8]),e=new Kr({props:o}),Me.push(()=>Pt(e,"record",s)),{c(){Ni(e.$$.fragment)},m(r,u){Ui(e,r,u),n=!0},p(r,u){const a={};u[0]&2&&(a.i18n=r[1]),u[0]&32768&&(a.timing=r[15]),u[0]&4&&(a.show_recording_waveform=r[2].show_recording_waveform),u[0]&16384&&(a.record_time=de(r[14])),!t&&u[0]&256&&(t=!0,a.record=r[8],Mt(()=>t=!1)),e.$set(a)},i(r){n||(Le(e.$$.fragment,r),n=!0)},o(r){st(e.$$.fragment,r),n=!1},d(r){Ii(e,r)}}}function pi(i){let e,t,n,s,o;function r(l){i[26](l)}function u(l){i[27](l)}function a(l){i[28](l)}let d={container:i[6],playing:i[12],audio_duration:i[13],i18n:i[1],editable:i[4],interactive:!0,handle_trim_audio:i[17],show_redo:!0,handle_reset_value:i[3],waveform_options:i[2]};return i[5]!==void 0&&(d.waveform=i[5]),i[16]!==void 0&&(d.trimDuration=i[16]),i[0]!==void 0&&(d.mode=i[0]),e=new Ai({props:d}),Me.push(()=>Pt(e,"waveform",r)),Me.push(()=>Pt(e,"trimDuration",u)),Me.push(()=>Pt(e,"mode",a)),{c(){Ni(e.$$.fragment)},m(l,c){Ui(e,l,c),o=!0},p(l,c){const h={};c[0]&64&&(h.container=l[6]),c[0]&4096&&(h.playing=l[12]),c[0]&8192&&(h.audio_duration=l[13]),c[0]&2&&(h.i18n=l[1]),c[0]&16&&(h.editable=l[4]),c[0]&8&&(h.handle_reset_value=l[3]),c[0]&4&&(h.waveform_options=l[2]),!t&&c[0]&32&&(t=!0,h.waveform=l[5],Mt(()=>t=!1)),!n&&c[0]&65536&&(n=!0,h.trimDuration=l[16],Mt(()=>n=!1)),!s&&c[0]&1&&(s=!0,h.mode=l[0],Mt(()=>s=!1)),e.$set(h)},i(l){o||(Le(e.$$.fragment,l),o=!0)},o(l){st(e.$$.fragment,l),o=!1},d(l){Ii(e,l)}}}function rl(i){let e,t,n,s,o,r,u,a,d=(i[15]||i[9])&&i[2].show_recording_waveform&&_i(i),l=i[7]&&!i[9]&&gi(i),c=i[5]&&i[9]&&pi(i);return{c(){e=we("div"),t=we("div"),n=it(),s=we("div"),o=it(),d&&d.c(),r=it(),l&&l.c(),u=it(),c&&c.c(),be(t,"class","microphone svelte-9n45fh"),be(t,"data-testid","microphone-waveform"),be(s,"data-testid","recording-waveform"),be(e,"class","component-wrapper svelte-9n45fh")},m(h,_){Et(h,e,_),ce(e,t),i[21](t),ce(e,n),ce(e,s),i[22](s),ce(e,o),d&&d.m(e,null),ce(e,r),l&&l.m(e,null),ce(e,u),c&&c.m(e,null),a=!0},p(h,_){(h[15]||h[9])&&h[2].show_recording_waveform?d?d.p(h,_):(d=_i(h),d.c(),d.m(e,r)):d&&(d.d(1),d=null),h[7]&&!h[9]?l?(l.p(h,_),_[0]&640&&Le(l,1)):(l=gi(h),l.c(),Le(l,1),l.m(e,u)):l&&(fi(),st(l,1,1,()=>{l=null}),hi()),h[5]&&h[9]?c?(c.p(h,_),_[0]&544&&Le(c,1)):(c=pi(h),c.c(),Le(c,1),c.m(e,null)):c&&(fi(),st(c,1,1,()=>{c=null}),hi())},i(h){a||(Le(l),Le(c),a=!0)},o(h){st(l),st(c),a=!1},d(h){h&&Ct(e),i[21](null),i[22](null),d&&d.d(),l&&l.d(),c&&c.d()}}}function ll(i,e,t){let{mode:n}=e,{i18n:s}=e,{dispatch_blob:o}=e,{waveform_settings:r}=e,{waveform_options:u={show_recording_waveform:!0}}=e,{handle_reset_value:a}=e,{editable:d=!0}=e,l,c,h=!1,_,m,f,g=null,k,E,p,L=0,R,A=!1,C=0;const T=()=>{clearInterval(R),t(20,R=setInterval(()=>{t(14,L++,L)},1e3))},D=il(),z=()=>{m&&t(7,m.innerHTML="",m),l!==void 0&&l.destroy(),m&&(l=rt.create({...r,normalize:!1,container:m}),t(8,f=l.registerPlugin(yt.create())),f.startMic())},B=()=>{let b=_;!g||!b||t(5,c=rt.create({container:b,url:g,...r}))},q=async(b,G)=>{t(0,n="edit");const y=c.getDecodedData();y&&await mn(y,b,G).then(async J=>{await o([J],"change"),await o([J],"stop_recording"),c.destroy(),B()}),D("edit")};nl(()=>{z(),window.addEventListener("keydown",b=>{b.key==="ArrowRight"?At(c,.1):b.key==="ArrowLeft"&&At(c,-.1)})});function $(b){Me[b?"unshift":"push"](()=>{m=b,t(7,m)})}function X(b){Me[b?"unshift":"push"](()=>{_=b,t(6,_)})}function W(b){Me[b?"unshift":"push"](()=>{k=b,t(10,k),t(5,c)})}function M(b){Me[b?"unshift":"push"](()=>{E=b,t(11,E),t(5,c)})}function v(b){f=b,t(8,f)}function I(b){c=b,t(5,c)}function O(b){C=b,t(16,C)}function P(b){n=b,t(0,n)}return i.$$set=b=>{"mode"in b&&t(0,n=b.mode),"i18n"in b&&t(1,s=b.i18n),"dispatch_blob"in b&&t(18,o=b.dispatch_blob),"waveform_settings"in b&&t(19,r=b.waveform_settings),"waveform_options"in b&&t(2,u=b.waveform_options),"handle_reset_value"in b&&t(3,a=b.handle_reset_value),"editable"in b&&t(4,d=b.editable)},i.$$.update=()=>{i.$$.dirty[0]&388&&f?.on("record-start",()=>{if(T(),t(15,A=!0),D("start_recording"),u.show_recording_waveform){let b=m;b&&(b.style.display="block")}}),i.$$.dirty[0]&1835264&&f?.on("record-end",async b=>{t(14,L=0),t(15,A=!1),clearInterval(R);try{const G=await b.arrayBuffer(),J=await new AudioContext({sampleRate:r.sampleRate}).decodeAudioData(G);J&&await mn(J).then(async le=>{await o([le],"change"),await o([le],"stop_recording")})}catch(G){console.error(G)}}),i.$$.dirty[0]&1048832&&f?.on("record-pause",()=>{D("pause_recording"),clearInterval(R)}),i.$$.dirty[0]&256&&f?.on("record-resume",()=>{T()}),i.$$.dirty[0]&2080&&c?.on("decode",b=>{t(13,p=b),E&&t(11,E.textContent=de(b),E)}),i.$$.dirty[0]&1056&&c?.on("timeupdate",b=>k&&t(10,k.textContent=de(b),k)),i.$$.dirty[0]&32&&c?.on("pause",()=>{D("pause"),t(12,h=!1)}),i.$$.dirty[0]&32&&c?.on("play",()=>{D("play"),t(12,h=!0)}),i.$$.dirty[0]&32&&c?.on("finish",()=>{D("stop"),t(12,h=!1)}),i.$$.dirty[0]&960&&f?.on("record-end",b=>{t(9,g=URL.createObjectURL(b));const G=m,y=_;G&&(G.style.display="none"),y&&g&&(y.innerHTML="",B())})},[n,s,u,a,d,c,_,m,f,g,k,E,h,p,L,A,C,q,o,r,R,$,X,W,M,v,I,O,P]}class al extends Qr{constructor(e){super(),xr(this,e,ll,rl,tl,{mode:0,i18n:1,dispatch_blob:18,waveform_settings:19,waveform_options:2,handle_reset_value:3,editable:4},null,[-1,-1])}get mode(){return this.$$.ctx[0]}set mode(e){this.$$set({mode:e}),Ve()}get i18n(){return this.$$.ctx[1]}set i18n(e){this.$$set({i18n:e}),Ve()}get dispatch_blob(){return this.$$.ctx[18]}set dispatch_blob(e){this.$$set({dispatch_blob:e}),Ve()}get waveform_settings(){return this.$$.ctx[19]}set waveform_settings(e){this.$$set({waveform_settings:e}),Ve()}get waveform_options(){return this.$$.ctx[2]}set waveform_options(e){this.$$set({waveform_options:e}),Ve()}get handle_reset_value(){return this.$$.ctx[3]}set handle_reset_value(e){this.$$set({handle_reset_value:e}),Ve()}get editable(){return this.$$.ctx[4]}set editable(e){this.$$set({editable:e}),Ve()}}const{SvelteComponent:ul,add_flush_callback:cl,append:ke,attr:Ue,bind:dl,binding_callbacks:Xi,create_component:hl,destroy_component:fl,detach:Ut,element:Fe,flush:Ne,init:_l,insert:jt,listen:Gi,mount_component:ml,null_to_empty:vi,safe_not_equal:gl,set_data:Yi,set_style:bi,space:$t,text:Zi,transition_in:pl,transition_out:vl}=window.__gradio__svelte__internal,{onMount:bl}=window.__gradio__svelte__internal;function wi(i){let e;return{c(){e=Fe("div"),bi(e,"display",i[0]?"block":"none")},m(t,n){jt(t,e,n),i[10](e)},p(t,n){n&1&&bi(e,"display",t[0]?"block":"none")},d(t){t&&Ut(e),i[10](null)}}}function wl(i){let e,t,n,s=i[4]("audio.record")+"",o,r,u;return{c(){e=Fe("button"),t=Fe("span"),t.innerHTML='<span class="dot"></span>',n=$t(),o=Zi(s),Ue(t,"class","record-icon"),Ue(e,"class","record-button svelte-1m31gsz")},m(a,d){jt(a,e,d),ke(e,t),ke(e,n),ke(e,o),r||(u=Gi(e,"click",i[12]),r=!0)},p(a,d){d&16&&s!==(s=a[4]("audio.record")+"")&&Yi(o,s)},d(a){a&&Ut(e),r=!1,u()}}}function kl(i){let e,t,n,s=(i[1]?i[4]("audio.pause"):i[4]("audio.stop"))+"",o,r,u,a;return{c(){e=Fe("button"),t=Fe("span"),t.innerHTML='<span class="pinger"></span> <span class="dot"></span>',n=$t(),o=Zi(s),Ue(t,"class","record-icon"),Ue(e,"class",r=vi(i[1]?"stop-button-paused":"stop-button")+" svelte-1m31gsz")},m(d,l){jt(d,e,l),ke(e,t),ke(e,n),ke(e,o),u||(a=Gi(e,"click",i[11]),u=!0)},p(d,l){l&18&&s!==(s=(d[1]?d[4]("audio.pause"):d[4]("audio.stop"))+"")&&Yi(o,s),l&2&&r!==(r=vi(d[1]?"stop-button-paused":"stop-button")+" svelte-1m31gsz")&&Ue(e,"class",r)},d(d){d&&Ut(e),u=!1,a()}}}function yl(i){let e,t,n,s,o,r,u,a=i[5].show_recording_waveform&&wi(i);function d(m,f){return m[0]?kl:wl}let l=d(i),c=l(i);function h(m){i[13](m)}let _={i18n:i[4]};return i[8]!==void 0&&(_.micDevices=i[8]),o=new Bi({props:_}),Xi.push(()=>dl(o,"micDevices",h)),{c(){e=Fe("div"),a&&a.c(),t=$t(),n=Fe("div"),c.c(),s=$t(),hl(o.$$.fragment),Ue(n,"class","controls svelte-1m31gsz"),Ue(e,"class","mic-wrap svelte-1m31gsz")},m(m,f){jt(m,e,f),a&&a.m(e,null),ke(e,t),ke(e,n),c.m(n,null),ke(n,s),ml(o,n,null),u=!0},p(m,[f]){m[5].show_recording_waveform?a?a.p(m,f):(a=wi(m),a.c(),a.m(e,t)):a&&(a.d(1),a=null),l===(l=d(m))&&c?c.p(m,f):(c.d(1),c=l(m),c&&(c.c(),c.m(n,s)));const g={};f&16&&(g.i18n=m[4]),!r&&f&256&&(r=!0,g.micDevices=m[8],cl(()=>r=!1)),o.$set(g)},i(m){u||(pl(o.$$.fragment,m),u=!0)},o(m){vl(o.$$.fragment,m),u=!1},d(m){m&&Ut(e),a&&a.d(),c.d(),fl(o)}}}function Cl(i,e,t){let{recording:n=!1}=e,{paused_recording:s=!1}=e,{stop:o}=e,{record:r}=e,{i18n:u}=e,{waveform_settings:a}=e,{waveform_options:d={show_recording_waveform:!0}}=e,l,c,h,_=[];bl(()=>{m()});const m=()=>{l!==void 0&&l.destroy(),h&&(l=rt.create({...a,height:100,container:h}),t(6,c=l.registerPlugin(yt.create())))};function f(p){Xi[p?"unshift":"push"](()=>{h=p,t(7,h)})}const g=()=>{c?.stopMic(),o()},k=()=>{c?.startMic(),r()};function E(p){_=p,t(8,_)}return i.$$set=p=>{"recording"in p&&t(0,n=p.recording),"paused_recording"in p&&t(1,s=p.paused_recording),"stop"in p&&t(2,o=p.stop),"record"in p&&t(3,r=p.record),"i18n"in p&&t(4,u=p.i18n),"waveform_settings"in p&&t(9,a=p.waveform_settings),"waveform_options"in p&&t(5,d=p.waveform_options)},[n,s,o,r,u,d,c,h,_,a,f,g,k,E]}class El extends ul{constructor(e){super(),_l(this,e,Cl,yl,gl,{recording:0,paused_recording:1,stop:2,record:3,i18n:4,waveform_settings:9,waveform_options:5})}get recording(){return this.$$.ctx[0]}set recording(e){this.$$set({recording:e}),Ne()}get paused_recording(){return this.$$.ctx[1]}set paused_recording(e){this.$$set({paused_recording:e}),Ne()}get stop(){return this.$$.ctx[2]}set stop(e){this.$$set({stop:e}),Ne()}get record(){return this.$$.ctx[3]}set record(e){this.$$set({record:e}),Ne()}get i18n(){return this.$$.ctx[4]}set i18n(e){this.$$set({i18n:e}),Ne()}get waveform_settings(){return this.$$.ctx[9]}set waveform_settings(e){this.$$set({waveform_settings:e}),Ne()}get waveform_options(){return this.$$.ctx[5]}set waveform_options(e){this.$$set({waveform_options:e}),Ne()}}const{SvelteComponent:Rl,add_flush_callback:Ft,append:Dl,attr:Sl,bind:Xt,binding_callbacks:Gt,bubble:Ie,check_outros:Sn,create_component:qe,create_slot:Ll,destroy_component:Oe,detach:lt,element:Ml,empty:Ji,flush:Q,get_all_dirty_from_scope:Pl,get_slot_changes:Al,group_outros:Ln,init:Tl,insert:at,mount_component:Be,safe_not_equal:zl,space:Wt,transition_in:ne,transition_out:ie,update_slot_base:$l}=window.__gradio__svelte__internal,{getContext:Wl,onDestroy:ql,createEventDispatcher:Ol}=window.__gradio__svelte__internal;function Bl(i){let e,t,n,s,o;e=new Si({props:{i18n:i[9],download:i[6]?i[1].url:null,absolute:!0}}),e.$on("clear",i[20]),e.$on("edit",i[34]);function r(a){i[35](a)}let u={value:i[1],label:i[3],i18n:i[9],dispatch_blob:i[18],waveform_settings:i[10],waveform_options:i[12],trim_region_settings:i[11],handle_reset_value:i[13],editable:i[14],interactive:!0};return i[16]!==void 0&&(u.mode=i[16]),n=new $i({props:u}),Gt.push(()=>Xt(n,"mode",r)),n.$on("stop",i[36]),n.$on("play",i[37]),n.$on("pause",i[38]),n.$on("edit",i[39]),{c(){qe(e.$$.fragment),t=Wt(),qe(n.$$.fragment)},m(a,d){Be(e,a,d),at(a,t,d),Be(n,a,d),o=!0},p(a,d){const l={};d[0]&512&&(l.i18n=a[9]),d[0]&66&&(l.download=a[6]?a[1].url:null),e.$set(l);const c={};d[0]&2&&(c.value=a[1]),d[0]&8&&(c.label=a[3]),d[0]&512&&(c.i18n=a[9]),d[0]&1024&&(c.waveform_settings=a[10]),d[0]&4096&&(c.waveform_options=a[12]),d[0]&2048&&(c.trim_region_settings=a[11]),d[0]&8192&&(c.handle_reset_value=a[13]),d[0]&16384&&(c.editable=a[14]),!s&&d[0]&65536&&(s=!0,c.mode=a[16],Ft(()=>s=!1)),n.$set(c)},i(a){o||(ne(e.$$.fragment,a),ne(n.$$.fragment,a),o=!0)},o(a){ie(e.$$.fragment,a),ie(n.$$.fragment,a),o=!1},d(a){a&&lt(t),Oe(e,a),Oe(n,a)}}}function Hl(i){let e,t,n,s;const o=[Nl,Vl],r=[];function u(a,d){return a[2]==="microphone"?0:a[2]==="upload"?1:-1}return~(e=u(i))&&(t=r[e]=o[e](i)),{c(){t&&t.c(),n=Ji()},m(a,d){~e&&r[e].m(a,d),at(a,n,d),s=!0},p(a,d){let l=e;e=u(a),e===l?~e&&r[e].p(a,d):(t&&(Ln(),ie(r[l],1,1,()=>{r[l]=null}),Sn()),~e?(t=r[e],t?t.p(a,d):(t=r[e]=o[e](a),t.c()),ne(t,1),t.m(n.parentNode,n)):t=null)},i(a){s||(ne(t),s=!0)},o(a){ie(t),s=!1},d(a){a&&lt(n),~e&&r[e].d(a)}}}function Vl(i){let e,t,n;function s(r){i[32](r)}let o={filetype:"audio/aac,audio/midi,audio/mpeg,audio/ogg,audio/wav,audio/x-wav,audio/opus,audio/webm,audio/flac,audio/vnd.rn-realaudio,audio/x-ms-wma,audio/x-aiff,audio/amr,audio/*",root:i[4],$$slots:{default:[Il]},$$scope:{ctx:i}};return i[0]!==void 0&&(o.dragging=i[0]),e=new ds({props:o}),Gt.push(()=>Xt(e,"dragging",s)),e.$on("load",i[21]),e.$on("error",i[33]),{c(){qe(e.$$.fragment)},m(r,u){Be(e,r,u),n=!0},p(r,u){const a={};u[0]&16&&(a.root=r[4]),u[1]&1024&&(a.$$scope={dirty:u,ctx:r}),!t&&u[0]&1&&(t=!0,a.dragging=r[0],Ft(()=>t=!1)),e.$set(a)},i(r){n||(ne(e.$$.fragment,r),n=!0)},o(r){ie(e.$$.fragment,r),n=!1},d(r){Oe(e,r)}}}function Nl(i){let e,t,n,s,o,r;e=new Si({props:{i18n:i[9],absolute:!0}}),e.$on("clear",i[20]);const u=[jl,Ul],a=[];function d(l,c){return l[8]?0:1}return n=d(i),s=a[n]=u[n](i),{c(){qe(e.$$.fragment),t=Wt(),s.c(),o=Ji()},m(l,c){Be(e,l,c),at(l,t,c),a[n].m(l,c),at(l,o,c),r=!0},p(l,c){const h={};c[0]&512&&(h.i18n=l[9]),e.$set(h);let _=n;n=d(l),n===_?a[n].p(l,c):(Ln(),ie(a[_],1,1,()=>{a[_]=null}),Sn(),s=a[n],s?s.p(l,c):(s=a[n]=u[n](l),s.c()),ne(s,1),s.m(o.parentNode,o))},i(l){r||(ne(e.$$.fragment,l),ne(s),r=!0)},o(l){ie(e.$$.fragment,l),ie(s),r=!1},d(l){l&&(lt(t),lt(o)),Oe(e,l),a[n].d(l)}}}function Il(i){let e;const t=i[27].default,n=Ll(t,i,i[41],null);return{c(){n&&n.c()},m(s,o){n&&n.m(s,o),e=!0},p(s,o){n&&n.p&&(!e||o[1]&1024)&&$l(n,t,s,s[41],e?Al(t,s[41],o,null):Pl(s[41]),null)},i(s){e||(ne(n,s),e=!0)},o(s){ie(n,s),e=!1},d(s){n&&n.d(s)}}}function Ul(i){let e,t,n;function s(r){i[28](r)}let o={i18n:i[9],editable:i[14],dispatch_blob:i[18],waveform_settings:i[10],waveform_options:i[12],handle_reset_value:i[13]};return i[16]!==void 0&&(o.mode=i[16]),e=new al({props:o}),Gt.push(()=>Xt(e,"mode",s)),e.$on("start_recording",i[29]),e.$on("pause_recording",i[30]),e.$on("stop_recording",i[31]),{c(){qe(e.$$.fragment)},m(r,u){Be(e,r,u),n=!0},p(r,u){const a={};u[0]&512&&(a.i18n=r[9]),u[0]&16384&&(a.editable=r[14]),u[0]&1024&&(a.waveform_settings=r[10]),u[0]&4096&&(a.waveform_options=r[12]),u[0]&8192&&(a.handle_reset_value=r[13]),!t&&u[0]&65536&&(t=!0,a.mode=r[16],Ft(()=>
103t=!1)),e.$set(a)},i(r){n||(ne(e.$$.fragment,r),n=!0)},o(r){ie(e.$$.fragment,r),n=!1},d(r){Oe(e,r)}}}function jl(i){let e,t;return e=new El({props:{record:i[19],recording:i[15],stop:i[22],i18n:i[9],waveform_settings:i[10],waveform_options:i[12]}}),{c(){qe(e.$$.fragment)},m(n,s){Be(e,n,s),t=!0},p(n,s){const o={};s[0]&32768&&(o.recording=n[15]),s[0]&512&&(o.i18n=n[9]),s[0]&1024&&(o.waveform_settings=n[10]),s[0]&4096&&(o.waveform_options=n[12]),e.$set(o)},i(n){t||(ne(e.$$.fragment,n),t=!0)},o(n){ie(e.$$.fragment,n),t=!1},d(n){Oe(e,n)}}}function Fl(i){let e,t,n,s,o,r,u,a,d;e=new Ci({props:{show_label:i[5],Icon:qt,float:i[2]==="upload"&&i[1]===null,label:i[3]||i[9]("audio.audio")}});const l=[Hl,Bl],c=[];function h(f,g){return f[1]===null||f[8]?0:1}s=h(i),o=c[s]=l[s](i);function _(f){i[40](f)}let m={sources:i[7],handle_clear:i[20]};return i[2]!==void 0&&(m.active_source=i[2]),u=new hs({props:m}),Gt.push(()=>Xt(u,"active_source",_)),{c(){qe(e.$$.fragment),t=Wt(),n=Ml("div"),o.c(),r=Wt(),qe(u.$$.fragment),Sl(n,"class","audio-container svelte-cbyffp")},m(f,g){Be(e,f,g),at(f,t,g),at(f,n,g),c[s].m(n,null),Dl(n,r),Be(u,n,null),d=!0},p(f,g){const k={};g[0]&32&&(k.show_label=f[5]),g[0]&6&&(k.float=f[2]==="upload"&&f[1]===null),g[0]&520&&(k.label=f[3]||f[9]("audio.audio")),e.$set(k);let E=s;s=h(f),s===E?c[s].p(f,g):(Ln(),ie(c[E],1,1,()=>{c[E]=null}),Sn(),o=c[s],o?o.p(f,g):(o=c[s]=l[s](f),o.c()),ne(o,1),o.m(n,r));const p={};g[0]&128&&(p.sources=f[7]),!a&&g[0]&4&&(a=!0,p.active_source=f[2],Ft(()=>a=!1)),u.$set(p)},i(f){d||(ne(e.$$.fragment,f),ne(o),ne(u.$$.fragment,f),d=!0)},o(f){ie(e.$$.fragment,f),ie(o),ie(u.$$.fragment,f),d=!1},d(f){f&&(lt(t),lt(n)),Oe(e,f),c[s].d(),Oe(u)}}}const Xl=500,ki=44;function Gl(i,e,t){let{$$slots:n={},$$scope:s}=e,{value:o=null}=e,{label:r}=e,{root:u}=e,{show_label:a=!0}=e,{show_download_button:d=!1}=e,{sources:l=["microphone","upload"]}=e,{pending:c=!1}=e,{streaming:h=!1}=e,{i18n:_}=e,{waveform_settings:m}=e,{trim_region_settings:f={}}=e,{waveform_options:g={}}=e,{dragging:k}=e,{active_source:E}=e,{handle_reset_value:p=()=>{}}=e,{editable:L=!0}=e;const R=Wl("upload_files");let A=!1,C,T="",D,z=[],B=!1,q=!1,$=[],X;function W(){X=[Tn(()=>import("./module-084e0147.js"),["./module-084e0147.js","./module-a3cf0cc4.js","./Index-3441375f.js","./index-df998e04.js","./index-1ebe9c14.css","./Index-c88eb5f1.css"],import.meta.url),Tn(()=>import("./module-a5a0afa0.js"),["./module-a5a0afa0.js","./module-a3cf0cc4.js"],import.meta.url)]}h&&W();const M=Ol(),v=async(w,K)=>{let He=new File(w,"audio.wav");const ut=await us([He],K==="stream");t(1,o=(await cs(ut,u,void 0,R))?.filter(Boolean)[0]),M(K,o)};ql(()=>{h&&C&&C.state!=="inactive"&&C.stop()});async function I(){let w;try{w=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(K){if(!navigator.mediaDevices){M("error",_("audio.no_device_support"));return}if(K instanceof DOMException&&K.name=="NotAllowedError"){M("error",_("audio.allow_recording_access"));return}throw K}if(w!=null){if(h){const[{MediaRecorder:K,register:He},{connect:ut}]=await Promise.all(X);await He(await ut()),C=new K(w,{mimeType:"audio/wav"}),C.addEventListener("dataavailable",O)}else C=new MediaRecorder(w),C.addEventListener("dataavailable",K=>{$.push(K.data)}),C.addEventListener("stop",async()=>{t(15,A=!1),await v($,"change"),await v($,"stop_recording"),$=[]});q=!0}}async function O(w){let K=await w.data.arrayBuffer(),He=new Uint8Array(K);if(D||(t(24,D=new Uint8Array(K.slice(0,ki))),He=new Uint8Array(K.slice(ki))),c)z.push(He);else{let ut=[D].concat(z,[He]);v(ut,"stream"),t(25,z=[])}}async function P(){t(15,A=!0),M("start_recording"),q||await I(),t(24,D=void 0),h&&C.start(Xl)}function b(){M("change",null),M("clear"),t(16,T=""),t(1,o=null)}function G({detail:w}){t(1,o=w),M("change",w),M("upload",w)}function y(){t(15,A=!1),h&&(M("stop_recording"),C.stop(),c&&t(26,B=!0),v($,"stop_recording"),M("clear"),t(16,T=""))}function J(w){T=w,t(16,T)}function le(w){Ie.call(this,i,w)}function me(w){Ie.call(this,i,w)}function Yt(w){Ie.call(this,i,w)}function Zt(w){k=w,t(0,k)}const Jt=({detail:w})=>M("error",w),Kt=()=>t(16,T="edit");function Qt(w){T=w,t(16,T)}function xt(w){Ie.call(this,i,w)}function en(w){Ie.call(this,i,w)}function tn(w){Ie.call(this,i,w)}function nn(w){Ie.call(this,i,w)}function S(w){E=w,t(2,E)}return i.$$set=w=>{"value"in w&&t(1,o=w.value),"label"in w&&t(3,r=w.label),"root"in w&&t(4,u=w.root),"show_label"in w&&t(5,a=w.show_label),"show_download_button"in w&&t(6,d=w.show_download_button),"s
103ources"in w&&t(7,l=w.sources),"pending"in w&&t(23,c=w.pending),"streaming"in w&&t(8,h=w.streaming),"i18n"in w&&t(9,_=w.i18n),"waveform_settings"in w&&t(10,m=w.waveform_settings),"trim_region_settings"in w&&t(11,f=w.trim_region_settings),"waveform_options"in w&&t(12,g=w.waveform_options),"dragging"in w&&t(0,k=w.dragging),"active_source"in w&&t(2,E=w.active_source),"handle_reset_value"in w&&t(13,p=w.handle_reset_value),"editable"in w&&t(14,L=w.editable),"$$scope"in w&&t(41,s=w.$$scope)},i.$$.update=()=>{if(i.$$.dirty[0]&1&&M("drag",k),i.$$.dirty[0]&125829120&&B&&c===!1&&(t(26,B=!1),D&&z)){let w=[D].concat(z);t(25,z=[]),v(w,"stream")}},[k,o,E,r,u,a,d,l,h,_,m,f,g,p,L,A,T,M,v,P,b,G,y,c,D,z,B,n,J,le,me,Yt,Zt,Jt,Kt,Qt,xt,en,tn,nn,S,s]}class Yl extends Rl{constructor(e){super(),Tl(this,e,Gl,Fl,zl,{value:1,label:3,root:4,show_label:5,show_download_button:6,sources:7,pending:23,streaming:8,i18n:9,waveform_settings:10,trim_region_settings:11,waveform_options:12,dragging:0,active_source:2,handle_reset_value:13,editable:14},null,[-1,-1])}get value(){return this.$$.ctx[1]}set value(e){this.$$set({value:e}),Q()}get label(){return this.$$.ctx[3]}set label(e){this.$$set({label:e}),Q()}get root(){return this.$$.ctx[4]}set root(e){this.$$set({root:e}),Q()}get show_label(){return this.$$.ctx[5]}set show_label(e){this.$$set({show_label:e}),Q()}get show_download_button(){return this.$$.ctx[6]}set show_download_button(e){this.$$set({show_download_button:e}),Q()}get sources(){return this.$$.ctx[7]}set sources(e){this.$$set({sources:e}),Q()}get pending(){return this.$$.ctx[23]}set pending(e){this.$$set({pending:e}),Q()}get streaming(){return this.$$.ctx[8]}set streaming(e){this.$$set({streaming:e}),Q()}get i18n(){return this.$$.ctx[9]}set i18n(e){this.$$set({i18n:e}),Q()}get waveform_settings(){return this.$$.ctx[10]}set waveform_settings(e){this.$$set({waveform_settings:e}),Q()}get trim_region_settings(){return this.$$.ctx[11]}set trim_region_settings(e){this.$$set({trim_region_settings:e}),Q()}get waveform_options(){return this.$$.ctx[12]}set waveform_options(e){this.$$set({waveform_options:e}),Q()}get dragging(){return this.$$.ctx[0]}set dragging(e){this.$$set({dragging:e}),Q()}get active_source(){return this.$$.ctx[2]}set active_source(e){this.$$set({active_source:e}),Q()}get handle_reset_value(){return this.$$.ctx[13]}set handle_reset_value(e){this.$$set({handle_reset_value:e}),Q()}get editable(){return this.$$.ctx[14]}set editable(e){this.$$set({editable:e}),Q()}}const Zl=Yl,{SvelteComponent:Jl,add_flush_callback:Kl,assign:Ki,bind:Ql,binding_callbacks:xl,check_outros:ea,create_component:Xe,destroy_component:Ge,detach:Mn,empty:ta,flush:V,get_spread_object:Qi,get_spread_update:xi,group_outros:na,init:ia,insert:Pn,mount_component:Ye,safe_not_equal:sa,space:es,transition_in:ye,transition_out:Ce}=window.__gradio__svelte__internal;function oa(i){let e,t;return e=new yi({props:{variant:i[0]===null&&i[20]==="upload"?"dashed":"solid",border_mode:i[21]?"focus":"base",padding:!1,allow_overflow:!1,elem_id:i[2],elem_classes:i[3],visible:i[4],container:i[10],scale:i[11],min_width:i[12],$$slots:{default:[aa]},$$scope:{ctx:i}}}),{c(){Xe(e.$$.fragment)},m(n,s){Ye(e,n,s),t=!0},p(n,s){const o={};s[0]&1048577&&(o.variant=n[0]===null&&n[20]==="upload"?"dashed":"solid"),s[0]&2097152&&(o.border_mode=n[21]?"focus":"base"),s[0]&4&&(o.elem_id=n[2]),s[0]&8&&(o.elem_classes=n[3]),s[0]&16&&(o.visible=n[4]),s[0]&1024&&(o.container=n[10]),s[0]&2048&&(o.scale=n[11]),s[0]&4096&&(o.min_width=n[12]),s[0]&8364995|s[1]&262144&&(o.$$scope={dirty:s,ctx:n}),e.$set(o)},i(n){t||(ye(e.$$.fragment,n),t=!0)},o(n){Ce(e.$$.fragment,n),t=!1},d(n){Ge(e,n)}}}function ra(i){let e,t;return e=new yi({props:{variant:"solid",border_mode:i[21]?"focus":"base",padding:!1,allow_overflow:!1,elem_id:i[2],elem_classes:i[3],visible:i[4],container:i[10],scale:i[11],min_width:i[12],$$slots:{default:[ua]},$$scope:{ctx:i}}}),{c(){Xe(e.$$.fragment)},m(n,s){Ye(e,n,s),t=!0},p(n,s){const o={};s[0]&2097152&&(o.border_mode=n[21]?"focus":"base"),s[0]&4&&(o.elem_id=n[2]),s[0]&8&&(o.elem_classes=n[3]),s[0]&16&&(o.visible=n[4]),s[0]&1024&&(o.container=n[10]),s[0]&2048&&(o.scale=n[11]),s[0]&4096&&(o.min_width=n[12]),s[0]&4842115|s[1]&262144&&(o.$$scope={dirty:s,ctx:n}),e.$set(o)},i(n){t||(ye(e.$$.fragment,n),t=!0)},o(n){Ce(e.$$.fragment,n),t=!1},d(n){Ge(e,n)}}}function la(i){let e,t;return e=new fs({props:{i18n:i[19].i18n,type:"audio"}}),{c(){Xe(e.$$.fragment)},m(n,s){Ye(e,n,s),t=!0},p(n,s){const o={};
vendor: 4,166 bytes, line 103
103s[0]&524288&&(o.i18n=n[19].i18n),e.$set(o)},i(n){t||(ye(e.$$.fragment,n),t=!0)},o(n){Ce(e.$$.fragment,n),t=!1},d(n){Ge(e,n)}}}function aa(i){let e,t,n,s,o;const r=[{autoscroll:i[19].autoscroll},{i18n:i[19].i18n},i[1]];let u={};for(let l=0;l<r.length;l+=1)u=Ki(u,r[l]);e=new Ri({props:u});function a(l){i[34](l)}let d={label:i[7],show_label:i[9],show_download_button:i[13],value:i[0],root:i[8],sources:i[6],active_source:i[20],pending:i[17],streaming:i[18],handle_reset_value:i[23],editable:i[15],i18n:i[19].i18n,waveform_settings:i[22],waveform_options:i[16],trim_region_settings:i[24],$$slots:{default:[la]},$$scope:{ctx:i}};return i[21]!==void 0&&(d.dragging=i[21]),n=new Zl({props:d}),xl.push(()=>Ql(n,"dragging",a)),n.$on("change",i[35]),n.$on("stream",i[36]),n.$on("drag",i[37]),n.$on("edit",i[38]),n.$on("play",i[39]),n.$on("pause",i[40]),n.$on("stop",i[41]),n.$on("start_recording",i[42]),n.$on("pause_recording",i[43]),n.$on("stop_recording",i[44]),n.$on("upload",i[45]),n.$on("clear",i[46]),n.$on("error",i[25]),{c(){Xe(e.$$.fragment),t=es(),Xe(n.$$.fragment)},m(l,c){Ye(e,l,c),Pn(l,t,c),Ye(n,l,c),o=!0},p(l,c){const h=c[0]&524290?xi(r,[c[0]&524288&&{autoscroll:l[19].autoscroll},c[0]&524288&&{i18n:l[19].i18n},c[0]&2&&Qi(l[1])]):{};e.$set(h);const _={};c[0]&128&&(_.label=l[7]),c[0]&512&&(_.show_label=l[9]),c[0]&8192&&(_.show_download_button=l[13]),c[0]&1&&(_.value=l[0]),c[0]&256&&(_.root=l[8]),c[0]&64&&(_.sources=l[6]),c[0]&1048576&&(_.active_source=l[20]),c[0]&131072&&(_.pending=l[17]),c[0]&262144&&(_.streaming=l[18]),c[0]&32768&&(_.editable=l[15]),c[0]&524288&&(_.i18n=l[19].i18n),c[0]&4194304&&(_.waveform_settings=l[22]),c[0]&65536&&(_.waveform_options=l[16]),c[0]&524288|c[1]&262144&&(_.$$scope={dirty:c,ctx:l}),!s&&c[0]&2097152&&(s=!0,_.dragging=l[21],Kl(()=>s=!1)),n.$set(_)},i(l){o||(ye(e.$$.fragment,l),ye(n.$$.fragment,l),o=!0)},o(l){Ce(e.$$.fragment,l),Ce(n.$$.fragment,l),o=!1},d(l){l&&Mn(t),Ge(e,l),Ge(n,l)}}}function ua(i){let e,t,n,s;const o=[{autoscroll:i[19].autoscroll},{i18n:i[19].i18n},i[1]];let r={};for(let u=0;u<o.length;u+=1)r=Ki(r,o[u]);return e=new Ri({props:r}),n=new Mr({props:{i18n:i[19].i18n,show_label:i[9],show_download_button:i[13],show_share_button:i[14],value:i[0],label:i[7],waveform_settings:i[22],waveform_options:i[16],editable:i[15]}}),n.$on("share",i[29]),n.$on("error",i[30]),n.$on("play",i[31]),n.$on("pause",i[32]),n.$on("stop",i[33]),{c(){Xe(e.$$.fragment),t=es(),Xe(n.$$.fragment)},m(u,a){Ye(e,u,a),Pn(u,t,a),Ye(n,u,a),s=!0},p(u,a){const d=a[0]&524290?xi(o,[a[0]&524288&&{autoscroll:u[19].autoscroll},a[0]&524288&&{i18n:u[19].i18n},a[0]&2&&Qi(u[1])]):{};e.$set(d);const l={};a[0]&524288&&(l.i18n=u[19].i18n),a[0]&512&&(l.show_label=u[9]),a[0]&8192&&(l.show_download_button=u[13]),a[0]&16384&&(l.show_share_button=u[14]),a[0]&1&&(l.value=u[0]),a[0]&128&&(l.label=u[7]),a[0]&4194304&&(l.waveform_settings=u[22]),a[0]&65536&&(l.waveform_options=u[16]),a[0]&32768&&(l.editable=u[15]),n.$set(l)},i(u){s||(ye(e.$$.fragment,u),ye(n.$$.fragment,u),s=!0)},o(u){Ce(e.$$.fragment,u),Ce(n.$$.fragment,u),s=!1},d(u){u&&Mn(t),Ge(e,u),Ge(n,u)}}}function ca(i){let e,t,n,s;const o=[ra,oa],r=[];function u(a,d){return a[5]?1:0}return e=u(i),t=r[e]=o[e](i),{c(){t.c(),n=ta()},m(a,d){r[e].m(a,d),Pn(a,n,d),s=!0},p(a,d){let l=e;e=u(a),e===l?r[e].p(a,d):(na(),Ce(r[l],1,1,()=>{r[l]=null}),ea(),t=r[e],t?t.p(a,d):(t=r[e]=o[e](a),t.c()),ye(t,1),t.m(n.parentNode,n))},i(a){s||(ye(t),s=!0)},o(a){Ce(t),s=!1},d(a){a&&Mn(n),r[e].d(a)}}}function da(i,e,t){let{elem_id:n=""}=e,{elem_classes:s=[]}=e,{visible:o=!0}=e,{interactive:r}=e,{value:u=null}=e,{sources:a}=e,{label:d}=e,{root:l}=e,{show_label:c}=e,{container:h=!0}=e,{scale:_=null}=e,{min_width:m=void 0}=e,{loading_status:f}=e,{autoplay:g=!1}=e,{show_download_button:k}=e,{show_share_button:E=!1}=e,{editable:p=!0}=e,{waveform_options:L={}}=e,{pending:R}=e,{streaming:A}=e,{gradio:C}=e,T=null,D,z=u;const B=()=>{z===null||u===z||t(0,u=z)};let q,$,X=getComputedStyle(document.documentElement).getPropertyValue("--color-accent");const W={color:L.trim_region_color,drag:!0,resize:!0};function M(){document.documentElement.style.setProperty("--trim-region-color",W.color||X)}M();
103function v({detail:S}){const[w,K]=S.includes("Invalid file type")?["warning","complete"]:["error","error"];t(1,f=f||{}),t(1,f.status=K,f),t(1,f.message=S,f),C.dispatch(w,S)}const I=S=>C.dispatch("share",S.detail),O=S=>C.dispatch("error",S.detail),P=()=>C.dispatch("play"),b=()=>C.dispatch("pause"),G=()=>C.dispatch("stop");function y(S){q=S,t(21,q)}const J=({detail:S})=>t(0,u=S),le=({detail:S})=>{t(0,u=S),C.dispatch("stream",u)},me=({detail:S})=>t(21,q=S),Yt=()=>C.dispatch("edit"),Zt=()=>C.dispatch("play"),Jt=()=>C.dispatch("pause"),Kt=()=>C.dispatch("stop"),Qt=()=>C.dispatch("start_recording"),xt=()=>C.dispatch("pause_recording"),en=S=>C.dispatch("stop_recording"),tn=()=>C.dispatch("upload"),nn=()=>C.dispatch("clear");return i.$$set=S=>{"elem_id"in S&&t(2,n=S.elem_id),"elem_classes"in S&&t(3,s=S.elem_classes),"visible"in S&&t(4,o=S.visible),"interactive"in S&&t(5,r=S.interactive),"value"in S&&t(0,u=S.value),"sources"in S&&t(6,a=S.sources),"label"in S&&t(7,d=S.label),"root"in S&&t(8,l=S.root),"show_label"in S&&t(9,c=S.show_label),"container"in S&&t(10,h=S.container),"scale"in S&&t(11,_=S.scale),"min_width"in S&&t(12,m=S.min_width),"loading_status"in S&&t(1,f=S.loading_status),"autoplay"in S&&t(26,g=S.autoplay),"show_download_button"in S&&t(13,k=S.show_download_button),"show_share_button"in S&&t(14,E=S.show_share_button),"editable"in S&&t(15,p=S.editable),"waveform_options"in S&&t(16,L=S.waveform_options),"pending"in S&&t(17,R=S.pending),"streaming"in S&&t(18,A=S.streaming),"gradio"in S&&t(19,C=S.gradio)},i.$$.update=()=>{i.$$.dirty[0]&268435457&&u&&z===null&&t(28,z=u),i.$$.dirty[0]&134742017&&JSON.stringify(u)!==JSON.stringify(T)&&(t(27,T=u),C.dispatch("change")),i.$$.dirty[0]&1048640&&!D&&a&&t(20,D=a[0]),i.$$.dirty[0]&67174400&&t(22,$={height:50,waveColor:L.waveform_color||"#9ca3af",progressColor:L.waveform_progress_color||X,barWidth:2,barGap:3,cursorWidth:2,cursorColor:"#ddd5e9",autoplay:g,barRadius:10,dragToSeek:!0,normalize:!0,minPxPerSec:20,mediaControls:L.show_controls,sampleRate:L.sample_rate||44100})},[u,f,n,s,o,r,a,d,l,c,h,_,m,k,E,p,L,R,A,C,D,q,$,B,W,v,g,T,z,I,O,P,b,G,y,J,le,me,Yt,Zt,Jt,Kt,Qt,xt,en,tn,nn]}class ha extends Jl{constructor(e){super(),ia(this,e,da,ca,sa,{elem_id:2,elem_classes:3,visible:4,interactive:5,value:0,sources:6,label:7,root:8,show_label:9,container:10,scale:11,min_width:12,loading_status:1,autoplay:26,show_download_button:13,show_share_button:14,editable:15,waveform_options:16,pending:17,streaming:18,gradio:19},null,[-1,-1])}get elem_id(){return this.$$.ctx[2]}set elem_id(e){this.$$set({elem_id:e}),V()}get elem_classes(){return this.$$.ctx[3]}set elem_classes(e){this.$$set({elem_classes:e}),V()}get visible(){return this.$$.ctx[4]}set visible(e){this.$$set({visible:e}),V()}get interactive(){return this.$$.ctx[5]}set interactive(e){this.$$set({interactive:e}),V()}get value(){return this.$$.ctx[0]}set value(e){this.$$set({value:e}),V()}get sources(){return this.$$.ctx[6]}set sources(e){this.$$set({sources:e}),V()}get label(){return this.$$.ctx[7]}set label(e){this.$$set({label:e}),V()}get root(){return this.$$.ctx[8]}set root(e){this.$$set({root:e}),V()}get show_label(){return this.$$.ctx[9]}set show_label(e){this.$$set({show_label:e}),V()}get container(){return this.$$.ctx[10]}set container(e){this.$$set({container:e}),V()}get scale(){return this.$$.ctx[11]}set scale(e){this.$$set({scale:e}),V()}get min_width(){return this.$$.ctx[12]}set min_width(e){this.$$set({min_width:e}),V()}get loading_status(){return this.$$.ctx[1]}set loading_status(e){this.$$set({loading_status:e}),V()}get autoplay(){return this.$$.ctx[26]}set autoplay(e){this.$$set({autoplay:e}),V()}get show_download_button(){return this.$$.ctx[13]}set show_download_button(e){this.$$set({show_download_button:e}),V()}get show_share_button(){return this.$$.ctx[14]}set show_share_button(e){this.$$set({show_share_button:e}),V()}get editable(){return this.$$.ctx[15]}set editable(e){this.$$set({editable:e}),V()}get waveform_options(){return this.$$.ctx[16]}set waveform_options(e){this.$$set({waveform_options:e}),V()}get pending(){return this.$$.ctx[17]}set pending(e){this.$$set({pending:e}),V()}get streaming(){return this.$$.ctx[18]}set streaming(e){this.$$set({streaming:e}),V()}get gradio(){return this.$$.ctx[19]}set gradio(e){this.$$set({gradio:e}),V()}}const Wa=ha;export{Ba as BaseExample,Zl as BaseInteractiveAudio,$i as BasePlayer,Mr as BaseStaticAudio,Wa as default};
104//# sourceMappingURL=index-3744e2a9.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.