import './async-D55cHugf.js';
import { d as bind_props, f as attr_class, a as attr, i as stringify, c as spread_props, g as attr_style, j as clsx, e as ensure_array_like } from './index-u8mz_F03.js';
import { o as onDestroy, t as tick } from './index-server-CQz6EZl_.js';
import { b as bs } from './2-BLdXJizP.js';
import { $, b } from './utils.svelte-B2py64Fz.js';
import { W } from './index3-Df92vI-L.js';
import { A as kl, S as Pl } from './StaticAudio-CgMOYc6I.js';
import { e as ee } from './Upload2-uTutz1dY.js';
import { v } from './ModifyUpload-CWSi2EyW.js';
import { k } from './BlockLabel-bKYWnOzQ.js';
import { y } from './ShareButton-7VTs9dOO.js';
import { t } from './Music-B6sg6ISZ.js';
import { w } from './SelectSource-Bhpgvmj9.js';
import { v as v$1 } from './IconButtonWrapper-CjFRPb3y.js';
import { o } from './StreamingBar-BGU65w2M.js';
import { G } from './Block-DZmzQwnI.js';
import { k as k$1 } from './UploadText-BDXc1cBO.js';
export { default as BaseExample } from './Example10-_LenqteX.js';
import { e as escape_html } from './escaping-CBnpiEl5.js';
import './context-CBkBucIx.js';
import './index5-BoOEKc6P.js';
import './dev-fallback-Bc5Ork7Y.js';
import './index-Cg-Pg6j3.js';
import './clone-Yk88IHKV.js';
import './IconButton-BRnu7KaR.js';
import './Clear-D7Yjckqz.js';
import './DownloadLink-nj1p0krE.js';
import './Empty-DGRbZO0a.js';
import './Download-DcU5dONL.js';
import './MinimalAudioPlayer-CtXDbTgQ.js';
import './VolumeLevels-DlU2d99x.js';
import './Play-B_z3rKL1.js';
import './Undo-Ce01x-M5.js';
import './Edit-DWZSi_T0.js';
import './Upload-BbxeBrrD.js';
import './Microphone-BMM9-23W.js';
import './Video-FfbWmOVG.js';
import './Webcam-CvKMKUzA.js';

function Ms(f){f.push('<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 50 50" class="svelte-l5a973"><circle cx="25" cy="25" r="20" fill="none" stroke-width="3.0" stroke-linecap="round" stroke-dasharray="94.2477796076938 94.2477796076938" stroke-dashoffset="0" class="svelte-l5a973"><animateTransform attributeName="transform" type="rotate" from="0 25 25" to="360 25 25" repeatCount="indefinite" class="svelte-l5a973"></animateTransform></circle></svg>');}function zs(f,_){f.component(l=>{let{i18n:i,micDevices:r=void 0,onerror:c}=_;if(l.push(`<select class="mic-select svelte-ym1wxn" aria-label="Select input device"${attr("disabled",!r||r.length===0,true)}>`),!r||r.length===0)l.push("<!--[-->"),l.option({value:""},u=>{u.push(`${escape_html(i("audio.no_microphone"))}`);});else {l.push("<!--[!-->"),l.push("<!--[-->");const u=ensure_array_like(r);for(let d=0,s=u.length;d<s;d++){let m=u[d];l.option({value:m.deviceId},b=>{b.push(`${escape_html(m.label)}`);});}l.push("<!--]-->");}l.push("<!--]--></select>"),bind_props(_,{micDevices:r});});}function Es(f,_){f.component(l=>{let{mode:i=void 0,i18n:r,dispatch_blob:c,waveform_settings:u,waveform_options:d={show_recording_waveform:true},handle_reset_value:s,editable:m=true,recording:b=false,onstartrecording:S,onpauserecording:e,onstoprecording:x,onstop:h,onplay:B,onpause:M,onedit:A}=_;let y=true,v;function D(n){n.push('<div class="component-wrapper svelte-j9q3sk"><div class="microphone svelte-j9q3sk" data-testid="microphone-waveform"></div> <div data-testid="recording-waveform"></div> '),n.push("<!--[!-->"),n.push("<!--]--> "),n.push("<!--[!-->"),n.push("<!--]--> "),n.push("<!--[!-->"),n.push("<!--]--></div>");}do y=true,v=l.copy(),D(v);while(!y);l.subsume(v),bind_props(_,{mode:i});});}function Ps(f,_){f.component(l=>{let{recording:i=false,paused_recording:r=false,i18n:c,waveform_options:u={show_recording_waveform:true},waiting:d=false}=_,s=[];let m=true,b;function S(e){e.push('<div class="mic-wrap svelte-m6ymia">'),u.show_recording_waveform?(e.push("<!--[-->"),e.push(`<div class="svelte-m6ymia"${attr_style("",{display:i?"block":"none"})}></div>`)):e.push("<!--[!-->"),e.push('<!--]--> <div class="controls svelte-m6ymia">'),i&&!d?(e.push("<!--[-->"),e.push(`<button${attr_class(clsx(r?"stop-button-paused":"stop-button"),"svelte-m6ymia")}><span class="record-icon svelte-m6ymia"><span class="pinger svelte-m6ymia"></span> <span class="dot svelte-m6ymia"></span></span> ${escape_html(c(r?"audio.pause":"audio.stop"))}</button>`)):(e.push("<!--[!-->"),i&&d?(e.push("<!--[-->"),e.push('<button class="spinner-button svelte-m6ymia"><div class="icon svelte-m6ymia">'),Ms(e),e.push(`<!----></div> ${escape_html(c("audio.waiting"))}</button>`)):(e.push("<!--[!-->"),e.push(`<button class="record-button svelte-m6ymia"><span class="record-icon svelte-m6ymia"><span class="dot svelte-m6ymia"></span></span> ${escape_html(c("audio.record"))}</button>`)),e.push("<!--]-->")),e.push("<!--]--> "),zs(e,{i18n:c,get micDevices(){return s},set micDevices(x){s=x,m=false;}}),e.push("<!----></div></div>");}do m=true,b=l.copy(),S(b);while(!m);l.subsume(b);});}let Z;async function Ts(){const{MediaRecorder:f,register:_}=await import('./module3-CsOA9qDp.js'),{connect:l}=await import('./module-BW3J_rLT.js');return _(await l()),Z=f,Z}function Us(f,_){f.component(l=>{let{value:i=null,subtitles:r=null,label:c,root:u,loop:d,show_label:s=true,buttons:m=["download","share"],on_custom_button_click:b$1=null,sources:S=["microphone","upload"],pending:e=false,streaming:x=false,i18n:h,waveform_settings:B,trim_region_settings:M={},waveform_options:A={},dragging:y$1=false,active_source:v$2="microphone",handle_reset_value:D=()=>{},editable:n=true,max_file_size:C=null,upload:T,stream_handler:w$1,stream_every:g=.1,uploading:a=false,recording:G=false,class_name:$="",upload_promise:R=void 0,initial_value:W=void 0,playback_position:j=void 0,time_limit:ss=null,stream_state:os="closed",onchange:q,onstream:as,onedit:H,onplay:ts,onpause:es,onstop:is,ondrag:Gs,onerror:O,onupload:ls,onclear:ns,onstart_recording:ps,onpause_recording:us,onstop_recording:J,onclose_stream:Rs,children:K}=_,I="";typeof window<"u"&&x&&Ts().then(t=>{});const rs=t=>t.map(o=>o instanceof Blob?o:o.slice()),Q=async(t,o)=>{let z=new File(rs(t),"audio.wav",{type:"audio/wav"});if(z.size===0)return;const E=await bs([z],o==="stream");W=i,i=(await T(E,u,void 0,C||void 0))?.filter(Boolean)[0],o==="stream"?as?.(i):o==="change"?q?.(i):o==="stop_recording"&&J?.();};onDestroy(()=>{});function F(){q?.(null),ns?.(),I="",i=null;}function cs(t){i=t,q?.(t),ls?.(t);}let k$1=true,L;function ds(t$1){k(t$1,{show_label:s,Icon:t,float:v$2==="upload"&&i===null,label:c||h("audio.audio")}),t$1.push(`<!----> <div${attr_class(`audio-container ${stringify($)}`,"svelte-ocxd3m")}${attr("data-testid",c?"waveform-"+c:"unlabelled-audio")}>`),o(t$1,{time_limit:ss}),t$1.push("<!----> "),i==null||x?(t$1.push("<!--[-->"),v$2==="microphone"?(t$1.push("<!--[-->"),v(t$1,{i18n:h,onclear:F}),t$1.push("<!----> "),x?(t$1.push("<!--[-->"),Ps(t$1,{recording:G,i18n:h,waveform_options:A,waiting:os==="waiting"})):(t$1.push("<!--[!-->"),Es(t$1,{i18n:h,editable:n,recording:G,dispatch_blob:Q,waveform_settings:B,waveform_options:A,handle_reset_value:D,onstartrecording:()=>ps?.(),onpauserecording:()=>us?.(),onstoprecording:()=>J?.(),get mode(){return I},set mode(o){I=o,k$1=false;}})),t$1.push("<!--]-->")):(t$1.push("<!--[!-->"),v$2==="upload"?(t$1.push("<!--[-->"),ee(t$1,{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/*",onload:cs,onerror:o=>O?.(o),root:u,max_file_size:C,upload:T,stream_handler:w$1,aria_label:h("audio.drop_to_upload"),get upload_promise(){return R},set upload_promise(o){R=o,k$1=false;},get dragging(){return y$1},set dragging(o){y$1=o,k$1=false;},get uploading(){return a},set uploading(o){a=o,k$1=false;},children:o=>{K?(o.push("<!--[-->"),K(o),o.push("<!---->")):o.push("<!--[!-->"),o.push("<!--]-->");},$$slots:{default:true}})):t$1.push("<!--[!-->"),t$1.push("<!--]-->")),t$1.push("<!--]-->")):(t$1.push("<!--[!-->"),v(t$1,{i18n:h,onclear:F,onedit:()=>{I="edit",H?.();},download:m===null||m.some(o=>typeof o=="string"&&o==="download")?i.url:null,children:o=>{if(i!==null&&m){o.push("<!--[-->"),o.push("<!--[-->");const z=ensure_array_like(m);for(let E=0,ms=z.length;E<ms;E++){let N=z[E];typeof N=="string"?(o.push("<!--[-->"),N==="share"?(o.push("<!--[-->"),y(o,{i18n:h,onerror:O,onshare:()=>{},formatter:async P=>!P||!P.url?"":`<audio controls src="${await b(P.url)}"></audio>`,value:i})):o.push("<!--[!-->"),o.push("<!--]-->")):(o.push("<!--[!-->"),v$1(o,{button:N,on_click:P=>{b$1&&b$1(P);}})),o.push("<!--]-->");}o.push("<!--]-->");}else o.push("<!--[!-->");o.push("<!--]-->");}}),t$1.push("<!----> "),kl(t$1,{value:i,subtitles:Array.isArray(r)?r:r?.url,label:c,i18n:h,dispatch_blob:Q,waveform_settings:B,waveform_options:A,trim_region_settings:M,handle_reset_value:D,editable:n,loop:d,interactive:true,onstop:is,onplay:ts,onpause:es,onedit:H,get mode(){return I},set mode(o){I=o,k$1=false;},get playback_position(){return j},set playback_position(o){j=o,k$1=false;}}),t$1.push("<!---->")),t$1.push("<!--]--> "),w(t$1,{sources:S,handle_clear:F,get active_source(){return v$2},set active_source(o){v$2=o,k$1=false;}}),t$1.push("<!----></div>");}do k$1=true,L=l.copy(),ds(L);while(!k$1);l.subsume(L),bind_props(_,{value:i,dragging:y$1,active_source:v$2,uploading:a,recording:G,upload_promise:R,initial_value:W,playback_position:j});});}function uo(f,_){f.component(l=>{let{$$slots:i,$$events:r,...c}=_,u;c.props.stream_every=.1;class d extends ${async get_data(){return u&&(await u,await tick()),await super.get_data()}}const s=new d(c);let m=s.shared.label||s.i18n("audio.audio"),b=c.minimal??s.props.minimal??false,S=s.props.sources?s.props.sources[0]:null,e=s.props.value;const x=()=>{e===null||s.props.value===e||(s.props.value=e);};let h=false,B=s.props.recording??false,M="darkorange",A={height:50,barWidth:2,barGap:3,cursorWidth:2,cursorColor:"#ddd5e9",autoplay:s.props.autoplay,barRadius:10,dragToSeek:true,normalize:true,minPxPerSec:20,waveColor:s.props.waveform_options.waveform_color||"#9ca3af",progressColor:s.props.waveform_options.waveform_progress_color||M,mediaControls:s.props.waveform_options.show_controls??false,sampleRate:s.props.waveform_options.sample_rate||44100};const y={color:s.props.waveform_options.trim_region_color,drag:true,resize:true};function D(w){const[g,a]=w.includes("Invalid file type")?["warning","complete"]:["error","error"];s.shared.loading_status&&(s.shared.loading_status.status=a,s.shared.loading_status.message=w),s.dispatch(g,w);}s.watch_for_change();let n=true,C;function T(w){s.shared.interactive?(w.push("<!--[!-->"),G(w,{variant:s.props.value===null&&S==="upload"?"dashed":"solid",border_mode:h?"focus":"base",padding:false,allow_overflow:false,elem_id:s.shared.elem_id,elem_classes:s.shared.elem_classes,visible:s.shared.visible,container:s.shared.container,scale:s.shared.scale,min_width:s.shared.min_width,children:g=>{W(g,spread_props([{autoscroll:s.shared.autoscroll,i18n:s.i18n},s.shared.loading_status,{on_clear_status:()=>s.dispatch("clear_status",s.shared.loading_status)}])),g.push("<!----> "),Us(g,{label:m,show_label:s.shared.show_label,buttons:s.props.buttons??[],on_custom_button_click:a=>{s.dispatch("custom_button_click",{id:a});},value:s.props.value,subtitles:s.props.subtitles,onchange:a=>s.props.value=a,onstream:a=>{s.props.value=a,s.dispatch("stream",s.props.value);},ondrag:a=>h=a,root:s.shared.root,sources:s.props.sources,active_source:S||void 0,pending:s.shared.loading_status.pending,streaming:s.props.streaming,loop:s.props.loop,max_file_size:s.shared.max_file_size,handle_reset_value:x,editable:s.props.editable,onedit:()=>s.dispatch("edit"),onplay:()=>s.dispatch("play"),onpause:()=>s.dispatch("pause"),onstop:()=>s.dispatch("stop"),onstart_recording:()=>s.dispatch("start_recording"),onpause_recording:()=>s.dispatch("pause_recording"),onstop_recording:()=>{s.dispatch("stop_recording"),s.dispatch("input");},onupload:()=>{s.dispatch("upload"),s.dispatch("input");},onclear:()=>{s.dispatch("clear"),s.dispatch("input");},onerror:D,onclose_stream:()=>s.dispatch("close_stream","stream"),i18n:s.i18n,waveform_settings:A,waveform_options:s.props.waveform_options,trim_region_settings:y,stream_every:s.props.stream_every,stream_state:s.shared.loading_status.stream_state,upload:(...a)=>s.shared.client.upload(...a),stream_handler:(...a)=>s.shared.client.stream(...a),time_limit:s.shared.loading_status.time_limit,get upload_promise(){return u},set upload_promise(a){u=a,n=false;},get initial_value(){return e},set initial_value(a){e=a,n=false;},get recording(){return B},set recording(a){B=a,n=false;},get dragging(){return h},set dragging(a){h=a,n=false;},get playback_position(){return s.props.playback_position},set playback_position(a){s.props.playback_position=a,n=false;},children:a=>{k$1(a,{i18n:s.i18n,type:"audio"});},$$slots:{default:true}}),g.push("<!---->");},$$slots:{default:true}})):(w.push("<!--[-->"),G(w,{variant:"solid",border_mode:h?"focus":"base",padding:false,allow_overflow:false,elem_id:s.shared.elem_id,elem_classes:s.shared.elem_classes,visible:s.shared.visible,container:s.shared.container,scale:s.shared.scale,min_width:s.shared.min_width,children:g=>{W(g,spread_props([{autoscroll:s.shared.autoscroll,i18n:s.i18n},s.shared.loading_status,{on_clear_status:()=>s.dispatch("clear_status",s.shared.loading_status)}])),g.push("<!----> "),Pl(g,{i18n:s.i18n,show_label:s.shared.show_label,buttons:s.props.buttons??["download","share"],value:s.props.value,subtitles:s.props.subtitles,label:m,loop:s.props.loop,waveform_settings:A,waveform_options:s.props.waveform_options,editable:s.props.editable,minimal:b,on_custom_button_click:a=>{s.dispatch("custom_button_click",{id:a});},onshare:a=>s.dispatch("share",a),onerror:a=>s.dispatch("error",a.detail),onplay:()=>s.dispatch("play"),onpause:()=>s.dispatch("pause"),onstop:()=>s.dispatch("stop"),get playback_position(){return s.props.playback_position},set playback_position(a){s.props.playback_position=a,n=false;}}),g.push("<!---->");},$$slots:{default:true}})),w.push("<!--]-->");}do n=true,C=l.copy(),T(C);while(!n);l.subsume(C);});}

export { Us as BaseInteractiveAudio, kl as BasePlayer, Pl as BaseStaticAudio, uo as default };
//# sourceMappingURL=index53-wvB_-bo9.js.map
