import { s as snapshot } from './clone-BLo8hHdj.js';
import './async-Djx13DAD.js';
import { g as getContext } from './context-BZS6UlnY.js';

const l="GRADIO_ROOT";class d extends Error{constructor(t){super(t),this.name="ShareError";}}async function w(s,t){if(window.__gradio_space__==null)throw new d("Must be on Spaces to share.");let e,r,n;{let i;if(typeof s=="object"&&s.url)i=s.url;else if(typeof s=="string")i=s;else throw new Error("Invalid data format for URL type");const p=await fetch(i);e=await p.blob(),r=p.headers.get("content-type")||"",n=p.headers.get("content-disposition")||"";}const o=new File([e],n,{type:r}),a=await fetch("https://huggingface.co/uploads",{method:"POST",body:o,headers:{"Content-Type":o.type,"X-Requested-With":"XMLHttpRequest"}});if(!a.ok){if(a.headers.get("content-type")?.includes("application/json")){const i=await a.json();throw new d(`Upload failed: ${i.error}`)}throw new d("Upload failed.")}return await a.text()}const y=s=>{const t=Math.floor(s/3600),e=Math.floor(s%3600/60),r=Math.round(s)%60,n=`${e<10?"0":""}${e}`,o=`${r<10?"0":""}${r}`;return t>0?`${t}:${n}:${o}`:`${e}:${o}`},_=typeof window<"u",f=["elem_id","elem_classes","visible","interactive","server_fns","server","id","target","theme_mode","version","root","autoscroll","max_file_size","formatter","client","load_component","scale","min_width","theme","padding","loading_status","label","show_label","validation_error","show_progress","api_prefix","container","attached_events"];class g{load_component;shared={};props={};i18n={};dispatcher;last_update=null;shared_props=f;constructor(t,e){for(const o in t.shared_props)this.shared[o]=t.shared_props[o];for(const o in t.props)this.props[o]=t.props[o];if(e)for(const o in e)this.props[o]===void 0&&(this.props[o]=e[o]);if(this.i18n=this.props.i18n,this.load_component=this.shared.load_component,!_||t.props?.__GRADIO_BROWSER_TEST__){this.dispatcher=()=>{};return}const{register:r,dispatcher:n}=getContext(l);r(t.shared_props.id,this.set_data.bind(this),this.get_data.bind(this)),this.dispatcher=n;}dispatch(t,e){this.dispatcher(this.shared.id,t,e);}async get_data(){return snapshot(this.props)}update(t){this.set_data(t);}set_data(t){for(const e in t)if(this.shared_props.includes(e)){const r=e;this.shared[r]=t[r];continue}else this.props[e]=t[e];}}const b=s=>typeof s=="number"?s+"px":s;

export { b, d, f, g, l, w, y };
//# sourceMappingURL=utils.svelte-D8Xdzglu.js.map
