import { f as fallback } from './async-Djx13DAD.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-B7gr0Dsc.js';
import { t as tick } from './index-server-lqjMX237.js';
import { l as ls, m as mr, d as ds, p as ps, y as ys, b as ms } from './2-CeYbpaU1.js';
export { Q as all_common_keys, v as changeLocale, x as get_initial_locale, M as i18n_marker, e as is_translation_metadata, w as language_choices, K as load_translations, h as mount_css, f as prefix_css, J as process_langs, E as setupi18n } from './2-CeYbpaU1.js';
import { u } from './index6-vb2nI4_V.js';
import { f } from './utils.svelte-D8Xdzglu.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';

const Q="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 ct(t,e){t.component(s$1=>{var i;let r,a,n=e.wrapper,l=e.version,p=e.initial_height,c=e.fill_width,m=e.is_embed,b=e.space,g=e.display,F=e.info,A=e.loaded,S=fallback(e.pages,()=>[],true),j=fallback(e.current_page,""),z=e.root,R=fallback(e.components,()=>[],true),k=R.find(u=>u.type==="navbar"),_=k?{visible:k.props.visible,main_page_name:k.props.main_page_name,value:k.props.value}:null;_&&ls.set(_);function D(u){let f=u.split("?")[0].split("#")[0];return f=f.replace(/^\/+|\/+$/g,""),f}function T(u,f){return u.startsWith("http://")||u.startsWith("https://")?false:D(u)===D(f)}if(store_get(i??={},"$navbar_config",ls)&&(_={visible:store_get(i??={},"$navbar_config",ls).visible??true,main_page_name:store_get(i??={},"$navbar_config",ls).main_page_name??"Home",value:store_get(i??={},"$navbar_config",ls).value??null}),r=S.length>1&&(_===null||_.visible!==false),a=(()=>{let u=S.filter(([d,h,v],y)=>y===0&&d===""?_?.main_page_name!==false:v!==false),f=_&&_.main_page_name!==false&&_.main_page_name!=="Home"?u.map(([d,h,v],y)=>y===0&&d===""&&h==="Home"?[d,_.main_page_name]:[d,h]):u.map(([d,h])=>[d,h]);if(_?.value&&_.value.length>0){const d=new Set(f.map(([v])=>v)),h=_.value.map(([v,y])=>[y,v]).filter(([v])=>!d.has(v));return [...f,...h]}return f})(),s$1.push(`<div${attr_class(`gradio-container gradio-container-${stringify(l)}`,"svelte-99kmwu",{fill_width:c,"embed-container":g,"with-info":F})} data-iframe-height=""${attr_style("",{"min-height":A?"initial":p,"flex-grow":g?"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 u=ensure_array_like(a);for(let f=0,d=u.length;f<d;f++){let[h,v]=u[f];s$1.push(`<a${attr("href",h.startsWith("http://")||h.startsWith("https://")?h:`${z}/${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,j)})}>${escape_html(v)}</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:!g&&!m})}><!--[-->`),slot(s$1,e,"default",{},null),s$1.push("<!--]--> <div>"),g&&b&&F?(s$1.push("<!--[-->"),s$1.push(`<div class="info svelte-99kmwu"><span class="svelte-99kmwu"><a${attr("href",`https://huggingface.co/spaces/${stringify(b)}`)} class="title svelte-99kmwu">${escape_html(b)}</a></span> <span class="svelte-99kmwu">${escape_html(store_get(i??={},"$_",mr)("common.built_with"))} <a class="gradio svelte-99kmwu" href="https://gradio.app">Gradio</a>.</span> <span class="svelte-99kmwu">${escape_html(store_get(i??={},"$_",mr)("common.hosted_on"))} <a class="hf svelte-99kmwu" href="https://huggingface.co/spaces"><span class="space-logo svelte-99kmwu"><img${attr("src",Q)} 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(e,{wrapper:n,version:l,initial_height:p,fill_width:c,is_embed:m,space:b,display:g,info:F,loaded:A,pages:S,current_page:j,root:z,components:R});});}const X={walkthrough:"tabs",walkthroughstep:"tabitem"};class ht{#r;#e;#s;reactive_formatter=e=>e;#t;client;root;root_untracked;#a=new Set;#n=new Set;#c=[];#o=new Map;#i=new Map;#l;component_ids;initial_tabs={};components_to_register=new Set;ready;ready_resolve;resolved=false;#p=new Set;constructor(e,s,i,r,a,n,l){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.#r=e,this.#e=s,this.#s=i,this.root=this.create_node({id:s.id,children:[]},new Map,true);for(const c of e)c.props.visible!=false&&this.components_to_register.add(c.id);this.client=a,this.prepare();const p=e.reduce((c,m)=>(c.set(m.id,m),c),new Map);this.root.children=this.#e.children.map(c=>this.traverse(c,m=>this.create_node(m,p,false,this.reactive_formatter))),this.component_ids=e.map(c=>c.id),this.initial_tabs={},W(this.root,this.initial_tabs),this.postprocess(this.root),this.#l=l,this.root_untracked=this.root;}reload(e,s,i,r){this.#e=s,this.#r=e,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 e)n.props.visible!=false&&this.components_to_register.add(n.id);this.prepare();const a=e.reduce((n,l)=>(n.set(l.id,l),n),new Map);this.root.children=this.#e.children.map(n=>this.traverse(n,l=>this.create_node(l,a,false,this.reactive_formatter))),this.component_ids=e.map(n=>n.id),this.initial_tabs={},W(this.root,this.initial_tabs),this.postprocess(this.root);}register_component(e,s,i){this.#i.set(e,s),this.#o.set(e,i),this.components_to_register.delete(e),this.components_to_register.size===0&&!this.resolved&&(this.resolved=true,this.ready_resolve());}prepare(){const[e,s]=ds(this.#s);this.#a=e,this.#n=s;}process(){}postprocess(e){this.root=this.traverse(e,[s=>E(s,this.#t.api_url),s=>et(s,this.components_to_register),s=>it(s,this.components_to_register),s=>rt(s),s=>U(s,this.initial_tabs),s=>this.find_attached_events(s,this.#s),s=>st(s,this.components_to_register,this.#p)]);}find_attached_events(e,s){const i=s.filter(r=>r.targets.find(([a])=>a===e.id)).map(r=>{const a=r.targets.find(([n])=>n===e.id);return a?a[1]:null}).filter(Boolean);return e.props.shared_props.attached_events=i,e}traverse(e,s){function i(r,a,n){const l=a(r);return "children"in r&&r.children.length>0&&(l.children=r.children?.map(p=>n(p,a))||[]),l}if(Array.isArray(s)){let r=e;for(const a of s)r=i(r,a,this.traverse.bind(this));return r}else return i(e,s,this.traverse.bind(this))}create_node(e,s,i=false,r){let a;if(i?a={type:"column",id:e.id,props:{visible:true,root:"",theme_mode:"light"},component_class_id:"column",key:null}:a=s.get(e.id),!a)throw new Error(`Component with ID ${e.id} not found`);r&&(a.props.i18n=r);const n=$(e.id,a.props,[this.#a,this.#n],this.client,this.#t.api_url,{...this.#t}),l=X[a.type]||a.type;return {id:e.id,type:l,props:n,children:[],show_progress_on:null,component_class_id:a.component_class_id||a.type,component:n.shared_props.visible!==false?ps(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(e,s){const i=e.reduce((l,p)=>(l.set(p.id,p),l),new Map),r=this.traverse(s,l=>this.create_node(l,i,false,this.reactive_formatter));W(r,this.initial_tabs);const a=this.traverse(r,l=>U(l,this.initial_tabs)),n=M(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(e,s){e.children.forEach(i=>{const r=this.#i.get(i.id);r&&r(s),this.update_visibility(i,s);});}async update_state(e,s,i=true){const r=M(this.root,e);let a=false;i&&!r?.component&&(await tick(),this.root=this.traverse(this.root,[p=>tt(p,e,s.visible),p=>P(p,e,s.visible),p=>E(p,this.#t.api_url)]),await tick(),a=true);const n=this.#i.get(e);if(n)n&&n(s);else {const p=r?.props.props.value,c=C(s);r.props.shared_props={...r?.props.shared_props,...c.shared_props},r.props.props={...r?.props.props,...c.props},"value"in s&&!u(p,s.value)&&this.#l(e,"change",null);}if(!i||a)return;await tick(),await this.update_visibility(r,s);const l=I(this.root,e);l&&P(l,e,s.visible);}async get_state(e){const s=this.#o.get(e),i=M(this.root,e);return !s&&!i?null:s?await s():i?Promise.resolve({value:i.props.props.value}):null}async render_previously_invisible_children(e){this.root=this.traverse(this.root,[s=>(s.id===e&&B(s,this.#p),s),s=>E(s,this.#t.api_url)]);}}function B(t,e){t.props.shared_props.visible=e.has(t.id)?true:t.props.shared_props.visible,t.children.forEach(s=>{B(s,e);});}function Y(t,e,s){return e?e.reduce((i,r)=>(i[r]=async(...a)=>(a.length===1&&(a=a[0]),await s.component_server(t,r,a)),i),{}):{}}function C(t){const e={},s={};for(const i in t)if(i==="id"||i==="autoscroll")s[i]=t[i];else if(f.includes(i)){const r=i;e[r]=t[i];}else s[i]=t[i];return {shared_props:e,props:s}}function $(t,e,s,i,r,a={}){const{shared_props:n,props:l}=C(e);n.server=Y(t,e.server_fns,i);for(const p in a)if(f.includes(p)){const c=p;n[c]=a[p];}else l[p]=a[p];return n.client=i,n.id=t,n.interactive=ms(t,n.interactive,l.value,s),n.load_component=(p,c)=>ps(p,"",r,c),n.visible=n.visible===void 0?true:n.visible,n.loading_status={},{shared_props:n,props:l}}function E(t,e){if(t.props.shared_props.visible&&!t.component){const s={...t,component:ps(t.type,t.component_class_id,e),children:[]};return t.children&&(s.children=t.children.map(i=>E(i,e))),s}else return t}function tt(t,e,s){return t.id==e&&(t.props.shared_props.visible=s),t}function H(t,e){e.delete(t.id),t.children&&t.children.forEach(s=>H(s,e));}function et(t,e){return t.props.shared_props.visible!==true&&H(t,e),t}function x(t,e){return t.props.shared_props.visible===true&&(e.add(t.id),t.props.shared_props.visible=false),t.children.forEach(s=>{x(s,e);}),t}function st(t,e,s){return t.type==="accordion"&&t.props.props.open===false&&(H(t,e),t.children&&t.children.forEach(i=>{x(i,s);})),t.type==="tabs"&&t.children.forEach(i=>{i.type==="tabitem"&&i.props.props.id!==(t.props.props.selected||t.props.props.initial_tabs[0].id)&&(H(i,e),x(i,s));}),t}function it(t,e){return t.type==="form"&&t.children.every(i=>i.props.shared_props.visible===false)&&(t.props.shared_props.visible=false,e.delete(t.id)),t}function P(t,e,s){return t.type==="form"&&t.children.length&&t.children.some(i=>i.id===e)&&(s===true?t.props.shared_props.visible=true:!s&&t.children.length===1&&(t.props.shared_props.visible="hidden")),t}function rt(t){const e=["description","info","title","placeholder","value","label"];for(const s of Object.keys(t.props.shared_props))e.includes(s)&&(t.props.shared_props[s]=ys(t.props.shared_props[s]));for(const s of Object.keys(t.props.props))e.includes(s)&&(t.props.props[s]=ys(t.props.props[s]));return t}function U(t,e){if(t.type==="tabs"&&t.id in e){const s=e[t.id].sort((i,r)=>i.order-r.order);t.props.props.initial_tabs=s;}else t.type==="tabitem"&&(t.props.props.component_id=t.id);return t}function G(t,e,s,i){s!==null&&t.type==="tabitem"&&(s in e||(e[s]=[]),"id"in t.props.props||(t.props.props.id=t.id),e[s].push({label:t.props.shared_props.label,id:t.props.props.id,elem_id:t.props.shared_props.elem_id,visible:t.props.shared_props.visible,interactive:t.props.shared_props.interactive,scale:t.props.shared_props.scale||null,component_id:t.id}),t.props.props.order=i),t.children&&t.children.forEach((r,a)=>{G(r,e,t.type==="tabs"?t.id:null,t.type==="tabs"?a:null);});}function W(t,e){function s(i){"children"in i&&i.children.length>0&&i.children?.forEach(r=>G(r,e,i.type==="tabs"?i.id:null,null));}return s(t)}function M(t,e){if(t.id===e)return t;if(t.children)for(const s of t.children){const i=M(s,e);if(i)return i}return null}function I(t,e){if(t.children)for(const s of t.children){if(s.id===e)return t;const i=I(s,e);if(i)return i}return null}

export { ht as AppTree, ct as Embed, ys as translate_if_needed };
//# sourceMappingURL=index-DclgKfz7.js.map
