import { f as fallback } from './async-Djx13DAD.js';
import { c as bind_props, d as attr_class, g as attr_style, b as spread_props, i as slot } from './index-B7gr0Dsc.js';
import { t as tick } from './index-server-lqjMX237.js';
import './2-CeYbpaU1.js';
import { g } from './utils.svelte-D8Xdzglu.js';
import Q$1 from './ImagePreview-C_D-UOrN.js';
import './MarkdownCode.svelte_svelte_type_style_lang-DJRtJayx.js';
import { k } from './BlockLabel-DYKzuObf.js';
import { w } from './IconButton-7VBZdgpA.js';
import { o } from './Clear-CiR-WD8W.js';
import { i } from './Image2-CJoaEJF4.js';
import { n } from './SelectSource-DRzd8ZLx.js';
import { y } from './IconButtonWrapper-DlgTGGi-.js';
import { v } from './FullscreenButton-DPSRpBkM.js';
import { $ } from './Webcam2-Co_MYLbs.js';
import { e as ee, Q } from './Upload2-BHtWS_cp.js';
import { c } from './Image-Bw5_tidM.js';
import { G } from './Block-2-03Azgw.js';
import { p } from './Empty-uaeWNu3s.js';
import { k as k$1 } from './UploadText-vH2cVEO2.js';
import { R } from './index3-DONAw0dG.js';
export { default as BaseExample } from './Example6-CrA7b0Zv.js';
import './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 './DownloadLink-BLkRTIUs.js';
import './ShareButton-B1Vd_e6T.js';
import './Download-rAXPPveZ.js';
import './prism-python-BaDPvmdn.js';
import './Maximize-DxOGYNPn.js';
import './Upload-C6YVFLtW.js';
import './Microphone-_E2SOwNB.js';
import './Video-Cl-Q8BCK.js';
import './Webcam-D2mdKJI9.js';
import './StreamingBar-D7mIo11c.js';
import './spring-DyDQVd5U.js';

function ua(S,e){S.component(b=>{let v$1,u=fallback(e.value,null),I=fallback(e.label,void 0),z=e.show_label,h=fallback(e.sources,()=>["upload","clipboard","webcam"],true),c$1=fallback(e.streaming,false),a=fallback(e.pending,false),p=e.webcam_options,_=fallback(e.selectable,false),m=e.root,w$1=e.i18n,n$1=fallback(e.max_file_size,null),f=e.upload,k$1=e.stream_handler,r=e.stream_every,i$1=e.time_limit,l=fallback(e.show_fullscreen_button,true),x=fallback(e.stream_state,"closed"),C=fallback(e.upload_promise,null),P=fallback(e.onerror,void 0),j,y$1=fallback(e.uploading,false),d=fallback(e.active_source,null),W=fallback(e.fullscreen,false),q=[],A;async function H(s){if(!c$1){if(s.path?.toLowerCase().endsWith(".svg")&&s.url){const N=await(await fetch(s.url)).text();u={...s,url:`data:image/svg+xml,${encodeURIComponent(N)}`};}else u=s;await tick();}}function G(){u=null;}function J(s){G(),s.stopPropagation();}let U=fallback(e.dragging,false);async function K(s){s==="clipboard"&&j.paste_clipboard();}!d&&h&&(d=h[0]),v$1=c$1&&d==="webcam",y$1&&!v$1&&(u=null);let g=true,E;function M(s$1){k(s$1,{show_label:z,Icon:i,label:I||"Image"}),s$1.push('<!----> <div data-testid="image" class="image-container svelte-6uxbr3">'),y(s$1,{children:t=>{u?.url&&!v$1?(t.push("<!--[-->"),l?(t.push("<!--[-->"),v(t,{fullscreen:W})):t.push("<!--[!-->"),t.push("<!--]--> "),w(t,{Icon:o,label:"Remove Image",onclick:J}),t.push("<!---->")):t.push("<!--[!-->"),t.push("<!--]-->");}}),s$1.push(`<!----> <div${attr_class("upload-container svelte-6uxbr3",void 0,{"reduced-height":h.length>1})}${attr_style("",{width:u?"auto":"100%"})}>`),ee(s$1,{hidden:u!==null||d==="webcam",filetype:d==="clipboard"?"clipboard":"image/*",onload:H,onerror:P,root:m,max_file_size:n$1,disable_click:!h.includes("upload")||u!==null,upload:f,stream_handler:k$1,aria_label:w$1("image.drop_to_upload"),get upload_promise(){return C},set upload_promise(t){C=t,g=false;},get uploading(){return y$1},set uploading(t){y$1=t,g=false;},get dragging(){return U},set dragging(t){U=t,g=false;},children:t=>{u===null?(t.push("<!--[-->"),t.push("<!--[-->"),slot(t,e,"default",{},null),t.push("<!--]-->")):t.push("<!--[!-->"),t.push("<!--]-->");},$$slots:{default:true}}),s$1.push("<!----> "),d==="webcam"&&!c$1&&a?(s$1.push("<!--[-->"),Q(s$1,{root:m,upload_id:A,stream_handler:k$1,files:q})):(s$1.push("<!--[!-->"),d==="webcam"&&(c$1||!c$1&&!u)?(s$1.push("<!--[-->"),$(s$1,{root:m,value:u,stream_state:x,mirror_webcam:p.mirror,stream_every:r,streaming:c$1,mode:"image",include_audio:false,i18n:w$1,upload:f,time_limit:i$1,webcam_constraints:p.constraints})):(s$1.push("<!--[!-->"),u!==null&&!c$1?(s$1.push("<!--[-->"),s$1.push(`<div${attr_class("image-frame svelte-6uxbr3",void 0,{selectable:_})}>`),c(s$1,{src:u.url,restProps:{alt:u.alt_text}}),s$1.push("<!----></div>")):s$1.push("<!--[!-->"),s$1.push("<!--]-->")),s$1.push("<!--]-->")),s$1.push("<!--]--></div> "),h.length>1||h.includes("clipboard")?(s$1.push("<!--[-->"),n(s$1,{sources:h,handle_clear:G,handle_select:K,get active_source(){return d},set active_source(t){d=t,g=false;}})):s$1.push("<!--[!-->"),s$1.push("<!--]--></div>");}do g=true,E=b.copy(),M(E);while(!g);b.subsume(E),bind_props(e,{value:u,label:I,show_label:z,sources:h,streaming:c$1,pending:a,webcam_options:p,selectable:_,root:m,i18n:w$1,max_file_size:n$1,upload:f,stream_handler:k$1,stream_every:r,time_limit:i$1,show_fullscreen_button:l,stream_state:x,upload_promise:C,onerror:P,uploading:y$1,active_source:d,fullscreen:W,dragging:U});});}function Ga(S,e){S.component(b=>{let v={value:null},u;class I extends g{async get_data(){u&&(await u,await tick());const i=await super.get_data();return c.props.streaming&&(i.value=v.value),i}}const{$$slots:z,$$events:h,...c}=e,a=new I(c);let p$1=false,_=false,m=a.props.sources?a.props.sources[0]:null;a.props.value;let w=a?.shared?.loading_status.stream_state,n=true,f;function k(r){a.shared.interactive?(r.push("<!--[!-->"),G(r,{visible:a.shared.visible,variant:a.props.value===null?"dashed":"solid",border_mode:_?"focus":"base",padding:false,elem_id:a.shared.elem_id,elem_classes:a.shared.elem_classes,height:a.props.height||void 0,width:a.props.width,allow_overflow:false,container:a.shared.container,scale:a.shared.scale,min_width:a.shared.min_width,get fullscreen(){return p$1},set fullscreen(i){p$1=i,n=false;},children:i$1=>{a.shared.loading_status.type==="output"?(i$1.push("<!--[-->"),R(i$1,spread_props([{autoscroll:a.shared.autoscroll,i18n:a.i18n},a.shared.loading_status,{on_clear_status:()=>a.dispatch("clear_status",a.shared.loading_status)}]))):i$1.push("<!--[!-->"),i$1.push("<!--]--> "),ua(i$1,{selectable:a.props._selectable,root:a.shared.root,sources:a.props.sources,fullscreen:p$1,show_fullscreen_button:a.props.buttons===null?true:a.props.buttons.some(l=>typeof l=="string"&&l==="fullscreen"),onerror:l=>{a.shared.loading_status.status="error",a.dispatch("error",l);},label:a.shared.label,show_label:a.shared.show_label,pending:a.shared.loading_status?.status==="pending"||a.shared.loading_status?.status==="streaming",streaming:a.props.streaming,webcam_options:a.props.webcam_options,stream_every:a.props.stream_every,time_limit:a.shared.loading_status?.time_limit,max_file_size:a.shared.max_file_size,i18n:a.i18n,upload:(...l)=>a.shared.client.upload(...l),stream_handler:a.shared.client?.stream,stream_state:w,get upload_promise(){return u},set upload_promise(l){u=l,n=false;},get active_source(){return m},set active_source(l){m=l,n=false;},get value(){return a.props.value},set value(l){a.props.value=l,n=false;},get dragging(){return _},set dragging(l){_=l,n=false;},children:l=>{m==="upload"||!m?(l.push("<!--[-->"),k$1(l,{i18n:a.i18n,type:"image",placeholder:a.props.placeholder})):(l.push("<!--[!-->"),m==="clipboard"?(l.push("<!--[-->"),k$1(l,{i18n:a.i18n,type:"clipboard",mode:"short"})):(l.push("<!--[!-->"),p(l,{unpadded_box:true,size:"large",children:x=>{i(x);},$$slots:{default:true}})),l.push("<!--]-->")),l.push("<!--]-->");},$$slots:{default:true}}),i$1.push("<!---->");},$$slots:{default:true}})):(r.push("<!--[-->"),G(r,{visible:a.shared.visible,variant:"solid",border_mode:_?"focus":"base",padding:false,elem_id:a.shared.elem_id,elem_classes:a.shared.elem_classes,height:a.props.height||void 0,width:a.props.width,allow_overflow:false,container:a.shared.container,"scale{gradio.shared.scale}":true,min_width:a.shared.min_width,get fullscreen(){return p$1},set fullscreen(i){p$1=i,n=false;},children:i=>{R(i,spread_props([{autoscroll:a.shared.autoscroll,i18n:a.i18n},a.shared.loading_status,{on_clear_status:()=>a.dispatch("clear_status",a.shared.loading_status)}])),i.push("<!----> "),Q$1(i,{fullscreen:p$1,value:a.props.value,label:a.shared.label,show_label:a.shared.show_label,selectable:a.props._selectable,i18n:a.i18n,buttons:a.props.buttons,on_custom_button_click:l=>{a.dispatch("custom_button_click",{id:l});}}),i.push("<!---->");},$$slots:{default:true}})),r.push("<!--]-->");}do n=true,f=b.copy(),k(f);while(!n);b.subsume(f);});}

export { c as BaseImage, ua as BaseImageUploader, Q$1 as BaseStaticImage, $ as Webcam, Ga as default };
//# sourceMappingURL=Index29-mSlexPCc.js.map
