const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["_astro/MarkdownRenderer.D6rEEnku.js","_astro/codemirror.TQBH0qoE.js","_astro/markdown.CybDVaw9.js","_astro/index.Cdq9u7kK.js","_astro/MarkdownRenderer.CRMLQbfA.css"])))=>i.map(i=>d[i]); import{r as p,j as g,R as st,a as Bc,g as df}from"./codemirror.TQBH0qoE.js";import{r as ff}from"./index.Cdq9u7kK.js";var xr=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},nn=typeof window>"u"||"Deno"in globalThis;function Fe(){}function hf(e,t){return typeof e=="function"?e(t):e}function lo(e){return typeof e=="number"&&e>=0&&e!==1/0}function Kc(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Ft(e,t){return typeof e=="function"?e(t):e}function He(e,t){return typeof e=="function"?e(t):e}function ra(e,t){const{type:n="all",exact:r,fetchStatus:s,predicate:o,queryKey:i,stale:a}=e;if(i){if(r){if(t.queryHash!==ai(i,t.options))return!1}else if(!or(t.queryKey,i))return!1}if(n!=="all"){const c=t.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof a=="boolean"&&t.isStale()!==a||s&&s!==t.state.fetchStatus||o&&!o(t))}function sa(e,t){const{exact:n,status:r,predicate:s,mutationKey:o}=e;if(o){if(!t.options.mutationKey)return!1;if(n){if(sr(t.options.mutationKey)!==sr(o))return!1}else if(!or(t.options.mutationKey,o))return!1}return!(r&&t.state.status!==r||s&&!s(t))}function ai(e,t){return(t?.queryKeyHashFn||sr)(e)}function sr(e){return JSON.stringify(e,(t,n)=>fo(n)?Object.keys(n).sort().reduce((r,s)=>(r[s]=n[s],r),{}):n)}function or(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>or(e[n],t[n])):!1}function zc(e,t){if(e===t)return e;const n=oa(e)&&oa(t);if(n||fo(e)&&fo(t)){const r=n?e:Object.keys(e),s=r.length,o=n?t:Object.keys(t),i=o.length,a=n?[]:{},c=new Set(r);let l=0;for(let u=0;u{setTimeout(t,e)})}function ho(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?zc(e,t):t}function mf(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function gf(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var ci=Symbol();function Vc(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===ci?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function yf(e,t){return typeof e=="function"?e(...t):!!e}var vf=class extends xr{#t;#e;#n;constructor(){super(),this.#n=e=>{if(!nn&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#e||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(e){this.#n=e,this.#e?.(),this.#e=e(t=>{typeof t=="boolean"?this.setFocused(t):this.onFocus()})}setFocused(e){this.#t!==e&&(this.#t=e,this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#t=="boolean"?this.#t:globalThis.document?.visibilityState!=="hidden"}},li=new vf,bf=class extends xr{#t=!0;#e;#n;constructor(){super(),this.#n=e=>{if(!nn&&window.addEventListener){const t=()=>e(!0),n=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",n)}}}}onSubscribe(){this.#e||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(e){this.#n=e,this.#e?.(),this.#e=e(this.setOnline.bind(this))}setOnline(e){this.#t!==e&&(this.#t=e,this.listeners.forEach(n=>{n(e)}))}isOnline(){return this.#t}},rs=new bf;function po(){let e,t;const n=new Promise((s,o)=>{e=s,t=o});n.status="pending",n.catch(()=>{});function r(s){Object.assign(n,s),delete n.resolve,delete n.reject}return n.resolve=s=>{r({status:"fulfilled",value:s}),e(s)},n.reject=s=>{r({status:"rejected",reason:s}),t(s)},n}function wf(e){return Math.min(1e3*2**e,3e4)}function Uc(e){return(e??"online")==="online"?rs.isOnline():!0}var qc=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function Wc(e){let t=!1,n=0,r;const s=po(),o=()=>s.status!=="pending",i=h=>{o()||(f(new qc(h)),e.abort?.())},a=()=>{t=!0},c=()=>{t=!1},l=()=>li.isFocused()&&(e.networkMode==="always"||rs.isOnline())&&e.canRun(),u=()=>Uc(e.networkMode)&&e.canRun(),d=h=>{o()||(r?.(),s.resolve(h))},f=h=>{o()||(r?.(),s.reject(h))},m=()=>new Promise(h=>{r=v=>{(o()||l())&&h(v)},e.onPause?.()}).then(()=>{r=void 0,o()||e.onContinue?.()}),y=()=>{if(o())return;let h;const v=n===0?e.initialPromise:void 0;try{h=v??e.fn()}catch(b){h=Promise.reject(b)}Promise.resolve(h).then(d).catch(b=>{if(o())return;const w=e.retry??(nn?0:3),x=e.retryDelay??wf,_=typeof x=="function"?x(n,b):x,C=w===!0||typeof w=="number"&&nl()?void 0:m()).then(()=>{t?f(b):y()})})};return{promise:s,status:()=>s.status,cancel:i,continue:()=>(r?.(),s),cancelRetry:a,continueRetry:c,canStart:u,start:()=>(u()?y():m().then(y),s)}}var xf=e=>setTimeout(e,0);function _f(){let e=[],t=0,n=a=>{a()},r=a=>{a()},s=xf;const o=a=>{t?e.push(a):s(()=>{n(a)})},i=()=>{const a=e;e=[],a.length&&s(()=>{r(()=>{a.forEach(c=>{n(c)})})})};return{batch:a=>{let c;t++;try{c=a()}finally{t--,t||i()}return c},batchCalls:a=>(...c)=>{o(()=>{a(...c)})},schedule:o,setNotifyFunction:a=>{n=a},setBatchNotifyFunction:a=>{r=a},setScheduler:a=>{s=a}}}var Me=_f(),Hc=class{#t;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),lo(this.gcTime)&&(this.#t=setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(nn?1/0:300*1e3))}clearGcTimeout(){this.#t&&(clearTimeout(this.#t),this.#t=void 0)}},Cf=class extends Hc{#t;#e;#n;#r;#s;#a;#i;constructor(e){super(),this.#i=!1,this.#a=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#r=e.client,this.#n=this.#r.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=kf(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#s?.promise}setOptions(e){this.options={...this.#a,...e},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(e,t){const n=ho(this.state.data,e,this.options);return this.#o({data:n,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e,t){this.#o({type:"setState",state:e,setStateOptions:t})}cancel(e){const t=this.#s?.promise;return this.#s?.cancel(e),t?t.then(Fe).catch(Fe):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#t)}isActive(){return this.observers.some(e=>He(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===ci||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>Ft(e.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e==="static"?!1:this.state.isInvalidated?!0:!Kc(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(t=>t.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#s?.continue()}onOnline(){this.observers.find(t=>t.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#s?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#s&&(this.#i?this.#s.cancel({revert:!0}):this.#s.cancelRetry()),this.scheduleGc()),this.#n.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#o({type:"invalidate"})}async fetch(e,t){if(this.state.fetchStatus!=="idle"&&this.#s?.status()!=="rejected"){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#s)return this.#s.continueRetry(),this.#s.promise}if(e&&this.setOptions(e),!this.options.queryFn){const a=this.observers.find(c=>c.options.queryFn);a&&this.setOptions(a.options)}const n=new AbortController,r=a=>{Object.defineProperty(a,"signal",{enumerable:!0,get:()=>(this.#i=!0,n.signal)})},s=()=>{const a=Vc(this.options,t),l=(()=>{const u={client:this.#r,queryKey:this.queryKey,meta:this.meta};return r(u),u})();return this.#i=!1,this.options.persister?this.options.persister(a,l,this):a(l)},i=(()=>{const a={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#r,state:this.state,fetchFn:s};return r(a),a})();this.options.behavior?.onFetch(i,this),this.#e=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==i.fetchOptions?.meta)&&this.#o({type:"fetch",meta:i.fetchOptions?.meta}),this.#s=Wc({initialPromise:t?.initialPromise,fn:i.fetchFn,abort:n.abort.bind(n),onFail:(a,c)=>{this.#o({type:"failed",failureCount:a,error:c})},onPause:()=>{this.#o({type:"pause"})},onContinue:()=>{this.#o({type:"continue"})},retry:i.options.retry,retryDelay:i.options.retryDelay,networkMode:i.options.networkMode,canRun:()=>!0});try{const a=await this.#s.start();if(a===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(a),this.#n.config.onSuccess?.(a,this),this.#n.config.onSettled?.(a,this.state.error,this),a}catch(a){if(a instanceof qc){if(a.silent)return this.#s.promise;if(a.revert)return this.setState({...this.#e,fetchStatus:"idle"}),this.state.data}throw this.#o({type:"error",error:a}),this.#n.config.onError?.(a,this),this.#n.config.onSettled?.(this.state.data,a,this),a}finally{this.scheduleGc()}}#o(e){const t=n=>{switch(e.type){case"failed":return{...n,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...Zc(n.data,this.options),fetchMeta:e.meta??null};case"success":const r={...n,data:e.data,dataUpdateCount:n.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#e=e.manual?r:void 0,r;case"error":const s=e.error;return{...n,error:s,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:s,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...e.state}}};this.state=t(this.state),Me.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:e})})}};function Zc(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Uc(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function kf(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var Sf=class extends xr{constructor(e={}){super(),this.config=e,this.#t=new Map}#t;build(e,t,n){const r=t.queryKey,s=t.queryHash??ai(r,t);let o=this.get(s);return o||(o=new Cf({client:e,queryKey:r,queryHash:s,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(o)),o}add(e){this.#t.has(e.queryHash)||(this.#t.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const t=this.#t.get(e.queryHash);t&&(e.destroy(),t===e&&this.#t.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){Me.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#t.get(e)}getAll(){return[...this.#t.values()]}find(e){const t={exact:!0,...e};return this.getAll().find(n=>ra(t,n))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(n=>ra(e,n)):t}notify(e){Me.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){Me.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){Me.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},Af=class extends Hc{#t;#e;#n;constructor(e){super(),this.mutationId=e.mutationId,this.#e=e.mutationCache,this.#t=[],this.state=e.state||Ef(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#e.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#e.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#e.remove(this))}continue(){return this.#n?.continue()??this.execute(this.state.variables)}async execute(e){const t=()=>{this.#r({type:"continue"})};this.#n=Wc({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(s,o)=>{this.#r({type:"failed",failureCount:s,error:o})},onPause:()=>{this.#r({type:"pause"})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#e.canRun(this)});const n=this.state.status==="pending",r=!this.#n.canStart();try{if(n)t();else{this.#r({type:"pending",variables:e,isPaused:r}),await this.#e.config.onMutate?.(e,this);const o=await this.options.onMutate?.(e);o!==this.state.context&&this.#r({type:"pending",context:o,variables:e,isPaused:r})}const s=await this.#n.start();return await this.#e.config.onSuccess?.(s,e,this.state.context,this),await this.options.onSuccess?.(s,e,this.state.context),await this.#e.config.onSettled?.(s,null,this.state.variables,this.state.context,this),await this.options.onSettled?.(s,null,e,this.state.context),this.#r({type:"success",data:s}),s}catch(s){try{throw await this.#e.config.onError?.(s,e,this.state.context,this),await this.options.onError?.(s,e,this.state.context),await this.#e.config.onSettled?.(void 0,s,this.state.variables,this.state.context,this),await this.options.onSettled?.(void 0,s,e,this.state.context),s}finally{this.#r({type:"error",error:s})}}finally{this.#e.runNext(this)}}#r(e){const t=n=>{switch(e.type){case"failed":return{...n,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...n,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:e.error,failureCount:n.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=t(this.state),Me.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(e)}),this.#e.notify({mutation:this,type:"updated",action:e})})}};function Ef(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Rf=class extends xr{constructor(e={}){super(),this.config=e,this.#t=new Set,this.#e=new Map,this.#n=0}#t;#e;#n;build(e,t,n){const r=new Af({mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#t.add(e);const t=Mr(e);if(typeof t=="string"){const n=this.#e.get(t);n?n.push(e):this.#e.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#t.delete(e)){const t=Mr(e);if(typeof t=="string"){const n=this.#e.get(t);if(n)if(n.length>1){const r=n.indexOf(e);r!==-1&&n.splice(r,1)}else n[0]===e&&this.#e.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=Mr(e);if(typeof t=="string"){const r=this.#e.get(t)?.find(s=>s.state.status==="pending");return!r||r===e}else return!0}runNext(e){const t=Mr(e);return typeof t=="string"?this.#e.get(t)?.find(r=>r!==e&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){Me.batch(()=>{this.#t.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#t.clear(),this.#e.clear()})}getAll(){return Array.from(this.#t)}find(e){const t={exact:!0,...e};return this.getAll().find(n=>sa(t,n))}findAll(e={}){return this.getAll().filter(t=>sa(e,t))}notify(e){Me.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){const e=this.getAll().filter(t=>t.state.isPaused);return Me.batch(()=>Promise.all(e.map(t=>t.continue().catch(Fe))))}};function Mr(e){return e.options.scope?.id}function aa(e){return{onFetch:(t,n)=>{const r=t.options,s=t.fetchOptions?.meta?.fetchMore?.direction,o=t.state.data?.pages||[],i=t.state.data?.pageParams||[];let a={pages:[],pageParams:[]},c=0;const l=async()=>{let u=!1;const d=y=>{Object.defineProperty(y,"signal",{enumerable:!0,get:()=>(t.signal.aborted?u=!0:t.signal.addEventListener("abort",()=>{u=!0}),t.signal)})},f=Vc(t.options,t.fetchOptions),m=async(y,h,v)=>{if(u)return Promise.reject();if(h==null&&y.pages.length)return Promise.resolve(y);const w=(()=>{const S={client:t.client,queryKey:t.queryKey,pageParam:h,direction:v?"backward":"forward",meta:t.options.meta};return d(S),S})(),x=await f(w),{maxPages:_}=t.options,C=v?gf:mf;return{pages:C(y.pages,x,_),pageParams:C(y.pageParams,h,_)}};if(s&&o.length){const y=s==="backward",h=y?Of:ca,v={pages:o,pageParams:i},b=h(r,v);a=await m(v,b,y)}else{const y=e??o.length;do{const h=c===0?i[0]??r.initialPageParam:ca(r,a);if(c>0&&h==null)break;a=await m(a,h),c++}while(ct.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=l}}}function ca(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function Of(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var Pf=class{#t;#e;#n;#r;#s;#a;#i;#o;constructor(e={}){this.#t=e.queryCache||new Sf,this.#e=e.mutationCache||new Rf,this.#n=e.defaultOptions||{},this.#r=new Map,this.#s=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#i=li.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#t.onFocus())}),this.#o=rs.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#t.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#i?.(),this.#i=void 0,this.#o?.(),this.#o=void 0)}isFetching(e){return this.#t.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#e.findAll({...e,status:"pending"}).length}getQueryData(e){const t=this.defaultQueryOptions({queryKey:e});return this.#t.get(t.queryHash)?.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=this.#t.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Ft(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#t.findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),o=this.#t.get(r.queryHash)?.state.data,i=hf(t,o);if(i!==void 0)return this.#t.build(this,r).setData(i,{...n,manual:!0})}setQueriesData(e,t,n){return Me.batch(()=>this.#t.findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){const t=this.defaultQueryOptions({queryKey:e});return this.#t.get(t.queryHash)?.state}removeQueries(e){const t=this.#t;Me.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=this.#t;return Me.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=Me.batch(()=>this.#t.findAll(e).map(s=>s.cancel(n)));return Promise.all(r).then(Fe).catch(Fe)}invalidateQueries(e,t={}){return Me.batch(()=>(this.#t.findAll(e).forEach(n=>{n.invalidate()}),e?.refetchType==="none"?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=Me.batch(()=>this.#t.findAll(e).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let o=s.fetch(void 0,n);return n.throwOnError||(o=o.catch(Fe)),s.state.fetchStatus==="paused"?Promise.resolve():o}));return Promise.all(r).then(Fe)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=this.#t.build(this,t);return n.isStaleByTime(Ft(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Fe).catch(Fe)}fetchInfiniteQuery(e){return e.behavior=aa(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Fe).catch(Fe)}ensureInfiniteQueryData(e){return e.behavior=aa(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return rs.isOnline()?this.#e.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#t}getMutationCache(){return this.#e}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(sr(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...this.#r.values()],n={};return t.forEach(r=>{or(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){this.#s.set(sr(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...this.#s.values()],n={};return t.forEach(r=>{or(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=ai(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===ci&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#t.clear(),this.#e.clear()}},Mf=class extends xr{constructor(e,t){super(),this.options=t,this.#t=e,this.#o=null,this.#i=po(),this.options.experimental_prefetchInRender||this.#i.reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(t)}#t;#e=void 0;#n=void 0;#r=void 0;#s;#a;#i;#o;#m;#f;#h;#l;#u;#c;#p=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#e.addObserver(this),la(this.#e,this.options)?this.#d():this.updateResult(),this.#b())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return mo(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return mo(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#w(),this.#x(),this.#e.removeObserver(this)}setOptions(e){const t=this.options,n=this.#e;if(this.options=this.#t.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof He(this.options.enabled,this.#e)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#_(),this.#e.setOptions(this.options),t._defaulted&&!uo(this.options,t)&&this.#t.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const r=this.hasListeners();r&&ua(this.#e,n,this.options,t)&&this.#d(),this.updateResult(),r&&(this.#e!==n||He(this.options.enabled,this.#e)!==He(t.enabled,this.#e)||Ft(this.options.staleTime,this.#e)!==Ft(t.staleTime,this.#e))&&this.#g();const s=this.#y();r&&(this.#e!==n||He(this.options.enabled,this.#e)!==He(t.enabled,this.#e)||s!==this.#c)&&this.#v(s)}getOptimisticResult(e){const t=this.#t.getQueryCache().build(this.#t,e),n=this.createResult(t,e);return If(this,n)&&(this.#r=n,this.#a=this.options,this.#s=this.#e.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(n,r)=>(this.trackProp(r),t?.(r),Reflect.get(n,r))})}trackProp(e){this.#p.add(e)}getCurrentQuery(){return this.#e}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const t=this.#t.defaultQueryOptions(e),n=this.#t.getQueryCache().build(this.#t,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#d({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#d(e){this.#_();let t=this.#e.fetch(this.options,e);return e?.throwOnError||(t=t.catch(Fe)),t}#g(){this.#w();const e=Ft(this.options.staleTime,this.#e);if(nn||this.#r.isStale||!lo(e))return;const n=Kc(this.#r.dataUpdatedAt,e)+1;this.#l=setTimeout(()=>{this.#r.isStale||this.updateResult()},n)}#y(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#c=e,!(nn||He(this.options.enabled,this.#e)===!1||!lo(this.#c)||this.#c===0)&&(this.#u=setInterval(()=>{(this.options.refetchIntervalInBackground||li.isFocused())&&this.#d()},this.#c))}#b(){this.#g(),this.#v(this.#y())}#w(){this.#l&&(clearTimeout(this.#l),this.#l=void 0)}#x(){this.#u&&(clearInterval(this.#u),this.#u=void 0)}createResult(e,t){const n=this.#e,r=this.options,s=this.#r,o=this.#s,i=this.#a,c=e!==n?e.state:this.#n,{state:l}=e;let u={...l},d=!1,f;if(t._optimisticResults){const A=this.hasListeners(),O=!A&&la(e,t),R=A&&ua(e,n,t,r);(O||R)&&(u={...u,...Zc(l.data,e.options)}),t._optimisticResults==="isRestoring"&&(u.fetchStatus="idle")}let{error:m,errorUpdatedAt:y,status:h}=u;f=u.data;let v=!1;if(t.placeholderData!==void 0&&f===void 0&&h==="pending"){let A;s?.isPlaceholderData&&t.placeholderData===i?.placeholderData?(A=s.data,v=!0):A=typeof t.placeholderData=="function"?t.placeholderData(this.#h?.state.data,this.#h):t.placeholderData,A!==void 0&&(h="success",f=ho(s?.data,A,t),d=!0)}if(t.select&&f!==void 0&&!v)if(s&&f===o?.data&&t.select===this.#m)f=this.#f;else try{this.#m=t.select,f=t.select(f),f=ho(s?.data,f,t),this.#f=f,this.#o=null}catch(A){this.#o=A}this.#o&&(m=this.#o,f=this.#f,y=Date.now(),h="error");const b=u.fetchStatus==="fetching",w=h==="pending",x=h==="error",_=w&&b,C=f!==void 0,k={status:h,fetchStatus:u.fetchStatus,isPending:w,isSuccess:h==="success",isError:x,isInitialLoading:_,isLoading:_,data:f,dataUpdatedAt:u.dataUpdatedAt,error:m,errorUpdatedAt:y,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:u.dataUpdateCount>0||u.errorUpdateCount>0,isFetchedAfterMount:u.dataUpdateCount>c.dataUpdateCount||u.errorUpdateCount>c.errorUpdateCount,isFetching:b,isRefetching:b&&!w,isLoadingError:x&&!C,isPaused:u.fetchStatus==="paused",isPlaceholderData:d,isRefetchError:x&&C,isStale:ui(e,t),refetch:this.refetch,promise:this.#i,isEnabled:He(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const A=T=>{k.status==="error"?T.reject(k.error):k.data!==void 0&&T.resolve(k.data)},O=()=>{const T=this.#i=k.promise=po();A(T)},R=this.#i;switch(R.status){case"pending":e.queryHash===n.queryHash&&A(R);break;case"fulfilled":(k.status==="error"||k.data!==R.value)&&O();break;case"rejected":(k.status!=="error"||k.error!==R.reason)&&O();break}}return k}updateResult(){const e=this.#r,t=this.createResult(this.#e,this.options);if(this.#s=this.#e.state,this.#a=this.options,this.#s.data!==void 0&&(this.#h=this.#e),uo(t,e))return;this.#r=t;const n=()=>{if(!e)return!0;const{notifyOnChangeProps:r}=this.options,s=typeof r=="function"?r():r;if(s==="all"||!s&&!this.#p.size)return!0;const o=new Set(s??this.#p);return this.options.throwOnError&&o.add("error"),Object.keys(this.#r).some(i=>{const a=i;return this.#r[a]!==e[a]&&o.has(a)})};this.#C({listeners:n()})}#_(){const e=this.#t.getQueryCache().build(this.#t,this.options);if(e===this.#e)return;const t=this.#e;this.#e=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#b()}#C(e){Me.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#r)}),this.#t.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function Tf(e,t){return He(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function la(e,t){return Tf(e,t)||e.state.data!==void 0&&mo(e,t,t.refetchOnMount)}function mo(e,t,n){if(He(t.enabled,e)!==!1&&Ft(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&ui(e,t)}return!1}function ua(e,t,n,r){return(e!==t||He(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&ui(e,n)}function ui(e,t){return He(t.enabled,e)!==!1&&e.isStaleByTime(Ft(t.staleTime,e))}function If(e,t){return!uo(e.getCurrentResult(),t)}var Gc=p.createContext(void 0),Qc=e=>{const t=p.useContext(Gc);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Nf=({client:e,children:t})=>(p.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),g.jsx(Gc.Provider,{value:e,children:t})),Yc=p.createContext(!1),Df=()=>p.useContext(Yc);Yc.Provider;function jf(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Ff=p.createContext(jf()),Lf=()=>p.useContext(Ff),$f=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},Bf=e=>{p.useEffect(()=>{e.clearReset()},[e])},Kf=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:s})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(s&&e.data===void 0||yf(n,[e.error,r])),zf=e=>{if(e.suspense){const t=r=>r==="static"?r:Math.max(r??1e3,1e3),n=e.staleTime;e.staleTime=typeof n=="function"?(...r)=>t(n(...r)):t(n),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},Vf=(e,t)=>e.isLoading&&e.isFetching&&!t,Uf=(e,t)=>e?.suspense&&t.isPending,da=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function qf(e,t,n){const r=Df(),s=Lf(),o=Qc(),i=o.defaultQueryOptions(e);o.getDefaultOptions().queries?._experimental_beforeQuery?.(i),i._optimisticResults=r?"isRestoring":"optimistic",zf(i),$f(i,s),Bf(s);const a=!o.getQueryCache().get(i.queryHash),[c]=p.useState(()=>new t(o,i)),l=c.getOptimisticResult(i),u=!r&&e.subscribed!==!1;if(p.useSyncExternalStore(p.useCallback(d=>{const f=u?c.subscribe(Me.batchCalls(d)):Fe;return c.updateResult(),f},[c,u]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),p.useEffect(()=>{c.setOptions(i)},[i,c]),Uf(i,l))throw da(i,c,s);if(Kf({result:l,errorResetBoundary:s,throwOnError:i.throwOnError,query:o.getQueryCache().get(i.queryHash),suspense:i.suspense}))throw l.error;return o.getDefaultOptions().queries?._experimental_afterQuery?.(i,l),i.experimental_prefetchInRender&&!nn&&Vf(l,r)&&(a?da(i,c,s):o.getQueryCache().get(i.queryHash)?.promise)?.catch(Fe).finally(()=>{c.updateResult()}),i.notifyOnChangeProps?l:c.trackResult(l)}function di(e,t){return qf(e,Mf)}let Ls=null;function Wf(){return Ls||(Ls=new Pf({defaultOptions:{queries:{staleTime:6e4,refetchOnWindowFocus:!1,retry:1}}})),Ls}const Hf=({children:e})=>g.jsx(Nf,{client:Wf(),children:e});function Xc(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var s=e.length;for(t=0;t{const t=Qf(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:i=>{const a=i.split(hi);return a[0]===""&&a.length!==1&&a.shift(),Jc(a,t)||Gf(i)},getConflictingClassGroupIds:(i,a)=>{const c=n[i]||[];return a&&r[i]?[...c,...r[i]]:c}}},Jc=(e,t)=>{if(e.length===0)return t.classGroupId;const n=e[0],r=t.nextPart.get(n),s=r?Jc(e.slice(1),r):void 0;if(s)return s;if(t.validators.length===0)return;const o=e.join(hi);return t.validators.find(({validator:i})=>i(o))?.classGroupId},fa=/^\[(.+)\]$/,Gf=e=>{if(fa.test(e)){const t=fa.exec(e)[1],n=t?.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},Qf=e=>{const{theme:t,classGroups:n}=e,r={nextPart:new Map,validators:[]};for(const s in n)go(n[s],r,s,t);return r},go=(e,t,n,r)=>{e.forEach(s=>{if(typeof s=="string"){const o=s===""?t:ha(t,s);o.classGroupId=n;return}if(typeof s=="function"){if(Yf(s)){go(s(r),t,n,r);return}t.validators.push({validator:s,classGroupId:n});return}Object.entries(s).forEach(([o,i])=>{go(i,ha(t,o),n,r)})})},ha=(e,t)=>{let n=e;return t.split(hi).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},Yf=e=>e.isThemeGetter,Xf=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,r=new Map;const s=(o,i)=>{n.set(o,i),t++,t>e&&(t=0,r=n,n=new Map)};return{get(o){let i=n.get(o);if(i!==void 0)return i;if((i=r.get(o))!==void 0)return s(o,i),i},set(o,i){n.has(o)?n.set(o,i):s(o,i)}}},yo="!",vo=":",Jf=vo.length,eh=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=s=>{const o=[];let i=0,a=0,c=0,l;for(let y=0;yc?l-c:void 0;return{modifiers:o,hasImportantModifier:f,baseClassName:d,maybePostfixModifierPosition:m}};if(t){const s=t+vo,o=r;r=i=>i.startsWith(s)?o(i.substring(s.length)):{isExternal:!0,modifiers:[],hasImportantModifier:!1,baseClassName:i,maybePostfixModifierPosition:void 0}}if(n){const s=r;r=o=>n({className:o,parseClassName:s})}return r},th=e=>e.endsWith(yo)?e.substring(0,e.length-1):e.startsWith(yo)?e.substring(1):e,nh=e=>{const t=Object.fromEntries(e.orderSensitiveModifiers.map(r=>[r,!0]));return r=>{if(r.length<=1)return r;const s=[];let o=[];return r.forEach(i=>{i[0]==="["||t[i]?(s.push(...o.sort(),i),o=[]):o.push(i)}),s.push(...o.sort()),s}},rh=e=>({cache:Xf(e.cacheSize),parseClassName:eh(e),sortModifiers:nh(e),...Zf(e)}),sh=/\s+/,oh=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:s,sortModifiers:o}=t,i=[],a=e.trim().split(sh);let c="";for(let l=a.length-1;l>=0;l-=1){const u=a[l],{isExternal:d,modifiers:f,hasImportantModifier:m,baseClassName:y,maybePostfixModifierPosition:h}=n(u);if(d){c=u+(c.length>0?" "+c:c);continue}let v=!!h,b=r(v?y.substring(0,h):y);if(!b){if(!v){c=u+(c.length>0?" "+c:c);continue}if(b=r(y),!b){c=u+(c.length>0?" "+c:c);continue}v=!1}const w=o(f).join(":"),x=m?w+yo:w,_=x+b;if(i.includes(_))continue;i.push(_);const C=s(b,v);for(let S=0;S0?" "+c:c)}return c};function ih(){let e=0,t,n,r="";for(;e{if(typeof e=="string")return e;let t,n="";for(let r=0;rd(u),e());return n=rh(l),r=n.cache.get,s=n.cache.set,o=a,a(c)}function a(c){const l=r(c);if(l)return l;const u=oh(c,n);return s(c,u),u}return function(){return o(ih.apply(null,arguments))}}const Ee=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},tl=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,nl=/^\((?:(\w[\w-]*):)?(.+)\)$/i,ch=/^\d+\/\d+$/,lh=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,uh=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,dh=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,fh=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,hh=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,hn=e=>ch.test(e),oe=e=>!!e&&!Number.isNaN(Number(e)),Rt=e=>!!e&&Number.isInteger(Number(e)),$s=e=>e.endsWith("%")&&oe(e.slice(0,-1)),pt=e=>lh.test(e),ph=()=>!0,mh=e=>uh.test(e)&&!dh.test(e),rl=()=>!1,gh=e=>fh.test(e),yh=e=>hh.test(e),vh=e=>!$(e)&&!B(e),bh=e=>Ln(e,il,rl),$=e=>tl.test(e),Zt=e=>Ln(e,al,mh),Bs=e=>Ln(e,kh,oe),pa=e=>Ln(e,sl,rl),wh=e=>Ln(e,ol,yh),Tr=e=>Ln(e,cl,gh),B=e=>nl.test(e),qn=e=>$n(e,al),xh=e=>$n(e,Sh),ma=e=>$n(e,sl),_h=e=>$n(e,il),Ch=e=>$n(e,ol),Ir=e=>$n(e,cl,!0),Ln=(e,t,n)=>{const r=tl.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},$n=(e,t,n=!1)=>{const r=nl.exec(e);return r?r[1]?t(r[1]):n:!1},sl=e=>e==="position"||e==="percentage",ol=e=>e==="image"||e==="url",il=e=>e==="length"||e==="size"||e==="bg-size",al=e=>e==="length",kh=e=>e==="number",Sh=e=>e==="family-name",cl=e=>e==="shadow",Ah=()=>{const e=Ee("color"),t=Ee("font"),n=Ee("text"),r=Ee("font-weight"),s=Ee("tracking"),o=Ee("leading"),i=Ee("breakpoint"),a=Ee("container"),c=Ee("spacing"),l=Ee("radius"),u=Ee("shadow"),d=Ee("inset-shadow"),f=Ee("text-shadow"),m=Ee("drop-shadow"),y=Ee("blur"),h=Ee("perspective"),v=Ee("aspect"),b=Ee("ease"),w=Ee("animate"),x=()=>["auto","avoid","all","avoid-page","page","left","right","column"],_=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],C=()=>[..._(),B,$],S=()=>["auto","hidden","clip","visible","scroll"],k=()=>["auto","contain","none"],A=()=>[B,$,c],O=()=>[hn,"full","auto",...A()],R=()=>[Rt,"none","subgrid",B,$],T=()=>["auto",{span:["full",Rt,B,$]},Rt,B,$],q=()=>[Rt,"auto",B,$],H=()=>["auto","min","max","fr",B,$],W=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],ue=()=>["start","end","center","stretch","center-safe","end-safe"],Q=()=>["auto",...A()],G=()=>[hn,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...A()],E=()=>[e,B,$],P=()=>[..._(),ma,pa,{position:[B,$]}],U=()=>["no-repeat",{repeat:["","x","y","space","round"]}],me=()=>["auto","cover","contain",_h,bh,{size:[B,$]}],Y=()=>[$s,qn,Zt],L=()=>["","none","full",l,B,$],X=()=>["",oe,qn,Zt],de=()=>["solid","dashed","dotted","double"],ne=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],D=()=>[oe,$s,ma,pa],ie=()=>["","none",y,B,$],I=()=>["none",oe,B,$],K=()=>["none",oe,B,$],re=()=>[oe,B,$],ce=()=>[hn,"full",...A()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[pt],breakpoint:[pt],color:[ph],container:[pt],"drop-shadow":[pt],ease:["in","out","in-out"],font:[vh],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[pt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[pt],shadow:[pt],spacing:["px",oe],text:[pt],"text-shadow":[pt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",hn,$,B,v]}],container:["container"],columns:[{columns:[oe,$,B,a]}],"break-after":[{"break-after":x()}],"break-before":[{"break-before":x()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:C()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:k()}],"overscroll-x":[{"overscroll-x":k()}],"overscroll-y":[{"overscroll-y":k()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:O()}],"inset-x":[{"inset-x":O()}],"inset-y":[{"inset-y":O()}],start:[{start:O()}],end:[{end:O()}],top:[{top:O()}],right:[{right:O()}],bottom:[{bottom:O()}],left:[{left:O()}],visibility:["visible","invisible","collapse"],z:[{z:[Rt,"auto",B,$]}],basis:[{basis:[hn,"full","auto",a,...A()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[oe,hn,"auto","initial","none",$]}],grow:[{grow:["",oe,B,$]}],shrink:[{shrink:["",oe,B,$]}],order:[{order:[Rt,"first","last","none",B,$]}],"grid-cols":[{"grid-cols":R()}],"col-start-end":[{col:T()}],"col-start":[{"col-start":q()}],"col-end":[{"col-end":q()}],"grid-rows":[{"grid-rows":R()}],"row-start-end":[{row:T()}],"row-start":[{"row-start":q()}],"row-end":[{"row-end":q()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":H()}],"auto-rows":[{"auto-rows":H()}],gap:[{gap:A()}],"gap-x":[{"gap-x":A()}],"gap-y":[{"gap-y":A()}],"justify-content":[{justify:[...W(),"normal"]}],"justify-items":[{"justify-items":[...ue(),"normal"]}],"justify-self":[{"justify-self":["auto",...ue()]}],"align-content":[{content:["normal",...W()]}],"align-items":[{items:[...ue(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...ue(),{baseline:["","last"]}]}],"place-content":[{"place-content":W()}],"place-items":[{"place-items":[...ue(),"baseline"]}],"place-self":[{"place-self":["auto",...ue()]}],p:[{p:A()}],px:[{px:A()}],py:[{py:A()}],ps:[{ps:A()}],pe:[{pe:A()}],pt:[{pt:A()}],pr:[{pr:A()}],pb:[{pb:A()}],pl:[{pl:A()}],m:[{m:Q()}],mx:[{mx:Q()}],my:[{my:Q()}],ms:[{ms:Q()}],me:[{me:Q()}],mt:[{mt:Q()}],mr:[{mr:Q()}],mb:[{mb:Q()}],ml:[{ml:Q()}],"space-x":[{"space-x":A()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":A()}],"space-y-reverse":["space-y-reverse"],size:[{size:G()}],w:[{w:[a,"screen",...G()]}],"min-w":[{"min-w":[a,"screen","none",...G()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[i]},...G()]}],h:[{h:["screen","lh",...G()]}],"min-h":[{"min-h":["screen","lh","none",...G()]}],"max-h":[{"max-h":["screen","lh",...G()]}],"font-size":[{text:["base",n,qn,Zt]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,B,Bs]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",$s,$]}],"font-family":[{font:[xh,$,t]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[s,B,$]}],"line-clamp":[{"line-clamp":[oe,"none",B,Bs]}],leading:[{leading:[o,...A()]}],"list-image":[{"list-image":["none",B,$]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",B,$]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:E()}],"text-color":[{text:E()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...de(),"wavy"]}],"text-decoration-thickness":[{decoration:[oe,"from-font","auto",B,Zt]}],"text-decoration-color":[{decoration:E()}],"underline-offset":[{"underline-offset":[oe,"auto",B,$]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:A()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",B,$]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",B,$]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:P()}],"bg-repeat":[{bg:U()}],"bg-size":[{bg:me()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Rt,B,$],radial:["",B,$],conic:[Rt,B,$]},Ch,wh]}],"bg-color":[{bg:E()}],"gradient-from-pos":[{from:Y()}],"gradient-via-pos":[{via:Y()}],"gradient-to-pos":[{to:Y()}],"gradient-from":[{from:E()}],"gradient-via":[{via:E()}],"gradient-to":[{to:E()}],rounded:[{rounded:L()}],"rounded-s":[{"rounded-s":L()}],"rounded-e":[{"rounded-e":L()}],"rounded-t":[{"rounded-t":L()}],"rounded-r":[{"rounded-r":L()}],"rounded-b":[{"rounded-b":L()}],"rounded-l":[{"rounded-l":L()}],"rounded-ss":[{"rounded-ss":L()}],"rounded-se":[{"rounded-se":L()}],"rounded-ee":[{"rounded-ee":L()}],"rounded-es":[{"rounded-es":L()}],"rounded-tl":[{"rounded-tl":L()}],"rounded-tr":[{"rounded-tr":L()}],"rounded-br":[{"rounded-br":L()}],"rounded-bl":[{"rounded-bl":L()}],"border-w":[{border:X()}],"border-w-x":[{"border-x":X()}],"border-w-y":[{"border-y":X()}],"border-w-s":[{"border-s":X()}],"border-w-e":[{"border-e":X()}],"border-w-t":[{"border-t":X()}],"border-w-r":[{"border-r":X()}],"border-w-b":[{"border-b":X()}],"border-w-l":[{"border-l":X()}],"divide-x":[{"divide-x":X()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":X()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...de(),"hidden","none"]}],"divide-style":[{divide:[...de(),"hidden","none"]}],"border-color":[{border:E()}],"border-color-x":[{"border-x":E()}],"border-color-y":[{"border-y":E()}],"border-color-s":[{"border-s":E()}],"border-color-e":[{"border-e":E()}],"border-color-t":[{"border-t":E()}],"border-color-r":[{"border-r":E()}],"border-color-b":[{"border-b":E()}],"border-color-l":[{"border-l":E()}],"divide-color":[{divide:E()}],"outline-style":[{outline:[...de(),"none","hidden"]}],"outline-offset":[{"outline-offset":[oe,B,$]}],"outline-w":[{outline:["",oe,qn,Zt]}],"outline-color":[{outline:E()}],shadow:[{shadow:["","none",u,Ir,Tr]}],"shadow-color":[{shadow:E()}],"inset-shadow":[{"inset-shadow":["none",d,Ir,Tr]}],"inset-shadow-color":[{"inset-shadow":E()}],"ring-w":[{ring:X()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:E()}],"ring-offset-w":[{"ring-offset":[oe,Zt]}],"ring-offset-color":[{"ring-offset":E()}],"inset-ring-w":[{"inset-ring":X()}],"inset-ring-color":[{"inset-ring":E()}],"text-shadow":[{"text-shadow":["none",f,Ir,Tr]}],"text-shadow-color":[{"text-shadow":E()}],opacity:[{opacity:[oe,B,$]}],"mix-blend":[{"mix-blend":[...ne(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":ne()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[oe]}],"mask-image-linear-from-pos":[{"mask-linear-from":D()}],"mask-image-linear-to-pos":[{"mask-linear-to":D()}],"mask-image-linear-from-color":[{"mask-linear-from":E()}],"mask-image-linear-to-color":[{"mask-linear-to":E()}],"mask-image-t-from-pos":[{"mask-t-from":D()}],"mask-image-t-to-pos":[{"mask-t-to":D()}],"mask-image-t-from-color":[{"mask-t-from":E()}],"mask-image-t-to-color":[{"mask-t-to":E()}],"mask-image-r-from-pos":[{"mask-r-from":D()}],"mask-image-r-to-pos":[{"mask-r-to":D()}],"mask-image-r-from-color":[{"mask-r-from":E()}],"mask-image-r-to-color":[{"mask-r-to":E()}],"mask-image-b-from-pos":[{"mask-b-from":D()}],"mask-image-b-to-pos":[{"mask-b-to":D()}],"mask-image-b-from-color":[{"mask-b-from":E()}],"mask-image-b-to-color":[{"mask-b-to":E()}],"mask-image-l-from-pos":[{"mask-l-from":D()}],"mask-image-l-to-pos":[{"mask-l-to":D()}],"mask-image-l-from-color":[{"mask-l-from":E()}],"mask-image-l-to-color":[{"mask-l-to":E()}],"mask-image-x-from-pos":[{"mask-x-from":D()}],"mask-image-x-to-pos":[{"mask-x-to":D()}],"mask-image-x-from-color":[{"mask-x-from":E()}],"mask-image-x-to-color":[{"mask-x-to":E()}],"mask-image-y-from-pos":[{"mask-y-from":D()}],"mask-image-y-to-pos":[{"mask-y-to":D()}],"mask-image-y-from-color":[{"mask-y-from":E()}],"mask-image-y-to-color":[{"mask-y-to":E()}],"mask-image-radial":[{"mask-radial":[B,$]}],"mask-image-radial-from-pos":[{"mask-radial-from":D()}],"mask-image-radial-to-pos":[{"mask-radial-to":D()}],"mask-image-radial-from-color":[{"mask-radial-from":E()}],"mask-image-radial-to-color":[{"mask-radial-to":E()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":_()}],"mask-image-conic-pos":[{"mask-conic":[oe]}],"mask-image-conic-from-pos":[{"mask-conic-from":D()}],"mask-image-conic-to-pos":[{"mask-conic-to":D()}],"mask-image-conic-from-color":[{"mask-conic-from":E()}],"mask-image-conic-to-color":[{"mask-conic-to":E()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:P()}],"mask-repeat":[{mask:U()}],"mask-size":[{mask:me()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",B,$]}],filter:[{filter:["","none",B,$]}],blur:[{blur:ie()}],brightness:[{brightness:[oe,B,$]}],contrast:[{contrast:[oe,B,$]}],"drop-shadow":[{"drop-shadow":["","none",m,Ir,Tr]}],"drop-shadow-color":[{"drop-shadow":E()}],grayscale:[{grayscale:["",oe,B,$]}],"hue-rotate":[{"hue-rotate":[oe,B,$]}],invert:[{invert:["",oe,B,$]}],saturate:[{saturate:[oe,B,$]}],sepia:[{sepia:["",oe,B,$]}],"backdrop-filter":[{"backdrop-filter":["","none",B,$]}],"backdrop-blur":[{"backdrop-blur":ie()}],"backdrop-brightness":[{"backdrop-brightness":[oe,B,$]}],"backdrop-contrast":[{"backdrop-contrast":[oe,B,$]}],"backdrop-grayscale":[{"backdrop-grayscale":["",oe,B,$]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[oe,B,$]}],"backdrop-invert":[{"backdrop-invert":["",oe,B,$]}],"backdrop-opacity":[{"backdrop-opacity":[oe,B,$]}],"backdrop-saturate":[{"backdrop-saturate":[oe,B,$]}],"backdrop-sepia":[{"backdrop-sepia":["",oe,B,$]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":A()}],"border-spacing-x":[{"border-spacing-x":A()}],"border-spacing-y":[{"border-spacing-y":A()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",B,$]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[oe,"initial",B,$]}],ease:[{ease:["linear","initial",b,B,$]}],delay:[{delay:[oe,B,$]}],animate:[{animate:["none",w,B,$]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[h,B,$]}],"perspective-origin":[{"perspective-origin":C()}],rotate:[{rotate:I()}],"rotate-x":[{"rotate-x":I()}],"rotate-y":[{"rotate-y":I()}],"rotate-z":[{"rotate-z":I()}],scale:[{scale:K()}],"scale-x":[{"scale-x":K()}],"scale-y":[{"scale-y":K()}],"scale-z":[{"scale-z":K()}],"scale-3d":["scale-3d"],skew:[{skew:re()}],"skew-x":[{"skew-x":re()}],"skew-y":[{"skew-y":re()}],transform:[{transform:[B,$,"","none","gpu","cpu"]}],"transform-origin":[{origin:C()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ce()}],"translate-x":[{"translate-x":ce()}],"translate-y":[{"translate-y":ce()}],"translate-z":[{"translate-z":ce()}],"translate-none":["translate-none"],accent:[{accent:E()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:E()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",B,$]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":A()}],"scroll-mx":[{"scroll-mx":A()}],"scroll-my":[{"scroll-my":A()}],"scroll-ms":[{"scroll-ms":A()}],"scroll-me":[{"scroll-me":A()}],"scroll-mt":[{"scroll-mt":A()}],"scroll-mr":[{"scroll-mr":A()}],"scroll-mb":[{"scroll-mb":A()}],"scroll-ml":[{"scroll-ml":A()}],"scroll-p":[{"scroll-p":A()}],"scroll-px":[{"scroll-px":A()}],"scroll-py":[{"scroll-py":A()}],"scroll-ps":[{"scroll-ps":A()}],"scroll-pe":[{"scroll-pe":A()}],"scroll-pt":[{"scroll-pt":A()}],"scroll-pr":[{"scroll-pr":A()}],"scroll-pb":[{"scroll-pb":A()}],"scroll-pl":[{"scroll-pl":A()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",B,$]}],fill:[{fill:["none",...E()]}],"stroke-w":[{stroke:[oe,qn,Zt,Bs]}],stroke:[{stroke:["none",...E()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},Eh=ah(Ah);function Ve(...e){return Eh(fi(e))}function ga(e,t=new Date){const n=typeof e=="string"||typeof e=="number"?new Date(e):e,r=t.getTime()-n.getTime(),s=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"}),o=[["year",1e3*60*60*24*365],["month",1e3*60*60*24*30],["week",1e3*60*60*24*7],["day",1e3*60*60*24],["hour",1e3*60*60],["minute",1e3*60],["second",1e3]];for(const[i,a]of o)if(Math.abs(r)>=a||i==="second"){const c=Math.round(r/a);return s.format(-c,i)}return"now"}const ll=p.forwardRef(({className:e,...t},n)=>g.jsx("textarea",{ref:n,className:Ve("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground border-input flex w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive","resize-none",e),...t}));ll.displayName="Textarea";/** * @license lucide-react v0.532.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rh=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Oh=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase()),ya=e=>{const t=Oh(e);return t.charAt(0).toUpperCase()+t.slice(1)},ul=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim(),Ph=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};/** * @license lucide-react v0.532.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */var Mh={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** * @license lucide-react v0.532.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Th=p.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:o,iconNode:i,...a},c)=>p.createElement("svg",{ref:c,...Mh,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:ul("lucide",s),...!o&&!Ph(a)&&{"aria-hidden":"true"},...a},[...i.map(([l,u])=>p.createElement(l,u)),...Array.isArray(o)?o:[o]]));/** * @license lucide-react v0.532.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ge=(e,t)=>{const n=p.forwardRef(({className:r,...s},o)=>p.createElement(Th,{ref:o,iconNode:t,className:ul(`lucide-${Rh(ya(e))}`,`lucide-${e}`,r),...s}));return n.displayName=ya(e),n};/** * @license lucide-react v0.532.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ih=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],va=Ge("chevron-down",Ih);/** * @license lucide-react v0.532.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nh=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],dl=Ge("chevron-left",Nh);/** * @license lucide-react v0.532.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dh=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],fl=Ge("chevron-right",Dh);/** * @license lucide-react v0.532.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jh=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],hl=Ge("copy",jh);/** * @license lucide-react v0.532.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fh=[["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 18h16",key:"19g7jn"}],["path",{d:"M4 6h16",key:"1o0s65"}]],Lh=Ge("menu",Fh);/** * @license lucide-react v0.532.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $h=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],Bh=Ge("paperclip",$h);/** * @license lucide-react v0.532.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kh=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],bo=Ge("plus",Kh);/** * @license lucide-react v0.532.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zh=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],pl=Ge("refresh-cw",zh);/** * @license lucide-react v0.532.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vh=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],Uh=Ge("send",Vh);/** * @license lucide-react v0.532.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qh=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Wh=Ge("square",qh);/** * @license lucide-react v0.532.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hh=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],pi=Ge("trash-2",Hh);/** * @license lucide-react v0.532.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zh=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],ml=Ge("x",Zh),Gh="modulepreload",Qh=function(e){return"/"+e},ba={},mi=function(t,n,r){let s=Promise.resolve();if(n&&n.length>0){let i=function(l){return Promise.all(l.map(u=>Promise.resolve(u).then(d=>({status:"fulfilled",value:d}),d=>({status:"rejected",reason:d}))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),c=a?.nonce||a?.getAttribute("nonce");s=i(n.map(l=>{if(l=Qh(l),l in ba)return;ba[l]=!0;const u=l.endsWith(".css"),d=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${d}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":Gh,u||(f.as="script"),f.crossOrigin="",f.href=l,c&&f.setAttribute("nonce",c),document.head.appendChild(f),u)return new Promise((m,y)=>{f.addEventListener("load",m),f.addEventListener("error",()=>y(new Error(`Unable to preload CSS for ${l}`)))})}))}function o(i){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=i,window.dispatchEvent(a),!a.defaultPrevented)throw i}return s.then(i=>{for(const a of i||[])a.status==="rejected"&&o(a.reason);return t().catch(o)})};function Yh(e){return e.replace(/\r\n|\r(?!\n)|\n/g,` `)}function Xh(e,t){if(!t||t.line===void 0||t.column===void 0)return"";const n=Yh(e).split(` `).map(i=>i.replace(/\t/g," ")),r=[];for(let i=-2;i<=2;i++)n[t.line+i]&&r.push(t.line+i);let s=0;for(const i of r){let a=`> ${i}`;a.length>s&&(s=a.length)}let o="";for(const i of r){const a=i===t.line-1;o+=a?"> ":" ",o+=`${i+1} | ${n[i]} `,a&&(o+=`${Array.from({length:s}).join(" ")} | ${Array.from({length:t.column}).join(" ")}^ `)}return o}class Jh extends Error{loc;title;hint;frame;type="AstroError";constructor(t,n){const{name:r,title:s,message:o,stack:i,location:a,hint:c,frame:l}=t;super(o,n),this.title=s,this.name=r,o&&(this.message=o),this.stack=i||this.stack,this.loc=a,this.hint=c,this.frame=l}setLocation(t){this.loc=t}setName(t){this.name=t}setMessage(t){this.message=t}setHint(t){this.hint=t}setFrame(t,n){this.frame=Xh(t,n)}static is(t){return t.type==="AstroError"}}const wa={name:"InvalidComponentArgs",title:"Invalid component arguments.",message:e=>`Invalid arguments passed to${e?` <${e}>`:""} component.`,hint:"Astro components cannot be rendered directly via function call, such as `Component()` or `{items.map(Component)}`."};function ep(e){return!(e.length!==3||!e[0]||typeof e[0]!="object")}function gl(e,t,n){const r=t?.split("/").pop()?.replace(".astro","")??"",s=(...o)=>{if(!ep(o))throw new Jh({...wa,message:wa.message(r)});return e(...o)};return Object.defineProperty(s,"name",{value:r,writable:!1}),s.isAstroComponentFactory=!0,s.moduleId=t,s.propagation=n,s}function tp(e){return gl(e.factory,e.moduleId,e.propagation)}function np(e,t,n){return typeof e=="function"?gl(e,t,n):tp(e)}typeof process<"u"&&process.stdout&&process.stdout.isTTY;const{replace:rp}="",sp=/[&<>'"]/g,op={"&":"&","<":"<",">":">","'":"'",'"':"""},ip=e=>op[e],ap=e=>rp.call(e,sp,ip);function On(e){return!!e&&typeof e=="object"&&"then"in e&&typeof e.then=="function"}const cp=ap;class ss extends String{get[Symbol.toStringTag](){return"HTMLString"}}const Le=e=>e instanceof ss?e:typeof e=="string"?new ss(e):e;function lp(e){return Object.prototype.toString.call(e)==="[object HTMLString]"}function up(e){return Le(e)}const dp=/^(?:allowfullscreen|async|autofocus|autoplay|checked|controls|default|defer|disabled|disablepictureinpicture|disableremoteplayback|formnovalidate|hidden|inert|loop|nomodule|novalidate|open|playsinline|readonly|required|reversed|scoped|seamless|selected|itemscope)$/i,fp=/&/g,hp=/"/g,pp=new Set(["set:html","set:text"]),Qt=(e,t=!0)=>t?String(e).replace(fp,"&").replace(hp,"""):e,mp=e=>e.toLowerCase()===e?e:e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`),xa=e=>Object.entries(e).filter(([t,n])=>typeof n=="string"&&n.trim()||typeof n=="number").map(([t,n])=>t[0]!=="-"&&t[1]!=="-"?`${mp(t)}:${n}`:`${t}:${n}`).join(";");function gp(e){return e.includes("-")}function Ks(e,t,n,r){return r&&gp(r)?Le(` ${e}="${Qt(t,n)}"`):Le(t?` ${e}`:"")}function yp(e,t,n=!0,r=""){if(e==null)return"";if(pp.has(t))return console.warn(`[astro] The "${t}" directive cannot be applied dynamically at runtime. It will not be rendered as an attribute. Make sure to use the static attribute syntax (\`${t}={value}\`) instead of the dynamic spread syntax (\`{...{ "${t}": value }}\`).`),"";if(t==="class:list"){const s=Qt(fi(e),n);return s===""?"":Le(` ${t.slice(0,-5)}="${s}"`)}if(t==="style"&&!(e instanceof ss)){if(Array.isArray(e)&&e.length===2)return Le(` ${t}="${Qt(`${xa(e[0])};${e[1]}`,n)}"`);if(typeof e=="object")return Le(` ${t}="${Qt(xa(e),n)}"`)}return t==="className"?Le(` class="${Qt(e,n)}"`):typeof e=="string"&&e.includes("&")&&xp(e)?Le(` ${t}="${Qt(e,!1)}"`):dp.test(t)?Ks(t,e,n,r):e===""?Le(` ${t}`):t==="popover"&&typeof e=="boolean"||t==="download"&&typeof e=="boolean"?Ks(t,e,n,r):Le(` ${t}="${Qt(e,n)}"`)}const vp=()=>{};class bp{chunks=[];renderPromise;destination;flushed=!1;constructor(t,n){this.destination=t,this.renderPromise=n(this),On(this.renderPromise)&&Promise.resolve(this.renderPromise).catch(vp)}write(t){this.flushed?this.destination.write(t):this.chunks.push(t)}flush(){if(this.flushed)throw new Error("The render buffer has already been flushed.");this.flushed=!0;for(const t of this.chunks)this.destination.write(t);return this.renderPromise}}function yl(e,t){return new bp(e,t)}typeof process<"u"&&Object.prototype.toString.call(process);const wp=["http:","https:"];function xp(e){try{const t=new URL(e);return wp.includes(t.protocol)}catch{return!1}}var _a;(function(e){e[e.Include=0]="Include",e[e.None=1]="None"})(_a||(_a={}));var Ca;(function(e){e[e.Required=0]="Required",e[e.Ignore=1]="Ignore"})(Ca||(Ca={}));var ka;(function(e){e[e.Include=0]="Include",e[e.None=1]="None"})(ka||(ka={}));var Sa;(function(e){e[e.Required=0]="Required",e[e.Ignore=1]="Ignore"})(Sa||(Sa={}));var he;(function(e){e.assertEqual=s=>{};function t(s){}e.assertIs=t;function n(s){throw new Error}e.assertNever=n,e.arrayToEnum=s=>{const o={};for(const i of s)o[i]=i;return o},e.getValidEnumValues=s=>{const o=e.objectKeys(s).filter(a=>typeof s[s[a]]!="number"),i={};for(const a of o)i[a]=s[a];return e.objectValues(i)},e.objectValues=s=>e.objectKeys(s).map(function(o){return s[o]}),e.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const o=[];for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&o.push(i);return o},e.find=(s,o)=>{for(const i of s)if(o(i))return i},e.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function r(s,o=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(o)}e.joinValues=r,e.jsonStringifyReplacer=(s,o)=>typeof o=="bigint"?o.toString():o})(he||(he={}));var Aa;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(Aa||(Aa={}));const z=he.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),It=e=>{switch(typeof e){case"undefined":return z.undefined;case"string":return z.string;case"number":return Number.isNaN(e)?z.nan:z.number;case"boolean":return z.boolean;case"function":return z.function;case"bigint":return z.bigint;case"symbol":return z.symbol;case"object":return Array.isArray(e)?z.array:e===null?z.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?z.promise:typeof Map<"u"&&e instanceof Map?z.map:typeof Set<"u"&&e instanceof Set?z.set:typeof Date<"u"&&e instanceof Date?z.date:z.object;default:return z.unknown}},M=he.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class xt extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(o){return o.message},r={_errors:[]},s=o=>{for(const i of o.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)r._errors.push(n(i));else{let a=r,c=0;for(;cn.message){const n={},r=[];for(const s of this.issues)if(s.path.length>0){const o=s.path[0];n[o]=n[o]||[],n[o].push(t(s))}else r.push(t(s));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}xt.create=e=>new xt(e);const wo=(e,t)=>{let n;switch(e.code){case M.invalid_type:e.received===z.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case M.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,he.jsonStringifyReplacer)}`;break;case M.unrecognized_keys:n=`Unrecognized key(s) in object: ${he.joinValues(e.keys,", ")}`;break;case M.invalid_union:n="Invalid input";break;case M.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${he.joinValues(e.options)}`;break;case M.invalid_enum_value:n=`Invalid enum value. Expected ${he.joinValues(e.options)}, received '${e.received}'`;break;case M.invalid_arguments:n="Invalid function arguments";break;case M.invalid_return_type:n="Invalid function return type";break;case M.invalid_date:n="Invalid date";break;case M.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:he.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case M.too_small:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:n="Invalid input";break;case M.too_big:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:n="Invalid input";break;case M.custom:n="Invalid input";break;case M.invalid_intersection_types:n="Intersection results could not be merged";break;case M.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case M.not_finite:n="Number must be finite";break;default:n=t.defaultError,he.assertNever(e)}return{message:n}};let _p=wo;function Cp(){return _p}const kp=e=>{const{data:t,path:n,errorMaps:r,issueData:s}=e,o=[...n,...s.path||[]],i={...s,path:o};if(s.message!==void 0)return{...s,path:o,message:s.message};let a="";const c=r.filter(l=>!!l).slice().reverse();for(const l of c)a=l(i,{data:t,defaultError:a}).message;return{...s,path:o,message:a}};function N(e,t){const n=Cp(),r=kp({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===wo?void 0:wo].filter(s=>!!s)});e.common.issues.push(r)}class qe{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){const r=[];for(const s of n){if(s.status==="aborted")return ee;s.status==="dirty"&&t.dirty(),r.push(s.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,n){const r=[];for(const s of n){const o=await s.key,i=await s.value;r.push({key:o,value:i})}return qe.mergeObjectSync(t,r)}static mergeObjectSync(t,n){const r={};for(const s of n){const{key:o,value:i}=s;if(o.status==="aborted"||i.status==="aborted")return ee;o.status==="dirty"&&t.dirty(),i.status==="dirty"&&t.dirty(),o.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(r[o.value]=i.value)}return{status:t.value,value:r}}}const ee=Object.freeze({status:"aborted"}),Zn=e=>({status:"dirty",value:e}),Qe=e=>({status:"valid",value:e}),Ea=e=>e.status==="aborted",Ra=e=>e.status==="dirty",Pn=e=>e.status==="valid",os=e=>typeof Promise<"u"&&e instanceof Promise;var V;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(V||(V={}));class $t{constructor(t,n,r,s){this._cachedPath=[],this.parent=t,this.data=n,this._path=r,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Oa=(e,t)=>{if(Pn(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new xt(e.common.issues);return this._error=n,this._error}}};function ae(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:r,description:s}=e;if(t&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:s}:{errorMap:(i,a)=>{const{message:c}=e;return i.code==="invalid_enum_value"?{message:c??a.defaultError}:typeof a.data>"u"?{message:c??r??a.defaultError}:i.code!=="invalid_type"?{message:a.defaultError}:{message:c??n??a.defaultError}},description:s}}class fe{get description(){return this._def.description}_getType(t){return It(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:It(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new qe,ctx:{common:t.parent.common,data:t.data,parsedType:It(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(os(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){const n=this._parse(t);return Promise.resolve(n)}parse(t,n){const r=this.safeParse(t,n);if(r.success)return r.data;throw r.error}safeParse(t,n){const r={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:It(t)},s=this._parseSync({data:t,path:r.path,parent:r});return Oa(r,s)}"~validate"(t){const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:It(t)};if(!this["~standard"].async)try{const r=this._parseSync({data:t,path:[],parent:n});return Pn(r)?{value:r.value}:{issues:n.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:n}).then(r=>Pn(r)?{value:r.value}:{issues:n.common.issues})}async parseAsync(t,n){const r=await this.safeParseAsync(t,n);if(r.success)return r.data;throw r.error}async safeParseAsync(t,n){const r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:It(t)},s=this._parse({data:t,path:r.path,parent:r}),o=await(os(s)?s:Promise.resolve(s));return Oa(r,o)}refine(t,n){const r=s=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(s):n;return this._refinement((s,o)=>{const i=t(s),a=()=>o.addIssue({code:M.custom,...r(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(t,n){return this._refinement((r,s)=>t(r)?!0:(s.addIssue(typeof n=="function"?n(r,s):n),!1))}_refinement(t){return new Tn({schema:this,typeName:te.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return Lt.create(this,this._def)}nullable(){return In.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ct.create(this)}promise(){return ls.create(this,this._def)}or(t){return as.create([this,t],this._def)}and(t){return cs.create(this,t,this._def)}transform(t){return new Tn({...ae(this._def),schema:this,typeName:te.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new _o({...ae(this._def),innerType:this,defaultValue:n,typeName:te.ZodDefault})}brand(){return new Hp({typeName:te.ZodBranded,type:this,...ae(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new Co({...ae(this._def),innerType:this,catchValue:n,typeName:te.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return gi.create(this,t)}readonly(){return ko.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Sp=/^c[^\s-]{8,}$/i,Ap=/^[0-9a-z]+$/,Ep=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Rp=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Op=/^[a-z0-9_-]{21}$/i,Pp=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Mp=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Tp=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ip="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let zs;const Np=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Dp=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,jp=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Fp=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Lp=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,$p=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,vl="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Bp=new RegExp(`^${vl}$`);function bl(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);const n=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function Kp(e){return new RegExp(`^${bl(e)}$`)}function zp(e){let t=`${vl}T${bl(e)}`;const n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function Vp(e,t){return!!((t==="v4"||!t)&&Np.test(e)||(t==="v6"||!t)&&jp.test(e))}function Up(e,t){if(!Pp.test(e))return!1;try{const[n]=e.split(".");if(!n)return!1;const r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),s=JSON.parse(atob(r));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||t&&s.alg!==t)}catch{return!1}}function qp(e,t){return!!((t==="v4"||!t)&&Dp.test(e)||(t==="v6"||!t)&&Fp.test(e))}class Yt extends fe{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==z.string){const o=this._getOrReturnCtx(t);return N(o,{code:M.invalid_type,expected:z.string,received:o.parsedType}),ee}const r=new qe;let s;for(const o of this._def.checks)if(o.kind==="min")t.data.lengtho.value&&(s=this._getOrReturnCtx(t,s),N(s,{code:M.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),r.dirty());else if(o.kind==="length"){const i=t.data.length>o.value,a=t.data.lengtht.test(s),{validation:n,code:M.invalid_string,...V.errToObj(r)})}_addCheck(t){return new Yt({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...V.errToObj(t)})}url(t){return this._addCheck({kind:"url",...V.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...V.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...V.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...V.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...V.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...V.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...V.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...V.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...V.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...V.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...V.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...V.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:t?.offset??!1,local:t?.local??!1,...V.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...V.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...V.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...V.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n?.position,...V.errToObj(n?.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...V.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...V.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...V.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...V.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...V.errToObj(n)})}nonempty(t){return this.min(1,V.errToObj(t))}trim(){return new Yt({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Yt({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Yt({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.valuenew Yt({checks:[],typeName:te.ZodString,coerce:e?.coerce??!1,...ae(e)});function Wp(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,s=n>r?n:r,o=Number.parseInt(e.toFixed(s).replace(".","")),i=Number.parseInt(t.toFixed(s).replace(".",""));return o%i/10**s}class ir extends fe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==z.number){const o=this._getOrReturnCtx(t);return N(o,{code:M.invalid_type,expected:z.number,received:o.parsedType}),ee}let r;const s=new qe;for(const o of this._def.checks)o.kind==="int"?he.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),N(r,{code:M.invalid_type,expected:"integer",received:"float",message:o.message}),s.dirty()):o.kind==="min"?(o.inclusive?t.datao.value:t.data>=o.value)&&(r=this._getOrReturnCtx(t,r),N(r,{code:M.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),s.dirty()):o.kind==="multipleOf"?Wp(t.data,o.value)!==0&&(r=this._getOrReturnCtx(t,r),N(r,{code:M.not_multiple_of,multipleOf:o.value,message:o.message}),s.dirty()):o.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),N(r,{code:M.not_finite,message:o.message}),s.dirty()):he.assertNever(o);return{status:s.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,V.toString(n))}gt(t,n){return this.setLimit("min",t,!1,V.toString(n))}lte(t,n){return this.setLimit("max",t,!0,V.toString(n))}lt(t,n){return this.setLimit("max",t,!1,V.toString(n))}setLimit(t,n,r,s){return new ir({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:V.toString(s)}]})}_addCheck(t){return new ir({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:V.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:V.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:V.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:V.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:V.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:V.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:V.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:V.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:V.toString(t)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.valuet.kind==="int"||t.kind==="multipleOf"&&he.isInteger(t.value))}get isFinite(){let t=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(t===null||r.valuenew ir({checks:[],typeName:te.ZodNumber,coerce:e?.coerce||!1,...ae(e)});class ar extends fe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==z.bigint)return this._getInvalidInput(t);let r;const s=new qe;for(const o of this._def.checks)o.kind==="min"?(o.inclusive?t.datao.value:t.data>=o.value)&&(r=this._getOrReturnCtx(t,r),N(r,{code:M.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),s.dirty()):o.kind==="multipleOf"?t.data%o.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),N(r,{code:M.not_multiple_of,multipleOf:o.value,message:o.message}),s.dirty()):he.assertNever(o);return{status:s.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return N(n,{code:M.invalid_type,expected:z.bigint,received:n.parsedType}),ee}gte(t,n){return this.setLimit("min",t,!0,V.toString(n))}gt(t,n){return this.setLimit("min",t,!1,V.toString(n))}lte(t,n){return this.setLimit("max",t,!0,V.toString(n))}lt(t,n){return this.setLimit("max",t,!1,V.toString(n))}setLimit(t,n,r,s){return new ar({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:V.toString(s)}]})}_addCheck(t){return new ar({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:V.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:V.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:V.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:V.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:V.toString(n)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.valuenew ar({checks:[],typeName:te.ZodBigInt,coerce:e?.coerce??!1,...ae(e)});class Pa extends fe{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==z.boolean){const r=this._getOrReturnCtx(t);return N(r,{code:M.invalid_type,expected:z.boolean,received:r.parsedType}),ee}return Qe(t.data)}}Pa.create=e=>new Pa({typeName:te.ZodBoolean,coerce:e?.coerce||!1,...ae(e)});class is extends fe{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==z.date){const o=this._getOrReturnCtx(t);return N(o,{code:M.invalid_type,expected:z.date,received:o.parsedType}),ee}if(Number.isNaN(t.data.getTime())){const o=this._getOrReturnCtx(t);return N(o,{code:M.invalid_date}),ee}const r=new qe;let s;for(const o of this._def.checks)o.kind==="min"?t.data.getTime()o.value&&(s=this._getOrReturnCtx(t,s),N(s,{code:M.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),r.dirty()):he.assertNever(o);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new is({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:V.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:V.toString(n)})}get minDate(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.valuenew is({checks:[],coerce:e?.coerce||!1,typeName:te.ZodDate,...ae(e)});class Ma extends fe{_parse(t){if(this._getType(t)!==z.symbol){const r=this._getOrReturnCtx(t);return N(r,{code:M.invalid_type,expected:z.symbol,received:r.parsedType}),ee}return Qe(t.data)}}Ma.create=e=>new Ma({typeName:te.ZodSymbol,...ae(e)});class Ta extends fe{_parse(t){if(this._getType(t)!==z.undefined){const r=this._getOrReturnCtx(t);return N(r,{code:M.invalid_type,expected:z.undefined,received:r.parsedType}),ee}return Qe(t.data)}}Ta.create=e=>new Ta({typeName:te.ZodUndefined,...ae(e)});class Ia extends fe{_parse(t){if(this._getType(t)!==z.null){const r=this._getOrReturnCtx(t);return N(r,{code:M.invalid_type,expected:z.null,received:r.parsedType}),ee}return Qe(t.data)}}Ia.create=e=>new Ia({typeName:te.ZodNull,...ae(e)});class cr extends fe{constructor(){super(...arguments),this._any=!0}_parse(t){return Qe(t.data)}}cr.create=e=>new cr({typeName:te.ZodAny,...ae(e)});class Na extends fe{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Qe(t.data)}}Na.create=e=>new Na({typeName:te.ZodUnknown,...ae(e)});class Bt extends fe{_parse(t){const n=this._getOrReturnCtx(t);return N(n,{code:M.invalid_type,expected:z.never,received:n.parsedType}),ee}}Bt.create=e=>new Bt({typeName:te.ZodNever,...ae(e)});class Da extends fe{_parse(t){if(this._getType(t)!==z.undefined){const r=this._getOrReturnCtx(t);return N(r,{code:M.invalid_type,expected:z.void,received:r.parsedType}),ee}return Qe(t.data)}}Da.create=e=>new Da({typeName:te.ZodVoid,...ae(e)});class ct extends fe{_parse(t){const{ctx:n,status:r}=this._processInputParams(t),s=this._def;if(n.parsedType!==z.array)return N(n,{code:M.invalid_type,expected:z.array,received:n.parsedType}),ee;if(s.exactLength!==null){const i=n.data.length>s.exactLength.value,a=n.data.lengths.maxLength.value&&(N(n,{code:M.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((i,a)=>s.type._parseAsync(new $t(n,i,n.path,a)))).then(i=>qe.mergeArray(r,i));const o=[...n.data].map((i,a)=>s.type._parseSync(new $t(n,i,n.path,a)));return qe.mergeArray(r,o)}get element(){return this._def.type}min(t,n){return new ct({...this._def,minLength:{value:t,message:V.toString(n)}})}max(t,n){return new ct({...this._def,maxLength:{value:t,message:V.toString(n)}})}length(t,n){return new ct({...this._def,exactLength:{value:t,message:V.toString(n)}})}nonempty(t){return this.min(1,t)}}ct.create=(e,t)=>new ct({type:e,minLength:null,maxLength:null,exactLength:null,typeName:te.ZodArray,...ae(t)});function bn(e){if(e instanceof Re){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=Lt.create(bn(r))}return new Re({...e._def,shape:()=>t})}else return e instanceof ct?new ct({...e._def,type:bn(e.element)}):e instanceof Lt?Lt.create(bn(e.unwrap())):e instanceof In?In.create(bn(e.unwrap())):e instanceof rn?rn.create(e.items.map(t=>bn(t))):e}class Re extends fe{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),n=he.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==z.object){const l=this._getOrReturnCtx(t);return N(l,{code:M.invalid_type,expected:z.object,received:l.parsedType}),ee}const{status:r,ctx:s}=this._processInputParams(t),{shape:o,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof Bt&&this._def.unknownKeys==="strip"))for(const l in s.data)i.includes(l)||a.push(l);const c=[];for(const l of i){const u=o[l],d=s.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new $t(s,d,s.path,l)),alwaysSet:l in s.data})}if(this._def.catchall instanceof Bt){const l=this._def.unknownKeys;if(l==="passthrough")for(const u of a)c.push({key:{status:"valid",value:u},value:{status:"valid",value:s.data[u]}});else if(l==="strict")a.length>0&&(N(s,{code:M.unrecognized_keys,keys:a}),r.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const u of a){const d=s.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new $t(s,d,s.path,u)),alwaysSet:u in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const l=[];for(const u of c){const d=await u.key,f=await u.value;l.push({key:d,value:f,alwaysSet:u.alwaysSet})}return l}).then(l=>qe.mergeObjectSync(r,l)):qe.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(t){return V.errToObj,new Re({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,r)=>{const s=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:V.errToObj(t).message??s}:{message:s}}}:{}})}strip(){return new Re({...this._def,unknownKeys:"strip"})}passthrough(){return new Re({...this._def,unknownKeys:"passthrough"})}extend(t){return new Re({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new Re({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:te.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new Re({...this._def,catchall:t})}pick(t){const n={};for(const r of he.objectKeys(t))t[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new Re({...this._def,shape:()=>n})}omit(t){const n={};for(const r of he.objectKeys(this.shape))t[r]||(n[r]=this.shape[r]);return new Re({...this._def,shape:()=>n})}deepPartial(){return bn(this)}partial(t){const n={};for(const r of he.objectKeys(this.shape)){const s=this.shape[r];t&&!t[r]?n[r]=s:n[r]=s.optional()}return new Re({...this._def,shape:()=>n})}required(t){const n={};for(const r of he.objectKeys(this.shape))if(t&&!t[r])n[r]=this.shape[r];else{let o=this.shape[r];for(;o instanceof Lt;)o=o._def.innerType;n[r]=o}return new Re({...this._def,shape:()=>n})}keyof(){return wl(he.objectKeys(this.shape))}}Re.create=(e,t)=>new Re({shape:()=>e,unknownKeys:"strip",catchall:Bt.create(),typeName:te.ZodObject,...ae(t)});Re.strictCreate=(e,t)=>new Re({shape:()=>e,unknownKeys:"strict",catchall:Bt.create(),typeName:te.ZodObject,...ae(t)});Re.lazycreate=(e,t)=>new Re({shape:e,unknownKeys:"strip",catchall:Bt.create(),typeName:te.ZodObject,...ae(t)});class as extends fe{_parse(t){const{ctx:n}=this._processInputParams(t),r=this._def.options;function s(o){for(const a of o)if(a.result.status==="valid")return a.result;for(const a of o)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;const i=o.map(a=>new xt(a.ctx.common.issues));return N(n,{code:M.invalid_union,unionErrors:i}),ee}if(n.common.async)return Promise.all(r.map(async o=>{const i={...n,common:{...n.common,issues:[]},parent:null};return{result:await o._parseAsync({data:n.data,path:n.path,parent:i}),ctx:i}})).then(s);{let o;const i=[];for(const c of r){const l={...n,common:{...n.common,issues:[]},parent:null},u=c._parseSync({data:n.data,path:n.path,parent:l});if(u.status==="valid")return u;u.status==="dirty"&&!o&&(o={result:u,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(o)return n.common.issues.push(...o.ctx.common.issues),o.result;const a=i.map(c=>new xt(c));return N(n,{code:M.invalid_union,unionErrors:a}),ee}}get options(){return this._def.options}}as.create=(e,t)=>new as({options:e,typeName:te.ZodUnion,...ae(t)});function xo(e,t){const n=It(e),r=It(t);if(e===t)return{valid:!0,data:e};if(n===z.object&&r===z.object){const s=he.objectKeys(t),o=he.objectKeys(e).filter(a=>s.indexOf(a)!==-1),i={...e,...t};for(const a of o){const c=xo(e[a],t[a]);if(!c.valid)return{valid:!1};i[a]=c.data}return{valid:!0,data:i}}else if(n===z.array&&r===z.array){if(e.length!==t.length)return{valid:!1};const s=[];for(let o=0;o{if(Ea(o)||Ea(i))return ee;const a=xo(o.value,i.value);return a.valid?((Ra(o)||Ra(i))&&n.dirty(),{status:n.value,value:a.data}):(N(r,{code:M.invalid_intersection_types}),ee)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([o,i])=>s(o,i)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}cs.create=(e,t,n)=>new cs({left:e,right:t,typeName:te.ZodIntersection,...ae(n)});class rn extends fe{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==z.array)return N(r,{code:M.invalid_type,expected:z.array,received:r.parsedType}),ee;if(r.data.lengththis._def.items.length&&(N(r,{code:M.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const o=[...r.data].map((i,a)=>{const c=this._def.items[a]||this._def.rest;return c?c._parse(new $t(r,i,r.path,a)):null}).filter(i=>!!i);return r.common.async?Promise.all(o).then(i=>qe.mergeArray(n,i)):qe.mergeArray(n,o)}get items(){return this._def.items}rest(t){return new rn({...this._def,rest:t})}}rn.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new rn({items:e,typeName:te.ZodTuple,rest:null,...ae(t)})};class ja extends fe{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==z.map)return N(r,{code:M.invalid_type,expected:z.map,received:r.parsedType}),ee;const s=this._def.keyType,o=this._def.valueType,i=[...r.data.entries()].map(([a,c],l)=>({key:s._parse(new $t(r,a,r.path,[l,"key"])),value:o._parse(new $t(r,c,r.path,[l,"value"]))}));if(r.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const c of i){const l=await c.key,u=await c.value;if(l.status==="aborted"||u.status==="aborted")return ee;(l.status==="dirty"||u.status==="dirty")&&n.dirty(),a.set(l.value,u.value)}return{status:n.value,value:a}})}else{const a=new Map;for(const c of i){const l=c.key,u=c.value;if(l.status==="aborted"||u.status==="aborted")return ee;(l.status==="dirty"||u.status==="dirty")&&n.dirty(),a.set(l.value,u.value)}return{status:n.value,value:a}}}}ja.create=(e,t,n)=>new ja({valueType:t,keyType:e,typeName:te.ZodMap,...ae(n)});class lr extends fe{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==z.set)return N(r,{code:M.invalid_type,expected:z.set,received:r.parsedType}),ee;const s=this._def;s.minSize!==null&&r.data.sizes.maxSize.value&&(N(r,{code:M.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),n.dirty());const o=this._def.valueType;function i(c){const l=new Set;for(const u of c){if(u.status==="aborted")return ee;u.status==="dirty"&&n.dirty(),l.add(u.value)}return{status:n.value,value:l}}const a=[...r.data.values()].map((c,l)=>o._parse(new $t(r,c,r.path,l)));return r.common.async?Promise.all(a).then(c=>i(c)):i(a)}min(t,n){return new lr({...this._def,minSize:{value:t,message:V.toString(n)}})}max(t,n){return new lr({...this._def,maxSize:{value:t,message:V.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}lr.create=(e,t)=>new lr({valueType:e,minSize:null,maxSize:null,typeName:te.ZodSet,...ae(t)});class Fa extends fe{get schema(){return this._def.getter()}_parse(t){const{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}Fa.create=(e,t)=>new Fa({getter:e,typeName:te.ZodLazy,...ae(t)});class La extends fe{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return N(n,{received:n.data,code:M.invalid_literal,expected:this._def.value}),ee}return{status:"valid",value:t.data}}get value(){return this._def.value}}La.create=(e,t)=>new La({value:e,typeName:te.ZodLiteral,...ae(t)});function wl(e,t){return new Mn({values:e,typeName:te.ZodEnum,...ae(t)})}class Mn extends fe{_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),r=this._def.values;return N(n,{expected:he.joinValues(r),received:n.parsedType,code:M.invalid_type}),ee}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const n=this._getOrReturnCtx(t),r=this._def.values;return N(n,{received:n.data,code:M.invalid_enum_value,options:r}),ee}return Qe(t.data)}get options(){return this._def.values}get enum(){const t={};for(const n of this._def.values)t[n]=n;return t}get Values(){const t={};for(const n of this._def.values)t[n]=n;return t}get Enum(){const t={};for(const n of this._def.values)t[n]=n;return t}extract(t,n=this._def){return Mn.create(t,{...this._def,...n})}exclude(t,n=this._def){return Mn.create(this.options.filter(r=>!t.includes(r)),{...this._def,...n})}}Mn.create=wl;class $a extends fe{_parse(t){const n=he.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==z.string&&r.parsedType!==z.number){const s=he.objectValues(n);return N(r,{expected:he.joinValues(s),received:r.parsedType,code:M.invalid_type}),ee}if(this._cache||(this._cache=new Set(he.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const s=he.objectValues(n);return N(r,{received:r.data,code:M.invalid_enum_value,options:s}),ee}return Qe(t.data)}get enum(){return this._def.values}}$a.create=(e,t)=>new $a({values:e,typeName:te.ZodNativeEnum,...ae(t)});class ls extends fe{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==z.promise&&n.common.async===!1)return N(n,{code:M.invalid_type,expected:z.promise,received:n.parsedType}),ee;const r=n.parsedType===z.promise?n.data:Promise.resolve(n.data);return Qe(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}}ls.create=(e,t)=>new ls({type:e,typeName:te.ZodPromise,...ae(t)});class Tn extends fe{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===te.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:n,ctx:r}=this._processInputParams(t),s=this._def.effect||null,o={addIssue:i=>{N(r,i),i.fatal?n.abort():n.dirty()},get path(){return r.path}};if(o.addIssue=o.addIssue.bind(o),s.type==="preprocess"){const i=s.transform(r.data,o);if(r.common.async)return Promise.resolve(i).then(async a=>{if(n.value==="aborted")return ee;const c=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return c.status==="aborted"?ee:c.status==="dirty"||n.value==="dirty"?Zn(c.value):c});{if(n.value==="aborted")return ee;const a=this._def.schema._parseSync({data:i,path:r.path,parent:r});return a.status==="aborted"?ee:a.status==="dirty"||n.value==="dirty"?Zn(a.value):a}}if(s.type==="refinement"){const i=a=>{const c=s.refinement(a,o);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?ee:(a.status==="dirty"&&n.dirty(),i(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?ee:(a.status==="dirty"&&n.dirty(),i(a.value).then(()=>({status:n.value,value:a.value}))))}if(s.type==="transform")if(r.common.async===!1){const i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Pn(i))return ee;const a=s.transform(i.value,o);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(i=>Pn(i)?Promise.resolve(s.transform(i.value,o)).then(a=>({status:n.value,value:a})):ee);he.assertNever(s)}}Tn.create=(e,t,n)=>new Tn({schema:e,typeName:te.ZodEffects,effect:t,...ae(n)});Tn.createWithPreprocess=(e,t,n)=>new Tn({schema:t,effect:{type:"preprocess",transform:e},typeName:te.ZodEffects,...ae(n)});class Lt extends fe{_parse(t){return this._getType(t)===z.undefined?Qe(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}Lt.create=(e,t)=>new Lt({innerType:e,typeName:te.ZodOptional,...ae(t)});class In extends fe{_parse(t){return this._getType(t)===z.null?Qe(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}In.create=(e,t)=>new In({innerType:e,typeName:te.ZodNullable,...ae(t)});class _o extends fe{_parse(t){const{ctx:n}=this._processInputParams(t);let r=n.data;return n.parsedType===z.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}_o.create=(e,t)=>new _o({innerType:e,typeName:te.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...ae(t)});class Co extends fe{_parse(t){const{ctx:n}=this._processInputParams(t),r={...n,common:{...n.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return os(s)?s.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new xt(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new xt(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}Co.create=(e,t)=>new Co({innerType:e,typeName:te.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...ae(t)});class Ba extends fe{_parse(t){if(this._getType(t)!==z.nan){const r=this._getOrReturnCtx(t);return N(r,{code:M.invalid_type,expected:z.nan,received:r.parsedType}),ee}return{status:"valid",value:t.data}}}Ba.create=e=>new Ba({typeName:te.ZodNaN,...ae(e)});class Hp extends fe{_parse(t){const{ctx:n}=this._processInputParams(t),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class gi extends fe{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{const o=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?ee:o.status==="dirty"?(n.dirty(),Zn(o.value)):this._def.out._parseAsync({data:o.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?ee:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(t,n){return new gi({in:t,out:n,typeName:te.ZodPipeline})}}class ko extends fe{_parse(t){const n=this._def.innerType._parse(t),r=s=>(Pn(s)&&(s.value=Object.freeze(s.value)),s);return os(n)?n.then(s=>r(s)):r(n)}unwrap(){return this._def.innerType}}ko.create=(e,t)=>new ko({innerType:e,typeName:te.ZodReadonly,...ae(t)});function Ka(e,t){const n=typeof e=="function"?e(t):typeof e=="string"?{message:e}:e;return typeof n=="string"?{message:n}:n}function xl(e,t={},n){return e?cr.create().superRefine((r,s)=>{const o=e(r);if(o instanceof Promise)return o.then(i=>{if(!i){const a=Ka(t,r),c=a.fatal??n??!0;s.addIssue({code:"custom",...a,fatal:c})}});if(!o){const i=Ka(t,r),a=i.fatal??n??!0;s.addIssue({code:"custom",...i,fatal:a})}}):cr.create()}var te;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(te||(te={}));cr.create;Bt.create;ct.create;as.create;cs.create;rn.create;const Zp=Mn.create;ls.create;Lt.create;In.create;const _l={"SHA-256":"sha256-","SHA-384":"sha384-","SHA-512":"sha512-"},Gp=Object.values(_l);Zp(Object.keys(_l)).optional().default("SHA-256");xl(e=>typeof e!="string"?!1:Gp.some(t=>e.startsWith(t)));const Qp=["base-uri","child-src","connect-src","default-src","fenced-frame-src","font-src","form-action","frame-ancestors","frame-src","img-src","manifest-src","media-src","object-src","referrer","report-to","report-uri","require-trusted-types-for","sandbox","trusted-types","upgrade-insecure-requests","worker-src"];xl(e=>typeof e!="string"?!1:Qp.some(t=>e.startsWith(t)));new TextEncoder;new TextDecoder;const Cl=Symbol.for("astro.renderTemplateResult");class Yp{[Cl]=!0;htmlParts;expressions;error;constructor(t,n){this.htmlParts=t,this.error=void 0,this.expressions=n.map(r=>On(r)?Promise.resolve(r).catch(s=>{if(!this.error)throw this.error=s,s}):r)}render(t){const n=this.expressions.map(o=>yl(t,i=>{if(o||o===0)return Nn(i,o)}));let r=0;const s=()=>{for(;rserver-island-starte.trim()).filter(e=>e&&!e.startsWith("//")).join(" "));new TextEncoder;new TextDecoder;function tm(e){return!!e&&typeof e=="object"&&"render"in e&&typeof e.render=="function"}function Nn(e,t){if(On(t))return t.then(n=>Nn(e,n));if(t instanceof em){e.write(t);return}if(lp(t)){e.write(t);return}if(Array.isArray(t))return nm(e,t);if(typeof t=="function")return Nn(e,t());if(!(!t&&t!==0)){if(typeof t=="string"){e.write(Le(cp(t)));return}if(tm(t)||Xp(t)||im(t))return t.render(e);if(ArrayBuffer.isView(t)){e.write(t);return}if(typeof t=="object"&&(Symbol.asyncIterator in t||Symbol.iterator in t))return Symbol.asyncIterator in t?sm(e,t):rm(e,t);e.write(t)}}function nm(e,t){const r=t.map(o=>yl(e,i=>Nn(i,o)))[Symbol.iterator](),s=()=>{for(;;){const{value:o,done:i}=r.next();if(i)break;const a=o.flush();if(On(a))return a.then(s)}};return s()}function rm(e,t){const n=t[Symbol.iterator](),r=()=>{for(;;){const{value:s,done:o}=n.next();if(o)break;const i=Nn(e,s);if(On(i))return i.then(r)}};return r()}async function sm(e,t){for await(const n of t)await Nn(e,n)}const om=Symbol.for("astro.componentInstance");function im(e){return typeof e=="object"&&e!==null&&!!e[om]}/*! https://mths.be/cssesc v3.0.0 by @mathias */var Vs,Va;function am(){if(Va)return Vs;Va=1;var e={},t=e.hasOwnProperty,n=function(c,l){if(!c)return l;var u={};for(var d in l)u[d]=t.call(c,d)?c[d]:l[d];return u},r=/[ -,\.\/:-@\[-\^`\{-~]/,s=/[ -,\.\/:-@\[\]\^`\{-~]/,o=/(^|\\+)?(\\[A-F0-9]{1,6})\x20(?![a-fA-F0-9\x20])/g,i=function a(c,l){l=n(l,a.options),l.quotes!="single"&&l.quotes!="double"&&(l.quotes="single");for(var u=l.quotes=="double"?'"':"'",d=l.isIdentifier,f=c.charAt(0),m="",y=0,h=c.length;y126){if(b>=55296&&b<=56319&&y(e[t.charCodeAt(0)]=t,e),[]);"-0123456789_".split("").reduce((e,t)=>(e[t.charCodeAt(0)]=t,e),[]);function cm(e={},t,{class:n}={}){let r="";n&&(typeof e.class<"u"?e.class+=` ${n}`:typeof e["class:list"]<"u"?e["class:list"]=[e["class:list"],n]:e.class=n);for(const[s,o]of Object.entries(e))r+=yp(o,s,!0,t);return Le(r)}function lm({meta:e,attributes:t,children:n}){const r=np((s,o)=>{const i=hm(t,o);return Jp`${up(n)}`});return Object.defineProperty(r,"toJSON",{value:()=>e,enumerable:!1}),Object.assign(r,e)}const um=["xmlns","xmlns:xlink","version"],dm={};function fm(e){for(const t of um)delete e[t];return e}function hm(e,t){return fm({...dm,...e,...t})}const xn=lm({meta:{src:"/_astro/dolphin.DrilHqr_.svg",width:512,height:512,format:"svg"},attributes:{width:"512",height:"512"},children:` `});function us(e){if(typeof e=="string")return e;if(Array.isArray(e))return e.map(s=>us(s)).filter(Boolean).join(` `);if(!e||typeof e!="object")return"";const t=e.text;if(typeof t=="string")return t;const n=e.content;if(typeof n=="string")return n;if(Array.isArray(n))return us(n);const r=e.value;return typeof r=="string"?r:""}function Xn(e){const t={content:e||"",reasoning:""},n=(e||"").trim();if(!n.startsWith("{")&&!n.startsWith("["))return t;try{const r=JSON.parse(n),s=r?.choices?.[0]?.message??r?.message??null;if(!s||typeof s!="object")return t;const o=us(s.content),i=us(s.reasoning??s.reasoning_content);return{content:o||"",reasoning:i||""}}catch{return t}}function pm(e){const t=e.split(/\r?\n/),n=[];let r=!1;const s=a=>{if(!a||!/\S/.test(a)||a.includes("|"))return null;const c=a.split(/\t+|\s{2,}/).map(l=>l.trim()).filter(Boolean);return c.length<3?null:c},o=a=>{if(a.length<2){a.forEach(m=>n.push(m.join(" ")));return}const c=Math.max(...a.map(m=>m.length)),l=a.map(m=>{if(m.length===c)return m;const y=[...m];for(;y.lengthn.push(`| ${m.join(" | ")} |`)),n.push("")};let i=null;for(let a=0;a0&&(o(i),i=null),r=!0,n.push(c);continue}else if(r&&l){r=!1,n.push(c);continue}if(!r){const u=c.match(/^(\s{4,}|\t+)(.*)$/);if(u){const y=u[1].replace(/\t/g," ").slice(0,3);n.push(`${y}${u[2]}`);continue}const d=c.match(/^(\s*>+\s*)(\s{4,}|\t+)(.*)$/);if(d){const y=d[2].replace(/\t/g," ").slice(0,3);n.push(`${d[1]}${y}${d[3]}`);continue}const f=s(c);if(f){i||(i=[]),i.push(f);continue}else if(i&&c.trim()===""){o(i),i=null,n.push(c);continue}else i&&(o(i),i=null);if(/^(\s{0,3})([-*+]\s+|\d+[.)]\s+)/.test(c)){let y=n.length-1;for(;y>=0&&n[y].trim()==="";)y--;y>=0&&n[y].trim()!==""&&n.push("")}if(/^\s*-{3,}\s*$/.test(c)){n.push(c);continue}}n.push(c)}return i&&i.length>0&&(o(i),i=null),r&&(n.push("```"),r=!1),n.join(` `)}function jt(e){return e?e.replace(/[\s\S]*?<\/think>/gi,"").replace(/[\s\S]*?<\/think-block>/gi,""):""}function ds(e){const t=Xn(e||""),r=pm(jt(t.content||"")).split(/\r?\n/),s=(()=>{let c=0;for(;c{let c=s.length-1;for(;c>=0&&s[c].trim()==="";)c--;return s.slice(0,c+1)})(),i=[];let a=!1;for(const c of o){const l=c.trim()==="";l&&a||(i.push(c),a=l)}return i.join(` `)}const mm="_assistantContainer_k8s6m_1",gm="_userTurn_k8s6m_24",ym="_messageContent_k8s6m_26",vm="_streaming_k8s6m_31",bm="_dolphinIcon_k8s6m_35",wm="_typingCaret_k8s6m_40",xm="_scrollContainer_k8s6m_58",Xe={assistantContainer:mm,userTurn:gm,messageContent:ym,streaming:vm,dolphinIcon:bm,typingCaret:wm,scrollContainer:xm},_m=st.lazy(()=>mi(()=>import("./MarkdownRenderer.D6rEEnku.js"),__vite__mapDeps([0,1,2,3,4])).then(e=>({default:e.default||e.MarkdownRenderer}))),Cm=({id:e,data:t,models:n,onRegenerate:r,onDelete:s,onSwipeChange:o,autoScroll:i})=>{const[a,c]=p.useState(!1),{role:l,model:u,isStreaming:d}=t,{content:f,reasoning:m}=p.useMemo(()=>{if(t.content&&t.content.trim().length>0)return{content:t.content,reasoning:t.reasoning||""};const b=Array.isArray(t.variants)?t.variants:[];if(b.length>0){const w=typeof t.activeVariantIndex=="number"&&b.length>0?Math.min(Math.max(0,t.activeVariantIndex),b.length-1):b.length-1;return{content:b[w]?.content||t.content||"",reasoning:b[w]?.reasoning||t.reasoning||""}}return{content:t.content||"",reasoning:t.reasoning||""}},[t]),y=p.useMemo(()=>u?n.find(w=>w.id===u)?.label||u:"Dolphin",[u,n]),h=p.useRef(null),v=p.useMemo(()=>ds(f),[f]);return p.useEffect(()=>{if(!i)return;const b=document.querySelector("[data-chat-scroller]");b?b.scrollTop=b.scrollHeight:h.current&&h.current.scrollIntoView({block:"end"})},[f,i]),l==="user"?g.jsx("div",{className:"bg-glass rounded-lg p-4 mb-8 text-end prose prose-invert prose-p:my-2",children:g.jsx("p",{children:f})}):g.jsxs("div",{className:"flex items-start md:gap-4 gap-0 mb-8",children:[g.jsx("div",{className:"hidden md:block w-12 h-12 flex-shrink-0",children:g.jsx("img",{src:xn.src,alt:"Dolphin",width:xn.width,height:xn.height,className:Xe.dolphinIcon})}),g.jsxs("div",{className:`${Xe.assistantContainer} prose prose-invert prose-p:my-2 prose-strong:text-sidebar-foreground flex-1 min-w-0`,children:[g.jsx("p",{children:g.jsx("strong",{children:y})}),g.jsx("div",{ref:h,className:`${Xe.messageContent} ${d?Xe.streaming:""}`,children:g.jsx(p.Suspense,{fallback:g.jsx("div",{className:"opacity-70",children:"Rendering…"}),children:g.jsx(_m,{content:f,reasoning:m})})}),!d&&g.jsxs("div",{className:"flex items-center gap-4 mt-4 text-muted-foreground fade-in",children:[g.jsxs("button",{type:"button","aria-label":"Copy",onClick:async()=>{const b=v||(h.current?.innerText?ds(h.current.innerText):"");await navigator.clipboard.writeText(b),c(!0),setTimeout(()=>c(!1),700)},className:`relative p-0.5 rounded transition-transform cursor-pointer ${a?"scale-110":""}`,children:[g.jsx(hl,{size:18,className:"transition-transform"}),a&&g.jsx("span",{className:"absolute -top-4 left-1/2 -translate-x-1/2 text-[10px] opacity-80",children:"copied"})]}),g.jsx(pl,{size:18,className:"cursor-pointer hover:text-white transition-colors",onClick:()=>r?.(e),"aria-label":"Regenerate"}),g.jsx(pi,{size:18,className:"cursor-pointer hover:text-white transition-colors",onClick:()=>s?.(e),"aria-label":"Delete"}),Array.isArray(t.variants)&&t.variants.length>1&&g.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[g.jsx("button",{type:"button",className:"p-0.5 rounded hover:text-white disabled:opacity-40",onClick:()=>{const b=typeof t.activeVariantIndex=="number"?t.activeVariantIndex:t.variants.length-1,w=Math.max(0,b-1);o?.(e,w)},disabled:(typeof t.activeVariantIndex=="number"?t.activeVariantIndex:t.variants.length-1)<=0,"aria-label":"Previous variant",children:g.jsx(dl,{size:16})}),g.jsxs("span",{className:"tabular-nums opacity-80",children:[typeof t.activeVariantIndex=="number"?t.activeVariantIndex+1:t.variants.length,"/",t.variants.length]}),g.jsx("button",{type:"button",className:"p-0.5 rounded hover:text-white disabled:opacity-40",onClick:()=>{const b=typeof t.activeVariantIndex=="number"?t.activeVariantIndex:t.variants.length-1,w=Math.min(t.variants.length-1,b+1);o?.(e,w)},disabled:(typeof t.activeVariantIndex=="number"?t.activeVariantIndex:t.variants.length-1)>=t.variants.length-1,"aria-label":"Next variant",children:g.jsx(fl,{size:16})})]})]})]})]})},km=st.lazy(()=>mi(()=>import("./MarkdownRenderer.D6rEEnku.js"),__vite__mapDeps([0,1,2,3,4])).then(e=>({default:e.default||e.MarkdownRenderer}))),Sm=({id:e,data:t,models:n,onStreamComplete:r,onRegenerate:s,onDelete:o,onSwipeChange:i,autoScroll:a})=>{const c=p.useRef(null),l=p.useRef(null),{content:u,reasoning:d,model:f,isStreaming:m}=t,y=f?n.find(T=>T.id===f)?.label||f:"Dolphin",[h,v]=p.useState(!1),b=ds(u||""),w=p.useRef(!!m),x=p.useRef(null),_=p.useRef(null),C=p.useRef(!0),S=p.useRef(null),k=()=>{if(x.current&&document.body.contains(x.current))return x.current;const R=document.querySelector("[data-chat-scroller]");return x.current=R,R},A=()=>{const R=k();if(!R){l.current&&l.current.scrollIntoView({block:"end"});return}S.current!=null&&cancelAnimationFrame(S.current),S.current=requestAnimationFrame(()=>{R.scrollTop=R.scrollHeight,S.current=null})},O=()=>{const R=k();return R?R.scrollHeight-R.scrollTop-R.clientHeight<=120:!0};return p.useEffect(()=>{if(!a)return;const R=O();C.current=R,R&&A()},[u,a]),p.useEffect(()=>{const R=w.current,T=!!m;R&&!T&&(a&&A(),r?.()),w.current=T},[m,r,a]),p.useEffect(()=>{if(!a)return;const R=k();if(!R)return;const T=()=>{C.current=O()};R.addEventListener("scroll",T,{passive:!0});const q=R.firstElementChild||null;_.current=q;let H=null;return q&&(H=new ResizeObserver(()=>{C.current&&A()}),H.observe(q)),()=>{R.removeEventListener("scroll",T),H&&q&&H.unobserve(q),S.current!=null&&cancelAnimationFrame(S.current)}},[a]),p.useEffect(()=>{if(!a)return;const R=c.current;if(!R)return;const T=new MutationObserver(()=>{C.current&&A()});return T.observe(R,{childList:!0,subtree:!0,characterData:!0}),()=>T.disconnect()},[a]),g.jsxs("div",{className:"flex items-start md:gap-4 gap-0 mb-8",children:[g.jsx("div",{className:"hidden md:block w-12 h-12 flex-shrink-0",children:g.jsx("img",{src:xn.src,alt:"Dolphin",width:xn.width,height:xn.height,className:Xe.dolphinIcon})}),g.jsxs("div",{className:`${Xe.assistantContainer} prose prose-invert prose-p:my-2 prose-strong:text-sidebar-foreground flex-1 min-w-0`,children:[g.jsx("p",{children:g.jsx("strong",{children:y})}),g.jsxs("div",{ref:c,className:`${Xe.messageContent} ${Xe.streaming}`,children:[g.jsx(p.Suspense,{fallback:g.jsx("div",{className:"opacity-70",children:"Rendering…"}),children:g.jsx(km,{content:u||"",reasoning:d,streaming:!!m})}),m&&(!u||u.trim().length===0)&&g.jsx("span",{className:Xe.typingCaret}),g.jsx("span",{ref:l})]}),!m&&g.jsxs("div",{className:"flex items-center gap-4 mt-4 text-muted-foreground fade-in",children:[g.jsxs("button",{type:"button","aria-label":"Copy",onClick:async()=>{const R=b||(c.current?.innerText?ds(c.current.innerText):"");await navigator.clipboard.writeText(R),v(!0),setTimeout(()=>v(!1),700)},className:`relative p-0.5 rounded transition-transform cursor-pointer ${h?"scale-110":""}`,children:[g.jsx(hl,{size:18,className:"transition-transform"}),h&&g.jsx("span",{className:"absolute -top-4 left-1/2 -translate-x-1/2 text-[10px] opacity-80",children:"copied"})]}),g.jsx(pl,{size:18,className:"cursor-pointer hover:text-white transition-colors",onClick:()=>s?.(e),"aria-label":"Regenerate"}),g.jsx(pi,{size:18,className:"cursor-pointer hover:text-white transition-colors",onClick:()=>o?.(e),"aria-label":"Delete"}),Array.isArray(t.variants)&&t.variants.length>1&&g.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[g.jsx("button",{type:"button",className:"p-0.5 rounded hover:text-white disabled:opacity-40",onClick:()=>{const R=typeof t.activeVariantIndex=="number"?t.activeVariantIndex:t.variants.length-1,T=Math.max(0,R-1);i?.(e,T)},disabled:(typeof t.activeVariantIndex=="number"?t.activeVariantIndex:t.variants.length-1)<=0,"aria-label":"Previous variant",children:g.jsx(dl,{size:16})}),g.jsxs("span",{className:"tabular-nums opacity-80",children:[typeof t.activeVariantIndex=="number"?t.activeVariantIndex+1:t.variants.length,"/",t.variants.length]}),g.jsx("button",{type:"button",className:"p-0.5 rounded hover:text-white disabled:opacity-40",onClick:()=>{const R=typeof t.activeVariantIndex=="number"?t.activeVariantIndex:t.variants.length-1,T=Math.min(t.variants.length-1,R+1);i?.(e,T)},disabled:(typeof t.activeVariantIndex=="number"?t.activeVariantIndex:t.variants.length-1)>=t.variants.length-1,"aria-label":"Next variant",children:g.jsx(fl,{size:16})})]})]}),!m&&Array.isArray(t.variants)&&t.variants.length>1&&g.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[g.jsx("button",{type:"button",className:"px-2 py-1 text-xs rounded bg-white/10 hover:bg-white/15 border border-white/10",onClick:()=>{const R=typeof t.activeVariantIndex=="number"?t.activeVariantIndex:t.variants.length-1,T=Math.max(0,R-1);i?.(e,T)},"aria-label":"Previous variant",children:"Prev"}),g.jsx("div",{className:"flex items-center gap-1",children:t.variants.map((R,T)=>{const q=(typeof t.activeVariantIndex=="number"?t.activeVariantIndex:t.variants.length-1)===T;return g.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${q?"bg-white":"bg-white/40"}`},T)})}),g.jsx("button",{type:"button",className:"px-2 py-1 text-xs rounded bg-white/10 hover:bg-white/15 border border-white/10",onClick:()=>{const R=typeof t.activeVariantIndex=="number"?t.activeVariantIndex:t.variants.length-1,T=Math.min(t.variants.length-1,R+1);i?.(e,T)},"aria-label":"Next variant",children:"Next"})]})]})]})},Am=st.lazy(()=>mi(()=>import("./MarkdownRenderer.D6rEEnku.js"),__vite__mapDeps([0,1,2,3,4])).then(e=>({default:e.default||e.MarkdownRenderer}))),Em=({items:e,models:t,onStreamComplete:n,onRegenerate:r,onDelete:s,onSwipeChange:o})=>{const i=c=>{switch(c.type){case"chat-message":return c.data.isStreaming?g.jsx(Sm,{id:c.id,data:c.data,models:t,onStreamComplete:()=>n?.(c.id),onRegenerate:r,onDelete:s,onSwipeChange:o,autoScroll:!1},c.id):g.jsx(Cm,{id:c.id,data:c.data,models:t,onRegenerate:r,onDelete:s,onSwipeChange:o,autoScroll:!1},c.id);case"user-message":return g.jsxs("div",{className:`bg-glass rounded-lg p-4 mb-8 text-end prose prose-invert prose-p:my-2 break-words ${Xe.userTurn}`,children:[g.jsx(p.Suspense,{fallback:g.jsx("div",{className:"opacity-70",children:"Rendering…"}),children:g.jsx(Am,{content:c.data.content})}),Array.isArray(c.data.attachments)&&c.data.attachments.length>0&&g.jsx("div",{className:"mt-3 flex flex-wrap gap-2 justify-end",children:c.data.attachments.map(l=>{const u=l.name.length>10?l.name.slice(0,10)+"…":l.name;return g.jsx("span",{className:"inline-flex items-center gap-1 px-2 py-1 rounded-full bg-white/10 border border-white/15 text-[11px]",children:u},l.id)})})]},c.id);case"widget":return g.jsx("div",{className:"mb-8",children:g.jsxs("div",{className:"bg-glass rounded-lg p-4",children:["Widget: ",c.data.component]})},c.id);case"system-message":return g.jsx("div",{className:"mb-8",children:g.jsx("div",{className:`rounded-lg p-4 ${c.data.level==="error"?"bg-red-500/20 border border-red-500/30":c.data.level==="warning"?"bg-yellow-500/20 border border-yellow-500/30":"bg-blue-500/20 border border-blue-500/30"}`,children:g.jsx("p",{className:"text-sm",children:c.data.content})})},c.id);case"context-divider":return g.jsxs("div",{className:"mb-6 flex items-center gap-2 text-xs text-white/60",children:[g.jsx("div",{className:"flex-1 h-[1px] bg-white/15"}),g.jsx("span",{className:"px-2 py-0.5 rounded bg-white/10 border border-white/15",children:c.data.label}),g.jsx("div",{className:"flex-1 h-[1px] bg-white/15"})]},c.id);default:return null}},a=p.useMemo(()=>e.slice().reverse(),[e]);return g.jsx("div",{className:`w-full max-w-4xl mx-auto pt-8 h-full flex flex-col-reverse overflow-y-scroll ${Xe.scrollContainer}`,children:a.map(i)})};function yi(){return di({queryKey:["models"],queryFn:async()=>{const e=await fetch("/api/models",{headers:{Accept:"application/json"}});if(!e.ok)throw new Error("Failed to fetch models");const t=await e.json();return Array.isArray(t?.data)?t.data.map(r=>({id:r?.id,label:r?.label,vision:typeof r?.vision=="boolean"?r.vision:void 0})).filter(r=>typeof r.id=="string"):[]},staleTime:6e4})}async function Ua(e,t,n){const r={"Content-Type":"application/json","Cache-Control":"no-cache",...n?.headers||{}};return fetch(e,{...n||{},method:"POST",headers:r,body:JSON.stringify(t)})}const xe=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Se=Object.keys,Ie=Array.isArray;function De(e,t){return typeof t!="object"||Se(t).forEach(function(n){e[n]=t[n]}),e}typeof Promise>"u"||xe.Promise||(xe.Promise=Promise);const ur=Object.getPrototypeOf,Rm={}.hasOwnProperty;function We(e,t){return Rm.call(e,t)}function Dn(e,t){typeof t=="function"&&(t=t(ur(e))),(typeof Reflect>"u"?Se:Reflect.ownKeys)(t).forEach(n=>{bt(e,n,t[n])})}const kl=Object.defineProperty;function bt(e,t,n,r){kl(e,t,De(n&&We(n,"get")&&typeof n.get=="function"?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},r))}function _n(e){return{from:function(t){return e.prototype=Object.create(t.prototype),bt(e.prototype,"constructor",e),{extend:Dn.bind(null,e.prototype)}}}}const Om=Object.getOwnPropertyDescriptor;function vi(e,t){let n;return Om(e,t)||(n=ur(e))&&vi(n,t)}const Pm=[].slice;function fs(e,t,n){return Pm.call(e,t,n)}function Sl(e,t){return t(e)}function Gn(e){if(!e)throw new Error("Assertion Failed")}function Al(e){xe.setImmediate?setImmediate(e):setTimeout(e,0)}function El(e,t){return e.reduce((n,r,s)=>{var o=t(r,s);return o&&(n[o[0]]=o[1]),n},{})}function wt(e,t){if(typeof t=="string"&&We(e,t))return e[t];if(!t)return e;if(typeof t!="string"){for(var n=[],r=0,s=t.length;r["Int","Uint","Float"].map(t=>t+e+"Array")))).filter(e=>xe[e]),Tm=Pl.map(e=>xe[e]);El(Pl,e=>[e,!0]);let Nt=null;function _r(e){Nt=typeof WeakMap<"u"&&new WeakMap;const t=So(e);return Nt=null,t}function So(e){if(!e||typeof e!="object")return e;let t=Nt&&Nt.get(e);if(t)return t;if(Ie(e)){t=[],Nt&&Nt.set(e,t);for(var n=0,r=e.length;n=0)t=e;else{const o=ur(e);for(var s in t=o===Object.prototype?{}:Object.create(o),Nt&&Nt.set(e,t),e)We(e,s)&&(t[s]=So(e[s]))}return t}const{toString:Im}={};function Ao(e){return Im.call(e).slice(8,-1)}const Eo=typeof Symbol<"u"?Symbol.iterator:"@@iterator",Nm=typeof Eo=="symbol"?function(e){var t;return e!=null&&(t=e[Eo])&&t.apply(e)}:function(){return null},wn={};function yt(e){var t,n,r,s;if(arguments.length===1){if(Ie(e))return e.slice();if(this===wn&&typeof e=="string")return[e];if(s=Nm(e)){for(n=[];!(r=s.next()).done;)n.push(r.value);return n}if(e==null)return[e];if(typeof(t=e.length)=="number"){for(n=new Array(t);t--;)n[t]=e[t];return n}return[e]}for(t=arguments.length,n=new Array(t);t--;)n[t]=arguments[t];return n}const bi=typeof Symbol<"u"?e=>e[Symbol.toStringTag]==="AsyncFunction":()=>!1;var dt=typeof location<"u"&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function Ml(e,t){dt=e,Tl=t}var Tl=()=>!0;const Dm=!new Error("").stack;function ln(){if(Dm)try{throw ln.arguments,new Error}catch(e){return e}return new Error}function Ro(e,t){var n=e.stack;return n?(t=t||0,n.indexOf(e.name)===0&&(t+=(e.name+e.message).split(` `).length),n.split(` `).slice(t).filter(Tl).map(r=>` `+r).join("")):""}var Il=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],wi=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(Il),jm={VersionChanged:"Database version changed by other database connection",DatabaseClosed:"Database has been closed",Abort:"Transaction aborted",TransactionInactive:"Transaction has already completed or failed",MissingAPI:"IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb"};function Cn(e,t){this._e=ln(),this.name=e,this.message=t}function Nl(e,t){return e+". Errors: "+Object.keys(t).map(n=>t[n].toString()).filter((n,r,s)=>s.indexOf(n)===r).join(` `)}function hs(e,t,n,r){this._e=ln(),this.failures=t,this.failedKeys=r,this.successCount=n,this.message=Nl(e,t)}function Jn(e,t){this._e=ln(),this.name="BulkError",this.failures=Object.keys(t).map(n=>t[n]),this.failuresByPos=t,this.message=Nl(e,t)}_n(Cn).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+Ro(this._e,2))}},toString:function(){return this.name+": "+this.message}}),_n(hs).from(Cn),_n(Jn).from(Cn);var xi=wi.reduce((e,t)=>(e[t]=t+"Error",e),{});const Fm=Cn;var J=wi.reduce((e,t)=>{var n=t+"Error";function r(s,o){this._e=ln(),this.name=n,s?typeof s=="string"?(this.message=`${s}${o?` `+o:""}`,this.inner=o||null):typeof s=="object"&&(this.message=`${s.name} ${s.message}`,this.inner=s):(this.message=jm[t]||n,this.inner=null)}return _n(r).from(Fm),e[t]=r,e},{});J.Syntax=SyntaxError,J.Type=TypeError,J.Range=RangeError;var qa=Il.reduce((e,t)=>(e[t+"Error"]=J[t],e),{}),Hr=wi.reduce((e,t)=>(["Syntax","Type","Range"].indexOf(t)===-1&&(e[t+"Error"]=J[t]),e),{});function ve(){}function dr(e){return e}function Lm(e,t){return e==null||e===dr?t:function(n){return t(e(n))}}function sn(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function $m(e,t){return e===ve?t:function(){var n=e.apply(this,arguments);n!==void 0&&(arguments[0]=n);var r=this.onsuccess,s=this.onerror;this.onsuccess=null,this.onerror=null;var o=t.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?sn(r,this.onsuccess):r),s&&(this.onerror=this.onerror?sn(s,this.onerror):s),o!==void 0?o:n}}function Bm(e,t){return e===ve?t:function(){e.apply(this,arguments);var n=this.onsuccess,r=this.onerror;this.onsuccess=this.onerror=null,t.apply(this,arguments),n&&(this.onsuccess=this.onsuccess?sn(n,this.onsuccess):n),r&&(this.onerror=this.onerror?sn(r,this.onerror):r)}}function Km(e,t){return e===ve?t:function(n){var r=e.apply(this,arguments);De(n,r);var s=this.onsuccess,o=this.onerror;this.onsuccess=null,this.onerror=null;var i=t.apply(this,arguments);return s&&(this.onsuccess=this.onsuccess?sn(s,this.onsuccess):s),o&&(this.onerror=this.onerror?sn(o,this.onerror):o),r===void 0?i===void 0?void 0:i:De(r,i)}}function zm(e,t){return e===ve?t:function(){return t.apply(this,arguments)!==!1&&e.apply(this,arguments)}}function _i(e,t){return e===ve?t:function(){var n=e.apply(this,arguments);if(n&&typeof n.then=="function"){for(var r=this,s=arguments.length,o=new Array(s);s--;)o[s]=arguments[s];return n.then(function(){return t.apply(r,o)})}return t.apply(this,arguments)}}Hr.ModifyError=hs,Hr.DexieError=Cn,Hr.BulkError=Jn;var fr={};const Dl=100,[Oo,ps,Po]=typeof Promise>"u"?[]:(()=>{let e=Promise.resolve();if(typeof crypto>"u"||!crypto.subtle)return[e,ur(e),e];const t=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[t,ur(t),e]})(),jl=ps&&ps.then,Zr=Oo&&Oo.constructor,Ci=!!Po;var Mo=!1,Vm=Po?()=>{Po.then(Nr)}:xe.setImmediate?setImmediate.bind(null,Nr):xe.MutationObserver?()=>{var e=document.createElement("div");new MutationObserver(()=>{Nr(),e=null}).observe(e,{attributes:!0}),e.setAttribute("i","1")}:()=>{setTimeout(Nr,0)},er=function(e,t){Qn.push([e,t]),ms&&(Vm(),ms=!1)},To=!0,ms=!0,Jt=[],Gr=[],Io=null,No=dr,kn={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:Za,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(e=>{try{Za(e[0],e[1])}catch{}})}},Z=kn,Qn=[],en=0,Qr=[];function j(e){if(typeof this!="object")throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=ve,this._lib=!1;var t=this._PSD=Z;if(dt&&(this._stackHolder=ln(),this._prev=null,this._numPrev=0),typeof e!="function"){if(e!==fr)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(this._state===!1&&jo(this,this._value))}this._state=null,this._value=null,++t.ref,Ll(this,e)}const Do={get:function(){var e=Z,t=gs;function n(r,s){var o=!e.global&&(e!==Z||t!==gs);const i=o&&!_t();var a=new j((c,l)=>{ki(this,new Fl(ys(r,e,o,i),ys(s,e,o,i),c,l,e))});return dt&&Kl(a,this),a}return n.prototype=fr,n},set:function(e){bt(this,"then",e&&e.prototype===fr?Do:{get:function(){return e},set:Do.set})}};function Fl(e,t,n,r,s){this.onFulfilled=typeof e=="function"?e:null,this.onRejected=typeof t=="function"?t:null,this.resolve=n,this.reject=r,this.psd=s}function Ll(e,t){try{t(n=>{if(e._state===null){if(n===e)throw new TypeError("A promise cannot be resolved with itself.");var r=e._lib&&Cr();n&&typeof n.then=="function"?Ll(e,(s,o)=>{n instanceof j?n._then(s,o):n.then(s,o)}):(e._state=!0,e._value=n,$l(e)),r&&kr()}},jo.bind(null,e))}catch(n){jo(e,n)}}function jo(e,t){if(Gr.push(t),e._state===null){var n=e._lib&&Cr();t=No(t),e._state=!1,e._value=t,dt&&t!==null&&typeof t=="object"&&!t._promise&&function(r,s,o){try{r.apply(null,o)}catch{}}(()=>{var r=vi(t,"stack");t._promise=e,bt(t,"stack",{get:()=>Mo?r&&(r.get?r.get.apply(t):r.value):e.stack})}),function(r){Jt.some(s=>s._value===r._value)||Jt.push(r)}(e),$l(e),n&&kr()}}function $l(e){var t=e._listeners;e._listeners=[];for(var n=0,r=t.length;n{--en==0&&Si()},[]))}function ki(e,t){if(e._state!==null){var n=e._state?t.onFulfilled:t.onRejected;if(n===null)return(e._state?t.resolve:t.reject)(e._value);++t.psd.ref,++en,er(Um,[n,e,t])}else e._listeners.push(t)}function Um(e,t,n){try{Io=t;var r,s=t._value;t._state?r=e(s):(Gr.length&&(Gr=[]),r=e(s),Gr.indexOf(s)===-1&&function(o){for(var i=Jt.length;i;)if(Jt[--i]._value===o._value)return void Jt.splice(i,1)}(t)),n.resolve(r)}catch(o){n.reject(o)}finally{Io=null,--en==0&&Si(),--n.psd.ref||n.psd.finalize()}}function Bl(e,t,n){if(t.length===n)return t;var r="";if(e._state===!1){var s,o,i=e._value;i!=null?(s=i.name||"Error",o=i.message||i,r=Ro(i,0)):(s=i,o=""),t.push(s+(o?": "+o:"")+r)}return dt&&((r=Ro(e._stackHolder,2))&&t.indexOf(r)===-1&&t.push(r),e._prev&&Bl(e._prev,t,n)),t}function Kl(e,t){var n=t?t._numPrev+1:0;n<100&&(e._prev=t,e._numPrev=n)}function Nr(){Cr()&&kr()}function Cr(){var e=To;return To=!1,ms=!1,e}function kr(){var e,t,n;do for(;Qn.length>0;)for(e=Qn,Qn=[],n=e.length,t=0;t0);To=!0,ms=!0}function Si(){var e=Jt;Jt=[],e.forEach(r=>{r._PSD.onunhandled.call(null,r._value,r)});for(var t=Qr.slice(0),n=t.length;n;)t[--n]()}function Dr(e){return new j(fr,!1,e)}function Ce(e,t){var n=Z;return function(){var r=Cr(),s=Z;try{return zt(n,!0),e.apply(this,arguments)}catch(o){t&&t(o)}finally{zt(s,!1),r&&kr()}}}Dn(j.prototype,{then:Do,_then:function(e,t){ki(this,new Fl(null,null,e,t,Z))},catch:function(e){if(arguments.length===1)return this.then(null,e);var t=arguments[0],n=arguments[1];return typeof t=="function"?this.then(null,r=>r instanceof t?n(r):Dr(r)):this.then(null,r=>r&&r.name===t?n(r):Dr(r))},finally:function(e){return this.then(t=>(e(),t),t=>(e(),Dr(t)))},stack:{get:function(){if(this._stack)return this._stack;try{Mo=!0;var e=Bl(this,[],20).join(` From previous: `);return this._state!==null&&(this._stack=e),e}finally{Mo=!1}}},timeout:function(e,t){return e<1/0?new j((n,r)=>{var s=setTimeout(()=>r(new J.Timeout(t)),e);this.then(n,r).finally(clearTimeout.bind(null,s))}):this}}),typeof Symbol<"u"&&Symbol.toStringTag&&bt(j.prototype,Symbol.toStringTag,"Dexie.Promise"),kn.env=zl(),Dn(j,{all:function(){var e=yt.apply(null,arguments).map(jr);return new j(function(t,n){e.length===0&&t([]);var r=e.length;e.forEach((s,o)=>j.resolve(s).then(i=>{e[o]=i,--r||t(e)},n))})},resolve:e=>{if(e instanceof j)return e;if(e&&typeof e.then=="function")return new j((n,r)=>{e.then(n,r)});var t=new j(fr,!0,e);return Kl(t,Io),t},reject:Dr,race:function(){var e=yt.apply(null,arguments).map(jr);return new j((t,n)=>{e.map(r=>j.resolve(r).then(t,n))})},PSD:{get:()=>Z,set:e=>Z=e},totalEchoes:{get:()=>gs},newPSD:Kt,usePSD:Kn,scheduler:{get:()=>er,set:e=>{er=e}},rejectionMapper:{get:()=>No,set:e=>{No=e}},follow:(e,t)=>new j((n,r)=>Kt((s,o)=>{var i=Z;i.unhandleds=[],i.onunhandled=o,i.finalize=sn(function(){(function(a){function c(){a(),Qr.splice(Qr.indexOf(c),1)}Qr.push(c),++en,er(()=>{--en==0&&Si()},[])})(()=>{this.unhandleds.length===0?s():o(this.unhandleds[0])})},i.finalize),e()},t,n,r))}),Zr&&(Zr.allSettled&&bt(j,"allSettled",function(){const e=yt.apply(null,arguments).map(jr);return new j(t=>{e.length===0&&t([]);let n=e.length;const r=new Array(n);e.forEach((s,o)=>j.resolve(s).then(i=>r[o]={status:"fulfilled",value:i},i=>r[o]={status:"rejected",reason:i}).then(()=>--n||t(r)))})}),Zr.any&&typeof AggregateError<"u"&&bt(j,"any",function(){const e=yt.apply(null,arguments).map(jr);return new j((t,n)=>{e.length===0&&n(new AggregateError([]));let r=e.length;const s=new Array(r);e.forEach((o,i)=>j.resolve(o).then(a=>t(a),a=>{s[i]=a,--r||n(new AggregateError(s))}))})}));const Te={awaits:0,echoes:0,id:0};var qm=0,Yr=[],Us=0,gs=0,Wm=0;function Kt(e,t,n,r){var s=Z,o=Object.create(s);o.parent=s,o.ref=0,o.global=!1,o.id=++Wm;var i=kn.env;o.env=Ci?{Promise:j,PromiseProp:{value:j,configurable:!0,writable:!0},all:j.all,race:j.race,allSettled:j.allSettled,any:j.any,resolve:j.resolve,reject:j.reject,nthen:Wa(i.nthen,o),gthen:Wa(i.gthen,o)}:{},t&&De(o,t),++s.ref,o.finalize=function(){--this.parent.ref||this.parent.finalize()};var a=Kn(o,e,n,r);return o.ref===0&&o.finalize(),a}function Bn(){return Te.id||(Te.id=++qm),++Te.awaits,Te.echoes+=Dl,Te.id}function _t(){return!!Te.awaits&&(--Te.awaits==0&&(Te.id=0),Te.echoes=Te.awaits*Dl,!0)}function jr(e){return Te.echoes&&e&&e.constructor===Zr?(Bn(),e.then(t=>(_t(),t),t=>(_t(),Oe(t)))):e}function Hm(e){++gs,Te.echoes&&--Te.echoes!=0||(Te.echoes=Te.id=0),Yr.push(Z),zt(e,!0)}function Zm(){var e=Yr[Yr.length-1];Yr.pop(),zt(e,!1)}function zt(e,t){var n=Z;if((t?!Te.echoes||Us++&&e===Z:!Us||--Us&&e===Z)||Vl(t?Hm.bind(null,e):Zm),e!==Z&&(Z=e,n===kn&&(kn.env=zl()),Ci)){var r=kn.env.Promise,s=e.env;ps.then=s.nthen,r.prototype.then=s.gthen,(n.global||e.global)&&(Object.defineProperty(xe,"Promise",s.PromiseProp),r.all=s.all,r.race=s.race,r.resolve=s.resolve,r.reject=s.reject,s.allSettled&&(r.allSettled=s.allSettled),s.any&&(r.any=s.any))}}function zl(){var e=xe.Promise;return Ci?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(xe,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject,nthen:ps.then,gthen:e.prototype.then}:{}}function Kn(e,t,n,r,s){var o=Z;try{return zt(e,!0),t(n,r,s)}finally{zt(o,!1)}}function Vl(e){jl.call(Oo,e)}function ys(e,t,n,r){return typeof e!="function"?e:function(){var s=Z;n&&Bn(),zt(t,!0);try{return e.apply(this,arguments)}finally{zt(s,!1),r&&Vl(_t)}}}function Wa(e,t){return function(n,r){return e.call(this,ys(n,t),ys(r,t))}}(""+jl).indexOf("[native code]")===-1&&(Bn=_t=ve);const Ha="unhandledrejection";function Za(e,t){var n;try{n=t.onuncatched(e)}catch{}if(n!==!1)try{var r,s={promise:t,reason:e};if(xe.document&&document.createEvent?((r=document.createEvent("Event")).initEvent(Ha,!0,!0),De(r,s)):xe.CustomEvent&&De(r=new CustomEvent(Ha,{detail:s}),s),r&&xe.dispatchEvent&&(dispatchEvent(r),!xe.PromiseRejectionEvent&&xe.onunhandledrejection))try{xe.onunhandledrejection(r)}catch{}dt&&r&&!r.defaultPrevented&&console.warn(`Unhandled rejection: ${e.stack||e}`)}catch{}}var Oe=j.reject;function Fo(e,t,n,r){if(e.idbdb&&(e._state.openComplete||Z.letThrough||e._vip)){var s=e._createTransaction(t,n,e._dbSchema);try{s.create(),e._state.PR1398_maxLoop=3}catch(o){return o.name===xi.InvalidState&&e.isOpen()&&--e._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),e._close(),e.open().then(()=>Fo(e,t,n,r))):Oe(o)}return s._promise(t,(o,i)=>Kt(()=>(Z.trans=s,r(o,i,s)))).then(o=>s._completion.then(()=>o))}if(e._state.openComplete)return Oe(new J.DatabaseClosed(e._state.dbOpenError));if(!e._state.isBeingOpened){if(!e._options.autoOpen)return Oe(new J.DatabaseClosed);e.open().catch(ve)}return e._state.dbReadyPromise.then(()=>Fo(e,t,n,r))}const Ga="3.2.7",Xt="￿",Lo=-1/0,mt="Invalid key provided. Keys must be of type string, number, Date or Array.",Ul="String expected.",tr=[],Es=typeof navigator<"u"&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),Gm=Es,Qm=Es,ql=e=>!/(dexie\.js|dexie\.min\.js)/.test(e),Rs="__dbnames",qs="readonly",Ws="readwrite";function on(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}const Wl={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function Fr(e){return typeof e!="string"||/\./.test(e)?t=>t:t=>(t[e]===void 0&&e in t&&delete(t=_r(t))[e],t)}class Ym{_trans(t,n,r){const s=this._tx||Z.trans,o=this.name;function i(c,l,u){if(!u.schema[o])throw new J.NotFound("Table "+o+" not part of transaction");return n(u.idbtrans,u)}const a=Cr();try{return s&&s.db===this.db?s===Z.trans?s._promise(t,i,r):Kt(()=>s._promise(t,i,r),{trans:s,transless:Z.transless||Z}):Fo(this.db,t,[this.name],i)}finally{a&&kr()}}get(t,n){return t&&t.constructor===Object?this.where(t).first(n):this._trans("readonly",r=>this.core.get({trans:r,key:t}).then(s=>this.hook.reading.fire(s))).then(n)}where(t){if(typeof t=="string")return new this.db.WhereClause(this,t);if(Ie(t))return new this.db.WhereClause(this,`[${t.join("+")}]`);const n=Se(t);if(n.length===1)return this.where(n[0]).equals(t[n[0]]);const r=this.schema.indexes.concat(this.schema.primKey).filter(l=>{if(l.compound&&n.every(u=>l.keyPath.indexOf(u)>=0)){for(let u=0;ul.keyPath.length-u.keyPath.length)[0];if(r&&this.db._maxKey!==Xt){const l=r.keyPath.slice(0,n.length);return this.where(l).equals(l.map(u=>t[u]))}!r&&dt&&console.warn(`The query ${JSON.stringify(t)} on ${this.name} would benefit of a compound index [${n.join("+")}]`);const{idxByName:s}=this.schema,o=this.db._deps.indexedDB;function i(l,u){try{return o.cmp(l,u)===0}catch{return!1}}const[a,c]=n.reduce(([l,u],d)=>{const f=s[d],m=t[d];return[l||f,l||!f?on(u,f&&f.multi?y=>{const h=wt(y,d);return Ie(h)&&h.some(v=>i(m,v))}:y=>i(m,wt(y,d))):u]},[null,null]);return a?this.where(a.name).equals(t[a.keyPath]).filter(c):r?this.filter(c):this.where(n).equals("")}filter(t){return this.toCollection().and(t)}count(t){return this.toCollection().count(t)}offset(t){return this.toCollection().offset(t)}limit(t){return this.toCollection().limit(t)}each(t){return this.toCollection().each(t)}toArray(t){return this.toCollection().toArray(t)}toCollection(){return new this.db.Collection(new this.db.WhereClause(this))}orderBy(t){return new this.db.Collection(new this.db.WhereClause(this,Ie(t)?`[${t.join("+")}]`:t))}reverse(){return this.toCollection().reverse()}mapToClass(t){this.schema.mappedClass=t;const n=r=>{if(!r)return r;const s=Object.create(t.prototype);for(var o in r)if(We(r,o))try{s[o]=r[o]}catch{}return s};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=n,this.hook("reading",n),t}defineClass(){return this.mapToClass(function(t){De(this,t)})}add(t,n){const{auto:r,keyPath:s}=this.schema.primKey;let o=t;return s&&r&&(o=Fr(s)(t)),this._trans("readwrite",i=>this.core.mutate({trans:i,type:"add",keys:n!=null?[n]:null,values:[o]})).then(i=>i.numFailures?j.reject(i.failures[0]):i.lastResult).then(i=>{if(s)try{Je(t,s,i)}catch{}return i})}update(t,n){if(typeof t!="object"||Ie(t))return this.where(":id").equals(t).modify(n);{const r=wt(t,this.schema.primKey.keyPath);if(r===void 0)return Oe(new J.InvalidArgument("Given object does not contain its primary key"));try{typeof n!="function"?Se(n).forEach(s=>{Je(t,s,n[s])}):n(t,{value:t,primKey:r})}catch{}return this.where(":id").equals(r).modify(n)}}put(t,n){const{auto:r,keyPath:s}=this.schema.primKey;let o=t;return s&&r&&(o=Fr(s)(t)),this._trans("readwrite",i=>this.core.mutate({trans:i,type:"put",values:[o],keys:n!=null?[n]:null})).then(i=>i.numFailures?j.reject(i.failures[0]):i.lastResult).then(i=>{if(s)try{Je(t,s,i)}catch{}return i})}delete(t){return this._trans("readwrite",n=>this.core.mutate({trans:n,type:"delete",keys:[t]})).then(n=>n.numFailures?j.reject(n.failures[0]):void 0)}clear(){return this._trans("readwrite",t=>this.core.mutate({trans:t,type:"deleteRange",range:Wl})).then(t=>t.numFailures?j.reject(t.failures[0]):void 0)}bulkGet(t){return this._trans("readonly",n=>this.core.getMany({keys:t,trans:n}).then(r=>r.map(s=>this.hook.reading.fire(s))))}bulkAdd(t,n,r){const s=Array.isArray(n)?n:void 0,o=(r=r||(s?void 0:n))?r.allKeys:void 0;return this._trans("readwrite",i=>{const{auto:a,keyPath:c}=this.schema.primKey;if(c&&s)throw new J.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(s&&s.length!==t.length)throw new J.InvalidArgument("Arguments objects and keys must have the same length");const l=t.length;let u=c&&a?t.map(Fr(c)):t;return this.core.mutate({trans:i,type:"add",keys:s,values:u,wantResults:o}).then(({numFailures:d,results:f,lastResult:m,failures:y})=>{if(d===0)return o?f:m;throw new Jn(`${this.name}.bulkAdd(): ${d} of ${l} operations failed`,y)})})}bulkPut(t,n,r){const s=Array.isArray(n)?n:void 0,o=(r=r||(s?void 0:n))?r.allKeys:void 0;return this._trans("readwrite",i=>{const{auto:a,keyPath:c}=this.schema.primKey;if(c&&s)throw new J.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(s&&s.length!==t.length)throw new J.InvalidArgument("Arguments objects and keys must have the same length");const l=t.length;let u=c&&a?t.map(Fr(c)):t;return this.core.mutate({trans:i,type:"put",keys:s,values:u,wantResults:o}).then(({numFailures:d,results:f,lastResult:m,failures:y})=>{if(d===0)return o?f:m;throw new Jn(`${this.name}.bulkPut(): ${d} of ${l} operations failed`,y)})})}bulkDelete(t){const n=t.length;return this._trans("readwrite",r=>this.core.mutate({trans:r,type:"delete",keys:t})).then(({numFailures:r,lastResult:s,failures:o})=>{if(r===0)return s;throw new Jn(`${this.name}.bulkDelete(): ${r} of ${n} operations failed`,o)})}}function nr(e){var t={},n=function(i,a){if(a){for(var c=arguments.length,l=new Array(c-1);--c;)l[c-1]=arguments[c];return t[i].subscribe.apply(null,l),e}if(typeof i=="string")return t[i]};n.addEventType=o;for(var r=1,s=arguments.length;ron(r(),t()):t,e.justLimit=n&&!r}function Xr(e,t){if(e.isPrimKey)return t.primaryKey;const n=t.getIndexByKeyPath(e.index);if(!n)throw new J.Schema("KeyPath "+e.index+" on object store "+t.name+" is not indexed");return n}function Qa(e,t,n){const r=Xr(e,t.schema);return t.openCursor({trans:n,values:!e.keysOnly,reverse:e.dir==="prev",unique:!!e.unique,query:{index:r,range:e.range}})}function Lr(e,t,n,r){const s=e.replayFilter?on(e.filter,e.replayFilter()):e.filter;if(e.or){const o={},i=(a,c,l)=>{if(!s||s(c,l,f=>c.stop(f),f=>c.fail(f))){var u=c.primaryKey,d=""+u;d==="[object ArrayBuffer]"&&(d=""+new Uint8Array(u)),We(o,d)||(o[d]=!0,t(a,c,l))}};return Promise.all([e.or._iterate(i,n),Ya(Qa(e,r,n),e.algorithm,i,!e.keysOnly&&e.valueMapper)])}return Ya(Qa(e,r,n),on(e.algorithm,s),t,!e.keysOnly&&e.valueMapper)}function Ya(e,t,n,r){var s=Ce(r?(o,i,a)=>n(r(o),i,a):n);return e.then(o=>{if(o)return o.start(()=>{var i=()=>o.continue();t&&!t(o,a=>i=a,a=>{o.stop(a),i=ve},a=>{o.fail(a),i=ve})||s(o.value,o,a=>i=a),i()})})}function Ne(e,t){try{const n=Xa(e),r=Xa(t);if(n!==r)return n==="Array"?1:r==="Array"?-1:n==="binary"?1:r==="binary"?-1:n==="string"?1:r==="string"?-1:n==="Date"?1:r!=="Date"?NaN:-1;switch(n){case"number":case"Date":case"string":return e>t?1:eLr(n,t,r,n.table.core))}count(t){return this._read(n=>{const r=this._ctx,s=r.table.core;if(pn(r,!0))return s.count({trans:n,query:{index:Xr(r,s.schema),range:r.range}}).then(i=>Math.min(i,r.limit));var o=0;return Lr(r,()=>(++o,!1),n,s).then(()=>o)}).then(t)}sortBy(t,n){const r=t.split(".").reverse(),s=r[0],o=r.length-1;function i(l,u){return u?i(l[r[u]],u-1):l[s]}var a=this._ctx.dir==="next"?1:-1;function c(l,u){var d=i(l,o),f=i(u,o);return df?a:0}return this.toArray(function(l){return l.sort(c)}).then(n)}toArray(t){return this._read(n=>{var r=this._ctx;if(r.dir==="next"&&pn(r,!0)&&r.limit>0){const{valueMapper:s}=r,o=Xr(r,r.table.core.schema);return r.table.core.query({trans:n,limit:r.limit,values:!0,query:{index:o,range:r.range}}).then(({result:i})=>s?i.map(s):i)}{const s=[];return Lr(r,o=>s.push(o),n,r.table.core).then(()=>s)}},t)}offset(t){var n=this._ctx;return t<=0||(n.offset+=t,pn(n)?Zs(n,()=>{var r=t;return(s,o)=>r===0||(r===1?(--r,!1):(o(()=>{s.advance(r),r=0}),!1))}):Zs(n,()=>{var r=t;return()=>--r<0})),this}limit(t){return this._ctx.limit=Math.min(this._ctx.limit,t),Zs(this._ctx,()=>{var n=t;return function(r,s,o){return--n<=0&&s(o),n>=0}},!0),this}until(t,n){return Hs(this._ctx,function(r,s,o){return!t(r.value)||(s(o),n)}),this}first(t){return this.limit(1).toArray(function(n){return n[0]}).then(t)}last(t){return this.reverse().first(t)}filter(t){var n,r;return Hs(this._ctx,function(s){return t(s.value)}),n=this._ctx,r=t,n.isMatch=on(n.isMatch,r),this}and(t){return this.filter(t)}or(t){return new this.db.WhereClause(this._ctx.table,t,this)}reverse(){return this._ctx.dir=this._ctx.dir==="prev"?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this}desc(){return this.reverse()}eachKey(t){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(r,s){t(s.key,s)})}eachUniqueKey(t){return this._ctx.unique="unique",this.eachKey(t)}eachPrimaryKey(t){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(r,s){t(s.primaryKey,s)})}keys(t){var n=this._ctx;n.keysOnly=!n.isMatch;var r=[];return this.each(function(s,o){r.push(o.key)}).then(function(){return r}).then(t)}primaryKeys(t){var n=this._ctx;if(n.dir==="next"&&pn(n,!0)&&n.limit>0)return this._read(s=>{var o=Xr(n,n.table.core.schema);return n.table.core.query({trans:s,values:!1,limit:n.limit,query:{index:o,range:n.range}})}).then(({result:s})=>s).then(t);n.keysOnly=!n.isMatch;var r=[];return this.each(function(s,o){r.push(o.primaryKey)}).then(function(){return r}).then(t)}uniqueKeys(t){return this._ctx.unique="unique",this.keys(t)}firstKey(t){return this.limit(1).keys(function(n){return n[0]}).then(t)}lastKey(t){return this.reverse().firstKey(t)}distinct(){var t=this._ctx,n=t.index&&t.table.schema.idxByName[t.index];if(!n||!n.multi)return this;var r={};return Hs(this._ctx,function(s){var o=s.primaryKey.toString(),i=We(r,o);return r[o]=!0,!i}),this}modify(t){var n=this._ctx;return this._write(r=>{var s;if(typeof t=="function")s=t;else{var o=Se(t),i=o.length;s=function(h){for(var v=!1,b=0;b{const{failures:b,numFailures:w}=v;f+=h-w;for(let x of Se(b))d.push(b[x])};return this.clone().primaryKeys().then(h=>{const v=b=>{const w=Math.min(u,h.length-b);return a.getMany({trans:r,keys:h.slice(b,b+w),cache:"immutable"}).then(x=>{const _=[],C=[],S=c?[]:null,k=[];for(let O=0;O0&&a.mutate({trans:r,type:"add",values:_}).then(O=>{for(let R in O.failures)k.splice(parseInt(R),1);y(_.length,O)})).then(()=>(C.length>0||A&&typeof t=="object")&&a.mutate({trans:r,type:"put",keys:S,values:C,criteria:A,changeSpec:typeof t!="function"&&t}).then(O=>y(C.length,O))).then(()=>(k.length>0||A&&t===Gs)&&a.mutate({trans:r,type:"delete",keys:k,criteria:A}).then(O=>y(k.length,O))).then(()=>h.length>b+w&&v(b+u))})};return v(0).then(()=>{if(d.length>0)throw new hs("Error modifying one or more objects",d,f,m);return h.length})})})}delete(){var t=this._ctx,n=t.range;return pn(t)&&(t.isPrimKey&&!Qm||n.type===3)?this._write(r=>{const{primaryKey:s}=t.table.core.schema,o=n;return t.table.core.count({trans:r,query:{index:s,range:o}}).then(i=>t.table.core.mutate({trans:r,type:"deleteRange",range:o}).then(({failures:a,lastResult:c,results:l,numFailures:u})=>{if(u)throw new hs("Could not delete some values",Object.keys(a).map(d=>a[d]),i-u);return i-u}))}):this.modify(Gs)}}const Gs=(e,t)=>t.value=null;function Jm(e,t){return et?-1:e===t?0:1}function Ke(e,t,n){var r=e instanceof Zl?new e.Collection(e):e;return r._ctx.error=n?new n(t):new TypeError(t),r}function mn(e){return new e.Collection(e,()=>Hl("")).limit(0)}function tg(e,t,n,r,s,o){for(var i=Math.min(e.length,r.length),a=-1,c=0;c=0?e.substr(0,a)+t[a]+n.substr(a+1):null;s(e[c],l)<0&&(a=c)}return itypeof h=="string"))return Ke(e,Ul);function f(h){s=function(b){return b==="next"?w=>w.toUpperCase():w=>w.toLowerCase()}(h),o=function(b){return b==="next"?w=>w.toLowerCase():w=>w.toUpperCase()}(h),i=h==="next"?Jm:eg;var v=n.map(function(b){return{lower:o(b),upper:s(b)}}).sort(function(b,w){return i(b.lower,w.lower)});a=v.map(function(b){return b.upper}),c=v.map(function(b){return b.lower}),l=h,u=h==="next"?"":r}f("next");var m=new e.Collection(e,()=>Pt(a[0],c[d-1]+r));m._ondirectionchange=function(h){f(h)};var y=0;return m._addAlgorithm(function(h,v,b){var w=h.key;if(typeof w!="string")return!1;var x=o(w);if(t(x,c,y))return!0;for(var _=null,C=y;C0)&&(_=S)}return v(_!==null?function(){h.continue(_+u)}:b),!1}),m}function Pt(e,t,n,r){return{type:2,lower:e,upper:t,lowerOpen:n,upperOpen:r}}function Hl(e){return{type:1,lower:e,upper:e}}class Zl{get Collection(){return this._ctx.table.db.Collection}between(t,n,r,s){r=r!==!1,s=s===!0;try{return this._cmp(t,n)>0||this._cmp(t,n)===0&&(r||s)&&(!r||!s)?mn(this):new this.Collection(this,()=>Pt(t,n,!r,!s))}catch{return Ke(this,mt)}}equals(t){return t==null?Ke(this,mt):new this.Collection(this,()=>Hl(t))}above(t){return t==null?Ke(this,mt):new this.Collection(this,()=>Pt(t,void 0,!0))}aboveOrEqual(t){return t==null?Ke(this,mt):new this.Collection(this,()=>Pt(t,void 0,!1))}below(t){return t==null?Ke(this,mt):new this.Collection(this,()=>Pt(void 0,t,!1,!0))}belowOrEqual(t){return t==null?Ke(this,mt):new this.Collection(this,()=>Pt(void 0,t))}startsWith(t){return typeof t!="string"?Ke(this,Ul):this.between(t,t+Xt,!0,!0)}startsWithIgnoreCase(t){return t===""?this.startsWith(t):$r(this,(n,r)=>n.indexOf(r[0])===0,[t],Xt)}equalsIgnoreCase(t){return $r(this,(n,r)=>n===r[0],[t],"")}anyOfIgnoreCase(){var t=yt.apply(wn,arguments);return t.length===0?mn(this):$r(this,(n,r)=>r.indexOf(n)!==-1,t,"")}startsWithAnyOfIgnoreCase(){var t=yt.apply(wn,arguments);return t.length===0?mn(this):$r(this,(n,r)=>r.some(s=>n.indexOf(s)===0),t,Xt)}anyOf(){const t=yt.apply(wn,arguments);let n=this._cmp;try{t.sort(n)}catch{return Ke(this,mt)}if(t.length===0)return mn(this);const r=new this.Collection(this,()=>Pt(t[0],t[t.length-1]));r._ondirectionchange=o=>{n=o==="next"?this._ascending:this._descending,t.sort(n)};let s=0;return r._addAlgorithm((o,i,a)=>{const c=o.key;for(;n(c,t[s])>0;)if(++s,s===t.length)return i(a),!1;return n(c,t[s])===0||(i(()=>{o.continue(t[s])}),!1)}),r}notEqual(t){return this.inAnyRange([[Lo,t],[t,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){const t=yt.apply(wn,arguments);if(t.length===0)return new this.Collection(this);try{t.sort(this._ascending)}catch{return Ke(this,mt)}const n=t.reduce((r,s)=>r?r.concat([[r[r.length-1][1],s]]):[[Lo,s]],null);return n.push([t[t.length-1],this.db._maxKey]),this.inAnyRange(n,{includeLowers:!1,includeUppers:!1})}inAnyRange(t,n){const r=this._cmp,s=this._ascending,o=this._descending,i=this._min,a=this._max;if(t.length===0)return mn(this);if(!t.every(w=>w[0]!==void 0&&w[1]!==void 0&&s(w[0],w[1])<=0))return Ke(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",J.InvalidArgument);const c=!n||n.includeLowers!==!1,l=n&&n.includeUppers===!0;let u,d=s;function f(w,x){return d(w[0],x[0])}try{u=t.reduce(function(w,x){let _=0,C=w.length;for(;_0){S[0]=i(S[0],x[0]),S[1]=a(S[1],x[1]);break}}return _===C&&w.push(x),w},[]),u.sort(f)}catch{return Ke(this,mt)}let m=0;const y=l?w=>s(w,u[m][1])>0:w=>s(w,u[m][1])>=0,h=c?w=>o(w,u[m][0])>0:w=>o(w,u[m][0])>=0;let v=y;const b=new this.Collection(this,()=>Pt(u[0][0],u[u.length-1][1],!c,!l));return b._ondirectionchange=w=>{w==="next"?(v=y,d=s):(v=h,d=o),u.sort(f)},b._addAlgorithm((w,x,_)=>{for(var C=w.key;v(C);)if(++m,m===u.length)return x(_),!1;return!!function(S){return!y(S)&&!h(S)}(C)||(this._cmp(C,u[m][1])===0||this._cmp(C,u[m][0])===0||x(()=>{d===s?w.continue(u[m][0]):w.continue(u[m][1])}),!1)}),b}startsWithAnyOf(){const t=yt.apply(wn,arguments);return t.every(n=>typeof n=="string")?t.length===0?mn(this):this.inAnyRange(t.map(n=>[n,n+Xt])):Ke(this,"startsWithAnyOf() only works with strings")}}function ot(e){return Ce(function(t){return hr(t),e(t.target.error),!1})}function hr(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}const pr="storagemutated",Dt="x-storagemutated-1",Vt=nr(null,pr);class ng{_lock(){return Gn(!Z.global),++this._reculock,this._reculock!==1||Z.global||(Z.lockOwnerFor=this),this}_unlock(){if(Gn(!Z.global),--this._reculock==0)for(Z.global||(Z.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var t=this._blockedFuncs.shift();try{Kn(t[1],t[0])}catch{}}return this}_locked(){return this._reculock&&Z.lockOwnerFor!==this}create(t){if(!this.mode)return this;const n=this.db.idbdb,r=this.db._state.dbOpenError;if(Gn(!this.idbtrans),!t&&!n)switch(r&&r.name){case"DatabaseClosedError":throw new J.DatabaseClosed(r);case"MissingAPIError":throw new J.MissingAPI(r.message,r);default:throw new J.OpenFailed(r)}if(!this.active)throw new J.TransactionInactive;return Gn(this._completion._state===null),(t=this.idbtrans=t||(this.db.core?this.db.core.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}):n.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}))).onerror=Ce(s=>{hr(s),this._reject(t.error)}),t.onabort=Ce(s=>{hr(s),this.active&&this._reject(new J.Abort(t.error)),this.active=!1,this.on("abort").fire(s)}),t.oncomplete=Ce(()=>{this.active=!1,this._resolve(),"mutatedParts"in t&&Vt.storagemutated.fire(t.mutatedParts)}),this}_promise(t,n,r){if(t==="readwrite"&&this.mode!=="readwrite")return Oe(new J.ReadOnly("Transaction is readonly"));if(!this.active)return Oe(new J.TransactionInactive);if(this._locked())return new j((o,i)=>{this._blockedFuncs.push([()=>{this._promise(t,n,r).then(o,i)},Z])});if(r)return Kt(()=>{var o=new j((i,a)=>{this._lock();const c=n(i,a,this);c&&c.then&&c.then(i,a)});return o.finally(()=>this._unlock()),o._lib=!0,o});var s=new j((o,i)=>{var a=n(o,i,this);a&&a.then&&a.then(o,i)});return s._lib=!0,s}_root(){return this.parent?this.parent._root():this}waitFor(t){var n=this._root();const r=j.resolve(t);if(n._waitingFor)n._waitingFor=n._waitingFor.then(()=>r);else{n._waitingFor=r,n._waitingQueue=[];var s=n.idbtrans.objectStore(n.storeNames[0]);(function i(){for(++n._spinCount;n._waitingQueue.length;)n._waitingQueue.shift()();n._waitingFor&&(s.get(-1/0).onsuccess=i)})()}var o=n._waitingFor;return new j((i,a)=>{r.then(c=>n._waitingQueue.push(Ce(i.bind(null,c))),c=>n._waitingQueue.push(Ce(a.bind(null,c)))).finally(()=>{n._waitingFor===o&&(n._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new J.Abort))}table(t){const n=this._memoizedTables||(this._memoizedTables={});if(We(n,t))return n[t];const r=this.schema[t];if(!r)throw new J.NotFound("Table "+t+" not part of transaction");const s=new this.db.Table(t,r,this);return s.core=this.db.core.table(t),n[t]=s,s}}function $o(e,t,n,r,s,o,i){return{name:e,keyPath:t,unique:n,multi:r,auto:s,compound:o,src:(n&&!i?"&":"")+(r?"*":"")+(s?"++":"")+Gl(t)}}function Gl(e){return typeof e=="string"?e:e?"["+[].join.call(e,"+")+"]":""}function Ql(e,t,n){return{name:e,primKey:t,indexes:n,mappedClass:null,idxByName:El(n,r=>[r.name,r])}}let mr=e=>{try{return e.only([[]]),mr=()=>[[]],[[]]}catch{return mr=()=>Xt,Xt}};function Bo(e){return e==null?()=>{}:typeof e=="string"?function(t){return t.split(".").length===1?r=>r[t]:r=>wt(r,t)}(e):t=>wt(t,e)}function ec(e){return[].slice.call(e)}let rg=0;function rr(e){return e==null?":id":typeof e=="string"?e:`[${e.join("+")}]`}function sg(e,t,n){function r(c){if(c.type===3)return null;if(c.type===4)throw new Error("Cannot convert never type to IDBKeyRange");const{lower:l,upper:u,lowerOpen:d,upperOpen:f}=c;return l===void 0?u===void 0?null:t.upperBound(u,!!f):u===void 0?t.lowerBound(l,!!d):t.bound(l,u,!!d,!!f)}const{schema:s,hasGetAll:o}=function(c,l){const u=ec(c.objectStoreNames);return{schema:{name:c.name,tables:u.map(d=>l.objectStore(d)).map(d=>{const{keyPath:f,autoIncrement:m}=d,y=Ie(f),h=f==null,v={},b={name:d.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:h,compound:y,keyPath:f,autoIncrement:m,unique:!0,extractKey:Bo(f)},indexes:ec(d.indexNames).map(w=>d.index(w)).map(w=>{const{name:x,unique:_,multiEntry:C,keyPath:S}=w,k={name:x,compound:Ie(S),keyPath:S,unique:_,multiEntry:C,extractKey:Bo(S)};return v[rr(S)]=k,k}),getIndexByKeyPath:w=>v[rr(w)]};return v[":id"]=b.primaryKey,f!=null&&(v[rr(f)]=b.primaryKey),b})},hasGetAll:u.length>0&&"getAll"in l.objectStore(u[0])&&!(typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}}(e,n),i=s.tables.map(c=>function(l){const u=l.name;return{name:u,schema:l,mutate:function({trans:d,type:f,keys:m,values:y,range:h}){return new Promise((v,b)=>{v=Ce(v);const w=d.objectStore(u),x=w.keyPath==null,_=f==="put"||f==="add";if(!_&&f!=="delete"&&f!=="deleteRange")throw new Error("Invalid operation type: "+f);const{length:C}=m||y||{length:1};if(m&&y&&m.length!==y.length)throw new Error("Given keys array must have same length as given values array.");if(C===0)return v({numFailures:0,failures:{},results:[],lastResult:void 0});let S;const k=[],A=[];let O=0;const R=q=>{++O,hr(q)};if(f==="deleteRange"){if(h.type===4)return v({numFailures:O,failures:A,results:[],lastResult:void 0});h.type===3?k.push(S=w.clear()):k.push(S=w.delete(r(h)))}else{const[q,H]=_?x?[y,m]:[y,null]:[m,null];if(_)for(let W=0;W{const H=q.target.result;k.forEach((W,ue)=>W.error!=null&&(A[ue]=W.error)),v({numFailures:O,failures:A,results:f==="delete"?m:k.map(W=>W.result),lastResult:H})};S.onerror=q=>{R(q),T(q)},S.onsuccess=T})},getMany:({trans:d,keys:f})=>new Promise((m,y)=>{m=Ce(m);const h=d.objectStore(u),v=f.length,b=new Array(v);let w,x=0,_=0;const C=k=>{const A=k.target;b[A._pos]=A.result,++_===x&&m(b)},S=ot(y);for(let k=0;knew Promise((m,y)=>{m=Ce(m);const h=d.objectStore(u).get(f);h.onsuccess=v=>m(v.target.result),h.onerror=ot(y)}),query:function(d){return f=>new Promise((m,y)=>{m=Ce(m);const{trans:h,values:v,limit:b,query:w}=f,x=b===1/0?void 0:b,{index:_,range:C}=w,S=h.objectStore(u),k=_.isPrimaryKey?S:S.index(_.name),A=r(C);if(b===0)return m({result:[]});if(d){const O=v?k.getAll(A,x):k.getAllKeys(A,x);O.onsuccess=R=>m({result:R.target.result}),O.onerror=ot(y)}else{let O=0;const R=v||!("openKeyCursor"in k)?k.openCursor(A):k.openKeyCursor(A),T=[];R.onsuccess=q=>{const H=R.result;return H?(T.push(v?H.value:H.primaryKey),++O===b?m({result:T}):void H.continue()):m({result:T})},R.onerror=ot(y)}})}(o),openCursor:function({trans:d,values:f,query:m,reverse:y,unique:h}){return new Promise((v,b)=>{v=Ce(v);const{index:w,range:x}=m,_=d.objectStore(u),C=w.isPrimaryKey?_:_.index(w.name),S=y?h?"prevunique":"prev":h?"nextunique":"next",k=f||!("openKeyCursor"in C)?C.openCursor(r(x),S):C.openKeyCursor(r(x),S);k.onerror=ot(b),k.onsuccess=Ce(A=>{const O=k.result;if(!O)return void v(null);O.___id=++rg,O.done=!1;const R=O.continue.bind(O);let T=O.continuePrimaryKey;T&&(T=T.bind(O));const q=O.advance.bind(O),H=()=>{throw new Error("Cursor not stopped")};O.trans=d,O.stop=O.continue=O.continuePrimaryKey=O.advance=()=>{throw new Error("Cursor not started")},O.fail=Ce(b),O.next=function(){let W=1;return this.start(()=>W--?this.continue():this.stop()).then(()=>this)},O.start=W=>{const ue=new Promise((G,E)=>{G=Ce(G),k.onerror=ot(E),O.fail=E,O.stop=P=>{O.stop=O.continue=O.continuePrimaryKey=O.advance=H,G(P)}}),Q=()=>{if(k.result)try{W()}catch(G){O.fail(G)}else O.done=!0,O.start=()=>{throw new Error("Cursor behind last entry")},O.stop()};return k.onsuccess=Ce(G=>{k.onsuccess=Q,Q()}),O.continue=R,O.continuePrimaryKey=T,O.advance=q,Q(),ue},v(O)},b)})},count({query:d,trans:f}){const{index:m,range:y}=d;return new Promise((h,v)=>{const b=f.objectStore(u),w=m.isPrimaryKey?b:b.index(m.name),x=r(y),_=x?w.count(x):w.count();_.onsuccess=Ce(C=>h(C.target.result)),_.onerror=ot(v)})}}}(c)),a={};return i.forEach(c=>a[c.name]=c),{stack:"dbcore",transaction:e.transaction.bind(e),table(c){if(!a[c])throw new Error(`Table '${c}' not found`);return a[c]},MIN_KEY:-1/0,MAX_KEY:mr(t),schema:s}}function Ko({_novip:e},t){const n=t.db,r=function(s,o,{IDBKeyRange:i,indexedDB:a},c){return{dbcore:function(u,d){return d.reduce((f,{create:m})=>({...f,...m(f)}),u)}(sg(o,i,c),s.dbcore)}}(e._middlewares,n,e._deps,t);e.core=r.dbcore,e.tables.forEach(s=>{const o=s.name;e.core.schema.tables.some(i=>i.name===o)&&(s.core=e.core.table(o),e[o]instanceof e.Table&&(e[o].core=s.core))})}function vs({_novip:e},t,n,r){n.forEach(s=>{const o=r[s];t.forEach(i=>{const a=vi(i,s);(!a||"value"in a&&a.value===void 0)&&(i===e.Transaction.prototype||i instanceof e.Transaction?bt(i,s,{get(){return this.table(s)},set(c){kl(this,s,{value:c,writable:!0,configurable:!0,enumerable:!0})}}):i[s]=new e.Table(s,o))})})}function zo({_novip:e},t){t.forEach(n=>{for(let r in n)n[r]instanceof e.Table&&delete n[r]})}function og(e,t){return e._cfg.version-t._cfg.version}function ig(e,t,n,r){const s=e._dbSchema,o=e._createTransaction("readwrite",e._storeNames,s);o.create(n),o._completion.catch(r);const i=o._reject.bind(o),a=Z.transless||Z;Kt(()=>{Z.trans=o,Z.transless=a,t===0?(Se(s).forEach(c=>{Qs(n,c,s[c].primKey,s[c].indexes)}),Ko(e,n),j.follow(()=>e.on.populate.fire(o)).catch(i)):function({_novip:c},l,u,d){const f=[],m=c._versions;let y=c._dbSchema=Uo(c,c.idbdb,d),h=!1;const v=m.filter(w=>w._cfg.version>=l);function b(){return f.length?j.resolve(f.shift()(u.idbtrans)).then(b):j.resolve()}return v.forEach(w=>{f.push(()=>{const x=y,_=w._cfg.dbschema;qo(c,x,d),qo(c,_,d),y=c._dbSchema=_;const C=Yl(x,_);C.add.forEach(k=>{Qs(d,k[0],k[1].primKey,k[1].indexes)}),C.change.forEach(k=>{if(k.recreate)throw new J.Upgrade("Not yet support for changing primary key");{const A=d.objectStore(k.name);k.add.forEach(O=>Vo(A,O)),k.change.forEach(O=>{A.deleteIndex(O.name),Vo(A,O)}),k.del.forEach(O=>A.deleteIndex(O))}});const S=w._cfg.contentUpgrade;if(S&&w._cfg.version>l){Ko(c,d),u._memoizedTables={},h=!0;let k=Rl(_);C.del.forEach(T=>{k[T]=x[T]}),zo(c,[c.Transaction.prototype]),vs(c,[c.Transaction.prototype],Se(k),k),u.schema=k;const A=bi(S);let O;A&&Bn();const R=j.follow(()=>{if(O=S(u),O&&A){var T=_t.bind(null,null);O.then(T,T)}});return O&&typeof O.then=="function"?j.resolve(O):R.then(()=>O)}}),f.push(x=>{(!h||!Gm)&&function(_,C){[].slice.call(C.db.objectStoreNames).forEach(S=>_[S]==null&&C.db.deleteObjectStore(S))}(w._cfg.dbschema,x),zo(c,[c.Transaction.prototype]),vs(c,[c.Transaction.prototype],c._storeNames,c._dbSchema),u.schema=c._dbSchema})}),b().then(()=>{var w,x;x=d,Se(w=y).forEach(_=>{x.db.objectStoreNames.contains(_)||Qs(x,_,w[_].primKey,w[_].indexes)})})}(e,t,o,n).catch(i)})}function Yl(e,t){const n={del:[],add:[],change:[]};let r;for(r in e)t[r]||n.del.push(r);for(r in t){const s=e[r],o=t[r];if(s){const i={name:r,def:o,recreate:!1,del:[],add:[],change:[]};if(""+(s.primKey.keyPath||"")!=""+(o.primKey.keyPath||"")||s.primKey.auto!==o.primKey.auto&&!Es)i.recreate=!0,n.change.push(i);else{const a=s.idxByName,c=o.idxByName;let l;for(l in a)c[l]||i.del.push(l);for(l in c){const u=a[l],d=c[l];u?u.src!==d.src&&i.change.push(d):i.add.push(d)}(i.del.length>0||i.add.length>0||i.change.length>0)&&n.change.push(i)}}else n.add.push([r,o])}return n}function Qs(e,t,n,r){const s=e.db.createObjectStore(t,n.keyPath?{keyPath:n.keyPath,autoIncrement:n.auto}:{autoIncrement:n.auto});return r.forEach(o=>Vo(s,o)),s}function Vo(e,t){e.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function Uo(e,t,n){const r={};return fs(t.objectStoreNames,0).forEach(s=>{const o=n.objectStore(s);let i=o.keyPath;const a=$o(Gl(i),i||"",!1,!1,!!o.autoIncrement,i&&typeof i!="string",!0),c=[];for(let u=0;u{if(t[r]!==null){var s=t[r].split(",").map((i,a)=>{const c=(i=i.trim()).replace(/([&*]|\+\+)/g,""),l=/^\[/.test(c)?c.match(/^\[(.*)\]$/)[1].split("+"):c;return $o(c,l||null,/\&/.test(i),/\*/.test(i),/\+\+/.test(i),Ie(l),a===0)}),o=s.shift();if(o.multi)throw new J.Schema("Primary key cannot be multi-valued");s.forEach(i=>{if(i.auto)throw new J.Schema("Only primary key can be marked as autoIncrement (++)");if(!i.keyPath)throw new J.Schema("Index must have a name and cannot be an empty string")}),n[r]=Ql(r,o,s)}})}stores(t){const n=this.db;this._cfg.storesSource=this._cfg.storesSource?De(this._cfg.storesSource,t):t;const r=n._versions,s={};let o={};return r.forEach(i=>{De(s,i._cfg.storesSource),o=i._cfg.dbschema={},i._parseStoresSpec(s,o)}),n._dbSchema=o,zo(n,[n._allTables,n,n.Transaction.prototype]),vs(n,[n._allTables,n,n.Transaction.prototype,this._cfg.tables],Se(o),o),n._storeNames=Se(o),this}upgrade(t){return this._cfg.contentUpgrade=_i(this._cfg.contentUpgrade||ve,t),this}}function Ai(e,t){let n=e._dbNamesDB;return n||(n=e._dbNamesDB=new tn(Rs,{addons:[],indexedDB:e,IDBKeyRange:t}),n.version(1).stores({dbnames:"name"})),n.table("dbnames")}function Ei(e){return e&&typeof e.databases=="function"}function Wo(e){return Kt(function(){return Z.letThrough=!0,e()})}function cg(){var e;return!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(t){var n=function(){return indexedDB.databases().finally(t)};e=setInterval(n,100),n()}).finally(function(){return clearInterval(e)}):Promise.resolve()}function lg(e){const t=e._state,{indexedDB:n}=e._deps;if(t.isBeingOpened||e.idbdb)return t.dbReadyPromise.then(()=>t.dbOpenError?Oe(t.dbOpenError):e);dt&&(t.openCanceller._stackHolder=ln()),t.isBeingOpened=!0,t.dbOpenError=null,t.openComplete=!1;const r=t.openCanceller;function s(){if(t.openCanceller!==r)throw new J.DatabaseClosed("db.open() was cancelled")}let o=t.dbReadyResolve,i=null,a=!1;const c=()=>new j((l,u)=>{if(s(),!n)throw new J.MissingAPI;const d=e.name,f=t.autoSchema?n.open(d):n.open(d,Math.round(10*e.verno));if(!f)throw new J.MissingAPI;f.onerror=ot(u),f.onblocked=Ce(e._fireOnBlocked),f.onupgradeneeded=Ce(m=>{if(i=f.transaction,t.autoSchema&&!e._options.allowEmptyDB){f.onerror=hr,i.abort(),f.result.close();const h=n.deleteDatabase(d);h.onsuccess=h.onerror=Ce(()=>{u(new J.NoSuchDatabase(`Database ${d} doesnt exist`))})}else{i.onerror=ot(u);var y=m.oldVersion>Math.pow(2,62)?0:m.oldVersion;a=y<1,e._novip.idbdb=f.result,ig(e,y/10,i,u)}},u),f.onsuccess=Ce(()=>{i=null;const m=e._novip.idbdb=f.result,y=fs(m.objectStoreNames);if(y.length>0)try{const v=m.transaction((h=y).length===1?h[0]:h,"readonly");t.autoSchema?function({_novip:b},w,x){b.verno=w.version/10;const _=b._dbSchema=Uo(0,w,x);b._storeNames=fs(w.objectStoreNames,0),vs(b,[b._allTables],Se(_),_)}(e,m,v):(qo(e,e._dbSchema,v),function(b,w){const x=Yl(Uo(0,b.idbdb,w),b._dbSchema);return!(x.add.length||x.change.some(_=>_.add.length||_.change.length))}(e,v)||console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),Ko(e,v)}catch{}var h;tr.push(e),m.onversionchange=Ce(v=>{t.vcFired=!0,e.on("versionchange").fire(v)}),m.onclose=Ce(v=>{e.on("close").fire(v)}),a&&function({indexedDB:v,IDBKeyRange:b},w){!Ei(v)&&w!==Rs&&Ai(v,b).put({name:w}).catch(ve)}(e._deps,d),l()},u)}).catch(l=>l&&l.name==="UnknownError"&&t.PR1398_maxLoop>0?(t.PR1398_maxLoop--,console.warn("Dexie: Workaround for Chrome UnknownError on open()"),c()):j.reject(l));return j.race([r,(typeof navigator>"u"?j.resolve():cg()).then(c)]).then(()=>(s(),t.onReadyBeingFired=[],j.resolve(Wo(()=>e.on.ready.fire(e.vip))).then(function l(){if(t.onReadyBeingFired.length>0){let u=t.onReadyBeingFired.reduce(_i,ve);return t.onReadyBeingFired=[],j.resolve(Wo(()=>u(e.vip))).then(l)}}))).finally(()=>{t.onReadyBeingFired=null,t.isBeingOpened=!1}).then(()=>e).catch(l=>{t.dbOpenError=l;try{i&&i.abort()}catch{}return r===t.openCanceller&&e._close(),Oe(l)}).finally(()=>{t.openComplete=!0,o()})}function Ho(e){var t=o=>e.next(o),n=s(t),r=s(o=>e.throw(o));function s(o){return i=>{var a=o(i),c=a.value;return a.done?c:c&&typeof c.then=="function"?c.then(n,r):Ie(c)?Promise.all(c).then(n,r):n(c)}}return s(t)()}function ug(e,t,n){var r=arguments.length;if(r<2)throw new J.InvalidArgument("Too few arguments");for(var s=new Array(r-1);--r;)s[r-1]=arguments[r];return n=s.pop(),[e,Ol(s),n]}function Xl(e,t,n,r,s){return j.resolve().then(()=>{const o=Z.transless||Z,i=e._createTransaction(t,n,e._dbSchema,r),a={trans:i,transless:o};if(r)i.idbtrans=r.idbtrans;else try{i.create(),e._state.PR1398_maxLoop=3}catch(d){return d.name===xi.InvalidState&&e.isOpen()&&--e._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),e._close(),e.open().then(()=>Xl(e,t,n,null,s))):Oe(d)}const c=bi(s);let l;c&&Bn();const u=j.follow(()=>{if(l=s.call(i,i),l)if(c){var d=_t.bind(null,null);l.then(d,d)}else typeof l.next=="function"&&typeof l.throw=="function"&&(l=Ho(l))},a);return(l&&typeof l.then=="function"?j.resolve(l).then(d=>i.active?d:Oe(new J.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):u.then(()=>l)).then(d=>(r&&i._resolve(),i._completion.then(()=>d))).catch(d=>(i._reject(d),Oe(d)))})}function Br(e,t,n){const r=Ie(e)?e.slice():[e];for(let s=0;s0,b={...f,isVirtual:v,keyTail:d,keyLength:h,extractKey:Bo(u),unique:!v&&f.unique};return y.push(b),b.isPrimaryKey||o.push(b),h>1&&i(h===2?u[0]:u.slice(0,h-1),d+1,f),y.sort((w,x)=>w.keyTail-x.keyTail),b}const a=i(r.primaryKey.keyPath,0,r.primaryKey);s[":id"]=[a];for(const u of r.indexes)i(u.keyPath,0,u);function c(u){const d=u.query.index;return d.isVirtual?{...u,query:{index:d,range:(f=u.query.range,m=d.keyTail,{type:f.type===1?2:f.type,lower:Br(f.lower,f.lowerOpen?e.MAX_KEY:e.MIN_KEY,m),lowerOpen:!0,upper:Br(f.upper,f.upperOpen?e.MIN_KEY:e.MAX_KEY,m),upperOpen:!0})}}:u;var f,m}return{...n,schema:{...r,primaryKey:a,indexes:o,getIndexByKeyPath:function(u){const d=s[rr(u)];return d&&d[0]}},count:u=>n.count(c(u)),query:u=>n.query(c(u)),openCursor(u){const{keyTail:d,isVirtual:f,keyLength:m}=u.query.index;return f?n.openCursor(c(u)).then(y=>y&&function(h){return Object.create(h,{continue:{value:function(b){b!=null?h.continue(Br(b,u.reverse?e.MAX_KEY:e.MIN_KEY,d)):u.unique?h.continue(h.key.slice(0,m).concat(u.reverse?e.MIN_KEY:e.MAX_KEY,d)):h.continue()}},continuePrimaryKey:{value(b,w){h.continuePrimaryKey(Br(b,e.MAX_KEY,d),w)}},primaryKey:{get:()=>h.primaryKey},key:{get(){const b=h.key;return m===1?b[0]:b.slice(0,m)}},value:{get:()=>h.value}})}(y)):n.openCursor(u)}}}}}};function Ri(e,t,n,r){return n=n||{},r=r||"",Se(e).forEach(s=>{if(We(t,s)){var o=e[s],i=t[s];if(typeof o=="object"&&typeof i=="object"&&o&&i){const a=Ao(o);a!==Ao(i)?n[r+s]=t[s]:a==="Object"?Ri(o,i,n,r+s+"."):o!==i&&(n[r+s]=t[s])}else o!==i&&(n[r+s]=t[s])}else n[r+s]=void 0}),Se(t).forEach(s=>{We(e,s)||(n[r+s]=t[s])}),n}const fg={stack:"dbcore",name:"HooksMiddleware",level:2,create:e=>({...e,table(t){const n=e.table(t),{primaryKey:r}=n.schema;return{...n,mutate(o){const i=Z.trans,{deleting:a,creating:c,updating:l}=i.table(t).hook;switch(o.type){case"add":if(c.fire===ve)break;return i._promise("readwrite",()=>u(o),!0);case"put":if(c.fire===ve&&l.fire===ve)break;return i._promise("readwrite",()=>u(o),!0);case"delete":if(a.fire===ve)break;return i._promise("readwrite",()=>u(o),!0);case"deleteRange":if(a.fire===ve)break;return i._promise("readwrite",()=>function(f){return d(f.trans,f.range,1e4)}(o),!0)}return n.mutate(o);function u(f){const m=Z.trans,y=f.keys||function(h,v){return v.type==="delete"?v.keys:v.keys||v.values.map(h.extractKey)}(r,f);if(!y)throw new Error("Keys missing");return(f=f.type==="add"||f.type==="put"?{...f,keys:y}:{...f}).type!=="delete"&&(f.values=[...f.values]),f.keys&&(f.keys=[...f.keys]),function(h,v,b){return v.type==="add"?Promise.resolve([]):h.getMany({trans:v.trans,keys:b,cache:"immutable"})}(n,f,y).then(h=>{const v=y.map((b,w)=>{const x=h[w],_={onerror:null,onsuccess:null};if(f.type==="delete")a.fire.call(_,b,x,m);else if(f.type==="add"||x===void 0){const C=c.fire.call(_,b,f.values[w],m);b==null&&C!=null&&(b=C,f.keys[w]=b,r.outbound||Je(f.values[w],r.keyPath,b))}else{const C=Ri(x,f.values[w]),S=l.fire.call(_,C,b,x,m);if(S){const k=f.values[w];Object.keys(S).forEach(A=>{We(k,A)?k[A]=S[A]:Je(k,A,S[A])})}}return _});return n.mutate(f).then(({failures:b,results:w,numFailures:x,lastResult:_})=>{for(let C=0;C(v.forEach(w=>w.onerror&&w.onerror(b)),Promise.reject(b)))})}function d(f,m,y){return n.query({trans:f,values:!1,query:{index:r,range:m},limit:y}).then(({result:h})=>u({type:"delete",keys:h,trans:f}).then(v=>v.numFailures>0?Promise.reject(v.failures[0]):h.length({table:t=>{const n=e.table(t);return{...n,getMany:r=>{if(!r.cache)return n.getMany(r);const s=Jl(r.keys,r.trans._cache,r.cache==="clone");return s?j.resolve(s):n.getMany(r).then(o=>(r.trans._cache={keys:r.keys,values:r.cache==="clone"?_r(o):o},o))},mutate:r=>(r.type!=="add"&&(r.trans._cache=null),n.mutate(r))}}})};function Oi(e){return!("from"in e)}const gt=function(e,t){if(!this){const n=new gt;return e&&"d"in e&&De(n,e),n}De(this,arguments.length?{d:1,from:e,to:arguments.length>1?t:e}:{d:0})};function gr(e,t,n){const r=Ne(t,n);if(isNaN(r))return;if(r>0)throw RangeError();if(Oi(e))return De(e,{from:t,to:n,d:1});const s=e.l,o=e.r;if(Ne(n,e.from)<0)return s?gr(s,t,n):e.l={from:t,to:n,d:1,l:null,r:null},tc(e);if(Ne(t,e.to)>0)return o?gr(o,t,n):e.r={from:t,to:n,d:1,l:null,r:null},tc(e);Ne(t,e.from)<0&&(e.from=t,e.l=null,e.d=o?o.d+1:1),Ne(n,e.to)>0&&(e.to=n,e.r=null,e.d=e.l?e.l.d+1:1);const i=!e.r;s&&!e.l&&bs(e,s),o&&i&&bs(e,o)}function bs(e,t){Oi(t)||function n(r,{from:s,to:o,l:i,r:a}){gr(r,s,o),i&&n(r,i),a&&n(r,a)}(e,t)}function pg(e,t){const n=Zo(t);let r=n.next();if(r.done)return!1;let s=r.value;const o=Zo(e);let i=o.next(s.from),a=i.value;for(;!r.done&&!i.done;){if(Ne(a.from,s.to)<=0&&Ne(a.to,s.from)>=0)return!0;Ne(s.from,a.from)<0?s=(r=n.next(a.from)).value:a=(i=o.next(s.from)).value}return!1}function Zo(e){let t=Oi(e)?null:{s:0,n:e};return{next(n){const r=arguments.length>0;for(;t;)switch(t.s){case 0:if(t.s=1,r)for(;t.n.l&&Ne(n,t.n.from)<0;)t={up:t,n:t.n.l,s:1};else for(;t.n.l;)t={up:t,n:t.n.l,s:1};case 1:if(t.s=2,!r||Ne(n,t.n.to)<=0)return{value:t.n,done:!1};case 2:if(t.n.r){t.s=3,t={up:t,n:t.n.r,s:0};continue}case 3:t=t.up}return{done:!0}}}}function tc(e){var t,n;const r=(((t=e.r)===null||t===void 0?void 0:t.d)||0)-(((n=e.l)===null||n===void 0?void 0:n.d)||0),s=r>1?"r":r<-1?"l":"";if(s){const o=s==="r"?"l":"r",i={...e},a=e[s];e.from=a.from,e.to=a.to,e[s]=a[s],i[s]=a[o],e[o]=i,i.d=nc(i)}e.d=nc(e)}function nc({r:e,l:t}){return(e?t?Math.max(e.d,t.d):e.d:t?t.d:0)+1}Dn(gt.prototype,{add(e){return bs(this,e),this},addKey(e){return gr(this,e,e),this},addKeys(e){return e.forEach(t=>gr(this,t,t)),this},[Eo](){return Zo(this)}});const mg={stack:"dbcore",level:0,create:e=>{const t=e.schema.name,n=new gt(e.MIN_KEY,e.MAX_KEY);return{...e,table:r=>{const s=e.table(r),{schema:o}=s,{primaryKey:i}=o,{extractKey:a,outbound:c}=i,l={...s,mutate:f=>{const m=f.trans,y=m.mutatedParts||(m.mutatedParts={}),h=S=>{const k=`idb://${t}/${r}/${S}`;return y[k]||(y[k]=new gt)},v=h(""),b=h(":dels"),{type:w}=f;let[x,_]=f.type==="deleteRange"?[f.range]:f.type==="delete"?[f.keys]:f.values.length<50?[[],f.values]:[];const C=f.trans._cache;return s.mutate(f).then(S=>{if(Ie(x)){w!=="delete"&&(x=S.results),v.addKeys(x);const k=Jl(x,C);k||w==="add"||b.addKeys(x),(k||_)&&function(A,O,R,T){function q(H){const W=A(H.name||"");function ue(G){return G!=null?H.extractKey(G):null}const Q=G=>H.multiEntry&&Ie(G)?G.forEach(E=>W.addKey(E)):W.addKey(G);(R||T).forEach((G,E)=>{const P=R&&ue(R[E]),U=T&&ue(T[E]);Ne(P,U)!==0&&(P!=null&&Q(P),U!=null&&Q(U))})}O.indexes.forEach(q)}(h,o,k,_)}else if(x){const k={from:x.lower,to:x.upper};b.add(k),v.add(k)}else v.add(n),b.add(n),o.indexes.forEach(k=>h(k.name).add(n));return S})}},u=({query:{index:f,range:m}})=>{var y,h;return[f,new gt((y=m.lower)!==null&&y!==void 0?y:e.MIN_KEY,(h=m.upper)!==null&&h!==void 0?h:e.MAX_KEY)]},d={get:f=>[i,new gt(f.key)],getMany:f=>[i,new gt().addKeys(f.keys)],count:u,query:u,openCursor:u};return Se(d).forEach(f=>{l[f]=function(m){const{subscr:y}=Z;if(y){const h=_=>{const C=`idb://${t}/${r}/${_}`;return y[C]||(y[C]=new gt)},v=h(""),b=h(":dels"),[w,x]=d[f](m);if(h(w.name||"").add(x),!w.isPrimaryKey){if(f!=="count"){const _=f==="query"&&c&&m.values&&s.query({...m,values:!1});return s[f].apply(this,arguments).then(C=>{if(f==="query"){if(c&&m.values)return _.then(({result:k})=>(v.addKeys(k),C));const S=m.values?C.result.map(a):C.result;m.values?v.addKeys(S):b.addKeys(S)}else if(f==="openCursor"){const S=C,k=m.values;return S&&Object.create(S,{key:{get:()=>(b.addKey(S.primaryKey),S.key)},primaryKey:{get(){const A=S.primaryKey;return b.addKey(A),A}},value:{get:()=>(k&&v.addKey(S.primaryKey),S.value)}})}return C})}b.add(n)}}return s[f].apply(this,arguments)}}),l}}}};class tn{constructor(t,n){this._middlewares={},this.verno=0;const r=tn.dependencies;this._options=n={addons:tn.addons,autoOpen:!0,indexedDB:r.indexedDB,IDBKeyRange:r.IDBKeyRange,...n},this._deps={indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange};const{addons:s}=n;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;const o={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:ve,dbReadyPromise:null,cancelOpen:ve,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};var i;o.dbReadyPromise=new j(a=>{o.dbReadyResolve=a}),o.openCanceller=new j((a,c)=>{o.cancelOpen=c}),this._state=o,this.name=t,this.on=nr(this,"populate","blocked","versionchange","close",{ready:[_i,ve]}),this.on.ready.subscribe=Sl(this.on.ready.subscribe,a=>(c,l)=>{tn.vip(()=>{const u=this._state;if(u.openComplete)u.dbOpenError||j.resolve().then(c),l&&a(c);else if(u.onReadyBeingFired)u.onReadyBeingFired.push(c),l&&a(c);else{a(c);const d=this;l||a(function f(){d.on.ready.unsubscribe(c),d.on.ready.unsubscribe(f)})}})}),this.Collection=(i=this,Wn(Xm.prototype,function(a,c){this.db=i;let l=Wl,u=null;if(c)try{l=c()}catch(y){u=y}const d=a._ctx,f=d.table,m=f.hook.reading.fire;this._ctx={table:f,index:d.index,isPrimKey:!d.index||f.schema.primKey.keyPath&&d.index===f.schema.primKey.name,range:l,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:u,or:d.or,valueMapper:m!==dr?m:null}})),this.Table=function(a){return Wn(Ym.prototype,function(c,l,u){this.db=a,this._tx=u,this.name=c,this.schema=l,this.hook=a._allTables[c]?a._allTables[c].hook:nr(null,{creating:[$m,ve],reading:[Lm,dr],updating:[Km,ve],deleting:[Bm,ve]})})}(this),this.Transaction=function(a){return Wn(ng.prototype,function(c,l,u,d,f){this.db=a,this.mode=c,this.storeNames=l,this.schema=u,this.chromeTransactionDurability=d,this.idbtrans=null,this.on=nr(this,"complete","error","abort"),this.parent=f||null,this.active=!0,this._reculock=0,this._blockedFuncs=[],this._resolve=null,this._reject=null,this._waitingFor=null,this._waitingQueue=null,this._spinCount=0,this._completion=new j((m,y)=>{this._resolve=m,this._reject=y}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},m=>{var y=this.active;return this.active=!1,this.on.error.fire(m),this.parent?this.parent._reject(m):y&&this.idbtrans&&this.idbtrans.abort(),Oe(m)})})}(this),this.Version=function(a){return Wn(ag.prototype,function(c){this.db=a,this._cfg={version:c,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(a){return Wn(Zl.prototype,function(c,l,u){this.db=a,this._ctx={table:c,index:l===":id"?null:l,or:u};const d=a._deps.indexedDB;if(!d)throw new J.MissingAPI;this._cmp=this._ascending=d.cmp.bind(d),this._descending=(f,m)=>d.cmp(m,f),this._max=(f,m)=>d.cmp(f,m)>0?f:m,this._min=(f,m)=>d.cmp(f,m)<0?f:m,this._IDBKeyRange=a._deps.IDBKeyRange})}(this),this.on("versionchange",a=>{a.newVersion>0?console.warn(`Another connection wants to upgrade database '${this.name}'. Closing db now to resume the upgrade.`):console.warn(`Another connection wants to delete database '${this.name}'. Closing db now to resume the delete request.`),this.close()}),this.on("blocked",a=>{!a.newVersion||a.newVersionnew this.Transaction(a,c,l,this._options.chromeTransactionDurability,u),this._fireOnBlocked=a=>{this.on("blocked").fire(a),tr.filter(c=>c.name===this.name&&c!==this&&!c._state.vcFired).map(c=>c.on("versionchange").fire(a))},this.use(dg),this.use(fg),this.use(mg),this.use(hg),this.vip=Object.create(this,{_vip:{value:!0}}),s.forEach(a=>a(this))}version(t){if(isNaN(t)||t<.1)throw new J.Type("Given version is not a positive number");if(t=Math.round(10*t)/10,this.idbdb||this._state.isBeingOpened)throw new J.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,t);const n=this._versions;var r=n.filter(s=>s._cfg.version===t)[0];return r||(r=new this.Version(t),n.push(r),n.sort(og),r.stores({}),this._state.autoSchema=!1,r)}_whenReady(t){return this.idbdb&&(this._state.openComplete||Z.letThrough||this._vip)?t():new j((n,r)=>{if(this._state.openComplete)return r(new J.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void r(new J.DatabaseClosed);this.open().catch(ve)}this._state.dbReadyPromise.then(n,r)}).then(t)}use({stack:t,create:n,level:r,name:s}){s&&this.unuse({stack:t,name:s});const o=this._middlewares[t]||(this._middlewares[t]=[]);return o.push({stack:t,create:n,level:r??10,name:s}),o.sort((i,a)=>i.level-a.level),this}unuse({stack:t,name:n,create:r}){return t&&this._middlewares[t]&&(this._middlewares[t]=this._middlewares[t].filter(s=>r?s.create!==r:!!n&&s.name!==n)),this}open(){return lg(this)}_close(){const t=this._state,n=tr.indexOf(this);if(n>=0&&tr.splice(n,1),this.idbdb){try{this.idbdb.close()}catch{}this._novip.idbdb=null}t.dbReadyPromise=new j(r=>{t.dbReadyResolve=r}),t.openCanceller=new j((r,s)=>{t.cancelOpen=s})}close(){this._close();const t=this._state;this._options.autoOpen=!1,t.dbOpenError=new J.DatabaseClosed,t.isBeingOpened&&t.cancelOpen(t.dbOpenError)}delete(){const t=arguments.length>0,n=this._state;return new j((r,s)=>{const o=()=>{this.close();var i=this._deps.indexedDB.deleteDatabase(this.name);i.onsuccess=Ce(()=>{(function({indexedDB:a,IDBKeyRange:c},l){!Ei(a)&&l!==Rs&&Ai(a,c).delete(l).catch(ve)})(this._deps,this.name),r()}),i.onerror=ot(s),i.onblocked=this._fireOnBlocked};if(t)throw new J.InvalidArgument("Arguments not allowed in db.delete()");n.isBeingOpened?n.dbReadyPromise.then(o):o()})}backendDB(){return this.idbdb}isOpen(){return this.idbdb!==null}hasBeenClosed(){const t=this._state.dbOpenError;return t&&t.name==="DatabaseClosed"}hasFailed(){return this._state.dbOpenError!==null}dynamicallyOpened(){return this._state.autoSchema}get tables(){return Se(this._allTables).map(t=>this._allTables[t])}transaction(){const t=ug.apply(this,arguments);return this._transaction.apply(this,t)}_transaction(t,n,r){let s=Z.trans;s&&s.db===this&&t.indexOf("!")===-1||(s=null);const o=t.indexOf("?")!==-1;let i,a;t=t.replace("!","").replace("?","");try{if(a=n.map(l=>{var u=l instanceof this.Table?l.name:l;if(typeof u!="string")throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return u}),t=="r"||t===qs)i=qs;else{if(t!="rw"&&t!=Ws)throw new J.InvalidArgument("Invalid transaction mode: "+t);i=Ws}if(s){if(s.mode===qs&&i===Ws){if(!o)throw new J.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");s=null}s&&a.forEach(l=>{if(s&&s.storeNames.indexOf(l)===-1){if(!o)throw new J.SubTransaction("Table "+l+" not included in parent transaction.");s=null}}),o&&s&&!s.active&&(s=null)}}catch(l){return s?s._promise(null,(u,d)=>{d(l)}):Oe(l)}const c=Xl.bind(null,this,i,a,s,r);return s?s._promise(i,c,"lock"):Z.trans?Kn(Z.transless,()=>this._whenReady(c)):this._whenReady(c)}table(t){if(!We(this._allTables,t))throw new J.InvalidTable(`Table ${t} does not exist`);return this._allTables[t]}}const gg=typeof Symbol<"u"&&"observable"in Symbol?Symbol.observable:"@@observable";class yg{constructor(t){this._subscribe=t}subscribe(t,n,r){return this._subscribe(t&&typeof t!="function"?t:{next:t,error:n,complete:r})}[gg](){return this}}function eu(e,t){return Se(t).forEach(n=>{bs(e[n]||(e[n]=new gt),t[n])}),e}function vg(e){let t,n=!1;const r=new yg(s=>{const o=bi(e);let i=!1,a={},c={};const l={get closed(){return i},unsubscribe:()=>{i=!0,Vt.storagemutated.unsubscribe(m)}};s.start&&s.start(l);let u=!1,d=!1;function f(){return Se(c).some(h=>a[h]&&pg(a[h],c[h]))}const m=h=>{eu(a,h),f()&&y()},y=()=>{if(u||i)return;a={};const h={},v=function(b){o&&Bn();const w=()=>Kt(e,{subscr:b,trans:null}),x=Z.trans?Kn(Z.transless,w):w();return o&&x.then(_t,_t),x}(h);d||(Vt(pr,m),d=!0),u=!0,Promise.resolve(v).then(b=>{n=!0,t=b,u=!1,i||(f()?y():(a={},c=h,s.next&&s.next(b)))},b=>{u=!1,n=!1,s.error&&s.error(b),l.unsubscribe()})};return y(),l});return r.hasValue=()=>n,r.getValue=()=>t,r}let Go;try{Go={indexedDB:xe.indexedDB||xe.mozIndexedDB||xe.webkitIndexedDB||xe.msIndexedDB,IDBKeyRange:xe.IDBKeyRange||xe.webkitIDBKeyRange}}catch{Go={indexedDB:null,IDBKeyRange:null}}const Gt=tn;function Jr(e){let t=vt;try{vt=!0,Vt.storagemutated.fire(e)}finally{vt=t}}Dn(Gt,{...Hr,delete:e=>new Gt(e,{addons:[]}).delete(),exists:e=>new Gt(e,{addons:[]}).open().then(t=>(t.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(e){try{return function({indexedDB:t,IDBKeyRange:n}){return Ei(t)?Promise.resolve(t.databases()).then(r=>r.map(s=>s.name).filter(s=>s!==Rs)):Ai(t,n).toCollection().primaryKeys()}(Gt.dependencies).then(e)}catch{return Oe(new J.MissingAPI)}},defineClass:()=>function(e){De(this,e)},ignoreTransaction:e=>Z.trans?Kn(Z.transless,e):e(),vip:Wo,async:function(e){return function(){try{var t=Ho(e.apply(this,arguments));return t&&typeof t.then=="function"?t:j.resolve(t)}catch(n){return Oe(n)}}},spawn:function(e,t,n){try{var r=Ho(e.apply(n,t||[]));return r&&typeof r.then=="function"?r:j.resolve(r)}catch(s){return Oe(s)}},currentTransaction:{get:()=>Z.trans||null},waitFor:function(e,t){const n=j.resolve(typeof e=="function"?Gt.ignoreTransaction(e):e).timeout(t||6e4);return Z.trans?Z.trans.waitFor(n):n},Promise:j,debug:{get:()=>dt,set:e=>{Ml(e,e==="dexie"?()=>!0:ql)}},derive:_n,extend:De,props:Dn,override:Sl,Events:nr,on:Vt,liveQuery:vg,extendObservabilitySet:eu,getByKeyPath:wt,setByKeyPath:Je,delByKeyPath:function(e,t){typeof t=="string"?Je(e,t,void 0):"length"in t&&[].map.call(t,function(n){Je(e,n,void 0)})},shallowClone:Rl,deepClone:_r,getObjectDiff:Ri,cmp:Ne,asap:Al,minKey:Lo,addons:[],connections:tr,errnames:xi,dependencies:Go,semVer:Ga,version:Ga.split(".").map(e=>parseInt(e)).reduce((e,t,n)=>e+t/Math.pow(10,2*n))}),Gt.maxKey=mr(Gt.dependencies.IDBKeyRange),typeof dispatchEvent<"u"&&typeof addEventListener<"u"&&(Vt(pr,e=>{if(!vt){let t;Es?(t=document.createEvent("CustomEvent"),t.initCustomEvent(Dt,!0,!0,e)):t=new CustomEvent(Dt,{detail:e}),vt=!0,dispatchEvent(t),vt=!1}}),addEventListener(Dt,({detail:e})=>{vt||Jr(e)}));let vt=!1;if(typeof BroadcastChannel<"u"){const e=new BroadcastChannel(Dt);typeof e.unref=="function"&&e.unref(),Vt(pr,t=>{vt||e.postMessage(t)}),e.onmessage=t=>{t.data&&Jr(t.data)}}else if(typeof self<"u"&&typeof navigator<"u"){Vt(pr,t=>{try{vt||(typeof localStorage<"u"&&localStorage.setItem(Dt,JSON.stringify({trig:Math.random(),changedParts:t})),typeof self.clients=="object"&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(n=>n.postMessage({type:Dt,changedParts:t})))}catch{}}),typeof addEventListener<"u"&&addEventListener("storage",t=>{if(t.key===Dt){const n=JSON.parse(t.newValue);n&&Jr(n.changedParts)}});const e=self.document&&navigator.serviceWorker;e&&e.addEventListener("message",function({data:t}){t&&t.type===Dt&&Jr(t.changedParts)})}j.rejectionMapper=function(e,t){if(!e||e instanceof Cn||e instanceof TypeError||e instanceof SyntaxError||!e.name||!qa[e.name])return e;var n=new qa[e.name](t||e.message,e);return"stack"in e&&bt(n,"stack",{get:function(){return this.inner.stack}}),n},Ml(dt,ql);class bg extends tn{sessions;messages;preferences;constructor(){super("chatui-db"),this.version(1).stores({sessions:"id, updatedAt",messages:"id, sessionId, createdAt"}),this.version(2).stores({preferences:"key"})}}const ge=new bg,Qo=new Set;function Sr(){for(const e of Array.from(Qo))try{e()}catch{}}function wg(e){return Qo.add(e),()=>Qo.delete(e)}async function xg(){const e=crypto.randomUUID(),t=Date.now(),n={id:e,createdAt:t,updatedAt:t};return await ge.sessions.add(n),Sr(),n}async function Pi(e){await ge.sessions.update(e,{updatedAt:Date.now()}),Sr()}async function _g(){return ge.sessions.orderBy("updatedAt").reverse().toArray()}async function Cg(e){await ge.transaction("rw",ge.sessions,ge.messages,async()=>{await ge.messages.where("sessionId").equals(e).delete(),await ge.sessions.delete(e)}),Sr()}async function kg(e){return(await ge.messages.where("sessionId").equals(e).sortBy("createdAt")).map(n=>n.item)}async function rc(e,t){const n={id:t.id,sessionId:e,createdAt:t.timestamp instanceof Date?t.timestamp.getTime():Date.now(),item:t};await ge.transaction("rw",ge.messages,ge.sessions,async()=>{await ge.messages.add(n),await Pi(e)})}async function Be(e,t,n){await ge.transaction("rw",ge.messages,ge.sessions,async()=>{await ge.messages.put({id:t.id,sessionId:e,createdAt:t.timestamp instanceof Date?t.timestamp.getTime():Date.now(),item:t}),n?.bumpTimestamp!==!1&&await Pi(e)})}async function Ys(e,t,n){await ge.transaction("rw",ge.messages,ge.sessions,async()=>{await ge.messages.delete(t),n&&await ge.messages.delete(n),await ge.messages.where("sessionId").equals(e).count()===0?await ge.sessions.delete(e):await Pi(e)}),Sr()}async function Sg(e,t){const n=(t||"").trim();n&&(await ge.transaction("rw",ge.sessions,async()=>{const r=await ge.sessions.get(e);r&&!r.title&&await ge.sessions.update(e,{title:n})}),Sr())}async function Yo(e){return(await ge.preferences.get(e))?.value}async function Mt(e,t){await ge.preferences.put({key:e,value:t})}const sc="x-context-kept-count";function Xo(e){return typeof e=="string"?e:Array.isArray(e)?e.map(t=>Xo(t)).filter(Boolean).join(""):!e||typeof e!="object"?"":typeof e.text=="string"?e.text:""}const oc=async(e,t)=>{const n=e.body?.getReader();if(!n)return{raw:await e.text(),sawDataPrefix:!1};let r="",s=!1;const o=new TextDecoder;let i=!1,a="";for(;;){const{done:c,value:l}=await n.read();if(c)break;const u=o.decode(l,{stream:!0});r+=u,a+=u;const d=/\r?\n$/.test(a),f=a.split(/\r?\n/);a=d?"":f.pop()||"";for(const m of f){const y=m.trim();if(!y||!y.startsWith("data:"))continue;s=!0;const h=y.slice(y.indexOf(":")+1).trimStart();if(h==="[DONE]"){i=!0;break}try{const b=JSON.parse(h)?.choices?.[0]?.delta??{},w=Xo(b?.content),x=Xo(b?.reasoning??b?.reasoning_content);(w||x)&&t({contentDelta:w,reasoningDelta:x})}catch{}}if(i)break}return{raw:r,sawDataPrefix:s}};function Ag(e){return!e||e.length===0?"":e.map(t=>`${t.content}`).join(` `)+` `}function Eg(e){const t=[];for(const n of e)if(n.type==="user-message"){const r=n.data&&(n.data.sentContent??n.data.content)||"",s=String(r),o=/([\s\S]*?)<\/file>/g,a=Array.from(s.matchAll(o)).map(c=>c&&c[1]?String(c[1]):"").filter(c=>typeof c=="string"&&c.startsWith("data:image/"));if(a.length>0){const c=s.replace(o,"").trimStart(),l=[],u=jt(c);u&&u.trim().length>0&&l.push({type:"text",text:u});for(const d of a)l.push({type:"image_url",image_url:{url:d}});t.push({role:"user",content:l})}else t.push({role:"user",content:jt(s)})}else if(n.type==="chat-message"&&!n.data.isStreaming){const r=n.data,s=Array.isArray(r.variants)?r.variants:[],o=typeof r.activeVariantIndex=="number"&&s.length>0?Math.min(Math.max(0,r.activeVariantIndex),s.length-1):-1,i=o>=0?s[o]:null,a=i?i.content:r.content;t.push({role:"assistant",content:jt(Xn(a).content)})}return t}function Hn(e,t,n){const r=t||e.content||"",s=n||e.reasoning||"",i=[...Array.isArray(e.variants)?e.variants:[]];if(r.trim().length>0||s.trim().length>0){const c=i.length>0?i[i.length-1]:void 0,l=c?.content??c,u=c?.reasoning||"";(l!==r||u!==s)&&i.push({content:r,reasoning:s,model:e.model})}const a=Math.max(0,i.length-1);return{...e,isStreaming:!1,variants:i,activeVariantIndex:a,content:r,reasoning:s,model:i[a]?.model||e.model}}function ic(e,t,n){const r=e.data;return{...e,data:{...r,content:t,reasoning:n??r.reasoning}}}function ac(e){return{id:`error-${Date.now()}`,type:"system-message",timestamp:new Date,data:{content:e,level:"error"}}}function tu(){return di({queryKey:["templates"],queryFn:async()=>{const e=await fetch("/api/templates",{headers:{Accept:"application/json"}});if(!e.ok)throw new Error("Failed to fetch templates");const t=await e.json();return Array.isArray(t?.data)?t.data.map(r=>({name:r?.name,label:r?.label})).filter(r=>typeof r.name=="string"&&typeof r.label=="string"):[]},staleTime:6e4})}const Rg=()=>{const[e,t]=p.useState(null),[n,r]=p.useState(null),{data:s=[]}=yi(),{data:o=[]}=tu();p.useEffect(()=>{(async()=>{let a=null,c=null;try{const l=await Yo("selectedModel");if(l&&typeof l=="string")a=l;else{const u=localStorage.getItem("chatui.selectedModel");if(u&&typeof u=="string"){a=u;try{await Mt("selectedModel",u)}catch{}try{localStorage.removeItem("chatui.selectedModel")}catch{}}}}catch{}a&&t(a);try{const l=await Yo("selectedTemplate");if(l&&typeof l=="string")c=l;else{const u=localStorage.getItem("chatui.selectedTemplate");if(u&&typeof u=="string"){c=u;try{await Mt("selectedTemplate",u)}catch{}try{localStorage.removeItem("chatui.selectedTemplate")}catch{}}}}catch{}c&&r(c)})()},[]),p.useEffect(()=>{if(s.length===0)return;const c=e&&s.some(l=>l.id===e)?e:s[0]?.id;if(c&&c!==e){t(c);try{Mt("selectedModel",c)}catch{}}},[s,e]),p.useEffect(()=>{if(o.length===0)return;const a=o.map(u=>u.name),l=n&&a.includes(n)?n:a[0];if(l&&l!==n){r(l);try{Mt("selectedTemplate",l)}catch{}}},[o,n]);const i=p.useCallback(()=>{if(e&&s.some(a=>a.id===e))return e;if(s.length>0){const a=s[0].id;t(a);try{Mt("selectedModel",a)}catch{}return a}return null},[e,s]);return{selectedModel:e,setSelectedModel:a=>{t(a);try{Mt("selectedModel",a)}catch{}},selectedTemplate:n,setSelectedTemplate:a=>{r(a);try{Mt("selectedTemplate",a)}catch{}},pickEffectiveModel:i}},Og=()=>{const[e,t]=p.useState(null),n=p.useRef(null),r=p.useCallback(i=>{t(i),n.current=i},[]),s=p.useCallback(async i=>await kg(i),[]),o=p.useCallback(async()=>(r(null),null),[r]);return{sessionId:e,sessionIdRef:n,setSession:r,loadMessages:s,startNewSession:o}};function Pg(e,t){switch(t.type){case"insert-divider":{const n={id:t.id,type:"context-divider",timestamp:t.timestamp,data:{label:t.label}},r=[];for(let s=0;s=e.length&&r.push(n),r}case"remove-dividers":return e.filter(n=>n.type!=="context-divider");case"replace-all":return t.items;case"clear":return[];case"add-user":{const n={id:t.id,type:"user-message",timestamp:t.timestamp,data:{content:t.content,attachments:t.attachments,sentContent:t.sentContent}};return[...e,n]}case"add-streaming":{const n={id:t.id,type:"chat-message",timestamp:t.timestamp,data:{content:t.content||"",reasoning:"",role:"assistant",model:t.model,isStreaming:!0,variants:[],activeVariantIndex:0}};return[...e,n]}case"update-streaming":return e.map(n=>{if(n.id!==t.id||n.type!=="chat-message")return n;const r=n.data;return{...n,data:{...r,content:t.content,reasoning:t.reasoning??r.reasoning}}});case"complete-streaming":return e.map(n=>{if(n.id!==t.id||n.type!=="chat-message")return n;const r=n.data,s=(typeof t.finalContent=="string"?t.finalContent:r.content)||"",o=(typeof t.finalReasoning=="string"?t.finalReasoning:r.reasoning)||"",a=[...Array.isArray(r.variants)?r.variants:[]];if(s.trim().length>0||o.trim().length>0){const l=a.length>0?a[a.length-1]:void 0,u=l?.content,d=l?.reasoning||"";(u!==s||d!==o)&&a.push({content:s,reasoning:o,model:r.model})}const c=Math.max(0,a.length-1);return{...n,data:{...r,isStreaming:!1,variants:a,activeVariantIndex:c,content:s,reasoning:o,model:a[c]?.model||r.model}}});case"cancel-streaming":return e.map(n=>{if(n.id!==t.id||n.type!=="chat-message")return n;const r=n.data;return{...n,data:{...r,isStreaming:!1}}});case"set-variant-index":return e.map(n=>{if(n.id!==t.id||n.type!=="chat-message")return n;const r=n.data,s=Array.isArray(r.variants)?r.variants:[];if(s.length===0)return n;const o=Math.min(Math.max(0,t.index),s.length-1),i=s[o],a=i?.content,c=i?.reasoning||r.reasoning,l=i?.model||r.model,u={...r,activeVariantIndex:o,content:a||r.content,reasoning:c,model:l};return{...n,data:u}});case"delete-assistant-turn":{const n=e.findIndex(s=>s.id===t.assistantId);if(n===-1)return e;const r=[];for(let s=0;s{const[e,t]=p.useReducer(Pg,[]),n=p.useCallback((m,y,h)=>{const v=`user-${Date.now()}`,b=new Date;return t({type:"add-user",id:v,timestamp:b,content:m,attachments:y,sentContent:h}),{id:v,type:"user-message",timestamp:b,data:{content:m,attachments:y,sentContent:h}}},[]),r=p.useCallback((m="",y)=>{const h=`assistant-${Date.now()}`,v=new Date;return t({type:"add-streaming",id:h,timestamp:v,content:m,model:y}),{id:h,type:"chat-message",timestamp:v,data:{content:m,reasoning:"",role:"assistant",model:y,isStreaming:!0,variants:[],activeVariantIndex:0}}},[]),s=p.useCallback((m,y)=>{const h=`divider-${Date.now()}`,v=new Date;return t({type:"insert-divider",id:h,timestamp:v,label:m,beforeIndex:y}),{id:h,type:"context-divider",timestamp:v,data:{label:m}}},[]),o=p.useCallback(()=>{t({type:"remove-dividers"})},[]),i=p.useCallback((m,y,h)=>{const v=e.find(w=>w.id===m&&w.type==="chat-message");let b=null;if(v){const w=v.data;b={...v,data:{...w,content:y,reasoning:h??w.reasoning}}}return t({type:"update-streaming",id:m,content:y,reasoning:h}),b},[e]),a=p.useCallback((m,y,h)=>{const v=e.find(w=>w.id===m&&w.type==="chat-message");let b=null;if(v){const w=v.data,x=(typeof y=="string"?y:w.content)||"",_=(typeof h=="string"?h:w.reasoning)||"",S=[...Array.isArray(w.variants)?w.variants:[]];if(x.trim().length>0||_.trim().length>0){const A=S.length>0?S[S.length-1]:void 0,O=A?.content,R=A?.reasoning||"";(O!==x||R!==_)&&S.push({content:x,reasoning:_,model:w.model})}const k=Math.max(0,S.length-1);b={...v,data:{...w,isStreaming:!1,variants:S,activeVariantIndex:k,content:x,reasoning:_,model:S[k]?.model||w.model}}}return t({type:"complete-streaming",id:m,finalContent:y,finalReasoning:h}),b},[e]),c=p.useCallback(m=>{const y=e.find(v=>v.id===m&&v.type==="chat-message");let h=null;if(y){const v=y.data;h={...y,data:{...v,isStreaming:!1}}}return t({type:"cancel-streaming",id:m}),h},[e]),l=p.useCallback((m,y)=>{const h=e.find(b=>b.id===m&&b.type==="chat-message");let v=null;if(h){const b=h.data,w=Array.isArray(b.variants)?b.variants:[];if(w.length>0){const x=Math.min(Math.max(0,y),w.length-1),_=w[x],C=_?.content,S=_?.reasoning||b.reasoning,k=_?.model||b.model;v={...h,data:{...b,activeVariantIndex:x,content:C||b.content,reasoning:S,model:k}}}}return t({type:"set-variant-index",id:m,index:y}),v},[e]),u=p.useCallback(m=>{const y=e.findIndex(v=>v.id===m),h=y!==-1&&e[y-1]?.type==="user-message"?e[y-1].id:void 0;return t({type:"delete-assistant-turn",assistantId:m}),{removedPrevUserId:h}},[e]),d=p.useCallback(()=>{t({type:"clear"})},[]),f=p.useCallback((m,y)=>{m.length===0&&!y?.allowEmpty&&e.length>0||t({type:"replace-all",items:m})},[e]);return{timelineItems:e,replaceAll:f,addUserMessage:n,addStreamingMessage:r,insertDivider:s,removeDividers:o,updateStreamingMessage:i,completeStreamingMessage:a,cancelStreamingMessage:c,setAssistantSwipeIndex:l,deleteAssistantTurn:u,clearChat:d}},Tg=()=>{const[e,t]=p.useState(!1),n=p.useRef(null),r=p.useRef(null),s="Dolphin can only see the messages below",{selectedModel:o,setSelectedModel:i,selectedTemplate:a,setSelectedTemplate:c,pickEffectiveModel:l}=Rg(),{sessionId:u,sessionIdRef:d,setSession:f,loadMessages:m,startNewSession:y}=Og(),{timelineItems:h,replaceAll:v,addUserMessage:b,addStreamingMessage:w,updateStreamingMessage:x,completeStreamingMessage:_,setAssistantSwipeIndex:C,deleteAssistantTurn:S,clearChat:k,insertDivider:A,removeDividers:O}=Mg(),R=p.useCallback(async(E,P)=>{const U=[],me=E.map(Y=>{if(Y.type==="chat-message"){const L=Y.data;let X=!1;const de={...L};if(L?.isStreaming&&(de.isStreaming=!1,X=!0),Array.isArray(L?.variants)&&L.variants.length>0){const ne=L.variants.map(K=>typeof K=="string"?{content:K,model:L.model}:K);ne.some((K,re)=>K!==L.variants[re])&&(de.variants=ne,X=!0);const D=ne.length-1;(typeof L.activeVariantIndex!="number"||L.activeVariantIndex<0||L.activeVariantIndex>D)&&(de.activeVariantIndex=D,X=!0);const ie=typeof de.activeVariantIndex=="number"?de.activeVariantIndex:D,I=ne[ie];I&&(I.content&&I.content!==L.content&&(de.content=I.content,X=!0),(I.reasoning||"")!==(L.reasoning||"")&&(de.reasoning=I.reasoning||"",X=!0),I.model&&I.model!==L.model&&(de.model=I.model,X=!0))}if(X){const ne={...Y,data:de};return U.push(ne),ne}}return Y});v(me),P&&await Promise.all(U.map(Y=>Be(P,Y,{bumpTimestamp:!1})))},[v]),T=p.useCallback(async(E,P)=>{if(!E.trim()||e)return;t(!0);let U=u;if(!U){const F=await xg();U=F.id,f(F.id)}const me=P?.map(F=>({id:F.id,name:F.name})),Y=Ag(P),L=`${Y}${E}`,X=b(E,me,L);if(U){await rc(U,X);const F=(E||"").replace(/\s+/g," ").trim(),be=F.length>60?F.slice(0,57)+"…":F;try{await Sg(U,be)}catch{}}const de=l();if(!de){const F={id:`error-${Date.now()}`,type:"system-message",timestamp:new Date,data:{content:"No models available. Please configure an API key or try again later.",level:"error"}};v([...h,F]),t(!1);return}const ne=w("",de),D=ne.id;let ie=ne;r.current=D,U&&await rc(U,ne);const I=Eg(h),K=(P||[]).filter(F=>typeof F.content=="string"&&F.content.startsWith("data:")).map(F=>({type:"image_url",image_url:{url:F.content}})),ce=`${(P||[]).some(F=>typeof F.content=="string"&&F.content.startsWith("data:"))?"":Y}${jt(E)}`;if(K.length>0){const F=[];ce&&ce.trim().length>0&&F.push({type:"text",text:ce});for(const be of K)F.push(be);I.push({role:"user",content:F})}else I.push({role:"user",content:ce});try{const F=new AbortController;n.current=F;const be=await Ua("/api/chat",{messages:I,model:de,template:a||void 0},{signal:F.signal,headers:{Accept:"text/event-stream"}});if(!be.ok){let le="Failed to get response";try{const we=await be.json();le=we&&(we.error||JSON.stringify(we))||le}catch{try{le=await be.text()}catch{}}const ke={id:`error-${Date.now()}`,type:"system-message",timestamp:new Date,data:{content:`API error (${be.status}): ${le}`,level:"error"}};if(v([...h.filter(we=>we.id!==D&&we.id!==X.id),ke]),U)try{Ys(U,D,X.id)}catch{}return}try{O();const le=be.headers.get(sc);if(le){const ke=parseInt(le,10);if(Number.isFinite(ke)&&ke>=0){const we=[];for(let Ye=0;Ye{ye+=le,_e+=ke,x(D,ye,_e),ie=ic(ie,ye,_e);const we=d.current;we&&Be(we,ie)});if(_(D,ye,_e),U){const le=ie.data;ie={...ie,data:Hn(le,ye,_e)},await Be(U,ie)}if(!rt&&pe)try{const{content:le,reasoning:ke}=Xn(pe);if((le||ke)&&(x(D,le,ke),_(D,le,ke),U)){const we=ie.data;ie={...ie,data:Hn(we,le,ke)},await Be(U,ie)}}catch{if(x(D,pe),_(D,pe),U){const le=ie.data;ie={...ie,data:Hn(le,pe)},await Be(U,ie)}}}catch(F){if(F?.name==="AbortError"){const be=r.current;if(be){_(be);const ye=d.current;if(ye){const _e=ie.data,pe=Array.isArray(_e.variants)?_e.variants:[],rt=Math.max(0,pe.length-1);ie={...ie,data:{..._e,isStreaming:!1,activeVariantIndex:rt,content:_e.content,reasoning:_e.reasoning,variants:pe}},Be(ye,ie)}}}else{const be=ac("Failed to send message. Please try again.");if(v([...h.filter(ye=>ye.id!==D&&ye.id!==X.id),be]),U)try{Ys(U,D,X.id)}catch{}}}finally{t(!1),n.current=null,r.current=null}},[e,u,f,b,l,v,h,w,x,_,a,A,O,d]),q=p.useCallback(()=>{const E=n.current;if(E){E.abort();const P=r.current;if(P){const U=_(P),me=d.current;me&&U&&Be(me,U)}n.current=null,r.current=null,t(!1)}},[_,d]),H=p.useCallback(async E=>{if(e)return;const P=h.findIndex(Y=>Y.id===E);if(P===-1)return;const U=h.slice(0,P).filter(Y=>Y.type==="user-message"||Y.type==="chat-message").map(Y=>{if(Y.type==="user-message"){const L=String(Y.data&&(Y.data.sentContent??Y.data.content)||""),X=/([\s\S]*?)<\/file>/g,ne=Array.from(L.matchAll(X)).map(D=>D&&D[1]?String(D[1]):"").filter(D=>typeof D=="string"&&D.startsWith("data:image/"));if(ne.length>0){const D=L.replace(X,"").trimStart(),ie=[],I=jt(D);I&&I.trim().length>0&&ie.push({type:"text",text:I});for(const K of ne)ie.push({type:"image_url",image_url:{url:K}});return{role:"user",content:ie}}return{role:"user",content:jt(L)}}return{role:"assistant",content:jt(Xn(Y.data.content).content)}}),me=l();if(v(h.map(Y=>{if(Y.id!==E||Y.type!=="chat-message")return Y;const L=Y.data;return{...Y,data:{...L,content:"",reasoning:"",isStreaming:!0,model:me||o||L.model}}})),d.current){const Y=h.find(L=>L.id===E);if(Y){const L=Y.data,X={...Y,data:{...L,content:"",reasoning:"",isStreaming:!0,model:me||o||L.model}};Be(d.current,X)}}try{t(!0);const Y=new AbortController;n.current=Y,r.current=E;const L=await Ua("/api/chat",{messages:U,model:me||void 0,template:a||void 0},{signal:Y.signal,headers:{Accept:"text/event-stream"}});if(!L.ok){let K="Failed to get response";try{const ce=await L.json();K=ce.error||JSON.stringify(ce)}catch{try{K=await L.text()}catch{}}const re={id:`error-${Date.now()}`,type:"system-message",timestamp:new Date,data:{content:`API error (${L.status}): ${K}`,level:"error"}};v([...h,re]);return}try{O();const K=L.headers.get(sc);if(K){const re=parseInt(K,10);if(Number.isFinite(re)&&re>=0){const ce=U.length;if(reK.id===E)||null;const{raw:D,sawDataPrefix:ie}=await oc(L,({contentDelta:K,reasoningDelta:re})=>{X+=K,de+=re,x(E,X,de),ne&&(ne=ic(ne,X,de));const ce=d.current;ce&&ne&&Be(ce,ne)});_(E,X,de);const I=d.current;if(I&&ne){const K=ne.data;ne={...ne,data:Hn(K,X,de)},await Be(I,ne)}if(!ie&&D){const{content:K,reasoning:re}=Xn(D);if((K||re)&&(x(E,K,re),_(E,K,re),I&&ne)){const ce=ne.data;ne={...ne,data:Hn(ce,K,re)},await Be(I,ne)}}}catch(Y){if(Y?.name==="AbortError"){_(E);const L=d.current,X=h.find(de=>de.id===E);L&&X&&Be(L,X)}else{const L=ac("Failed to regenerate message.");v([...h,L])}}finally{t(!1),n.current=null,r.current=null}},[e,h,l,o,a,v,x,_,A,O,d]),W=p.useCallback((E,P)=>{const U=C(E,P),me=d.current;me&&U&&Be(me,U)},[C,d]),ue=p.useCallback(E=>{r.current===E&&n.current&&n.current.abort();const{removedPrevUserId:P}=S(E),U=d.current;U&&Ys(U,E,P)},[S]),Q=p.useCallback(async E=>{if(!E){f(null),v([],{allowEmpty:!0});return}const P=await m(E);f(E),await R(P,E)},[m,v,R,f]),G=p.useCallback(async()=>(await y(),v([],{allowEmpty:!0}),null),[v,y]);return{timelineItems:h,isLoading:e,sendMessage:T,stopStreaming:q,regenerateMessage:H,deleteAssistantTurn:ue,clearChat:k,sessionId:u,selectSession:Q,startNewSession:G,setAssistantSwipeIndex:W,selectedModel:o,setSelectedModel:i,selectedTemplate:a,setSelectedTemplate:c}};function se(e,t,{checkForDefaultPrevented:n=!0}={}){return function(s){if(e?.(s),n===!1||!s.defaultPrevented)return t?.(s)}}function cc(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Os(...e){return t=>{let n=!1;const r=e.map(s=>{const o=cc(s,t);return!n&&typeof o=="function"&&(n=!0),o});if(n)return()=>{for(let s=0;s{const{children:i,...a}=o,c=p.useMemo(()=>a,Object.values(a));return g.jsx(n.Provider,{value:c,children:i})};r.displayName=e+"Provider";function s(o){const i=p.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${o}\` must be used within \`${e}\``)}return[r,s]}function un(e,t=[]){let n=[];function r(o,i){const a=p.createContext(i),c=n.length;n=[...n,i];const l=d=>{const{scope:f,children:m,...y}=d,h=f?.[e]?.[c]||a,v=p.useMemo(()=>y,Object.values(y));return g.jsx(h.Provider,{value:v,children:m})};l.displayName=o+"Provider";function u(d,f){const m=f?.[e]?.[c]||a,y=p.useContext(m);if(y)return y;if(i!==void 0)return i;throw new Error(`\`${d}\` must be used within \`${o}\``)}return[l,u]}const s=()=>{const o=n.map(i=>p.createContext(i));return function(a){const c=a?.[e]||o;return p.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])}};return s.scopeName=e,[r,Ng(s,...t)]}function Ng(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(o){const i=r.reduce((a,{useScope:c,scopeName:l})=>{const d=c(o)[`__scope${l}`];return{...a,...d}},{});return p.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var Ut=globalThis?.document?p.useLayoutEffect:()=>{},Dg=Bc[" useInsertionEffect ".trim().toString()]||Ut;function Mi({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[s,o,i]=jg({defaultProp:t,onChange:n}),a=e!==void 0,c=a?e:s;{const u=p.useRef(e!==void 0);p.useEffect(()=>{const d=u.current;d!==a&&console.warn(`${r} is changing from ${d?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),u.current=a},[a,r])}const l=p.useCallback(u=>{if(a){const d=Fg(u)?u(e):u;d!==e&&i.current?.(d)}else o(u)},[a,e,o,i]);return[c,l]}function jg({defaultProp:e,onChange:t}){const[n,r]=p.useState(e),s=p.useRef(n),o=p.useRef(t);return Dg(()=>{o.current=t},[t]),p.useEffect(()=>{s.current!==n&&(o.current?.(n),s.current=n)},[n,s]),[n,r,o]}function Fg(e){return typeof e=="function"}var Ti=ff();const Lg=df(Ti);function jn(e){const t=Bg(e),n=p.forwardRef((r,s)=>{const{children:o,...i}=r,a=p.Children.toArray(o),c=a.find(zg);if(c){const l=c.props.children,u=a.map(d=>d===c?p.Children.count(l)>1?p.Children.only(null):p.isValidElement(l)?l.props.children:null:d);return g.jsx(t,{...i,ref:s,children:p.isValidElement(l)?p.cloneElement(l,void 0,u):null})}return g.jsx(t,{...i,ref:s,children:o})});return n.displayName=`${e}.Slot`,n}var $g=jn("Slot");function Bg(e){const t=p.forwardRef((n,r)=>{const{children:s,...o}=n;if(p.isValidElement(s)){const i=Ug(s),a=Vg(o,s.props);return s.type!==p.Fragment&&(a.ref=r?Os(r,i):i),p.cloneElement(s,a)}return p.Children.count(s)>1?p.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var nu=Symbol("radix.slottable");function Kg(e){const t=({children:n})=>g.jsx(g.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=nu,t}function zg(e){return p.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===nu}function Vg(e,t){const n={...t};for(const r in t){const s=e[r],o=t[r];/^on[A-Z]/.test(r)?s&&o?n[r]=(...a)=>{const c=o(...a);return s(...a),c}:s&&(n[r]=s):r==="style"?n[r]={...s,...o}:r==="className"&&(n[r]=[s,o].filter(Boolean).join(" "))}return{...e,...n}}function Ug(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var qg=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ae=qg.reduce((e,t)=>{const n=jn(`Primitive.${t}`),r=p.forwardRef((s,o)=>{const{asChild:i,...a}=s,c=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),g.jsx(c,{...a,ref:o})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function ru(e,t){e&&Ti.flushSync(()=>e.dispatchEvent(t))}function su(e){const t=e+"CollectionProvider",[n,r]=un(t),[s,o]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=h=>{const{scope:v,children:b}=h,w=st.useRef(null),x=st.useRef(new Map).current;return g.jsx(s,{scope:v,itemMap:x,collectionRef:w,children:b})};i.displayName=t;const a=e+"CollectionSlot",c=jn(a),l=st.forwardRef((h,v)=>{const{scope:b,children:w}=h,x=o(a,b),_=Pe(v,x.collectionRef);return g.jsx(c,{ref:_,children:w})});l.displayName=a;const u=e+"CollectionItemSlot",d="data-radix-collection-item",f=jn(u),m=st.forwardRef((h,v)=>{const{scope:b,children:w,...x}=h,_=st.useRef(null),C=Pe(v,_),S=o(u,b);return st.useEffect(()=>(S.itemMap.set(_,{ref:_,...x}),()=>void S.itemMap.delete(_))),g.jsx(f,{[d]:"",ref:C,children:w})});m.displayName=u;function y(h){const v=o(e+"CollectionConsumer",h);return st.useCallback(()=>{const w=v.collectionRef.current;if(!w)return[];const x=Array.from(w.querySelectorAll(`[${d}]`));return Array.from(v.itemMap.values()).sort((S,k)=>x.indexOf(S.ref.current)-x.indexOf(k.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:i,Slot:l,ItemSlot:m},y,r]}var Wg=p.createContext(void 0);function ou(e){const t=p.useContext(Wg);return e||t||"ltr"}function Ct(e){const t=p.useRef(e);return p.useEffect(()=>{t.current=e}),p.useMemo(()=>(...n)=>t.current?.(...n),[])}function Hg(e,t=globalThis?.document){const n=Ct(e);p.useEffect(()=>{const r=s=>{s.key==="Escape"&&n(s)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var Zg="DismissableLayer",Jo="dismissableLayer.update",Gg="dismissableLayer.pointerDownOutside",Qg="dismissableLayer.focusOutside",lc,iu=p.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Ii=p.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:s,onFocusOutside:o,onInteractOutside:i,onDismiss:a,...c}=e,l=p.useContext(iu),[u,d]=p.useState(null),f=u?.ownerDocument??globalThis?.document,[,m]=p.useState({}),y=Pe(t,k=>d(k)),h=Array.from(l.layers),[v]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),b=h.indexOf(v),w=u?h.indexOf(u):-1,x=l.layersWithOutsidePointerEventsDisabled.size>0,_=w>=b,C=Jg(k=>{const A=k.target,O=[...l.branches].some(R=>R.contains(A));!_||O||(s?.(k),i?.(k),k.defaultPrevented||a?.())},f),S=ey(k=>{const A=k.target;[...l.branches].some(R=>R.contains(A))||(o?.(k),i?.(k),k.defaultPrevented||a?.())},f);return Hg(k=>{w===l.layers.size-1&&(r?.(k),!k.defaultPrevented&&a&&(k.preventDefault(),a()))},f),p.useEffect(()=>{if(u)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(lc=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),l.layersWithOutsidePointerEventsDisabled.add(u)),l.layers.add(u),uc(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=lc)}},[u,f,n,l]),p.useEffect(()=>()=>{u&&(l.layers.delete(u),l.layersWithOutsidePointerEventsDisabled.delete(u),uc())},[u,l]),p.useEffect(()=>{const k=()=>m({});return document.addEventListener(Jo,k),()=>document.removeEventListener(Jo,k)},[]),g.jsx(Ae.div,{...c,ref:y,style:{pointerEvents:x?_?"auto":"none":void 0,...e.style},onFocusCapture:se(e.onFocusCapture,S.onFocusCapture),onBlurCapture:se(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:se(e.onPointerDownCapture,C.onPointerDownCapture)})});Ii.displayName=Zg;var Yg="DismissableLayerBranch",Xg=p.forwardRef((e,t)=>{const n=p.useContext(iu),r=p.useRef(null),s=Pe(t,r);return p.useEffect(()=>{const o=r.current;if(o)return n.branches.add(o),()=>{n.branches.delete(o)}},[n.branches]),g.jsx(Ae.div,{...e,ref:s})});Xg.displayName=Yg;function Jg(e,t=globalThis?.document){const n=Ct(e),r=p.useRef(!1),s=p.useRef(()=>{});return p.useEffect(()=>{const o=a=>{if(a.target&&!r.current){let c=function(){au(Gg,n,l,{discrete:!0})};const l={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",s.current),s.current=c,t.addEventListener("click",s.current,{once:!0})):c()}else t.removeEventListener("click",s.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",o)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",o),t.removeEventListener("click",s.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function ey(e,t=globalThis?.document){const n=Ct(e),r=p.useRef(!1);return p.useEffect(()=>{const s=o=>{o.target&&!r.current&&au(Qg,n,{originalEvent:o},{discrete:!1})};return t.addEventListener("focusin",s),()=>t.removeEventListener("focusin",s)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function uc(){const e=new CustomEvent(Jo);document.dispatchEvent(e)}function au(e,t,n,{discrete:r}){const s=n.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&s.addEventListener(e,t,{once:!0}),r?ru(s,o):s.dispatchEvent(o)}var Xs=0;function cu(){p.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??dc()),document.body.insertAdjacentElement("beforeend",e[1]??dc()),Xs++,()=>{Xs===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Xs--}},[])}function dc(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Js="focusScope.autoFocusOnMount",eo="focusScope.autoFocusOnUnmount",fc={bubbles:!1,cancelable:!0},ty="FocusScope",Ni=p.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:s,onUnmountAutoFocus:o,...i}=e,[a,c]=p.useState(null),l=Ct(s),u=Ct(o),d=p.useRef(null),f=Pe(t,h=>c(h)),m=p.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;p.useEffect(()=>{if(r){let h=function(x){if(m.paused||!a)return;const _=x.target;a.contains(_)?d.current=_:Tt(d.current,{select:!0})},v=function(x){if(m.paused||!a)return;const _=x.relatedTarget;_!==null&&(a.contains(_)||Tt(d.current,{select:!0}))},b=function(x){if(document.activeElement===document.body)for(const C of x)C.removedNodes.length>0&&Tt(a)};document.addEventListener("focusin",h),document.addEventListener("focusout",v);const w=new MutationObserver(b);return a&&w.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",h),document.removeEventListener("focusout",v),w.disconnect()}}},[r,a,m.paused]),p.useEffect(()=>{if(a){pc.add(m);const h=document.activeElement;if(!a.contains(h)){const b=new CustomEvent(Js,fc);a.addEventListener(Js,l),a.dispatchEvent(b),b.defaultPrevented||(ny(ay(lu(a)),{select:!0}),document.activeElement===h&&Tt(a))}return()=>{a.removeEventListener(Js,l),setTimeout(()=>{const b=new CustomEvent(eo,fc);a.addEventListener(eo,u),a.dispatchEvent(b),b.defaultPrevented||Tt(h??document.body,{select:!0}),a.removeEventListener(eo,u),pc.remove(m)},0)}}},[a,l,u,m]);const y=p.useCallback(h=>{if(!n&&!r||m.paused)return;const v=h.key==="Tab"&&!h.altKey&&!h.ctrlKey&&!h.metaKey,b=document.activeElement;if(v&&b){const w=h.currentTarget,[x,_]=ry(w);x&&_?!h.shiftKey&&b===_?(h.preventDefault(),n&&Tt(x,{select:!0})):h.shiftKey&&b===x&&(h.preventDefault(),n&&Tt(_,{select:!0})):b===w&&h.preventDefault()}},[n,r,m.paused]);return g.jsx(Ae.div,{tabIndex:-1,...i,ref:f,onKeyDown:y})});Ni.displayName=ty;function ny(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Tt(r,{select:t}),document.activeElement!==n)return}function ry(e){const t=lu(e),n=hc(t,e),r=hc(t.reverse(),e);return[n,r]}function lu(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const s=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||s?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function hc(e,t){for(const n of e)if(!sy(n,{upTo:t}))return n}function sy(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function oy(e){return e instanceof HTMLInputElement&&"select"in e}function Tt(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&oy(e)&&t&&e.select()}}var pc=iy();function iy(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=mc(e,t),e.unshift(t)},remove(t){e=mc(e,t),e[0]?.resume()}}}function mc(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function ay(e){return e.filter(t=>t.tagName!=="A")}var cy=Bc[" useId ".trim().toString()]||(()=>{}),ly=0;function Sn(e){const[t,n]=p.useState(cy());return Ut(()=>{n(r=>r??String(ly++))},[e]),e||(t?`radix-${t}`:"")}const uy=["top","right","bottom","left"],qt=Math.min,ze=Math.max,ws=Math.round,Kr=Math.floor,lt=e=>({x:e,y:e}),dy={left:"right",right:"left",bottom:"top",top:"bottom"},fy={start:"end",end:"start"};function ei(e,t,n){return ze(e,qt(t,n))}function kt(e,t){return typeof e=="function"?e(t):e}function St(e){return e.split("-")[0]}function zn(e){return e.split("-")[1]}function Di(e){return e==="x"?"y":"x"}function ji(e){return e==="y"?"height":"width"}const hy=new Set(["top","bottom"]);function at(e){return hy.has(St(e))?"y":"x"}function Fi(e){return Di(at(e))}function py(e,t,n){n===void 0&&(n=!1);const r=zn(e),s=Fi(e),o=ji(s);let i=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(i=xs(i)),[i,xs(i)]}function my(e){const t=xs(e);return[ti(e),t,ti(t)]}function ti(e){return e.replace(/start|end/g,t=>fy[t])}const gc=["left","right"],yc=["right","left"],gy=["top","bottom"],yy=["bottom","top"];function vy(e,t,n){switch(e){case"top":case"bottom":return n?t?yc:gc:t?gc:yc;case"left":case"right":return t?gy:yy;default:return[]}}function by(e,t,n,r){const s=zn(e);let o=vy(St(e),n==="start",r);return s&&(o=o.map(i=>i+"-"+s),t&&(o=o.concat(o.map(ti)))),o}function xs(e){return e.replace(/left|right|bottom|top/g,t=>dy[t])}function wy(e){return{top:0,right:0,bottom:0,left:0,...e}}function uu(e){return typeof e!="number"?wy(e):{top:e,right:e,bottom:e,left:e}}function _s(e){const{x:t,y:n,width:r,height:s}=e;return{width:r,height:s,top:n,left:t,right:t+r,bottom:n+s,x:t,y:n}}function vc(e,t,n){let{reference:r,floating:s}=e;const o=at(t),i=Fi(t),a=ji(i),c=St(t),l=o==="y",u=r.x+r.width/2-s.width/2,d=r.y+r.height/2-s.height/2,f=r[a]/2-s[a]/2;let m;switch(c){case"top":m={x:u,y:r.y-s.height};break;case"bottom":m={x:u,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:d};break;case"left":m={x:r.x-s.width,y:d};break;default:m={x:r.x,y:r.y}}switch(zn(t)){case"start":m[i]-=f*(n&&l?-1:1);break;case"end":m[i]+=f*(n&&l?-1:1);break}return m}const xy=async(e,t,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:o=[],platform:i}=n,a=o.filter(Boolean),c=await(i.isRTL==null?void 0:i.isRTL(t));let l=await i.getElementRects({reference:e,floating:t,strategy:s}),{x:u,y:d}=vc(l,r,c),f=r,m={},y=0;for(let h=0;h({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:s,rects:o,platform:i,elements:a,middlewareData:c}=t,{element:l,padding:u=0}=kt(e,t)||{};if(l==null)return{};const d=uu(u),f={x:n,y:r},m=Fi(s),y=ji(m),h=await i.getDimensions(l),v=m==="y",b=v?"top":"left",w=v?"bottom":"right",x=v?"clientHeight":"clientWidth",_=o.reference[y]+o.reference[m]-f[m]-o.floating[y],C=f[m]-o.reference[m],S=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l));let k=S?S[x]:0;(!k||!await(i.isElement==null?void 0:i.isElement(S)))&&(k=a.floating[x]||o.floating[y]);const A=_/2-C/2,O=k/2-h[y]/2-1,R=qt(d[b],O),T=qt(d[w],O),q=R,H=k-h[y]-T,W=k/2-h[y]/2+A,ue=ei(q,W,H),Q=!c.arrow&&zn(s)!=null&&W!==ue&&o.reference[y]/2-(WW<=0)){var T,q;const W=(((T=o.flip)==null?void 0:T.index)||0)+1,ue=k[W];if(ue&&(!(d==="alignment"?w!==at(ue):!1)||R.every(E=>E.overflows[0]>0&&at(E.placement)===w)))return{data:{index:W,overflows:R},reset:{placement:ue}};let Q=(q=R.filter(G=>G.overflows[0]<=0).sort((G,E)=>G.overflows[1]-E.overflows[1])[0])==null?void 0:q.placement;if(!Q)switch(m){case"bestFit":{var H;const G=(H=R.filter(E=>{if(S){const P=at(E.placement);return P===w||P==="y"}return!0}).map(E=>[E.placement,E.overflows.filter(P=>P>0).reduce((P,U)=>P+U,0)]).sort((E,P)=>E[1]-P[1])[0])==null?void 0:H[0];G&&(Q=G);break}case"initialPlacement":Q=a;break}if(s!==Q)return{reset:{placement:Q}}}return{}}}};function bc(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function wc(e){return uy.some(t=>e[t]>=0)}const ky=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...s}=kt(e,t);switch(r){case"referenceHidden":{const o=await yr(t,{...s,elementContext:"reference"}),i=bc(o,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:wc(i)}}}case"escaped":{const o=await yr(t,{...s,altBoundary:!0}),i=bc(o,n.floating);return{data:{escapedOffsets:i,escaped:wc(i)}}}default:return{}}}}},du=new Set(["left","top"]);async function Sy(e,t){const{placement:n,platform:r,elements:s}=e,o=await(r.isRTL==null?void 0:r.isRTL(s.floating)),i=St(n),a=zn(n),c=at(n)==="y",l=du.has(i)?-1:1,u=o&&c?-1:1,d=kt(t,e);let{mainAxis:f,crossAxis:m,alignmentAxis:y}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&typeof y=="number"&&(m=a==="end"?y*-1:y),c?{x:m*u,y:f*l}:{x:f*l,y:m*u}}const Ay=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:s,y:o,placement:i,middlewareData:a}=t,c=await Sy(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:s+c.x,y:o+c.y,data:{...c,placement:i}}}}},Ey=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:s}=t,{mainAxis:o=!0,crossAxis:i=!1,limiter:a={fn:v=>{let{x:b,y:w}=v;return{x:b,y:w}}},...c}=kt(e,t),l={x:n,y:r},u=await yr(t,c),d=at(St(s)),f=Di(d);let m=l[f],y=l[d];if(o){const v=f==="y"?"top":"left",b=f==="y"?"bottom":"right",w=m+u[v],x=m-u[b];m=ei(w,m,x)}if(i){const v=d==="y"?"top":"left",b=d==="y"?"bottom":"right",w=y+u[v],x=y-u[b];y=ei(w,y,x)}const h=a.fn({...t,[f]:m,[d]:y});return{...h,data:{x:h.x-n,y:h.y-r,enabled:{[f]:o,[d]:i}}}}}},Ry=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:s,rects:o,middlewareData:i}=t,{offset:a=0,mainAxis:c=!0,crossAxis:l=!0}=kt(e,t),u={x:n,y:r},d=at(s),f=Di(d);let m=u[f],y=u[d];const h=kt(a,t),v=typeof h=="number"?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(c){const x=f==="y"?"height":"width",_=o.reference[f]-o.floating[x]+v.mainAxis,C=o.reference[f]+o.reference[x]-v.mainAxis;m<_?m=_:m>C&&(m=C)}if(l){var b,w;const x=f==="y"?"width":"height",_=du.has(St(s)),C=o.reference[d]-o.floating[x]+(_&&((b=i.offset)==null?void 0:b[d])||0)+(_?0:v.crossAxis),S=o.reference[d]+o.reference[x]+(_?0:((w=i.offset)==null?void 0:w[d])||0)-(_?v.crossAxis:0);yS&&(y=S)}return{[f]:m,[d]:y}}}},Oy=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:s,rects:o,platform:i,elements:a}=t,{apply:c=()=>{},...l}=kt(e,t),u=await yr(t,l),d=St(s),f=zn(s),m=at(s)==="y",{width:y,height:h}=o.floating;let v,b;d==="top"||d==="bottom"?(v=d,b=f===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(b=d,v=f==="end"?"top":"bottom");const w=h-u.top-u.bottom,x=y-u.left-u.right,_=qt(h-u[v],w),C=qt(y-u[b],x),S=!t.middlewareData.shift;let k=_,A=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=x),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(k=w),S&&!f){const R=ze(u.left,0),T=ze(u.right,0),q=ze(u.top,0),H=ze(u.bottom,0);m?A=y-2*(R!==0||T!==0?R+T:ze(u.left,u.right)):k=h-2*(q!==0||H!==0?q+H:ze(u.top,u.bottom))}await c({...t,availableWidth:A,availableHeight:k});const O=await i.getDimensions(a.floating);return y!==O.width||h!==O.height?{reset:{rects:!0}}:{}}}};function Ps(){return typeof window<"u"}function Vn(e){return fu(e)?(e.nodeName||"").toLowerCase():"#document"}function Ue(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function ft(e){var t;return(t=(fu(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function fu(e){return Ps()?e instanceof Node||e instanceof Ue(e).Node:!1}function et(e){return Ps()?e instanceof Element||e instanceof Ue(e).Element:!1}function ut(e){return Ps()?e instanceof HTMLElement||e instanceof Ue(e).HTMLElement:!1}function xc(e){return!Ps()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Ue(e).ShadowRoot}const Py=new Set(["inline","contents"]);function Ar(e){const{overflow:t,overflowX:n,overflowY:r,display:s}=tt(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Py.has(s)}const My=new Set(["table","td","th"]);function Ty(e){return My.has(Vn(e))}const Iy=[":popover-open",":modal"];function Ms(e){return Iy.some(t=>{try{return e.matches(t)}catch{return!1}})}const Ny=["transform","translate","scale","rotate","perspective"],Dy=["transform","translate","scale","rotate","perspective","filter"],jy=["paint","layout","strict","content"];function Li(e){const t=$i(),n=et(e)?tt(e):e;return Ny.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||Dy.some(r=>(n.willChange||"").includes(r))||jy.some(r=>(n.contain||"").includes(r))}function Fy(e){let t=Wt(e);for(;ut(t)&&!Fn(t);){if(Li(t))return t;if(Ms(t))return null;t=Wt(t)}return null}function $i(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Ly=new Set(["html","body","#document"]);function Fn(e){return Ly.has(Vn(e))}function tt(e){return Ue(e).getComputedStyle(e)}function Ts(e){return et(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Wt(e){if(Vn(e)==="html")return e;const t=e.assignedSlot||e.parentNode||xc(e)&&e.host||ft(e);return xc(t)?t.host:t}function hu(e){const t=Wt(e);return Fn(t)?e.ownerDocument?e.ownerDocument.body:e.body:ut(t)&&Ar(t)?t:hu(t)}function vr(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const s=hu(e),o=s===((r=e.ownerDocument)==null?void 0:r.body),i=Ue(s);if(o){const a=ni(i);return t.concat(i,i.visualViewport||[],Ar(s)?s:[],a&&n?vr(a):[])}return t.concat(s,vr(s,[],n))}function ni(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function pu(e){const t=tt(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const s=ut(e),o=s?e.offsetWidth:n,i=s?e.offsetHeight:r,a=ws(n)!==o||ws(r)!==i;return a&&(n=o,r=i),{width:n,height:r,$:a}}function Bi(e){return et(e)?e:e.contextElement}function An(e){const t=Bi(e);if(!ut(t))return lt(1);const n=t.getBoundingClientRect(),{width:r,height:s,$:o}=pu(t);let i=(o?ws(n.width):n.width)/r,a=(o?ws(n.height):n.height)/s;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const $y=lt(0);function mu(e){const t=Ue(e);return!$i()||!t.visualViewport?$y:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function By(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Ue(e)?!1:t}function an(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const s=e.getBoundingClientRect(),o=Bi(e);let i=lt(1);t&&(r?et(r)&&(i=An(r)):i=An(e));const a=By(o,n,r)?mu(o):lt(0);let c=(s.left+a.x)/i.x,l=(s.top+a.y)/i.y,u=s.width/i.x,d=s.height/i.y;if(o){const f=Ue(o),m=r&&et(r)?Ue(r):r;let y=f,h=ni(y);for(;h&&r&&m!==y;){const v=An(h),b=h.getBoundingClientRect(),w=tt(h),x=b.left+(h.clientLeft+parseFloat(w.paddingLeft))*v.x,_=b.top+(h.clientTop+parseFloat(w.paddingTop))*v.y;c*=v.x,l*=v.y,u*=v.x,d*=v.y,c+=x,l+=_,y=Ue(h),h=ni(y)}}return _s({width:u,height:d,x:c,y:l})}function Ki(e,t){const n=Ts(e).scrollLeft;return t?t.left+n:an(ft(e)).left+n}function gu(e,t,n){n===void 0&&(n=!1);const r=e.getBoundingClientRect(),s=r.left+t.scrollLeft-(n?0:Ki(e,r)),o=r.top+t.scrollTop;return{x:s,y:o}}function Ky(e){let{elements:t,rect:n,offsetParent:r,strategy:s}=e;const o=s==="fixed",i=ft(r),a=t?Ms(t.floating):!1;if(r===i||a&&o)return n;let c={scrollLeft:0,scrollTop:0},l=lt(1);const u=lt(0),d=ut(r);if((d||!d&&!o)&&((Vn(r)!=="body"||Ar(i))&&(c=Ts(r)),ut(r))){const m=an(r);l=An(r),u.x=m.x+r.clientLeft,u.y=m.y+r.clientTop}const f=i&&!d&&!o?gu(i,c,!0):lt(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function zy(e){return Array.from(e.getClientRects())}function Vy(e){const t=ft(e),n=Ts(e),r=e.ownerDocument.body,s=ze(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),o=ze(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Ki(e);const a=-n.scrollTop;return tt(r).direction==="rtl"&&(i+=ze(t.clientWidth,r.clientWidth)-s),{width:s,height:o,x:i,y:a}}function Uy(e,t){const n=Ue(e),r=ft(e),s=n.visualViewport;let o=r.clientWidth,i=r.clientHeight,a=0,c=0;if(s){o=s.width,i=s.height;const l=$i();(!l||l&&t==="fixed")&&(a=s.offsetLeft,c=s.offsetTop)}return{width:o,height:i,x:a,y:c}}const qy=new Set(["absolute","fixed"]);function Wy(e,t){const n=an(e,!0,t==="fixed"),r=n.top+e.clientTop,s=n.left+e.clientLeft,o=ut(e)?An(e):lt(1),i=e.clientWidth*o.x,a=e.clientHeight*o.y,c=s*o.x,l=r*o.y;return{width:i,height:a,x:c,y:l}}function _c(e,t,n){let r;if(t==="viewport")r=Uy(e,n);else if(t==="document")r=Vy(ft(e));else if(et(t))r=Wy(t,n);else{const s=mu(e);r={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return _s(r)}function yu(e,t){const n=Wt(e);return n===t||!et(n)||Fn(n)?!1:tt(n).position==="fixed"||yu(n,t)}function Hy(e,t){const n=t.get(e);if(n)return n;let r=vr(e,[],!1).filter(a=>et(a)&&Vn(a)!=="body"),s=null;const o=tt(e).position==="fixed";let i=o?Wt(e):e;for(;et(i)&&!Fn(i);){const a=tt(i),c=Li(i);!c&&a.position==="fixed"&&(s=null),(o?!c&&!s:!c&&a.position==="static"&&!!s&&qy.has(s.position)||Ar(i)&&!c&&yu(e,i))?r=r.filter(u=>u!==i):s=a,i=Wt(i)}return t.set(e,r),r}function Zy(e){let{element:t,boundary:n,rootBoundary:r,strategy:s}=e;const i=[...n==="clippingAncestors"?Ms(t)?[]:Hy(t,this._c):[].concat(n),r],a=i[0],c=i.reduce((l,u)=>{const d=_c(t,u,s);return l.top=ze(d.top,l.top),l.right=qt(d.right,l.right),l.bottom=qt(d.bottom,l.bottom),l.left=ze(d.left,l.left),l},_c(t,a,s));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function Gy(e){const{width:t,height:n}=pu(e);return{width:t,height:n}}function Qy(e,t,n){const r=ut(t),s=ft(t),o=n==="fixed",i=an(e,!0,o,t);let a={scrollLeft:0,scrollTop:0};const c=lt(0);function l(){c.x=Ki(s)}if(r||!r&&!o)if((Vn(t)!=="body"||Ar(s))&&(a=Ts(t)),r){const m=an(t,!0,o,t);c.x=m.x+t.clientLeft,c.y=m.y+t.clientTop}else s&&l();o&&!r&&s&&l();const u=s&&!r&&!o?gu(s,a):lt(0),d=i.left+a.scrollLeft-c.x-u.x,f=i.top+a.scrollTop-c.y-u.y;return{x:d,y:f,width:i.width,height:i.height}}function to(e){return tt(e).position==="static"}function Cc(e,t){if(!ut(e)||tt(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return ft(e)===n&&(n=n.ownerDocument.body),n}function vu(e,t){const n=Ue(e);if(Ms(e))return n;if(!ut(e)){let s=Wt(e);for(;s&&!Fn(s);){if(et(s)&&!to(s))return s;s=Wt(s)}return n}let r=Cc(e,t);for(;r&&Ty(r)&&to(r);)r=Cc(r,t);return r&&Fn(r)&&to(r)&&!Li(r)?n:r||Fy(e)||n}const Yy=async function(e){const t=this.getOffsetParent||vu,n=this.getDimensions,r=await n(e.floating);return{reference:Qy(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Xy(e){return tt(e).direction==="rtl"}const Jy={convertOffsetParentRelativeRectToViewportRelativeRect:Ky,getDocumentElement:ft,getClippingRect:Zy,getOffsetParent:vu,getElementRects:Yy,getClientRects:zy,getDimensions:Gy,getScale:An,isElement:et,isRTL:Xy};function bu(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function ev(e,t){let n=null,r;const s=ft(e);function o(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,c){a===void 0&&(a=!1),c===void 0&&(c=1),o();const l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:m}=l;if(a||t(),!f||!m)return;const y=Kr(d),h=Kr(s.clientWidth-(u+f)),v=Kr(s.clientHeight-(d+m)),b=Kr(u),x={rootMargin:-y+"px "+-h+"px "+-v+"px "+-b+"px",threshold:ze(0,qt(1,c))||1};let _=!0;function C(S){const k=S[0].intersectionRatio;if(k!==c){if(!_)return i();k?i(!1,k):r=setTimeout(()=>{i(!1,1e-7)},1e3)}k===1&&!bu(l,e.getBoundingClientRect())&&i(),_=!1}try{n=new IntersectionObserver(C,{...x,root:s.ownerDocument})}catch{n=new IntersectionObserver(C,x)}n.observe(e)}return i(!0),o}function tv(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:s=!0,ancestorResize:o=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,l=Bi(e),u=s||o?[...l?vr(l):[],...vr(t)]:[];u.forEach(b=>{s&&b.addEventListener("scroll",n,{passive:!0}),o&&b.addEventListener("resize",n)});const d=l&&a?ev(l,n):null;let f=-1,m=null;i&&(m=new ResizeObserver(b=>{let[w]=b;w&&w.target===l&&m&&(m.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var x;(x=m)==null||x.observe(t)})),n()}),l&&!c&&m.observe(l),m.observe(t));let y,h=c?an(e):null;c&&v();function v(){const b=an(e);h&&!bu(h,b)&&n(),h=b,y=requestAnimationFrame(v)}return n(),()=>{var b;u.forEach(w=>{s&&w.removeEventListener("scroll",n),o&&w.removeEventListener("resize",n)}),d?.(),(b=m)==null||b.disconnect(),m=null,c&&cancelAnimationFrame(y)}}const nv=Ay,rv=Ey,sv=Cy,ov=Oy,iv=ky,kc=_y,av=Ry,cv=(e,t,n)=>{const r=new Map,s={platform:Jy,...n},o={...s.platform,_c:r};return xy(e,t,{...s,platform:o})};var lv=typeof document<"u",uv=function(){},es=lv?p.useLayoutEffect:uv;function Cs(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,s;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Cs(e[r],t[r]))return!1;return!0}if(s=Object.keys(e),n=s.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,s[r]))return!1;for(r=n;r--!==0;){const o=s[r];if(!(o==="_owner"&&e.$$typeof)&&!Cs(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}function wu(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Sc(e,t){const n=wu(e);return Math.round(t*n)/n}function no(e){const t=p.useRef(e);return es(()=>{t.current=e}),t}function dv(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:s,elements:{reference:o,floating:i}={},transform:a=!0,whileElementsMounted:c,open:l}=e,[u,d]=p.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,m]=p.useState(r);Cs(f,r)||m(r);const[y,h]=p.useState(null),[v,b]=p.useState(null),w=p.useCallback(E=>{E!==S.current&&(S.current=E,h(E))},[]),x=p.useCallback(E=>{E!==k.current&&(k.current=E,b(E))},[]),_=o||y,C=i||v,S=p.useRef(null),k=p.useRef(null),A=p.useRef(u),O=c!=null,R=no(c),T=no(s),q=no(l),H=p.useCallback(()=>{if(!S.current||!k.current)return;const E={placement:t,strategy:n,middleware:f};T.current&&(E.platform=T.current),cv(S.current,k.current,E).then(P=>{const U={...P,isPositioned:q.current!==!1};W.current&&!Cs(A.current,U)&&(A.current=U,Ti.flushSync(()=>{d(U)}))})},[f,t,n,T,q]);es(()=>{l===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,d(E=>({...E,isPositioned:!1})))},[l]);const W=p.useRef(!1);es(()=>(W.current=!0,()=>{W.current=!1}),[]),es(()=>{if(_&&(S.current=_),C&&(k.current=C),_&&C){if(R.current)return R.current(_,C,H);H()}},[_,C,H,R,O]);const ue=p.useMemo(()=>({reference:S,floating:k,setReference:w,setFloating:x}),[w,x]),Q=p.useMemo(()=>({reference:_,floating:C}),[_,C]),G=p.useMemo(()=>{const E={position:n,left:0,top:0};if(!Q.floating)return E;const P=Sc(Q.floating,u.x),U=Sc(Q.floating,u.y);return a?{...E,transform:"translate("+P+"px, "+U+"px)",...wu(Q.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:P,top:U}},[n,a,Q.floating,u.x,u.y]);return p.useMemo(()=>({...u,update:H,refs:ue,elements:Q,floatingStyles:G}),[u,H,ue,Q,G])}const fv=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:s}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?kc({element:r.current,padding:s}).fn(n):{}:r?kc({element:r,padding:s}).fn(n):{}}}},hv=(e,t)=>({...nv(e),options:[e,t]}),pv=(e,t)=>({...rv(e),options:[e,t]}),mv=(e,t)=>({...av(e),options:[e,t]}),gv=(e,t)=>({...sv(e),options:[e,t]}),yv=(e,t)=>({...ov(e),options:[e,t]}),vv=(e,t)=>({...iv(e),options:[e,t]}),bv=(e,t)=>({...fv(e),options:[e,t]});var wv="Arrow",xu=p.forwardRef((e,t)=>{const{children:n,width:r=10,height:s=5,...o}=e;return g.jsx(Ae.svg,{...o,ref:t,width:r,height:s,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:g.jsx("polygon",{points:"0,0 30,0 15,10"})})});xu.displayName=wv;var xv=xu;function _v(e){const[t,n]=p.useState(void 0);return Ut(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(s=>{if(!Array.isArray(s)||!s.length)return;const o=s[0];let i,a;if("borderBoxSize"in o){const c=o.borderBoxSize,l=Array.isArray(c)?c[0]:c;i=l.inlineSize,a=l.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var zi="Popper",[_u,Cu]=un(zi),[Cv,ku]=_u(zi),Su=e=>{const{__scopePopper:t,children:n}=e,[r,s]=p.useState(null);return g.jsx(Cv,{scope:t,anchor:r,onAnchorChange:s,children:n})};Su.displayName=zi;var Au="PopperAnchor",Eu=p.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...s}=e,o=ku(Au,n),i=p.useRef(null),a=Pe(t,i);return p.useEffect(()=>{o.onAnchorChange(r?.current||i.current)}),r?null:g.jsx(Ae.div,{...s,ref:a})});Eu.displayName=Au;var Vi="PopperContent",[kv,Sv]=_u(Vi),Ru=p.forwardRef((e,t)=>{const{__scopePopper:n,side:r="bottom",sideOffset:s=0,align:o="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:d="partial",hideWhenDetached:f=!1,updatePositionStrategy:m="optimized",onPlaced:y,...h}=e,v=ku(Vi,n),[b,w]=p.useState(null),x=Pe(t,D=>w(D)),[_,C]=p.useState(null),S=_v(_),k=S?.width??0,A=S?.height??0,O=r+(o!=="center"?"-"+o:""),R=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},T=Array.isArray(l)?l:[l],q=T.length>0,H={padding:R,boundary:T.filter(Ev),altBoundary:q},{refs:W,floatingStyles:ue,placement:Q,isPositioned:G,middlewareData:E}=dv({strategy:"fixed",placement:O,whileElementsMounted:(...D)=>tv(...D,{animationFrame:m==="always"}),elements:{reference:v.anchor},middleware:[hv({mainAxis:s+A,alignmentAxis:i}),c&&pv({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?mv():void 0,...H}),c&&gv({...H}),yv({...H,apply:({elements:D,rects:ie,availableWidth:I,availableHeight:K})=>{const{width:re,height:ce}=ie.reference,F=D.floating.style;F.setProperty("--radix-popper-available-width",`${I}px`),F.setProperty("--radix-popper-available-height",`${K}px`),F.setProperty("--radix-popper-anchor-width",`${re}px`),F.setProperty("--radix-popper-anchor-height",`${ce}px`)}}),_&&bv({element:_,padding:a}),Rv({arrowWidth:k,arrowHeight:A}),f&&vv({strategy:"referenceHidden",...H})]}),[P,U]=Mu(Q),me=Ct(y);Ut(()=>{G&&me?.()},[G,me]);const Y=E.arrow?.x,L=E.arrow?.y,X=E.arrow?.centerOffset!==0,[de,ne]=p.useState();return Ut(()=>{b&&ne(window.getComputedStyle(b).zIndex)},[b]),g.jsx("div",{ref:W.setFloating,"data-radix-popper-content-wrapper":"",style:{...ue,transform:G?ue.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:de,"--radix-popper-transform-origin":[E.transformOrigin?.x,E.transformOrigin?.y].join(" "),...E.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:g.jsx(kv,{scope:n,placedSide:P,onArrowChange:C,arrowX:Y,arrowY:L,shouldHideArrow:X,children:g.jsx(Ae.div,{"data-side":P,"data-align":U,...h,ref:x,style:{...h.style,animation:G?void 0:"none"}})})})});Ru.displayName=Vi;var Ou="PopperArrow",Av={top:"bottom",right:"left",bottom:"top",left:"right"},Pu=p.forwardRef(function(t,n){const{__scopePopper:r,...s}=t,o=Sv(Ou,r),i=Av[o.placedSide];return g.jsx("span",{ref:o.onArrowChange,style:{position:"absolute",left:o.arrowX,top:o.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[o.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[o.placedSide],visibility:o.shouldHideArrow?"hidden":void 0},children:g.jsx(xv,{...s,ref:n,style:{...s.style,display:"block"}})})});Pu.displayName=Ou;function Ev(e){return e!==null}var Rv=e=>({name:"transformOrigin",options:e,fn(t){const{placement:n,rects:r,middlewareData:s}=t,i=s.arrow?.centerOffset!==0,a=i?0:e.arrowWidth,c=i?0:e.arrowHeight,[l,u]=Mu(n),d={start:"0%",center:"50%",end:"100%"}[u],f=(s.arrow?.x??0)+a/2,m=(s.arrow?.y??0)+c/2;let y="",h="";return l==="bottom"?(y=i?d:`${f}px`,h=`${-c}px`):l==="top"?(y=i?d:`${f}px`,h=`${r.floating.height+c}px`):l==="right"?(y=`${-c}px`,h=i?d:`${m}px`):l==="left"&&(y=`${r.floating.width+c}px`,h=i?d:`${m}px`),{data:{x:y,y:h}}}});function Mu(e){const[t,n="center"]=e.split("-");return[t,n]}var Ov=Su,Pv=Eu,Mv=Ru,Tv=Pu,Iv="Portal",Ui=p.forwardRef((e,t)=>{const{container:n,...r}=e,[s,o]=p.useState(!1);Ut(()=>o(!0),[]);const i=n||s&&globalThis?.document?.body;return i?Lg.createPortal(g.jsx(Ae.div,{...r,ref:t}),i):null});Ui.displayName=Iv;function Nv(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var Ht=e=>{const{present:t,children:n}=e,r=Dv(t),s=typeof n=="function"?n({present:r.isPresent}):p.Children.only(n),o=Pe(r.ref,jv(s));return typeof n=="function"||r.isPresent?p.cloneElement(s,{ref:o}):null};Ht.displayName="Presence";function Dv(e){const[t,n]=p.useState(),r=p.useRef(null),s=p.useRef(e),o=p.useRef("none"),i=e?"mounted":"unmounted",[a,c]=Nv(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return p.useEffect(()=>{const l=zr(r.current);o.current=a==="mounted"?l:"none"},[a]),Ut(()=>{const l=r.current,u=s.current;if(u!==e){const f=o.current,m=zr(l);e?c("MOUNT"):m==="none"||l?.display==="none"?c("UNMOUNT"):c(u&&f!==m?"ANIMATION_OUT":"UNMOUNT"),s.current=e}},[e,c]),Ut(()=>{if(t){let l;const u=t.ownerDocument.defaultView??window,d=m=>{const h=zr(r.current).includes(m.animationName);if(m.target===t&&h&&(c("ANIMATION_END"),!s.current)){const v=t.style.animationFillMode;t.style.animationFillMode="forwards",l=u.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=v)})}},f=m=>{m.target===t&&(o.current=zr(r.current))};return t.addEventListener("animationstart",f),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{u.clearTimeout(l),t.removeEventListener("animationstart",f),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:p.useCallback(l=>{r.current=l?getComputedStyle(l):null,n(l)},[])}}function zr(e){return e?.animationName||"none"}function jv(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var ro="rovingFocusGroup.onEntryFocus",Fv={bubbles:!1,cancelable:!0},Er="RovingFocusGroup",[ri,Tu,Lv]=su(Er),[$v,Iu]=un(Er,[Lv]),[Bv,Kv]=$v(Er),Nu=p.forwardRef((e,t)=>g.jsx(ri.Provider,{scope:e.__scopeRovingFocusGroup,children:g.jsx(ri.Slot,{scope:e.__scopeRovingFocusGroup,children:g.jsx(zv,{...e,ref:t})})}));Nu.displayName=Er;var zv=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:s=!1,dir:o,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=p.useRef(null),m=Pe(t,f),y=ou(o),[h,v]=Mi({prop:i,defaultProp:a??null,onChange:c,caller:Er}),[b,w]=p.useState(!1),x=Ct(l),_=Tu(n),C=p.useRef(!1),[S,k]=p.useState(0);return p.useEffect(()=>{const A=f.current;if(A)return A.addEventListener(ro,x),()=>A.removeEventListener(ro,x)},[x]),g.jsx(Bv,{scope:n,orientation:r,dir:y,loop:s,currentTabStopId:h,onItemFocus:p.useCallback(A=>v(A),[v]),onItemShiftTab:p.useCallback(()=>w(!0),[]),onFocusableItemAdd:p.useCallback(()=>k(A=>A+1),[]),onFocusableItemRemove:p.useCallback(()=>k(A=>A-1),[]),children:g.jsx(Ae.div,{tabIndex:b||S===0?-1:0,"data-orientation":r,...d,ref:m,style:{outline:"none",...e.style},onMouseDown:se(e.onMouseDown,()=>{C.current=!0}),onFocus:se(e.onFocus,A=>{const O=!C.current;if(A.target===A.currentTarget&&O&&!b){const R=new CustomEvent(ro,Fv);if(A.currentTarget.dispatchEvent(R),!R.defaultPrevented){const T=_().filter(Q=>Q.focusable),q=T.find(Q=>Q.active),H=T.find(Q=>Q.id===h),ue=[q,H,...T].filter(Boolean).map(Q=>Q.ref.current);Fu(ue,u)}}C.current=!1}),onBlur:se(e.onBlur,()=>w(!1))})})}),Du="RovingFocusGroupItem",ju=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:s=!1,tabStopId:o,children:i,...a}=e,c=Sn(),l=o||c,u=Kv(Du,n),d=u.currentTabStopId===l,f=Tu(n),{onFocusableItemAdd:m,onFocusableItemRemove:y,currentTabStopId:h}=u;return p.useEffect(()=>{if(r)return m(),()=>y()},[r,m,y]),g.jsx(ri.ItemSlot,{scope:n,id:l,focusable:r,active:s,children:g.jsx(Ae.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...a,ref:t,onMouseDown:se(e.onMouseDown,v=>{r?u.onItemFocus(l):v.preventDefault()}),onFocus:se(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:se(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){u.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const b=qv(v,u.orientation,u.dir);if(b!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let x=f().filter(_=>_.focusable).map(_=>_.ref.current);if(b==="last")x.reverse();else if(b==="prev"||b==="next"){b==="prev"&&x.reverse();const _=x.indexOf(v.currentTarget);x=u.loop?Wv(x,_+1):x.slice(_+1)}setTimeout(()=>Fu(x))}}),children:typeof i=="function"?i({isCurrentTabStop:d,hasTabStop:h!=null}):i})})});ju.displayName=Du;var Vv={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Uv(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function qv(e,t,n){const r=Uv(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Vv[r]}function Fu(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Wv(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Hv=Nu,Zv=ju,Gv=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},gn=new WeakMap,Vr=new WeakMap,Ur={},so=0,Lu=function(e){return e&&(e.host||Lu(e.parentNode))},Qv=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Lu(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},Yv=function(e,t,n,r){var s=Qv(t,Array.isArray(e)?e:[e]);Ur[n]||(Ur[n]=new WeakMap);var o=Ur[n],i=[],a=new Set,c=new Set(s),l=function(d){!d||a.has(d)||(a.add(d),l(d.parentNode))};s.forEach(l);var u=function(d){!d||c.has(d)||Array.prototype.forEach.call(d.children,function(f){if(a.has(f))u(f);else try{var m=f.getAttribute(r),y=m!==null&&m!=="false",h=(gn.get(f)||0)+1,v=(o.get(f)||0)+1;gn.set(f,h),o.set(f,v),i.push(f),h===1&&y&&Vr.set(f,!0),v===1&&f.setAttribute(n,"true"),y||f.setAttribute(r,"true")}catch(b){console.error("aria-hidden: cannot operate on ",f,b)}})};return u(t),a.clear(),so++,function(){i.forEach(function(d){var f=gn.get(d)-1,m=o.get(d)-1;gn.set(d,f),o.set(d,m),f||(Vr.has(d)||d.removeAttribute(r),Vr.delete(d)),m||d.removeAttribute(n)}),so--,so||(gn=new WeakMap,gn=new WeakMap,Vr=new WeakMap,Ur={})}},$u=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),s=Gv(e);return s?(r.push.apply(r,Array.from(s.querySelectorAll("[aria-live], script"))),Yv(r,s,n,"aria-hidden")):function(){return null}},it=function(){return it=Object.assign||function(t){for(var n,r=1,s=arguments.length;r"u")return pb;var t=mb(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},yb=Vu(),En="data-scroll-locked",vb=function(e,t,n,r){var s=e.left,o=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),` .`.concat(Jv,` { overflow: hidden `).concat(r,`; padding-right: `).concat(a,"px ").concat(r,`; } body[`).concat(En,`] { overflow: hidden `).concat(r,`; overscroll-behavior: contain; `).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&` padding-left: `.concat(s,`px; padding-top: `).concat(o,`px; padding-right: `).concat(i,`px; margin-left:0; margin-top:0; margin-right: `).concat(a,"px ").concat(r,`; `),n==="padding"&&"padding-right: ".concat(a,"px ").concat(r,";")].filter(Boolean).join(""),` } .`).concat(ts,` { right: `).concat(a,"px ").concat(r,`; } .`).concat(ns,` { margin-right: `).concat(a,"px ").concat(r,`; } .`).concat(ts," .").concat(ts,` { right: 0 `).concat(r,`; } .`).concat(ns," .").concat(ns,` { margin-right: 0 `).concat(r,`; } body[`).concat(En,`] { `).concat(eb,": ").concat(a,`px; } `)},Ec=function(){var e=parseInt(document.body.getAttribute(En)||"0",10);return isFinite(e)?e:0},bb=function(){p.useEffect(function(){return document.body.setAttribute(En,(Ec()+1).toString()),function(){var e=Ec()-1;e<=0?document.body.removeAttribute(En):document.body.setAttribute(En,e.toString())}},[])},wb=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,s=r===void 0?"margin":r;bb();var o=p.useMemo(function(){return gb(s)},[s]);return p.createElement(yb,{styles:vb(o,!t,s,n?"":"!important")})},si=!1;if(typeof window<"u")try{var qr=Object.defineProperty({},"passive",{get:function(){return si=!0,!0}});window.addEventListener("test",qr,qr),window.removeEventListener("test",qr,qr)}catch{si=!1}var yn=si?{passive:!1}:!1,xb=function(e){return e.tagName==="TEXTAREA"},Uu=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!xb(e)&&n[t]==="visible")},_b=function(e){return Uu(e,"overflowY")},Cb=function(e){return Uu(e,"overflowX")},Rc=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var s=qu(e,r);if(s){var o=Wu(e,r),i=o[1],a=o[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},kb=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},Sb=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},qu=function(e,t){return e==="v"?_b(t):Cb(t)},Wu=function(e,t){return e==="v"?kb(t):Sb(t)},Ab=function(e,t){return e==="h"&&t==="rtl"?-1:1},Eb=function(e,t,n,r,s){var o=Ab(e,window.getComputedStyle(t).direction),i=o*r,a=n.target,c=t.contains(a),l=!1,u=i>0,d=0,f=0;do{if(!a)break;var m=Wu(e,a),y=m[0],h=m[1],v=m[2],b=h-v-o*y;(y||b)&&qu(e,a)&&(d+=b,f+=y);var w=a.parentNode;a=w&&w.nodeType===Node.DOCUMENT_FRAGMENT_NODE?w.host:w}while(!c&&a!==document.body||c&&(t.contains(a)||t===a));return(u&&Math.abs(d)<1||!u&&Math.abs(f)<1)&&(l=!0),l},Wr=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Oc=function(e){return[e.deltaX,e.deltaY]},Pc=function(e){return e&&"current"in e?e.current:e},Rb=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Ob=function(e){return` .block-interactivity-`.concat(e,` {pointer-events: none;} .allow-interactivity-`).concat(e,` {pointer-events: all;} `)},Pb=0,vn=[];function Mb(e){var t=p.useRef([]),n=p.useRef([0,0]),r=p.useRef(),s=p.useState(Pb++)[0],o=p.useState(Vu)[0],i=p.useRef(e);p.useEffect(function(){i.current=e},[e]),p.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(s));var h=Xv([e.lockRef.current],(e.shards||[]).map(Pc),!0).filter(Boolean);return h.forEach(function(v){return v.classList.add("allow-interactivity-".concat(s))}),function(){document.body.classList.remove("block-interactivity-".concat(s)),h.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(s))})}}},[e.inert,e.lockRef.current,e.shards]);var a=p.useCallback(function(h,v){if("touches"in h&&h.touches.length===2||h.type==="wheel"&&h.ctrlKey)return!i.current.allowPinchZoom;var b=Wr(h),w=n.current,x="deltaX"in h?h.deltaX:w[0]-b[0],_="deltaY"in h?h.deltaY:w[1]-b[1],C,S=h.target,k=Math.abs(x)>Math.abs(_)?"h":"v";if("touches"in h&&k==="h"&&S.type==="range")return!1;var A=Rc(k,S);if(!A)return!0;if(A?C=k:(C=k==="v"?"h":"v",A=Rc(k,S)),!A)return!1;if(!r.current&&"changedTouches"in h&&(x||_)&&(r.current=C),!C)return!0;var O=r.current||C;return Eb(O,v,h,O==="h"?x:_)},[]),c=p.useCallback(function(h){var v=h;if(!(!vn.length||vn[vn.length-1]!==o)){var b="deltaY"in v?Oc(v):Wr(v),w=t.current.filter(function(C){return C.name===v.type&&(C.target===v.target||v.target===C.shadowParent)&&Rb(C.delta,b)})[0];if(w&&w.should){v.cancelable&&v.preventDefault();return}if(!w){var x=(i.current.shards||[]).map(Pc).filter(Boolean).filter(function(C){return C.contains(v.target)}),_=x.length>0?a(v,x[0]):!i.current.noIsolation;_&&v.cancelable&&v.preventDefault()}}},[]),l=p.useCallback(function(h,v,b,w){var x={name:h,delta:v,target:b,should:w,shadowParent:Tb(b)};t.current.push(x),setTimeout(function(){t.current=t.current.filter(function(_){return _!==x})},1)},[]),u=p.useCallback(function(h){n.current=Wr(h),r.current=void 0},[]),d=p.useCallback(function(h){l(h.type,Oc(h),h.target,a(h,e.lockRef.current))},[]),f=p.useCallback(function(h){l(h.type,Wr(h),h.target,a(h,e.lockRef.current))},[]);p.useEffect(function(){return vn.push(o),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",c,yn),document.addEventListener("touchmove",c,yn),document.addEventListener("touchstart",u,yn),function(){vn=vn.filter(function(h){return h!==o}),document.removeEventListener("wheel",c,yn),document.removeEventListener("touchmove",c,yn),document.removeEventListener("touchstart",u,yn)}},[]);var m=e.removeScrollBar,y=e.inert;return p.createElement(p.Fragment,null,y?p.createElement(o,{styles:Ob(s)}):null,m?p.createElement(wb,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Tb(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Ib=ab(zu,Mb);var qi=p.forwardRef(function(e,t){return p.createElement(Is,it({},e,{ref:t,sideCar:Ib}))});qi.classNames=Is.classNames;var oi=["Enter"," "],Nb=["ArrowDown","PageUp","Home"],Hu=["ArrowUp","PageDown","End"],Db=[...Nb,...Hu],jb={ltr:[...oi,"ArrowRight"],rtl:[...oi,"ArrowLeft"]},Fb={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Rr="Menu",[br,Lb,$b]=su(Rr),[dn,Zu]=un(Rr,[$b,Cu,Iu]),Ns=Cu(),Gu=Iu(),[Bb,fn]=dn(Rr),[Kb,Or]=dn(Rr),Qu=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:s,onOpenChange:o,modal:i=!0}=e,a=Ns(t),[c,l]=p.useState(null),u=p.useRef(!1),d=Ct(o),f=ou(s);return p.useEffect(()=>{const m=()=>{u.current=!0,document.addEventListener("pointerdown",y,{capture:!0,once:!0}),document.addEventListener("pointermove",y,{capture:!0,once:!0})},y=()=>u.current=!1;return document.addEventListener("keydown",m,{capture:!0}),()=>{document.removeEventListener("keydown",m,{capture:!0}),document.removeEventListener("pointerdown",y,{capture:!0}),document.removeEventListener("pointermove",y,{capture:!0})}},[]),g.jsx(Ov,{...a,children:g.jsx(Bb,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:g.jsx(Kb,{scope:t,onClose:p.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:i,children:r})})})};Qu.displayName=Rr;var zb="MenuAnchor",Wi=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,s=Ns(n);return g.jsx(Pv,{...s,...r,ref:t})});Wi.displayName=zb;var Hi="MenuPortal",[Vb,Yu]=dn(Hi,{forceMount:void 0}),Xu=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:s}=e,o=fn(Hi,t);return g.jsx(Vb,{scope:t,forceMount:n,children:g.jsx(Ht,{present:n||o.open,children:g.jsx(Ui,{asChild:!0,container:s,children:r})})})};Xu.displayName=Hi;var Ze="MenuContent",[Ub,Zi]=dn(Ze),Ju=p.forwardRef((e,t)=>{const n=Yu(Ze,e.__scopeMenu),{forceMount:r=n.forceMount,...s}=e,o=fn(Ze,e.__scopeMenu),i=Or(Ze,e.__scopeMenu);return g.jsx(br.Provider,{scope:e.__scopeMenu,children:g.jsx(Ht,{present:r||o.open,children:g.jsx(br.Slot,{scope:e.__scopeMenu,children:i.modal?g.jsx(qb,{...s,ref:t}):g.jsx(Wb,{...s,ref:t})})})})}),qb=p.forwardRef((e,t)=>{const n=fn(Ze,e.__scopeMenu),r=p.useRef(null),s=Pe(t,r);return p.useEffect(()=>{const o=r.current;if(o)return $u(o)},[]),g.jsx(Gi,{...e,ref:s,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:se(e.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Wb=p.forwardRef((e,t)=>{const n=fn(Ze,e.__scopeMenu);return g.jsx(Gi,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Hb=jn("MenuContent.ScrollLock"),Gi=p.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:s,onOpenAutoFocus:o,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:m,disableOutsideScroll:y,...h}=e,v=fn(Ze,n),b=Or(Ze,n),w=Ns(n),x=Gu(n),_=Lb(n),[C,S]=p.useState(null),k=p.useRef(null),A=Pe(t,k,v.onContentChange),O=p.useRef(0),R=p.useRef(""),T=p.useRef(0),q=p.useRef(null),H=p.useRef("right"),W=p.useRef(0),ue=y?qi:p.Fragment,Q=y?{as:Hb,allowPinchZoom:!0}:void 0,G=P=>{const U=R.current+P,me=_().filter(D=>!D.disabled),Y=document.activeElement,L=me.find(D=>D.ref.current===Y)?.textValue,X=me.map(D=>D.textValue),de=ow(X,U,L),ne=me.find(D=>D.textValue===de)?.ref.current;(function D(ie){R.current=ie,window.clearTimeout(O.current),ie!==""&&(O.current=window.setTimeout(()=>D(""),1e3))})(U),ne&&setTimeout(()=>ne.focus())};p.useEffect(()=>()=>window.clearTimeout(O.current),[]),cu();const E=p.useCallback(P=>H.current===q.current?.side&&aw(P,q.current?.area),[]);return g.jsx(Ub,{scope:n,searchRef:R,onItemEnter:p.useCallback(P=>{E(P)&&P.preventDefault()},[E]),onItemLeave:p.useCallback(P=>{E(P)||(k.current?.focus(),S(null))},[E]),onTriggerLeave:p.useCallback(P=>{E(P)&&P.preventDefault()},[E]),pointerGraceTimerRef:T,onPointerGraceIntentChange:p.useCallback(P=>{q.current=P},[]),children:g.jsx(ue,{...Q,children:g.jsx(Ni,{asChild:!0,trapped:s,onMountAutoFocus:se(o,P=>{P.preventDefault(),k.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:g.jsx(Ii,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:m,children:g.jsx(Hv,{asChild:!0,...x,dir:b.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:S,onEntryFocus:se(c,P=>{b.isUsingKeyboardRef.current||P.preventDefault()}),preventScrollOnEntryFocus:!0,children:g.jsx(Mv,{role:"menu","aria-orientation":"vertical","data-state":md(v.open),"data-radix-menu-content":"",dir:b.dir,...w,...h,ref:A,style:{outline:"none",...h.style},onKeyDown:se(h.onKeyDown,P=>{const me=P.target.closest("[data-radix-menu-content]")===P.currentTarget,Y=P.ctrlKey||P.altKey||P.metaKey,L=P.key.length===1;me&&(P.key==="Tab"&&P.preventDefault(),!Y&&L&&G(P.key));const X=k.current;if(P.target!==X||!Db.includes(P.key))return;P.preventDefault();const ne=_().filter(D=>!D.disabled).map(D=>D.ref.current);Hu.includes(P.key)&&ne.reverse(),rw(ne)}),onBlur:se(e.onBlur,P=>{P.currentTarget.contains(P.target)||(window.clearTimeout(O.current),R.current="")}),onPointerMove:se(e.onPointerMove,wr(P=>{const U=P.target,me=W.current!==P.clientX;if(P.currentTarget.contains(U)&&me){const Y=P.clientX>W.current?"right":"left";H.current=Y,W.current=P.clientX}}))})})})})})})});Ju.displayName=Ze;var Zb="MenuGroup",Qi=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return g.jsx(Ae.div,{role:"group",...r,ref:t})});Qi.displayName=Zb;var Gb="MenuLabel",ed=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return g.jsx(Ae.div,{...r,ref:t})});ed.displayName=Gb;var ks="MenuItem",Mc="menu.itemSelect",Ds=p.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...s}=e,o=p.useRef(null),i=Or(ks,e.__scopeMenu),a=Zi(ks,e.__scopeMenu),c=Pe(t,o),l=p.useRef(!1),u=()=>{const d=o.current;if(!n&&d){const f=new CustomEvent(Mc,{bubbles:!0,cancelable:!0});d.addEventListener(Mc,m=>r?.(m),{once:!0}),ru(d,f),f.defaultPrevented?l.current=!1:i.onClose()}};return g.jsx(td,{...s,ref:c,disabled:n,onClick:se(e.onClick,u),onPointerDown:d=>{e.onPointerDown?.(d),l.current=!0},onPointerUp:se(e.onPointerUp,d=>{l.current||d.currentTarget?.click()}),onKeyDown:se(e.onKeyDown,d=>{const f=a.searchRef.current!=="";n||f&&d.key===" "||oi.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})})});Ds.displayName=ks;var td=p.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:s,...o}=e,i=Zi(ks,n),a=Gu(n),c=p.useRef(null),l=Pe(t,c),[u,d]=p.useState(!1),[f,m]=p.useState("");return p.useEffect(()=>{const y=c.current;y&&m((y.textContent??"").trim())},[o.children]),g.jsx(br.ItemSlot,{scope:n,disabled:r,textValue:s??f,children:g.jsx(Zv,{asChild:!0,...a,focusable:!r,children:g.jsx(Ae.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...o,ref:l,onPointerMove:se(e.onPointerMove,wr(y=>{r?i.onItemLeave(y):(i.onItemEnter(y),y.defaultPrevented||y.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:se(e.onPointerLeave,wr(y=>i.onItemLeave(y))),onFocus:se(e.onFocus,()=>d(!0)),onBlur:se(e.onBlur,()=>d(!1))})})})}),Qb="MenuCheckboxItem",nd=p.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...s}=e;return g.jsx(ad,{scope:e.__scopeMenu,checked:n,children:g.jsx(Ds,{role:"menuitemcheckbox","aria-checked":Ss(n)?"mixed":n,...s,ref:t,"data-state":Xi(n),onSelect:se(s.onSelect,()=>r?.(Ss(n)?!0:!n),{checkForDefaultPrevented:!1})})})});nd.displayName=Qb;var rd="MenuRadioGroup",[Yb,Xb]=dn(rd,{value:void 0,onValueChange:()=>{}}),sd=p.forwardRef((e,t)=>{const{value:n,onValueChange:r,...s}=e,o=Ct(r);return g.jsx(Yb,{scope:e.__scopeMenu,value:n,onValueChange:o,children:g.jsx(Qi,{...s,ref:t})})});sd.displayName=rd;var od="MenuRadioItem",id=p.forwardRef((e,t)=>{const{value:n,...r}=e,s=Xb(od,e.__scopeMenu),o=n===s.value;return g.jsx(ad,{scope:e.__scopeMenu,checked:o,children:g.jsx(Ds,{role:"menuitemradio","aria-checked":o,...r,ref:t,"data-state":Xi(o),onSelect:se(r.onSelect,()=>s.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});id.displayName=od;var Yi="MenuItemIndicator",[ad,Jb]=dn(Yi,{checked:!1}),cd=p.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...s}=e,o=Jb(Yi,n);return g.jsx(Ht,{present:r||Ss(o.checked)||o.checked===!0,children:g.jsx(Ae.span,{...s,ref:t,"data-state":Xi(o.checked)})})});cd.displayName=Yi;var ew="MenuSeparator",ld=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return g.jsx(Ae.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});ld.displayName=ew;var tw="MenuArrow",ud=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,s=Ns(n);return g.jsx(Tv,{...s,...r,ref:t})});ud.displayName=tw;var nw="MenuSub",[Gx,dd]=dn(nw),Yn="MenuSubTrigger",fd=p.forwardRef((e,t)=>{const n=fn(Yn,e.__scopeMenu),r=Or(Yn,e.__scopeMenu),s=dd(Yn,e.__scopeMenu),o=Zi(Yn,e.__scopeMenu),i=p.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:c}=o,l={__scopeMenu:e.__scopeMenu},u=p.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return p.useEffect(()=>u,[u]),p.useEffect(()=>{const d=a.current;return()=>{window.clearTimeout(d),c(null)}},[a,c]),g.jsx(Wi,{asChild:!0,...l,children:g.jsx(td,{id:s.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":s.contentId,"data-state":md(n.open),...e,ref:Os(t,s.onTriggerChange),onClick:d=>{e.onClick?.(d),!(e.disabled||d.defaultPrevented)&&(d.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:se(e.onPointerMove,wr(d=>{o.onItemEnter(d),!d.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(o.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:se(e.onPointerLeave,wr(d=>{u();const f=n.content?.getBoundingClientRect();if(f){const m=n.content?.dataset.side,y=m==="right",h=y?-5:5,v=f[y?"left":"right"],b=f[y?"right":"left"];o.onPointerGraceIntentChange({area:[{x:d.clientX+h,y:d.clientY},{x:v,y:f.top},{x:b,y:f.top},{x:b,y:f.bottom},{x:v,y:f.bottom}],side:m}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(d),d.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:se(e.onKeyDown,d=>{const f=o.searchRef.current!=="";e.disabled||f&&d.key===" "||jb[r.dir].includes(d.key)&&(n.onOpenChange(!0),n.content?.focus(),d.preventDefault())})})})});fd.displayName=Yn;var hd="MenuSubContent",pd=p.forwardRef((e,t)=>{const n=Yu(Ze,e.__scopeMenu),{forceMount:r=n.forceMount,...s}=e,o=fn(Ze,e.__scopeMenu),i=Or(Ze,e.__scopeMenu),a=dd(hd,e.__scopeMenu),c=p.useRef(null),l=Pe(t,c);return g.jsx(br.Provider,{scope:e.__scopeMenu,children:g.jsx(Ht,{present:r||o.open,children:g.jsx(br.Slot,{scope:e.__scopeMenu,children:g.jsx(Gi,{id:a.contentId,"aria-labelledby":a.triggerId,...s,ref:l,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:u=>{i.isUsingKeyboardRef.current&&c.current?.focus(),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:se(e.onFocusOutside,u=>{u.target!==a.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:se(e.onEscapeKeyDown,u=>{i.onClose(),u.preventDefault()}),onKeyDown:se(e.onKeyDown,u=>{const d=u.currentTarget.contains(u.target),f=Fb[i.dir].includes(u.key);d&&f&&(o.onOpenChange(!1),a.trigger?.focus(),u.preventDefault())})})})})})});pd.displayName=hd;function md(e){return e?"open":"closed"}function Ss(e){return e==="indeterminate"}function Xi(e){return Ss(e)?"indeterminate":e?"checked":"unchecked"}function rw(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function sw(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function ow(e,t,n){const s=t.length>1&&Array.from(t).every(l=>l===t[0])?t[0]:t,o=n?e.indexOf(n):-1;let i=sw(e,Math.max(o,0));s.length===1&&(i=i.filter(l=>l!==n));const c=i.find(l=>l.toLowerCase().startsWith(s.toLowerCase()));return c!==n?c:void 0}function iw(e,t){const{x:n,y:r}=e;let s=!1;for(let o=0,i=t.length-1;or!=f>r&&n<(d-l)*(r-u)/(f-u)+l&&(s=!s)}return s}function aw(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return iw(n,t)}function wr(e){return t=>t.pointerType==="mouse"?e(t):void 0}var cw=Qu,lw=Wi,uw=Xu,dw=Ju,fw=Qi,hw=ed,pw=Ds,mw=nd,gw=sd,yw=id,vw=cd,bw=ld,ww=ud,xw=fd,_w=pd,js="DropdownMenu",[Cw,Qx]=un(js,[Zu]),je=Zu(),[kw,gd]=Cw(js),yd=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:s,defaultOpen:o,onOpenChange:i,modal:a=!0}=e,c=je(t),l=p.useRef(null),[u,d]=Mi({prop:s,defaultProp:o??!1,onChange:i,caller:js});return g.jsx(kw,{scope:t,triggerId:Sn(),triggerRef:l,contentId:Sn(),open:u,onOpenChange:d,onOpenToggle:p.useCallback(()=>d(f=>!f),[d]),modal:a,children:g.jsx(cw,{...c,open:u,onOpenChange:d,dir:r,modal:a,children:n})})};yd.displayName=js;var vd="DropdownMenuTrigger",bd=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...s}=e,o=gd(vd,n),i=je(n);return g.jsx(lw,{asChild:!0,...i,children:g.jsx(Ae.button,{type:"button",id:o.triggerId,"aria-haspopup":"menu","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":o.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...s,ref:Os(t,o.triggerRef),onPointerDown:se(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(o.onOpenToggle(),o.open||a.preventDefault())}),onKeyDown:se(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&o.onOpenToggle(),a.key==="ArrowDown"&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});bd.displayName=vd;var Sw="DropdownMenuPortal",wd=e=>{const{__scopeDropdownMenu:t,...n}=e,r=je(t);return g.jsx(uw,{...r,...n})};wd.displayName=Sw;var xd="DropdownMenuContent",_d=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=gd(xd,n),o=je(n),i=p.useRef(!1);return g.jsx(dw,{id:s.contentId,"aria-labelledby":s.triggerId,...o,...r,ref:t,onCloseAutoFocus:se(e.onCloseAutoFocus,a=>{i.current||s.triggerRef.current?.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:se(e.onInteractOutside,a=>{const c=a.detail.originalEvent,l=c.button===0&&c.ctrlKey===!0,u=c.button===2||l;(!s.modal||u)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});_d.displayName=xd;var Aw="DropdownMenuGroup",Ew=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=je(n);return g.jsx(fw,{...s,...r,ref:t})});Ew.displayName=Aw;var Rw="DropdownMenuLabel",Ow=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=je(n);return g.jsx(hw,{...s,...r,ref:t})});Ow.displayName=Rw;var Pw="DropdownMenuItem",Cd=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=je(n);return g.jsx(pw,{...s,...r,ref:t})});Cd.displayName=Pw;var Mw="DropdownMenuCheckboxItem",Tw=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=je(n);return g.jsx(mw,{...s,...r,ref:t})});Tw.displayName=Mw;var Iw="DropdownMenuRadioGroup",Nw=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=je(n);return g.jsx(gw,{...s,...r,ref:t})});Nw.displayName=Iw;var Dw="DropdownMenuRadioItem",jw=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=je(n);return g.jsx(yw,{...s,...r,ref:t})});jw.displayName=Dw;var Fw="DropdownMenuItemIndicator",Lw=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=je(n);return g.jsx(vw,{...s,...r,ref:t})});Lw.displayName=Fw;var $w="DropdownMenuSeparator",Bw=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=je(n);return g.jsx(bw,{...s,...r,ref:t})});Bw.displayName=$w;var Kw="DropdownMenuArrow",zw=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=je(n);return g.jsx(ww,{...s,...r,ref:t})});zw.displayName=Kw;var Vw="DropdownMenuSubTrigger",Uw=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=je(n);return g.jsx(xw,{...s,...r,ref:t})});Uw.displayName=Vw;var qw="DropdownMenuSubContent",Ww=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=je(n);return g.jsx(_w,{...s,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Ww.displayName=qw;var Hw=yd,Zw=bd,Gw=wd,Qw=_d,Yw=Cd;function Tc({modal:e=!1,...t}){return g.jsx(Hw,{"data-slot":"dropdown-menu",modal:e,...t})}function Ic({...e}){return g.jsx(Zw,{"data-slot":"dropdown-menu-trigger",...e})}function Nc({className:e,sideOffset:t=4,...n}){return g.jsx(Gw,{children:g.jsx(Qw,{"data-slot":"dropdown-menu-content",sideOffset:t,className:Ve("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-[100000] max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",e),...n})})}function Ot({className:e,inset:t,variant:n="default",...r}){return g.jsx(Yw,{"data-slot":"dropdown-menu-item","data-inset":t,"data-variant":n,className:Ve("focus:bg-white/10 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...r})}function Dc(e,t){if(e.length<=t)return e;const n=Math.max(1,Math.floor((t-1)/2));return`${e.slice(0,n)}…${e.slice(-n)}`}function jc({selectedModel:e,onSelectModel:t,selectedTemplate:n=null,onSelectTemplate:r,showModels:s=!0,showTemplates:o=!0,expand:i=!1}){const{data:a=[],isLoading:c}=yi(),{data:l=[],isLoading:u}=tu(),[d,f]=p.useState(!1),[m,y]=p.useState(!1),h=a.length>0,v=e?a.find(R=>R.id===e):null,b=!!e&&h&&!a.some(R=>R.id===e),w=c?"Loading...":v?.label?v.label:b&&e?`${e} (missing)`:"Select model",x=Dc(w,20),_=l.length>0,C=n?l.find(R=>R.name===n):null,S=!!n&&_&&!C,k=u?"Loading...":C?.label?C.label:_&&S&&n?`${n} (missing)`:"Template",A=Dc(k,20),O=i?"grid grid-cols-2 gap-2 w-full":"flex items-center gap-2 justify-center";return g.jsxs("div",{className:O,children:[s&&g.jsxs(Tc,{open:d,onOpenChange:f,children:[g.jsx("div",{className:i?"w-full min-w-0":"",children:g.jsx(Ic,{asChild:!0,children:g.jsxs("button",{type:"button",onTouchStart:()=>{const R=document.activeElement;R&&typeof R.blur=="function"&&R.blur()},onClick:()=>f(!0),className:`bg-glass flex items-center ${i?"w-full justify-between":"justify-center"} hover:cursor-pointer text-white hover:text-white border-white/5 border-none rounded-full text-xs disabled:opacity-60 disabled:cursor-not-allowed h-8 px-3`,children:[x," ",g.jsx(va,{size:16,className:"ml-1"})]})})}),g.jsxs(Nc,{children:[c&&g.jsx(Ot,{disabled:!0,children:"Loading..."}),!c&&a.length===0&&g.jsx(Ot,{disabled:!0,children:"No models"}),!c&&b&&e&&g.jsxs(Ot,{disabled:!0,children:[e," (missing)"]}),!c&&a.map(R=>g.jsx(Ot,{onClick:()=>t(R.id),children:R.label},R.id))]})]}),o&&g.jsxs(Tc,{open:m,onOpenChange:y,children:[g.jsx("div",{className:i?"w-full min-w-0":"",children:g.jsx(Ic,{asChild:!0,children:g.jsxs("button",{type:"button",onTouchStart:()=>{const R=document.activeElement;R&&typeof R.blur=="function"&&R.blur()},onClick:()=>y(!0),className:`bg-glass flex items-center ${i?"w-full justify-between":"justify-center"} hover:cursor-pointer text-white hover:text-white border-white/5 border-none rounded-full text-xs h-8 px-3`,children:[A," ",g.jsx(va,{size:16,className:"ml-1"})]})})}),g.jsxs(Nc,{children:[u&&g.jsx(Ot,{disabled:!0,children:"Loading..."}),!u&&l.length===0&&g.jsx(Ot,{disabled:!0,children:"No templates"}),!u&&S&&n&&g.jsxs(Ot,{disabled:!0,children:[n," (missing)"]}),!u&&l.map(R=>g.jsx(Ot,{onClick:()=>r&&r(R.name),children:R.label},R.name))]})]})]})}const Xw="_main_ybx8h_1",Jw="_composer_ybx8h_9",ex="_noAnchor_ybx8h_14",co={main:Xw,composer:Jw,noAnchor:ex};function tx(){const e=Qc(),t=di({queryKey:["sessions"],queryFn:()=>_g(),staleTime:1/0});return p.useEffect(()=>wg(()=>{e.invalidateQueries({queryKey:["sessions"]})}),[e]),t}var Fs="Dialog",[kd,Sd]=un(Fs),[nx,nt]=kd(Fs),Ad=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:s,onOpenChange:o,modal:i=!0}=e,a=p.useRef(null),c=p.useRef(null),[l,u]=Mi({prop:r,defaultProp:s??!1,onChange:o,caller:Fs});return g.jsx(nx,{scope:t,triggerRef:a,contentRef:c,contentId:Sn(),titleId:Sn(),descriptionId:Sn(),open:l,onOpenChange:u,onOpenToggle:p.useCallback(()=>u(d=>!d),[u]),modal:i,children:n})};Ad.displayName=Fs;var Ed="DialogTrigger",Rd=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,s=nt(Ed,n),o=Pe(t,s.triggerRef);return g.jsx(Ae.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":ta(s.open),...r,ref:o,onClick:se(e.onClick,s.onOpenToggle)})});Rd.displayName=Ed;var Ji="DialogPortal",[rx,Od]=kd(Ji,{forceMount:void 0}),Pd=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:s}=e,o=nt(Ji,t);return g.jsx(rx,{scope:t,forceMount:n,children:p.Children.map(r,i=>g.jsx(Ht,{present:n||o.open,children:g.jsx(Ui,{asChild:!0,container:s,children:i})}))})};Pd.displayName=Ji;var As="DialogOverlay",Md=p.forwardRef((e,t)=>{const n=Od(As,e.__scopeDialog),{forceMount:r=n.forceMount,...s}=e,o=nt(As,e.__scopeDialog);return o.modal?g.jsx(Ht,{present:r||o.open,children:g.jsx(ox,{...s,ref:t})}):null});Md.displayName=As;var sx=jn("DialogOverlay.RemoveScroll"),ox=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,s=nt(As,n);return g.jsx(qi,{as:sx,allowPinchZoom:!0,shards:[s.contentRef],children:g.jsx(Ae.div,{"data-state":ta(s.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),cn="DialogContent",Td=p.forwardRef((e,t)=>{const n=Od(cn,e.__scopeDialog),{forceMount:r=n.forceMount,...s}=e,o=nt(cn,e.__scopeDialog);return g.jsx(Ht,{present:r||o.open,children:o.modal?g.jsx(ix,{...s,ref:t}):g.jsx(ax,{...s,ref:t})})});Td.displayName=cn;var ix=p.forwardRef((e,t)=>{const n=nt(cn,e.__scopeDialog),r=p.useRef(null),s=Pe(t,n.contentRef,r);return p.useEffect(()=>{const o=r.current;if(o)return $u(o)},[]),g.jsx(Id,{...e,ref:s,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:se(e.onCloseAutoFocus,o=>{o.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:se(e.onPointerDownOutside,o=>{const i=o.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&o.preventDefault()}),onFocusOutside:se(e.onFocusOutside,o=>o.preventDefault())})}),ax=p.forwardRef((e,t)=>{const n=nt(cn,e.__scopeDialog),r=p.useRef(!1),s=p.useRef(!1);return g.jsx(Id,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{e.onCloseAutoFocus?.(o),o.defaultPrevented||(r.current||n.triggerRef.current?.focus(),o.preventDefault()),r.current=!1,s.current=!1},onInteractOutside:o=>{e.onInteractOutside?.(o),o.defaultPrevented||(r.current=!0,o.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const i=o.target;n.triggerRef.current?.contains(i)&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&s.current&&o.preventDefault()}})}),Id=p.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:s,onCloseAutoFocus:o,...i}=e,a=nt(cn,n),c=p.useRef(null),l=Pe(t,c);return cu(),g.jsxs(g.Fragment,{children:[g.jsx(Ni,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:s,onUnmountAutoFocus:o,children:g.jsx(Ii,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":ta(a.open),...i,ref:l,onDismiss:()=>a.onOpenChange(!1)})}),g.jsxs(g.Fragment,{children:[g.jsx(lx,{titleId:a.titleId}),g.jsx(dx,{contentRef:c,descriptionId:a.descriptionId})]})]})}),ea="DialogTitle",Nd=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,s=nt(ea,n);return g.jsx(Ae.h2,{id:s.titleId,...r,ref:t})});Nd.displayName=ea;var Dd="DialogDescription",jd=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,s=nt(Dd,n);return g.jsx(Ae.p,{id:s.descriptionId,...r,ref:t})});jd.displayName=Dd;var Fd="DialogClose",Ld=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,s=nt(Fd,n);return g.jsx(Ae.button,{type:"button",...r,ref:t,onClick:se(e.onClick,()=>s.onOpenChange(!1))})});Ld.displayName=Fd;function ta(e){return e?"open":"closed"}var $d="DialogTitleWarning",[cx,Bd]=Ig($d,{contentName:cn,titleName:ea,docsSlug:"dialog"}),lx=({titleId:e})=>{const t=Bd($d),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users. If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component. For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return p.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},ux="DialogDescriptionWarning",dx=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Bd(ux).contentName}}.`;return p.useEffect(()=>{const s=e.current?.getAttribute("aria-describedby");t&&s&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},fx=Ad,hx=Rd,px=Pd,mx=Md,gx=Td,yx=Nd,vx=jd,Kd=Ld,zd="AlertDialog",[bx,Yx]=un(zd,[Sd]),At=Sd(),Vd=e=>{const{__scopeAlertDialog:t,...n}=e,r=At(t);return g.jsx(fx,{...r,...n,modal:!0})};Vd.displayName=zd;var wx="AlertDialogTrigger",xx=p.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,s=At(n);return g.jsx(hx,{...s,...r,ref:t})});xx.displayName=wx;var _x="AlertDialogPortal",Ud=e=>{const{__scopeAlertDialog:t,...n}=e,r=At(t);return g.jsx(px,{...r,...n})};Ud.displayName=_x;var Cx="AlertDialogOverlay",qd=p.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,s=At(n);return g.jsx(mx,{...s,...r,ref:t})});qd.displayName=Cx;var Rn="AlertDialogContent",[kx,Sx]=bx(Rn),Ax=Kg("AlertDialogContent"),Wd=p.forwardRef((e,t)=>{const{__scopeAlertDialog:n,children:r,...s}=e,o=At(n),i=p.useRef(null),a=Pe(t,i),c=p.useRef(null);return g.jsx(cx,{contentName:Rn,titleName:Hd,docsSlug:"alert-dialog",children:g.jsx(kx,{scope:n,cancelRef:c,children:g.jsxs(gx,{role:"alertdialog",...o,...s,ref:a,onOpenAutoFocus:se(s.onOpenAutoFocus,l=>{l.preventDefault(),c.current?.focus({preventScroll:!0})}),onPointerDownOutside:l=>l.preventDefault(),onInteractOutside:l=>l.preventDefault(),children:[g.jsx(Ax,{children:r}),g.jsx(Rx,{contentRef:i})]})})})});Wd.displayName=Rn;var Hd="AlertDialogTitle",Zd=p.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,s=At(n);return g.jsx(yx,{...s,...r,ref:t})});Zd.displayName=Hd;var Gd="AlertDialogDescription",Qd=p.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,s=At(n);return g.jsx(vx,{...s,...r,ref:t})});Qd.displayName=Gd;var Ex="AlertDialogAction",Yd=p.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,s=At(n);return g.jsx(Kd,{...s,...r,ref:t})});Yd.displayName=Ex;var Xd="AlertDialogCancel",Jd=p.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,{cancelRef:s}=Sx(Xd,n),o=At(n),i=Pe(t,s);return g.jsx(Kd,{...o,...r,ref:i})});Jd.displayName=Xd;var Rx=({contentRef:e})=>{const t=`\`${Rn}\` requires a description for the component to be accessible for screen reader users. You can add a description to the \`${Rn}\` by passing a \`${Gd}\` component as a child, which also benefits sighted users by adding visible context to the dialog. Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${Rn}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component. For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return p.useEffect(()=>{document.getElementById(e.current?.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null},Ox=Vd,Px=Ud,ef=qd,tf=Wd,Mx=Yd,Tx=Jd,nf=Zd,rf=Qd;const Ix=Ox,Nx=Px,sf=p.forwardRef(({className:e,...t},n)=>g.jsx(ef,{ref:n,className:Ve("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50 backdrop-blur-sm",e),...t}));sf.displayName=ef.displayName;const of=p.forwardRef(({className:e,...t},n)=>g.jsxs(Nx,{children:[g.jsx(sf,{}),g.jsx(tf,{ref:n,className:Ve("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed left-[50%] top-[50%] z-50 grid w-full max-w-[calc(100vw-2rem)] sm:max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border p-6 shadow-lg duration-200 rounded-xl",e),...t})]}));of.displayName=tf.displayName;function Dx({className:e,...t}){return g.jsx("div",{className:Ve("flex flex-col space-y-2 text-center sm:text-left",e),...t})}function jx({className:e,...t}){return g.jsx("div",{className:Ve("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2 space-y-2 space-y-reverse sm:space-y-0",e),...t})}const af=p.forwardRef(({className:e,...t},n)=>g.jsx(nf,{ref:n,className:Ve("text-lg font-semibold leading-none tracking-tight",e),...t}));af.displayName=nf.displayName;const cf=p.forwardRef(({className:e,...t},n)=>g.jsx(rf,{ref:n,className:Ve("text-sm text-muted-foreground",e),...t}));cf.displayName=rf.displayName;const Fx=Mx,Lx=Tx,Fc=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Lc=fi,$x=(e,t)=>n=>{var r;if(t?.variants==null)return Lc(e,n?.class,n?.className);const{variants:s,defaultVariants:o}=t,i=Object.keys(s).map(l=>{const u=n?.[l],d=o?.[l];if(u===null)return null;const f=Fc(u)||Fc(d);return s[l][f]}),a=n&&Object.entries(n).reduce((l,u)=>{let[d,f]=u;return f===void 0||(l[d]=f),l},{}),c=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((l,u)=>{let{class:d,className:f,...m}=u;return Object.entries(m).every(y=>{let[h,v]=y;return Array.isArray(v)?v.includes({...o,...a}[h]):{...o,...a}[h]===v})?[...l,d,f]:l},[]);return Lc(e,i,c,n?.class,n?.className)},Bx=$x("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}}),ii=p.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...s},o)=>{const i=r?$g:"button";return g.jsx(i,{ref:o,"data-slot":"button",className:Ve(Bx({variant:t,size:n,className:e})),...s})});ii.displayName="Button";function Kx(e){const{open:t,onOpenChange:n,title:r,description:s,confirmLabel:o="Confirm",cancelLabel:i="Cancel",confirmVariant:a="default",showNeverAskAgain:c=!1,neverAskAgainLabel:l="Never ask me again",onConfirm:u,onCancel:d}=e,[f,m]=p.useState(!1);return p.useEffect(()=>{t||m(!1)},[t]),g.jsx(Ix,{open:t,onOpenChange:n,children:g.jsxs(of,{children:[g.jsxs(Dx,{children:[g.jsx(af,{children:r}),s?g.jsx(cf,{children:s}):null]}),c&&g.jsxs("div",{className:"flex items-center gap-2 py-1",children:[g.jsx("input",{id:"confirm-dialog-never",type:"checkbox",className:"size-4 rounded border-white/20 bg-transparent accent-white",checked:f,onChange:y=>m(y.target.checked)}),g.jsx("label",{htmlFor:"confirm-dialog-never",className:"text-sm opacity-90 select-none",children:l})]}),g.jsxs(jx,{children:[g.jsx(Lx,{asChild:!0,children:g.jsx(ii,{variant:"outline",className:"cursor-pointer text-white hover:text-white",onClick:async()=>{d&&await d({neverAskAgain:f})},children:i})}),g.jsx(Fx,{asChild:!0,children:g.jsx(ii,{variant:a,className:"cursor-pointer",onClick:async()=>{u&&await u({neverAskAgain:f})},children:o})})]})]})})}async function zx(e,t=!0){try{const n=await Yo(e);if(typeof n=="boolean")return n}catch{}return t}async function $c(e,t){try{await Mt(e,!1)}catch{}}const lf=e=>{const{requested:t,preferenceKey:n,title:r,description:s,confirmLabel:o,cancelLabel:i,confirmVariant:a,neverAskAgainLabel:c,onConfirm:l,onCancel:u,onSettled:d}=e,[f,m]=p.useState(!1),y=p.useRef(!1);p.useEffect(()=>{const v=y.current;t&&!v&&(async()=>{if(await zx(n))m(!0);else try{await l()}finally{d&&await d()}})(),y.current=t},[t,n,l,d]);const h=async()=>{m(!1),d&&await d()};return g.jsx(Kx,{open:f,onOpenChange:v=>{v||h(),m(v)},title:r,description:s,confirmLabel:o,cancelLabel:i,confirmVariant:a,showNeverAskAgain:!0,onCancel:async({neverAskAgain:v}={})=>{try{v&&await $c(n,!0),u&&await u()}finally{await h()}},onConfirm:async({neverAskAgain:v}={})=>{try{v&&await $c(n,!0),await l()}finally{await h()}},neverAskAgainLabel:c})},Vx=({open:e,onClose:t,currentSessionId:n,onSelectSession:r})=>{const{data:s=[]}=tx(),o=p.useMemo(()=>s,[s]),[i,a]=p.useState(null),c=async()=>{r("")},l=async u=>{a(u)};return g.jsx("div",{className:Ve("fixed inset-y-0 left-0 z-50 w-72 bg-black/70 backdrop-blur-xl border-r border-white/10 transform transition-transform duration-300",e?"translate-x-0":"-translate-x-full"),children:g.jsxs("div",{className:"h-full flex flex-col",children:[g.jsxs("div",{className:"p-3 flex items-center justify-between border-b border-white/10",children:[g.jsxs("button",{onClick:c,className:"inline-flex items-center gap-2 px-3 py-1 rounded-md bg-white/10 border border-white/10 text-sm cursor-pointer hover:bg-white/15",children:[g.jsx(bo,{size:16})," New chat"]}),g.jsx("button",{onClick:t,"aria-label":"Close sidebar",className:"p-2 rounded-md hover:bg-white/10",children:g.jsx(ml,{size:18})})]}),g.jsx("div",{className:"flex-1 overflow-y-auto",children:o.length===0?g.jsx("div",{className:"p-4 text-sm text-white/70 select-none",children:"No history yet"}):g.jsx("ul",{className:"p-2",children:o.map((u,d)=>g.jsx("li",{className:Ve("group rounded-md overflow-hidden mb-1 border border-transparent hover:border-white/10"),children:g.jsxs("div",{role:"button",tabIndex:0,className:Ve("w-full text-left px-3 py-2 flex items-center justify-between gap-2 cursor-pointer outline-none",n===u.id?"bg-white/10":"hover:bg-white/5"),onClick:()=>r(u.id),onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),r(u.id))},children:[g.jsxs("div",{className:"flex flex-col",children:[g.jsx("span",{className:"text-sm",children:u.title?u.title:`${ga(u.createdAt)}`}),g.jsxs("span",{className:"text-xs text-white/60",children:["Updated ",ga(u.updatedAt)]})]}),g.jsx("button",{className:"opacity-60 hover:opacity-100 p-1 rounded hover:bg-white/10",onClick:f=>{f.stopPropagation(),l(u.id)},"aria-label":"Delete chat",children:g.jsx(pi,{size:16})})]})},u.id))})}),g.jsx(lf,{requested:i!==null,preferenceKey:"confirmDeleteChatSession",title:"Delete this chat?",description:"This will permanently delete this chat and all of its messages. This action cannot be undone.",confirmLabel:"Delete",confirmVariant:"destructive",onConfirm:async()=>{i&&(await Cg(i),n===i&&r(""))},onSettled:()=>a(null)})]})})},Ux=2e3,qx=".txt",Wx=()=>{const[e,t]=p.useState(""),{timelineItems:n,isLoading:r,sendMessage:s,stopStreaming:o,regenerateMessage:i,deleteAssistantTurn:a,sessionId:c,selectSession:l,startNewSession:u,setAssistantSwipeIndex:d,selectedModel:f,setSelectedModel:m,selectedTemplate:y,setSelectedTemplate:h}=Tg(),{data:v=[]}=yi(),b=(()=>{const I=v.find(K=>K?.id===f);return!!(I&&I.vision===!0)})(),w=p.useRef(null),x=p.useRef(null),_=p.useRef(null),[C,S]=p.useState([]),k=p.useRef(C),[A,O]=p.useState(!1),R=p.useRef(0),[T,q]=p.useState(!1),[H,W]=p.useState(null),[ue]=p.useState(!0),Q=Number(Ux),G=(()=>{const K=String(qx).split(",").map(F=>F.trim()).filter(Boolean).map(F=>F.startsWith(".")?F.toLowerCase():`.${F.toLowerCase()}`),re=Array.from(new Set(K)),ce=re.length>0?re:[".txt"];if(b){const F=[".png",".jpg",".jpeg"];return Array.from(new Set([...ce,...F]))}return ce})(),E=I=>{const K=I.toLowerCase();return G.some(re=>K.endsWith(re))},P=G.join(", "),U=G[0]||".txt",me=I=>{let K=0;for(const re of I){const ce=re.name.match(/^pasted-(\d+)\./);if(ce){const F=parseInt(ce[1],10);Number.isNaN(F)||(K=Math.max(K,F))}}return K+1};p.useEffect(()=>{const I=w.current;I&&(I.style.height="auto",I.style.height=`${Math.min(I.scrollHeight,300)}px`)},[e]),p.useEffect(()=>{try{(typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(pointer: coarse)").matches:!1)||w.current?.focus()}catch{}},[]);const Y=async()=>{if(!e.trim()||r)return;const I=e.trim(),K=C;t(""),S([]),await s(I,K)},L=async I=>{I.preventDefault(),await Y()},X=I=>{I.key==="Enter"&&!I.shiftKey&&(I.preventDefault(),L(I))},de=async I=>{try{const re=Array.from(I.clipboardData?.items||[]).filter(pe=>pe.kind==="file"&&typeof pe.type=="string"&&(pe.type==="image/png"||pe.type==="image/jpeg"));if(b&&re.length>0){const pe=C.length,rt=Math.max(0,5-pe);if(rt>0){I.preventDefault();const le=re.slice(0,rt),ke=await Promise.all(le.map(async we=>{const $e=we.getAsFile();if(!$e)return null;const Ye=await new Promise((Pr,uf)=>{const Un=new FileReader;Un.onload=()=>Pr(String(Un.result||"")),Un.onerror=()=>uf(Un.error||new Error("Failed to read image from clipboard")),Un.readAsDataURL($e)}),ht=(()=>{const Pr=($e.type||"").toLowerCase();return Pr==="image/png"?".png":Pr==="image/jpeg"?".jpg":".png"})(),Et=`pasted-${me(C)}${ht}`;return{id:`${Et}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,name:Et,content:Ye}}));S(we=>[...we,...ke.filter(Boolean)]);return}}const ce=Q;if(!ce||ce<=0)return;const F=I.clipboardData?.getData("text/plain")||"";if(!F||F.length{if(pe.length>=5)return pe;const le=`pasted-${me(pe)}${U}`;return[...pe,{id:_e,name:le,content:F}]})}catch{}},ne=()=>{r||_.current?.click()},D=async I=>{const K=I.target.files;if(!K||K.length===0)return;const re=C.length,ce=Math.max(0,5-re),F=Array.from(K).filter(ye=>E(ye.name)).slice(0,ce),be=await Promise.all(F.map(async ye=>{const _e=`${ye.name}-${ye.lastModified}-${Math.random().toString(36).slice(2,8)}`,pe=ye.name.toLowerCase();if(b&&(pe.endsWith(".png")||pe.endsWith(".jpg")||pe.endsWith(".jpeg"))){const le=await new Promise((ke,we)=>{const $e=new FileReader;$e.onload=()=>ke(String($e.result||"")),$e.onerror=()=>we($e.error||new Error("Failed to read image")),$e.readAsDataURL(ye)});return{id:_e,name:ye.name,content:le}}return{id:_e,name:ye.name,content:await ye.text()}}));S(ye=>[...ye,...be]),_.current&&(_.current.value="")},ie=I=>{S(K=>K.filter(re=>re.id!==I))};return p.useEffect(()=>{k.current=C},[C]),p.useEffect(()=>{const I=F=>{F.preventDefault(),F.dataTransfer&&(F.dataTransfer.dropEffect="copy")},K=F=>{!F.dataTransfer||!Array.from(F.dataTransfer.types||[]).includes("Files")||(R.current+=1,O(!0))},re=F=>{R.current=Math.max(0,R.current-1),R.current===0&&O(!1)},ce=async F=>{F.preventDefault(),R.current=0,O(!1);const be=F.dataTransfer?.files;if(!be||be.length===0)return;const ye=k.current.length,_e=Math.max(0,5-ye),pe=Array.from(be).filter(le=>E(le.name)).slice(0,_e);if(pe.length===0)return;const rt=await Promise.all(pe.map(async le=>{const ke=`${le.name}-${le.lastModified}-${Math.random().toString(36).slice(2,8)}`,we=le.name.toLowerCase();if(b&&(we.endsWith(".png")||we.endsWith(".jpg")||we.endsWith(".jpeg"))){const Ye=await new Promise((ht,na)=>{const Et=new FileReader;Et.onload=()=>ht(String(Et.result||"")),Et.onerror=()=>na(Et.error||new Error("Failed to read image")),Et.readAsDataURL(le)});return{id:ke,name:le.name,content:Ye}}return{id:ke,name:le.name,content:await le.text()}}));S(le=>[...le,...rt])};return window.addEventListener("dragover",I),window.addEventListener("dragenter",K),window.addEventListener("dragleave",re),window.addEventListener("drop",ce),()=>{window.removeEventListener("dragover",I),window.removeEventListener("dragenter",K),window.removeEventListener("dragleave",re),window.removeEventListener("drop",ce)}},[]),g.jsxs("div",{className:"relative bg-white/5 text-sidebar-foreground h-full w-full flex flex-col justify-between p-4 border border-white/10 rounded-2xl chat-container",children:[g.jsx(Vx,{open:T,onClose:()=>q(!1),currentSessionId:c??null,onSelectSession:async I=>{q(!1),await l(I||null),w.current?.focus()}}),T&&g.jsx("button",{type:"button","aria-label":"Close sidebar overlay",className:"fixed inset-0 z-40 bg-black/50",onClick:()=>q(!1)}),A&&g.jsx("div",{className:"fixed inset-0 z-40 pointer-events-none",children:g.jsx("div",{className:"absolute inset-2 md:inset-6 rounded-3xl border-2 border-dashed border-white/30 bg-black/40 backdrop-blur-sm flex items-center justify-center text-center",children:g.jsxs("div",{className:"px-6 py-4",children:[g.jsxs("p",{className:"text-lg font-medium",children:["Drop ",P," files to attach"]}),g.jsxs("p",{className:"text-xs text-white/70 mt-1",children:["Up to 5 files • ",P]})]})})}),g.jsx("header",{className:"flex justify-between items-center",children:g.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0 w-full",children:[g.jsx("button",{className:"w-8 h-8 rounded-md inline-flex items-center justify-center cursor-pointer bg-white/10 border border-white/10 hover:bg-white/15 hover:border-white/25 transition-colors",onClick:()=>q(!0),"aria-label":"Open menu",title:"Open menu",children:g.jsx(Lh,{size:20})}),g.jsxs("button",{type:"button",className:"hidden sm:inline-flex h-8 px-3 rounded-md items-center gap-1 cursor-pointer bg-white/10 border border-white/10 hover:bg-white/15 hover:border-white/25 transition-colors text-xs",onClick:()=>{u().then(()=>{w.current?.focus()})},"aria-label":"New chat",title:"New chat",children:[g.jsx(bo,{size:16}),g.jsx("span",{children:"New chat"})]}),g.jsx("div",{className:"sm:hidden flex items-center gap-2 flex-1 min-w-0",children:g.jsx(jc,{selectedModel:f,onSelectModel:m,selectedTemplate:y,onSelectTemplate:h,showModels:!0,showTemplates:!0,expand:!0})})]})}),g.jsx("main",{ref:x,className:`flex-grow flex flex-col items-center text-sm sm:text-base min-h-0 z-0 ${co.main}`,children:n.length===0?g.jsx("div",{className:"flex-grow flex items-center justify-center text-muted-foreground",children:g.jsx("p",{className:"select-none",children:"Start a conversation with Dolphin..."})}):g.jsx(Em,{items:n,models:v,onRegenerate:I=>i(I),onDelete:I=>{W(I)},onSwipeChange:(I,K)=>d(I,K)})}),g.jsx(lf,{requested:H!==null,preferenceKey:"confirmDeleteAssistantTurn",title:"Delete this message?",description:"This will remove the assistant reply and its preceding user message. This action cannot be undone.",confirmLabel:"Delete",confirmVariant:"destructive",onConfirm:async()=>{H&&a(H)},onSettled:()=>W(null)}),g.jsx("footer",{className:`w-full max-w-4xl mx-auto relative z-10 ${co.noAnchor}`,children:g.jsx("form",{onSubmit:L,children:g.jsxs("div",{className:"bg-glass rounded-2xl p-4",children:[C.length>0&&g.jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:C.map(I=>{const K=I.name,re=K.length>10?K.slice(0,10)+"…":K;return g.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 rounded-full bg-white/10 border border-white/15 text-xs",children:[re,g.jsx("button",{type:"button",className:"p-0.5 rounded hover:bg-white/10","aria-label":`Remove ${I.name}`,onClick:()=>ie(I.id),children:g.jsx(ml,{size:12})})]},I.id)})}),g.jsx(ll,{ref:w,placeholder:"Ask dolphin...",className:`border-none w-full px-4 py-3 text-base sm:text-sm placeholder:text-muted-foreground text-white focus-visible:ring-0 focus-visible:ring-offset-0 resize-none ${co.composer}`,rows:1,value:e,onChange:I=>t(I.target.value),onKeyDown:X,onPaste:de}),g.jsxs("div",{className:"mt-2 flex justify-between items-center",children:[g.jsxs("div",{children:[g.jsx("div",{className:"hidden sm:block",children:g.jsx(jc,{selectedModel:f,onSelectModel:m,selectedTemplate:y,onSelectTemplate:h,showModels:!0,showTemplates:!0})}),g.jsx("div",{className:"sm:hidden",children:g.jsxs("button",{type:"button",className:"h-8 px-3 rounded-md inline-flex items-center gap-2 cursor-pointer bg-white/10 border border-white/10 hover:bg-white/15 hover:border-white/25 transition-colors text-xs",onClick:()=>{u().then(()=>{w.current?.focus()})},"aria-label":"New chat",title:"New chat",children:[g.jsx(bo,{size:16}),g.jsx("span",{children:"New chat"})]})})]}),g.jsxs("div",{className:"flex bg-white/10 rounded-full border-2 border-white/5 px-2 py-1 items-center gap-x-3",children:[g.jsx("input",{ref:_,type:"file",accept:G.join(","),multiple:!0,hidden:!0,onChange:D}),g.jsx("button",{type:"button",onClick:ne,className:"text-white/80 hover:text-white transition-colors cursor-pointer hover:bg-white/10 rounded","aria-label":"Attach files",title:`Attach ${P} files`,children:g.jsx(Bh,{size:20})}),r?g.jsx("button",{type:"button",className:"bg-red-500/20 hover:bg-red-500/30 text-white rounded-full p-2 border-2 border-red-500/30 transition-colors",onClick:I=>{I.preventDefault(),o()},"aria-label":"Stop streaming",title:"Stop streaming",children:g.jsx(Wh,{size:20})}):g.jsx("button",{type:"submit",disabled:!e.trim()||r,className:"bg-white/10 border-2 hover:bg-white/20 disabled:opacity-50 disabled:cursor-not-allowed text-white rounded-full p-2 border-white/5 transition-colors",onClick:I=>{I.preventDefault(),Y()},"aria-label":"Send",title:"Send",children:g.jsx(Uh,{size:20})})]})]})]})})})]})},Xx=()=>g.jsx(Hf,{children:g.jsx(Wx,{})});export{hl as C,mi as _,va as a,Xx as b,Ge as c,Xn as e,pm as p,jt as s};