import './async-Djx13DAD.js';
import { c as bind_props, d as attr_class, a as attr, e as ensure_array_like, g as attr_style, b as spread_props } from './index-B7gr0Dsc.js';
import './2-CeYbpaU1.js';
import { g, y } from './utils.svelte-D8Xdzglu.js';
import { o as onDestroy, t as tick } from './index-server-lqjMX237.js';
import { c } from './BlockTitle-CMSrY_fB.js';
import './MarkdownCode.svelte_svelte_type_style_lang-DJRtJayx.js';
import { e as e$1 } from './Check-THd8EJll.js';
import { o } from './Clear-CiR-WD8W.js';
import { i } from './File-CWWp_-I1.js';
import { i as i$1 } from './Microphone-_E2SOwNB.js';
import { t } from './Music-CFRjVwjy.js';
import { s } from './Square-DrWSae15.js';
import { r } from './Video-Cl-Q8BCK.js';
import { u } from './ScrollFade-BSTTZOwu.js';
import { e as ee } from './Upload2-BHtWS_cp.js';
import { c as c$1 } from './Image-Bw5_tidM.js';
import { Z } from './MinimalAudioPlayer-YeOh_PMv.js';
import { G } from './Block-2-03Azgw.js';
import { R } from './index3-DONAw0dG.js';
export { default as BaseExample } from './Example23-hRijCfS3.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 './Info-D8EmJbKn.js';
import './MarkdownCode-zMHESTz4.js';
import './index35-D6cyUa2I.js';
import 'path';
import 'url';
import 'fs';
import './prism-python-BaDPvmdn.js';
import './spring-DyDQVd5U.js';
import './IconButton-7VBZdgpA.js';
import './Video2-pxW-QOKm.js';

function e(o){o.push('<svg width="100%" height="100%" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="19" x2="12" y2="5"></line><polyline points="5 12 12 5 19 12"></polyline></svg>');}

function K(f){f.push('<svg fill="currentColor" width="100%" height="100%" viewBox="0 0 1920 1920" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"><path d="M1752.768 221.109C1532.646.986 1174.283.986 954.161 221.109l-838.588 838.588c-154.052 154.165-154.052 404.894 0 558.946 149.534 149.421 409.976 149.308 559.059 0l758.738-758.626c87.982-88.094 87.982-231.417 0-319.51-88.32-88.208-231.642-87.982-319.51 0l-638.796 638.908 79.85 79.849 638.795-638.908c43.934-43.821 115.539-43.934 159.812 0 43.934 44.047 43.934 115.877 0 159.812l-758.739 758.625c-110.23 110.118-289.355 110.005-399.36 0-110.118-110.117-110.005-289.242 0-399.247l838.588-838.588c175.963-175.962 462.382-176.188 638.909 0 176.075 176.188 176.075 462.833 0 638.908l-798.607 798.72 79.849 79.85 798.607-798.72c220.01-220.123 220.01-578.485 0-798.607" fill-rule="evenodd"></path></g></svg>');}function kt(f,v){f.component(a=>{let {label:l,waveform_settings:G={},recording:I=void 0,upload:W,root:P,max_file_size:s$1=null,upload_promise:m=void 0,onchange:M,onstoprecording:b,onclear:g}=v,r=0,_;onDestroy(()=>{clearInterval(_);}),a.push(`<div class="minimal-audio-recorder svelte-doy9oc"${attr("aria-label",l||"Audio Recorder")} data-testid="minimal-audio-recorder">`),(a.push("<!--[!-->"),a.push(`<div class="waveform-wrapper svelte-doy9oc"></div> <div class="timestamp svelte-doy9oc">${escape_html(y(r))}</div> <button class="stop-button svelte-doy9oc" aria-label="Stop recording">`),s(a,{}),a.push("<!----></button>")),a.push("<!--]--></div>"),bind_props(v,{recording:I,upload_promise:m});});}function St(f,v){f.component(a=>{let{value:l=void 0,value_is_output:G=false,lines:I=1,i18n:W,placeholder:P="",disabled:s$1=false,label:m,info:M=void 0,show_label:b=true,max_lines:g,submit_btn:r$1=null,stop_btn:_=null,rtl:c$2=false,autofocus:A=false,text_align:w=void 0,autoscroll:R=true,root:d,file_types_string:e$2=null,max_file_size:h=null,upload:q,stream_handler:p,file_count:n="multiple",max_plain_text_length:i$2=1e3,waveform_settings:Q,waveform_options:Mt={show_recording_waveform:true},sources_string:X="upload",active_source:F=void 0,html_attributes:x=null,upload_promise:z=void 0,dragging:U=void 0,onchange:H,onsubmit:At,onstop:Rt,onblur:zt,onselect:Bt,oninput:Y,onfocus:Gt,ondrag:It,onupload:Z$1,onclear:$,onload:Pt,onerror:tt,onstop_recording:st}=v,ot=false,C=false;l?.text;let T=false,B=null,k=X.split(",").map(t=>t.trim()).filter(t=>t==="upload"||t==="microphone"),lt=e$2?e$2.split(",").map(t=>t.trim()):null,j=k&&k.includes("upload")&&!(n==="single"&&l?.files?.length>0);async function at(){H?.(l),G||Y?.();}async function it(t){if(at(),Array.isArray(t)){for(let V of t)l.files.push(V);l=l;}else l.files.push(t),l=l;await tick(),H?.(l),Z$1?.(t);}let S=true,E;function et(t$1){if(t$1.push(`<div${attr_class("full-container svelte-1qn0337",void 0,{dragging:U})} role="group" aria-label="Multimedia input field">`),c(t$1,{show_label:b,info:M,rtl:c$2,children:u=>{u.push(`<!---->${escape_html(m)}`);},$$slots:{default:true}}),t$1.push('<!----> <div class="input-container svelte-1qn0337">'),k&&k.includes("microphone")&&F==="microphone"?(t$1.push("<!--[-->"),t$1.push(`<div${attr_class("recording-overlay svelte-1qn0337",void 0,{"has-audio":B!==null})}>`),B?(t$1.push("<!--[!-->"),t$1.push('<div class="recording-content svelte-1qn0337">'),Z(t$1,{value:B,label:m||"Audio",loop:false}),t$1.push('<!----> <div class="action-buttons svelte-1qn0337"><button class="confirm-button svelte-1qn0337" aria-label="Attach audio">'),e$1(t$1),t$1.push('<!----></button> <button class="cancel-button svelte-1qn0337" aria-label="Clear audio">'),o(t$1),t$1.push("<!----></button></div></div>")):(t$1.push("<!--[-->"),t$1.push('<div class="recording-content svelte-1qn0337">'),kt(t$1,{label:m||"Audio",waveform_settings:Q,recording:T,upload:q,root:d,max_file_size:h,onchange:u=>{B=u;},onstoprecording:()=>{T=false,st?.();},onclear:()=>{F=null,T=false,B=null,$?.();},get upload_promise(){return z},set upload_promise(u){z=u,S=false;}}),t$1.push("<!----></div>")),t$1.push("<!--]--></div>")):t$1.push("<!--[!-->"),t$1.push("<!--]--> "),j?(t$1.push("<!--[-->"),ee(t$1,{onload:it,file_count:n,filetype:lt,root:d,max_file_size:h,show_progress:false,disable_click:true,onerror:tt,hidden:true,upload:q,stream_handler:p,get upload_promise(){return z},set upload_promise(u){z=u,S=false;},get dragging(){return U},set dragging(u){U=u,S=false;},get uploading(){return C},set uploading(u){C=u,S=false;}})):t$1.push("<!--[!-->"),t$1.push(`<!--]--> <div${attr_class("input-wrapper svelte-1qn0337",void 0,{"has-files":(l?.files?.length??0)>0||C})}>`),(l?.files?.length??0)>0||C){t$1.push("<!--[-->"),t$1.push('<div class="thumbnails svelte-1qn0337" aria-label="Uploaded files" data-testid="container_el">'),j?(t$1.push("<!--[-->"),t$1.push(`<button data-testid="upload-button" class="upload-button thumbnail-add svelte-1qn0337"${attr("disabled",s$1,true)} aria-label="Upload a file">`),K(t$1),t$1.push("<!----></button>")):t$1.push("<!--[!-->"),t$1.push("<!--]--> <!--[-->");const u=ensure_array_like(l?.files??[]);for(let D=0,ut=u.length;D<ut;D++){let y=u[D];t$1.push('<span class="thumbnail-wrapper svelte-1qn0337" role="listitem" aria-label="File thumbnail"><div class="thumbnail-item thumbnail-small svelte-1qn0337">'),y.mime_type&&y.mime_type.includes("image")?(t$1.push("<!--[-->"),c$1(t$1,{src:y.url,restProps:{title:null,alt:"",loading:"lazy",class:"thumbnail-image"}})):(t$1.push("<!--[!-->"),y.mime_type&&y.mime_type.includes("audio")?(t$1.push("<!--[-->"),t(t$1)):(t$1.push("<!--[!-->"),y.mime_type&&y.mime_type.includes("video")?(t$1.push("<!--[-->"),r(t$1)):(t$1.push("<!--[!-->"),i(t$1)),t$1.push("<!--]-->")),t$1.push("<!--]-->")),t$1.push('<!--]--> <button class="delete-button svelte-1qn0337" aria-label="Remove file">'),o(t$1),t$1.push("<!----></button></div></span>");}t$1.push("<!--]--> "),C?(t$1.push("<!--[-->"),t$1.push('<div class="loader svelte-1qn0337" role="status" aria-label="Uploading"></div>')):t$1.push("<!--[!-->"),t$1.push("<!--]--></div>");}else t$1.push("<!--[!-->");t$1.push('<!--]--> <div class="input-row svelte-1qn0337">'),j&&(l?.files?.length??0)===0&&!C?(t$1.push("<!--[-->"),t$1.push(`<button data-testid="upload-button" class="upload-button icon-button svelte-1qn0337"${attr("disabled",s$1,true)} aria-label="Upload a file">`),K(t$1),t$1.push("<!----></button>")):t$1.push("<!--[!-->"),t$1.push(`<!--]--> <div class="textarea-wrapper svelte-1qn0337"><textarea data-testid="textbox"${attr("dir",c$2?"rtl":"ltr")}${attr("placeholder",P)}${attr("rows",I)}${attr("disabled",s$1,true)}${attr_style(w?"text-align: "+w:"")}${attr("autocapitalize",x?.autocapitalize)}${attr("autocorrect",x?.autocorrect)}${attr("spellcheck",x?.spellcheck)}${attr("autocomplete",x?.autocomplete)}${attr("tabindex",x?.tabindex)}${attr("enterkeyhint",x?.enterkeyhint)}${attr("lang",x?.lang)}${attr_class("svelte-1qn0337",void 0,{"no-label":!b})}>`);const V=escape_html(l.text);V&&t$1.push(`${V}`),t$1.push("</textarea> "),u(t$1,{visible:ot,position:"absolute"}),t$1.push("<!----></div> "),k&&k.includes("microphone")?(t$1.push("<!--[-->"),t$1.push(`<button data-testid="microphone-button"${attr_class("microphone-button svelte-1qn0337",void 0,{recording:T})}${attr("disabled",s$1,true)} aria-label="Record audio">`),i$1(t$1),t$1.push("<!----></button>")):t$1.push("<!--[!-->"),t$1.push("<!--]--> "),r$1?(t$1.push("<!--[-->"),t$1.push(`<button${attr_class("submit-button svelte-1qn0337",void 0,{"padded-button":r$1!==true})} data-testid="submit-button"${attr("disabled",s$1,true)} aria-label="Submit">`),r$1===true?(t$1.push("<!--[-->"),e(t$1)):(t$1.push("<!--[!-->"),t$1.push(`${escape_html(r$1)}`)),t$1.push("<!--]--></button>")):t$1.push("<!--[!-->"),t$1.push("<!--]--> "),_?(t$1.push("<!--[-->"),t$1.push(`<button${attr_class("stop-button svelte-1qn0337",void 0,{"padded-button":_!==true})} aria-label="Stop">`),_===true?(t$1.push("<!--[-->"),s(t$1,{fill:"none",stroke_width:2.5})):(t$1.push("<!--[!-->"),t$1.push(`${escape_html(_)}`)),t$1.push("<!--]--></button>")):t$1.push("<!--[!-->"),t$1.push("<!--]--></div></div></div></div>");}do S=true,E=a.copy(),et(E);while(!S);a.subsume(E),bind_props(v,{value:l,active_source:F,upload_promise:z,dragging:U});});}function ps(f,v){f.component(a=>{let l=null;let G$1 = class G extends g{async get_data(){return l&&(await l,await tick()),await super.get_data()}};let{$$slots:I,$$events:W,...P}=v;const s$1=new G$1(P);s$1.props.value=s$1.props.value??{text:"",files:[]};let m=false,M=null;const g$1={height:50,barWidth:2,barGap:3,cursorWidth:2,cursorColor:"#ddd5e9",autoplay:false,barRadius:10,dragToSeek:true,normalize:true,minPxPerSec:20,waveColor:"",progressColor:"",mediaControls:false,sampleRate:44100};({color:s$1.props?.waveform_options?.trim_region_color});const c=(...p)=>s$1.shared.client.upload(...p),A=p=>s$1.i18n(p),w=(...p)=>s$1.shared.client.stream(...p);let R$1=s$1.props.sources.join(","),d=(s$1.props.file_types||[]).join(",")||null,e=true,h;function q(p){G(p,{visible:s$1.shared.visible,elem_id:s$1.shared.elem_id,elem_classes:[...s$1.shared.elem_classes||[],"multimodal-textbox"],scale:s$1.shared.scale,min_width:s$1.shared.min_width,allow_overflow:false,padding:false,border_mode:m?"focus":"base",rtl:s$1.props.rtl,children:n=>{s$1.shared.loading_status?(n.push("<!--[-->"),R(n,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)}]))):n.push("<!--[!-->"),n.push("<!--]--> "),St(n,{value_is_output:true,file_types_string:d,root:s$1.shared.root,label:s$1.shared.label||"MultimodalTextbox",info:s$1.props.info,show_label:s$1.shared.show_label,lines:s$1.props.lines,rtl:s$1.props.rtl,text_align:s$1.props.text_align,waveform_settings:g$1,i18n:A,max_lines:s$1.props.max_lines?s$1.props.max_lines:s$1.props.lines+1,placeholder:s$1.props.placeholder,submit_btn:s$1.props.submit_btn,stop_btn:s$1.props.stop_btn,autofocus:s$1.props.autofocus,autoscroll:s$1.shared.autoscroll,file_count:s$1.props.file_count,sources_string:R$1,max_file_size:s$1.shared.max_file_size,onchange:i=>{s$1.props.value=i,s$1.dispatch("change",s$1.props.value);},oninput:()=>s$1.dispatch("input"),onsubmit:()=>s$1.dispatch("submit"),onstop:()=>s$1.dispatch("stop"),onblur:()=>s$1.dispatch("blur"),onselect:i=>s$1.dispatch("select",i),onfocus:()=>s$1.dispatch("focus"),onerror:i=>{s$1.dispatch("error",i);},onstop_recording:()=>s$1.dispatch("stop_recording"),onupload:i=>s$1.dispatch("upload",i),onclear:()=>s$1.dispatch("clear"),disabled:!s$1.shared.interactive,upload:c,stream_handler:w,max_plain_text_length:s$1.props.max_plain_text_length,html_attributes:s$1.props.html_attributes,get upload_promise(){return l},set upload_promise(i){l=i,e=false;},get value(){return s$1.props.value},set value(i){s$1.props.value=i,e=false;},get dragging(){return m},set dragging(i){m=i,e=false;},get active_source(){return M},set active_source(i){M=i,e=false;}}),n.push("<!---->");},$$slots:{default:true}});}do e=true,h=a.copy(),q(h);while(!e);a.subsume(h);});}

export { St as BaseMultimodalTextbox, ps as default };
//# sourceMappingURL=Index51-BzlluZQA.js.map
