import { f as fallback } from './async-D55cHugf.js';
import { d as bind_props, f as attr_class, g as attr_style, c as spread_props, s as slot } from './index-u8mz_F03.js';
import { t as tick } from './index-server-CQz6EZl_.js';
import './2-BLdXJizP.js';
import { $ } from './utils.svelte-B2py64Fz.js';
import Q$1 from './ImagePreview-Ca2hvNZZ.js';
import { k } from './BlockLabel-bKYWnOzQ.js';
import { w } from './IconButton-BRnu7KaR.js';
import { o } from './Clear-D7Yjckqz.js';
import { i } from './Image2-vcp9_ifi.js';
import { w as w$1 } from './SelectSource-Bhpgvmj9.js';
import { y } from './IconButtonWrapper-CjFRPb3y.js';
import { k as k$1 } from './FullscreenButton-D8PvgSmk.js';
import { Z } from './Webcam2-CNM_PDwT.js';
import { e as ee, Q } from './Upload2-uTutz1dY.js';
import { c } from './Image-CuPo5pWT.js';
import { G } from './Block-DZmzQwnI.js';
import { p } from './Empty-DGRbZO0a.js';
import { k as k$2 } from './UploadText-BDXc1cBO.js';
import { W } from './index3-Df92vI-L.js';
export { default as BaseExample } from './Example6-cJA6M13Z.js';
import './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 './DownloadLink-nj1p0krE.js';
import './ShareButton-7VTs9dOO.js';
import './Download-DcU5dONL.js';
import './Maximize-CuHbK64j.js';
import './Upload-BbxeBrrD.js';
import './Microphone-BMM9-23W.js';
import './Video-FfbWmOVG.js';
import './Webcam-CvKMKUzA.js';
import './StreamingBar-BGU65w2M.js';

function ua(S,e){S.component(b=>{let v,u=fallback(e.value,null),I=fallback(e.label,void 0),z=e.show_label,r=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),d=e.root,w$2=e.i18n,n=fallback(e.max_file_size,null),f=e.upload,k$2=e.stream_handler,h=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),m=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();}!m&&r&&(m=r[0]),v=c$1&&m==="webcam",y$1&&!v&&(u=null);let g=true,E;function M(s){k(s,{show_label:z,Icon:i,label:I||"Image"}),s.push('<!----> <div data-testid="image" class="image-container svelte-6uxbr3">'),y(s,{children:t=>{u?.url&&!v?(t.push("<!--[-->"),l?(t.push("<!--[-->"),k$1(t,{fullscreen:W})):t.push("<!--[!-->"),t.push("<!--]--> "),w(t,{Icon:o,label:"Remove Image",onclick:J}),t.push("<!---->")):t.push("<!--[!-->"),t.push("<!--]-->");}}),s.push(`<!----> <div${attr_class("upload-container svelte-6uxbr3",void 0,{"reduced-height":r.length>1})}${attr_style("",{width:u?"auto":"100%"})}>`),ee(s,{hidden:u!==null||m==="webcam",filetype:m==="clipboard"?"clipboard":"image/*",onload:H,onerror:P,root:d,max_file_size:n,disable_click:!r.includes("upload")||u!==null,upload:f,stream_handler:k$2,aria_label:w$2("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",{}),t.push("<!--]-->")):t.push("<!--[!-->"),t.push("<!--]-->");},$$slots:{default:true}}),s.push("<!----> "),m==="webcam"&&!c$1&&a?(s.push("<!--[-->"),Q(s,{root:d,upload_id:A,stream_handler:k$2,files:q})):(s.push("<!--[!-->"),m==="webcam"&&(c$1||!c$1&&!u)?(s.push("<!--[-->"),Z(s,{root:d,value:u,stream_state:x,mirror_webcam:p.mirror,stream_every:h,streaming:c$1,mode:"image",include_audio:false,i18n:w$2,upload:f,time_limit:i$1,webcam_constraints:p.constraints})):(s.push("<!--[!-->"),u!==null&&!c$1?(s.push("<!--[-->"),s.push(`<div${attr_class("image-frame svelte-6uxbr3",void 0,{selectable:_})}>`),c(s,{src:u.url,restProps:{alt:u.alt_text}}),s.push("<!----></div>")):s.push("<!--[!-->"),s.push("<!--]-->")),s.push("<!--]-->")),s.push("<!--]--></div> "),r.length>1||r.includes("clipboard")?(s.push("<!--[-->"),w$1(s,{sources:r,handle_clear:G,handle_select:K,get active_source(){return m},set active_source(t){m=t,g=false;}})):s.push("<!--[!-->"),s.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:r,streaming:c$1,pending:a,webcam_options:p,selectable:_,root:d,i18n:w$2,max_file_size:n,upload:f,stream_handler:k$2,stream_every:h,time_limit:i$1,show_fullscreen_button:l,stream_state:x,upload_promise:C,onerror:P,uploading:y$1,active_source:m,fullscreen:W,dragging:U});});}function Wa(S,e){S.component(b=>{let v={value:null},u;class I extends ${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:r,...c}=e,a=new I(c);let p$1=false,_=false,d=a.props.sources?a.props.sources[0]:null;a.props.value;let w=a?.shared?.loading_status.stream_state,n=true,f;function k(h){a.shared.interactive?(h.push("<!--[!-->"),G(h,{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"||a.shared.loading_status.validation_error?(i$1.push("<!--[-->"),W(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 d},set active_source(l){d=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=>{d==="upload"||!d?(l.push("<!--[-->"),k$2(l,{i18n:a.i18n,type:"image",placeholder:a.props.placeholder})):(l.push("<!--[!-->"),d==="clipboard"?(l.push("<!--[-->"),k$2(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}})):(h.push("<!--[-->"),G(h,{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=>{W(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}})),h.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, Z as Webcam, Wa as default };
//# sourceMappingURL=Index26-DaAQhbOM.js.map
