import './async-Djx13DAD.js';
import { c as bind_props, d as attr_class, a as attr, j as stringify, b as spread_props, g as attr_style, k as clsx, e as ensure_array_like } from './index-B7gr0Dsc.js';
import { o as onDestroy, t as tick } from './index-server-lqjMX237.js';
import { S as Ss } from './2-CeYbpaU1.js';
import { g, w } from './utils.svelte-D8Xdzglu.js';
import { R } from './index3-DONAw0dG.js';
import { A as kl, S as Pl } from './StaticAudio-DNyI0JWU.js';
import { e as ee } from './Upload2-BHtWS_cp.js';
import { z } from './ModifyUpload-Dqp1u9XX.js';
import './MarkdownCode.svelte_svelte_type_style_lang-DJRtJayx.js';
import { k } from './BlockLabel-DYKzuObf.js';
import { y } from './ShareButton-B1Vd_e6T.js';
import { t } from './Music-CFRjVwjy.js';
import { n } from './SelectSource-DRzd8ZLx.js';
import { v } from './IconButtonWrapper-DlgTGGi-.js';
import { o } from './StreamingBar-D7mIo11c.js';
import { G } from './Block-2-03Azgw.js';
import { k as k$1 } from './UploadText-vH2cVEO2.js';
export { default as BaseExample } from './Example10-aPUFDTHz.js';
import { e as escape_html } from './escaping-CBnpiEl5.js';
import './context-BZS6UlnY.js';
import './uneval-DjLoL4oF.js';
import './clone-BLo8hHdj.js';
import './index5-BoOEKc6P.js';
import './dev-fallback-Bc5Ork7Y.js';
import './spring-DyDQVd5U.js';
import './IconButton-7VBZdgpA.js';
import './Clear-CiR-WD8W.js';
import './DownloadLink-BLkRTIUs.js';
import './Empty-uaeWNu3s.js';
import './Download-rAXPPveZ.js';
import './MinimalAudioPlayer-YeOh_PMv.js';
import './VolumeLevels-ChNcuVO2.js';
import './Play-BVmRHWoH.js';
import './Undo-DlTKhhuO.js';
import './Edit-DVsun1ou.js';
import './prism-python-BaDPvmdn.js';
import './Upload-C6YVFLtW.js';
import './Microphone-_E2SOwNB.js';
import './Video-Cl-Q8BCK.js';
import './Webcam-D2mdKJI9.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$1=u.length;d<s$1;d++){let m=u[d];l.option({value:m.deviceId},w=>{w.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$1,editable:m=true,recording:w=false,onstartrecording:S,onpauserecording:e,onstoprecording:x,onstop:h,onplay:B,onpause:M,onedit:A}=_;let y=true,v;function D(p){p.push('<div class="component-wrapper svelte-j9q3sk"><div class="microphone svelte-j9q3sk" data-testid="microphone-waveform"></div> <div data-testid="recording-waveform"></div> '),p.push("<!--[!-->"),p.push("<!--]--> "),p.push("<!--[!-->"),p.push("<!--]--> "),p.push("<!--[!-->"),p.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$1=[];let m=true,w;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$1},set micDevices(x){s$1=x,m=false;}}),e.push("<!----></div></div>");}do m=true,w=l.copy(),S(w);while(!m);l.subsume(w);});}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$1=true,buttons:m=["download","share"],on_custom_button_click:w$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$1="microphone",handle_reset_value:D=()=>{},editable:p=true,max_file_size:C=null,upload:T,stream_handler:b,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:ps,onstart_recording:ns,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 Ss([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),ps?.(),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$1,Icon:t,float:v$1==="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$1==="microphone"?(t$1.push("<!--[-->"),z(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:p,recording:G,dispatch_blob:Q,waveform_settings:B,waveform_options:A,handle_reset_value:D,onstartrecording:()=>ns?.(),onpauserecording:()=>us?.(),onstoprecording:()=>J?.(),get mode(){return I},set mode(o){I=o,k$1=false;}})),t$1.push("<!--]-->")):(t$1.push("<!--[!-->"),v$1==="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:b,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("<!--[!-->"),z(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 w(P.url)}"></audio>`,value:i})):o.push("<!--[!-->"),o.push("<!--]-->")):(o.push("<!--[!-->"),v(o,{button:N,on_click:P=>{w$1&&w$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:p,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("<!--]--> "),n(t$1,{sources:S,handle_clear:F,get active_source(){return v$1},set active_source(o){v$1=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$1,uploading:a,recording:G,upload_promise:R,initial_value:W,playback_position:j});});}function ro(f,_){f.component(l=>{let{$$slots:i,$$events:r,...c}=_,u;c.props.stream_every=.1;class d extends g{async get_data(){return u&&(await u,await tick()),await super.get_data()}}const s$1=new d(c);let m=s$1.shared.label||s$1.i18n("audio.audio"),w=c.minimal??s$1.props.minimal??false,S=s$1.props.sources?s$1.props.sources[0]:null,e=s$1.props.value;const x=()=>{e===null||s$1.props.value===e||(s$1.props.value=e);};let h=false,B=s$1.props.recording??false,M="darkorange",A={height:50,barWidth:2,barGap:3,cursorWidth:2,cursorColor:"#ddd5e9",autoplay:s$1.props.autoplay,barRadius:10,dragToSeek:true,normalize:true,minPxPerSec:20,waveColor:s$1.props.waveform_options.waveform_color||"#9ca3af",progressColor:s$1.props.waveform_options.waveform_progress_color||M,mediaControls:s$1.props.waveform_options.show_controls??false,sampleRate:s$1.props.waveform_options.sample_rate||44100};const y={color:s$1.props.waveform_options.trim_region_color,drag:true,resize:true};function D(b){const[g,a]=b.includes("Invalid file type")?["warning","complete"]:["error","error"];s$1.shared.loading_status&&(s$1.shared.loading_status.status=a,s$1.shared.loading_status.message=b),s$1.dispatch(g,b);}s$1.props.value;let p=true,C;function T(b){s$1.shared.interactive?(b.push("<!--[!-->"),G(b,{variant:s$1.props.value===null&&S==="upload"?"dashed":"solid",border_mode:h?"focus":"base",padding:false,allow_overflow:false,elem_id:s$1.shared.elem_id,elem_classes:s$1.shared.elem_classes,visible:s$1.shared.visible,container:s$1.shared.container,scale:s$1.shared.scale,min_width:s$1.shared.min_width,children:g=>{R(g,spread_props([{autoscroll:s$1.shared.autoscroll,i18n:s$1.i18n},s$1.shared.loading_status,{on_clear_status:()=>s$1.dispatch("clear_status",s$1.shared.loading_status)}])),g.push("<!----> "),Us(g,{label:m,show_label:s$1.shared.show_label,buttons:s$1.props.buttons??[],on_custom_button_click:a=>{s$1.dispatch("custom_button_click",{id:a});},value:s$1.props.value,subtitles:s$1.props.subtitles,onchange:a=>s$1.props.value=a,onstream:a=>{s$1.props.value=a,s$1.dispatch("stream",s$1.props.value);},ondrag:a=>h=a,root:s$1.shared.root,sources:s$1.props.sources,active_source:S||void 0,pending:s$1.shared.loading_status.pending,streaming:s$1.props.streaming,loop:s$1.props.loop,max_file_size:s$1.shared.max_file_size,handle_reset_value:x,editable:s$1.props.editable,onedit:()=>s$1.dispatch("edit"),onplay:()=>s$1.dispatch("play"),onpause:()=>s$1.dispatch("pause"),onstop:()=>s$1.dispatch("stop"),onstart_recording:()=>s$1.dispatch("start_recording"),onpause_recording:()=>s$1.dispatch("pause_recording"),onstop_recording:()=>{s$1.dispatch("stop_recording"),s$1.dispatch("input");},onupload:()=>{s$1.dispatch("upload"),s$1.dispatch("input");},onclear:()=>{s$1.dispatch("clear"),s$1.dispatch("input");},onerror:D,onclose_stream:()=>s$1.dispatch("close_stream","stream"),i18n:s$1.i18n,waveform_settings:A,waveform_options:s$1.props.waveform_options,trim_region_settings:y,stream_every:s$1.props.stream_every,stream_state:s$1.shared.loading_status.stream_state,upload:(...a)=>s$1.shared.client.upload(...a),stream_handler:(...a)=>s$1.shared.client.stream(...a),time_limit:s$1.shared.loading_status.time_limit,get upload_promise(){return u},set upload_promise(a){u=a,p=false;},get initial_value(){return e},set initial_value(a){e=a,p=false;},get recording(){return B},set recording(a){B=a,p=false;},get dragging(){return h},set dragging(a){h=a,p=false;},get playback_position(){return s$1.props.playback_position},set playback_position(a){s$1.props.playback_position=a,p=false;},children:a=>{k$1(a,{i18n:s$1.i18n,type:"audio"});},$$slots:{default:true}}),g.push("<!---->");},$$slots:{default:true}})):(b.push("<!--[-->"),G(b,{variant:"solid",border_mode:h?"focus":"base",padding:false,allow_overflow:false,elem_id:s$1.shared.elem_id,elem_classes:s$1.shared.elem_classes,visible:s$1.shared.visible,container:s$1.shared.container,scale:s$1.shared.scale,min_width:s$1.shared.min_width,children:g=>{R(g,spread_props([{autoscroll:s$1.shared.autoscroll,i18n:s$1.i18n},s$1.shared.loading_status,{on_clear_status:()=>s$1.dispatch("clear_status",s$1.shared.loading_status)}])),g.push("<!----> "),Pl(g,{i18n:s$1.i18n,show_label:s$1.shared.show_label,buttons:s$1.props.buttons??["download","share"],value:s$1.props.value,subtitles:s$1.props.subtitles,label:m,loop:s$1.props.loop,waveform_settings:A,waveform_options:s$1.props.waveform_options,editable:s$1.props.editable,minimal:w,on_custom_button_click:a=>{s$1.dispatch("custom_button_click",{id:a});},onshare:a=>s$1.dispatch("share",a),onerror:a=>s$1.dispatch("error",a.detail),onplay:()=>s$1.dispatch("play"),onpause:()=>s$1.dispatch("pause"),onstop:()=>s$1.dispatch("stop"),get playback_position(){return s$1.props.playback_position},set playback_position(a){s$1.props.playback_position=a,p=false;}}),g.push("<!---->");},$$slots:{default:true}})),b.push("<!--]-->");}do p=true,C=l.copy(),T(C);while(!p);l.subsume(C);});}

export { Us as BaseInteractiveAudio, kl as BasePlayer, Pl as BaseStaticAudio, ro as default };
//# sourceMappingURL=index56-CttVoYqQ.js.map
