import { f as fallback } from './async-DWBXLqlH.js';
import { s as store_get, d as attr_class, g as attr_style, i as slot, a as attr, j as stringify, u as unsubscribe_stores, c as bind_props, e as ensure_array_like } from './index-D1re1cuM.js';
import { t as tick } from './index-server-D4bj_1UO.js';
import { s as ss, i as is, l as ls, u as us, h as hs } from './2-BbOIMXxe.js';
export { _ as changeLocale, b as get_initial_locale, d as is_translation_metadata, m as language_choices, K as load_translations, a as mount_css, c as prefix_css, Q as process_langs, g as setupi18n } from './2-BbOIMXxe.js';
import { u } from './index6-vb2nI4_V.js';
import { g } from './utils.svelte-BHoyPsmo.js';
export { d as i18n_marker } from './utils.svelte-BHoyPsmo.js';
import { e as escape_html } from './escaping-CBnpiEl5.js';
import './context-BZS6UlnY.js';
import './uneval-ZBzcyJ66.js';
import './clone-CubQhOZi.js';
import './index5-BoOEKc6P.js';
import './dev-fallback-Bc5Ork7Y.js';

const O="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='10'%20height='10'%20fill='none'%3e%3cpath%20fill='%23FF3270'%20d='M1.93%206.03v2.04h2.04V6.03H1.93Z'/%3e%3cpath%20fill='%23861FFF'%20d='M6.03%206.03v2.04h2.04V6.03H6.03Z'/%3e%3cpath%20fill='%23097EFF'%20d='M1.93%201.93v2.04h2.04V1.93H1.93Z'/%3e%3cpath%20fill='%23000'%20fill-rule='evenodd'%20d='M.5%201.4c0-.5.4-.9.9-.9h3.1a.9.9%200%200%201%20.87.67A2.44%202.44%200%200%201%209.5%202.95c0%20.65-.25%201.24-.67%201.68.39.1.67.46.67.88v3.08c0%20.5-.4.91-.9.91H1.4a.9.9%200%200%201-.9-.9V1.4Zm1.43.53v2.04h2.04V1.93H1.93Zm0%206.14V6.03h2.04v2.04H1.93Zm4.1%200V6.03h2.04v2.04H6.03Zm0-5.12a1.02%201.02%200%201%201%202.04%200%201.02%201.02%200%200%201-2.04%200Z'%20clip-rule='evenodd'/%3e%3cpath%20fill='%23FFD702'%20d='M7.05%201.93a1.02%201.02%200%201%200%200%202.04%201.02%201.02%200%200%200%200-2.04Z'/%3e%3c/svg%3e";function ot(e,t){e.component(s$1=>{var i;let r,a,n=t.wrapper,o=t.version,p=t.initial_height,c=t.fill_width,_=t.is_embed,g=t.space,b=t.display,S=t.info,z=t.loaded,Z=fallback(t.pages,()=>[],true),R=fallback(t.current_page,""),D=t.root,I=fallback(t.components,()=>[],true),E=I.find(f=>f.type==="navbar"),u=E?{visible:E.props.visible,main_page_name:E.props.main_page_name,value:E.props.value}:null;u&&ss.set(u);function L(f){let d=f.split("?")[0].split("#")[0];return d=d.replace(/^\/+|\/+$/g,""),d}function T(f,d){return f.startsWith("http://")||f.startsWith("https://")?false:L(f)===L(d)}if(store_get(i??={},"$navbar_config",ss)&&(u={visible:store_get(i??={},"$navbar_config",ss).visible??true,main_page_name:store_get(i??={},"$navbar_config",ss).main_page_name??"Home",value:store_get(i??={},"$navbar_config",ss).value??null}),r=Z.length>1&&(u===null||u.visible!==false),a=(()=>{let f=Z.filter(([v,h,m],y)=>y===0&&v===""?u?.main_page_name!==false:m!==false),d=u&&u.main_page_name!==false&&u.main_page_name!=="Home"?f.map(([v,h,m],y)=>y===0&&v===""&&h==="Home"?[v,u.main_page_name]:[v,h]):f.map(([v,h])=>[v,h]);if(u?.value&&u.value.length>0){const v=new Set(d.map(([m])=>m)),h=u.value.map(([m,y])=>[y,m]).filter(([m])=>!v.has(m));return [...d,...h]}return d})(),s$1.push(`<div${attr_class(`gradio-container gradio-container-${stringify(o)}`,"svelte-99kmwu",{fill_width:c,"embed-container":b,"with-info":S})} data-iframe-height=""${attr_style("",{"min-height":z?"initial":p,"flex-grow":b?"auto":"1"})}>`),r){s$1.push("<!--[-->"),s$1.push(`<div class="nav-holder svelte-99kmwu"><nav${attr_class("fillable svelte-99kmwu",void 0,{fill_width:c})}><!--[-->`);const f=ensure_array_like(a);for(let d=0,v=f.length;d<v;d++){let[h,m]=f[d];s$1.push(`<a${attr("href",h.startsWith("http://")||h.startsWith("https://")?h:`${D}/${h}`)} data-sveltekit-reload=""${attr("target",h.startsWith("http://")||h.startsWith("https://")?"_blank":"_self")}${attr("rel",h.startsWith("http://")||h.startsWith("https://")?"noopener noreferrer":"")}${attr_class("svelte-99kmwu",void 0,{active:T(h,R)})}>${escape_html(m)}</a>`);}s$1.push("<!--]--></nav></div>");}else s$1.push("<!--[!-->");s$1.push(`<!--]--> <div${attr_class("main fillable svelte-99kmwu",void 0,{fill_width:c,app:!b&&!_})}><!--[-->`),slot(s$1,t,"default",{},null),s$1.push("<!--]--> <div>"),b&&g&&S?(s$1.push("<!--[-->"),s$1.push(`<div class="info svelte-99kmwu"><span class="svelte-99kmwu"><a${attr("href",`https://huggingface.co/spaces/${stringify(g)}`)} class="title svelte-99kmwu">${escape_html(g)}</a></span> <span class="svelte-99kmwu">${escape_html(store_get(i??={},"$_",is)("common.built_with"))} <a class="gradio svelte-99kmwu" href="https://gradio.app">Gradio</a>.</span> <span class="svelte-99kmwu">${escape_html(store_get(i??={},"$_",is)("common.hosted_on"))} <a class="hf svelte-99kmwu" href="https://huggingface.co/spaces"><span class="space-logo svelte-99kmwu"><img${attr("src",O)} alt="Hugging Face Space" class="svelte-99kmwu"/></span> Spaces</a></span></div>`)):s$1.push("<!--[!-->"),s$1.push("<!--]--></div></div></div>"),i&&unsubscribe_stores(i),bind_props(t,{wrapper:n,version:o,initial_height:p,fill_width:c,is_embed:_,space:g,display:b,info:S,loaded:z,pages:Z,current_page:R,root:D,components:I});});}const Q={walkthrough:"tabs",walkthroughstep:"tabitem"};class lt{#n;#e;#s;reactive_formatter=t=>t;#t;client;root;root_untracked;#o=new Set;#l=new Set;#h=[];#p=new Map;#i=new Map;#r=new Map;#c;component_ids;initial_tabs={};components_to_register=new Set;ready;ready_resolve;resolved=false;#a=new Set;constructor(t,s,i,r,a,n,o){this.ready=new Promise(c=>{this.ready_resolve=c;}),this.reactive_formatter=n,this.#t={...r,api_url:new URL(r.api_prefix,r.root).toString()},this.#n=t,this.#e=s,this.#s=i,this.root=this.create_node({id:s.id,children:[]},new Map,true);for(const c of t)c.props.visible!=false&&this.components_to_register.add(c.id);this.client=a,this.prepare();const p=t.reduce((c,_)=>(c.set(_.id,_),c),new Map);this.root.children=this.#e.children.map(c=>this.traverse(c,_=>this.create_node(_,p,false,this.reactive_formatter))),this.component_ids=t.map(c=>c.id),this.initial_tabs={},x(this.root,this.initial_tabs),this.postprocess(this.root),this.#c=o,this.root_untracked=this.root;}reload(t,s,i,r){this.#e=s,this.#n=t,this.#t={...r,api_url:new URL(r.api_prefix,r.root).toString()},this.#s=i,this.root=this.create_node({id:s.id,children:[]},new Map,true);for(const n of t)n.props.visible!=false&&this.components_to_register.add(n.id);this.prepare();const a=t.reduce((n,o)=>(n.set(o.id,o),n),new Map);this.root.children=this.#e.children.map(n=>this.traverse(n,o=>this.create_node(o,a,false,this.reactive_formatter))),this.component_ids=t.map(n=>n.id),this.initial_tabs={},x(this.root,this.initial_tabs),this.postprocess(this.root);}register_component(t,s,i){this.#i.set(t,s),this.#p.set(t,i),this.components_to_register.delete(t);const r=this.#r.get(t);r&&(this.#r.delete(t),tick().then(()=>{const a=this.#i.get(t);a&&a(r);})),this.components_to_register.size===0&&!this.resolved&&(this.resolved=true,this.ready_resolve());}prepare(){const[t,s]=ls(this.#s);this.#o=t,this.#l=s;}process(){}postprocess(t){this.root=this.traverse(t,[s=>V(s,this.#t.api_url),s=>tt(s,this.components_to_register),s=>U(s,this.initial_tabs),s=>this.find_attached_events(s,this.#s),s=>et(s,this.components_to_register,this.#a)]);}find_attached_events(t,s){const i=s.filter(r=>r.targets.find(([a])=>a===t.id)).map(r=>{const a=r.targets.find(([n])=>n===t.id);return a?a[1]:null}).filter(Boolean);return t.props.shared_props.attached_events=i,t}traverse(t,s){function i(r,a,n){const o=a(r);return "children"in r&&r.children.length>0&&(o.children=r.children?.map(p=>n(p,a))||[]),o}if(Array.isArray(s)){let r=t;for(const a of s)r=i(r,a,this.traverse.bind(this));return r}else return i(t,s,this.traverse.bind(this))}create_node(t,s,i=false,r){let a;if(i?a={type:"column",id:t.id,props:{visible:true,root:"",theme_mode:"light"},component_class_id:"column",key:null}:a=s.get(t.id),!a)throw new Error(`Component with ID ${t.id} not found`);r&&(a.props.i18n=r);const n=Y(t.id,a.props,[this.#o,this.#l],this.client,this.#t.api_url,{...this.#t}),o=Q[a.type]||a.type;return {id:t.id,type:o,props:n,children:[],show_progress_on:null,component_class_id:a.component_class_id||a.type,component:n.shared_props.visible!==false?us(a.type,a.component_class_id,this.#t.api_url||""):null,key:a.key,rendered_in:a.rendered_in,documentation:a.documentation,original_visibility:n.shared_props.visible}}rerender(t,s){const i=t.reduce((o,p)=>(o.set(p.id,p),o),new Map),r=this.traverse(s,o=>this.create_node(o,i,false,this.reactive_formatter));x(r,this.initial_tabs);const a=this.traverse(r,o=>U(o,this.initial_tabs)),n=k(this.root,a.id);if(!n)throw new Error("Rerender failed: root node not found in current tree");n.children=a.children;}async update_visibility(t,s){t.children.forEach(i=>{const r=this.#i.get(i.id);r&&r(s),this.update_visibility(i,s);});}async update_state(t,s,i=true){const r=k(this.root,t);let a=false;i&&!r?.component&&(await tick(),this.root=this.traverse(this.root,[o=>$(o,t,s.visible),o=>V(o,this.#t.api_url)]),await tick(),a=true);const n=this.#i.get(t);if(n)n&&n(s);else {const o=r?.props.props.value,p=C(s);for(const _ in p.shared_props)r.props.shared_props[_]=p.shared_props[_];for(const _ in p.props)r.props.props[_]=p.props[_];const c=this.#r.get(t)||{};this.#r.set(t,{...c,...s}),"value"in s&&!u(o,s.value)&&this.#c(t,"change",null);}!i||a||(await tick(),await this.update_visibility(r,s));}async get_state(t){const s=this.#p.get(t),i=k(this.root,t);return !s&&!i?null:s?await s():i?Promise.resolve({value:i.props.props.value}):null}async render_previously_invisible_children(t){const s=k(this.root,t);s&&(!this.#a.has(s.id)&&!q(s,this.#a)||(W(s,this.#a,true),B(s,this.#t.api_url)));}}function W(e,t,s=false){if(e.props.shared_props.visible=t.has(e.id)?true:e.props.shared_props.visible,e.type==="tabs"){const i=e.props.props.selected??e.props.props.initial_tabs?.[0]?.id;e.children.forEach(r=>{r.type==="tabitem"&&(r.props.props.id===i||r.id===i)&&W(r,t,false);});}else e.type==="accordion"&&e.props.props.open===false&&!s||e.children.forEach(i=>{W(i,t,false);});}function q(e,t){for(const s of e.children)if(t.has(s.id)||q(s,t))return  true;return  false}function B(e,t){e.props.shared_props.visible&&!e.component&&(e.component=us(e.type,e.component_class_id,t)),e.children.forEach(s=>B(s,t));}function X(e,t,s){return t?t.reduce((i,r)=>(i[r]=async(...a)=>(a.length===1&&(a=a[0]),await s.component_server(e,r,a)),i),{}):{}}function C(e){const t={},s={};for(const i in e)if(i==="id"||i==="autoscroll")s[i]=e[i];else if(g.includes(i)){const r=i;t[r]=e[i];}else s[i]=e[i];return {shared_props:t,props:s}}function Y(e,t,s,i,r,a={}){const{shared_props:n,props:o}=C(t);n.server=X(e,t.server_fns,i);for(const p in a)if(g.includes(p)){const c=p;n[c]=a[p];}else o[p]=a[p];return n.client=i,n.id=e,n.interactive=hs(e,n.interactive,o.value,s),n.load_component=(p,c)=>us(p,"",r,c),n.visible=n.visible===void 0?true:n.visible,n.loading_status={},{shared_props:n,props:o}}function V(e,t){if(e.props.shared_props.visible&&!e.component){const s={...e,component:us(e.type,e.component_class_id,t),children:[]};return e.children&&(s.children=e.children.map(i=>V(i,t))),s}else return e}function $(e,t,s){return e.id==t&&(e.props.shared_props.visible=s),e}function H(e,t){t.delete(e.id),e.children&&e.children.forEach(s=>H(s,t));}function tt(e,t){return e.props.shared_props.visible!==true&&H(e,t),e}function A(e,t){return e.props.shared_props.visible===true&&(t.add(e.id),e.props.shared_props.visible=false),e.children.forEach(s=>{A(s,t);}),e}function et(e,t,s){return e.type==="accordion"&&e.props.props.open===false&&(H(e,t),e.children&&e.children.forEach(i=>{A(i,s);})),e.type==="tabs"&&e.children.forEach(i=>{i.type==="tabitem"&&i.props.props.id!==(e.props.props.selected||e.props.props.initial_tabs[0].id)&&(H(i,t),A(i,s));}),e}function U(e,t){if(e.type==="tabs"&&e.id in t){const s=t[e.id].sort((i,r)=>i.order-r.order);e.props.props.initial_tabs=s;}else e.type==="tabitem"&&(e.props.props.component_id=e.id);return e}function G(e,t,s,i){if(s!==null&&e.type==="tabitem"){s in t||(t[s]=[]),"id"in e.props.props||(e.props.props.id=e.id);const r=e.props.props.i18n,a=e.props.shared_props.label;t[s].push({label:r?r(a):a,id:e.props.props.id,elem_id:e.props.shared_props.elem_id,visible:e.props.shared_props.visible,interactive:e.props.shared_props.interactive,scale:e.props.shared_props.scale||null,component_id:e.id}),e.props.props.order=i;}e.children&&e.children.forEach((r,a)=>{G(r,t,e.type==="tabs"?e.id:null,e.type==="tabs"?a:null);});}function x(e,t){function s(i){"children"in i&&i.children.length>0&&i.children?.forEach(r=>G(r,t,i.type==="tabs"?i.id:null,null));}return s(e)}function k(e,t){if(e.id===t)return e;if(e.children)for(const s of e.children){const i=k(s,t);if(i)return i}return null}

export { lt as AppTree, ot as Embed };
//# sourceMappingURL=index-Cty_a_1G.js.map
