@fungi.computer/grove 0.6.0 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{anthropic-messages-CPEaUutD.js → anthropic-messages-CDm0hoBV.js} +3 -3
- package/dist/assets/{azure-openai-responses-v3mj5CZZ.js → azure-openai-responses-BjoRAOlM.js} +1 -1
- package/dist/assets/burger-DGewjCsv.js +1 -0
- package/dist/assets/cat-CRMM8U8H.js +1 -0
- package/dist/assets/{compat-CwkWF6ok.js → compat-tatm8WJ0.js} +2 -2
- package/dist/assets/{extension-hook-Br5iAg1w.js → extension-hook-CmoMuW6C.js} +2 -2
- package/dist/assets/{extensions-CjtnEhJO.js → extensions-CrmxvtfG.js} +1 -1
- package/dist/assets/{google-generative-ai-Cr31vBXM.js → google-generative-ai-xdelq2ko.js} +1 -1
- package/dist/assets/{google-shared-B7c3mJMP.js → google-shared-P7z8Pe9d.js} +1 -1
- package/dist/assets/{google-vertex-DkitNPeW.js → google-vertex-8hsu6Eaf.js} +1 -1
- package/dist/assets/{index-CKEriJXp.js → index-CCJvRnqn.js} +4 -4
- package/dist/assets/{mistral-conversations-BP4PIzHA.js → mistral-conversations-JKMpJrPb.js} +1 -1
- package/dist/assets/{mushroom-DWyBmJbK.js → mushroom-ur0TNKww.js} +1 -1
- package/dist/assets/{node.browser-Dxo8S8wh.js → node.browser-GHKlzSn3.js} +1 -1
- package/dist/assets/{openai-codex-responses-BIR4H8vE.js → openai-codex-responses-CidQ12Xa.js} +1 -1
- package/dist/assets/{openai-completions-rOTfBeMc.js → openai-completions-D9RzypE9.js} +1 -1
- package/dist/assets/{openai-responses-CDJo-fey.js → openai-responses-BXeaL2BV.js} +1 -1
- package/dist/assets/{openai-responses-shared-mHodHbGd.js → openai-responses-shared-Da1jFqQB.js} +1 -1
- package/dist/assets/{parakeet-conversation-C7vaUI2C.js → parakeet-conversation-DYlN7oL9.js} +1 -1
- package/dist/assets/{renderer-BMvbFBH6.js → renderer-BKCye2Ev.js} +1 -1
- package/dist/assets/{runtime-core-BCAZGL-z.js → runtime-core-DKpk6tKT.js} +1 -1
- package/dist/assets/{transform-messages-CiA_d5H1.js → transform-messages-YmXk5TtR.js} +1 -1
- package/dist/index.html +2 -2
- package/package.json +9 -9
- package/dist/assets/burger-CPCRQtwa.js +0 -1
- package/dist/assets/cat-BxITknTO.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/runtime-core-
|
|
2
|
-
import{r as e,t}from"./rolldown-runtime-hePW80VL.js";import{$a as n,$i as r,Aa as i,Ba as a,Bi as o,Ca as s,Ci as c,Ct as l,Da as u,E as d,Ea as f,Fa as p,Fi as m,Ga as h,Gi as g,Gn as _,Ha as v,Hi as y,I as b,Ia as x,Ii as S,Ji as C,Ka as w,Ki as T,La as E,Li as D,Ma as O,Na as k,Oa as A,Oi as j,Pa as M,Qa as N,Ra as P,Ri as F,Sa as I,St as L,Ta as ee,Ua as te,Ui as ne,V as re,Va as R,Vi as ie,Wa as ae,Wi as z,X as oe,Xa as se,Xi as ce,Y as le,Ya as ue,Yi as de,Yn as fe,Zi as pe,_a as me,a as he,aa as ge,at as _e,bt as ve,ca as ye,d as be,da as xe,ea as Se,er as Ce,et as we,ft as Te,g as Ee,ga as De,ha as Oe,ht as ke,ia as Ae,ir as je,j as Me,ja as Ne,ka as Pe,l as Fe,la as Ie,lr as Le,m as Re,ma as B,mt as ze,nr as Be,oa as Ve,or as He,pa as Ue,pi as We,pt as Ge,qa as Ke,qi as qe,ra as Je,rt as Ye,s as Xe,sr as Ze,t as Qe,ta as $e,tr as et,ua as tt,va as V,vi as nt,wa as rt,xa as it,xt as at,y as ot,yt as st,za as ct,zi as lt}from"./Effect-CtszBD7f.js";import{$r as ut,Aa as dt,Ai as ft,Ba as pt,Bi as mt,Br as ht,Ca as gt,Ci as _t,Co as vt,Cr as yt,Dn as bt,Dr as xt,Ea as St,Ei as Ct,Fa as wt,Fr as Tt,Ga as Et,Gn as Dt,Gr as Ot,Ha as kt,Hi as At,Hr as jt,Ia as Mt,Ja as Nt,Jr as Pt,Ka as Ft,Kr as It,La as Lt,Li as Rt,Ma as zt,Mi as Bt,Na as Vt,Ni as Ht,Pa as Ut,Pr as Wt,Si as Gt,Ta as Kt,Ti as qt,Ua as Jt,Ur as Yt,Va as Xt,Vi as Zt,Wa as Qt,Wr as $t,Xa as en,Xi as tn,Ya as nn,Yr as rn,Zi as an,Zr as on,_i as sn,_r as cn,ao as ln,ba as un,bi as dn,bo as fn,ca as pn,co as mn,d as hn,di as gn,ea as _n,ei as vn,eo as yn,f as bn,fa as H,fi as xn,fo as Sn,ga as Cn,gi as wn,go as Tn,i as En,ia as Dn,ii as On,ji as kn,ki as An,kr as jn,l as Mn,li as Nn,lo as Pn,m as Fn,mi as U,n as In,ni as Ln,no as Rn,oi as zn,p as Bn,pi as W,po as Vn,qa as Hn,ri as G,ro as Un,so as Wn,ti as Gn,u as Kn,ui as qn,uo as Jn,vi as Yn,wa as K,wi as q,wr as Xn,xi as Zn,xo as Qn,yi as $n,za as er,zi as tr,zr as nr}from"./extension-hook-Br5iAg1w.js";import{a as rr,o as ir,s as ar,t as or}from"./document-Bagsf-XI.js";import{t as sr}from"./preload-helper-DY31Aviq.js";import{a as cr,i as lr,n as ur,r as dr,t as fr}from"./base-face-DzmOsdaJ.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var pr=t((e=>{var t=Symbol.for(`react.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.provider`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.iterator;function p(e){return typeof e!=`object`||!e?null:(e=f&&e[f]||e[`@@iterator`],typeof e==`function`?e:null)}var m={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},h=Object.assign,g={};function _(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||m}_.prototype.isReactComponent={},_.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`setState(...): takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},_.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function v(){}v.prototype=_.prototype;function y(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||m}var b=y.prototype=new v;b.constructor=y,h(b,_.prototype),b.isPureReactComponent=!0;var x=Array.isArray,S=Object.prototype.hasOwnProperty,C={current:null},w={key:!0,ref:!0,__self:!0,__source:!0};function T(e,n,r){var i,a={},o=null,s=null;if(n!=null)for(i in n.ref!==void 0&&(s=n.ref),n.key!==void 0&&(o=``+n.key),n)S.call(n,i)&&!w.hasOwnProperty(i)&&(a[i]=n[i]);var c=arguments.length-2;if(c===1)a.children=r;else if(1<c){for(var l=Array(c),u=0;u<c;u++)l[u]=arguments[u+2];a.children=l}if(e&&e.defaultProps)for(i in c=e.defaultProps,c)a[i]===void 0&&(a[i]=c[i]);return{$$typeof:t,type:e,key:o,ref:s,props:a,_owner:C.current}}function E(e,n){return{$$typeof:t,type:e.type,key:n,ref:e.ref,props:e.props,_owner:e._owner}}function D(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function O(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var k=/\/+/g;function A(e,t){return typeof e==`object`&&e&&e.key!=null?O(``+e.key):t.toString(36)}function j(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0}}if(c)return c=e,o=o(c),e=a===``?`.`+A(c,0):a,x(o)?(i=``,e!=null&&(i=e.replace(k,`$&/`)+`/`),j(o,r,i,``,function(e){return e})):o!=null&&(D(o)&&(o=E(o,i+(!o.key||c&&c.key===o.key?``:(``+o.key).replace(k,`$&/`)+`/`)+e)),r.push(o)),1;if(c=0,a=a===``?`.`:a+`:`,x(e))for(var l=0;l<e.length;l++){s=e[l];var u=a+A(s,l);c+=j(s,r,i,u,o)}else if(u=p(e),typeof u==`function`)for(e=u.call(e),l=0;!(s=e.next()).done;)s=s.value,u=a+A(s,l++),c+=j(s,r,i,u,o);else if(s===`object`)throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`);return c}function M(e,t,n){if(e==null)return e;var r=[],i=0;return j(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function N(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var P={current:null},F={transition:null},I={ReactCurrentDispatcher:P,ReactCurrentBatchConfig:F,ReactCurrentOwner:C};function L(){throw Error(`act(...) is not supported in production builds of React.`)}e.Children={map:M,forEach:function(e,t,n){M(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return M(e,function(){t++}),t},toArray:function(e){return M(e,function(e){return e})||[]},only:function(e){if(!D(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}},e.Component=_,e.Fragment=r,e.Profiler=a,e.PureComponent=y,e.StrictMode=i,e.Suspense=l,e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=I,e.act=L,e.cloneElement=function(e,n,r){if(e==null)throw Error(`React.cloneElement(...): The argument must be a React element, but you passed `+e+`.`);var i=h({},e.props),a=e.key,o=e.ref,s=e._owner;if(n!=null){if(n.ref!==void 0&&(o=n.ref,s=C.current),n.key!==void 0&&(a=``+n.key),e.type&&e.type.defaultProps)var c=e.type.defaultProps;for(l in n)S.call(n,l)&&!w.hasOwnProperty(l)&&(i[l]=n[l]===void 0&&c!==void 0?c[l]:n[l])}var l=arguments.length-2;if(l===1)i.children=r;else if(1<l){c=Array(l);for(var u=0;u<l;u++)c[u]=arguments[u+2];i.children=c}return{$$typeof:t,type:e.type,key:a,ref:o,props:i,_owner:s}},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:o,_context:e},e.Consumer=e},e.createElement=T,e.createFactory=function(e){var t=T.bind(null,e);return t.type=e,t},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=D,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:N}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=F.transition;F.transition={};try{e()}finally{F.transition=t}},e.unstable_act=L,e.useCallback=function(e,t){return P.current.useCallback(e,t)},e.useContext=function(e){return P.current.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e){return P.current.useDeferredValue(e)},e.useEffect=function(e,t){return P.current.useEffect(e,t)},e.useId=function(){return P.current.useId()},e.useImperativeHandle=function(e,t,n){return P.current.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return P.current.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return P.current.useLayoutEffect(e,t)},e.useMemo=function(e,t){return P.current.useMemo(e,t)},e.useReducer=function(e,t,n){return P.current.useReducer(e,t,n)},e.useRef=function(e){return P.current.useRef(e)},e.useState=function(e){return P.current.useState(e)},e.useSyncExternalStore=function(e,t,n){return P.current.useSyncExternalStore(e,t,n)},e.useTransition=function(){return P.current.useTransition()},e.version=`18.3.1`})),mr=t(((e,t)=>{t.exports=pr()})),J=e(mr(),1),hr=ye(),gr=Ie(()=>ge(`status`,[B({status:tt(`available`)}).strict(),B({status:tt(`unavailable`),reason:V()}).strict()])),_r=hr,vr=Ie(()=>De(V(),_r)),yr=e=>_r.parse(e),br=e=>vr.parse(e),xr=Ie(()=>B({code:V().min(1).max(160),message:V().min(1).max(512),details:_r.optional()}).strict()),Sr=e=>xr.parse(e),Cr=vr,wr=Ie(()=>V().refine(e=>e.trim().length>0)),Tr=gr,Er=Ie(()=>it([B({type:tt(`action`)}).strict(),B({type:tt(`custom`),data:vr}).strict(),B({type:tt(`choice`),options:Se(B({value:_r,label:wr,description:wr.optional()}))}).strict(),B({type:tt(`form`),submitLabel:wr.optional()}).strict(),B({type:tt(`confirmation`),message:wr,confirmLabel:wr.optional(),cancelLabel:wr.optional()}).strict()])),Dr=Ie(()=>B({inputSchema:Cr.optional(),outputSchema:Cr.optional(),presentation:Er.optional()}).strict()),Or=Ie(()=>Ue().int().refine(e=>Number.isSafeInteger(e))),kr=Ie(()=>B({hint:wr.pipe(V().max(120)),words:Se(B({word:V().regex(/^\S{1,64}$/u),description:wr.pipe(V().max(512)).optional(),arguments:vr}).strict()).max(32).optional(),text:B({field:wr.pipe(V().max(120)),arguments:vr,requestIdField:wr.pipe(V().max(120)).optional()}).strict().optional()}).strict().refine(e=>e.words!==void 0||e.text!==void 0,`slash arguments need words or text`)),Ar=Ie(()=>B({order:Or.optional()}).strict()),jr=Ie(()=>B({bindings:B({order:Or.optional(),values:Se(wr).max(16)}).strict().optional(),agent:B({keybind:wr.optional(),order:Or.optional()}).strict().optional(),help:Ar.optional(),menu:Ar.optional(),palette:Ar.optional(),slash:B({aliases:Se(wr).max(16),consumesDraft:Je().optional(),order:Or.optional(),arguments:kr.optional()}).strict().optional()}).strict()),Mr=Ie(()=>B({id:wr.refine(e=>!e.includes(`:`)),title:wr,category:wr,description:wr.optional(),projections:jr.optional(),action:Dr.optional(),availability:Tr.optional()}).strict()),Nr=e=>Mr.parse(e),Pr=Ie(()=>B({inputSchema:Cr.optional(),outputSchema:Cr.optional()}).strict()),Fr=V().min(1).brand(),Ir=Ie(()=>B({commandId:Fr,command:B({namespace:V(),id:V()}).strict(),sourceId:V(),scope:V().optional(),title:V(),category:V(),description:V().optional(),order:Ue(),availability:gr,action:Pr.optional(),keybind:V().optional()}).strict());Se(Ir);var Lr=8192,Rr=wr.pipe(V().max(Lr)),zr=wr.pipe(V().max(60)),Br=s({protocol:/^https?$/u}),Vr=B({label:Rr,value:Rr}).strict(),Hr={summary:Rr.optional(),facts:Se(Vr).max(4).optional(),body:Rr.optional(),bodyLabel:Rr.optional(),details:Se(Vr).max(24).optional()},Ur=ge(`type`,[B({type:tt(`choice`),message:zr,...Hr,current:Rr.optional(),collapsedGroup:Rr.optional(),options:Se(B({value:Rr,label:Rr,description:Rr.optional(),group:Rr.optional(),destructive:tt(!0).optional()}).strict()).min(1).max(256)}).strict(),B({type:tt(`text`),message:zr,...Hr,placeholder:Rr.optional(),secret:Je().optional()}).strict(),B({type:tt(`confirmation`),message:zr,...Hr,confirmLabel:Rr.optional(),cancelLabel:Rr.optional(),destructive:tt(!0).optional()}).strict(),B({type:tt(`decision`),message:zr,...Hr,options:Se(B({value:Rr,label:Rr,description:Rr.optional(),destructive:tt(!0).optional()}).strict()).min(1).max(8).refine(e=>new Set(e.map(e=>e.value)).size===e.length,`Decision option values must be unique`),multiple:Je().optional(),other:B({label:Rr,placeholder:Rr.optional(),maxLength:Ue().int().min(1).max(Lr),blank:Rr.optional()}).strict().optional(),escape:Rr.optional()}).strict().refine(e=>[e.escape,e.other?.blank].every(t=>t===void 0||e.options.some(e=>e.value===t)),`A decision's escape and blank answers must be offered options`)]),Wr=Ie(()=>ge(`type`,[B({type:tt(`info`),message:Rr,links:Se(B({url:Br,label:Rr.optional()}).strict()).max(16).optional()}).strict(),B({type:tt(`progress`),message:Rr}).strict(),B({type:tt(`handoff`),url:Br,code:Rr.optional(),message:Rr.optional()}).strict(),B({type:tt(`success`),message:Rr}).strict()])),Gr=e=>Ur.parse(e),Kr=e=>Wr.parse(e),qr={decision:e=>{let t=Ur.options[3].parse(e),n=new Set(t.options.map(e=>e.value));return B({selected:Se(V()).max(t.options.length),text:Ve(wr.pipe(V().max(t.other?.maxLength??1)))}).strict().superRefine((e,r)=>{let i=e=>{r.addIssue({code:`custom`,message:e})};(e.selected.some(e=>!n.has(e))||new Set(e.selected).size!==e.selected.length)&&i(`Pick each offered option at most once`),t.multiple!==!0&&e.selected.length>1&&i(`Pick one option`),e.selected.length===0&&e.text===void 0&&i(`Pick an option or write an answer`),t.other===void 0&&e.text!==void 0&&i(`This decision takes no written answer`),t.multiple!==!0&&e.selected.length>0&&e.text!==void 0&&i(`Pick an option or write an answer, not both`)})},confirmation:e=>(Ur.options[2].parse(e),Je()),text:e=>(Ur.options[1].parse(e),V().max(Lr)),choice:e=>{let t=Ur.options[0].parse(e);return V().refine(e=>t.options.some(t=>t.value===e))}};function Jr(e){let t=qr[e.type](e);return e=>{let n=t.safeParse(e);return n.success?{kind:`accepted`,value:n.data}:{kind:`invalid`,cause:n.error}}}var Yr=class extends Error{code;details;constructor(e,t,n){super(t),this.code=e,this.details=n,this.name=`WhistleActionError`}},Xr=class extends Error{constructor(){super(`Whistle runtime is closed`),this.name=`WhistleClosedError`}};function Zr(){let e=!1,t=Ai,n=[],r=[],i=!1,a=[],o=new Set,s=()=>{for(let e of o)e()};return Object.freeze({close:()=>{e||(e=!0,n=[],a=[],r=[],t=Ai,s(),o.clear())},contribute:t=>{if(oi(t),e)throw new Xr;si(t,n),ci(t,n);let r=Symbol(`whistle-contribution`);ai(t)||(n=[...n,{contribution:li(t),generation:r}],i=!0,s());let a=!0;return Oi(o=>{if(!a||e)return;let c={...t,commands:o};oi(c);let l=n.findIndex(e=>e.generation===r),u=n.filter(e=>e.generation!==r);si(c,u),ci(c,u);let d=li(c);if(ai(c)){if(l<0)return;n=u}else n=l<0?[...n,{contribution:d,generation:r}]:n.map(e=>e.generation===r?{contribution:d,generation:r}:e);i=!0,s()},()=>{a&&(a=!1,n.find(e=>e.generation===r)!==void 0&&(n=n.filter(e=>e.generation!==r),i=!0,s()))})},execute:async(t,r)=>{if(t.namespace.trim().length===0||t.id.trim().length===0)return{status:`invalid`};if(e)return{status:`closed`};let i=ii(t,n);if(i===void 0)return{status:`missing`};let o;try{let e=Mi(i);if(e.status===`unavailable`)return e;let n=a.at(-1)?.presenter;r.interaction===void 0&&n!==void 0&&Qr.has(r.origin)&&(o=n({commandId:ri(t.namespace,t.id),title:i.title}));let s={...r,signal:r.signal??new AbortController().signal};o!==void 0&&(s.interaction=o.interaction,s.signal=AbortSignal.any([s.signal,o.interaction.signal]));let c=await i.handler(s);return o?.settle({status:`handled`}),c===void 0?{status:`handled`}:{status:`handled`,result:c}}catch(e){let t=Pi(e instanceof Error?e:Error(`Command handler threw a non-Error value`));return o?.settle(o.interaction.signal.aborted?{status:`cancelled`}:{status:`failed`,message:t.message}),{status:`failed`,error:t}}},present:t=>{let n={presenter:t};return e||(a=[...a,n]),()=>{a=a.filter(e=>e!==n)}},snapshot:()=>{if(e)return Ai;let a=n.flatMap(e=>e.contribution.commands.map(Mi));return(i||a.some((e,t)=>!Ni(e,r[t])))&&(t=Fi(n,a),r=a,i=!1),t},subscribe:t=>e?()=>void 0:(o.add(t),()=>{o.delete(t)})})}var Qr=new Set([`browser`,`keyboard`,`menu`,`palette`,`slash`,`terminal`]),$r=16,ei=32,ti=64,ni=256;function ri(e,t){return Fr.parse(`${e}:${t}`)}function ii(e,t){for(let n of t)if(n.contribution.namespace===e.namespace){for(let t of n.contribution.commands)if(t.id===e.id)return t}}function ai(e){return e.commands.length===0}function oi(e){Ei(e.sourceId,`source ID`),Ei(e.namespace,`namespace`),e.scope!==void 0&&Ei(e.scope,`scope`);for(let t of e.commands)xi(t)}function si(e,t){t.find(t=>t.contribution.namespace===e.namespace&&t.contribution.sourceId!==e.sourceId)!==void 0&&ki(`Namespace is already owned by another source`);let n=new Set,r=new Set;for(let i of t){let t=i.contribution.scope===e.scope;for(let e of i.contribution.commands)if(n.add(ri(i.contribution.namespace,e.id)),t)for(let t of e.projections?.slash?.aliases??[])r.add(t)}for(let t of e.commands){let i=ri(e.namespace,t.id);n.has(i)&&ki(`Canonical command ID is already registered`),n.add(i);for(let e of t.projections?.slash?.aliases??[])r.has(e)&&ki(`Slash alias is already registered`),r.add(e)}}function ci(e,t){t.length>=ti&&ki(`Live contribution capacity exceeded`),t.reduce((e,t)=>e+t.contribution.commands.length,0)+e.commands.length>ni&&ki(`Live command capacity exceeded`)}function li(e){let t={sourceId:e.sourceId,namespace:e.namespace,commands:e.commands.map(ui)};return e.scope===void 0?t:{...t,scope:e.scope}}function ui(e){let t={id:e.id,title:e.title,category:e.category,handler:e.handler};return e.description!==void 0&&(t.description=e.description),e.action!==void 0&&(t.action=di(e.action)),e.availability!==void 0&&(t.availability=e.availability),e.projections!==void 0&&(t.projections=hi(e.projections)),t}function di(e){let t={};return e.inputSchema!==void 0&&(t.inputSchema=fi(e.inputSchema)),e.outputSchema!==void 0&&(t.outputSchema=fi(e.outputSchema)),e.presentation!==void 0&&(t.presentation=mi(e.presentation)),Object.freeze(t)}function fi(e){return Object.freeze(Object.fromEntries(Object.entries(e).map(([e,t])=>[e,pi(t)])))}function pi(e){return Array.isArray(e)?Object.freeze(e.map(pi)):e!==null&&e instanceof Object?Object.freeze(Object.fromEntries(Object.entries(e).map(([e,t])=>[e,pi(t)]))):e}function mi(e){switch(e.type){case`action`:return Object.freeze({type:`action`});case`custom`:return Object.freeze({type:`custom`,data:fi(e.data)});case`choice`:return Object.freeze({type:`choice`,options:Object.freeze(e.options.map(e=>Object.freeze({...e,value:pi(e.value)})))});case`form`:return Object.freeze({...e});case`confirmation`:return Object.freeze({...e})}}function hi(e){let t={};return e.bindings!==void 0&&(t.bindings=gi(e.bindings)),e.agent!==void 0&&(t.agent=_i(e.agent)),e.help!==void 0&&(t.help=vi(e.help.order)),e.menu!==void 0&&(t.menu=vi(e.menu.order)),e.palette!==void 0&&(t.palette=vi(e.palette.order)),e.slash!==void 0&&(t.slash=yi(e.slash)),t}function gi(e){let t={values:[...e.values]};return e.order!==void 0&&(t.order=e.order),t}function _i(e){let t={};return e.keybind!==void 0&&(t.keybind=e.keybind),e.order!==void 0&&(t.order=e.order),t}function vi(e){let t={};return e!==void 0&&(t.order=e),t}function yi(e){let t={aliases:[...e.aliases]};return e.order!==void 0&&(t.order=e.order),e.consumesDraft!==void 0&&(t.consumesDraft=e.consumesDraft),e.arguments!==void 0&&(t.arguments=bi(e.arguments)),t}function bi(e){let t={hint:e.hint};return e.words!==void 0&&(t.words=Object.freeze(e.words.map(e=>Object.freeze({...e,arguments:fi(e.arguments)})))),e.text!==void 0&&(t.text=Object.freeze({...e.text,arguments:fi(e.text.arguments)})),Object.freeze(t)}function xi(e){Ei(e.id,`command ID`,!0),Ei(e.title,`title`),Ei(e.category,`category`),Si(e.action),Ci(e.projections)}function Si(e){if(e?.presentation!==void 0)switch(e.presentation.type){case`action`:case`custom`:return;case`choice`:for(let t of e.presentation.options)Ei(t.label,`choice label`),t.description!==void 0&&Ei(t.description,`choice description`);return;case`form`:e.presentation.submitLabel!==void 0&&Ei(e.presentation.submitLabel,`submit label`);return;case`confirmation`:Ei(e.presentation.message,`confirmation message`),e.presentation.confirmLabel!==void 0&&Ei(e.presentation.confirmLabel,`confirmation label`),e.presentation.cancelLabel!==void 0&&Ei(e.presentation.cancelLabel,`cancellation label`)}}function Ci(e){if(e!==void 0){for(let t of[e.bindings,e.palette,e.slash,e.help,e.menu,e.agent])t!==void 0&&Di(t.order);if(e.bindings!==void 0&&Ti(e.bindings.values,`binding`),e.slash!==void 0){Ti(e.slash.aliases,`slash alias`);for(let t of e.slash.aliases)/\s/u.test(t)&&ki(`slash alias must not contain whitespace`);wi(e.slash.arguments)}e.agent?.keybind!==void 0&&Ei(e.agent.keybind,`agent keybind`)}}function wi(e){if(e===void 0)return;Ei(e.hint,`argument hint`),e.words===void 0&&e.text===void 0&&ki(`slash arguments need words or text`);let t=new Set;for(let n of e.words??[])Ei(n.word,`argument word`),/\s/u.test(n.word)&&ki(`argument word must not contain whitespace`),t.has(n.word)&&ki(`argument word is repeated`),t.add(n.word),n.description!==void 0&&Ei(n.description,`argument word description`);t.size>ei&&ki(`argument word count exceeds 32`),e.text!==void 0&&(Ei(e.text.field,`argument text field`),e.text.requestIdField!==void 0&&Ei(e.text.requestIdField,`request id field`))}function Ti(e,t){e.length>$r&&ki(`${t} count exceeds 16`);for(let n of e)Ei(n,t)}function Ei(e,t,n=!1){e.trim().length===0&&ki(`${t} must not be blank`),n&&e.includes(`:`)&&ki(`${t} must not contain a colon`)}function Di(e){e!==void 0&&!Number.isSafeInteger(e)&&ki(`order must be a safe integer`)}function Oi(e=()=>void 0,t=()=>void 0){return Object.freeze({update:e,dispose:t})}function ki(e){throw Error(e)}var Ai=Object.freeze({bindings:Object.freeze([]),palette:Object.freeze([]),slash:Object.freeze([]),help:Object.freeze([]),menu:Object.freeze([]),agent:Object.freeze([])}),ji=Object.freeze({status:`available`});function Mi(e){let t=e.availability?.()??ji;return t.status===`available`?ji:Object.freeze({status:`unavailable`,reason:t.reason})}function Ni(e,t){return e.status===`available`?t?.status===`available`:t?.status===`unavailable`&&e.reason===t.reason}function Pi(e){if(e instanceof Yr){let t={code:e.code,message:e.message};return Object.freeze(e.details===void 0?t:{...t,details:pi(e.details)})}return Object.freeze({code:`command_failed`,message:e.message})}function Fi(e,t){let n=[],r=[],i=[],a=[],o=[],s=[],c=0;for(let l of e){let e=l.contribution;for(let l of e.commands){let u=l.projections,d=t[c++]??ji;if(u?.bindings!==void 0)for(let t of u.bindings.values)n.push({...Hi(e,l,u.bindings.order,d),binding:t});if(u?.palette!==void 0&&r.push({...Hi(e,l,u.palette.order,d)}),u?.slash!==void 0)for(let t of u.slash.aliases){let n={...Hi(e,l,u.slash.order,d),alias:t};u.slash.consumesDraft!==void 0&&(n={...n,consumesDraft:u.slash.consumesDraft}),u.slash.arguments!==void 0&&(n={...n,arguments:u.slash.arguments}),i.push(n)}u?.help!==void 0&&a.push({...Hi(e,l,u.help.order,d)}),u?.menu!==void 0&&o.push({...Hi(e,l,u.menu.order,d)}),u?.agent!==void 0&&s.push(Wi(e,l,u.agent,d))}}return zi(n),Bi(i),Ri(r),Ri(a),Ri(o),Ri(s),Object.freeze({bindings:Vi(n),palette:Vi(r),slash:Vi(i),help:Vi(a),menu:Vi(o),agent:Vi(s)})}var Ii=new TextEncoder;function Li(e,t){let n=Ii.encode(e),r=Ii.encode(t),i=Math.min(n.length,r.length);for(let e=0;e<i;e+=1){let t=n[e]??0,i=r[e]??0;if(t!==i)return t<i?-1:1}return n.length<r.length?-1:+(n.length>r.length)}function Ri(e){e.sort((e,t)=>e.order-t.order||Li(e.commandId,t.commandId))}function zi(e){e.sort((e,t)=>e.order-t.order||Li(e.commandId,t.commandId)||Li(e.binding,t.binding))}function Bi(e){e.sort((e,t)=>e.order-t.order||Li(e.commandId,t.commandId)||Li(e.alias,t.alias))}function Vi(e){return Object.freeze(e.map(e=>Object.freeze(e)))}function Hi(e,t,n,r){let i=Ui(e,t,n,r);return e.scope===void 0?i:{...i,scope:e.scope}}function Ui(e,t,n,r){let i={commandId:ri(e.namespace,t.id),command:Object.freeze({namespace:e.namespace,id:t.id}),sourceId:e.sourceId,title:t.title,category:t.category,order:n??0,availability:r},a=t.description===void 0?i:{...i,description:t.description};return t.action===void 0?a:{...a,action:t.action}}function Wi(e,t,n,r){let i=Hi(e,t,n.order,r),a=i.action===void 0?i:{...i,action:Gi(i.action)};return n.keybind===void 0?a:{...a,keybind:n.keybind}}function Gi(e){let t={};return e.inputSchema!==void 0&&(t.inputSchema=e.inputSchema),e.outputSchema!==void 0&&(t.outputSchema=e.outputSchema),Object.freeze(t)}function Ki(e,t){let n=!1,r=[];for(let i of t){let{availability:t,handler:a,...o}=i,s=a,c=t===void 0?o:{...o,availability:t()};e.register(c,async({arguments:e,origin:t,signal:n})=>{let r=await s(e===void 0?{origin:t,signal:n}:{arguments:e,origin:t,signal:n});return r===void 0?void 0:yr(r)}).then(e=>{n?e():r.push(e)},e=>{console.warn(`App command ${i.id} was not registered`,e)})}return()=>{if(!n){n=!0;for(let e of r.splice(0))e()}}}var qi=[`CANCELLED`,`CAPABILITY_DENIED`,`CAPABILITY_REVOKED`,`COMMAND_NOT_DECLARED`,`CONFLICT`,`DELIVERY_PENDING`,`DISCONNECTED`,`FILE_TOO_LARGE`,`HOST_FAILURE`,`IDENTITY`,`INSUFFICIENT_CREDIT`,`INVALID_ARGUMENT`,`MEDIA_PROVIDER_FAILURE`,`MEDIA_PROVIDER_FAILURE_UNCHARGED`,`PROTOCOL`,`SAFETY_FILTER_REFUSED`,`SELECTION_CHANGED`,`TIMEOUT`];U({name:G(`AppError`),code:On(qi),retryable:on});var Y=class extends Error{code;retryable;constructor(e,t){super(e,{cause:t.cause}),this.name=`AppError`,this.code=t.code,this.retryable=t.retryable}};C(`light.dark.latte.mocha.readout.readout-night.field-guide.field-guide-night.embed.embed-dark.phosphor.codec.paper.ember.tide.tape.sunrise.pirate-radio.pirate-radio-night.consulting.consulting-ink.consulting-night.consulting-night-ink.consulting-riso-latte.consulting-riso-latte-ink.consulting-riso-glomzy.consulting-riso-glomzy-ink.vishnu.coin.coin-night.chamfer`.split(`.`));var Ji=`data-theme`;function Yi(e){return e||(globalThis.document?.documentElement??null)}function Xi(e){let t=e.trim();if(t.length===0)throw TypeError(`Theme must be a non-empty string`);return t}function Zi(e,t){let n=Xi(e),r=Yi(t);r&&r.setAttribute(Ji,n)}function Qi(e){return Yi(e)?.getAttribute(Ji)??null}var $i=t((e=>{var t=mr(),n=Symbol.for(`react.element`),r=Symbol.for(`react.fragment`),i=Object.prototype.hasOwnProperty,a=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function s(e,t,r){var s,c={},l=null,u=null;for(s in r!==void 0&&(l=``+r),t.key!==void 0&&(l=``+t.key),t.ref!==void 0&&(u=t.ref),t)i.call(t,s)&&!o.hasOwnProperty(s)&&(c[s]=t[s]);if(e&&e.defaultProps)for(s in t=e.defaultProps,t)c[s]===void 0&&(c[s]=t[s]);return{$$typeof:n,type:e,key:l,ref:u,props:c,_owner:a.current}}e.Fragment=r,e.jsx=s,e.jsxs=s})),ea=t(((e,t)=>{t.exports=$i()})),X=ea(),ta=J.createContext(void 0),na=e=>{let t=J.useContext(ta);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},ra=({client:e,children:t})=>(J.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,X.jsx)(ta.Provider,{value:e,children:t})),ia={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},aa=new class{#e=ia;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function oa(e){setTimeout(e,0)}var sa=typeof window>`u`||`Deno`in globalThis;function ca(){}function la(e,t){return typeof e==`function`?e(t):e}function ua(e){return typeof e==`number`&&e>=0&&e!==1/0}function da(e,t){return Math.max(e+(t||0)-Date.now(),0)}function fa(e,t){return typeof e==`function`?e(t):e}function pa(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==ha(o,t.options))return!1}else if(!_a(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function ma(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(ga(t.options.mutationKey)!==ga(a))return!1}else if(!_a(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function ha(e,t){return(t?.queryKeyHashFn||ga)(e)}function ga(e){return JSON.stringify(e,(e,t)=>Sa(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function _a(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(e&&t&&typeof e==`object`&&typeof t==`object`){if(Array.isArray(e)&&Array.isArray(t)){for(let n=0;n<t.length;n++)if(!_a(e[n],t[n]))return!1;return!0}let n=Object.keys(t);for(let r of n)if(!_a(e[r],t[r]))return!1;return!0}return!1}var va=Object.prototype.hasOwnProperty;function ya(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=xa(e)&&xa(t);if(!r&&!(Sa(e)&&Sa(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:va.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=ya(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function ba(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function xa(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Sa(e){if(!Ca(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!Ca(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function Ca(e){return Object.prototype.toString.call(e)===`[object Object]`}function wa(e){return new Promise(t=>{aa.setTimeout(t,e)})}function Ta(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:ya(e,t)}function Ea(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function Da(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Oa=Symbol();function ka(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===Oa?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Aa(e,t){return typeof e==`function`?e(...t):!!e}function ja(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var Ma=()=>sa,Na=()=>Ma(),Pa=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(){}},Fa=new class extends Pa{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},Ia=oa;function La(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=Ia,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var Ra=La(),za=new class extends Pa{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let 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.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function Ba(e){return Math.min(1e3*2**e,3e4)}function Va(e){return(e??`online`)!==`online`||za.isOnline()}var Ha=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function Ua(e){let t=!1,n=0,r,i=`pending`,a,o,s=new Promise((e,t)=>{a=e,o=t});s.catch(ca);let c=()=>i!==`pending`,l=t=>{if(!c()){let n=new Ha(t);h(n),e.onCancel?.(n)}},u=()=>{t=!0},d=()=>{t=!1},f=()=>Fa.isFocused()&&(e.networkMode===`always`||za.isOnline())&&e.canRun(),p=()=>Va(e.networkMode)&&e.canRun(),m=e=>{c()||(r?.(),i=`resolved`,a(e))},h=e=>{c()||(r?.(),i=`rejected`,o(e))},g=()=>new Promise(t=>{r=e=>{(c()||f())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,c()||e.onContinue?.()}),_=()=>{if(c())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(m).catch(r=>{if(c())return;let i=e.retry??(Na()?0:3),a=e.retryDelay??Ba,o=typeof a==`function`?a(n,r):a,s=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!s){h(r);return}n++,e.onFail?.(n,r),wa(o).then(()=>f()?void 0:g()).then(()=>{t?h(r):_()})})};return{promise:s,status:()=>i,cancel:l,continue:()=>(r?.(),s),cancelRetry:u,continueRetry:d,canStart:p,start:()=>(p()?_():g().then(_),s)}}var Wa=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ua(this.gcTime)&&(this.#e=aa.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Na()?1/0:3e5))}clearGcTimeout(){this.#e!==void 0&&(aa.clearTimeout(this.#e),this.#e=void 0)}};function Ga(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{ja(e,()=>t.signal,()=>n=!0)},u=ka(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);if(r==null&&e.pages.length)return Promise.resolve(e);let a=(()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})(),o=await u(a),{maxPages:s}=t.options,c=i?Da:Ea;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?qa:Ka,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:Ka(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.fetchFn=t.options.persister?()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):l}}}function Ka(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function qa(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}function Ja(e,t){return t?Ka(e,t)!=null:!1}function Ya(e,t){return!t||!e.getPreviousPageParam?!1:qa(e,t)!=null}var Xa=class extends Wa{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e){super(),this.#s=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=$a(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#a?.promise}setOptions(e){if(this.options={...this.#o,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=$a(this.options);e.data!==void 0&&(this.setState(Qa(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=Ta(this.state.data,e,this.options);return this.#c({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#c({type:`setState`,state:e})}cancel(e){let t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(ca).catch(ca):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>fa(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Oa||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>fa(e.options.staleTime,this)===`static`)}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:!da(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){let t=this.observers.indexOf(e);t!==-1&&(this.observers.splice(t,1),this.observers.length||(this.#a&&(this.#s||this.state.fetchStatus===`paused`&&this.state.status===`pending`?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#c({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#a?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#s=!0,n.signal)})},i=()=>{let e=ka(this.options,t),n=(()=>{let e={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#s=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(e),e})();(this.#e===`infinite`?Ga(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#c({type:`fetch`,meta:a.fetchOptions?.meta});let o=this.#a=Ua({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof Ha&&e.revert&&this.setState({...this.#n,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#c({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#c({type:`pause`})},onContinue:()=>{this.#c({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await o.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#r.config.onSuccess?.(e,this),this.#r.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof Ha){if(e.silent)return this.#a.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#c({type:`error`,error:e}),this.#r.config.onError?.(e,this),this.#r.config.onSettled?.(this.state.data,e,this),e}finally{this.#a===o&&(this.#a=void 0),this.scheduleGc()}}#c(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...Za(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...Qa(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),Ra.batch(()=>{this.observers.slice().forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function Za(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Va(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function Qa(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function $a(e){let 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 eo=class extends Pa{#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p=new Set;constructor(e,t){super(),this.options=t,this.#e=e,this.#o=null,this.bindMethods(),this.setOptions(t)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),no(this.#t,this.options)?this.#m():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return ro(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return ro(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof fa(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!ba(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&io(this.#t,n,this.options,t)&&this.#m(),this.updateResult(),r&&(this.#t!==n||fa(this.options.enabled,this.#t)!==fa(t.enabled,this.#t)||fa(this.options.staleTime,this.#t)!==fa(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||fa(this.options.enabled,this.#t)!==fa(t.enabled,this.#t)||i!==this.#f)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return ba(this.getCurrentResult(),n)||(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),Reflect.get(e,n))})}trackProp(e){this.#p.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t),r=()=>{},i,a=new Promise(e=>{i=e,r=this.#e.getQueryCache().subscribe(i=>{i.type===`updated`&&i.query.queryHash===n.queryHash&&n.state.data!==void 0&&(r(),e(this.createResult(n,t)))})});return Promise.race([n.fetch().then(()=>{let e=this.createResult(n,t);return i?.(e),e}).finally(()=>{r()}),a])}fetch(e){return this.#m({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#m(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(ca)),t}#h(e){return!Na()&&fa(this.options.enabled,this.#t)!==!1&&ua(e)}#g(){this.#b();let e=fa(this.options.staleTime,this.#t);if(this.#r.isStale||!this.#h(e))return;let t=da(this.#r.dataUpdatedAt,e)+1;this.#u=aa.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#f=e,!(this.#f===0||!this.#h(this.#f))&&(this.#d=aa.setInterval(()=>{(this.options.refetchIntervalInBackground||Fa.isFocused())&&this.#m()},this.#f))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#u!==void 0&&(aa.clearTimeout(this.#u),this.#u=void 0)}#x(){this.#d!==void 0&&(aa.clearInterval(this.#d),this.#d=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&no(e,t),o=i&&io(e,n,t,r);(a||o)&&(l={...l,...Za(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#l?.state.data,this.#l):t.placeholderData,e!==void 0&&(m=`success`,d=Ta(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h){if(i&&d===a?.data&&t.select===this.#s)d=this.#c;else try{this.#s=t.select,d=t.select(d),d=Ta(i?.data,d,t),this.#c=d,this.#o=null}catch(e){this.#o=e}}else d===void 0&&(this.#o=null);this.#o&&(f=this.#o,d=this.#c,p=Date.now(),m=`error`,u=!1);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0;return{status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:ao(e,t),refetch:this.refetch,isEnabled:fa(t.enabled,e)!==!1}}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);if(this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#l=this.#t),ba(t,e))return;this.#r=t;let n=(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#p.size)return!0;let r=new Set(n??this.#p);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})();Ra.batch(()=>{n&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}};function to(e,t){return fa(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||fa(t.retryOnMount,e)!==!1)}function no(e,t){return to(e,t)||e.state.data!==void 0&&ro(e,t,t.refetchOnMount)}function ro(e,t,n){if(fa(t.enabled,e)!==!1&&fa(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&ao(e,t)}return!1}function io(e,t,n,r){return(e!==t||fa(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&ao(e,n)}function ao(e,t){return fa(t.enabled,e)!==!1&&e.isStaleByTime(fa(t.staleTime,e))}var oo=class extends eo{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,l=o&&c===`forward`,u=i&&c===`forward`,d=o&&c===`backward`,f=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Ja(t,n.data),hasPreviousPage:Ya(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}},so=class extends Wa{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||co(),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.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??(this.state.status===`pending`?this.execute(this.state.variables):Promise.resolve())}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey},r=this.#r=Ua({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)}),i=this.state.status===`pending`,a=!r.canStart();try{if(i)t();else{this.#i({type:`pending`,variables:e,isPaused:a}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:a})}let o=await r.start();return await this.#n.config.onSuccess?.(o,e,this.state.context,this,n),await this.options.onSuccess?.(o,e,this.state.context,n),await this.#n.config.onSettled?.(o,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(o,null,e,this.state.context,n),this.#i({type:`success`,data:o}),o}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#r===r&&(this.#r=void 0),this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,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{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),Ra.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function co(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var lo=class extends Pa{#e;#t;#n;constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}build(e,t,n){let r=new so({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=uo(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=uo(e);if(typeof t==`string`){let n=this.#t.get(t);if(n){if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=uo(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}return!0}runNext(e){let t=uo(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){Ra.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>ma(t,e))}findAll(e={}){return this.getAll().filter(t=>ma(e,t))}notify(e){Ra.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return Ra.batch(()=>Promise.all(e.map(e=>e.continue().catch(ca))))}};function uo(e){return e.options.scope?.id}var fo=class extends Pa{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),ba(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&ga(t.mutationKey)!==ga(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onSubscribe(){this.listeners.size===1&&this.#n&&(this.#n.addObserver(this),this.#i())}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??co();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){Ra.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}};function po(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}var mo=class extends Pa{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,Ra.batch(()=>{let e=this.#i,t=this.#p(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=e.length!==n.length,a=n.some((t,n)=>t!==e[n]),o=i||a,s=o?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!ba(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(po(e,n).forEach(e=>{e.destroy()}),po(n,e).forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})),this.#h()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#p(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){let n=new Set;return t.map((r,i)=>{let a=e[i];return r.defaultedQueryOptions.notifyOnChangeProps?a:r.observer.trackResult(a,e=>{n.has(e)||(n.add(e),t.forEach(t=>{t.observer.trackProp(e)}))})})}#d(e,t,n){if(t){let r=this.#c,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(this.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=ya(this.#a,t(e))),this.#a}return e}#f(){return!this.#r?.combine||this.#i.some((e,t)=>e.options.suspense&&this.#t[t]?.data===void 0)}#p(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new eo(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=this.#t.slice(),this.#t[n]=t,this.#h())}#h(){if(this.hasListeners()){let e=this.#f(),t=this.#a,n=e?t:this.#d(this.#u(this.#t,this.#l),this.#r?.combine);(e||t!==n)&&Ra.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},ho=class extends Pa{#e;constructor(e={}){super(),this.config=e,this.#e=new Map}build(e,t,n){let r=t.queryKey,i=t.queryHash??ha(r,t),a=this.get(i);return a||(a=new Xa({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){Ra.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>pa(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>pa(e,t)):t}notify(e){Ra.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){Ra.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){Ra.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},go=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new ho,this.#t=e.mutationCache||new lo,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=Fa.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=za.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(fa(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=la(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return Ra.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;Ra.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return Ra.batch(()=>{let r=n.findAll(e),i=new Set(r);return r.forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,predicate:e=>i.has(e)},t)})}cancelQueries(e,t={}){let n={revert:!0,...t},r=Ra.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(ca).catch(ca)}invalidateQueries(e,t={}){return Ra.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=Ra.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(ca)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(ca)}async query(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t),r=n.isStaleByTime(fa(t.staleTime,n))?await n.fetch(t):n.state.data,i=t.select;return i?i(r):r}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(fa(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(ca).catch(ca)}infiniteQuery(e){return e._type=`infinite`,this.query(e)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(ca).catch(ca)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return za.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(ga(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{_a(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(ga(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{_a(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=ha(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===Oa&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}};function _o({streamFn:e,refetchMode:t=`reset`,reducer:n=(e,t)=>Ea(e,t),initialValue:r=[]}){return async i=>{let a=i.client.getQueryCache().find({queryKey:i.queryKey,exact:!0}),o=!!a&&a.isFetched();o&&t===`reset`&&a.setState({...a.resetState,fetchStatus:`fetching`});let s=r,c=!1,l=await e(ja({client:i.client,meta:i.meta,queryKey:i.queryKey,pageParam:i.pageParam,direction:i.direction},()=>i.signal,()=>c=!0)),u=o&&t===`replace`;for await(let e of l){if(c)break;u?s=n(s,e):i.client.setQueryData(i.queryKey,t=>n(t===void 0?r:t,e))}return u&&!c&&i.client.setQueryData(i.queryKey,s),i.client.getQueryData(i.queryKey)??r}}var vo=J.createContext(!1),yo=()=>J.useContext(vo);vo.Provider;function bo(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var xo=J.createContext(bo()),So=()=>J.useContext(xo),Co=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?Aa(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||r)&&(t.isReset()||(e.retryOnMount=!1))},wo=e=>{J.useEffect(()=>{e.clearReset()},[e])},To=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||Aa(n,[e.error,r])),Eo=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},Do=(e,t)=>e?.suspense&&t.isPending,Oo=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function ko({queries:e,...t},n){let r=na(n),i=yo(),a=So(),o=t.subscribed!==!1,s=J.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:o?`optimistic`:void 0,t}),[e,r,i,o]);s.forEach(e=>{Eo(e);let t=r.getQueryCache().get(e.queryHash);Co(e,a,t)}),wo(a);let[c]=J.useState(()=>new mo(r,s,t)),[l,u,d]=c.getOptimisticResult(s,t.combine),f=!i&&o;J.useSyncExternalStore(J.useCallback(e=>f?c.subscribe(Ra.batchCalls(e)):ca,[c,f]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),J.useEffect(()=>{c.setQueries(s,t)},[s,t,c]);let p=l.some((e,t)=>Do(s[t],e))?l.flatMap((e,t)=>{let n=s[t];return n&&Do(n,e)?Oo(n,new eo(r,n),a):[]}):[];if(p.length>0)throw Promise.all(p);let m=l.find((e,t)=>{let n=s[t];return n&&To({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(m)throw m.error;return u(d())}function Ao(e,t,n){let r=yo(),i=So(),a=na(n),o=a.defaultQueryOptions(e),s=a.getQueryCache().get(o.queryHash),c=e.subscribed!==!1;o._optimisticResults=r?`isRestoring`:c?`optimistic`:void 0,Eo(o),Co(o,i,s),wo(i);let[l]=J.useState(()=>new t(a,o)),u=l.getOptimisticResult(o),d=!r&&c;if(J.useSyncExternalStore(J.useCallback(e=>{let t=d?l.subscribe(Ra.batchCalls(e)):ca;return l.updateResult(),t},[l,d]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),J.useEffect(()=>{l.setOptions(o)},[o,l]),Do(o,u))throw Oo(o,l,i);if(To({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw u.error;return o.notifyOnChangeProps?u:l.trackResult(u)}function jo(e,t){return Ao(e,eo,t)}function Mo(e){return e}function No(e){return e}function Po(e,t){let n=na(t),[r]=J.useState(()=>new fo(n,e));J.useEffect(()=>{r.setOptions(e)},[r,e]);let i=J.useSyncExternalStore(J.useCallback(e=>r.subscribe(Ra.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=J.useCallback((...e)=>{r.mutate(e[0],e[1]).catch(ca)},[r]);if(i.error&&Aa(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}var Fo=t((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=typeof setTimeout==`function`?setTimeout:null,_=typeof clearTimeout==`function`?clearTimeout:null,v=typeof setImmediate<`u`?setImmediate:null;typeof navigator<`u`&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function y(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function b(e){if(h=!1,y(e),!m){if(n(c)!==null)m=!0,M(x);else{var t=n(l);t!==null&&N(b,t.startTime-e)}}}function x(t,i){m=!1,h&&(h=!1,_(w),w=-1),p=!0;var a=f;try{for(y(i),d=n(c);d!==null&&(!(d.expirationTime>i)||t&&!D());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=i);i=e.unstable_now(),typeof s==`function`?d.callback=s:d===n(c)&&r(c),y(i)}else r(c);d=n(c)}if(d!==null)var u=!0;else{var g=n(l);g!==null&&N(b,g.startTime-i),u=!1}return u}finally{d=null,f=a,p=!1}}var S=!1,C=null,w=-1,T=5,E=-1;function D(){return!(e.unstable_now()-E<T)}function O(){if(C!==null){var t=e.unstable_now();E=t;var n=!0;try{n=C(!0,t)}finally{n?k():(S=!1,C=null)}}else S=!1}var k;if(typeof v==`function`)k=function(){v(O)};else if(typeof MessageChannel<`u`){var A=new MessageChannel,j=A.port2;A.port1.onmessage=O,k=function(){j.postMessage(null)}}else k=function(){g(O,0)};function M(e){C=e,S||(S=!0,k())}function N(t,n){w=g(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_continueExecution=function(){m||p||(m=!0,M(x))},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):T=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(_(w),w=-1):h=!0,N(b,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,M(x))),r},e.unstable_shouldYield=D,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),Io=t(((e,t)=>{t.exports=Fo()})),Lo=t((e=>{var t=mr(),n=Io();function r(e){for(var t=`https://reactjs.org/docs/error-decoder.html?invariant=`+e,n=1;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n]);return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}var i=new Set,a={};function o(e,t){s(e,t),s(e+`Capture`,t)}function s(e,t){for(a[e]=t,e=0;e<t.length;e++)i.add(t[e])}var c=!(typeof window>`u`||window.document===void 0||window.document.createElement===void 0),l=Object.prototype.hasOwnProperty,u=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,d={},f={};function p(e){return l.call(f,e)?!0:l.call(d,e)?!1:u.test(e)?f[e]=!0:(d[e]=!0,!1)}function m(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case`function`:case`symbol`:return!0;case`boolean`:return r?!1:n===null?(e=e.toLowerCase().slice(0,5),e!==`data-`&&e!==`aria-`):!n.acceptsBooleans;default:return!1}}function h(e,t,n,r){if(t==null||m(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return!1===t;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function g(e,t,n,r,i,a,o){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=a,this.removeEmptyString=o}var _={};`children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style`.split(` `).forEach(function(e){_[e]=new g(e,0,!1,e,null,!1,!1)}),[[`acceptCharset`,`accept-charset`],[`className`,`class`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`]].forEach(function(e){var t=e[0];_[t]=new g(t,1,!1,e[1],null,!1,!1)}),[`contentEditable`,`draggable`,`spellCheck`,`value`].forEach(function(e){_[e]=new g(e,2,!1,e.toLowerCase(),null,!1,!1)}),[`autoReverse`,`externalResourcesRequired`,`focusable`,`preserveAlpha`].forEach(function(e){_[e]=new g(e,2,!1,e,null,!1,!1)}),`allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope`.split(` `).forEach(function(e){_[e]=new g(e,3,!1,e.toLowerCase(),null,!1,!1)}),[`checked`,`multiple`,`muted`,`selected`].forEach(function(e){_[e]=new g(e,3,!0,e,null,!1,!1)}),[`capture`,`download`].forEach(function(e){_[e]=new g(e,4,!1,e,null,!1,!1)}),[`cols`,`rows`,`size`,`span`].forEach(function(e){_[e]=new g(e,6,!1,e,null,!1,!1)}),[`rowSpan`,`start`].forEach(function(e){_[e]=new g(e,5,!1,e.toLowerCase(),null,!1,!1)});var v=/[\-:]([a-z])/g;function y(e){return e[1].toUpperCase()}`accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height`.split(` `).forEach(function(e){var t=e.replace(v,y);_[t]=new g(t,1,!1,e,null,!1,!1)}),`xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type`.split(` `).forEach(function(e){var t=e.replace(v,y);_[t]=new g(t,1,!1,e,`http://www.w3.org/1999/xlink`,!1,!1)}),[`xml:base`,`xml:lang`,`xml:space`].forEach(function(e){var t=e.replace(v,y);_[t]=new g(t,1,!1,e,`http://www.w3.org/XML/1998/namespace`,!1,!1)}),[`tabIndex`,`crossOrigin`].forEach(function(e){_[e]=new g(e,1,!1,e.toLowerCase(),null,!1,!1)}),_.xlinkHref=new g(`xlinkHref`,1,!1,`xlink:href`,`http://www.w3.org/1999/xlink`,!0,!1),[`src`,`href`,`action`,`formAction`].forEach(function(e){_[e]=new g(e,1,!1,e.toLowerCase(),null,!0,!0)});function b(e,t,n,r){var i=_.hasOwnProperty(t)?_[t]:null;(i===null?r||!(2<t.length)||t[0]!==`o`&&t[0]!==`O`||t[1]!==`n`&&t[1]!==`N`:i.type!==0)&&(h(t,n,i,r)&&(n=null),r||i===null?p(t)&&(n===null?e.removeAttribute(t):e.setAttribute(t,``+n)):i.mustUseProperty?e[i.propertyName]=n===null?i.type!==3&&``:n:(t=i.attributeName,r=i.attributeNamespace,n===null?e.removeAttribute(t):(i=i.type,n=i===3||i===4&&!0===n?``:``+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}var x=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,S=Symbol.for(`react.element`),C=Symbol.for(`react.portal`),w=Symbol.for(`react.fragment`),T=Symbol.for(`react.strict_mode`),E=Symbol.for(`react.profiler`),D=Symbol.for(`react.provider`),O=Symbol.for(`react.context`),k=Symbol.for(`react.forward_ref`),A=Symbol.for(`react.suspense`),j=Symbol.for(`react.suspense_list`),M=Symbol.for(`react.memo`),N=Symbol.for(`react.lazy`),P=Symbol.for(`react.offscreen`),F=Symbol.iterator;function I(e){return typeof e!=`object`||!e?null:(e=F&&e[F]||e[`@@iterator`],typeof e==`function`?e:null)}var L=Object.assign,ee;function te(e){if(ee===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);ee=t&&t[1]||``}return`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/runtime-core-DKpk6tKT.js","assets/rolldown-runtime-hePW80VL.js","assets/Effect-CtszBD7f.js","assets/extension-hook-CmoMuW6C.js","assets/preload-helper-DY31Aviq.js","assets/extensions-CrmxvtfG.js","assets/mushroom-ur0TNKww.js","assets/document-Bagsf-XI.js","assets/renderer-BKCye2Ev.js","assets/cat-CRMM8U8H.js","assets/base-face-DzmOsdaJ.js","assets/burger-DGewjCsv.js","assets/parakeet-conversation-DYlN7oL9.js","assets/parakeet-conversation-COndlivb.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e,t}from"./rolldown-runtime-hePW80VL.js";import{$a as n,$i as r,Aa as i,Ba as a,Bi as o,Ca as s,Ci as c,Ct as l,Da as u,E as d,Ea as f,Fa as p,Fi as m,Ga as h,Gi as g,Gn as _,Ha as v,Hi as y,I as b,Ia as x,Ii as S,Ji as C,Ka as w,Ki as T,La as E,Li as D,Ma as O,Na as k,Oa as A,Oi as j,Pa as M,Qa as N,Ra as P,Ri as F,Sa as I,St as L,Ta as ee,Ua as te,Ui as ne,V as re,Va as R,Vi as ie,Wa as ae,Wi as z,X as oe,Xa as se,Xi as ce,Y as le,Ya as ue,Yi as de,Yn as fe,Zi as pe,_a as me,a as he,aa as ge,at as _e,bt as ve,ca as ye,d as be,da as xe,ea as Se,er as Ce,et as we,ft as Te,g as Ee,ga as De,ha as Oe,ht as ke,ia as Ae,ir as je,j as Me,ja as Ne,ka as Pe,l as Fe,la as Ie,lr as Le,m as Re,ma as B,mt as ze,nr as Be,oa as Ve,or as He,pa as Ue,pi as We,pt as Ge,qa as Ke,qi as qe,ra as Je,rt as Ye,s as Xe,sr as Ze,t as Qe,ta as $e,tr as et,ua as tt,va as V,vi as nt,wa as rt,xa as it,xt as at,y as ot,yt as st,za as ct,zi as lt}from"./Effect-CtszBD7f.js";import{$r as ut,Aa as dt,Ai as ft,Ba as pt,Bi as mt,Br as ht,Ca as gt,Ci as _t,Co as vt,Cr as yt,Dn as bt,Dr as xt,Ea as St,Ei as Ct,Fa as wt,Fr as Tt,Ga as Et,Gn as Dt,Gr as Ot,Ha as kt,Hi as At,Hr as jt,Ia as Mt,Ja as Nt,Jr as Pt,Ka as Ft,Kr as It,La as Lt,Li as Rt,Ma as zt,Mi as Bt,Na as Vt,Ni as Ht,Pa as Ut,Pr as Wt,Si as Gt,Ta as Kt,Ti as qt,Ua as Jt,Ur as Yt,Va as Xt,Vi as Zt,Wa as Qt,Wr as $t,Xa as en,Xi as tn,Ya as nn,Yr as rn,Zi as an,Zr as on,_i as sn,_r as cn,ao as ln,ba as un,bi as dn,bo as fn,ca as pn,co as mn,d as hn,di as gn,ea as _n,ei as vn,eo as yn,f as bn,fa as H,fi as xn,fo as Sn,ga as Cn,gi as wn,go as Tn,i as En,ia as Dn,ii as On,ji as kn,ki as An,kr as jn,l as Mn,li as Nn,lo as Pn,m as Fn,mi as U,n as In,ni as Ln,no as Rn,oi as zn,p as Bn,pi as W,po as Vn,qa as Hn,ri as G,ro as Un,so as Wn,ti as Gn,u as Kn,ui as qn,uo as Jn,vi as Yn,wa as K,wi as q,wr as Xn,xi as Zn,xo as Qn,yi as $n,za as er,zi as tr,zr as nr}from"./extension-hook-CmoMuW6C.js";import{a as rr,o as ir,s as ar,t as or}from"./document-Bagsf-XI.js";import{t as sr}from"./preload-helper-DY31Aviq.js";import{a as cr,i as lr,n as ur,r as dr,t as fr}from"./base-face-DzmOsdaJ.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var pr=t((e=>{var t=Symbol.for(`react.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.provider`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.iterator;function p(e){return typeof e!=`object`||!e?null:(e=f&&e[f]||e[`@@iterator`],typeof e==`function`?e:null)}var m={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},h=Object.assign,g={};function _(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||m}_.prototype.isReactComponent={},_.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`setState(...): takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},_.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function v(){}v.prototype=_.prototype;function y(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||m}var b=y.prototype=new v;b.constructor=y,h(b,_.prototype),b.isPureReactComponent=!0;var x=Array.isArray,S=Object.prototype.hasOwnProperty,C={current:null},w={key:!0,ref:!0,__self:!0,__source:!0};function T(e,n,r){var i,a={},o=null,s=null;if(n!=null)for(i in n.ref!==void 0&&(s=n.ref),n.key!==void 0&&(o=``+n.key),n)S.call(n,i)&&!w.hasOwnProperty(i)&&(a[i]=n[i]);var c=arguments.length-2;if(c===1)a.children=r;else if(1<c){for(var l=Array(c),u=0;u<c;u++)l[u]=arguments[u+2];a.children=l}if(e&&e.defaultProps)for(i in c=e.defaultProps,c)a[i]===void 0&&(a[i]=c[i]);return{$$typeof:t,type:e,key:o,ref:s,props:a,_owner:C.current}}function E(e,n){return{$$typeof:t,type:e.type,key:n,ref:e.ref,props:e.props,_owner:e._owner}}function D(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function O(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var k=/\/+/g;function A(e,t){return typeof e==`object`&&e&&e.key!=null?O(``+e.key):t.toString(36)}function j(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0}}if(c)return c=e,o=o(c),e=a===``?`.`+A(c,0):a,x(o)?(i=``,e!=null&&(i=e.replace(k,`$&/`)+`/`),j(o,r,i,``,function(e){return e})):o!=null&&(D(o)&&(o=E(o,i+(!o.key||c&&c.key===o.key?``:(``+o.key).replace(k,`$&/`)+`/`)+e)),r.push(o)),1;if(c=0,a=a===``?`.`:a+`:`,x(e))for(var l=0;l<e.length;l++){s=e[l];var u=a+A(s,l);c+=j(s,r,i,u,o)}else if(u=p(e),typeof u==`function`)for(e=u.call(e),l=0;!(s=e.next()).done;)s=s.value,u=a+A(s,l++),c+=j(s,r,i,u,o);else if(s===`object`)throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`);return c}function M(e,t,n){if(e==null)return e;var r=[],i=0;return j(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function N(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var P={current:null},F={transition:null},I={ReactCurrentDispatcher:P,ReactCurrentBatchConfig:F,ReactCurrentOwner:C};function L(){throw Error(`act(...) is not supported in production builds of React.`)}e.Children={map:M,forEach:function(e,t,n){M(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return M(e,function(){t++}),t},toArray:function(e){return M(e,function(e){return e})||[]},only:function(e){if(!D(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}},e.Component=_,e.Fragment=r,e.Profiler=a,e.PureComponent=y,e.StrictMode=i,e.Suspense=l,e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=I,e.act=L,e.cloneElement=function(e,n,r){if(e==null)throw Error(`React.cloneElement(...): The argument must be a React element, but you passed `+e+`.`);var i=h({},e.props),a=e.key,o=e.ref,s=e._owner;if(n!=null){if(n.ref!==void 0&&(o=n.ref,s=C.current),n.key!==void 0&&(a=``+n.key),e.type&&e.type.defaultProps)var c=e.type.defaultProps;for(l in n)S.call(n,l)&&!w.hasOwnProperty(l)&&(i[l]=n[l]===void 0&&c!==void 0?c[l]:n[l])}var l=arguments.length-2;if(l===1)i.children=r;else if(1<l){c=Array(l);for(var u=0;u<l;u++)c[u]=arguments[u+2];i.children=c}return{$$typeof:t,type:e.type,key:a,ref:o,props:i,_owner:s}},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:o,_context:e},e.Consumer=e},e.createElement=T,e.createFactory=function(e){var t=T.bind(null,e);return t.type=e,t},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=D,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:N}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=F.transition;F.transition={};try{e()}finally{F.transition=t}},e.unstable_act=L,e.useCallback=function(e,t){return P.current.useCallback(e,t)},e.useContext=function(e){return P.current.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e){return P.current.useDeferredValue(e)},e.useEffect=function(e,t){return P.current.useEffect(e,t)},e.useId=function(){return P.current.useId()},e.useImperativeHandle=function(e,t,n){return P.current.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return P.current.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return P.current.useLayoutEffect(e,t)},e.useMemo=function(e,t){return P.current.useMemo(e,t)},e.useReducer=function(e,t,n){return P.current.useReducer(e,t,n)},e.useRef=function(e){return P.current.useRef(e)},e.useState=function(e){return P.current.useState(e)},e.useSyncExternalStore=function(e,t,n){return P.current.useSyncExternalStore(e,t,n)},e.useTransition=function(){return P.current.useTransition()},e.version=`18.3.1`})),mr=t(((e,t)=>{t.exports=pr()})),J=e(mr(),1),hr=ye(),gr=Ie(()=>ge(`status`,[B({status:tt(`available`)}).strict(),B({status:tt(`unavailable`),reason:V()}).strict()])),_r=hr,vr=Ie(()=>De(V(),_r)),yr=e=>_r.parse(e),br=e=>vr.parse(e),xr=Ie(()=>B({code:V().min(1).max(160),message:V().min(1).max(512),details:_r.optional()}).strict()),Sr=e=>xr.parse(e),Cr=vr,wr=Ie(()=>V().refine(e=>e.trim().length>0)),Tr=gr,Er=Ie(()=>it([B({type:tt(`action`)}).strict(),B({type:tt(`custom`),data:vr}).strict(),B({type:tt(`choice`),options:Se(B({value:_r,label:wr,description:wr.optional()}))}).strict(),B({type:tt(`form`),submitLabel:wr.optional()}).strict(),B({type:tt(`confirmation`),message:wr,confirmLabel:wr.optional(),cancelLabel:wr.optional()}).strict()])),Dr=Ie(()=>B({inputSchema:Cr.optional(),outputSchema:Cr.optional(),presentation:Er.optional()}).strict()),Or=Ie(()=>Ue().int().refine(e=>Number.isSafeInteger(e))),kr=Ie(()=>B({hint:wr.pipe(V().max(120)),words:Se(B({word:V().regex(/^\S{1,64}$/u),description:wr.pipe(V().max(512)).optional(),arguments:vr}).strict()).max(32).optional(),text:B({field:wr.pipe(V().max(120)),arguments:vr,requestIdField:wr.pipe(V().max(120)).optional()}).strict().optional()}).strict().refine(e=>e.words!==void 0||e.text!==void 0,`slash arguments need words or text`)),Ar=Ie(()=>B({order:Or.optional()}).strict()),jr=Ie(()=>B({bindings:B({order:Or.optional(),values:Se(wr).max(16)}).strict().optional(),agent:B({keybind:wr.optional(),order:Or.optional()}).strict().optional(),help:Ar.optional(),menu:Ar.optional(),palette:Ar.optional(),slash:B({aliases:Se(wr).max(16),consumesDraft:Je().optional(),order:Or.optional(),arguments:kr.optional()}).strict().optional()}).strict()),Mr=Ie(()=>B({id:wr.refine(e=>!e.includes(`:`)),title:wr,category:wr,description:wr.optional(),projections:jr.optional(),action:Dr.optional(),availability:Tr.optional()}).strict()),Nr=e=>Mr.parse(e),Pr=Ie(()=>B({inputSchema:Cr.optional(),outputSchema:Cr.optional()}).strict()),Fr=V().min(1).brand(),Ir=Ie(()=>B({commandId:Fr,command:B({namespace:V(),id:V()}).strict(),sourceId:V(),scope:V().optional(),title:V(),category:V(),description:V().optional(),order:Ue(),availability:gr,action:Pr.optional(),keybind:V().optional()}).strict());Se(Ir);var Lr=8192,Rr=wr.pipe(V().max(Lr)),zr=wr.pipe(V().max(60)),Br=s({protocol:/^https?$/u}),Vr=B({label:Rr,value:Rr}).strict(),Hr={summary:Rr.optional(),facts:Se(Vr).max(4).optional(),body:Rr.optional(),bodyLabel:Rr.optional(),details:Se(Vr).max(24).optional()},Ur=ge(`type`,[B({type:tt(`choice`),message:zr,...Hr,current:Rr.optional(),collapsedGroup:Rr.optional(),options:Se(B({value:Rr,label:Rr,description:Rr.optional(),group:Rr.optional(),destructive:tt(!0).optional()}).strict()).min(1).max(256)}).strict(),B({type:tt(`text`),message:zr,...Hr,placeholder:Rr.optional(),secret:Je().optional()}).strict(),B({type:tt(`confirmation`),message:zr,...Hr,confirmLabel:Rr.optional(),cancelLabel:Rr.optional(),destructive:tt(!0).optional()}).strict(),B({type:tt(`decision`),message:zr,...Hr,options:Se(B({value:Rr,label:Rr,description:Rr.optional(),destructive:tt(!0).optional()}).strict()).min(1).max(8).refine(e=>new Set(e.map(e=>e.value)).size===e.length,`Decision option values must be unique`),multiple:Je().optional(),other:B({label:Rr,placeholder:Rr.optional(),maxLength:Ue().int().min(1).max(Lr),blank:Rr.optional()}).strict().optional(),escape:Rr.optional()}).strict().refine(e=>[e.escape,e.other?.blank].every(t=>t===void 0||e.options.some(e=>e.value===t)),`A decision's escape and blank answers must be offered options`)]),Wr=Ie(()=>ge(`type`,[B({type:tt(`info`),message:Rr,links:Se(B({url:Br,label:Rr.optional()}).strict()).max(16).optional()}).strict(),B({type:tt(`progress`),message:Rr}).strict(),B({type:tt(`handoff`),url:Br,code:Rr.optional(),message:Rr.optional()}).strict(),B({type:tt(`success`),message:Rr}).strict()])),Gr=e=>Ur.parse(e),Kr=e=>Wr.parse(e),qr={decision:e=>{let t=Ur.options[3].parse(e),n=new Set(t.options.map(e=>e.value));return B({selected:Se(V()).max(t.options.length),text:Ve(wr.pipe(V().max(t.other?.maxLength??1)))}).strict().superRefine((e,r)=>{let i=e=>{r.addIssue({code:`custom`,message:e})};(e.selected.some(e=>!n.has(e))||new Set(e.selected).size!==e.selected.length)&&i(`Pick each offered option at most once`),t.multiple!==!0&&e.selected.length>1&&i(`Pick one option`),e.selected.length===0&&e.text===void 0&&i(`Pick an option or write an answer`),t.other===void 0&&e.text!==void 0&&i(`This decision takes no written answer`),t.multiple!==!0&&e.selected.length>0&&e.text!==void 0&&i(`Pick an option or write an answer, not both`)})},confirmation:e=>(Ur.options[2].parse(e),Je()),text:e=>(Ur.options[1].parse(e),V().max(Lr)),choice:e=>{let t=Ur.options[0].parse(e);return V().refine(e=>t.options.some(t=>t.value===e))}};function Jr(e){let t=qr[e.type](e);return e=>{let n=t.safeParse(e);return n.success?{kind:`accepted`,value:n.data}:{kind:`invalid`,cause:n.error}}}var Yr=class extends Error{code;details;constructor(e,t,n){super(t),this.code=e,this.details=n,this.name=`WhistleActionError`}},Xr=class extends Error{constructor(){super(`Whistle runtime is closed`),this.name=`WhistleClosedError`}};function Zr(){let e=!1,t=Ai,n=[],r=[],i=!1,a=[],o=new Set,s=()=>{for(let e of o)e()};return Object.freeze({close:()=>{e||(e=!0,n=[],a=[],r=[],t=Ai,s(),o.clear())},contribute:t=>{if(oi(t),e)throw new Xr;si(t,n),ci(t,n);let r=Symbol(`whistle-contribution`);ai(t)||(n=[...n,{contribution:li(t),generation:r}],i=!0,s());let a=!0;return Oi(o=>{if(!a||e)return;let c={...t,commands:o};oi(c);let l=n.findIndex(e=>e.generation===r),u=n.filter(e=>e.generation!==r);si(c,u),ci(c,u);let d=li(c);if(ai(c)){if(l<0)return;n=u}else n=l<0?[...n,{contribution:d,generation:r}]:n.map(e=>e.generation===r?{contribution:d,generation:r}:e);i=!0,s()},()=>{a&&(a=!1,n.find(e=>e.generation===r)!==void 0&&(n=n.filter(e=>e.generation!==r),i=!0,s()))})},execute:async(t,r)=>{if(t.namespace.trim().length===0||t.id.trim().length===0)return{status:`invalid`};if(e)return{status:`closed`};let i=ii(t,n);if(i===void 0)return{status:`missing`};let o;try{let e=Mi(i);if(e.status===`unavailable`)return e;let n=a.at(-1)?.presenter;r.interaction===void 0&&n!==void 0&&Qr.has(r.origin)&&(o=n({commandId:ri(t.namespace,t.id),title:i.title}));let s={...r,signal:r.signal??new AbortController().signal};o!==void 0&&(s.interaction=o.interaction,s.signal=AbortSignal.any([s.signal,o.interaction.signal]));let c=await i.handler(s);return o?.settle({status:`handled`}),c===void 0?{status:`handled`}:{status:`handled`,result:c}}catch(e){let t=Pi(e instanceof Error?e:Error(`Command handler threw a non-Error value`));return o?.settle(o.interaction.signal.aborted?{status:`cancelled`}:{status:`failed`,message:t.message}),{status:`failed`,error:t}}},present:t=>{let n={presenter:t};return e||(a=[...a,n]),()=>{a=a.filter(e=>e!==n)}},snapshot:()=>{if(e)return Ai;let a=n.flatMap(e=>e.contribution.commands.map(Mi));return(i||a.some((e,t)=>!Ni(e,r[t])))&&(t=Fi(n,a),r=a,i=!1),t},subscribe:t=>e?()=>void 0:(o.add(t),()=>{o.delete(t)})})}var Qr=new Set([`browser`,`keyboard`,`menu`,`palette`,`slash`,`terminal`]),$r=16,ei=32,ti=64,ni=256;function ri(e,t){return Fr.parse(`${e}:${t}`)}function ii(e,t){for(let n of t)if(n.contribution.namespace===e.namespace){for(let t of n.contribution.commands)if(t.id===e.id)return t}}function ai(e){return e.commands.length===0}function oi(e){Ei(e.sourceId,`source ID`),Ei(e.namespace,`namespace`),e.scope!==void 0&&Ei(e.scope,`scope`);for(let t of e.commands)xi(t)}function si(e,t){t.find(t=>t.contribution.namespace===e.namespace&&t.contribution.sourceId!==e.sourceId)!==void 0&&ki(`Namespace is already owned by another source`);let n=new Set,r=new Set;for(let i of t){let t=i.contribution.scope===e.scope;for(let e of i.contribution.commands)if(n.add(ri(i.contribution.namespace,e.id)),t)for(let t of e.projections?.slash?.aliases??[])r.add(t)}for(let t of e.commands){let i=ri(e.namespace,t.id);n.has(i)&&ki(`Canonical command ID is already registered`),n.add(i);for(let e of t.projections?.slash?.aliases??[])r.has(e)&&ki(`Slash alias is already registered`),r.add(e)}}function ci(e,t){t.length>=ti&&ki(`Live contribution capacity exceeded`),t.reduce((e,t)=>e+t.contribution.commands.length,0)+e.commands.length>ni&&ki(`Live command capacity exceeded`)}function li(e){let t={sourceId:e.sourceId,namespace:e.namespace,commands:e.commands.map(ui)};return e.scope===void 0?t:{...t,scope:e.scope}}function ui(e){let t={id:e.id,title:e.title,category:e.category,handler:e.handler};return e.description!==void 0&&(t.description=e.description),e.action!==void 0&&(t.action=di(e.action)),e.availability!==void 0&&(t.availability=e.availability),e.projections!==void 0&&(t.projections=hi(e.projections)),t}function di(e){let t={};return e.inputSchema!==void 0&&(t.inputSchema=fi(e.inputSchema)),e.outputSchema!==void 0&&(t.outputSchema=fi(e.outputSchema)),e.presentation!==void 0&&(t.presentation=mi(e.presentation)),Object.freeze(t)}function fi(e){return Object.freeze(Object.fromEntries(Object.entries(e).map(([e,t])=>[e,pi(t)])))}function pi(e){return Array.isArray(e)?Object.freeze(e.map(pi)):e!==null&&e instanceof Object?Object.freeze(Object.fromEntries(Object.entries(e).map(([e,t])=>[e,pi(t)]))):e}function mi(e){switch(e.type){case`action`:return Object.freeze({type:`action`});case`custom`:return Object.freeze({type:`custom`,data:fi(e.data)});case`choice`:return Object.freeze({type:`choice`,options:Object.freeze(e.options.map(e=>Object.freeze({...e,value:pi(e.value)})))});case`form`:return Object.freeze({...e});case`confirmation`:return Object.freeze({...e})}}function hi(e){let t={};return e.bindings!==void 0&&(t.bindings=gi(e.bindings)),e.agent!==void 0&&(t.agent=_i(e.agent)),e.help!==void 0&&(t.help=vi(e.help.order)),e.menu!==void 0&&(t.menu=vi(e.menu.order)),e.palette!==void 0&&(t.palette=vi(e.palette.order)),e.slash!==void 0&&(t.slash=yi(e.slash)),t}function gi(e){let t={values:[...e.values]};return e.order!==void 0&&(t.order=e.order),t}function _i(e){let t={};return e.keybind!==void 0&&(t.keybind=e.keybind),e.order!==void 0&&(t.order=e.order),t}function vi(e){let t={};return e!==void 0&&(t.order=e),t}function yi(e){let t={aliases:[...e.aliases]};return e.order!==void 0&&(t.order=e.order),e.consumesDraft!==void 0&&(t.consumesDraft=e.consumesDraft),e.arguments!==void 0&&(t.arguments=bi(e.arguments)),t}function bi(e){let t={hint:e.hint};return e.words!==void 0&&(t.words=Object.freeze(e.words.map(e=>Object.freeze({...e,arguments:fi(e.arguments)})))),e.text!==void 0&&(t.text=Object.freeze({...e.text,arguments:fi(e.text.arguments)})),Object.freeze(t)}function xi(e){Ei(e.id,`command ID`,!0),Ei(e.title,`title`),Ei(e.category,`category`),Si(e.action),Ci(e.projections)}function Si(e){if(e?.presentation!==void 0)switch(e.presentation.type){case`action`:case`custom`:return;case`choice`:for(let t of e.presentation.options)Ei(t.label,`choice label`),t.description!==void 0&&Ei(t.description,`choice description`);return;case`form`:e.presentation.submitLabel!==void 0&&Ei(e.presentation.submitLabel,`submit label`);return;case`confirmation`:Ei(e.presentation.message,`confirmation message`),e.presentation.confirmLabel!==void 0&&Ei(e.presentation.confirmLabel,`confirmation label`),e.presentation.cancelLabel!==void 0&&Ei(e.presentation.cancelLabel,`cancellation label`)}}function Ci(e){if(e!==void 0){for(let t of[e.bindings,e.palette,e.slash,e.help,e.menu,e.agent])t!==void 0&&Di(t.order);if(e.bindings!==void 0&&Ti(e.bindings.values,`binding`),e.slash!==void 0){Ti(e.slash.aliases,`slash alias`);for(let t of e.slash.aliases)/\s/u.test(t)&&ki(`slash alias must not contain whitespace`);wi(e.slash.arguments)}e.agent?.keybind!==void 0&&Ei(e.agent.keybind,`agent keybind`)}}function wi(e){if(e===void 0)return;Ei(e.hint,`argument hint`),e.words===void 0&&e.text===void 0&&ki(`slash arguments need words or text`);let t=new Set;for(let n of e.words??[])Ei(n.word,`argument word`),/\s/u.test(n.word)&&ki(`argument word must not contain whitespace`),t.has(n.word)&&ki(`argument word is repeated`),t.add(n.word),n.description!==void 0&&Ei(n.description,`argument word description`);t.size>ei&&ki(`argument word count exceeds 32`),e.text!==void 0&&(Ei(e.text.field,`argument text field`),e.text.requestIdField!==void 0&&Ei(e.text.requestIdField,`request id field`))}function Ti(e,t){e.length>$r&&ki(`${t} count exceeds 16`);for(let n of e)Ei(n,t)}function Ei(e,t,n=!1){e.trim().length===0&&ki(`${t} must not be blank`),n&&e.includes(`:`)&&ki(`${t} must not contain a colon`)}function Di(e){e!==void 0&&!Number.isSafeInteger(e)&&ki(`order must be a safe integer`)}function Oi(e=()=>void 0,t=()=>void 0){return Object.freeze({update:e,dispose:t})}function ki(e){throw Error(e)}var Ai=Object.freeze({bindings:Object.freeze([]),palette:Object.freeze([]),slash:Object.freeze([]),help:Object.freeze([]),menu:Object.freeze([]),agent:Object.freeze([])}),ji=Object.freeze({status:`available`});function Mi(e){let t=e.availability?.()??ji;return t.status===`available`?ji:Object.freeze({status:`unavailable`,reason:t.reason})}function Ni(e,t){return e.status===`available`?t?.status===`available`:t?.status===`unavailable`&&e.reason===t.reason}function Pi(e){if(e instanceof Yr){let t={code:e.code,message:e.message};return Object.freeze(e.details===void 0?t:{...t,details:pi(e.details)})}return Object.freeze({code:`command_failed`,message:e.message})}function Fi(e,t){let n=[],r=[],i=[],a=[],o=[],s=[],c=0;for(let l of e){let e=l.contribution;for(let l of e.commands){let u=l.projections,d=t[c++]??ji;if(u?.bindings!==void 0)for(let t of u.bindings.values)n.push({...Hi(e,l,u.bindings.order,d),binding:t});if(u?.palette!==void 0&&r.push({...Hi(e,l,u.palette.order,d)}),u?.slash!==void 0)for(let t of u.slash.aliases){let n={...Hi(e,l,u.slash.order,d),alias:t};u.slash.consumesDraft!==void 0&&(n={...n,consumesDraft:u.slash.consumesDraft}),u.slash.arguments!==void 0&&(n={...n,arguments:u.slash.arguments}),i.push(n)}u?.help!==void 0&&a.push({...Hi(e,l,u.help.order,d)}),u?.menu!==void 0&&o.push({...Hi(e,l,u.menu.order,d)}),u?.agent!==void 0&&s.push(Wi(e,l,u.agent,d))}}return zi(n),Bi(i),Ri(r),Ri(a),Ri(o),Ri(s),Object.freeze({bindings:Vi(n),palette:Vi(r),slash:Vi(i),help:Vi(a),menu:Vi(o),agent:Vi(s)})}var Ii=new TextEncoder;function Li(e,t){let n=Ii.encode(e),r=Ii.encode(t),i=Math.min(n.length,r.length);for(let e=0;e<i;e+=1){let t=n[e]??0,i=r[e]??0;if(t!==i)return t<i?-1:1}return n.length<r.length?-1:+(n.length>r.length)}function Ri(e){e.sort((e,t)=>e.order-t.order||Li(e.commandId,t.commandId))}function zi(e){e.sort((e,t)=>e.order-t.order||Li(e.commandId,t.commandId)||Li(e.binding,t.binding))}function Bi(e){e.sort((e,t)=>e.order-t.order||Li(e.commandId,t.commandId)||Li(e.alias,t.alias))}function Vi(e){return Object.freeze(e.map(e=>Object.freeze(e)))}function Hi(e,t,n,r){let i=Ui(e,t,n,r);return e.scope===void 0?i:{...i,scope:e.scope}}function Ui(e,t,n,r){let i={commandId:ri(e.namespace,t.id),command:Object.freeze({namespace:e.namespace,id:t.id}),sourceId:e.sourceId,title:t.title,category:t.category,order:n??0,availability:r},a=t.description===void 0?i:{...i,description:t.description};return t.action===void 0?a:{...a,action:t.action}}function Wi(e,t,n,r){let i=Hi(e,t,n.order,r),a=i.action===void 0?i:{...i,action:Gi(i.action)};return n.keybind===void 0?a:{...a,keybind:n.keybind}}function Gi(e){let t={};return e.inputSchema!==void 0&&(t.inputSchema=e.inputSchema),e.outputSchema!==void 0&&(t.outputSchema=e.outputSchema),Object.freeze(t)}function Ki(e,t){let n=!1,r=[];for(let i of t){let{availability:t,handler:a,...o}=i,s=a,c=t===void 0?o:{...o,availability:t()};e.register(c,async({arguments:e,origin:t,signal:n})=>{let r=await s(e===void 0?{origin:t,signal:n}:{arguments:e,origin:t,signal:n});return r===void 0?void 0:yr(r)}).then(e=>{n?e():r.push(e)},e=>{console.warn(`App command ${i.id} was not registered`,e)})}return()=>{if(!n){n=!0;for(let e of r.splice(0))e()}}}var qi=[`CANCELLED`,`CAPABILITY_DENIED`,`CAPABILITY_REVOKED`,`COMMAND_NOT_DECLARED`,`CONFLICT`,`DELIVERY_PENDING`,`DISCONNECTED`,`FILE_TOO_LARGE`,`HOST_FAILURE`,`IDENTITY`,`INSUFFICIENT_CREDIT`,`INVALID_ARGUMENT`,`MEDIA_PROVIDER_FAILURE`,`MEDIA_PROVIDER_FAILURE_UNCHARGED`,`PROTOCOL`,`SAFETY_FILTER_REFUSED`,`SELECTION_CHANGED`,`TIMEOUT`];U({name:G(`AppError`),code:On(qi),retryable:on});var Y=class extends Error{code;retryable;constructor(e,t){super(e,{cause:t.cause}),this.name=`AppError`,this.code=t.code,this.retryable=t.retryable}};C(`light.dark.latte.mocha.readout.readout-night.field-guide.field-guide-night.embed.embed-dark.phosphor.codec.paper.ember.tide.tape.sunrise.pirate-radio.pirate-radio-night.consulting.consulting-ink.consulting-night.consulting-night-ink.consulting-riso-latte.consulting-riso-latte-ink.consulting-riso-glomzy.consulting-riso-glomzy-ink.vishnu.coin.coin-night.chamfer`.split(`.`));var Ji=`data-theme`;function Yi(e){return e||(globalThis.document?.documentElement??null)}function Xi(e){let t=e.trim();if(t.length===0)throw TypeError(`Theme must be a non-empty string`);return t}function Zi(e,t){let n=Xi(e),r=Yi(t);r&&r.setAttribute(Ji,n)}function Qi(e){return Yi(e)?.getAttribute(Ji)??null}var $i=t((e=>{var t=mr(),n=Symbol.for(`react.element`),r=Symbol.for(`react.fragment`),i=Object.prototype.hasOwnProperty,a=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function s(e,t,r){var s,c={},l=null,u=null;for(s in r!==void 0&&(l=``+r),t.key!==void 0&&(l=``+t.key),t.ref!==void 0&&(u=t.ref),t)i.call(t,s)&&!o.hasOwnProperty(s)&&(c[s]=t[s]);if(e&&e.defaultProps)for(s in t=e.defaultProps,t)c[s]===void 0&&(c[s]=t[s]);return{$$typeof:n,type:e,key:l,ref:u,props:c,_owner:a.current}}e.Fragment=r,e.jsx=s,e.jsxs=s})),ea=t(((e,t)=>{t.exports=$i()})),X=ea(),ta=J.createContext(void 0),na=e=>{let t=J.useContext(ta);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},ra=({client:e,children:t})=>(J.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,X.jsx)(ta.Provider,{value:e,children:t})),ia={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},aa=new class{#e=ia;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function oa(e){setTimeout(e,0)}var sa=typeof window>`u`||`Deno`in globalThis;function ca(){}function la(e,t){return typeof e==`function`?e(t):e}function ua(e){return typeof e==`number`&&e>=0&&e!==1/0}function da(e,t){return Math.max(e+(t||0)-Date.now(),0)}function fa(e,t){return typeof e==`function`?e(t):e}function pa(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==ha(o,t.options))return!1}else if(!_a(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function ma(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(ga(t.options.mutationKey)!==ga(a))return!1}else if(!_a(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function ha(e,t){return(t?.queryKeyHashFn||ga)(e)}function ga(e){return JSON.stringify(e,(e,t)=>Sa(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function _a(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(e&&t&&typeof e==`object`&&typeof t==`object`){if(Array.isArray(e)&&Array.isArray(t)){for(let n=0;n<t.length;n++)if(!_a(e[n],t[n]))return!1;return!0}let n=Object.keys(t);for(let r of n)if(!_a(e[r],t[r]))return!1;return!0}return!1}var va=Object.prototype.hasOwnProperty;function ya(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=xa(e)&&xa(t);if(!r&&!(Sa(e)&&Sa(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:va.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=ya(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function ba(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function xa(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Sa(e){if(!Ca(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!Ca(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function Ca(e){return Object.prototype.toString.call(e)===`[object Object]`}function wa(e){return new Promise(t=>{aa.setTimeout(t,e)})}function Ta(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:ya(e,t)}function Ea(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function Da(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Oa=Symbol();function ka(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===Oa?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Aa(e,t){return typeof e==`function`?e(...t):!!e}function ja(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var Ma=()=>sa,Na=()=>Ma(),Pa=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(){}},Fa=new class extends Pa{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},Ia=oa;function La(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=Ia,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var Ra=La(),za=new class extends Pa{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let 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.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function Ba(e){return Math.min(1e3*2**e,3e4)}function Va(e){return(e??`online`)!==`online`||za.isOnline()}var Ha=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function Ua(e){let t=!1,n=0,r,i=`pending`,a,o,s=new Promise((e,t)=>{a=e,o=t});s.catch(ca);let c=()=>i!==`pending`,l=t=>{if(!c()){let n=new Ha(t);h(n),e.onCancel?.(n)}},u=()=>{t=!0},d=()=>{t=!1},f=()=>Fa.isFocused()&&(e.networkMode===`always`||za.isOnline())&&e.canRun(),p=()=>Va(e.networkMode)&&e.canRun(),m=e=>{c()||(r?.(),i=`resolved`,a(e))},h=e=>{c()||(r?.(),i=`rejected`,o(e))},g=()=>new Promise(t=>{r=e=>{(c()||f())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,c()||e.onContinue?.()}),_=()=>{if(c())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(m).catch(r=>{if(c())return;let i=e.retry??(Na()?0:3),a=e.retryDelay??Ba,o=typeof a==`function`?a(n,r):a,s=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!s){h(r);return}n++,e.onFail?.(n,r),wa(o).then(()=>f()?void 0:g()).then(()=>{t?h(r):_()})})};return{promise:s,status:()=>i,cancel:l,continue:()=>(r?.(),s),cancelRetry:u,continueRetry:d,canStart:p,start:()=>(p()?_():g().then(_),s)}}var Wa=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ua(this.gcTime)&&(this.#e=aa.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Na()?1/0:3e5))}clearGcTimeout(){this.#e!==void 0&&(aa.clearTimeout(this.#e),this.#e=void 0)}};function Ga(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{ja(e,()=>t.signal,()=>n=!0)},u=ka(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);if(r==null&&e.pages.length)return Promise.resolve(e);let a=(()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})(),o=await u(a),{maxPages:s}=t.options,c=i?Da:Ea;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?qa:Ka,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:Ka(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.fetchFn=t.options.persister?()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):l}}}function Ka(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function qa(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}function Ja(e,t){return t?Ka(e,t)!=null:!1}function Ya(e,t){return!t||!e.getPreviousPageParam?!1:qa(e,t)!=null}var Xa=class extends Wa{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e){super(),this.#s=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=$a(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#a?.promise}setOptions(e){if(this.options={...this.#o,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=$a(this.options);e.data!==void 0&&(this.setState(Qa(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=Ta(this.state.data,e,this.options);return this.#c({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#c({type:`setState`,state:e})}cancel(e){let t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(ca).catch(ca):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>fa(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Oa||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>fa(e.options.staleTime,this)===`static`)}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:!da(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){let t=this.observers.indexOf(e);t!==-1&&(this.observers.splice(t,1),this.observers.length||(this.#a&&(this.#s||this.state.fetchStatus===`paused`&&this.state.status===`pending`?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#c({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#a?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#s=!0,n.signal)})},i=()=>{let e=ka(this.options,t),n=(()=>{let e={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#s=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(e),e})();(this.#e===`infinite`?Ga(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#c({type:`fetch`,meta:a.fetchOptions?.meta});let o=this.#a=Ua({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof Ha&&e.revert&&this.setState({...this.#n,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#c({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#c({type:`pause`})},onContinue:()=>{this.#c({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await o.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#r.config.onSuccess?.(e,this),this.#r.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof Ha){if(e.silent)return this.#a.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#c({type:`error`,error:e}),this.#r.config.onError?.(e,this),this.#r.config.onSettled?.(this.state.data,e,this),e}finally{this.#a===o&&(this.#a=void 0),this.scheduleGc()}}#c(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...Za(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...Qa(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),Ra.batch(()=>{this.observers.slice().forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function Za(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Va(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function Qa(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function $a(e){let 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 eo=class extends Pa{#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p=new Set;constructor(e,t){super(),this.options=t,this.#e=e,this.#o=null,this.bindMethods(),this.setOptions(t)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),no(this.#t,this.options)?this.#m():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return ro(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return ro(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof fa(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!ba(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&io(this.#t,n,this.options,t)&&this.#m(),this.updateResult(),r&&(this.#t!==n||fa(this.options.enabled,this.#t)!==fa(t.enabled,this.#t)||fa(this.options.staleTime,this.#t)!==fa(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||fa(this.options.enabled,this.#t)!==fa(t.enabled,this.#t)||i!==this.#f)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return ba(this.getCurrentResult(),n)||(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),Reflect.get(e,n))})}trackProp(e){this.#p.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t),r=()=>{},i,a=new Promise(e=>{i=e,r=this.#e.getQueryCache().subscribe(i=>{i.type===`updated`&&i.query.queryHash===n.queryHash&&n.state.data!==void 0&&(r(),e(this.createResult(n,t)))})});return Promise.race([n.fetch().then(()=>{let e=this.createResult(n,t);return i?.(e),e}).finally(()=>{r()}),a])}fetch(e){return this.#m({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#m(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(ca)),t}#h(e){return!Na()&&fa(this.options.enabled,this.#t)!==!1&&ua(e)}#g(){this.#b();let e=fa(this.options.staleTime,this.#t);if(this.#r.isStale||!this.#h(e))return;let t=da(this.#r.dataUpdatedAt,e)+1;this.#u=aa.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#f=e,!(this.#f===0||!this.#h(this.#f))&&(this.#d=aa.setInterval(()=>{(this.options.refetchIntervalInBackground||Fa.isFocused())&&this.#m()},this.#f))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#u!==void 0&&(aa.clearTimeout(this.#u),this.#u=void 0)}#x(){this.#d!==void 0&&(aa.clearInterval(this.#d),this.#d=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&no(e,t),o=i&&io(e,n,t,r);(a||o)&&(l={...l,...Za(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#l?.state.data,this.#l):t.placeholderData,e!==void 0&&(m=`success`,d=Ta(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h){if(i&&d===a?.data&&t.select===this.#s)d=this.#c;else try{this.#s=t.select,d=t.select(d),d=Ta(i?.data,d,t),this.#c=d,this.#o=null}catch(e){this.#o=e}}else d===void 0&&(this.#o=null);this.#o&&(f=this.#o,d=this.#c,p=Date.now(),m=`error`,u=!1);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0;return{status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:ao(e,t),refetch:this.refetch,isEnabled:fa(t.enabled,e)!==!1}}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);if(this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#l=this.#t),ba(t,e))return;this.#r=t;let n=(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#p.size)return!0;let r=new Set(n??this.#p);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})();Ra.batch(()=>{n&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}};function to(e,t){return fa(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||fa(t.retryOnMount,e)!==!1)}function no(e,t){return to(e,t)||e.state.data!==void 0&&ro(e,t,t.refetchOnMount)}function ro(e,t,n){if(fa(t.enabled,e)!==!1&&fa(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&ao(e,t)}return!1}function io(e,t,n,r){return(e!==t||fa(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&ao(e,n)}function ao(e,t){return fa(t.enabled,e)!==!1&&e.isStaleByTime(fa(t.staleTime,e))}var oo=class extends eo{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,l=o&&c===`forward`,u=i&&c===`forward`,d=o&&c===`backward`,f=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Ja(t,n.data),hasPreviousPage:Ya(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}},so=class extends Wa{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||co(),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.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??(this.state.status===`pending`?this.execute(this.state.variables):Promise.resolve())}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey},r=this.#r=Ua({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)}),i=this.state.status===`pending`,a=!r.canStart();try{if(i)t();else{this.#i({type:`pending`,variables:e,isPaused:a}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:a})}let o=await r.start();return await this.#n.config.onSuccess?.(o,e,this.state.context,this,n),await this.options.onSuccess?.(o,e,this.state.context,n),await this.#n.config.onSettled?.(o,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(o,null,e,this.state.context,n),this.#i({type:`success`,data:o}),o}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#r===r&&(this.#r=void 0),this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,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{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),Ra.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function co(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var lo=class extends Pa{#e;#t;#n;constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}build(e,t,n){let r=new so({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=uo(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=uo(e);if(typeof t==`string`){let n=this.#t.get(t);if(n){if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=uo(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}return!0}runNext(e){let t=uo(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){Ra.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>ma(t,e))}findAll(e={}){return this.getAll().filter(t=>ma(e,t))}notify(e){Ra.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return Ra.batch(()=>Promise.all(e.map(e=>e.continue().catch(ca))))}};function uo(e){return e.options.scope?.id}var fo=class extends Pa{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),ba(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&ga(t.mutationKey)!==ga(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onSubscribe(){this.listeners.size===1&&this.#n&&(this.#n.addObserver(this),this.#i())}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??co();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){Ra.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}};function po(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}var mo=class extends Pa{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,Ra.batch(()=>{let e=this.#i,t=this.#p(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=e.length!==n.length,a=n.some((t,n)=>t!==e[n]),o=i||a,s=o?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!ba(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(po(e,n).forEach(e=>{e.destroy()}),po(n,e).forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})),this.#h()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#p(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){let n=new Set;return t.map((r,i)=>{let a=e[i];return r.defaultedQueryOptions.notifyOnChangeProps?a:r.observer.trackResult(a,e=>{n.has(e)||(n.add(e),t.forEach(t=>{t.observer.trackProp(e)}))})})}#d(e,t,n){if(t){let r=this.#c,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(this.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=ya(this.#a,t(e))),this.#a}return e}#f(){return!this.#r?.combine||this.#i.some((e,t)=>e.options.suspense&&this.#t[t]?.data===void 0)}#p(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new eo(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=this.#t.slice(),this.#t[n]=t,this.#h())}#h(){if(this.hasListeners()){let e=this.#f(),t=this.#a,n=e?t:this.#d(this.#u(this.#t,this.#l),this.#r?.combine);(e||t!==n)&&Ra.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},ho=class extends Pa{#e;constructor(e={}){super(),this.config=e,this.#e=new Map}build(e,t,n){let r=t.queryKey,i=t.queryHash??ha(r,t),a=this.get(i);return a||(a=new Xa({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){Ra.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>pa(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>pa(e,t)):t}notify(e){Ra.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){Ra.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){Ra.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},go=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new ho,this.#t=e.mutationCache||new lo,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=Fa.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=za.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(fa(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=la(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return Ra.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;Ra.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return Ra.batch(()=>{let r=n.findAll(e),i=new Set(r);return r.forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,predicate:e=>i.has(e)},t)})}cancelQueries(e,t={}){let n={revert:!0,...t},r=Ra.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(ca).catch(ca)}invalidateQueries(e,t={}){return Ra.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=Ra.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(ca)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(ca)}async query(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t),r=n.isStaleByTime(fa(t.staleTime,n))?await n.fetch(t):n.state.data,i=t.select;return i?i(r):r}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(fa(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(ca).catch(ca)}infiniteQuery(e){return e._type=`infinite`,this.query(e)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(ca).catch(ca)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return za.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(ga(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{_a(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(ga(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{_a(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=ha(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===Oa&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}};function _o({streamFn:e,refetchMode:t=`reset`,reducer:n=(e,t)=>Ea(e,t),initialValue:r=[]}){return async i=>{let a=i.client.getQueryCache().find({queryKey:i.queryKey,exact:!0}),o=!!a&&a.isFetched();o&&t===`reset`&&a.setState({...a.resetState,fetchStatus:`fetching`});let s=r,c=!1,l=await e(ja({client:i.client,meta:i.meta,queryKey:i.queryKey,pageParam:i.pageParam,direction:i.direction},()=>i.signal,()=>c=!0)),u=o&&t===`replace`;for await(let e of l){if(c)break;u?s=n(s,e):i.client.setQueryData(i.queryKey,t=>n(t===void 0?r:t,e))}return u&&!c&&i.client.setQueryData(i.queryKey,s),i.client.getQueryData(i.queryKey)??r}}var vo=J.createContext(!1),yo=()=>J.useContext(vo);vo.Provider;function bo(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var xo=J.createContext(bo()),So=()=>J.useContext(xo),Co=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?Aa(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||r)&&(t.isReset()||(e.retryOnMount=!1))},wo=e=>{J.useEffect(()=>{e.clearReset()},[e])},To=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||Aa(n,[e.error,r])),Eo=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},Do=(e,t)=>e?.suspense&&t.isPending,Oo=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function ko({queries:e,...t},n){let r=na(n),i=yo(),a=So(),o=t.subscribed!==!1,s=J.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:o?`optimistic`:void 0,t}),[e,r,i,o]);s.forEach(e=>{Eo(e);let t=r.getQueryCache().get(e.queryHash);Co(e,a,t)}),wo(a);let[c]=J.useState(()=>new mo(r,s,t)),[l,u,d]=c.getOptimisticResult(s,t.combine),f=!i&&o;J.useSyncExternalStore(J.useCallback(e=>f?c.subscribe(Ra.batchCalls(e)):ca,[c,f]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),J.useEffect(()=>{c.setQueries(s,t)},[s,t,c]);let p=l.some((e,t)=>Do(s[t],e))?l.flatMap((e,t)=>{let n=s[t];return n&&Do(n,e)?Oo(n,new eo(r,n),a):[]}):[];if(p.length>0)throw Promise.all(p);let m=l.find((e,t)=>{let n=s[t];return n&&To({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(m)throw m.error;return u(d())}function Ao(e,t,n){let r=yo(),i=So(),a=na(n),o=a.defaultQueryOptions(e),s=a.getQueryCache().get(o.queryHash),c=e.subscribed!==!1;o._optimisticResults=r?`isRestoring`:c?`optimistic`:void 0,Eo(o),Co(o,i,s),wo(i);let[l]=J.useState(()=>new t(a,o)),u=l.getOptimisticResult(o),d=!r&&c;if(J.useSyncExternalStore(J.useCallback(e=>{let t=d?l.subscribe(Ra.batchCalls(e)):ca;return l.updateResult(),t},[l,d]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),J.useEffect(()=>{l.setOptions(o)},[o,l]),Do(o,u))throw Oo(o,l,i);if(To({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw u.error;return o.notifyOnChangeProps?u:l.trackResult(u)}function jo(e,t){return Ao(e,eo,t)}function Mo(e){return e}function No(e){return e}function Po(e,t){let n=na(t),[r]=J.useState(()=>new fo(n,e));J.useEffect(()=>{r.setOptions(e)},[r,e]);let i=J.useSyncExternalStore(J.useCallback(e=>r.subscribe(Ra.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=J.useCallback((...e)=>{r.mutate(e[0],e[1]).catch(ca)},[r]);if(i.error&&Aa(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}var Fo=t((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=typeof setTimeout==`function`?setTimeout:null,_=typeof clearTimeout==`function`?clearTimeout:null,v=typeof setImmediate<`u`?setImmediate:null;typeof navigator<`u`&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function y(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function b(e){if(h=!1,y(e),!m){if(n(c)!==null)m=!0,M(x);else{var t=n(l);t!==null&&N(b,t.startTime-e)}}}function x(t,i){m=!1,h&&(h=!1,_(w),w=-1),p=!0;var a=f;try{for(y(i),d=n(c);d!==null&&(!(d.expirationTime>i)||t&&!D());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=i);i=e.unstable_now(),typeof s==`function`?d.callback=s:d===n(c)&&r(c),y(i)}else r(c);d=n(c)}if(d!==null)var u=!0;else{var g=n(l);g!==null&&N(b,g.startTime-i),u=!1}return u}finally{d=null,f=a,p=!1}}var S=!1,C=null,w=-1,T=5,E=-1;function D(){return!(e.unstable_now()-E<T)}function O(){if(C!==null){var t=e.unstable_now();E=t;var n=!0;try{n=C(!0,t)}finally{n?k():(S=!1,C=null)}}else S=!1}var k;if(typeof v==`function`)k=function(){v(O)};else if(typeof MessageChannel<`u`){var A=new MessageChannel,j=A.port2;A.port1.onmessage=O,k=function(){j.postMessage(null)}}else k=function(){g(O,0)};function M(e){C=e,S||(S=!0,k())}function N(t,n){w=g(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_continueExecution=function(){m||p||(m=!0,M(x))},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):T=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(_(w),w=-1):h=!0,N(b,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,M(x))),r},e.unstable_shouldYield=D,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),Io=t(((e,t)=>{t.exports=Fo()})),Lo=t((e=>{var t=mr(),n=Io();function r(e){for(var t=`https://reactjs.org/docs/error-decoder.html?invariant=`+e,n=1;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n]);return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}var i=new Set,a={};function o(e,t){s(e,t),s(e+`Capture`,t)}function s(e,t){for(a[e]=t,e=0;e<t.length;e++)i.add(t[e])}var c=!(typeof window>`u`||window.document===void 0||window.document.createElement===void 0),l=Object.prototype.hasOwnProperty,u=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,d={},f={};function p(e){return l.call(f,e)?!0:l.call(d,e)?!1:u.test(e)?f[e]=!0:(d[e]=!0,!1)}function m(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case`function`:case`symbol`:return!0;case`boolean`:return r?!1:n===null?(e=e.toLowerCase().slice(0,5),e!==`data-`&&e!==`aria-`):!n.acceptsBooleans;default:return!1}}function h(e,t,n,r){if(t==null||m(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return!1===t;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function g(e,t,n,r,i,a,o){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=a,this.removeEmptyString=o}var _={};`children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style`.split(` `).forEach(function(e){_[e]=new g(e,0,!1,e,null,!1,!1)}),[[`acceptCharset`,`accept-charset`],[`className`,`class`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`]].forEach(function(e){var t=e[0];_[t]=new g(t,1,!1,e[1],null,!1,!1)}),[`contentEditable`,`draggable`,`spellCheck`,`value`].forEach(function(e){_[e]=new g(e,2,!1,e.toLowerCase(),null,!1,!1)}),[`autoReverse`,`externalResourcesRequired`,`focusable`,`preserveAlpha`].forEach(function(e){_[e]=new g(e,2,!1,e,null,!1,!1)}),`allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope`.split(` `).forEach(function(e){_[e]=new g(e,3,!1,e.toLowerCase(),null,!1,!1)}),[`checked`,`multiple`,`muted`,`selected`].forEach(function(e){_[e]=new g(e,3,!0,e,null,!1,!1)}),[`capture`,`download`].forEach(function(e){_[e]=new g(e,4,!1,e,null,!1,!1)}),[`cols`,`rows`,`size`,`span`].forEach(function(e){_[e]=new g(e,6,!1,e,null,!1,!1)}),[`rowSpan`,`start`].forEach(function(e){_[e]=new g(e,5,!1,e.toLowerCase(),null,!1,!1)});var v=/[\-:]([a-z])/g;function y(e){return e[1].toUpperCase()}`accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height`.split(` `).forEach(function(e){var t=e.replace(v,y);_[t]=new g(t,1,!1,e,null,!1,!1)}),`xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type`.split(` `).forEach(function(e){var t=e.replace(v,y);_[t]=new g(t,1,!1,e,`http://www.w3.org/1999/xlink`,!1,!1)}),[`xml:base`,`xml:lang`,`xml:space`].forEach(function(e){var t=e.replace(v,y);_[t]=new g(t,1,!1,e,`http://www.w3.org/XML/1998/namespace`,!1,!1)}),[`tabIndex`,`crossOrigin`].forEach(function(e){_[e]=new g(e,1,!1,e.toLowerCase(),null,!1,!1)}),_.xlinkHref=new g(`xlinkHref`,1,!1,`xlink:href`,`http://www.w3.org/1999/xlink`,!0,!1),[`src`,`href`,`action`,`formAction`].forEach(function(e){_[e]=new g(e,1,!1,e.toLowerCase(),null,!0,!0)});function b(e,t,n,r){var i=_.hasOwnProperty(t)?_[t]:null;(i===null?r||!(2<t.length)||t[0]!==`o`&&t[0]!==`O`||t[1]!==`n`&&t[1]!==`N`:i.type!==0)&&(h(t,n,i,r)&&(n=null),r||i===null?p(t)&&(n===null?e.removeAttribute(t):e.setAttribute(t,``+n)):i.mustUseProperty?e[i.propertyName]=n===null?i.type!==3&&``:n:(t=i.attributeName,r=i.attributeNamespace,n===null?e.removeAttribute(t):(i=i.type,n=i===3||i===4&&!0===n?``:``+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}var x=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,S=Symbol.for(`react.element`),C=Symbol.for(`react.portal`),w=Symbol.for(`react.fragment`),T=Symbol.for(`react.strict_mode`),E=Symbol.for(`react.profiler`),D=Symbol.for(`react.provider`),O=Symbol.for(`react.context`),k=Symbol.for(`react.forward_ref`),A=Symbol.for(`react.suspense`),j=Symbol.for(`react.suspense_list`),M=Symbol.for(`react.memo`),N=Symbol.for(`react.lazy`),P=Symbol.for(`react.offscreen`),F=Symbol.iterator;function I(e){return typeof e!=`object`||!e?null:(e=F&&e[F]||e[`@@iterator`],typeof e==`function`?e:null)}var L=Object.assign,ee;function te(e){if(ee===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);ee=t&&t[1]||``}return`
|
|
3
3
|
`+ee+e}var ne=!1;function re(e,t){if(!e||ne)return``;ne=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t){if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(t,[])}catch(e){var r=e}Reflect.construct(e,[],t)}else{try{t.call()}catch(e){r=e}e.call(t.prototype)}}else{try{throw Error()}catch(e){r=e}e()}}catch(t){if(t&&r&&typeof t.stack==`string`){for(var i=t.stack.split(`
|
|
4
4
|
`),a=r.stack.split(`
|
|
5
5
|
`),o=i.length-1,s=a.length-1;1<=o&&0<=s&&i[o]!==a[s];)s--;for(;1<=o&&0<=s;o--,s--)if(i[o]!==a[s]){if(o!==1||s!==1)do if(o--,s--,0>s||i[o]!==a[s]){var c=`
|
|
@@ -136,7 +136,7 @@ Error generating stack: `+e.message+`
|
|
|
136
136
|
recovery_count = recovery_count + 1
|
|
137
137
|
WHERE job_id = ? AND state = 'running' AND claim_token = ?`,n.job.jobId,n.claimToken),MI(e,t,n.job.queue),{status:`requeued`};let i=r.row.cancellation_id!==null,a=i?null:r.job.recovery===void 0?`Execution disappeared without a recovery policy`:`Restart recovery budget exhausted (${String(r.job.recovery.maxRecoveries)} recoveries)`;e.sql.exec(`UPDATE watchdog_jobs
|
|
138
138
|
SET state = 'settled', outcome = ?, failure_reason = ?
|
|
139
|
-
WHERE job_id = ? AND state = 'running' AND claim_token = ?`,i?`cancelled`:`interrupted`,a,n.job.jobId,n.claimToken);let o=OI(e,n.job.jobId)?.job;return o?.state===`settled`?(MI(e,t,o.queue,o),{status:`settled`,job:o}):{status:`conflict`}}))})};return Object.freeze({store:i(n),partition:i,transactional:r})}var zI=W.check(Cn(1),H(256)),BI=W.check(Cn(1),H(200)),VI=vn.check(_n(-(2**53-1)),pn(2**53-1)),HI=vn.check(_n(0),pn(2**53-1)),UI=U({maxRecoveries:HI}),WI={jobId:zI,queue:zI,lane:uI,priority:VI,payload:Gt,recovery:K(UI)},GI=U({...WI,state:G(`queued`)}),KI=U({...WI,state:G(`settled`),outcome:On([`completed`,`failed`,`cancelled`,`outcome_unknown`,`interrupted`]),failureReason:Kt(BI)}),qI=U({...WI,state:G(`running`)}),JI=Zn([GI,qI,KI]);Zn([U({kind:G(`completed`)}),U({kind:G(`failed`),reason:Kt(BI)}),U({kind:G(`cancelled`)}),U({kind:G(`outcome_unknown`)})]);var YI=U({jobId:zI,cancellationId:zI,onlyIfQueued:K(on)}),XI=Zn([U({status:G(`absent`)}),U({status:G(`present`),cancellation:YI})]);Zn([U({status:G(`found`),job:JI,cancellation:XI}),U({status:G(`missing`)})]),Zn([U({state:G(`idle`)}),U({state:On([`queued`,`running`]),jobId:zI,cancellationRequested:on})]),Zn([U({status:G(`queued`)}),U({status:G(`duplicate`)})]),Zn([U({status:On([`recorded`,`replayed`])}),U({status:On([`conflict`,`missing`])})]);var ZI=Zn([mt(ArrayBuffer),W,gn,Nn]);xn(W,ZI);function QI(e){return ve({try:()=>{let t=e.concurrentLane===void 0?void 0:Ht(uI)(e.concurrentLane),n=RI(e.owner,e.project,t===void 0?void 0:{lane:t,include:!1}),r=lI(e,n.store),i={...r,transactional:n.transactional};if(t===void 0)return Object.freeze(i);let a=lI(e,n.partition({lane:t,include:!0}));return Object.freeze({...i,tickConcurrent:a.tick,failLane:e=>e.lane===t?a.failLane(e):r.failLane(e),cancel:e=>r.read(e.jobId).pipe(ot(n=>n.status===`found`&&n.job.lane===t?a.cancel(e):r.cancel(e)))})},catch:e=>new oI(`store_unavailable`,e)})}var $I=e=>({owner:e.owner,project:e.project,isAlive:t=>st({try:()=>e.isAlive(t),catch:e=>new oI(`liveness_unavailable`,e)}),executor:{execute:t=>st({try:n=>e.execute(t,n),catch:()=>new oI(`execution_failed`)})},wake:{recompute:()=>st({try:()=>e.wake.recompute(),catch:()=>new oI(`wake_unavailable`)})}}),eL=e=>Ye(e).then(e=>{if(Vn(e))return e.value;let t=et(fn(e.cause))??vt(e.cause);return Promise.reject(t instanceof Error?t:Error(String(t)))});function tL(e){let t=$I(e);return e.concurrentLane===void 0?eL(QI(t)).then(nL):eL(QI({...t,concurrentLane:e.concurrentLane})).then(e=>Object.freeze({...nL(e),tickConcurrent:()=>eL(e.tickConcurrent())}))}function nL(e){return Object.freeze({hasPendingWork:()=>eL(e.hasPendingWork),ingest:t=>eL(e.ingest(t)),read:t=>eL(e.read(t)),readQueueHead:t=>eL(e.readQueueHead(t)),tick:()=>eL(e.tick()),cancel:t=>eL(e.cancel(t)),failLane:t=>eL(e.failLane(t)),purge:t=>eL(e.purge(t)),transactional:e.transactional})}Object.freeze({make:tL});function rL(e){return oe(()=>sr(()=>import(`./runtime-core-
|
|
139
|
+
WHERE job_id = ? AND state = 'running' AND claim_token = ?`,i?`cancelled`:`interrupted`,a,n.job.jobId,n.claimToken);let o=OI(e,n.job.jobId)?.job;return o?.state===`settled`?(MI(e,t,o.queue,o),{status:`settled`,job:o}):{status:`conflict`}}))})};return Object.freeze({store:i(n),partition:i,transactional:r})}var zI=W.check(Cn(1),H(256)),BI=W.check(Cn(1),H(200)),VI=vn.check(_n(-(2**53-1)),pn(2**53-1)),HI=vn.check(_n(0),pn(2**53-1)),UI=U({maxRecoveries:HI}),WI={jobId:zI,queue:zI,lane:uI,priority:VI,payload:Gt,recovery:K(UI)},GI=U({...WI,state:G(`queued`)}),KI=U({...WI,state:G(`settled`),outcome:On([`completed`,`failed`,`cancelled`,`outcome_unknown`,`interrupted`]),failureReason:Kt(BI)}),qI=U({...WI,state:G(`running`)}),JI=Zn([GI,qI,KI]);Zn([U({kind:G(`completed`)}),U({kind:G(`failed`),reason:Kt(BI)}),U({kind:G(`cancelled`)}),U({kind:G(`outcome_unknown`)})]);var YI=U({jobId:zI,cancellationId:zI,onlyIfQueued:K(on)}),XI=Zn([U({status:G(`absent`)}),U({status:G(`present`),cancellation:YI})]);Zn([U({status:G(`found`),job:JI,cancellation:XI}),U({status:G(`missing`)})]),Zn([U({state:G(`idle`)}),U({state:On([`queued`,`running`]),jobId:zI,cancellationRequested:on})]),Zn([U({status:G(`queued`)}),U({status:G(`duplicate`)})]),Zn([U({status:On([`recorded`,`replayed`])}),U({status:On([`conflict`,`missing`])})]);var ZI=Zn([mt(ArrayBuffer),W,gn,Nn]);xn(W,ZI);function QI(e){return ve({try:()=>{let t=e.concurrentLane===void 0?void 0:Ht(uI)(e.concurrentLane),n=RI(e.owner,e.project,t===void 0?void 0:{lane:t,include:!1}),r=lI(e,n.store),i={...r,transactional:n.transactional};if(t===void 0)return Object.freeze(i);let a=lI(e,n.partition({lane:t,include:!0}));return Object.freeze({...i,tickConcurrent:a.tick,failLane:e=>e.lane===t?a.failLane(e):r.failLane(e),cancel:e=>r.read(e.jobId).pipe(ot(n=>n.status===`found`&&n.job.lane===t?a.cancel(e):r.cancel(e)))})},catch:e=>new oI(`store_unavailable`,e)})}var $I=e=>({owner:e.owner,project:e.project,isAlive:t=>st({try:()=>e.isAlive(t),catch:e=>new oI(`liveness_unavailable`,e)}),executor:{execute:t=>st({try:n=>e.execute(t,n),catch:()=>new oI(`execution_failed`)})},wake:{recompute:()=>st({try:()=>e.wake.recompute(),catch:()=>new oI(`wake_unavailable`)})}}),eL=e=>Ye(e).then(e=>{if(Vn(e))return e.value;let t=et(fn(e.cause))??vt(e.cause);return Promise.reject(t instanceof Error?t:Error(String(t)))});function tL(e){let t=$I(e);return e.concurrentLane===void 0?eL(QI(t)).then(nL):eL(QI({...t,concurrentLane:e.concurrentLane})).then(e=>Object.freeze({...nL(e),tickConcurrent:()=>eL(e.tickConcurrent())}))}function nL(e){return Object.freeze({hasPendingWork:()=>eL(e.hasPendingWork),ingest:t=>eL(e.ingest(t)),read:t=>eL(e.read(t)),readQueueHead:t=>eL(e.readQueueHead(t)),tick:()=>eL(e.tick()),cancel:t=>eL(e.cancel(t)),failLane:t=>eL(e.failLane(t)),purge:t=>eL(e.purge(t)),transactional:e.transactional})}Object.freeze({make:tL});function rL(e){return oe(()=>sr(()=>import(`./runtime-core-DKpk6tKT.js`).then(e=>e.t),__vite__mapDeps([0,1,2,3,4,5]))).pipe(ot(({openRuntimeCore:t})=>t(e)),b(({agent:e})=>e))}function iL(e){return e instanceof cn?e:new cn(`model`,`rejected`,`Model acquisition failed`,void 0,e)}function aL(e){return new cn(`model`,`rejected`,`Model release failed`,void 0,e)}function oL(e){let t=st({try:()=>e.release(),catch:aL}),n={model:e.model,release:t,retryable:e.retryable};return e.failureReason!==void 0&&(n={...n,failureReason:e.failureReason}),e.providerError!==void 0&&(n={...n,providerError:e.providerError}),e.rejection!==void 0&&(n={...n,rejection:e.rejection}),e.stream===void 0?e.retryAfterMs===void 0?Object.freeze(n):Object.freeze({...n,retryAfterMs:e.retryAfterMs}):e.retryAfterMs===void 0?Object.freeze({...n,stream:e.stream}):Object.freeze({...n,stream:e.stream,retryAfterMs:e.retryAfterMs})}function sL(e){return Fe((t,n)=>{if(n.aborted)return;let r;try{r=Promise.resolve(e(n))}catch(e){t(Ee(iL(e)));return}let i=r.then(e=>{if(n.aborted)return Promise.resolve(e.release()).then(()=>void 0);t(Te(oL(e)))},e=>{n.aborted?Dt(`late-model-acquisition`,e):t(Ee(iL(e)))});return st({try:()=>i,catch:aL}).pipe(le)})}function cL(e){let t,n=L(n=>ot(n(e),e=>ze(()=>(t=e,e))));return Qe(n,()=>t===void 0?l:t.release.pipe(le),{interruptible:!0})}function lL(e){let t=({sessionId:t,preference:n})=>sL(r=>e.acquire({sessionId:t,preference:n,signal:r})),n=e.describe;return Object.freeze(n===void 0?{acquire:t}:{acquire:t,describe:({sessionId:e,preference:t})=>st({try:r=>n({sessionId:e,preference:t,signal:r}),catch:iL})})}function uL(e,t){return new cn(e,`rejected`,t)}var dL=W.pipe(q(Cn(1)),q(H(256))),fL=W.pipe(q(Cn(1)),q(gt(e=>new TextEncoder().encode(e).byteLength<=32e3))),pL=U({revision:dL,text:fL,modules:Kt(qt(e=>Array.isArray(e)&&e.every(nt)))}),mL=qt(e=>We(e)),hL=qt(e=>We(e)),gL=U({bind:mL}),_L=qt(e=>We(e)),vL=U({commit:_L,requestWake:hL,close:hL}),yL=U({close:hL}),bL=Bt(pL),xL=Bt(gL),SL=Bt(vL),CL=Bt(yL);function wL(e){return new cn(`runtime`,`invalid`,`Runtime host is invalid`,void 0,e)}function TL(){return new cn(`runtime`,`unavailable`,`Runtime host is unavailable`)}function EL(e,t){return ve({try:()=>t.call(e),catch:TL}).pipe(ot(e=>st({try:()=>Promise.resolve(e),catch:TL})),ot(e=>e===void 0?l:Ee(wL())))}function DL(e,t,n){let r=CL({close:t});return r._tag===`Failure`?Ee(wL(n)):at(EL(e,r.success.close)).pipe(re({onFailure:e=>Ee(wL({cause:n,cleanup:e})),onSuccess:()=>Ee(wL(n))}))}function OL(e){return Ge(()=>{if(!nt(e))return Ee(wL());let t=e,n;try{n=t.close}catch(e){return Ee(wL(e))}let r;try{r=t.requestWake}catch(e){return DL(t,n,e)}let i=SL({commit:t.commit,requestWake:r,close:n});return i._tag===`Failure`?DL(t,n):Te(Object.freeze({commit:e=>st({try:()=>t.commit(()=>Bn(e)),catch:e=>e instanceof cn?e:TL()}),requestWake:EL(t,i.success.requestWake),close:EL(t,i.success.close)}))})}function kL(e){return ve({try:()=>{let t=e.runtime;if(!nt(t))throw wL();let n=xL(t);if(n._tag===`Failure`)throw wL();return{receiver:t,bind:n.success.bind}},catch:wL}).pipe(b(({receiver:e,bind:t})=>Object.freeze({bind:({reconcile:n,pendingWork:r})=>ve({try:()=>t.call(e,{reconcile:()=>Bn(n),pendingWork:()=>Bn(r)}),catch:TL}).pipe(ot(e=>st({try:()=>Promise.resolve(e),catch:TL})),ot(OL))})))}function AL(e,t){let n={store:e.store,runtime:t,extensions:e.extensions,instructions:{load:({sessionId:t,commandId:n})=>st({try:r=>e.instructions.load({sessionId:t,commandId:n,signal:r}),catch:()=>uL(`instructions`,`Instruction acquisition failed`)}).pipe(ot(e=>{let t=bL(e);return t._tag===`Success`?Te(t.success):Ee(new cn(`contract`,`invalid`,`Instruction revision is invalid`))}))},model:lL(e.model)};e.meta!==void 0&&Object.assign(n,{meta:e.meta}),e.storagePressure!==void 0&&Object.assign(n,{storagePressure:e.storagePressure}),e.admission!==void 0&&Object.assign(n,{admission:e.admission}),e.compaction!==void 0&&Object.assign(n,{compaction:e.compaction});let r=e.tools;return r===void 0?n:{...n,tools:bn(r)}}function jL(e,t){return Bn(kL(e).pipe(ot(n=>t(AL(e,n))))).then(Fn)}Object.freeze({make:e=>jL(e,rL)});var ML=200,NL=me({action:tt(`list`)}),PL=De(V(),ye()).parse(structuredClone(ee(NL))),FL=120,IL=me({title:V()}).optional().transform(e=>e?.title.trim().replaceAll(/\s+/gu,` `)??``),LL=4096,RL=me({instructions:V()}).optional().transform(e=>e?.instructions.trim()??``);function zL(e,t){return e?.notify({type:`info`,message:t}),t}function BL(e,t,n){let r=e=>{throw Error(`${e} is unavailable in this host.`)},i={sourceId:n.sourceId,namespace:n.namespace,commands:[{id:`session`,title:`Session status`,category:`Advanced`,projections:{help:{order:1},palette:{order:1},slash:{aliases:[`session`],order:1}},handler:async({interaction:e})=>{let n=await t.read();return zL(e,`Session ${n.sessionId} is ${_M(mM(n))}; ${String(n.pending.prompts.length)} queued prompt${n.pending.prompts.length===1?``:`s`}.`)}},{id:`queue`,title:`Queued prompts`,category:`Advanced`,projections:{help:{order:3},palette:{order:3},slash:{aliases:[`queue`],order:3,arguments:{hint:`list`,words:[{word:`list`,description:`List accepted queued prompts`,arguments:{action:`list`}}]}}},action:{inputSchema:PL},handler:async({arguments:e,interaction:n})=>{if(!NL.safeParse(e??{action:`list`}).success)throw Error(`/queue requires list.`);let r=await t.read(),i=r.pending.prompts,a=r.terminals.map(e=>`${e.outcome} · ${e.commandId}`);zL(n,i.length===0&&a.length===0?`No queued prompts.`:[...i.map((e,t)=>`${String(t+1)}. queued · accepted: ${e.text}`),...a,...r.pending.hasMore===!0?[`More accepted prompts are waiting outside this view.`]:[]].join(`
|
|
140
140
|
`))}},{id:`resume`,title:`Resume a conversation`,category:`Conversation`,projections:{help:{order:5},palette:{order:5},slash:{aliases:[`resume`],order:5}},handler:async()=>{if(!n.sessionResumeAvailable||n.sessionResume===void 0){r(`/resume`);return}await n.sessionResume()}},{id:`fork`,title:`Fork conversation`,category:`Conversation`,projections:{help:{order:7},palette:{order:7},slash:{aliases:[`fork`],order:7}},handler:async({interaction:e})=>{let i=n.onForked;if(!n.forkAvailable||i===void 0){r(`/fork`);return}let a=await t.read();if(_M(mM(a))!==`idle`)throw Error(`Wait for the current run to finish, then fork.`);let o=YP(a.messages??[],a.compactions??[]).items.filter(e=>e.kind===`user_message`);if(o.length===0)throw Error(`No messages to fork from.`);if(e===void 0)throw Error(`Forking a Session needs a person.`);let s=[...o].reverse().slice(0,ML),c=Date.now(),l=await e.prompt({type:`choice`,message:`Fork from which message?`,summary:`Start a new conversation from your message.`,options:s.map(e=>({value:e.id,label:RA(e.text,44)||`(empty message)`,description:e.at===void 0?void 0:LA(e.at,c)}))}),u=await e.run(async()=>{try{return await t.command({type:`fork`,entryId:l})}catch(e){if(e instanceof cn){if(e.boundary===`runtime`&&e.cause===`conflict`)throw Error(`Wait for the current run to finish, then fork.`,{cause:e});if(e.boundary===`store`&&e.cause===`unavailable`)throw Error(`That message is no longer available to fork from.`,{cause:e});if(e.boundary===`runtime`&&e.cause===`rejected`)throw Error(`This Session is bound to a channel and cannot be forked.`,{cause:e})}throw e}});await e.run(async()=>{await i(u.sessionId)})}},{id:`compact`,title:`Compact conversation`,category:`Conversation`,description:`Summarize older context now; optional text sets its focus`,projections:{help:{order:8},palette:{order:8},slash:{aliases:[`compact`],order:8,arguments:{hint:`[instructions]`,text:{field:`instructions`,arguments:{}}}}},handler:async({arguments:e})=>{let n=RL.safeParse(e);if(!n.success)throw Error(`Use /compact, or /compact <what to focus on>.`);let r=n.data;if(r.length>LL)throw Error(`Compaction instructions are at most ${String(LL)} characters.`);return await t.command(r.length===0?{type:`compact`,requestId:It()}:{type:`compact`,requestId:It(),instructions:r}),`Compaction queued; it runs after any current work.`}},{id:`name`,title:`Name conversation`,category:`Conversation`,description:`Set the conversation title; no text restores it`,projections:{help:{order:9},palette:{order:9},slash:{aliases:[`name`],order:9,arguments:{hint:`[title]`,text:{field:`title`,arguments:{}}}}},handler:async({arguments:e})=>{let r=IL.safeParse(e);if(!r.success)throw Error(`Use /name <title>, or /name to clear it.`);let i=r.data;if(Array.from(i).length>FL)throw Error(`A conversation title is at most ${String(FL)} characters.`);let a=i.length===0?null:i;return await t.command({type:`title`,title:a}),await n.onTitled?.(a),a===null?`Conversation title cleared; it follows the first prompt again.`:`Conversation named "${a}".`}}]};return e.contribute(i)}var VL=new Set([`Esc`,`Ctrl+C`]);function HL(e){let{completion:t}=e;if(t.kind===`commands`&&t.items.length>0)return[{keys:`↑↓`,label:`choose`,priority:1},{keys:`Tab`,label:`complete`,priority:0},{keys:`Enter`,label:`run`,priority:0},{keys:`Esc`,label:`dismiss`,priority:2}];if(t.kind===`arguments`)return t.items.length>0?[{keys:`↑↓`,label:`choose`,priority:1},{keys:`Tab`,label:`complete`,priority:0},{keys:`Enter`,label:`run`,priority:0},{keys:`Esc`,label:`dismiss`,priority:2}]:[{keys:`Enter`,label:`run`,priority:0},{keys:`Esc`,label:`dismiss`,priority:2}];let n=[{keys:`Enter`,label:`send`,priority:0}];e.busy&&e.keys.queue!==void 0&&n.push({keys:e.keys.queue,label:`queue`,priority:0}),e.keys.newline!==void 0&&n.push({keys:e.keys.newline,label:`newline`,priority:1}),e.keys.scroll!==void 0&&n.push({keys:e.keys.scroll,label:`scroll`,priority:2});for(let t of e.bindings){let r=t.keys.split(`, `).some(e=>VL.has(e));r&&!e.busy||n.push({keys:t.keys,label:t.title.toLocaleLowerCase(),priority:r?0:3})}return n.push({keys:`/`,label:`commands`,priority:4}),n}var UL=` · `;function WL(e){return e.map(e=>`${e.keys} ${e.label}`).join(UL)}function GL(e,t,n){t!==void 0&&setTimeout(()=>{e.execute(t,{origin:n})},0)}function KL(e,t){return[{id:`help`,title:`Show commands`,category:`Advanced`,projections:{help:{order:-3},slash:{aliases:[`help`],order:-3}},handler:async n=>{if(t.showCommands!==void 0){await t.showCommands();return}let r=sF(e.snapshot()).filter(e=>e.alias!==`help`);if(n.interaction===void 0)return r.map(e=>`/${e.alias}`);let i=await n.interaction.prompt({type:`choice`,message:`Commands`,options:r.map(e=>({value:e.commandId,label:`/${e.alias}`,description:e.keys.length===0?e.title:`${e.title} · ${e.keys.join(`, `)}`}))});GL(e,r.find(e=>e.commandId===i)?.command,n.origin)}},{id:`keys`,title:`Show key bindings`,category:`Advanced`,projections:{help:{order:-2},slash:{aliases:[`keys`],order:-2,consumesDraft:!0}},handler:async t=>{let n=cF(e.snapshot());if(t.interaction===void 0)return n.map(e=>`${e.keys} ${e.title}`);if(n.length===0){t.interaction.notify({type:`info`,message:`No key bindings are active.`});return}let r=await t.interaction.prompt({type:`choice`,message:`Key bindings`,options:n.map(e=>({value:e.commandId,label:e.title,description:e.keys}))});GL(e,n.find(e=>e.commandId===r)?.command,t.origin)}},{id:`clear`,title:`Clear the composer`,category:`Advanced`,projections:{help:{order:-1},slash:{aliases:[`clear`],order:-1}},handler:()=>{t.clear()}}]}var qL=Zt(U({cancelled:G(!0)})),JL=Zt(dn(xn(W,zn)));function YL(e,t,n,r){let i=new Map,a=(e,t)=>n().find(t=>t.entryId===e)?.value.panel.flatMap(e=>e.actions??[]).filter(e=>e.id===t)??[],o=e=>JSON.stringify([e.id,e.input??{}]),s=new Set,c=()=>{for(let e of s){let t=new Set(a(e.entryId,e.commandId).map(o));i.has(e.entryId)&&e.intents.every(e=>t.has(e))||(e.execution.withdrawn=!0,e.controller.abort())}},l=e=>{i.get(e)?.lease.dispose(),i.delete(e)};return{update:n=>{let u=[];for(let e of i.keys()){let t=Object.hasOwn(n,e)?n[e]:void 0;(t?.status!==`running`||t.catalog===void 0)&&l(e)}for(let[d,f]of Object.entries(n)){if(f.status!==`running`||f.catalog===void 0)continue;let n=JSON.stringify(f.catalog);if(i.get(d)?.catalog!==n){l(d);try{let l=t.extension(d),u=aj(f.catalog),p=uj(u,(e,t)=>l.call(e,t));i.set(d,{catalog:n,lease:e.contribute({sourceId:`extension:${d}`,namespace:d,commands:p.map(e=>({...e,handler:async t=>{let f=a(d,e.id),p={intents:f.map(o),withdrawn:!1},m=uj(u,async(e,t)=>{let n=await l.call(e,t),r=sj(n);if(r.type===`prompt`){let e=f.filter(e=>Object.entries(e.input??{}).every(([e,n])=>JSON.stringify(Object.hasOwn(r.next.arguments,e)?r.next.arguments[e]:t[e])===JSON.stringify(n)));p.intents=(e.length>0?e:f).map(o)}return n}).find(t=>t.id===e.id);if(m===void 0)throw Error(`The advertised command is unavailable`);let h=t,g=t.interaction;if(g!==void 0){let t={...g,prompt:(t,n)=>{let r={entryId:d,commandId:e.id,intents:p.intents,execution:p,controller:new AbortController};return s.add(r),c(),g.prompt(t,{signal:n?.signal===void 0?r.controller.signal:AbortSignal.any([n.signal,r.controller.signal])}).finally(()=>s.delete(r))}};h={...h,interaction:t}}let _;try{_=await m.handler(h)}catch(e){if(p.withdrawn)return{cancelled:!0};throw e}finally{for(let e of s)e.execution===p&&s.delete(e)}return t.origin!==`agent`&&JL(t.arguments)&&!qL(_)&&!t.signal?.aborted&&i.get(d)?.catalog===n&&r?.(d,e.id),_}}))})})}catch(e){u.push({extensionId:d,message:e instanceof Error?e.message:`The advertised catalog is invalid`})}}}return c(),u},dispose:()=>{for(let e of i.keys())l(e);c()}}}function XL(e,t){let n=e.map((e,t)=>({item:e,index:t})).sort((e,t)=>e.item.arrivedAt-t.item.arrivedAt||e.index-t.index).map(({item:e})=>e),r=n.find(e=>!t.has(e.key));return{items:n,current:r,position:r===void 0?0:n.indexOf(r)+1,total:n.length}}function ZL(e,t){return t===``||e.forced?e.current:void 0}function QL(){return{highlight:0,toggled:new Set,other:``,phase:`choose`,details:!1}}var $L=e=>({state:e});function eR(e,t,n){return{...e,highlight:n,phase:n===t.options.length?`other`:`choose`,refusal:void 0}}function tR(e,t,n){let r=n.options.length,i=n.other,a=r+(i===void 0?0:1);if(t.type===`refused`)return{state:{...e,phase:`refused`,refusal:t.message}};if(e.phase===`sending`||e.details&&t.type!==`details`&&t.type!==`escape`)return $L(e);switch(t.type){case`move`:return{state:eR(e,n,(e.highlight+t.delta+a)%a)};case`pick`:return t.number>=1&&t.number<=a?{state:eR(e,n,t.number-1)}:$L(e);case`toggle`:{let t=n.options[e.highlight];if(n.multiple!==!0||t===void 0)return $L(e);let r=new Set(e.toggled);return r.delete(t.value)||r.add(t.value),{state:{...e,toggled:r,phase:`choose`,refusal:void 0}}}case`type`:case`append`:return i===void 0?$L(e):{state:{...e,other:(t.type===`append`?`${e.other}${t.text}`:t.text).slice(0,i.maxLength),highlight:r,phase:`other`,refusal:void 0}};case`details`:return{state:{...e,details:!e.details}};case`enter`:{let t=e.other.trim(),a=t===``?{}:{text:t};if(n.multiple===!0){let r=n.options.map(e=>e.value).filter(t=>e.toggled.has(t));return r.length===0&&t===``?{state:eR(e,n,e.highlight)}:{state:{...e,phase:`sending`,refusal:void 0},effect:{type:`answer`,selected:r,...a}}}let o=n.options[e.highlight];return o===void 0?t===``?i?.blank===void 0?{state:eR(e,n,r)}:{state:{...e,phase:`sending`,refusal:void 0},effect:{type:`answer`,selected:[i.blank]}}:{state:{...e,phase:`sending`,refusal:void 0},effect:{type:`answer`,selected:[],text:t}}:{state:{...e,phase:`sending`,refusal:void 0},effect:{type:`answer`,selected:[o.value]}}}case`escape`:return e.details?{state:{...e,details:!1}}:e.phase===`other`||e.phase===`confirm`?{state:{...e,highlight:0,phase:`choose`},effect:{type:`back`}}:n.escape===void 0?{state:e,effect:{type:`later`}}:{state:{...e,phase:`sending`,refusal:void 0},effect:{type:`answer`,selected:[n.escape]}}}}var nR={question:`question`,approval:`approval`};function rR(e,t,n){let r=t.multiple===!0,i=t.options.length,a=e.other.trim(),o=[...t.options.map((t,n)=>{let i=e.toggled.has(t.value),a=r?i?`[x]`:`[ ]`:`${String(n+1)}.`,o=`${t.label}${n===0?` (recommended)`:``}`;return{index:n,kind:`option`,marker:a,label:t.label,description:t.description,recommended:n===0,highlighted:e.highlight===n,toggled:i,destructive:t.destructive===!0,caption:o,text:`${a} ${o}`}}),...t.other===void 0?[]:[(t=>{let n=r&&a!==``,o=r?n?`[x]`:`[ ]`:`${String(i+1)}.`;return{index:i,kind:`other`,marker:o,label:t.label,description:void 0,recommended:!1,highlighted:e.highlight===i,toggled:n,destructive:!1,caption:t.label,text:`${o} ${t.label}`}})(t.other)]],s=e.phase===`other`,c=t.options.find(e=>e.value===t.other?.blank)?.label.toLowerCase(),l=t.options.find(e=>e.value===t.escape)?.label.toLowerCase(),u=e.phase===`sending`,d=(t.details?.length??0)>0||t.body!==void 0,f=u?[]:e.details?[{keys:`d`,label:`back`,priority:0},{keys:`Esc`,label:`back`,priority:1}]:[{keys:`↑↓`,label:`move`,priority:1},...r&&!s?[{keys:`Space`,label:`toggle`,priority:1}]:[],{keys:`Enter`,label:s&&a===``&&c!==void 0?c:r||s?`send`:e.highlight===i?`write`:`choose`,priority:0},...d?[{keys:s?`Alt+D`:`d`,label:`details`,priority:2}]:[],{keys:`Esc`,label:s?`back`:l??`later`,priority:2}];return{kind:n.kind,label:`Agent ${nR[n.kind]} ${String(n.position)} of ${String(n.total)}`,title:t.message,counter:n.total>1?`${String(n.position)} of ${String(n.total)}`:void 0,summary:t.summary,facts:t.facts??[],body:t.body,bodyLabel:t.bodyLabel,details:t.details??[],detailsOpen:e.details,rows:o,other:t.other===void 0?void 0:{label:t.other.label,placeholder:t.other.placeholder,text:e.other,focused:s,maxLength:t.other.maxLength},multiple:r,phase:e.phase,canSend:!u&&!e.details&&(r?e.toggled.size>0||a!==``:e.highlight<i||a!==``||t.other?.blank!==void 0),status:u?{tone:`info`,text:`Sending…`}:e.phase===`refused`?{tone:`error`,text:e.refusal??`That answer was refused.`}:void 0,hints:f}}function iR(e){return e.flatMap(({entryId:e,value:t})=>t.panel.flatMap(t=>(t.actions??[]).filter(e=>e.awaiting!==void 0).map(n=>({key:JSON.stringify([e,t.id]),command:{namespace:e,id:n.id},title:t.title,action:n}))))}function aR(e){if(e.status!==`handled`)return e.status===`failed`?e.error.message:e.status===`unavailable`?e.reason:`The question could not be opened (${e.status}).`}function oR(e){let{enabled:t,commands:n,store:r,contributions:i,online:a,requests:o,commandsVersion:s}=e,c=(0,J.useRef)(new Map),l=(0,J.useRef)(o);(0,J.useEffect)(()=>{let e=new Map((t&&a?iR(i):[]).map(e=>[e.key,e])),s=l.current!==o;l.current=o;for(let[t,n]of c.current)(!e.has(t)||s&&n.failed())&&(n.stop(),c.current.delete(t));for(let t of e.values()){if(c.current.has(t.key))continue;let e=gj({title:t.title}),i=e.begin(),a=new AbortController,o,s=!1,l=e.subscribe(()=>{o===void 0&&e.snapshot().prompt!==void 0&&(o=r.awaiting.add({key:t.key,kind:`question`,arrivedAt:Date.now(),host:e}))}),u={origin:`menu`,signal:a.signal,interaction:i.interaction};n.execute(t.command,t.action.input===void 0?u:{...u,arguments:t.action.input}).then(n=>{if(l(),o?.(),n.status===`missing`||n.status===`unavailable`){i.settle({status:`cancelled`}),c.current.get(t.key)?.failed()===!1&&c.current.delete(t.key);return}let u=aR(n);if(u===void 0){i.settle({status:`handled`});let t=e.snapshot().message;t?.type===`info`&&r.toast({variant:`info`,message:t.message});return}if(a.signal.aborted){i.settle({status:`cancelled`});return}s=!0,i.settle({status:`failed`,message:u}),r.report({tone:`error`,message:u})}),c.current.set(t.key,{failed:()=>s,stop:()=>{l(),o?.(),a.abort(),e.cancel()}})}},[t,a,i,n,r,o,s]),(0,J.useEffect)(()=>()=>{for(let e of c.current.values())e.stop();c.current.clear()},[n,r,t])}function sR(e){if(e!==void 0&&e.status!==`handled`)return e.status===`failed`?e.error.message:e.status===`unavailable`?e.reason:`Command ${e.status}`}function cR(e){let{commands:t,origin:n}=e,r=e.enabled??!0,i=eI(),a=QF(),o=tI(),s=rI(),c=(0,J.useRef)(s);c.current=s;let l=iI(),u=(0,J.useMemo)(()=>e.interactionStore??l,[e.interactionStore,l]),d=(0,J.useSyncExternalStore)(u.subscribe,u.snapshot,u.snapshot);(0,J.useEffect)(()=>{let e=d.inspection;e!==void 0&&!s.some(t=>t.entryId===e.entryId&&t.value.panel.some(t=>t.id===e.rowId&&t.inspection!==void 0))&&u.inspect(void 0)},[s,d.inspection,u]);let f={...XL(d.awaiting.items,d.awaiting.later),forced:d.awaiting.forced},p=(0,J.useSyncExternalStore)(t.subscribe,t.snapshot,t.snapshot),m=(0,J.useRef)(a);m.current=a;let h=(0,J.useRef)(e.showCommands);h.current=e.showCommands;let g=e.showCommands!==void 0;(0,J.useEffect)(()=>{if(r)return u.attach(t.present)},[t,r,u]),(0,J.useEffect)(()=>{if(!r)return;let e=t.contribute({sourceId:`parakeet`,namespace:`parakeet`,commands:KL(t,{showCommands:g?()=>h.current?.():void 0,clear:()=>{m.current.setDraft(``),u.report(void 0)}})});return()=>{e.dispose()}},[t,r,u,g]);let _=(0,J.useMemo)(()=>YL(t,i,()=>c.current,(e,t)=>{let n=c.current.find(t=>t.entryId===e)?.value.panel.find(e=>e.inspection?.commandId===t);n!==void 0&&u.inspect({entryId:e,rowId:n.id})}),[t,i,u]);(0,J.useEffect)(()=>()=>{_.dispose()},[_]),(0,J.useEffect)(()=>{if(!r){_.dispose();return}let[e]=_.update(o);e!==void 0&&u.report({tone:`error`,message:`${e.extensionId} commands are unavailable: ${e.message}`})},[_,r,o,s,u]);let{observation:v}=nI();oR({enabled:r,commands:t,store:u,contributions:s,online:v.status===`live`,requests:d.awaiting.requests,commandsVersion:p});let y=d.awaiting.items.length>0;(0,J.useEffect)(()=>{if(!r||!y)return;let e=t.contribute({sourceId:`parakeet-awaiting`,namespace:`parakeet-awaiting`,commands:[{id:`answer`,title:`Answer a question`,category:`Conversation`,description:`Answer what the Agent is waiting on`,projections:{help:{order:5},palette:{order:5},slash:{aliases:[`answer`],order:5,consumesDraft:!0}},handler:()=>{u.awaiting.focus()}}]});return()=>{e.dispose()}},[t,r,u,y]);let b=(0,J.useMemo)(()=>sF(p),[p]),[x,S]=(0,J.useState)(),[C,w]=(0,J.useState)({draft:``,index:0}),T=a.draft,E=!r||x===T||d.open!==void 0?{kind:`none`}:mF(b,T),D=E.kind===`none`?0:E.items.length,O=E.kind===`arguments`||E.kind===`commands`&&D>0,k=C.draft===T?Math.min(C.index,Math.max(0,D-1)):0,A=HL({completion:E,busy:e.busy,bindings:cF(p),keys:e.keys}),j=(0,J.useCallback)((e,i)=>{let a=m.current;if(!r){a.send(e);return}i!==void 0&&a.setDraft(i);let o=i??a.draft;u.report(void 0),S(o),a.submitCommand((r,i)=>_F(r,t,()=>{a.send(e)},n,i)).then(e=>{let t=sR(e);t!==void 0&&u.snapshot().open===void 0&&u.lastEnd()!==`cancelled`&&u.report({tone:`error`,message:`${o}: ${t}`})})},[t,r,n,u]),M=e=>{if(E.kind===`commands`||E.kind===`arguments`)return E.items[e]?.insert};return{completion:E,open:O,selected:k,hints:A,interactions:d,store:u,awaiting:f,move:e=>D!==0&&(w({draft:T,index:(k+e+D)%D}),!0),highlight:e=>{w({draft:T,index:e})},complete:()=>{let e=M(k);return e!==void 0&&(a.setDraft(e),!0)},dismiss:()=>d.open===void 0?d.inspection===void 0?O?(S(T),!0):d.notice!==void 0&&(u.report(void 0),!0):(u.inspect(void 0),!0):(u.close(),!0),submit:(t=e.busy?`followUp`:`steer`)=>{let n=(E.kind===`commands`||E.kind===`arguments`&&E.query.length>0)&&D>0?M(k):void 0;j(t,n?.trimEnd())},choose:t=>{let n=M(t);n!==void 0&&j(e.busy?`followUp`:`steer`,n.trimEnd())},available:e=>b.some(t=>t.alias===e&&t.availability.status===`available`),runCommand:e=>{u.report(void 0),_F(`/${e}`,t,()=>void 0,n).then(t=>{let n=sR(t);n!==void 0&&u.snapshot().open===void 0&&u.lastEnd()!==`cancelled`&&u.report({tone:`error`,message:`/${e}: ${n}`})})}}}function lR(e){return e.replace(/^\uFEFF/,``).replace(/\r\n?/g,`
|
|
141
141
|
`)}function uR(e){return/^\s*$/.test(e)}function dR(e,t){let n=0;for(;n<e.length&&n<t&&e[n]===` `;)n++;return e.slice(n)}function fR(e){let t=``;for(let n of e)n.type===`text`||n.type===`inlineCode`?t+=n.value:`children`in n?t+=fR(n.children):n.type===`image`&&(t+=n.alt);return t}function pR(){let e=new Map;return t=>{let n=t.toLowerCase().normalize(`NFKD`).replace(/[\u0300-\u036f]/g,``).replace(/&[a-z0-9#]+;/gi,``).replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`section`,r=e.get(n)??0;return e.set(n,r+1),r===0?n:`${n}-${r+1}`}}function mR(e){let t=e.trim().replace(/[\u0000-\u001F\u007F\s]+/g,``);return t?/^(#|\/|\.\/|\.\.\/)/.test(t)||/^(https?:|mailto:|tel:)/i.test(t)?t:/^[a-z][a-z0-9+.-]*:/i.test(t)?``:t:``}function hR(e){return e.trim().toLowerCase()}function gR(e){return hR(e).replace(/[^a-z0-9_-]+/g,`-`).replace(/^-+|-+$/g,``)}function _R(e,t={}){let n=LR(bR(e,t));for(let e of t.extensions??[])n=e.transformInline?.(n,{options:t})??n;return n}var vR=32,yR=16;function bR(e,t,n={scans:Math.max(e.length*yR,1024),depth:0}){if(n.depth>=vR)return e?[{type:`text`,value:e}]:[];n.depth++;let r=[],i=0,a=``,o=()=>{a&&=(r.push({type:`text`,value:a}),``)};for(;i<e.length;){let s=e[i],c=e[i+1];if(s===`\\`){if(c===`
|
|
142
142
|
`){o(),r.push({type:`break`}),i+=2;continue}if(c&&/[\\`*_[\]{}()#+\-.!|~<>]/.test(c)){a+=c,i+=2;continue}}if(s==="`"){let t=ER(e,i,"`"),s=DR(e,i+t,"`",t,n);if(s!==-1){o(),r.push({type:`inlineCode`,value:e.slice(i+t,s).replace(/\s+/g,` `).trim()}),i=s+t;continue}a+=e.slice(i,i+t),i+=t;continue}if(s===`!`&&c===`[`){let a=SR(e,i+1,t,n);if(a){o(),r.push({type:`image`,src:mR(a.href),alt:IR(a.label,n),...a.title?{title:a.title}:{}}),i=a.end;continue}}if(s===`[`){let a=xR(e,i,t,n);if(a){o(),r.push(a.node),i=a.end;continue}let s=SR(e,i,t,n);if(s){let e=mR(s.href);o(),e?r.push({type:`link`,href:e,...s.title?{title:s.title}:{},children:bR(s.label,t,n)}):r.push(...bR(s.label,t,n)),i=s.end;continue}}if(s===`*`&&c===`*`&&e[i+2]===`*`){let a=OR(e,i+3,`***`,n);if(a!==-1){o(),r.push({type:`emphasis`,children:bR(e.slice(i+1,a+2),t,n)}),i=a+3;continue}}if(s===`*`&&c===`*`||s===`_`&&c===`_`){let l=s===`_`&&!MR(e,i,2,!0)?-1:OR(e,i+2,s+s,n);if(l!==-1){o(),r.push({type:`strong`,children:bR(e.slice(i+2,l),t,n)}),i=l+2;continue}a+=s+c,i+=2;continue}if(s===`~`&&c===`~`&&e[i+2]===`~`){let t=ER(e,i,`~`);a+=e.slice(i,i+t),i+=t;continue}if(s===`~`&&c===`~`){let s=OR(e,i+2,`~~`,n);if(s!==-1){o(),r.push({type:`strike`,children:bR(e.slice(i+2,s),t,n)}),i=s+2;continue}a+=`~~`,i+=2;continue}if(s===`~`){let a=kR(e,i+1,n);if(a!==-1){o(),r.push({type:`strike`,children:bR(e.slice(i+1,a),t,n)}),i=a+1;continue}}if(s===`*`||s===`_`){let a=s===`_`&&!MR(e,i,1,!0)?-1:OR(e,i+1,s,n);if(a!==-1){o(),r.push({type:`emphasis`,children:bR(e.slice(i+1,a),t,n)}),i=a+1;continue}}if(s===`<`&&t.allowHtml){let t=AR(e,i+1,`>`,n);if(t!==-1&&CR(e.slice(i,t+1))){o(),r.push({type:`inlineHtml`,value:e.slice(i,t+1)}),i=t+1;continue}}a+=s,i++}return o(),n.depth--,r}function xR(e,t,n,r){if(e[t+1]!==`^`)return;let i=AR(e,t+2,`]`,r);if(i===-1)return;let a=hR(e.slice(t+2,i)),o=n.footnotes?.[a];if(!o||!n.footnoteOrder)return;let s=n.footnoteOrder.indexOf(a);s===-1&&(n.footnoteOrder.push(a),s=n.footnoteOrder.length-1);let c=(n.footnoteCounts?.[a]??0)+1;return n.footnoteCounts&&(n.footnoteCounts[a]=c),{node:{type:`footnoteReference`,id:o.id??(gR(o.label)||`footnote`),number:s+1,...c>1?{referenceIndex:c}:{}},end:i+1}}function SR(e,t,n,r){let i=TR(e,t,`[`,`]`,r);if(i===-1)return;let a=e.slice(t+1,i);if(e[i+1]===`(`){let t=TR(e,i+1,`(`,`)`,r);if(t===-1)return;let n=wR(e.slice(i+2,t).trim());return n?{label:a,href:n.href,...n.title?{title:n.title}:{},end:t+1}:void 0}if(e[i+1]===`[`){let t=TR(e,i+1,`[`,`]`,r);if(t===-1)return;let o=e.slice(i+2,t),s=n.references?.[hR(o||a)];return s?{label:a,href:s.href,...s.title?{title:s.title}:{},end:t+1}:void 0}let o=n.references?.[hR(a)];if(o)return{label:a,href:o.href,...o.title?{title:o.title}:{},end:i+1}}function CR(e){return/^<!--(?:[\s\S]*--|-?)>$/.test(e)||/^<\?[\s\S]*\?>$/.test(e)||/^<![A-Z][\s\S]*>$/.test(e)||/^<!\[CDATA\[[\s\S]*\]\]>$/.test(e)||/^<\/[A-Za-z][\w:-]*\s*>$/.test(e)?!0:/^<[A-Za-z][\w:-]*(?:\s+[A-Za-z_:][\w:.-]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'=<>`]+))?)*\s*\/?>$/.test(e)}function wR(e){let t=e.match(/^(\S+)(?:\s+["']([^"']*)["'])?$/);return t?{href:t[1].replace(/^<|>$/g,``),...t[2]?{title:t[2]}:{}}:{href:e}}function TR(e,t,n,r,i){let a=0;for(let o=t;o<e.length;o++){if(!jR(i))return-1;if(e[o-1]!==`\\`&&(e[o]===n&&a++,e[o]===r&&(a--,a===0)))return o}return-1}function ER(e,t,n,r){let i=0;for(;e[t+i]===n&&!(r&&!jR(r));)i++;return i}function DR(e,t,n,r,i){for(let a=t;a<e.length;a++){if(!jR(i))return-1;if(e[a]===n&&ER(e,a,n,i)>=r)return a}return-1}function OR(e,t,n,r){for(let i=t;i<e.length;i++){if(!jR(r))return-1;if(e[i-1]!==`\\`&&(n!==`~~`||e[i-1]!==`~`&&e[i+2]!==`~`)&&!(n[0]===`_`&&!MR(e,i,n.length,!1))&&e.startsWith(n,i))return i}return-1}function kR(e,t,n){if(FR(e[t]??``)||/\d/.test(e[t]??``))return-1;for(let r=t;r<e.length;r++){if(!jR(n))return-1;if(e[r-1]!==`\\`&&e[r]===`~`&&e[r-1]!==`~`&&e[r+1]!==`~`)return FR(e[r-1]??``)?-1:r}return-1}function AR(e,t,n,r){for(let i=t;i<e.length;i++){if(!jR(r))return-1;if(e[i]===n)return i}return-1}function jR(e){return e.scans<=0?!1:(e.scans--,!0)}function MR(e,t,n,r){let i=e[t-1],a=e[t+n],o=!NR(a)&&(!PR(a)||NR(i)||PR(i)),s=!NR(i)&&(!PR(i)||NR(a)||PR(a));return r?o&&(!s||PR(i)):s&&(!o||PR(a))}function NR(e){return e===void 0||/\s/.test(e)}function PR(e){return e!==void 0&&/[^\p{L}\p{N}\s]/u.test(e)}function FR(e){return/\s/.test(e)}function IR(e,t){return bR(e,{},t).map(e=>e.type===`text`||e.type===`inlineCode`?e.value:``).join(``)}function LR(e){let t=[];for(let n of e){let e=t.at(-1);e?.type===`text`&&n.type===`text`?e.value+=n.value:t.push(n)}return t}var RR=64;function zR(e,t={}){let n=lR(e),r=t.frontmatter!==!1,i=n.split(`
|
|
@@ -171,4 +171,4 @@ Error generating stack: `+e.message+`
|
|
|
171
171
|
`).map((e,n)=>{let r=AY.exec(e);if(!r)return e;let i=r[1]||r[2]||r[3];return t.push({className:i===`++`?`th-line--inserted`:`th-line--deleted`,lines:n+1}),e.slice(0,r.index)}).join(`
|
|
172
172
|
`),decorations:t}}function MY(e){return(t,n=`plaintext`,r={})=>{let i=jY(t);return gJ(hJ(e.tokenize(i.code,{lang:n}).tokens,{...r.lineNumbers===void 0?{}:{lineNumbers:r.lineNumbers},...i.decorations.length||r.highlightLines?.length?{decorations:[...i.decorations,...(r.highlightLines||[]).map(e=>({className:`th-line--highlighted`,lines:e}))]}:{}}))}}var NY=mJ({fallbackLanguage:`plaintext`,languages:[RJ,zJ,qJ,lY,uY,dY,fY,hY,gY,_Y,CY,wY,TY,EY]}),PY=MY(NY);function FY(e,t){return NY.highlightToHtml(e,t?{lang:t}:{})}var IY=(0,J.forwardRef)(function({className:e,variant:t=`default`,...n},r){return(0,X.jsx)(`article`,{...n,className:Q(`prose prose-caps`,t===`dropcap`&&`caps-prose-dropcap`,e),ref:r})});function LY(e){return URL.parse(e)?.protocol??null}function RY(e){if(e===``||e.startsWith(`//`))return!1;let t=LY(e);return t===null||t===`http:`||t===`https:`||t===`mailto:`}function zY(e){let t=LY(e);return t===`http:`||t===`https:`}function BY(e){if(e===``||e.startsWith(`//`))return!1;let t=LY(e);return t===null||t===`http:`||t===`https:`}function VY({children:e,className:t,components:n,frontmatter:r=!0,policy:i=`default`,typography:a=`prose`}){let o=(0,J.useMemo)(()=>zR(e,{allowHtml:!1,frontmatter:r}),[e,r]),s=(0,J.useMemo)(()=>({...n,a(e){let t=e.href??``;if(i===`visitor`){let n=URL.parse(t);return n===null||!zY(n.href)?(0,X.jsx)(`span`,{children:e.children}):(0,X.jsx)(`a`,{href:n.href,target:`_blank`,rel:`noopener noreferrer`,children:e.children})}if(!RY(t))return(0,X.jsx)(X.Fragment,{children:e.children});let n=zY(t);return(0,X.jsx)(`a`,{...e,href:t,rel:n?`noopener noreferrer`:e.rel,target:n?`_blank`:e.target})},img(e){if(i===`visitor`)return(0,X.jsx)(`span`,{className:`text-dim`,children:`Image removed`});let t=e.src??``;return BY(t)?n?.img?(0,J.createElement)(n.img,e):(0,X.jsx)(`img`,{alt:e.alt??``,className:`max-w-full`,src:t}):(0,X.jsx)(X.Fragment,{children:e.alt??``})}}),[n,i]),c=(0,X.jsx)(Zq,{allowHtml:!1,components:s,highlighter:PY,children:o}),l=Q(`min-w-0 break-words`,t);return a===`prose`?(0,X.jsx)(IY,{className:l,children:c}):(0,X.jsx)(`div`,{className:l,children:c})}var HY=(0,J.createContext)(`session`),UY={blockquote({children:e}){return(0,X.jsx)(`blockquote`,{className:`text-dim my-2 border-l-2 border-primary pl-3 italic`,children:e})},pre({children:e,className:t,...n}){return(0,X.jsx)(`pre`,{...n,className:Q(`whitespace-pre-wrap break-words`,t),children:e})},img({alt:e,src:t}){let n=t??``;return n.startsWith(`/`)?(0,X.jsxs)(`div`,{className:`my-2 px-3 py-2 font-mono text-[10px]`,style:{background:`var(--stipe-surface-selected)`,border:`1px solid var(--color-base-300)`},children:[(0,X.jsx)(`span`,{className:`text-dim`,children:e??`Generated image`}),(0,X.jsx)(`span`,{className:`text-dim mx-2`,children:`·`}),(0,X.jsx)(`span`,{style:{color:`var(--color-base-content)`},children:n})]}):(0,X.jsx)(`img`,{alt:e??`Image`,className:`my-2 max-w-full`,src:n,style:{maxHeight:400}})},strong({children:e}){return(0,X.jsx)(`strong`,{className:`font-semibold text-primary`,children:e})},table({children:e}){return(0,X.jsx)(`table`,{className:`my-2 w-full border-collapse text-xs`,children:e})},thead({children:e}){return(0,X.jsx)(`thead`,{style:{background:`var(--stipe-surface-selected)`},children:e})},th({children:e}){return(0,X.jsx)(`th`,{className:`border px-3 py-2 text-left font-semibold`,style:{borderColor:`var(--color-base-300)`},children:e})},td({children:e}){return(0,X.jsx)(`td`,{className:`border px-3 py-2`,style:{borderColor:`var(--color-base-300)`},children:e})},tr({children:e}){return(0,X.jsx)(`tr`,{children:e})},tbody({children:e}){return(0,X.jsx)(`tbody`,{children:e})}};function WY({children:e,policy:t}){let n=(0,J.useContext)(HY);return(0,X.jsx)(VY,{className:`markdown-renderer`,components:UY,frontmatter:!1,policy:(t??n)===`visitor`?`visitor`:`default`,typography:`inherit`,children:e})}var GY=(0,J.memo)(function({thinking:e}){let[t,n]=(0,J.useState)(!1);return(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`button`,{"aria-expanded":t,className:`flex h-8 w-full items-center gap-2 px-3 text-left text-[10px] uppercase tracking-wider transition-colors`,onClick:()=>{n(e=>!e)},style:{color:`var(--stipe-fg-muted)`,fontFamily:`var(--font-sans)`,fontStyle:`italic`},type:`button`,children:[`Thoughts`,(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`btn btn-circle btn-ghost btn-xs ml-auto text-dim`,style:{transform:t?`rotate(90deg)`:`rotate(0deg)`},children:(0,X.jsx)(nW,{size:12})})]}),t?(0,X.jsx)(`div`,{className:`max-w-[80ch] break-words px-3 pb-2 text-[11px]`,style:{color:`var(--stipe-fg-muted)`,fontFamily:`var(--font-sans)`,fontStyle:`italic`},children:(0,X.jsx)(WY,{children:e})}):null]})});function KY({pending:e}){return e?(0,X.jsx)(`span`,{className:`sr-only`,role:`status`,children:`Sending`}):null}function qY({children:e,isError:t,pending:n,speaker:r,thinking:i,markdownPolicy:a}){let o=(0,X.jsx)(WY,{policy:a,children:e});if(r===`user`)return(0,X.jsxs)(`div`,{className:`px-3 py-2 transition-opacity motion-reduce:transition-none ${n?`opacity-50`:``}`,"data-pending":n?`true`:void 0,"data-speaker":`user`,style:{background:`var(--stipe-surface)`,borderLeft:`3px solid var(--color-primary)`},children:[(0,X.jsx)(KY,{pending:n}),(0,X.jsx)(`div`,{className:`message-body text-base-content`,children:o})]});let s=e.trim().length>0;return!s&&!i?null:(0,X.jsxs)(`div`,{"data-speaker":`agent`,"data-pending":n?`true`:void 0,children:[i?(0,X.jsx)(GY,{thinking:i}):null,s?(0,X.jsx)(`div`,{className:`px-3 py-2 ${t?`text-error`:`text-base-content`}`,children:o}):null]})}var JY=db(`badge caps-badge`,{variants:{tone:{neutral:`badge-neutral`,primary:`badge-primary`,secondary:`badge-secondary`,accent:`badge-accent`,success:`badge-success`,info:`badge-info`,warning:`badge-warning`,error:`badge-error`},size:{sm:`badge-sm`,default:`badge-md`,lg:`badge-lg`},variant:{solid:``,quiet:`caps-badge-quiet`}},defaultVariants:{tone:`neutral`,size:`default`}}),YY=(0,J.forwardRef)(function({className:e,size:t,tone:n,variant:r,...i},a){return(0,X.jsx)(`span`,{...i,className:Q(JY({size:t,tone:n,variant:r}),e),ref:a})}),XY={add:`+`,context:` `,file:``,hunk:`@@`,remove:`-`};function ZY({lines:e,hiddenLines:t=0,className:n,...r}){return(0,X.jsxs)(`pre`,{...r,className:Q(`caps-diff`,n),children:[e.map((e,t)=>(0,X.jsxs)(`span`,{className:`caps-diff-line`,"data-kind":e.kind,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`caps-diff-marker`,children:XY[e.kind]}),e.text,`
|
|
173
173
|
`]},`${String(t)}:${e.kind}`)),t>0?(0,X.jsxs)(`span`,{className:`caps-diff-line`,"data-kind":`more`,children:[`… `,String(t),` more lines`]}):null]})}var QY=1e4;function $Y({className:e,content:t,header:n,hideCopy:r,language:i,maxHeight:a=`320px`,style:o}){let[s,c]=(0,J.useState)(`idle`),l=async()=>{try{await navigator.clipboard.writeText(t),c(`copied`),setTimeout(()=>{c(`idle`)},1500)}catch(e){kN(`copy code to clipboard`,e),c(`failed`)}},u=i&&t.length<=QY?FY(t,i):null,d={background:`var(--stipe-surface)`,border:`1px solid var(--color-base-300)`,color:`var(--color-base-content)`,...o};return(0,X.jsxs)(`div`,{className:`relative not-prose ${e??``}`,style:d,children:[n?(0,X.jsx)(`div`,{className:`text-dim px-2 pt-1.5 pb-1 text-[9px] uppercase tracking-wider`,children:n}):null,r?null:(0,X.jsx)(LG,{"aria-label":`Copy to clipboard`,className:`absolute top-1 right-1 z-10`,icon:s===`copied`?(0,X.jsx)(eW,{}):(0,X.jsx)(rW,{}),onClick:()=>{l()},type:`button`}),r?null:(0,X.jsx)(`span`,{"aria-live":`polite`,className:`sr-only`,role:`status`,children:s===`failed`?`Copy to clipboard failed.`:null}),(0,X.jsx)(`div`,{className:`overflow-y-auto text-[10px]`,"data-scrollable":!0,style:{maxHeight:a===`0`?void 0:a,padding:`6px 4px`},children:u===null?(0,X.jsxs)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-base-content`,style:{margin:0},children:[t,t.length>QY?(0,X.jsx)(`span`,{className:`text-dim ml-2 italic`,children:`(syntax highlighting skipped for very long content)`}):null]}):(0,X.jsx)(`div`,{dangerouslySetInnerHTML:{__html:u}})})]})}function eX(e,t,n){return n||e.length<=t?{shown:e,hidden:0}:{shown:e.slice(0,t),hidden:e.length-t}}function tX({hidden:e,onShowAll:t}){return e===0?null:(0,X.jsxs)(`button`,{className:`btn btn-ghost btn-xs text-dim`,onClick:t,type:`button`,children:[`Show `,String(e),` more lines`]})}var nX=`not-prose m-0 overflow-x-auto rounded-lg border border-base-300 bg-base-200 px-sm py-xs font-mono text-[10px] leading-relaxed`;function rX({section:e,full:t,onShowAll:n}){switch(e.kind){case`diff`:{let{shown:r,hidden:i}=eX(e.lines,e.preview,t);return(0,X.jsxs)(`div`,{className:`not-prose`,children:[(0,X.jsx)(ZY,{hiddenLines:0,lines:r}),(0,X.jsx)(tX,{hidden:i,onShowAll:n})]})}case`excerpt`:{let{shown:r,hidden:i}=eX(e.lines,e.preview,t);return(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`pre`,{className:nX,"data-parakeet-section":`excerpt`,children:r.map((e,t)=>(0,X.jsxs)(`span`,{className:`block whitespace-pre`,children:[e.number===void 0?null:(0,X.jsx)(`span`,{className:`text-dim mr-sm inline-block w-8 select-none text-right`,children:String(e.number)}),e.text]},String(t)))}),(0,X.jsx)(tX,{hidden:i,onShowAll:n})]})}case`matches`:{let{shown:r,hidden:i}=eX(e.matches,e.preview,t);return(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`pre`,{className:nX,"data-parakeet-section":`matches`,children:r.map((e,t)=>(0,X.jsxs)(`span`,{className:`block whitespace-pre`,children:[e.location===``?null:(0,X.jsx)(`span`,{className:`text-info mr-sm`,children:e.location}),e.text]},String(t)))}),(0,X.jsx)(tX,{hidden:i,onShowAll:n})]})}case`command`:case`script`:{let{shown:r,hidden:i}=eX(e.lines,e.preview,t);return(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`pre`,{className:nX,"data-parakeet-section":e.kind,children:r.map((t,n)=>(0,X.jsxs)(`span`,{className:`block whitespace-pre`,children:[e.kind===`command`&&n===0?(0,X.jsx)(`span`,{className:`text-dim select-none`,children:`$ `}):null,t]},String(n)))}),(0,X.jsx)(tX,{hidden:i,onShowAll:n})]})}case`output`:{let{shown:r,hidden:i}=eX(e.lines,e.preview,t);return(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`pre`,{className:nX,"data-parakeet-section":`output`,children:r.map((e,t)=>(0,X.jsxs)(`span`,{className:e.stream===`stderr`?`block whitespace-pre text-error`:`block whitespace-pre`,"data-stream":e.stream,children:[e.stream===`stderr`?(0,X.jsx)(`span`,{className:`select-none`,children:`▍`}):null,e.text]},String(t)))}),(0,X.jsx)(tX,{hidden:i,onShowAll:n})]})}case`text`:{let{shown:r,hidden:i}=eX(e.lines,e.preview,t);return(0,X.jsxs)(`div`,{children:[(0,X.jsx)($Y,{className:`overflow-hidden rounded-lg`,content:r.join(`
|
|
174
|
-
`),header:e.label,...e.language===void 0?{}:{language:e.language}}),(0,X.jsx)(tX,{hidden:i,onShowAll:n})]})}}}function iX({call:e,tool:t,disclosure:n,onToggle:r,mediaClaimed:i}){let a=`${e.id}:full`,o=FP(n,a,!1),s=()=>{r(a,!1)};return(0,X.jsxs)(`div`,{className:`space-y-1.5 py-1.5 pr-2`,"data-parakeet-call-body":!0,children:[e.error===void 0?null:(0,X.jsx)(`p`,{className:`not-prose m-0 font-mono text-[11px] text-error`,role:`alert`,children:e.error}),e.sections.map((e,t)=>(0,X.jsx)(rX,{full:o,onShowAll:s,section:e},`${e.kind}:${String(t)}`)),(i?[]:t?.result?.content??[]).filter(e=>e.type===`image`).map((t,n)=>(0,X.jsx)(`img`,{alt:`Tool result`,className:`max-w-full`,src:`data:${t.mimeType};base64,${t.data}`,style:{maxHeight:400}},`${e.id}-image-${String(n)}`))]})}function aX({call:e,tool:t,disclosureId:n,size:r,disclosure:i,onToggle:a,renderToolActions:o,claimsToolMedia:s}){let c=PP(e),l=FP(i,n,c),u=e.status===`running`;return(0,X.jsxs)(`div`,{"data-parakeet-call":e.kind,"data-status":e.status,children:[(0,X.jsx)(IK,{leading:(0,X.jsx)(Xq,{name:jN[e.kind],size:16}),onOpenChange:()=>{a(n,c)},open:l,size:r,summary:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`text-base-content`,children:u?e.activeVerb:e.verb}),` `,(0,X.jsx)(`span`,{className:`font-mono`,children:e.label})]}),tone:e.status===`error`?`error`:`neutral`,trailing:(0,X.jsxs)(X.Fragment,{children:[e.exitCode===void 0?null:(0,X.jsxs)(YY,{size:`sm`,tone:`error`,children:[`exit `,String(e.exitCode)]}),e.durationMs===void 0?null:(0,X.jsx)(`span`,{children:CP(e.durationMs)}),(0,X.jsx)(FG,{motion:u?`bounce`:`none`,title:e.status===`unknown`?`result unavailable`:e.status,tone:AN(e.status)})]}),children:(0,X.jsx)(iX,{call:e,disclosure:i,onToggle:a,mediaClaimed:t!==void 0&&s?.(t)===!0,tool:t})}),e.live===void 0?null:(0,X.jsx)(`pre`,{className:nX,"aria-label":`Live tool output`,children:NN(e,l).map((e,t)=>(0,X.jsx)(`span`,{className:`block whitespace-pre`,children:e||`\xA0`},String(t)))}),e.status===`completed`&&t?.result!==void 0?o?.(t):null]})}var oX=(0,J.memo)(function({group:e,disclosure:t,onToggle:n,renderToolActions:r,claimsToolMedia:i}){let a=MP(e),o=FP(t,e.id,a),s=e.status===`running`,c=e.active,l=e.calls.length===1?e.calls[0]:void 0;return l===void 0?(0,X.jsxs)(`div`,{className:`px-1`,children:[(0,X.jsx)(IK,{className:`[&>.caps-disclosure-panel]:hidden`,leading:(0,X.jsx)(Xq,{name:`list`,size:16}),onOpenChange:()=>{n(e.id,a)},open:o,summary:s&&c!==void 0?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`text-base-content`,children:c.activeVerb}),` `,(0,X.jsx)(`span`,{className:`font-mono`,children:c.label}),` ·`,` `,String(e.calls.length),` `,e.calls.length===1?`call`:`calls`]}):(0,X.jsxs)(`span`,{className:`text-base-content`,children:[e.summary,` · `,String(e.calls.length),` `,e.calls.length===1?`call`:`calls`]}),tone:e.status===`error`?`error`:`neutral`,trailing:(0,X.jsxs)(X.Fragment,{children:[e.failedCount>0?(0,X.jsxs)(`span`,{className:`text-error`,children:[String(e.failedCount),` failed`]}):null,e.durationMs===void 0?null:(0,X.jsx)(`span`,{children:CP(e.durationMs)}),(0,X.jsx)(FG,{motion:s?`bounce`:`none`,title:e.status===`unknown`?`result unavailable`:e.status,tone:AN(e.status)})]})}),NP(e,o).map(a=>(0,X.jsx)(aX,{call:a,disclosure:t,disclosureId:a.id,onToggle:n,renderToolActions:r,claimsToolMedia:i,size:`row`,tool:e.tools.find(e=>e.id===a.id)},a.id)),e.status===`completed`&&e.calls.length>3?(0,X.jsx)(`button`,{"aria-expanded":o,className:`btn btn-ghost btn-xs text-dim`,onClick:()=>{n(e.id,a)},type:`button`,children:o?`Show less`:`Show all ${String(e.calls.length)} calls`}):null]}):(0,X.jsx)(`div`,{className:`px-1`,children:(0,X.jsx)(aX,{call:l,disclosure:t,disclosureId:l.id,onToggle:n,renderToolActions:r,claimsToolMedia:i,size:`row`,tool:e.tools[0]})})}),sX=()=>void 0,cX={nothing_to_compact:`nothing to compact`,failed:`compaction failed`,stale:`compaction skipped: the context moved on`,insufficient:`compaction skipped: the summary would not fit`},lX=(0,J.memo)(function({item:e,onDismissFailed:t,onCancelQueued:n,cancellingQueued:r=!1,renderToolActions:i,claimsToolMedia:a,renderAssistantAttachment:o,formatAssistantText:s,toolDisclosure:c=jP,onToggleTool:l=sX}){switch(e.kind){case`user_message`:{let i=e.status===`pending`||e.status===`queued`,a=e.requestId,o=e.commandId,s=e.status===`queued`&&o!==void 0&&n!==void 0?(0,X.jsx)(`div`,{className:`flex justify-end px-3`,children:(0,X.jsx)(BT,{"aria-label":`Cancel queued message`,disabled:r,size:`sm`,variant:`ghost`,onClick:()=>{n(o)},children:`Cancel`})}):null,u=a===void 0||t===void 0?null:(0,X.jsx)(BT,{"aria-label":`Dismiss failed prompt`,variant:`outline`,size:`xs`,onClick:()=>{t(a)},type:`button`,children:`Dismiss`}),d=e.status===`failed`?(0,X.jsxs)(`div`,{className:`flex items-center gap-2 px-3 text-xs text-error`,role:`alert`,children:[(0,X.jsx)(`span`,{children:e.author?.kind===`agent`?`That Agent message didn’t make it through.`:`Your prompt didn’t make it through.`}),u]}):null;if(e.author?.kind===`agent`){let t=FP(c,e.id,!1);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:e.status===`confirmed`?`px-3 text-xs`:`px-3 text-xs opacity-60`,"data-agent-message":e.author.id,"data-author":e.author.id,children:[(0,X.jsx)(KY,{pending:i}),(0,X.jsxs)(`button`,{"aria-expanded":t,className:`text-dim flex w-full min-w-0 items-center gap-sm text-left`,onClick:()=>{l(e.id,!1)},type:`button`,children:[(0,X.jsx)(`span`,{className:`flex shrink-0`,children:(0,X.jsx)(Xq,{name:`agent`,size:16})}),(0,X.jsx)(`span`,{className:`shrink-0`,children:e.author.name}),t?null:(0,X.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`· `,e.text]})]}),t?(0,X.jsx)(`div`,{className:`whitespace-pre-wrap break-words pl-3`,children:e.text}):null]}),d,s]})}return(0,X.jsxs)(X.Fragment,{children:[e.author?(0,X.jsx)(`div`,{className:`px-3 text-xs text-dim`,"data-author":e.author.id,children:e.author.name}):null,(0,X.jsx)(qY,{pending:i,speaker:`user`,children:e.text}),d,s]})}case`assistant_message`:return MM(e)?(0,X.jsxs)(X.Fragment,{children:[e.author?(0,X.jsx)(`div`,{className:`px-3 text-xs text-dim`,"data-author":e.author.id,children:e.author.name}):null,(0,X.jsx)(qY,{isError:e.isError===!0,pending:e.pending,speaker:`agent`,...e.thinking?{thinking:e.thinking}:{},children:s?.(e.text)??e.text}),e.isError&&e.repeatCount!==void 0?(0,X.jsxs)(`span`,{className:`px-3 text-error`,children:[`x`,e.repeatCount]}):null,e.isError&&e.errorDetail?(0,X.jsx)(`p`,{className:`px-3 text-dim`,children:e.errorDetail}):null,e.isError&&e.providerError!==void 0?(0,X.jsx)(`div`,{className:`px-3 text-error`,"data-provider-error":e.id,children:(0,X.jsxs)(`details`,{children:[(0,X.jsx)(`summary`,{children:`Provider details (latest response)`}),(0,X.jsx)(`pre`,{className:`whitespace-pre-wrap`,children:e.providerError})]})}):null,!e.pending&&!e.isError?o?.(e.text):null]}):null;case`tool_group`:return(0,X.jsx)(oX,{disclosure:c,group:e,onToggle:l,renderToolActions:i,claimsToolMedia:a});case`compaction_divider`:return(0,X.jsx)(`div`,{className:`divider text-dim my-2 text-xs`,role:`separator`,children:e.tokensAfter===null?`compacted · the agent’s memory starts below`:`compacted ${NA(e.tokensBefore)} → ${NA(e.tokensAfter)}`});case`compaction_notice`:return(0,X.jsxs)(`div`,{className:`px-3 text-xs ${e.result===`failed`?`text-error`:`text-dim`}`,role:`status`,children:[`· `,cX[e.result],e.diagnostic===null?``:`: ${e.diagnostic}`]})}});function uX({disambiguateAuthors:e,visitor:t,composerActionVariant:n,empty:r,commands:i,renderToolActions:a,claimsToolMedia:o,renderAssistantAttachment:s,formatAssistantText:c,onLink:l,onOpen:u}){let d=(0,J.useRef)(null),[f]=(0,J.useState)(()=>Zr()),p=cR({enabled:t===void 0,commands:i??f,origin:`browser`,keys:{newline:`Shift+Enter`},busy:fX()}),m=iz(i??f),h=rI(),{draft:g}=QF(),_=ZL(p.awaiting,g)?.key,v=ZF(),y=(0,J.useMemo)(()=>cz(h,v.commandAnchors,v.positionAnchors),[h,v.commandAnchors,v.positionAnchors]);return(0,X.jsxs)(`div`,{className:`parakeet flex h-full flex-col items-stretch`,"data-parakeet":`standalone`,"data-testid":`parakeet-view`,onClickCapture:e=>{let t=e.target instanceof Element?e.target.closest(`a[href]`):null;t instanceof HTMLAnchorElement&&l?.(t.href)&&e.preventDefault()},children:[(0,X.jsxs)(`div`,{className:`flex h-full w-full flex-col border-r border-base-300`,children:[(0,X.jsx)(mX,{disambiguateAuthors:t===void 0&&e===!0,clientActions:m,onOpen:u,focusAfterJump:d,empty:r,renderToolActions:a,claimsToolMedia:o,renderAssistantAttachment:s,formatAssistantText:c}),h.some(({entryId:e,value:t})=>t.panel.some(t=>JSON.stringify([e,t.id])!==_))?(0,X.jsx)(`section`,{"aria-label":`Session extension controls`,className:`w-full shrink-0 border-t border-base-300 bg-base-100`,children:h.map(({entryId:e,value:t})=>{let n={...t,panel:t.panel.filter(t=>JSON.stringify([e,t.id])!==_)},r=n.panel.length===0?void 0:y.omitted.find(t=>t.entryId===e),i=n.panel.length===0?[]:y.unanchored.filter(t=>t.entryId===e).flatMap(({cell:e})=>e.rows.map(t=>({...t,id:`unanchored:${e.id}:${t.id}`})));return(0,X.jsx)(Sq,{entryId:e,rows:[...n.panel,...r===void 0?[]:[{id:`omitted:${e}`,title:`${String(r.count)} earlier change${r.count===1?``:`s`} omitted`,tone:`muted`}],...i],actions:m,onOpen:u},e)})}):null,(0,X.jsx)(hX,{clientActions:m}),(0,X.jsx)(gX,{visitor:t,textareaRef:d,composerActionVariant:n,slash:p})]}),t===void 0?(0,X.jsx)(pX,{slash:p}):null]})}var dX=new Set([`cancelling`,`queued`,`retrying`,`sending`,`streaming`,`thinking`]);function fX(){return dX.has(nI().status)}function pX({slash:e}){let t=e.interactions.open;return(0,X.jsx)(IU,{open:t!==void 0,onOpenChange:t=>{t||e.store.close()},children:(0,X.jsx)(VU,{className:`w-[min(32rem,calc(100vw-2rem))] rounded-box bg-base-100 p-md shadow-lg`,keepMounted:!1,children:t===void 0?null:(0,X.jsx)(rq,{host:t.host,onClose:e.store.close},t.key)})})}function mX({disambiguateAuthors:e,clientActions:t,onOpen:n,focusAfterJump:r,empty:i,renderToolActions:a,claimsToolMedia:o,renderAssistantAttachment:s,formatAssistantText:c}){let l=$F(),u=ZF(),d=(0,J.useCallback)(e=>{u.cancelQueued(e)},[u.cancelQueued]),f=(0,J.useMemo)(()=>BA(e?[...u.settled,...u.tail].flatMap(e=>`author`in e&&e.author?[e.author]:[]):[]),[e,u.settled,u.tail]),p=cz(rI(),u.commandAnchors,u.positionAnchors),m=p.before.map(({entryId:e,cell:r})=>(0,X.jsx)(Sq,{entryId:e,rows:r.rows,actions:t,onOpen:n},`${e}:${r.id}`)),[h,g]=(0,J.useState)(jP),_=(0,J.useCallback)((e,t)=>{g(n=>IP(n,e,t))},[]),v=nI(),y=(0,J.useRef)(null),b=(0,J.useRef)(void 0),x=u.settled.length+u.tail.length,S=(0,J.useCallback)(e=>e<u.settled.length?u.settled[e]:u.tail[e-u.settled.length],[u.settled,u.tail]),C=GW({anchorTo:`end`,count:x,estimateSize:()=>72,followOnAppend:`auto`,getItemKey:JW(u.settled,u.tail),getScrollElement:()=>y.current,initialRect:{height:800,width:800},overscan:6,useFlushSync:!1}),w=C.getVirtualItems(),T=C.isAtEnd(),[E,D]=(0,J.useState)(0),O=x>0?S(x-1)?.id:void 0,k=(0,J.useRef)({count:x,lastItem:O});(0,J.useEffect)(()=>{let e=k.current;k.current={count:x,lastItem:O},T?D(0):e.lastItem!==void 0&&O!==e.lastItem&&D(t=>t+Math.max(1,x-e.count))},[T,x,O]);let A=(w[0]?.index??1/0)<3,{hasMoreHistory:j,hasNewerHistory:M,loadingOlderHistory:N,loadOlderHistory:P,loadNewerHistory:F}=u,I=(0,J.useRef)(!1);(0,J.useEffect)(()=>{if(!A){I.current=!1;return}j&&!N&&!I.current&&(I.current=!0,P())},[j,P,N,A]);let L=(0,J.useCallback)(()=>{D(0),b.current=void 0,u.jumpToLatest(),C.scrollToEnd({behavior:`smooth`})},[C,u]);return(0,X.jsxs)(`div`,{className:`prose relative min-h-0 flex-1`,children:[(0,X.jsx)(`div`,{"aria-live":`polite`,"aria-atomic":`true`,className:`sr-only`,children:hq(v.status,v.viewState)}),v.observation.status===`unavailable`?(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-1 text-xs text-dim`,role:`status`,children:[(0,X.jsx)(`span`,{children:v.observation.reason}),(0,X.jsx)(BT,{variant:`outline`,size:`xs`,onClick:()=>void v.reconnect(),type:`button`,children:`Reconnect`})]}):null,(0,X.jsx)(`div`,{className:`h-full min-h-0 overflow-y-auto`,"data-chat-scroller":!0,ref:y,onScroll:e=>{let t=e.currentTarget.scrollTop;b.current!==void 0&&t<b.current&&u.pinVisibleHistory(),b.current=t},onWheel:e=>{let t=y.current;t===null||N||(e.deltaY<0&&u.pinVisibleHistory(),e.deltaY<0&&t.scrollTop<=1&&j&&P(),e.deltaY>0&&t.scrollTop+t.clientHeight>=t.scrollHeight-1&&M&&F())},style:{overscrollBehavior:`contain`},children:x>0?(0,X.jsx)(`div`,{className:`relative w-full`,style:{height:`${String(C.getTotalSize())}px`},children:w.map(e=>{let r=S(e.index);return r===void 0?null:(0,X.jsxs)(`div`,{"data-index":e.index,"data-parakeet-entry":r.kind===`user_message`?`user`:r.kind,"data-parakeet-id":r.id,"data-status":r.kind===`assistant_message`?r.isError?`error`:void 0:r.kind===`compaction_divider`||r.kind===`compaction_notice`?void 0:r.status,"data-tone":r.kind===`assistant_message`&&r.isError?`error`:void 0,ref:C.measureElement,style:{left:0,position:`absolute`,top:0,transform:`translateY(${String(e.start)}px)`,width:`100%`},children:[e.index===0?m:null,(0,X.jsx)(lX,{item:`author`in r&&r.author&&f.has(r.author.id)?{...r,author:{...r.author,name:f.get(r.author.id)??r.author.name}}:r,onDismissFailed:l,onCancelQueued:d,cancellingQueued:u.cancellingQueued,onToggleTool:_,renderToolActions:a,claimsToolMedia:o,renderAssistantAttachment:s,formatAssistantText:c,toolDisclosure:h}),p.after.get(r.id)?.map(({entryId:e,cell:r})=>(0,X.jsx)(Sq,{entryId:e,rows:r.rows,actions:t,onOpen:n},`${e}:${r.id}`))]},e.key)})}):m.length>0?m:j?null:i??(0,X.jsx)(`div`,{className:`flex h-full items-center justify-center text-center`,children:(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`mb-1 text-xs text-base-content`,children:`Ready`}),(0,X.jsx)(`p`,{className:`text-[10px] text-dim`,children:`What would you like to build?`})]})})}),x>0?(0,X.jsx)(xW,{direction:`forward`,unread:E,focusAfterJump:r,onJump:L,scrollerRef:y}):null]})}function hX({clientActions:e}){let{viewState:t}=nI(),n=rI(),r=t.kind===`idle`?n.find(({value:e})=>e.waiting!==null):void 0;return(0,X.jsx)(X.Fragment,{children:r?.value.waiting===void 0||r.value.waiting===null?null:(0,X.jsxs)(`div`,{className:`flex items-center gap-2 px-3 text-xs`,children:[(0,X.jsx)(`span`,{children:r.value.waiting.summary}),(0,X.jsx)(BT,{size:`xs`,variant:`outline`,disabled:!e.enabled||e.state.get(r.value.waiting.cancel)?.pending===!0,onClick:()=>{r.value.waiting!==null&&e.execute(r.entryId,r.value.waiting.cancel,!0)},children:r.value.waiting.cancel.label})]})})}function gX({visitor:e,textareaRef:t,composerActionVariant:n,slash:r}){let i=QF(),a=nI(),o=rI(),s=ZF();(0,J.useEffect)(()=>{i.failure!==void 0&&t.current?.focus()},[i.failure,t]);let c=(0,J.useCallback)(()=>{i.cancel()},[i.cancel]),l={queuedRecall:e===void 0?i:void 0,onImagesChange:e===void 0?i.setImages:void 0,statusChips:o.flatMap(({value:e})=>e.chips).sort((e,t)=>e.order-t.order).map(({row:e})=>e.title),actionVariant:n,draft:i.draft,failure:i.failure,failureCause:a.viewState.kind===`error`?a.viewState.cause:void 0,admissionError:i.admissionError,onAbort:c,onChange:i.setDraft,onRetry:i.retry,onSend:r.submit,slash:e===void 0?r:void 0,placeholder:e===void 0?void 0:`Ask ${e.agentName}…`,showFooter:e===void 0,status:a.status,viewState:a.viewState,textareaRef:t,model:s.model,usage:s.usage,context:a.context};return(0,X.jsx)(bq,{...l})}function _X({authorOf:e,disambiguateAuthors:t,visitor:n,markdownPolicy:r=`session`,composerActionVariant:i,empty:a,session:o,clients:s,renderToolActions:c,claimsToolMedia:l,renderAssistantAttachment:u,formatAssistantText:d,commands:f,onLink:p,onOpen:m}){return(0,X.jsx)(HY.Provider,{value:r,children:(0,X.jsx)(XF,{session:o,clients:s,authorOf:e,children:(0,X.jsx)(uX,{disambiguateAuthors:t,visitor:n,composerActionVariant:i,empty:a,renderToolActions:c,claimsToolMedia:l,renderAssistantAttachment:u,formatAssistantText:d,commands:f,onLink:p,onOpen:m})})})}function vX(e){let t=2166136261;for(let n of e)t^=n.codePointAt(0)??0,t=Math.imul(t,16777619)>>>0;return t}var yX=[`primary`,`secondary`,`accent`,`info`,`success`,`warning`];function bX(e){return yX[vX(e)%yX.length]??`primary`}var xX=(0,J.forwardRef)(function({className:e,name:t,seed:n,size:r=`default`,subject:i=`actor`,variant:a=`initial`,...o},s){let c=Array.from(t.trim())[0]?.toLocaleUpperCase()??`?`;return(0,X.jsx)(`span`,{"aria-hidden":`true`,...o,className:Q(`caps-monogram`,e),"data-subject":i===`actor`?void 0:i,"data-size":r==="default"?void 0:r,"data-tone":bX(n??t),ref:s,children:a===`specimen`?(0,X.jsx)(`svg`,{viewBox:`0 0 48 48`,width:`80%`,height:`80%`,fill:`none`,"aria-hidden":`true`,children:(0,X.jsxs)(`g`,{transform:`rotate(${String((n??t).split(``).reduce((e,t)=>e+(t.codePointAt(0)??0),0)%360)} 24 24)`,stroke:`currentColor`,strokeWidth:`1.5`,children:[Array.from({length:20},(e,t)=>(0,X.jsx)(`path`,{d:`M24 19 Q19 12 24 5`,transform:`rotate(${String(t*18)} 24 24)`},t)),(0,X.jsx)(`circle`,{cx:`24`,cy:`24`,r:`5`})]})}):c})}),SX=(0,J.createContext)(null),CX=(0,J.createContext)(void 0);function wX(e){let t=(0,J.useContext)(CX);return e??t}var TX=(0,J.forwardRef)(function({service:e,src:t,activity:n,expression:r,appearance:i,renderStyle:a,performance:o,timeMs:s,paused:c=!1,onState:l,...u},d){let f=wX(s),p=f!==void 0,m=(0,J.useContext)(SX),h=e??m;if(!h)throw Error(`Sprite needs a configured SpriteProvider or service`);let g=(0,J.useRef)(null),_=(0,J.useRef)(null),v=(0,J.useRef)(l);return v.current=l,(0,J.useImperativeHandle)(d,()=>{if(!g.current)throw Error(`Sprite host is not mounted`);return g.current}),(0,J.useEffect)(()=>{if(!g.current)return;let e=h.mount(g.current),t=e.subscribe(e=>{g.current&&(g.current.dataset.spriteStatus=e.status),v.current?.(e)});return _.current=e,()=>{t(),e.dispose().catch(e=>{console.error(`Sprite cleanup failed`,e)}),_.current=null}},[h]),(0,J.useEffect)(()=>{let e=_.current;if(!e)return;let s={src:t};n!==void 0&&(s={...s,activity:n}),r!==void 0&&(s={...s,expression:r}),i!==void 0&&(s={...s,appearance:i}),a!==void 0&&(s={...s,renderStyle:a}),o!==void 0&&(s={...s,performance:o}),f!==void 0&&(s={...s,timeMs:f}),e.set(s)},[h,t,n,r,i,a,o,f]),(0,J.useEffect)(()=>{_.current?.pause(c||p)},[h,c,p]),(0,X.jsx)(`div`,{...u,ref:g})});function EX(e){return{src:{local:e.character},appearance:e.appearance,expression:e.expression,renderStyle:e.renderStyle}}function DX(e){for(let[t,n]of Object.entries({maxBytes:e.maxBytes,maxTotalBytes:e.maxTotalBytes,maxRequests:e.maxRequests}))if(!Number.isSafeInteger(n)||n<=0)throw Error(`Avatar ${t} must be a positive safe integer`);let t=new Set(e.allowedOrigins.map(e=>new URL(e).origin)),n=e.fetch??globalThis.fetch;return()=>{let r=0,i=0;return async(a,o,s=e.baseURL)=>{let c=new URL(a,s);if(![`http:`,`https:`].includes(c.protocol)||!t.has(c.origin)||c.username||c.password)throw Error(`Avatar asset is not admitted: ${c.origin}`);if(i+=1,i>e.maxRequests)throw Error(`Avatar asset request limit reached`);let l=await n(c.href,{signal:o,redirect:`error`});if(!l.ok)throw Error(`Avatar asset request failed: ${String(l.status)}`);let u=Number(l.headers.get(`content-length`));if(u>e.maxBytes||u>e.maxTotalBytes-r)throw await l.body?.cancel(),Error(`Avatar asset exceeds the byte limit`);let d=l.body?.getReader();if(!d)throw Error(`Avatar asset has no response body`);let f=[],p=0;try{for(;;){o.throwIfAborted();let t=await d.read();if(t.done)break;if(p+=t.value.byteLength,p>e.maxBytes)throw Error(`Avatar asset exceeds the byte limit`);if(t.value.byteLength>e.maxTotalBytes-r)throw Error(`Avatar selection exceeds the total byte limit`);r+=t.value.byteLength,f.push(t.value)}}catch(e){let t=await d.cancel().then(()=>({kind:`cancelled`}),e=>({kind:`failed`,error:e instanceof Error?e:Error(String(e))}));throw t.kind===`failed`?AggregateError([e,t.error],`Avatar asset read and cancellation failed`,{cause:e}):e}finally{d.releaseLock()}let m=new Uint8Array(p),h=0;for(let e of f)m.set(e,h),h+=e.byteLength;return{url:c.href,bytes:m,contentType:l.headers.get(`content-type`)??`application/octet-stream`}}}}var OX=(e,t)=>{let n=ir.safeParse(e);return n.success?{kind:`local`,key:n.data.local}:{kind:`remote`,url:new URL(V().parse(e),t).href}},kX=e=>e instanceof Error?e:Error(String(e),{cause:e}),AX=e=>Sn(e)?kX(vt(e.cause)):Error(`Unexpected Sprite success`);function jX(e){let t=e.maxPixels??4194304;if(!Number.isSafeInteger(t)||t<=0)throw Error(`Sprite pixel limit must be a positive safe integer`);let n=e.assets??{baseURL:`https://sprite.invalid/`,allowedOrigins:[],maxBytes:1,maxTotalBytes:1,maxRequests:1},r=DX(n),i=new WeakSet,a=new WeakMap,o=e=>{let t=OX(e,n.baseURL);return t.kind===`remote`?t.url:`local:${t.key}`};return{mount(s){if(i.has(s))throw Error(`A Sprite already owns this target`);i.add(s);let c=_e(ln()),l=new Set,u={status:`empty`},d,f,p=0,m=!1,h,g,_,v=!1,y=!1,b=s.ownerDocument.defaultView?.matchMedia(`(prefers-reduced-motion: reduce)`),x=e=>{if(!(v&&e.status!==`destroyed`)){u=e;for(let t of l)try{t(e)}catch(e){console.error(`Sprite state observer failed`,e)}}},S=e=>{f?.controller.abort(),f?.holder.remove(),x({status:`error`,error:e}),T().catch(t=>{x({status:`error`,error:AggregateError([e,t],`Avatar failed and cleanup also failed`)})})},C=Fh(s),w=()=>{let e=y||s.ownerDocument.hidden||b?.matches===!0;C.still(e);try{f?.native?.pause(e)}catch(e){S(kX(e))}};_e(Rn(c,ze(()=>{s.ownerDocument.removeEventListener(`visibilitychange`,w),b?.removeEventListener(`change`,w),C.dispose()}))),s.ownerDocument.addEventListener(`visibilitychange`,w),b?.addEventListener(`change`,w);let T=async()=>{if(g)return g;let e=f;if(!e)return;f=void 0,e.controller.abort(),e.holder.remove();let t=Ye(Un(e.scope,Tn)).then(e=>{if(Sn(e))throw AX(e)});g=t;try{await t}finally{g===t&&(g=void 0)}},E=e=>{let t=e.native,n=e.document,r=d;if(!t||!n||!r||f!==e)return;let i=r.activity??`idle`,a=r.expression??t.expressions[0]??null,o,s;try{o=ar(n.controls,r.appearance),s=lh.parse(r.renderStyle??`plain`)}catch(e){let t=kX(e);u.status===`ready`?u.updateError?.message!==t.message&&x({...u,updateError:t}):S(t);return}let c={requestedActivity:i,requestedExpression:a,activity:t.activities.includes(i)?i:`idle`,expression:a!==null&&t.expressions.includes(a)?a:t.expressions[0]??null,appearance:o,renderStyle:s,fallback:!t.activities.includes(i)||a!==null&&!t.expressions.includes(a)},l=r.performance===void 0?c:{...c,performance:r.performance};r.timeMs!==void 0&&(l={...l,timeMs:r.timeMs});let p=JSON.stringify([l.activity,l.expression,l.appearance,l.timeMs]);if(C.set(s,e.holder),p!==e.appliedKey||r.performance!==e.appliedPerformance||u.status!==`ready`||u.presentation.renderStyle!==s||u.updateError!==void 0||u.presentation.requestedActivity!==i||u.presentation.requestedExpression!==a)try{if((p!==e.appliedKey||r.performance!==e.appliedPerformance)&&t.set(l),e.appliedKey=p,e.appliedPerformance=r.performance,w(),f===e){let t={status:`ready`,document:n,presentation:l};x(e.progress===void 0?t:{...t,progress:e.progress})}}catch(e){S(kX(e))}},D=async(i,a,o)=>{let c=r(),l=_e(ln()),d=new AbortController,m=s.ownerDocument.createElement(`div`);m.style.cssText=`width:100%;height:100%;position:relative`;let h={key:a,scope:l,controller:d,holder:m};f=h,_e(Rn(l,ze(()=>{m.remove()}))),s.append(m);let g=Me(function*(){let r,a,o=n.baseURL,s=OX(i.src,n.baseURL);if(s.kind===`remote`){let t=yield*st({try:()=>c(s.url,d.signal),catch:kX});o=t.url,r=rr.parse(JSON.parse(new TextDecoder().decode(t.bytes)));let n=e.renderers&&Object.hasOwn(e.renderers,r.renderer)?e.renderers[r.renderer]:void 0;if(!n)throw Error(`Renderer is not installed: ${r.renderer}`);a=(yield*st({try:n,catch:kX})).default}else{let t=s.key,n=e.characters&&Object.hasOwn(e.characters,t)?e.characters[t]:void 0;if(!n)throw Error(`Character is not installed: ${t}`);let i=yield*st({try:n,catch:kX});r=rr.parse(i.document),a=i.render}d.signal.throwIfAborted();let l=yield*a({target:m,document:r,signal:d.signal,maxPixels:t,reportError:e=>{f===h&&!d.signal.aborted&&S(e)},reportProgress:e=>{f!==h||d.signal.aborted||(h.progress=e,u.status===`ready`&&x({...u,progress:e}))},assetURL:e=>Me(function*(){let t=yield*st({try:()=>c(e,d.signal,o),catch:kX});return yield*Qe(ze(()=>URL.createObjectURL(new Blob([t.bytes],{type:t.contentType}))),e=>ze(()=>{URL.revokeObjectURL(e)}))})});if(!l.activities.includes(`idle`))throw Error(`Character has no idle fallback`);return l.pause(!0),{native:l,document:r}}).pipe(Wn(l)),_=await Ye(g,{signal:d.signal});if(!(v||o!==p||f!==h)){if(Sn(_)){let e=AX(_);try{await T(),x({status:`error`,error:e})}catch(t){x({status:`error`,error:AggregateError([e,t],`Avatar load and cleanup failed`)})}return}h.native=_.value.native,h.document=_.value.document,E(h)}},O=async()=>{let e=e=>v||e!==p;for(;m&&!v;){m=!1;let t=p;if(await T(),e(t)||!d)continue;let n=await a.get(s);if(n?.kind===`failed`)throw n.error;e(t)||(x({status:`loading`}),await D(d,o(d.src),t))}},k=()=>{m=!0,f?.controller.abort(),f?.holder.remove(),!h&&(h=O().catch(e=>{x({status:`error`,error:kX(e)})}).finally(()=>{h=void 0,m&&!v&&k()}))};return{get state(){return u},subscribe(e){return l.add(e),()=>l.delete(e)},set(e){if(v)throw Error(`Sprite is destroyed`);d=e;let t=o(e.src);f?.key===t&&u.status===`ready`?E(f):(f?.key!==t||u.status===`error`)&&(p+=1,k())},pause(e){if(v)throw Error(`Sprite is destroyed`);y=e,w()},dispose(){return _||(v=!0,p+=1,i.delete(s),f?.controller.abort(),f?.holder.remove(),x({status:`destroyed`}),_=(async()=>{await h,await T();let e=await Ye(Un(c,Tn));if(Sn(e))throw AX(e)})(),a.set(s,_.then(()=>({kind:`closed`}),e=>({kind:`failed`,error:kX(e)}))),_)}}}}}var MX=jX({characters:{mushroom:async()=>(await sr(async()=>{let{default:e}=await import(`./mushroom-DWyBmJbK.js`);return{default:e}},__vite__mapDeps([6,7,2,8,1]))).default,cat:async()=>(await sr(async()=>{let{default:e}=await import(`./cat-BxITknTO.js`);return{default:e}},__vite__mapDeps([9,7,2,8,1,10]))).default,burger:async()=>(await sr(async()=>{let{default:e}=await import(`./burger-CPCRQtwa.js`);return{default:e}},__vite__mapDeps([11,7,2,8,1,10]))).default}}),NX=(0,J.memo)(function({activity:e=`idle`,avatar:t,className:n,name:r,size:i=24,timeMs:a}){let o=wX(a),[s,c]=(0,J.useState)(!1),l=(0,J.useMemo)(()=>EX(t),[t]);return(0,X.jsxs)(`span`,{"aria-hidden":`true`,className:`relative inline-block shrink-0 ${n??``}`,"data-agent-head":s?`ready`:`loading`,style:{height:i,width:i},children:[s?null:(0,X.jsx)(xX,{className:`absolute inset-0`,name:r,seed:r}),(0,X.jsx)(TX,{activity:e,...o===void 0?{}:{timeMs:o},appearance:l.appearance,className:`absolute inset-0`,expression:l.expression,onState:e=>{c(e.status===`ready`)},paused:o!==void 0||e===`idle`,renderStyle:l.renderStyle,service:MX,src:l.src})]})}),PX=(0,J.memo)(function({avatar:e,className:t=`h-12 w-12 shrink-0`,service:n=MX,state:r}){let i=(0,J.useMemo)(()=>e?EX(e):void 0,[e]);return(0,X.jsx)(TX,{"aria-hidden":`true`,className:t,service:n,src:i?.src??{local:`mushroom`},...i?{appearance:i.appearance,renderStyle:i.renderStyle}:{},...r})}),FX={needs_you:`Waiting for you`,running:`Working`,errored:`Failed`,done:`Done`},IX={needs_you:0,errored_unseen:1,running:2,recent:3};function LX(e){return e===`running`||e===`needs_you`}function RX(e,t){return e!==void 0&&(t===void 0||e>t)}function zX(e,t){switch(e){case`needs_you`:return`needs_you`;case`running`:return`running`;case`errored`:return t?`errored_unseen`:`recent`;case`done`:return`recent`}}function BX(e,t){return IX[e.tier]-IX[t.tier]||(t.settledAt??t.createdAt)-(e.settledAt??e.createdAt)||e.agentId.localeCompare(t.agentId)||e.sessionId.localeCompare(t.sessionId)}var VX=[`Needs you`,`Working`,`Ready`,`Finished`];function HX(e){return e.tier===`running`?`Working`:e.shelf===`active`?`Needs you`:e.ready?`Ready`:`Finished`}function UX(e){return{key:JX(e.agentId,e.sessionId),shelf:HX(e),attention:e.tier===`needs_you`||e.tier===`errored_unseen`?`${e.tier}:${String(e.settledAt??e.createdAt)}`:null}}function WX(e,t,n){let r=new Map(t.map(e=>[JX(e.agentId,e.sessionId),e]));if(e!==null&&n.held)return e;let i=[...t].sort((e,t)=>(t.settledAt??t.createdAt)-(e.settledAt??e.createdAt)||e.agentId.localeCompare(t.agentId)||e.sessionId.localeCompare(t.sessionId)),a=new Map(e?.map(e=>[e.key,e])),o=i.map(UX).filter(e=>{let t=a.get(e.key);return t===void 0||e.key!==n.openKey&&e.attention!==null&&e.attention!==t.attention}),s=new Set(o.map(e=>e.key)),c=a.get(n.openKey??``),l=c===void 0?-1:(e??[]).filter(e=>e.shelf===c.shelf).findIndex(e=>e.key===c.key),u=VX.flatMap(t=>{let a;a=e===null||n.reorder?i.map(UX).filter(e=>e.shelf===t):[...o.filter(e=>e.shelf===t),...e.filter(e=>e.shelf===t&&!s.has(e.key)).flatMap(e=>{let t=r.get(e.key);return t===void 0?[]:[{...e,attention:UX(t).attention}]})];let u=c===void 0?void 0:r.get(c.key);return c!==void 0&&u!==void 0&&(a=a.filter(e=>e.key!==c.key),c.shelf===t&&a.splice(Math.min(l,a.length),0,{...c,attention:UX(u).attention})),a});return e!==null&&u.length===e.length&&u.every((t,n)=>t.key===e[n]?.key&&t.shelf===e[n]?.shelf&&t.attention===e[n]?.attention)?e:u}function GX(e){switch(e.kind){case`idle`:return`done`;case`waiting_for_you`:return`needs_you`;case`error`:return`errored`;default:return`running`}}function KX(e,t,n=null,r){let i=new Set(e.map(e=>e.agentId));return qX(t.filter(e=>!(`kind`in e)&&i.has(e.agentId)&&(n===null||e.agentId===n)),r)}function qX(e,t){let n=[],r=[];for(let i of e){if(`kind`in i)continue;if(i.state===`unavailable`){r.push({agentId:i.agentId,sessionId:i.sessionId});continue}let e=RX(i.settledAt,i.visitedAt),a=t?.agentId===i.agentId&&t.sessionId===i.sessionId?t.state:void 0,o=a?GX(a):i.state,s=a?a.kind===`idle`:o===`done`&&i.settledAt===void 0,c=zX(o,e);n.push({...i,state:o,ready:s,unseen:e,tier:c,shelf:c===`recent`?`settled`:`active`})}return n.sort(BX),{active:n.filter(e=>e.shelf===`active`),settled:n.filter(e=>e.shelf===`settled`),unavailable:r.sort((e,t)=>e.agentId.localeCompare(t.agentId)||e.sessionId.localeCompare(t.sessionId))}}function JX(e,t){return`${e}\u0000${t}`}function YX(e){return e.name}function XX({children:e}){return(0,X.jsx)(`span`,{className:`grove-rail-mark grid size-full place-items-center`,children:e})}function ZX({open:e,agents:t,agentActivity:n,agentFilterId:r,websitesSelected:i,websitesVisible:a,canCreate:o,createOpen:s,onAll:c,onWebsites:l,onAgent:u,onCreate:d}){let[f,p]=(0,J.useState)(null),m=`grove-rail-cell relative size-12 rounded-field p-0`,h=r===null&&!(i&&a);return(0,X.jsxs)(`nav`,{id:`grove-agent-rail`,"aria-label":`Agents`,className:`grove-rail min-h-0 w-16 flex-none flex-col items-center gap-1 border-r border-base-300 py-2 ${e?`flex`:`flex min-[900px]:hidden`}`,children:[(0,X.jsx)(BT,{variant:`ghost`,"aria-label":`All Agents`,"aria-pressed":h,className:`${m} text-xs ${h?`bg-base-300`:``}`,onClick:c,children:(0,X.jsx)(XX,{children:`All`})}),a?(0,X.jsx)(BT,{variant:`ghost`,"aria-label":`Websites`,"aria-pressed":i,className:`${m} ${i?`bg-base-300`:``}`,onClick:l,children:(0,X.jsx)(XX,{children:(0,X.jsx)(Xq,{name:`internet`,size:28})})}):null,(0,X.jsx)(DA,{className:`w-full flex-1`,style:{width:`100%`},children:(0,X.jsx)(`div`,{className:`flex flex-col items-center gap-1 py-1`,children:t.map(e=>(0,X.jsx)(BT,{variant:`ghost`,"aria-label":YX(e),title:YX(e),"aria-pressed":r===e.agentId&&!i,"data-agent-id":e.agentId,className:`${m} ${r===e.agentId&&!i?`bg-base-300`:``}`,onPointerEnter:()=>{p(e.agentId)},onPointerLeave:()=>{p(null)},onFocus:()=>{p(e.agentId)},onBlur:()=>{p(null)},onClick:()=>{u(e.agentId)},children:(0,X.jsx)(XX,{children:(0,X.jsx)(NX,{activity:n.get(e.agentId)??(f===e.agentId?`thinking`:`idle`),avatar:e.avatar,name:YX(e),size:32})})},e.agentId))})}),o?(0,X.jsx)(BT,{variant:`ghost`,"aria-label":`New Agent`,"aria-expanded":s,"aria-haspopup":`dialog`,className:`${m} mt-auto`,onClick:d,children:(0,X.jsx)(`span`,{className:`grove-rail-mark grid size-full place-items-center`,children:(0,X.jsx)(lW,{size:20})})}):null]})}function QX({app:e}){let[t,n]=(0,J.useState)(null),r=jo({queryKey:eb.of(e,`team-inbox-notices`,t),enabled:e!==null&&(e.capabilities.has(mg)||e.capabilities.has(hg)),queryFn:async()=>{if(!e)throw Error(`No App connection`);let n=await Sg(e.capabilities);try{return await Jy(n,t)}finally{await n.close()}}});return!r.isError&&!r.data?.items.length?null:(0,X.jsx)(`section`,{"aria-label":`Team notices`,className:`min-h-0 shrink-0`,children:(0,X.jsxs)(DA,{className:`max-h-52 border-b border-base-300`,children:[r.isError?(0,X.jsx)(`p`,{role:`alert`,className:`text-sm`,children:`Team notices unavailable.`}):(0,X.jsx)(Bx,{density:`compact`,className:`px-3 py-2`,children:r.data.items.map(e=>(0,X.jsx)(Vx,{children:(0,X.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[auto_minmax(0,1fr)] gap-x-[var(--spacing-xs)]`,children:[(0,X.jsx)(FG,{className:`col-span-2 grid grid-cols-subgrid`,size:`compact`,tone:`warning`,label:`kind`in e?`Seller closed`:`Installed App safety notice`}),(0,X.jsx)(`p`,{className:`m-0 col-start-2 text-sm [overflow-wrap:anywhere]`,children:`kind`in e?`${e.sellerName} closed. Your installation of ${e.displayName} continues; no new purchases are available.`:`${e.displayName} was removed. Fungi will disable it on your Team.`})]})},e.dispositionId))}),r.data?.next?(0,X.jsx)(BT,{variant:`ghost`,size:`sm`,onClick:()=>{n(r.data.next)},children:`Older notices`}):null,t===null?null:(0,X.jsx)(BT,{variant:`ghost`,size:`sm`,onClick:()=>{n(null)},children:`Newest notices`})]})})}var $X=`(min-width: 900px)`;function eZ(e){let t=globalThis.matchMedia($X);return t.addEventListener(`change`,e),()=>{t.removeEventListener(`change`,e)}}function tZ(){return globalThis.matchMedia($X).matches}function nZ(){return(0,J.useSyncExternalStore)(eZ,tZ,()=>!0)}function rZ({open:e,onOpenChange:t,returnFocus:n,children:r}){let i=nZ(),[a,o]=(0,J.useState)(null);return(0,X.jsxs)(IU,{open:i||e,modal:!i,disablePointerDismissal:i,onOpenChange:e=>{i||t(e)},children:[(0,X.jsx)(`div`,{ref:o,className:`contents`}),(0,X.jsxs)(RU,{container:a,keepMounted:!0,className:`contents`,children:[i?null:(0,X.jsx)(zU,{className:`grove-nav-scrim z-30 bg-base-200`}),(0,X.jsx)(BU,{id:`grove-nav`,role:i?`presentation`:`dialog`,"aria-label":i?void 0:`Agents and conversations`,initialFocus:!i&&void 0,finalFocus:!i&&n,className:`grove-nav min-h-0 flex-none rounded-none p-0 overflow-visible max-w-none max-h-none ${i?`static flex w-auto shadow-none`:`fixed inset-y-0 left-0 z-40 w-[min(22rem,88vw)] data-[open]:flex`}`,children:r})]})]})}function iZ({update:e,notify:t,unwatched:n}){return{link:r,unlink:i,propagate:a,checkDirty:o,shallowPropagate:s};function r(e,t,n){let r=t.depsTail;if(r!==void 0&&r.dep===e)return;let i=r===void 0?t.deps:r.nextDep;if(i!==void 0&&i.dep===e){i.version=n,t.depsTail=i;return}let a=e.subsTail;if(a!==void 0&&a.version===n&&a.sub===t)return;let o=t.depsTail=e.subsTail={version:n,dep:e,sub:t,prevDep:r,nextDep:i,prevSub:a,nextSub:void 0};i!==void 0&&(i.prevDep=o),r===void 0?t.deps=o:r.nextDep=o,a===void 0?e.subs=o:a.nextSub=o}function i(e,t=e.sub){let r=e.dep,i=e.prevDep,a=e.nextDep,o=e.nextSub,s=e.prevSub;return a===void 0?t.depsTail=i:a.prevDep=i,i===void 0?t.deps=a:i.nextDep=a,o===void 0?r.subsTail=s:o.prevSub=s,s===void 0?(r.subs=o)===void 0&&n(r):s.nextSub=o,a}function a(e){let n=e.nextSub,r;top:do{let i=e.sub,a=i.flags;if(a&60?a&12?a&4?!(a&48)&&c(e,i)?(i.flags=a|40,a&=1):a=0:i.flags=a&-9|32:a=0:i.flags=a|32,a&2&&t(i),a&1){let t=i.subs;if(t!==void 0){let i=(e=t).nextSub;i!==void 0&&(r={value:n,prev:r},n=i);continue}}if((e=n)!==void 0){n=e.nextSub;continue}for(;r!==void 0;)if(e=r.value,r=r.prev,e!==void 0){n=e.nextSub;continue top}break}while(!0)}function o(t,n){let r,i=0,a=!1;top:do{let o=t.dep,c=o.flags;if(n.flags&16)a=!0;else if((c&17)==17){if(e(o)){let e=o.subs;e.nextSub!==void 0&&s(e),a=!0}}else if((c&33)==33){(t.nextSub!==void 0||t.prevSub!==void 0)&&(r={value:t,prev:r}),t=o.deps,n=o,++i;continue}if(!a){let e=t.nextDep;if(e!==void 0){t=e;continue}}for(;i--;){let i=n.subs,o=i.nextSub!==void 0;if(o?(t=r.value,r=r.prev):t=i,a){if(e(n)){o&&s(i),n=t.sub;continue}a=!1}else n.flags&=-33;n=t.sub;let c=t.nextDep;if(c!==void 0){t=c;continue top}}return a}while(!0)}function s(e){do{let n=e.sub,r=n.flags;(r&48)==32&&(n.flags=r|16,(r&6)==2&&t(n))}while((e=e.nextSub)!==void 0)}function c(e,t){let n=t.depsTail;for(;n!==void 0;){if(n===e)return!0;n=n.prevDep}return!1}}function aZ(e,t,n){let r=typeof e==`object`,i=r?e:void 0;return{next:(r?e.next:e)?.bind(i),error:(r?e.error:t)?.bind(i),complete:(r?e.complete:n)?.bind(i)}}var oZ=[],sZ=0,{link:cZ,unlink:lZ,propagate:uZ,checkDirty:dZ,shallowPropagate:fZ}=iZ({update(e){return e._update()},notify(e){oZ[mZ++]=e,e.flags&=-3},unwatched(e){e.depsTail!==void 0&&(e.depsTail=void 0,e.flags=17,vZ(e))}}),pZ=0,mZ=0,hZ,gZ=0;function _Z(e){try{++gZ,e()}finally{--gZ||yZ()}}function vZ(e){let t=e.depsTail,n=t===void 0?e.deps:t.nextDep;for(;n!==void 0;)n=lZ(n,e)}function yZ(){if(!(gZ>0)){for(;pZ<mZ;){let e=oZ[pZ];oZ[pZ++]=void 0,e.notify()}pZ=0,mZ=0}}function bZ(e,t){let n=typeof e==`function`,r=e,i={_snapshot:n?void 0:e,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:+!n,get(){return hZ!==void 0&&cZ(i,hZ,sZ),i._snapshot},subscribe(e){let t=aZ(e),n={current:!1},r=xZ(()=>{i.get(),n.current?t.next?.(i._snapshot):n.current=!0});return{unsubscribe:()=>{r.stop()}}},_update(e){let a=hZ,o=t?.compare??Object.is;if(n)hZ=i,++sZ,i.depsTail=void 0;else if(e===void 0)return!1;n&&(i.flags=5);try{let t=i._snapshot,a=typeof e==`function`?e(t):e===void 0&&n?r(t):e;return t===void 0||!o(t,a)?(i._snapshot=a,!0):!1}finally{hZ=a,n&&(i.flags&=-5),vZ(i)}}};return n?(i.flags=17,i.get=function(){let e=i.flags;if(e&16||e&32&&dZ(i.deps,i)){if(i._update()){let e=i.subs;e!==void 0&&fZ(e)}}else e&32&&(i.flags=e&-33);return hZ!==void 0&&cZ(i,hZ,sZ),i._snapshot}):i.set=function(e){if(i._update(e)){let e=i.subs;e!==void 0&&(uZ(e),fZ(e),yZ())}},i}function xZ(e){let t=()=>{let t=hZ;hZ=n,++sZ,n.depsTail=void 0,n.flags=6;try{return e()}finally{hZ=t,n.flags&=-5,vZ(n)}},n={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:6,notify(){let e=this.flags;e&16||e&32&&dZ(this.deps,this)?t():this.flags=2},stop(){this.flags=0,this.depsTail=void 0,vZ(this)}};return t(),n}var SZ=class{constructor(e,t){this.atom=bZ(e),this.get=this.get.bind(this),this.setState=this.setState.bind(this),this.subscribe=this.subscribe.bind(this),t&&(this.actions=t(this))}setState(e){this.atom.set(e)}get state(){return this.atom.get()}get(){return this.state}subscribe(e){return this.atom.subscribe(aZ(e))}},CZ=class{constructor(e){this.atom=bZ(e)}get state(){return this.atom.get()}get(){return this.state}subscribe(e){return this.atom.subscribe(aZ(e))}};function wZ(e,t){return typeof e==`function`?new CZ(e):t?new SZ(e,t):new SZ(e)}var TZ=class{constructor(e,t){this.fn=e,this.options=t,this.lastExecutionTime=0,this.isPending=!1,this.maybeExecute=(...e)=>{let t=Date.now()-this.lastExecutionTime;if(this.options.leading&&t>=this.options.wait)this.execute(...e);else if(this.lastArgs=e,!this.timeoutId&&this.options.trailing){let e=this.options.wait-t;this.isPending=!0,this.timeoutId=setTimeout(()=>{this.lastArgs!==void 0&&this.execute(...this.lastArgs)},e)}},this.execute=(...e)=>{this.fn(...e),this.options.onExecute?.(e,this),this.lastExecutionTime=Date.now(),this.clearTimeout(),this.lastArgs=void 0,this.isPending=!1},this.flush=()=>{this.isPending&&this.lastArgs&&this.execute(...this.lastArgs)},this.cancel=()=>{this.clearTimeout(),this.lastArgs=void 0,this.isPending=!1},this.clearTimeout=()=>{this.timeoutId&&=(clearTimeout(this.timeoutId),void 0)},this.options.leading===void 0&&this.options.trailing===void 0&&(this.options.leading=!0,this.options.trailing=!0)}};function EZ(e,t){return new TZ(e,t).maybeExecute}var DZ=class{#e=!0;#t;#n;#r;#i;#a;#o;#s;#c=0;#l=5;#u=!1;#d=!1;#f=null;#p=()=>{this.debugLog(`Connected to event bus`),this.#a=!0,this.#u=!1,this.debugLog(`Emitting queued events`,this.#i),this.#i.forEach(e=>this.emitEventToBus(e)),this.#i=[],this.stopConnectLoop(),this.#n().removeEventListener(`tanstack-connect-success`,this.#p)};#m=()=>{if(this.#c<this.#l){this.#c++,this.dispatchCustomEvent(`tanstack-connect`,{});return}this.#n().removeEventListener(`tanstack-connect`,this.#m),this.#d=!0,this.debugLog(`Max retries reached, giving up on connection`),this.stopConnectLoop()};#h=()=>{this.#u||(this.#u=!0,this.#n().addEventListener(`tanstack-connect-success`,this.#p),this.#m())};constructor({pluginId:e,debug:t=!1,enabled:n=!0,reconnectEveryMs:r=300}){this.#t=e,this.#e=n,this.#n=this.getGlobalTarget,this.#r=t,this.debugLog(` Initializing event subscription for plugin`,this.#t),this.#i=[],this.#a=!1,this.#d=!1,this.#o=null,this.#s=r}startConnectLoop(){this.#o!==null||this.#a||(this.debugLog(`Starting connect loop (every ${this.#s}ms)`),this.#o=setInterval(this.#m,this.#s))}stopConnectLoop(){this.#u=!1,this.#o!==null&&(clearInterval(this.#o),this.#o=null,this.#i=[],this.debugLog(`Stopped connect loop`))}debugLog(...e){this.#r&&console.log(`🌴 [tanstack-devtools:${this.#t}-plugin]`,...e)}getGlobalTarget(){if(typeof globalThis<`u`&&globalThis.__TANSTACK_EVENT_TARGET__)return this.debugLog(`Using global event target`),globalThis.__TANSTACK_EVENT_TARGET__;if(typeof window<`u`&&window.addEventListener!==void 0)return this.debugLog(`Using window as event target`),window;let e=typeof EventTarget<`u`?new EventTarget:void 0;return e===void 0||e.addEventListener===void 0?(this.debugLog(`No event mechanism available, running in non-web environment`),{addEventListener:()=>{},removeEventListener:()=>{},dispatchEvent:()=>!1}):(this.debugLog(`Using new EventTarget as fallback`),e)}getPluginId(){return this.#t}dispatchCustomEventShim(e,t){try{let n=new Event(e,{detail:t});this.#n().dispatchEvent(n)}catch{this.debugLog(`Failed to dispatch shim event`)}}dispatchCustomEvent(e,t){try{this.#n().dispatchEvent(new CustomEvent(e,{detail:t}))}catch{this.dispatchCustomEventShim(e,t)}}emitEventToBus(e){this.debugLog(`Emitting event to client bus`,e),this.dispatchCustomEvent(`tanstack-dispatch-event`,e)}createEventPayload(e,t){return{type:`${this.#t}:${e}`,payload:t,pluginId:this.#t}}emit(e,t){if(!this.#e){this.debugLog(`Event bus client is disabled, not emitting event`,e,t);return}if(this.#f&&(this.debugLog(`Emitting event to internal event target`,e,t),this.#f.dispatchEvent(new CustomEvent(`${this.#t}:${e}`,{detail:this.createEventPayload(e,t)}))),this.#d){this.debugLog(`Previously failed to connect, not emitting to bus`);return}if(!this.#a){this.debugLog(`Bus not available, will be pushed as soon as connected`),this.#i.push(this.createEventPayload(e,t)),typeof CustomEvent<`u`&&!this.#u&&(this.#h(),this.startConnectLoop());return}return this.emitEventToBus(this.createEventPayload(e,t))}on(e,t,n){let r=n?.withEventTarget??!1,i=`${this.#t}:${e}`;if(r&&(this.#f||=new EventTarget,this.#f.addEventListener(i,e=>{t(e.detail)})),!this.#e)return this.debugLog(`Event bus client is disabled, not registering event`,i),()=>{};let a=e=>{this.debugLog(`Received event from bus`,e.detail),t(e.detail)};return this.#n().addEventListener(i,a),this.debugLog(`Registered event to bus`,i),()=>{r&&this.#f?.removeEventListener(i,a),this.#n().removeEventListener(i,a)}}onAll(e){if(!this.#e)return this.debugLog(`Event bus client is disabled, not registering event`),()=>{};let t=t=>{let n=t.detail;e(n)};return this.#n().addEventListener(`tanstack-devtools-global`,t),()=>this.#n().removeEventListener(`tanstack-devtools-global`,t)}onAllPluginEvents(e){if(!this.#e)return this.debugLog(`Event bus client is disabled, not registering event`),()=>{};let t=t=>{let n=t.detail;this.#t&&n.pluginId!==this.#t||e(n)};return this.#n().addEventListener(`tanstack-devtools-global`,t),()=>this.#n().removeEventListener(`tanstack-devtools-global`,t)}},OZ=new class extends DZ{constructor(){super({pluginId:`form-devtools`,reconnectEveryMs:1e3})}};function kZ(e,t){return typeof e==`function`?e(t):e}function AZ(e,t){return RZ(t).reduce((e,t)=>{if(e===null)return null;if(e!==void 0)return e[t]},e)}function jZ(e,t,n){let r=RZ(t);function i(e){if(!r.length)return kZ(n,e);let t=r.shift();if(typeof t==`string`||typeof t==`number`&&!Array.isArray(e))return typeof e==`object`?(e===null&&(e={}),{...e,[t]:i(e[t])}):{[t]:i()};if(Array.isArray(e)&&typeof t==`number`){let n=e.slice(0,t);return[...n.length?n:Array(t),i(e[t]),...e.slice(t+1)]}return[...Array(t),i()]}return i(e)}function MZ(e,t){let n=RZ(t);function r(e){if(!e)return;if(n.length===1){let t=n[0];if(Array.isArray(e)&&typeof t==`number`)return e.filter((e,n)=>n!==t);let{[t]:r,...i}=e;return i}let t=n.shift();if((typeof t==`string`||typeof t==`number`&&!Array.isArray(e))&&typeof e==`object`)return{...e,[t]:r(e[t])};if(typeof t==`number`&&Array.isArray(e)){if(t>=e.length)return e;let n=e.slice(0,t);return[...n.length?n:Array(t),r(e[t]),...e.slice(t+1)]}throw Error(`It seems we have created an infinite loop in deleteBy. `)}return r(e)}var NZ=46,PZ=91,FZ=93,IZ=48,LZ=57;function RZ(e){if(Array.isArray(e))return[...e];if(typeof e!=`string`)throw Error(`Path must be a string.`);let t=e.length,n=[],r=+(t>0&&e.charCodeAt(0)===PZ),i=!0,a=-1;for(let o=r;o<=t;o++){let s=o<t?e.charCodeAt(o):-1;if(o===t||s===NZ||s===PZ||s===FZ){let t=o-r;if(t>0){let a=i&&(t===1||e.charCodeAt(r)!==IZ),s=e.slice(r,o);if(a){let e=parseInt(s,10);t<=15||String(e)===s?n.push(e):n.push(s)}else n.push(s)}else a!==FZ&&(a!==-1||s!==FZ)&&(a!==s||s!==NZ&&s!==PZ)&&n.push(``);r=o+1,i=!0}else(s<IZ||s>LZ)&&(i=!1);a=s}return n.length||n.push(``),n}function zZ(e){return!(Array.isArray(e)&&e.length===0)}function BZ(e,t){return t.validationLogic({form:t.form,group:t.group,validators:t.validators,event:{type:e,fieldName:t.fieldName,async:!1},runValidation:e=>e.validators.filter(Boolean).map(e=>({cause:e.cause,validate:e.fn}))})}function VZ(e,t){let{asyncDebounceMs:n}=t,{onBlurAsyncDebounceMs:r,onChangeAsyncDebounceMs:i,onDynamicAsyncDebounceMs:a}=t.validators||{},o=n??0;return t.validationLogic({form:t.form,group:t.group,validators:t.validators,event:{type:e,fieldName:t.fieldName,async:!0},runValidation:t=>t.validators.filter(Boolean).map(t=>{let n=t?.cause||e,s=o;switch(n){case`change`:s=i??o;break;case`blur`:s=r??o;break;case`dynamic`:s=a??o;break;case`submit`:s=0}return e===`submit`&&(s=0),{cause:n,validate:t.fn,debounceMs:s}})})}var HZ=e=>!!e&&typeof e==`object`&&`fields`in e;function UZ(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!t.has(n)||!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length||n.length===0&&!Array.isArray(e)&&!Array.isArray(t)&&(Object.getPrototypeOf(e)!==Object.prototype||Object.getPrototypeOf(t)!==Object.prototype))return!1;for(let i of n)if(!r.includes(i)||!UZ(e[i],t[i]))return!1;return!0}var WZ=({newFormValidatorError:e,isPreviousErrorFromFormValidator:t,previousErrorValue:n})=>e?{newErrorValue:e,newSource:`form`}:t?{newErrorValue:void 0,newSource:void 0}:n?{newErrorValue:n,newSource:`field`}:{newErrorValue:void 0,newSource:void 0},GZ=({formLevelError:e,fieldLevelError:t})=>t?{newErrorValue:t,newSource:`field`}:e?{newErrorValue:e,newSource:`form`}:{newErrorValue:void 0,newSource:void 0};function KZ(e,t){return e==null?t:{...e,...t}}for(var qZ=256,JZ=[],YZ;qZ--;)JZ[qZ]=(qZ+256).toString(16).substring(1);function XZ(){let e=0,t,n=``;if(!YZ||qZ+16>256){for(YZ=Array(256),e=256;e--;)YZ[e]=256*Math.random()|0;e=0,qZ=0}for(;e<16;e++)t=YZ[qZ+e],n+=e===6?JZ[t&15|64]:e===8?JZ[t&63|128]:JZ[t],e&1&&e>1&&e<11&&(n+=`-`);return qZ++,n}var ZZ=EZ(e=>OZ.emit(`form-state`,{id:e.formId,state:e.store.state}),{wait:300});function QZ(e){if(typeof e!=`object`||!e)return e;if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++)t[n]=QZ(e[n]);return t}if(e instanceof Map){let t=new Map;return e.forEach((e,n)=>{t.set(n,QZ(e))}),t}if(e instanceof Set){let t=new Set;return e.forEach(e=>{t.add(QZ(e))}),t}let t={};for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=QZ(e[n]));return t}function $Z(e,t){return t===e||t.startsWith(`${e}.`)||t.startsWith(`${e}[`)}var eQ=e=>{if(!e.validators)return e.runValidation({validators:[],form:e.form});let t=e.event.async,n=t?void 0:{fn:e.validators.onMount,cause:`mount`},r={fn:t?e.validators.onChangeAsync:e.validators.onChange,cause:`change`},i={fn:t?e.validators.onBlurAsync:e.validators.onBlur,cause:`blur`},a={fn:t?e.validators.onSubmitAsync:e.validators.onSubmit,cause:`submit`},o=t?void 0:{fn:()=>void 0,cause:`server`};switch(e.event.type){case`mount`:return e.runValidation({validators:[n],form:e.form});case`submit`:return e.runValidation({validators:[r,i,a,o],form:e.form});case`server`:return e.runValidation({validators:[],form:e.form});case`blur`:return e.runValidation({validators:[i,o],form:e.form});case`change`:return e.runValidation({validators:[r,o],form:e.form});default:throw Error(`Unknown validation event type: ${e.event.type}`)}};function tQ(e,t){let n=new Map;for(let r of e){let e=r.path??[],i=t,a=``;for(let t=0;t<e.length;t++){let n=e[t];if(n===void 0)continue;let r=typeof n==`object`?n.key:n,o=Number(r);a+=Array.isArray(i)&&!Number.isNaN(o)?`[${o}]`:(t>0?`.`:``)+String(r),i=typeof i==`object`&&i?i[r]:void 0}n.set(a,(n.get(a)??[]).concat(r))}return Object.fromEntries(n)}var nQ=(e,t)=>{let n=tQ(e,t);return{form:n,fields:n}},rQ={validate({value:e,validationSource:t},n){let r=n[`~standard`].validate(e);if(r instanceof Promise)throw Error(`async function passed to sync validator`);if(r.issues)return t===`field`?r.issues:nQ(r.issues,e)},async validateAsync({value:e,validationSource:t},n){let r=await n[`~standard`].validate(e);if(r.issues)return t===`field`?r.issues:nQ(r.issues,e)}},iQ=e=>!!e&&`~standard`in e,aQ={isValidating:!1,isTouched:!1,isBlurred:!1,isDirty:!1,isPristine:!0,isValid:!0,isDefaultValue:!0,errors:[],errorMap:{},errorSourceMap:{},_arrayVersion:0,_pendingValidationsCount:0};function oQ(e){function t(t){let n=e.getFieldMeta(t)??aQ;e.setFieldMeta(t,{...n,_arrayVersion:(n._arrayVersion||0)+1})}function n(n,r,i){t(n);let a=s(n,r,`move`,i),c=Math.min(r,i),u=Math.max(r,i);for(let e=c;e<=u;e++)a.push(o(n,e));let d=Object.keys(e.fieldInfo).reduce((t,i)=>(i.startsWith(o(n,r))&&t.set(i,e.getFieldMeta(i)),t),new Map);l(a,r<i?`up`:`down`),Object.keys(e.fieldInfo).filter(e=>e.startsWith(o(n,i))).forEach(t=>{let a=t.replace(o(n,i),o(n,r)),s=d.get(a);s&&e.setFieldMeta(t,s)})}function r(e,n){t(e),l(s(e,n,`remove`),`up`)}function i(n,r,i){t(n),s(n,r,`swap`,i).forEach(t=>{if(!t.toString().startsWith(o(n,r)))return;let a=t.toString().replace(o(n,r),o(n,i)),[s,c]=[e.getFieldMeta(t),e.getFieldMeta(a)];s&&e.setFieldMeta(a,s),c&&e.setFieldMeta(t,c)})}function a(n,r){t(n);let i=s(n,r,`insert`);l(i,`down`),i.forEach(t=>{t.toString().startsWith(o(n,r))&&e.setFieldMeta(t,u())})}function o(e,t){return`${e}[${t}]`}function s(t,n,r,i){let a=[o(t,n)];switch(r){case`swap`:a.push(o(t,i));break;case`move`:{let[e,r]=[Math.min(n,i),Math.max(n,i)];for(let n=e;n<=r;n++)a.push(o(t,n));break}default:{let r=e.getFieldValue(t),i=Array.isArray(r)?r.length:0;for(let e=n+1;e<i;e++)a.push(o(t,e));break}}return Object.keys(e.fieldInfo).filter(e=>a.some(t=>e.startsWith(t)))}function c(e,t){return e.replace(/\[(\d+)\]/,(e,n)=>{let r=parseInt(n,10);return`[${t===`up`?r+1:Math.max(0,r-1)}]`})}function l(t,n){(n===`up`?t:[...t].reverse()).forEach(t=>{let r=c(t.toString(),n),i=e.getFieldMeta(r);i?e.setFieldMeta(t,i):e.setFieldMeta(t,u())})}let u=()=>aQ;return{bumpArrayVersion:t,handleArrayMove:n,handleArrayRemove:r,handleArraySwap:i,handleArrayInsert:a}}function sQ(e){return{values:e.values??{},errorMap:e.errorMap??{},fieldMetaBase:e.fieldMetaBase??{},formGroupStateBase:e.formGroupStateBase??{},isSubmitted:e.isSubmitted??!1,isSubmitting:e.isSubmitting??!1,isValidating:e.isValidating??!1,submissionAttempts:e.submissionAttempts??0,isSubmitSuccessful:e.isSubmitSuccessful??!1,validationMetaMap:e.validationMetaMap??{onChange:void 0,onBlur:void 0,onSubmit:void 0,onMount:void 0,onServer:void 0,onDynamic:void 0}}}var cQ=class{constructor(e){this.options={},this.fieldInfo={},this.formGroupApis=new Set,this.mount=()=>{let e=this.store.subscribe(()=>{ZZ(this)}),t=OZ.on(`request-form-state`,e=>{e.payload.id===this._formId&&OZ.emit(`form-api`,{id:this._formId,state:this.store.state,options:this.options})}),n=OZ.on(`request-form-reset`,e=>{e.payload.id===this._formId&&this.reset()}),r=OZ.on(`request-form-force-submit`,e=>{e.payload.id===this._formId&&(this._devtoolsSubmissionOverride=!0,this.handleSubmit(),this._devtoolsSubmissionOverride=!1)}),i=()=>{r(),n(),t(),e.unsubscribe(),OZ.emit(`form-unmounted`,{id:this._formId})};this.options.listeners?.onMount?.({formApi:this});let{onMount:a}=this.options.validators||{};return OZ.emit(`form-api`,{id:this._formId,state:this.store.state,options:this.options}),a&&this.validateSync(`mount`),i},this.update=e=>{if(!e)return;let t=this.options;this.options=e;let n=e.defaultValues&&!UZ(e.defaultValues,t.defaultValues)&&!this.state.isTouched,r=!UZ(e.defaultState,t.defaultState)&&!this.state.isTouched;if(!(!n&&!r)){if(_Z(()=>{this.baseStore.setState(()=>sQ(Object.assign({},this.state,r?e.defaultState:{},n?{values:e.defaultValues}:{})))}),n){let e=oQ(this);for(let t of Object.keys(this.fieldInfo))Array.isArray(this.getFieldValue(t))&&e.bumpArrayVersion(t)}OZ.emit(`form-api`,{id:this._formId,state:this.store.state,options:this.options})}},this.reset=(e,t)=>{let{fieldMeta:n}=this.state,r=this.resetFieldMeta(n);e&&!t?.keepDefaultValues&&(this.options={...this.options,defaultValues:e}),this.baseStore.setState(()=>{let t=e??this.options.defaultValues??this.options.defaultState?.values;return e||Object.values(this.fieldInfo).forEach(e=>{e.instance&&e.instance.options.defaultValue!==void 0&&(t=jZ(t,e.instance.name,e.instance.options.defaultValue))}),sQ({...this.options.defaultState,values:t,fieldMetaBase:r})})},this.validateAllFields=async e=>{let t=[];return _Z(()=>{Object.values(this.fieldInfo).forEach(n=>{if(!n.instance)return;let r=n.instance;t.push(Promise.resolve().then(()=>r.validate(e,{skipFormValidation:!0,skipGroupValidation:!0}))),n.instance.store.state.meta.isTouched||n.instance.setMeta(e=>({...e,isTouched:!0}))})}),(await Promise.all(t)).flat()},this.validateArrayFieldsStartingFrom=async(e,t,n)=>{let r=this.getFieldValue(e),i=Array.isArray(r)?Math.max(r.length-1,0):null,a=[`${e}[${t}]`];for(let n=t+1;n<=(i??0);n++)a.push(`${e}[${n}]`);let o=Object.keys(this.fieldInfo).filter(e=>a.some(t=>e.startsWith(t))),s=[];return _Z(()=>{o.forEach(e=>{s.push(Promise.resolve().then(()=>this.validateField(e,n)))})}),(await Promise.all(s)).flat()},this.validateField=(e,t)=>{let n=this.fieldInfo[e]?.instance;if(!n){let{hasErrored:n}=this.validateSync(t);return n&&!this.options.asyncAlways?this.getFieldMeta(e)?.errors??[]:this.validateAsync(t).then(()=>this.getFieldMeta(e)?.errors??[])}return n.store.state.meta.isTouched||n.setMeta(e=>({...e,isTouched:!0})),n.validate(t)},this.validateSync=(e,t)=>{let n=BZ(e,{...this.options,form:this,group:t?.group,validationLogic:this.options.validationLogic||eQ}),r=!1,i={};return _Z(()=>{for(let e of n){if(!e.validate)continue;let{formError:n,fieldErrors:a}=lQ(this.runValidator({validate:e.validate,value:{value:this.state.values,formApi:this,validationSource:`form`},type:`validate`})),o=uQ(e.cause),s=new Set([...Object.keys(this.state.fieldMeta),...Object.keys(a||{})]);t?.filterFieldNames&&(s=new Set([...s].filter(t.filterFieldNames)));for(let e of s){if(this.baseStore.state.fieldMetaBase[e]===void 0&&!a?.[e])continue;let{errorMap:t,errorSourceMap:n}=this.getFieldMeta(e)??aQ,r=a?.[e],{newErrorValue:s,newSource:c}=WZ({newFormValidatorError:r,isPreviousErrorFromFormValidator:n?.[o]===`form`,previousErrorValue:t?.[o]});c===`form`&&(i[e]={...i[e],[o]:r}),t?.[o]!==s&&this.setFieldMeta(e,(e=aQ)=>({...e,errorMap:{...e.errorMap,[o]:s},errorSourceMap:{...e.errorSourceMap,[o]:c}}))}t?.dontUpdateFormErrorMap||this.state.errorMap?.[o]!==n&&this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[o]:n}})),(n||a)&&(r=!0)}if(t?.dontUpdateFormErrorMap)return;let a=uQ(`submit`);this.state.errorMap?.[a]&&e!==`submit`&&!r&&this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[a]:void 0}}));let o=uQ(`server`);this.state.errorMap?.[o]&&e!==`server`&&!r&&this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[o]:void 0}}))}),{hasErrored:r,fieldsErrorMap:i}},this.validateAsync=async(e,t)=>{let n=VZ(e,{...this.options,form:this,group:t?.group,validationLogic:this.options.validationLogic||eQ});this.state.isFormValidating||this.baseStore.setState(e=>({...e,isFormValidating:!0}));let r=[],i;for(let e of n){if(!e.validate)continue;let n=uQ(e.cause);this.state.validationMetaMap[n]?.lastAbortController.abort();let a=new AbortController;this.state.validationMetaMap[n]={lastAbortController:a},r.push(new Promise(async n=>{let r;try{r=await new Promise((t,n)=>{setTimeout(async()=>{if(a.signal.aborted)return t(void 0);try{t(await this.runValidator({validate:e.validate,value:{value:this.state.values,formApi:this,validationSource:`form`,signal:a.signal},type:`validateAsync`}))}catch(e){n(e)}},e.debounceMs)})}catch(e){r=e}let{formError:o,fieldErrors:s}=lQ(r);s&&(i=i?{...i,...s}:s);let c=uQ(e.cause),l=new Set([...Object.keys(this.state.fieldMeta),...Object.keys(i||{})]),u=Array.from(l);t?.filterFieldNames&&(u=u.filter(t.filterFieldNames));for(let e of u){if(this.baseStore.state.fieldMetaBase[e]===void 0&&!i?.[e])continue;let{errorMap:t,errorSourceMap:n}=this.getFieldMeta(e)??aQ,r=i?.[e],{newErrorValue:a,newSource:o}=WZ({newFormValidatorError:r,isPreviousErrorFromFormValidator:n?.[c]===`form`,previousErrorValue:t?.[c]});t?.[c]!==a&&this.setFieldMeta(e,(e=aQ)=>({...e,errorMap:{...e.errorMap,[c]:a},errorSourceMap:{...e.errorSourceMap,[c]:o}}))}t?.dontUpdateFormErrorMap||this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[c]:o}})),n(i?{fieldErrors:i,errorMapKey:c}:void 0)}))}let a=[],o={};if(r.length){a=await Promise.all(r);for(let e of a)if(e?.fieldErrors){let{errorMapKey:t}=e;for(let[n,r]of Object.entries(e.fieldErrors))o[n]={...o[n]||{},[t]:r}}}return this.baseStore.setState(e=>({...e,isFormValidating:!1})),o},this.validate=(e,t)=>{let{hasErrored:n,fieldsErrorMap:r}=this.validateSync(e,t);return n&&!this.options.asyncAlways?r:this.validateAsync(e,t)},this._handleSubmit=async e=>{this.baseStore.setState(e=>({...e,isSubmitted:!1,submissionAttempts:e.submissionAttempts+1,isSubmitSuccessful:!1})),_Z(()=>{Object.values(this.fieldInfo).forEach(e=>{e.instance&&(e.instance.store.state.meta.isTouched||e.instance.setMeta(e=>({...e,isTouched:!0})))})});let t=e??this.options.onSubmitMeta;if(!this.state.canSubmit&&!this._devtoolsSubmissionOverride&&this.baseStore.state.submissionAttempts<=1){this.options.onSubmitInvalid?.({value:this.state.values,formApi:this,meta:t});return}this.baseStore.setState(e=>({...e,isSubmitting:!0}));let n=()=>{this.baseStore.setState(e=>({...e,isSubmitting:!1}))};if(await this.validateAllFields(`submit`),!this.state.isFieldsValid){n(),this.options.onSubmitInvalid?.({value:this.state.values,formApi:this,meta:t}),OZ.emit(`form-submission`,{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!1,stage:`validateAllFields`,errors:Object.values(this.state.fieldMeta).map(e=>e.errors).flat()});return}if(await this.validate(`submit`),!this.state.isValid){n(),this.options.onSubmitInvalid?.({value:this.state.values,formApi:this,meta:t}),OZ.emit(`form-submission`,{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!1,stage:`validate`,errors:this.state.errors});return}_Z(()=>{Object.values(this.fieldInfo).forEach(e=>{e.instance?.triggerOnSubmitListener()})}),this.options.listeners?.onSubmit?.({formApi:this,meta:t});try{await this.options.onSubmit?.({value:this.state.values,formApi:this,meta:t}),_Z(()=>{this.baseStore.setState(e=>({...e,isSubmitted:!0,isSubmitSuccessful:!0})),OZ.emit(`form-submission`,{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!0}),n()})}catch(e){throw this.baseStore.setState(e=>({...e,isSubmitSuccessful:!1})),OZ.emit(`form-submission`,{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!1,stage:`inflight`,onError:e}),n(),e}},this.getFieldValue=e=>AZ(this.state.values,e),this.getFieldMeta=e=>this.state.fieldMeta[e],this.getFormGroupMeta=e=>this.formGroupMetaDerived.state[e],this.getFieldInfo=e=>this.fieldInfo[e]||={instance:null,validationMetaMap:{onChange:void 0,onBlur:void 0,onSubmit:void 0,onMount:void 0,onServer:void 0,onDynamic:void 0}},this.setFieldMeta=(e,t)=>{this.baseStore.setState(n=>({...n,fieldMetaBase:{...n.fieldMetaBase,[e]:kZ(t,n.fieldMetaBase[e])}}))},this.resetFieldMeta=e=>Object.keys(e).reduce((e,t)=>{let n=t;return e[n]=aQ,e},{}),this.setFieldValue=(e,t,n)=>{let r=n?.dontUpdateMeta??!1,i=n?.dontRunListeners??!1,a=n?.dontValidate??!1;_Z(()=>{r||this.setFieldMeta(e,e=>({...e,isTouched:!0,isDirty:!0,errorMap:{...e?.errorMap,onMount:void 0}})),this.baseStore.setState(n=>({...n,values:jZ(n.values,e,t)}))}),i||this.getFieldInfo(e).instance?.triggerOnChangeListener(),a||this.validateField(e,`change`)},this.deleteField=e=>{let t=[...Object.keys(this.fieldInfo).filter(t=>{let n=e.toString();return t!==n&&t.startsWith(n)}),e];this.baseStore.setState(e=>{let n={...e};return t.forEach(e=>{n.values=MZ(n.values,e),delete this.fieldInfo[e],delete n.fieldMetaBase[e]}),n})},this.pushFieldValue=(e,t,n)=>{this.setFieldValue(e,e=>[...Array.isArray(e)?e:[],t],n),oQ(this).bumpArrayVersion(e)},this.insertFieldValue=async(e,t,n,r)=>{this.setFieldValue(e,e=>[...e.slice(0,t),n,...e.slice(t)],KZ(r,{dontValidate:!0}));let i=r?.dontValidate??!1;i||await this.validateField(e,`change`),oQ(this).handleArrayInsert(e,t),i||await this.validateArrayFieldsStartingFrom(e,t,`change`)},this.replaceFieldValue=async(e,t,n,r)=>{this.setFieldValue(e,e=>e.map((e,r)=>r===t?n:e),KZ(r,{dontValidate:!0})),oQ(this).bumpArrayVersion(e),(r?.dontValidate??!1)||(await this.validateField(e,`change`),await this.validateArrayFieldsStartingFrom(e,t,`change`))},this.removeFieldValue=async(e,t,n)=>{let r=this.getFieldValue(e),i=Array.isArray(r)?Math.max(r.length-1,0):null;if(this.setFieldValue(e,e=>e.filter((e,n)=>n!==t),KZ(n,{dontValidate:!0})),oQ(this).handleArrayRemove(e,t),i!==null){let t=`${e}[${i}]`;this.deleteField(t)}(n?.dontValidate??!1)||(await this.validateField(e,`change`),await this.validateArrayFieldsStartingFrom(e,t,`change`))},this.swapFieldValues=(e,t,n,r)=>{this.setFieldValue(e,e=>{let r=e[t],i=e[n];return jZ(jZ(e,`${t}`,i),`${n}`,r)},KZ(r,{dontValidate:!0})),oQ(this).handleArraySwap(e,t,n),(r?.dontValidate??!1)||(this.validateField(e,`change`),this.validateField(`${e}[${t}]`,`change`),this.validateField(`${e}[${n}]`,`change`))},this.moveFieldValues=(e,t,n,r)=>{this.setFieldValue(e,e=>{let r=[...e];return r.splice(n,0,r.splice(t,1)[0]),r},KZ(r,{dontValidate:!0})),oQ(this).handleArrayMove(e,t,n),(r?.dontValidate??!1)||(this.validateField(e,`change`),this.validateField(`${e}[${t}]`,`change`),this.validateField(`${e}[${n}]`,`change`))},this.clearFieldValues=(e,t)=>{let n=this.getFieldValue(e),r=Array.isArray(n)?Math.max(n.length-1,0):null;if(this.setFieldValue(e,[],KZ(t,{dontValidate:!0})),oQ(this).bumpArrayVersion(e),r!==null)for(let t=0;t<=r;t++){let n=`${e}[${t}]`;this.deleteField(n)}(t?.dontValidate??!1)||this.validateField(e,`change`)},this.resetField=e=>{this.baseStore.setState(t=>{let n=this.getFieldInfo(e).instance?.options.defaultValue,r=AZ(this.options.defaultValues,e),i=n??r;return{...t,fieldMetaBase:{...t.fieldMetaBase,[e]:aQ},values:i===void 0?t.values:jZ(t.values,e,i)}})},this.setErrorMap=e=>{_Z(()=>{Object.entries(e).forEach(([e,t])=>{let n=e;if(HZ(t)){let{formError:e,fieldErrors:r}=lQ(t);for(let e of Object.keys(this.fieldInfo))this.getFieldMeta(e)&&this.setFieldMeta(e,t=>({...t,errorMap:{...t.errorMap,[n]:r?.[e]},errorSourceMap:{...t.errorSourceMap,[n]:`form`}}));this.baseStore.setState(t=>({...t,errorMap:{...t.errorMap,[n]:e}}))}else this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[n]:t}}))})})},this.getAllErrors=()=>({form:{errors:this.state.errors,errorMap:this.state.errorMap},fields:Object.entries(this.state.fieldMeta).reduce((e,[t,n])=>(Object.keys(n).length&&n.errors.length&&(e[t]={errors:n.errors,errorMap:n.errorMap}),e),{})}),this.parseValuesWithSchema=e=>rQ.validate({value:this.state.values,validationSource:`form`},e),this.parseValuesWithSchemaAsync=e=>rQ.validateAsync({value:this.state.values,validationSource:`form`},e),this.timeoutIds={validations:{},listeners:{},formListeners:{}},this._formId=e?.formId??XZ(),this._devtoolsSubmissionOverride=!1;let t=sQ({...e?.defaultState,values:e?.defaultValues??e?.defaultState?.values});if(e?.transform){t=e.transform({state:t}).state;for(let e of Object.keys(t.errorMap)){let n=t.errorMap[e];if(!(n===void 0||!HZ(n)))for(let r of Object.keys(n.fields)){let i=n.fields[r];if(i===void 0)continue;let a=t.fieldMetaBase[r];t.fieldMetaBase[r]={isTouched:!1,isValidating:!1,isBlurred:!1,isDirty:!1,_arrayVersion:0,_pendingValidationsCount:0,...a??{},errorSourceMap:{...a?.errorSourceMap??{},onChange:`form`},errorMap:{...a?.errorMap??{},[e]:i}}}}}this.baseStore=wZ(t);let n;this.fieldMetaDerived=wZ(e=>{let t=this.baseStore.get(),r=0,i={};for(let a of Object.keys(t.fieldMetaBase)){let o=t.fieldMetaBase[a],s=n?.fieldMetaBase[a],c=e?.[a],l=AZ(t.values,a),u=c?.errors;if(!s||o.errorMap!==s.errorMap){u=Object.values(o.errorMap??{}).filter(e=>e!==void 0);let e=this.getFieldInfo(a)?.instance;(!e||!e.options.disableErrorFlat)&&(u=u.flat(1))}let d=!zZ(u),f=!o.isDirty,p=UZ(l,this.getFieldInfo(a)?.instance?.options.defaultValue??AZ(this.options.defaultValues,a));if(c&&c.isPristine===f&&c.isValid===d&&c.isDefaultValue===p&&c.errors===u&&o===s){i[a]=c,r++;continue}i[a]={...o,errors:u??[],isPristine:f,isValid:d,isDefaultValue:p}}return Object.keys(t.fieldMetaBase).length?e&&r===Object.keys(t.fieldMetaBase).length?e:(n=this.baseStore.get(),i):i}),this.formGroupMetaDerived=wZ(e=>{let t=this.baseStore.get(),n=this.fieldMetaDerived.get(),r={};for(let i of this.formGroupApis){let a=i.name,o=t.formGroupStateBase[a]??{isSubmitted:!1,isSubmitting:!1,isValidating:!1,submissionAttempts:0,isSubmitSuccessful:!1},s=n[a],c=!1,l=!0,u=!1,d=!1,f=!0,p=!1;for(let e in n){if(e===a||!$Z(a,e))continue;let t=n[e];t&&(t.isValidating&&(c=!0),t.isValid||(l=!1),t.isTouched&&(u=!0),t.isBlurred&&(d=!0),t.isDefaultValue||(f=!1),t.isDirty&&(p=!0))}let m=!p,h=!!c||o.isValidating,g=s?.errorMap??{},_=s?.errorSourceMap??{},v=!!(g.onMount||Object.entries(n).some(([e,t])=>t&&e!==a&&$Z(a,e)&&t.errorMap.onMount)),y=e?.[a],b=y?.errors??[];(!y||y.__srcErrorMap!==g)&&(b=Object.values(g).reduce((e,t)=>{if(t===void 0)return e;if(t&&typeof t==`object`&&`fields`in t){let n=t.group;return n!==void 0&&e.push(n),e}return e.push(t),e},[]));let x=b.length===0,S=l&&x,C=i.options.canSubmitWhenInvalid??!1,w=o.submissionAttempts===0&&!u&&!v||!h&&!o.isSubmitting&&S||C;if(y&&y.errorMap===g&&y.errorSourceMap===_&&y.errors===b&&y.isFieldsValidating===c&&y.isFieldsValid===l&&y.isGroupValid===x&&y.isValid===S&&y.canSubmit===w&&y.isTouched===u&&y.isBlurred===d&&y.isPristine===m&&y.isDefaultValue===f&&y.isDirty===p&&y.isValidating===h&&y.isSubmitting===o.isSubmitting&&y.isSubmitted===o.isSubmitted&&y.submissionAttempts===o.submissionAttempts&&y.isSubmitSuccessful===o.isSubmitSuccessful){r[a]=y;continue}let T={...o,errorMap:g,errorSourceMap:_,_arrayVersion:s?._arrayVersion??0,isTouched:u,isBlurred:d,isDirty:p,isPristine:m,isDefaultValue:f,isValid:S,errors:b,isValidating:h,isFieldsValidating:c,isFieldsValid:l,isGroupValid:x,canSubmit:w};Object.defineProperty(T,"__srcErrorMap",{value:g,enumerable:!1,configurable:!0}),r[a]=T}return r});let r;this.store=wZ(e=>{let t=this.baseStore.get(),n=this.fieldMetaDerived.get(),i=Object.values(n).filter(Boolean),a=i.some(e=>e.isValidating),o=i.every(e=>e.isValid),s=i.some(e=>e.isTouched),c=i.some(e=>e.isBlurred),l=i.every(e=>e.isDefaultValue),u=s&&t.errorMap?.onMount,d=i.some(e=>e.isDirty),f=!d,p=!!(t.errorMap?.onMount||i.some(e=>e?.errorMap?.onMount)),m=!!a,h=e?.errors??[];(!r||t.errorMap!==r.errorMap)&&(h=Object.values(t.errorMap).reduce((e,t)=>t===void 0?e:t&&HZ(t)?(e.push(t.form),e):(e.push(t),e),[]));let g=h.length===0,_=o&&g,v=this.options.canSubmitWhenInvalid??!1,y=t.submissionAttempts===0&&!s&&!p||!m&&!t.isSubmitting&&_||v,b=t.errorMap;if(u&&(h=h.filter(e=>e!==t.errorMap.onMount),b=Object.assign(b,{onMount:void 0})),e&&r&&e.errorMap===b&&e.fieldMeta===this.fieldMetaDerived.state&&e.errors===h&&e.isFieldsValidating===a&&e.isFieldsValid===o&&e.isFormValid===g&&e.isValid===_&&e.canSubmit===y&&e.isTouched===s&&e.isBlurred===c&&e.isPristine===f&&e.isDefaultValue===l&&e.isDirty===d&&UZ(r,t))return e;let x={...t,errorMap:b,fieldMeta:this.fieldMetaDerived.state,errors:h,isFieldsValidating:a,isFieldsValid:o,isFormValid:g,isValid:_,canSubmit:y,isTouched:s,isBlurred:c,isPristine:f,isDefaultValue:l,isDirty:d};return r=this.baseStore.get(),x}),this.handleSubmit=this.handleSubmit.bind(this),this.update(e||{})}get state(){return this.store.state}get formId(){return this._formId}runValidator(e){return iQ(e.validate)?rQ[e.type](e.value,e.validate):e.validate(e.value)}handleSubmit(e){return this._handleSubmit(e)}};function lQ(e){return e?HZ(e)?{formError:lQ(e.form).formError,fieldErrors:e.fields}:{formError:e}:{formError:void 0}}function uQ(e){switch(e){case`submit`:return`onSubmit`;case`blur`:return`onBlur`;case`mount`:return`onMount`;case`server`:return`onServer`;case`dynamic`:return`onDynamic`;default:return`onChange`}}var dQ=class e{constructor(t){this.options={},this.mount=()=>{this.options.defaultValue!==void 0&&!this.getMeta().isTouched&&this.form.setFieldValue(this.name,this.options.defaultValue,{dontUpdateMeta:!0});let e=this.getInfo();e.instance=this,this.update(this.options);let{onMount:t}=this.options.validators||{};if(t){let e=this.runValidator({validate:t,value:{value:this.state.value,fieldApi:this,validationSource:`field`},type:`validate`});e&&this.setMeta(t=>({...t,errorMap:{...t?.errorMap,onMount:e},errorSourceMap:{...t?.errorSourceMap,onMount:`field`}}))}return this.options.listeners?.onMount?.({value:this.state.value,fieldApi:this}),()=>{for(let[e,t]of Object.entries(this.timeoutIds.validations))t&&(clearTimeout(t),this.timeoutIds.validations[e]=null);for(let[e,t]of Object.entries(this.timeoutIds.listeners))t&&(clearTimeout(t),this.timeoutIds.listeners[e]=null);for(let[e,t]of Object.entries(this.timeoutIds.formListeners))t&&(clearTimeout(t),this.timeoutIds.formListeners[e]=null);let e=this.form.fieldInfo[this.name];if(e&&e.instance===this){for(let[t,n]of Object.entries(e.validationMetaMap))n?.lastAbortController.abort(),e.validationMetaMap[t]=void 0;this.form.baseStore.setState(e=>({...e,fieldMetaBase:{...e.fieldMetaBase,[this.name]:{...aQ,isTouched:e.fieldMetaBase[this.name]?.isTouched??aQ.isTouched,isBlurred:e.fieldMetaBase[this.name]?.isBlurred??aQ.isBlurred,isDirty:e.fieldMetaBase[this.name]?.isDirty??aQ.isDirty}}})),e.instance=null,this.options.listeners?.onUnmount?.({value:this.state.value,fieldApi:this}),this.form.options.listeners?.onFieldUnmount?.({formApi:this.form,fieldApi:this})}}},this.update=e=>{this.options=e,this.name=e.name,!this.state.meta.isTouched&&this.options.defaultValue!==void 0&&(UZ(this.form.getFieldValue(this.name),e.defaultValue)||this.form.setFieldValue(this.name,e.defaultValue,{dontUpdateMeta:!0,dontValidate:!0,dontRunListeners:!0})),this.form.getFieldMeta(this.name)||this.form.setFieldMeta(this.name,this.state.meta)},this.getValue=()=>this.form.getFieldValue(this.name),this.setValue=(e,t)=>{this.form.setFieldValue(this.name,e,KZ(t,{dontRunListeners:!0,dontValidate:!0})),t?.dontRunListeners||this.triggerOnChangeListener(),t?.dontValidate||this.validate(`change`)},this.getMeta=()=>this.store.state.meta,this.setMeta=e=>this.form.setFieldMeta(this.name,e),this.getInfo=()=>this.form.getFieldInfo(this.name),this.pushValue=(e,t)=>{this.form.pushFieldValue(this.name,e,KZ(t,{dontRunListeners:!0})),t?.dontRunListeners||this.triggerOnChangeListener()},this.insertValue=(e,t,n)=>{this.form.insertFieldValue(this.name,e,t,KZ(n,{dontRunListeners:!0})),n?.dontRunListeners||this.triggerOnChangeListener()},this.replaceValue=(e,t,n)=>{this.form.replaceFieldValue(this.name,e,t,KZ(n,{dontRunListeners:!0})),n?.dontRunListeners||this.triggerOnChangeListener()},this.removeValue=(e,t)=>{this.form.removeFieldValue(this.name,e,KZ(t,{dontRunListeners:!0})),t?.dontRunListeners||this.triggerOnChangeListener()},this.swapValues=(e,t,n)=>{this.form.swapFieldValues(this.name,e,t,KZ(n,{dontRunListeners:!0})),n?.dontRunListeners||this.triggerOnChangeListener()},this.moveValue=(e,t,n)=>{this.form.moveFieldValues(this.name,e,t,KZ(n,{dontRunListeners:!0})),n?.dontRunListeners||this.triggerOnChangeListener()},this.clearValues=e=>{this.form.clearFieldValues(this.name,KZ(e,{dontRunListeners:!0})),e?.dontRunListeners||this.triggerOnChangeListener()},this.getLinkedFields=t=>{let n=Object.values(this.form.fieldInfo),r=[];for(let i of n){if(!i.instance||!(i.instance instanceof e))continue;let{onChangeListenTo:n,onBlurListenTo:a}=i.instance.options.validators||{};t===`change`&&n?.includes(this.name)&&r.push(i.instance),t===`blur`&&a?.includes(this.name)&&r.push(i.instance)}return r},this.validateSync=(e,t)=>{let n=BZ(e,{...this.options,form:this.form,fieldName:this.name,validationLogic:this.form.options.validationLogic||eQ}),r=this.getLinkedFields(e).reduce((t,n)=>{let r=BZ(e,{...n.options,form:n.form,fieldName:n.name,validationLogic:n.form.options.validationLogic||eQ});return r.forEach(e=>{e.field=n}),t.concat(r)},[]),i=!1;_Z(()=>{let e=(e,n)=>{let r=pQ(n.cause),a=n.validate?fQ(e.runValidator({validate:n.validate,value:{value:e.store.state.value,validationSource:`field`,fieldApi:e},type:`validate`})):void 0,o=t[r],{newErrorValue:s,newSource:c}=GZ({formLevelError:o,fieldLevelError:a});e.state.meta.errorMap?.[r]!==s&&e.setMeta(e=>({...e,errorMap:{...e.errorMap,[r]:s},errorSourceMap:{...e.errorSourceMap,[r]:c}})),s&&(i=!0)};for(let t of n)e(this,t);for(let t of r)t.validate&&e(t.field,t)});let a=pQ(`submit`);return this.state.meta.errorMap?.[a]&&e!==`submit`&&!i&&this.setMeta(e=>({...e,errorMap:{...e.errorMap,[a]:void 0},errorSourceMap:{...e.errorSourceMap,[a]:void 0}})),{hasErrored:i}},this.validateAsync=async(e,t)=>{let n=VZ(e,{...this.options,form:this.form,fieldName:this.name,validationLogic:this.form.options.validationLogic||eQ}),r=await t,i=this.getLinkedFields(e).reduce((t,n)=>{let r=VZ(e,{...n.options,form:n.form,fieldName:n.name,validationLogic:n.form.options.validationLogic||eQ});return r.forEach(e=>{e.field=n}),t.concat(r)},[]),a=[],o=[],s=n.some(e=>e.validate),c=Array.from(new Set(i.filter(e=>e.validate).map(e=>e.field)));_Z(()=>{s&&this.startValidation();for(let e of c)e.startValidation()});let l=(e,t,n)=>{let i=pQ(t.cause),a=e.getInfo();a.validationMetaMap[i]?.lastAbortController.abort();let o=new AbortController;a.validationMetaMap[i]={lastAbortController:o},n.push(new Promise(async n=>{let a;try{a=await new Promise((n,r)=>{e.timeoutIds.validations[t.cause]&&(clearTimeout(e.timeoutIds.validations[t.cause]),e.endValidation()),e.timeoutIds.validations[t.cause]=setTimeout(async()=>{if(o.signal.aborted)return n(void 0);try{n(await this.runValidator({validate:t.validate,value:{value:e.store.state.value,fieldApi:e,signal:o.signal,validationSource:`field`},type:`validateAsync`}))}catch(e){r(e)}},t.debounceMs)})}catch(e){a=e}if(o.signal.aborted)return n(void 0);let s=fQ(a),c=r[e.name]?.[i],{newErrorValue:l,newSource:u}=GZ({formLevelError:c,fieldLevelError:s});if(e.getInfo().instance!==e)return n(void 0);e.setMeta(e=>({...e,errorMap:{...e?.errorMap,[i]:l},errorSourceMap:{...e.errorSourceMap,[i]:u}})),n(l)}))};for(let e of n)e.validate&&l(this,e,a);for(let e of i)e.validate&&l(e.field,e,o);let u=[];return(a.length||o.length)&&(u=await Promise.all(a),await Promise.all(o)),_Z(()=>{s&&this.endValidation();for(let e of c)e.endValidation()}),u.filter(Boolean)},this.validate=(e,t)=>{if(!this.state.meta.isTouched)return[];let n=t?.skipGroupValidation?[]:Array.from(this.form.formGroupApis).filter(e=>this.name.startsWith(e.name)),r=(t?.skipFormValidation?{fieldsErrorMap:{}}:this.form.validateSync(e)).fieldsErrorMap[this.name]??{};if(!t?.skipFormValidation)for(let t of n){if(t.state.meta.submissionAttempts===0)continue;let{fieldsErrorMap:n}=this.form.validateSync(e,{group:t,dontUpdateFormErrorMap:!0,filterFieldNames:e=>$Z(t.name,e)});r={...r,...n[this.name]??{}}}let{hasErrored:i}=this.validateSync(e,r),a=new WeakMap;for(let t of n){let{hasErrored:n}=t.validateSync(e,{},{skipRelatedFieldValidation:!0});a.set(t,n)}if(i&&!this.options.asyncAlways){this.getInfo().validationMetaMap[pQ(e)]?.lastAbortController.abort();let t=[];for(let r of n)r.getInfo().validationMetaMap[pQ(e)]?.lastAbortController.abort(),t.push(r.state.meta.errors);return[...this.state.meta.errors,...t.flat()]}let o=t?.skipFormValidation?Promise.resolve({}):this.form.validateAsync(e),s=this.validateAsync(e,o),c=[];for(let t of n)a.get(t)&&!t.options.asyncAlways||c.push(t.validateAsync(e,o,{skipRelatedFieldValidation:!0}));return c.length===0?s:Promise.all([s,...c]).then(e=>e.flat())},this.handleChange=e=>{this.setValue(e)},this.handleBlur=()=>{this.state.meta.isTouched||this.setMeta(e=>({...e,isTouched:!0})),this.state.meta.isBlurred||this.setMeta(e=>({...e,isBlurred:!0})),this.validate(`blur`),this.triggerOnBlurListener()},this.setErrorMap=e=>{this.setMeta(t=>({...t,errorMap:{...t.errorMap,...e}}))},this.parseValueWithSchema=e=>rQ.validate({value:this.state.value,validationSource:`field`},e),this.parseValueWithSchemaAsync=e=>rQ.validateAsync({value:this.state.value,validationSource:`field`},e),this.triggerOnBlurListener=()=>{let e=this.form.options.listeners?.onBlurDebounceMs;e&&e>0?(this.timeoutIds.formListeners.blur&&clearTimeout(this.timeoutIds.formListeners.blur),this.timeoutIds.formListeners.blur=setTimeout(()=>{this.form.options.listeners?.onBlur?.({formApi:this.form,fieldApi:this})},e)):this.form.options.listeners?.onBlur?.({formApi:this.form,fieldApi:this});let t=this.options.listeners?.onBlurDebounceMs;t&&t>0?(this.timeoutIds.listeners.blur&&clearTimeout(this.timeoutIds.listeners.blur),this.timeoutIds.listeners.blur=setTimeout(()=>{this.options.listeners?.onBlur?.({value:this.state.value,fieldApi:this})},t)):this.options.listeners?.onBlur?.({value:this.state.value,fieldApi:this})},this.triggerOnChangeListener=()=>{let e=this.form.options.listeners?.onChangeDebounceMs;e&&e>0?(this.timeoutIds.formListeners.change&&clearTimeout(this.timeoutIds.formListeners.change),this.timeoutIds.formListeners.change=setTimeout(()=>{this.form.options.listeners?.onChange?.({formApi:this.form,fieldApi:this})},e)):this.form.options.listeners?.onChange?.({formApi:this.form,fieldApi:this});let t=this.options.listeners?.onChangeDebounceMs;t&&t>0?(this.timeoutIds.listeners.change&&clearTimeout(this.timeoutIds.listeners.change),this.timeoutIds.listeners.change=setTimeout(()=>{this.options.listeners?.onChange?.({value:this.state.value,fieldApi:this})},t)):this.options.listeners?.onChange?.({value:this.state.value,fieldApi:this});for(let e of this.form.formGroupApis)$Z(e.name,this.name)&&e.triggerOnChangeListener()},this.triggerOnSubmitListener=()=>{this.options.listeners?.onSubmit?.({value:this.state.value,fieldApi:this})},this.form=t.form,this.name=t.name,this.options=t,this.timeoutIds={validations:{},listeners:{},formListeners:{}},this.store=wZ(e=>{this.form.store.get();let n=this.form.getFieldMeta(this.name)??{...aQ,...t.defaultMeta},r=this.form.getFieldValue(this.name);return!n.isTouched&&r===void 0&&this.options.defaultValue!==void 0&&!UZ(r,this.options.defaultValue)&&(r=this.options.defaultValue),e&&e.value===r&&e.meta===n?e:{value:r,meta:n}})}get state(){return this.store.state}runValidator(e){return iQ(e.validate)?rQ[e.type](e.value,e.validate):e.validate(e.value)}startValidation(){this.setMeta(e=>{let t=e._pendingValidationsCount+1;return{...e,_pendingValidationsCount:t,isValidating:t>0&&!e.isValidating||e.isValidating}})}endValidation(){this.setMeta(e=>{let t=Math.max(0,e._pendingValidationsCount-1);return{...e,_pendingValidationsCount:t,isValidating:t===0&&e.isValidating?!1:e.isValidating}})}};function fQ(e){if(e)return e}function pQ(e){switch(e){case`submit`:return`onSubmit`;case`blur`:return`onBlur`;case`mount`:return`onMount`;case`server`:return`onServer`;case`dynamic`:return`onDynamic`;default:return`onChange`}}function mQ(e){return{isSubmitted:e.isSubmitted??!1,isSubmitting:e.isSubmitting??!1,isValidating:e.isValidating??!1,submissionAttempts:e.submissionAttempts??0,isSubmitSuccessful:e.isSubmitSuccessful??!1}}function hQ(e){return{...aQ,...e,errors:[],isPristine:!0,isValid:!0,isDefaultValue:!0,isFieldsValidating:!1,isFieldsValid:!0,isGroupValid:!0,canSubmit:!0,isSubmitting:!1,isSubmitted:!1,isValidating:!1,submissionAttempts:0,isSubmitSuccessful:!1}}var gQ=class e{constructor(t){this.options={},this.setFormGroupState=e=>{this.form.baseStore.setState(t=>{let n=t.formGroupStateBase[this.name]??mQ({});return{...t,formGroupStateBase:{...t.formGroupStateBase,[this.name]:e(n)}}})},this._lastDistributedFieldNames={},this.update=e=>{this.options=e,this.name=e.name,!this.state.meta.isTouched&&this.options.defaultValue!==void 0&&(UZ(this.form.getFieldValue(this.name),e.defaultValue)||this.form.setFieldValue(this.name,e.defaultValue,{dontUpdateMeta:!0,dontValidate:!0,dontRunListeners:!0})),this.form.getFieldMeta(this.name)||this.form.setFieldMeta(this.name,{...aQ,...this.options.defaultMeta})},this.mount=()=>{this.update(this.options),this.form.formGroupApis.add(this),this.fieldInfo.instance=this,this.form.baseStore.setState(e=>({...e,formGroupStateBase:{...e.formGroupStateBase,[this.name]:e.formGroupStateBase[this.name]??mQ({...this.options.defaultState})}}));let{onMount:e}=this.options.validators||{};if(e){let t=this.runValidator({validate:e,value:{value:this.state.value,groupApi:this,validationSource:`form`},type:`validate`}),n=t,r;vQ(t)&&(n=t.group,r=t.fields);let i=_Q(n);i&&this.setMeta(e=>({...e,errorMap:{...e.errorMap,onMount:i},errorSourceMap:{...e.errorSourceMap,onMount:`field`}})),this.distributeFieldErrors(`onMount`,r)}return this.options.listeners?.onMount?.({value:this.state.value,groupApi:this}),()=>{for(let[e,t]of Object.entries(this.timeoutIds.validations))t&&(clearTimeout(t),this.timeoutIds.validations[e]=null);for(let[e,t]of Object.entries(this.timeoutIds.listeners))t&&(clearTimeout(t),this.timeoutIds.listeners[e]=null);for(let[e,t]of Object.entries(this.timeoutIds.formListeners))t&&(clearTimeout(t),this.timeoutIds.formListeners[e]=null);if(this.fieldInfo.instance===this){for(let[e,t]of Object.entries(this.fieldInfo.validationMetaMap))t?.lastAbortController.abort(),this.fieldInfo.validationMetaMap[e]=void 0;this.form.formGroupApis.delete(this),this.form.baseStore.setState(e=>({...e,formGroupStateBase:{...e.formGroupStateBase,[this.name]:mQ({})}})),this.fieldInfo.instance=null,this.options.listeners?.onUnmount?.({value:this.state.value,groupApi:this})}}},this.setValue=(e,t)=>{this.form.setFieldValue(this.name,e,KZ(t,{dontRunListeners:!0,dontValidate:!0})),t?.dontRunListeners||this.triggerOnChangeListener(),t?.dontValidate||this.validate(`change`)},this.getMeta=()=>this.store.state.meta,this.setMeta=e=>this.form.setFieldMeta(this.name,e),this.getInfo=()=>this.fieldInfo,this.getRelatedFields=()=>{let e=Object.values(this.form.fieldInfo),t=[];for(let n of e)n.instance&&n.instance instanceof dQ&&n.instance.name.startsWith(this.name)&&t.push(n.instance);return t},this.getRelatedFieldMetasDerived=()=>{let e=Object.entries(this.form.fieldMetaDerived.state),t=[];for(let[n,r]of e)n!==this.name&&$Z(this.name,n)&&t.push({...r,name:n});return t},this.buildChildFieldName=e=>e===``?this.name:e.startsWith(`[`)?`${this.name}${e}`:`${this.name}.${e}`,this.distributeFieldErrors=(e,t)=>{let n=this._lastDistributedFieldNames[e]??new Set,r=new Set;if(t)for(let[e,n]of Object.entries(t))n!=null&&n!==!1&&r.add(this.buildChildFieldName(e));let i=new Set([...n,...r]),a=!1;for(let n of i){let r=n.startsWith(this.name+`[`)?n.slice(this.name.length):n.slice(this.name.length+1),i=t?.[r],o=this.form.getFieldMeta(n);if(!o&&!i)continue;let s=o?.errorMap[e],{newErrorValue:c,newSource:l}=WZ({newFormValidatorError:i,isPreviousErrorFromFormValidator:o?.errorSourceMap[e]===`form`,previousErrorValue:s});c&&(a=!0),(s!==c||o?.errorSourceMap[e]!==l)&&this.form.setFieldMeta(n,(t=aQ)=>({...t,errorMap:{...t.errorMap,[e]:c},errorSourceMap:{...t.errorSourceMap,[e]:l}}))}return this._lastDistributedFieldNames[e]=r,a},this.validateSync=(t,n,r={})=>{let i=BZ(t,{...this.options,form:this.form,group:this,validationLogic:this.options.validationLogic||this.form.options.validationLogic||eQ}),a=(r.skipRelatedFieldValidation?[]:this.getRelatedFields()).reduce((e,n)=>{let r=BZ(t,{...n.options,form:n.form,validationLogic:n.form.options.validationLogic||eQ});return r.forEach(e=>{e.field=n}),e.concat(r)},[]),o=!1;_Z(()=>{let t=(t,r)=>{let i=bQ(r.cause),a=t===this,s;r.validate&&(s=t.runValidator({validate:r.validate,value:{value:t.store.state.value,validationSource:a?`form`:`field`,...t instanceof e?{groupApi:t}:{fieldApi:t}},type:`validate`}));let c=s,l;a&&vQ(s)&&(c=s.group,l=s.fields);let u=_Q(c),d=n[i],{newErrorValue:f,newSource:p}=GZ({formLevelError:d,fieldLevelError:u});t.state.meta.errorMap?.[i]!==f&&t.setMeta(e=>({...e,errorMap:{...e.errorMap,[i]:f},errorSourceMap:{...e.errorSourceMap,[i]:p}})),f&&(o=!0),a&&this.distributeFieldErrors(i,l)&&(o=!0)};for(let e of i)t(this,e);for(let e of a)e.validate&&t(e.field,e)});let s=bQ(`submit`);return this.state.meta.errorMap?.[s]&&t!==`submit`&&!o&&this.setMeta(e=>({...e,errorMap:{...e.errorMap,[s]:void 0},errorSourceMap:{...e.errorSourceMap,[s]:void 0}})),{hasErrored:o}},this.validateAsync=async(t,n,r={})=>{let i=VZ(t,{...this.options,form:this.form,group:this,validationLogic:this.options.validationLogic||this.form.options.validationLogic||eQ}),a=await n,o=r.skipRelatedFieldValidation?[]:this.getRelatedFields(),s=o.reduce((e,n)=>{let r=VZ(t,{...n.options,form:n.form,validationLogic:n.form.options.validationLogic||eQ});return r.forEach(e=>{e.field=n}),e.concat(r)},[]),c=[],l=[],u=i.some(e=>e.validate)||s.some(e=>e.validate);if(u){this.state.meta.isValidating||this.setMeta(e=>({...e,isValidating:!0}));for(let e of o)e.setMeta(e=>({...e,isValidating:!0}))}let d=(t,n,r)=>{let i=bQ(n.cause),o=t.getInfo();o.validationMetaMap[i]?.lastAbortController.abort();let s=new AbortController;o.validationMetaMap[i]={lastAbortController:s};let c=t===this;r.push(new Promise(async r=>{let o;try{o=await new Promise((r,i)=>{t.timeoutIds.validations[n.cause]&&clearTimeout(t.timeoutIds.validations[n.cause]),t.timeoutIds.validations[n.cause]=setTimeout(async()=>{if(s.signal.aborted)return r(void 0);try{r(await this.runValidator({validate:n.validate,value:{value:t.store.state.value,signal:s.signal,validationSource:c?`form`:`field`,...t instanceof e?{groupApi:t}:{fieldApi:t}},type:`validateAsync`}))}catch(e){i(e)}},n.debounceMs)})}catch(e){o=e}if(s.signal.aborted)return r(void 0);let l=o,u;c&&vQ(o)&&(l=o.group,u=o.fields);let d=_Q(l),f=a[t.name]?.[i],{newErrorValue:p,newSource:m}=GZ({formLevelError:f,fieldLevelError:d});if(t.getInfo().instance!==t)return r(void 0);t.setMeta(e=>({...e,errorMap:{...e?.errorMap,[i]:p},errorSourceMap:{...e.errorSourceMap,[i]:m}})),c&&this.distributeFieldErrors(i,u),r(p)}))};for(let e of i)e.validate&&d(this,e,c);for(let e of s)e.validate&&d(e.field,e,l);let f=[];if((c.length||l.length)&&(f=await Promise.all(c),await Promise.all(l)),u){this.setMeta(e=>({...e,isValidating:!1}));for(let e of o)e.setMeta(e=>({...e,isValidating:!1}))}return f.filter(Boolean)},this.validateAllFields=async e=>{let t=[];return _Z(()=>{Object.values(this.getRelatedFields()).forEach(n=>{t.push(Promise.resolve().then(()=>n.validate(e,{skipFormValidation:!0,skipGroupValidation:!0}))),n.store.state.meta.isTouched||n.setMeta(e=>({...e,isTouched:!0}))})}),(await Promise.all(t)).flat()},this.validateArrayFieldsStartingFrom=(e,t,n)=>this.form.validateArrayFieldsStartingFrom(e,t,n),this.validateField=(e,t)=>this.form.validateField(e,t),this.getFieldValue=e=>this.form.getFieldValue(e),this.getFieldMeta=e=>this.form.getFieldMeta(e),this.setFieldMeta=(e,t)=>this.form.setFieldMeta(e,t),this.setFieldValue=(e,t)=>this.form.setFieldValue(e,t),this.deleteField=e=>this.form.deleteField(e),this.pushFieldValue=(e,t)=>this.form.pushFieldValue(e,t),this.insertFieldValue=(e,t,n)=>this.form.insertFieldValue(e,t,n),this.replaceFieldValue=(e,t,n)=>this.form.replaceFieldValue(e,t,n),this.swapFieldValues=(e,t,n)=>this.form.swapFieldValues(e,t,n),this.moveFieldValues=(e,t,n)=>this.form.moveFieldValues(e,t,n),this.clearFieldValues=e=>this.form.clearFieldValues(e),this.resetField=e=>this.form.resetField(e),this.removeFieldValue=(e,t)=>this.form.removeFieldValue(e,t),this.areRelatedFieldsValid=()=>Object.values(this.getRelatedFields()).every(e=>e.state.meta.isValid),this.validate=(e,t)=>{let{fieldsErrorMap:n}=t?.skipFormValidation?{fieldsErrorMap:{}}:this.form.validateSync(e,{dontUpdateFormErrorMap:!0,filterFieldNames:e=>$Z(this.name,e)}),{hasErrored:r}=this.validateSync(e,n[this.name]??{},{skipRelatedFieldValidation:t?.skipRelatedFieldValidation});if(r&&!this.options.asyncAlways)return this.getInfo().validationMetaMap[bQ(e)]?.lastAbortController.abort(),this.state.meta.errors;let i=t?.skipFormValidation?Promise.resolve({}):this.form.validateAsync(e,{dontUpdateFormErrorMap:!0,filterFieldNames:e=>$Z(this.name,e)});return this.validateAsync(e,i,{skipRelatedFieldValidation:t?.skipRelatedFieldValidation})},this.triggerOnChangeListener=()=>{let e=this.form.options.listeners?.onChangeGroupDebounceMs;e&&e>0?(this.timeoutIds.formListeners.change&&clearTimeout(this.timeoutIds.formListeners.change),this.timeoutIds.formListeners.change=setTimeout(()=>{this.form.options.listeners?.onChangeGroup?.({formApi:this.form,groupApi:this})},e)):this.form.options.listeners?.onChangeGroup?.({formApi:this.form,groupApi:this});let t=this.options.listeners?.onChangeDebounceMs;t&&t>0?(this.timeoutIds.listeners.change&&clearTimeout(this.timeoutIds.listeners.change),this.timeoutIds.listeners.change=setTimeout(()=>{this.options.listeners?.onChange?.({value:this.state.value,groupApi:this})},t)):this.options.listeners?.onChange?.({value:this.state.value,groupApi:this})},this.triggerOnSubmitListener=()=>{this.options.listeners?.onSubmit?.({value:this.state.value,groupApi:this})},this._handleSubmit=async e=>{this.setFormGroupState(e=>({...e,isSubmitted:!1,submissionAttempts:e.submissionAttempts+1,isSubmitSuccessful:!1})),_Z(()=>{Object.values(this.getRelatedFields()).forEach(e=>{e.state.meta.isTouched||e.setMeta(e=>({...e,isTouched:!0}))})});let t=e??this.options.onSubmitMeta;this.setFormGroupState(e=>({...e,isSubmitting:!0}));let n=()=>{this.setFormGroupState(e=>({...e,isSubmitting:!1}))};if(await this.validateAllFields(`submit`),!this.areRelatedFieldsValid()){n(),this.options.onGroupSubmitInvalid?.({value:this.state.value,groupApi:this,meta:t});return}if(await this.validate(`submit`,{skipRelatedFieldValidation:!0}),!this.areRelatedFieldsValid()||!this.state.meta.isValid){n(),this.options.onGroupSubmitInvalid?.({value:this.state.value,groupApi:this,meta:t});return}_Z(()=>{Object.values(this.getRelatedFields()).forEach(e=>{e.options.listeners?.onGroupSubmit?.({value:e.state.value,fieldApi:e})})}),this.options.listeners?.onSubmit?.({groupApi:this,value:this.state.value});try{await this.options.onGroupSubmit?.({value:this.state.value,groupApi:this,meta:t}),_Z(()=>{this.setFormGroupState(e=>({...e,isSubmitted:!0,isSubmitSuccessful:!0})),n()})}catch(e){throw this.setFormGroupState(e=>({...e,isSubmitSuccessful:!1})),n(),e}},this.form=t.form,this.name=t.name,this.options=t,this.timeoutIds={validations:{},listeners:{},formListeners:{}},this.fieldInfo={instance:null,validationMetaMap:{onChange:void 0,onBlur:void 0,onSubmit:void 0,onMount:void 0,onServer:void 0,onDynamic:void 0}},this.store=wZ(e=>{this.form.formGroupMetaDerived.get(),this.form.baseStore.get();let n=this.form.getFormGroupMeta(this.name)??hQ(t.defaultMeta),r=this.form.getFieldValue(this.name);return!n.isTouched&&r===void 0&&this.options.defaultValue!==void 0&&!UZ(r,this.options.defaultValue)&&(r=this.options.defaultValue),e&&e.value===r&&e.meta===n?e:{value:r,meta:n}}),this.handleSubmit=this.handleSubmit.bind(this)}get state(){return this.store.state}runValidator(e){if(iQ(e.validate)){let t=rQ[e.type](e.value,e.validate);return e.type===`validate`?yQ(t):t.then(yQ)}return e.validate(e.value)}handleSubmit(e){return this._handleSubmit(e)}};function _Q(e){if(e)return e}function vQ(e){return!!e&&typeof e==`object`&&`fields`in e}function yQ(e){if(!e||typeof e!=`object`||!(`form`in e)&&!(`fields`in e))return e;let{form:t,fields:n,...r}=e;return{...r,group:t,fields:n}}function bQ(e){switch(e){case`submit`:return`onSubmit`;case`blur`:return`onBlur`;case`mount`:return`onMount`;case`server`:return`onServer`;case`dynamic`:return`onDynamic`;default:return`onChange`}}function xQ(e,t){if(!t)return;let n=Object.assign({},e,{state:QZ(e.state)});t(n),n.fieldInfo!==e.fieldInfo&&(e.fieldInfo=n.fieldInfo),n.options!==e.options&&(e.options=n.options);let r=Object.keys({values:null,validationMetaMap:null,fieldMetaBase:null,formGroupStateBase:null,isSubmitting:null,isSubmitted:null,isValidating:null,submissionAttempts:null,isSubmitSuccessful:null,_force_re_eval:null}).reduce((t,r)=>(e.state[r]!==n.state[r]&&(t[r]=n.state[r]),t),{});return _Z(()=>{Object.keys(r).length&&e.baseStore.setState(e=>({...e,...r})),n.state.errorMap!==e.state.errorMap&&e.setErrorMap(n.state.errorMap)}),n}function SQ(e,t){return e===t}function CQ(e,t=e=>e,n){let r=n?.compare??SQ,i=(0,J.useCallback)(t=>{let{unsubscribe:n}=e.subscribe(t);return n},[e]),a=(0,J.useCallback)(()=>e.get(),[e]);return(0,gV.useSyncExternalStoreWithSelector)(i,a,a,t,r)}var wQ=typeof window<`u`?J.useLayoutEffect:J.useEffect;function TQ(e){let[t,n]=(0,J.useState)(()=>({form:e.form,name:e.name})),[r,i]=(0,J.useState)(()=>new dQ({...e})),a=r;(t.form!==e.form||t.name!==e.name)&&(a=new dQ({...e}),i(a),n({form:e.form,name:e.name}));let o=CQ(a.store,e.mode===`array`?e=>e.meta._arrayVersion||0:e=>e.value),s=CQ(a.store,e=>e.meta.isTouched),c=CQ(a.store,e=>e.meta.isBlurred),l=CQ(a.store,e=>e.meta.isDirty),u=CQ(a.store,e=>e.meta.errorMap),d=CQ(a.store,e=>e.meta.errorSourceMap),f=CQ(a.store,e=>e.meta.isValidating),p=(0,J.useMemo)(()=>({...a,get state(){return{value:e.mode===`array`?a.state.value:o,get meta(){return{...a.state.meta,isTouched:s,isBlurred:c,isDirty:l,errorMap:u,errorSourceMap:d,isValidating:f}}}}}),[a,e.mode,o,s,c,l,u,d,f]);return wQ(a.mount,[a]),wQ(()=>{a.update(e)}),p}var EQ=(({children:e,...t})=>{let n=TQ(t),r=(0,J.useMemo)(()=>kZ(e,n),[e,n]);return(0,X.jsx)(X.Fragment,{children:r})});function DQ(){return(0,J.useState)(()=>XZ())[0]}var OQ=J,kQ=`18.3.1`.split(`.`)[0]===`17`?DQ:OQ.useId;function AQ(e){let[t,n]=(0,J.useState)(()=>({form:e.form,name:e.name})),[r,i]=(0,J.useState)(()=>new gQ({...e}));(t.form!==e.form||t.name!==e.name)&&(i(new gQ({...e})),n({form:e.form,name:e.name}));let a=CQ(r.store,e=>e.value),o=CQ(r.store,e=>e.meta.isTouched),s=CQ(r.store,e=>e.meta.isBlurred),c=CQ(r.store,e=>e.meta.isDirty),l=CQ(r.store,e=>e.meta.errorMap),u=CQ(r.store,e=>e.meta.errorSourceMap),d=CQ(r.store,e=>e.meta.isValidating),f=CQ(r.store,e=>e.meta.isSubmitting),p=CQ(r.store,e=>e.meta.isSubmitted),m=CQ(r.store,e=>e.meta.submissionAttempts),h=CQ(r.store,e=>e.meta.isSubmitSuccessful),g=CQ(r.store,e=>e.meta.canSubmit),_=CQ(r.store,e=>e.meta.isValid),v=CQ(r.store,e=>e.meta.isFieldsValid),y=CQ(r.store,e=>e.meta.isFieldsValidating),b=CQ(r.store,e=>e.meta.isGroupValid),x=(0,J.useMemo)(()=>({...r,handleSubmit:((...e)=>r._handleSubmit(...e)),get state(){return{...r.state,value:a,get meta(){return{...r.state.meta,isTouched:o,isBlurred:s,isDirty:c,errorMap:l,errorSourceMap:u,isValidating:d,isSubmitting:f,isSubmitted:p,submissionAttempts:m,isSubmitSuccessful:h,canSubmit:g,isValid:_,isFieldsValid:v,isFieldsValidating:y,isGroupValid:b}}}}}),[r,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b]);return wQ(r.mount,[r]),wQ(()=>{r.update(e)}),x}var jQ=(({children:e,...t})=>{let n=AQ(t),r=(0,J.useMemo)(()=>kZ(e,n),[e,n]);return(0,X.jsx)(X.Fragment,{children:r})});function MQ({form:e,selector:t=e=>e,children:n}){let r=CQ(e.store,t);return(0,X.jsx)(X.Fragment,{children:kZ(n,r)})}function NQ(e){let t=kQ(),[n,r]=(0,J.useState)(e?.formId),[i,a]=(0,J.useState)(()=>new cQ({...e,formId:e?.formId??t}));if(n!==e?.formId){let n=e?.formId??t;a(new cQ({...e,formId:n})),r(n)}let o=(0,J.useMemo)(()=>{let e={...i,handleSubmit:((...e)=>i._handleSubmit(...e)),get formId(){return i._formId},get state(){return i.store.state}};return e.Field=function(e){return(0,X.jsx)(EQ,{...e,form:i})},e.FormGroup=function(e){return(0,X.jsx)(jQ,{...e,form:i})},e.Subscribe=function(e){return(0,X.jsx)(MQ,{form:i,selector:e.selector,children:e.children})},e},[i]);wQ(i.mount,[]),wQ(()=>{i.update(e)});let s=(0,J.useRef)(!1);return wQ(()=>{s.current&&e?.transform&&xQ(i,e.transform)},[i,e?.transform]),wQ(()=>{s.current=!0}),o}var PQ=kn(W),FQ=kn(U({message:W}));function IQ(e){for(let t of e.errors){let e=et(Le(He(FQ(t),e=>e.message),()=>PQ(t)));if(e!==void 0&&e.length>0)return e}}var LQ={neutral:`progress-neutral`,primary:`progress-primary`,secondary:`progress-secondary`,accent:`progress-accent`,success:`progress-success`,info:`progress-info`,warning:`progress-warning`,error:`progress-error`},RQ=(0,J.forwardRef)(function({className:e,tone:t=`primary`,...n},r){return(0,X.jsx)(`progress`,{...n,"data-complete":n.value!==void 0&&Number(n.value)>=Number(n.max??1)?`true`:void 0,className:Q(`progress caps-gooey-motion caps-gooey-progress w-full`,LQ[t],e),ref:r})});(0,J.forwardRef)(function({label:e,value:t,max:n,tone:r=`info`,className:i,...a},o){return(0,X.jsxs)(`div`,{...a,ref:o,className:Q(`caps-game-meter`,i),children:[(0,X.jsxs)(`div`,{className:`caps-game-meter-readout`,children:[(0,X.jsx)(`span`,{children:e}),(0,X.jsxs)(`span`,{className:`caps-game-meter-value`,children:[t,` / `,n]})]}),(0,X.jsx)(RQ,{"aria-label":e,value:t,max:n,tone:r})]})});function zQ({className:e,items:t,onCancel:n,onRemove:r,onRetry:i,rowClassName:a}){return t.length?(0,X.jsx)(`div`,{"aria-live":`polite`,className:`caps-upload-queue flex w-full min-w-0 flex-col gap-sm ${e??``}`,"data-upload-rows":!0,children:t.map(e=>(0,X.jsx)(HQ,{item:e,onCancel:n,onRemove:r,onRetry:i,...a===void 0?{}:{rowClassName:a}},e.id))}):null}function BQ({action:e,id:t,onAction:n,retry:r=!1}){return e?(0,X.jsx)(LG,{"aria-label":e.accessibleLabel,title:e.label,variant:`ghost`,size:`xs`,className:`motion-reduce:transition-none`,icon:r?(0,X.jsx)(uW,{}):(0,X.jsx)(hW,{}),onClick:()=>void n(t),type:`button`}):null}function VQ({item:e}){return(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`span`,{className:`block min-w-0 truncate`,title:e.name,children:e.name}),(0,X.jsx)(`div`,{className:`caps-upload-details`,children:(0,X.jsxs)(`span`,{"aria-live":e.alert?`assertive`:void 0,className:`caps-upload-status min-w-0 break-words`,"data-upload-status":!0,role:e.alert?`alert`:void 0,children:[e.alert??e.statusLabel,` `,e.progressLabel]})})]})}function HQ({item:e,onCancel:t,onRemove:n,onRetry:r,rowClassName:i}){return(0,X.jsxs)(`div`,{className:`caps-upload-row grid w-full min-w-0 max-w-full grid-cols-[2rem_minmax(0,1fr)_auto] items-center gap-sm p-sm text-xs ${i??``}`,children:[e.preview.kind===`image`?(0,X.jsx)(`img`,{alt:``,className:`caps-upload-preview mask mask-squircle size-8 shrink-0 object-cover`,src:e.preview.url}):(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`caps-upload-preview mask mask-squircle flex size-8 shrink-0 items-center justify-center bg-base-300`,children:(0,X.jsx)(oW,{className:`size-4`})}),(0,X.jsx)(VQ,{item:e}),(0,X.jsx)(UQ,{actions:e.actions,id:e.id,onCancel:t,onRemove:n,onRetry:r}),(0,X.jsx)(RQ,{"aria-label":`${e.name} progress`,className:`caps-upload-progress`,tone:e.alert?`error`:e.progress===100?`success`:`accent`,max:100,value:e.progress??(e.alert?0:void 0)})]})}function UQ({actions:e,id:t,onCancel:n,onRemove:r,onRetry:i}){return(0,X.jsxs)(`div`,{className:`caps-upload-actions flex min-w-0 flex-wrap justify-end gap-xs`,children:[(0,X.jsx)(BQ,{action:e.retry,id:t,onAction:i,retry:!0}),(0,X.jsx)(BQ,{action:e.cancel,id:t,onAction:n}),(0,X.jsx)(BQ,{action:e.remove,id:t,onAction:r})]})}var WQ=J.createContext(void 0);function GQ(e){let t=J.useContext(WQ);if(t===void 0&&!e)throw Error(lE(47));return t}var KQ={...MV,disabled:e=>e.disabled,instantType:e=>e.instantType===`trigger-change`&&!MV.open(e)?void 0:e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,isPressOpenedByTrigger:(e,t)=>e.openChangeReason===`trigger-press`&&MV.isOpenedByTrigger(e,t),isTouchPressOpen:(e,t)=>t&&e.openMethod===`touch`&&e.openChangeReason===`trigger-press`,hasTriggerFocusGuards:(e,t)=>MV.isOpenedByTrigger(e,t)&&!e.focusManagerModal,modal:e=>e.modal,titleElementId:e=>e.titleElementId,descriptionElementId:e=>e.descriptionElementId,openOnHover:e=>e.openOnHover,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},qQ=class extends CV{constructor(e,t,n){let r=new rV;super(JQ(e,r,t,n),YQ(r),KQ)}setOpen=(e,t)=>{let n=t.reason===Sz,r=t.reason===`trigger-press`&&t.event.detail===0,i=!e&&(t.reason===`escape-key`||t.reason==null),a=ZB(t),o=this.select(`activeTriggerId`);if(!e&&t.reason===`close-press`&&t.trigger==null&&o!=null&&(t.trigger=this.context.triggerElements.getById(o)??this.select(`activeTriggerElement`)??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let s=()=>{let n=XB(this.state,e,t.trigger,a());n.openChangeReason=t.reason,this.update(n)};n?(this.context.stickIfOpen=!0,this.context.stickIfOpenTimeout.start(500,()=>{this.context.stickIfOpen=!1}),aI.flushSync(s)):s();let c;r?c=`click`:i?c=`dismiss`:t.reason===`focus-out`&&(c=`focus`),this.set(`instantType`,c)}};function JQ(e,t,n,r=!1){let i={...EV(t,n,r),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,openOnHover:!1,closeDelay:0,adaptiveOrigin:void 0,...e};return i.open&&e?.mounted===void 0&&(i.mounted=!0),i}function YQ(e){return{popupRef:J.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:J.createRef(),beforeTriggerFocusGuardRef:J.createRef(),beforeContentFocusGuardRef:J.createRef(),stickIfOpenTimeout:new oE,stickIfOpen:!0,triggerElements:e}}var XQ=fV(function({props:e}){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,modal:o=!1,handle:s,triggerId:c,defaultTriggerId:l=null}=e,u=QQ(s,{modal:o,open:r,openProp:n,activeTriggerId:l,triggerIdProp:c});u.useControlledProp(`openProp`,n),u.useControlledProp(`triggerIdProp`,c);let d=u.useState(`open`),f=u.useState(`mounted`),p=u.useState(`payload`);u.useContextCallback(`onOpenChange`,i),u.useContextCallback(`onOpenChangeComplete`,a),nV(u,d),$B(u);let{forceUnmount:m}=eV(d,u,()=>{u.context.stickIfOpen=!0,u.set(`openChangeReason`,null)});u.useSyncedValues({modal:o}),J.useEffect(()=>{d||u.context.stickIfOpenTimeout.clear()},[u,d]),J.useImperativeHandle(e.actionsRef,()=>({unmount:m,close:()=>u.setOpen(!1,yz(Dz))}),[m,u]);let h=d||f||s!=null;return(0,X.jsxs)(WQ.Provider,{value:u,children:[s&&(0,X.jsx)(qB,{handle:s,store:u}),h&&(0,X.jsx)($Q,{store:u,modal:o}),typeof t==`function`?t({payload:p}):t]})});function ZQ(e){return GQ(!0)?(0,X.jsx)(XQ,{props:e}):(0,X.jsx)(SB,{children:(0,X.jsx)(XQ,{props:e})})}function QQ(e,t){let n=KB((e,n)=>new qQ(t,e,n));return J.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function $Q({store:e,modal:t}){let n=IB(e.useState(`floatingRootContext`),{outsidePressEvent:{mouse:t===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}}),r=n.reference,i=n.floating;return tV(e,{activeTriggerProps:r,inactiveTriggerProps:r,popupProps:i}),null}function e$(e,t){function n(n,r,i){let a=n.currentTarget;aI.flushSync(()=>{e.setOpen(!1,yz(Tz,n.nativeEvent,a))}),Ak(a.isConnected?a:t.current,r,i)?.focus()}function r(t){n(t,-1,e.select(`positionerElement`))}function i(t){let r=e.select(`positionerElement`);r&&jk(t,r)?e.context.beforeContentFocusGuardRef.current?.focus():n(t,1,r)}return{handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}var t$=pV(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,handle:s,payload:c,openOnHover:l=!1,delay:u=300,closeDelay:d=0,id:f,...p}=e,m=GQ(!0),h=NV(s)??m;if(!h)throw Error(lE(74));let g=eD(f),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerPopupId`,g),x=J.useRef(null),{registerTrigger:S,isMountedByThisTrigger:C}=QB(g,x,h,{payload:c,disabled:a,openOnHover:l,closeDelay:d}),w=h.useState(`isPressOpenedByTrigger`,g),T=h.useState(`isTouchPressOpen`,l),E=h.useState(`hasTriggerFocusGuards`,g),D=VV(v,{enabled:!a&&l&&!T,mouseOnly:!0,move:!1,handleClose:YV(),restMs:u,delay:{close:d},triggerElementRef:x,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),O=NB(v,{stickIfOpen:QT(()=>h.context.stickIfOpen)}),k=kU(()=>h.select(`open`),e=>{h.set(`openMethod`,e)}),A=h.useState(`triggerProps`,C),{getButtonProps:j,buttonRef:M}=gz({disabled:a,native:o}),N={open(e){return w?gO.open(e):hO.open(e)}},{handlePreFocusGuardFocus:P,handleFocusTargetFocus:F}=e$(h,x),I=zE(`button`,e,{state:{disabled:a,open:y},ref:[M,t,S,x],props:[O.reference,D,A,k,{[oB]:``,id:g,"aria-haspopup":`dialog`,"aria-expanded":y,"aria-controls":b},p,j],stateAttributesMapping:N}),L=(0,X.jsx)(J.Fragment,{children:I},g);return E?(0,X.jsxs)(J.Fragment,{children:[(0,X.jsx)(Wz,{ref:h.context.beforeTriggerFocusGuardRef,onFocus:P}),L,(0,X.jsx)(Wz,{ref:h.context.triggerFocusTargetRef,onFocus:F})]}):L}),n$=J.createContext(void 0);function r$(){let e=J.useContext(n$);if(e===void 0)throw Error(lE(45));return e}var i$=J.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return GQ().useState(`mounted`)||n?(0,X.jsx)(n$.Provider,{value:n,children:(0,X.jsx)(pB,{ref:t,...r})}):null}),a$=J.createContext(void 0);function o$(){let e=J.useContext(a$);if(!e)throw Error(lE(46));return e}function s$(e){let{nodeId:t,externalTree:n,rootContext:r}=e,i=r.useState(`referenceElement`),a=r.useState(`floatingElement`),o=r.useState(`domReferenceElement`),s=r.useState(`open`),c=r.useState(`floatingId`),[l,u]=J.useState(null),d=J.useRef(null),f=yB(n),p=J.useMemo(()=>({reference:i,floating:a,domReference:o}),[i,a,o]),m=qH({...e,elements:{...p,...l&&{reference:l}}}),h=J.useCallback(e=>{let t=mD(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>e.getClientRects(),contextElement:e}:e;u(t),m.refs.setReference(t)},[m.refs]),g=J.useMemo(()=>({...m.refs,setPositionReference:h,domReference:d}),[m.refs,h]),_=J.useMemo(()=>({...m.elements,domReference:o}),[m.elements,o]),v=J.useMemo(()=>({...m,dataRef:r.context.dataRef,open:s,onOpenChange:r.setOpen,events:r.context.events,floatingId:c,refs:g,elements:_,nodeId:t,rootStore:r}),[m,g,_,t,r,s,c]);return Kk(()=>{o&&(d.current=o)},[o]),Kk(()=>{r.context.dataRef.current.floatingContext=v;let e=f?.nodesRef.current.find(e=>e.id===t);e&&(e.context=v)}),J.useMemo(()=>({...m,context:v,refs:g,elements:_,rootStore:r}),[m,g,_,v,r])}var c$=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=HO(e,t)||{};if(l==null)return{};let d=ok(u),f={x:n,y:r},p=JO(i),m=KO(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=s.floating[y]||a.floating[m],C=b/2-x/2,w=S/2-h[m]/2-1,T=Math.min(d[_],w),E=Math.min(d[v],w),D=T,O=S-h[m]-E,k=S/2-h[m]/2+C,A=VO(D,k,O),j=!c.arrow&&WO(i)!=null&&k!==A&&a.reference[m]/2-(k<D?T:E)-h[m]/2<0,M=j?k<D?k-D:k-O:0;return{[p]:f[p]+M,data:{[p]:A,centerOffset:k-A-M,...j&&{alignmentOffset:M}},reset:j}}}),l$=(e,t)=>{let{name:n,fn:r}=c$(e);return{name:n,fn:r,options:[e,t]}},u$={name:`hide`,async fn(e){let{width:t,height:n,x:r,y:i}=e.rects.reference,a=t===0&&n===0&&r===0&&i===0,o=await e.platform.detectOverflow(e,{elementContext:`reference`});return{data:{referenceHidden:o.top-n>=0||o.right-t>=0||o.bottom-n>=0||o.left-t>=0||a}}}},d$={sideX:`left`,sideY:`top`},f$=`--available-width`,p$=`--available-height`,m$=`--anchor-width`,h$=`--anchor-height`,g$=`--transform-origin`,_$=f$,v$=p$;function y$(e,t,n){let r=e===`inline-start`||e===`inline-end`;return{top:`top`,right:r?n?`inline-start`:`inline-end`:`right`,bottom:`bottom`,left:r?n?`inline-end`:`inline-start`:`left`}[t]}function b$(e,t,n){let{rects:r,placement:i}=e;return{side:y$(t,UO(i),n),align:WO(i)||`center`,anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function x$(e){return S$(e,s$)}function S$(e,t){let{anchor:n,positionMethod:r=`absolute`,side:i=`bottom`,sideOffset:a=0,align:o=`center`,alignOffset:s=0,collisionBoundary:c,collisionPadding:l=5,sticky:u=!1,arrowPadding:d=5,disableAnchorTracking:f=!1,inline:p,keepMounted:m=!1,floatingRootContext:h,mounted:g,collisionAvoidance:_,shift:v,nodeId:y,adaptiveOrigin:b,lazyFlip:x=!1,externalTree:S}=e,C=_.side||`flip`,w=_.align||`flip`,T=_.fallbackAxisSide||`end`,E=v?.crossAxis??!1,D=v?.rootBoundary,O=typeof n==`function`?n:void 0,k=QT(O),A=O?k:n,j=Iz(n),M=Iz(g),N=Zk()===`rtl`,[P,F]=J.useState(null);!g&&P!==null&&F(null);let I=x===`placement`,L=P?UO(P):null,ee=P&&I?WO(P)||`center`:null,te=L||{top:`top`,right:`right`,bottom:`bottom`,left:`left`,"inline-end":N?`left`:`right`,"inline-start":N?`right`:`left`}[i],ne=ee||o,re=ne===`center`?te:`${te}-${ne}`,R=l;typeof R==`number`?R={top:R,right:R,bottom:R,left:R}:R&&={top:R.top||0,right:R.right||0,bottom:R.bottom||0,left:R.left||0};let ie=+(i===`bottom`),ae=+(i===`top`),z=+(i===`right`),oe=+(i===`left`),se={boundary:c===`clipping-ancestors`?`clippingAncestors`:c,padding:R},ce=J.useRef(null),le=Iz(a),ue=Iz(s),de=typeof a==`function`?0:a,fe=typeof s==`function`?0:s,pe=[];p&&pe.push(p),pe.push(JH(e=>{let t=b$(e,i,N),n=typeof le.current==`function`?le.current(t):le.current,r=typeof ue.current==`function`?ue.current(t):ue.current;return{mainAxis:n,crossAxis:r,alignmentAxis:r}},[de,fe,N,i]));let me=w===`none`&&C!==`shift`,he=!me&&(u||E||C===`shift`),ge=C===`none`?null:ZH({...se,padding:{top:R.top+1+ie,right:R.right+1+oe,bottom:R.bottom+1+ae,left:R.left+1+z},mainAxis:!E&&C===`flip`,crossAxis:w===`flip`&&`alignment`,fallbackAxisSideDirection:T}),_e=me?null:YH({...se,rootBoundary:D,mainAxis:w!==`none`,crossAxis:he,limiter:u||E?void 0:XH(e=>{if(!ce.current)return{};let{width:t,height:n}=ce.current.getBoundingClientRect(),r=qO(UO(e.placement)),i=r===`y`?t:n,a=r===`y`?R.left+R.right:R.top+R.bottom;return{offset:i/2+a/2}})},[se,u,E,D,R,w]);C===`shift`||w===`shift`||ne===`center`?pe.push(_e,ge):pe.push(ge,_e),pe.push(QH({...se,apply({elements:{floating:e},availableWidth:t,availableHeight:n,rects:r}){if(!M.current)return;let i=e.style;i.setProperty(_$,`${t}px`),i.setProperty(v$,`${n}px`);let a=dD(e).devicePixelRatio||1,{x:o,y:s,width:c,height:l}=r.reference,u=(Math.round((o+c)*a)-Math.round(o*a))/a,d=(Math.round((s+l)*a)-Math.round(s*a))/a;i.setProperty(m$,`${u}px`),i.setProperty(h$,`${d}px`)}}),l$(e=>({element:ce.current||uk(e.elements.floating).createElement(`div`),padding:ce.current?d:0}),[d]),{name:`transformOrigin`,fn(e){let{elements:{floating:t},middlewareData:n,placement:r,platform:o,rects:s,y:c}=e,l=UO(r),u=WO(r),d=qO(l)===`y`,f=ce.current,p=typeof a==`function`?a(b$(e,i,N)):a,m;m=!f&&u&&Math.abs(d?n.shift?.x||0:n.shift?.y||0)<=1?u===`start`===(d&&o.isRTL?.(t)===!0)?`100%`:`0%`:`${(d?n.arrow?.x||0:n.arrow?.y||0)+(d?f?.clientWidth||0:f?.clientHeight||0)/2}px`;let h=l===`top`||l===`left`?`calc(100% + ${p}px)`:`${-p}px`;return he&&d&&Math.abs(n.shift?.y||0)>p&&(h=`${s.reference.y+s.reference.height/2-c}px`),t.style.setProperty(g$,d?`${m} ${h}`:`${h} ${m}`),{}}},u$,b),Kk(()=>{!g&&h&&h.update({referenceElement:null,floatingElement:null,domReferenceElement:null,positionReference:null})},[g,h]);let ve=J.useMemo(()=>({ancestorScroll:!f,elementResize:!f&&typeof ResizeObserver<`u`,layoutShift:!f&&typeof IntersectionObserver<`u`}),[f]),{refs:ye,elements:be,x:xe,y:Se,middlewareData:Ce,update:we,placement:Te,context:Ee,isPositioned:De,floatingStyles:Oe}=t({rootContext:h,open:m?g:void 0,placement:re,middleware:pe,strategy:r,whileElementsMounted:m?void 0:(...e)=>FH(...e,ve),nodeId:y,externalTree:S}),{sideX:ke,sideY:Ae}=Ce.adaptiveOrigin||d$,je=De?r:`fixed`,Me=J.useMemo(()=>{let e;return e=De?b?{position:je,[ke]:xe,[Ae]:Se}:{...Oe,position:je}:{position:je,top:0,left:0},e[_$]=`100vw`,e[v$]=`100vh`,De||(e.opacity=0),e},[b,je,ke,xe,Ae,Se,Oe,De]),Ne=J.useRef(null);Kk(()=>{if(!g)return;let e=j.current,t=typeof e==`function`?e():e,n=(C$(t)?t.current:t)||null;n!==Ne.current&&(ye.setPositionReference(n),Ne.current=n)},[g,ye,A,j]),J.useEffect(()=>{if(!g)return;let e=j.current;typeof e!=`function`&&C$(e)&&e.current!==Ne.current&&(ye.setPositionReference(e.current),Ne.current=e.current)},[g,ye,A,j]),J.useEffect(()=>{if(m&&g&&be.reference&&be.floating)return FH(be.reference,be.floating,we,ve)},[m,g,be,we,ve]);let Pe=UO(Te),Fe=y$(i,Pe,N),Ie=WO(Te)||`center`,Le=!!Ce.hide?.referenceHidden;Kk(()=>{x&&g&&De&&(Pe!==te||I&&Ie!==ne)&&F(Te)},[x,I,g,De,Te,Pe,Ie,te,ne]);let Re=J.useMemo(()=>({position:`absolute`,top:Ce.arrow?.y,left:Ce.arrow?.x}),[Ce.arrow]),B=Ce.arrow?.centerOffset!==0;return J.useMemo(()=>({positionerStyles:Me,arrowStyles:Re,arrowRef:ce,arrowUncentered:B,side:Fe,align:Ie,physicalSide:Pe,anchorHidden:Le,refs:ye,context:Ee,isPositioned:De,update:we}),[Me,Re,ce,B,Fe,Ie,Pe,Le,ye,Ee,De,we])}function C$(e){return e!=null&&`current`in e}function w$(e){let{store:t,domReference:n,positionerElement:r,open:i}=e,a=J.useRef(null),o=J.useRef(null),s=VB(r);Kk(()=>{i||(o.current?.abort(),o.current=null,t.state.instantType===`trigger-change`&&t.set(`instantType`,void 0))},[i,t]),Kk(()=>{let e=n,r=a.current;if(e&&(a.current=e),!r||!e||e===r||!t.select(`open`))return;t.set(`instantType`,void 0);let i=new AbortController;return o.current=i,s(()=>{t.select(`open`)&&t.set(`instantType`,`trigger-change`)},i.signal),()=>{i.abort()}},[n,s,t])}function T$(e){return e===`starting`?aB:rE}function E$(e,t,{styles:n,transitionStatus:r,props:i,refs:a,hidden:o,inert:s=!1}){let c={...n};return s&&(c.pointerEvents=`none`),zE(`div`,e,{state:t,ref:a,props:[{role:`presentation`,hidden:o,style:c},T$(r),i],stateAttributesMapping:_O})}var D$=20;function O$(e,t,n,r){let[i,a]=J.useState(!1);Kk(()=>{if(!e||!t||n==null){a(!1);return}let r=uk(n).documentElement.clientWidth,i=n.offsetWidth;a(r>0&&i>0&&i>=r-D$)},[e,t,n]),yU(e&&(!t||i),r)}var k$=J.forwardRef(function(e,t){let{render:n,className:r,style:i,anchor:a,positionMethod:o,side:s,align:c,sideOffset:l,alignOffset:u,collisionBoundary:d=`clipping-ancestors`,collisionPadding:f,arrowPadding:p,sticky:m,disableAnchorTracking:h=!1,collisionAvoidance:g=sB,..._}=e,v=GQ(),y=r$(),b=bB(),x=v.useState(`floatingRootContext`),S=v.useState(`mounted`),C=v.useState(`open`),w=v.useState(`openChangeReason`),T=v.useState(`activeTriggerElement`),E=v.useState(`modal`),D=v.useState(`openMethod`),O=v.useState(`positionerElement`),k=v.useState(`instantType`),A=v.useState(`transitionStatus`),j=x$({anchor:a,floatingRootContext:x,positionMethod:o,mounted:S,side:s,sideOffset:l,align:c,alignOffset:u,arrowPadding:p,collisionBoundary:d,collisionPadding:f,sticky:m,disableAnchorTracking:h,keepMounted:y,nodeId:b,collisionAvoidance:g,adaptiveOrigin:v.useState(`adaptiveOrigin`)});w$({store:v,domReference:x.useState(`domReferenceElement`),positionerElement:O,open:C});let M=E===!0&&w!==`trigger-hover`;O$(C&&M,D===`touch`,O,T);let N=v.useStateSetter(`positionerElement`),P=E$(e,{open:C,side:j.side,align:j.align,anchorHidden:j.anchorHidden,instant:k},{styles:j.positionerStyles,transitionStatus:A,props:_,refs:[t,N],hidden:!S,inert:!C});return(0,X.jsxs)(a$.Provider,{value:j,children:[S&&M&&(0,X.jsx)(sU,{inert:oU(!C),cutout:T}),(0,X.jsx)(xB,{id:b,children:P})]})}),A$=J.createContext(void 0);function j$(e){let t=J.useContext(A$);if(t===void 0&&!e)throw Error(lE(69));return t}var M$=J.createContext(void 0);function N$(){let[e,t]=J.useState(0),n=QT(()=>(t(e=>e+1),()=>{t(e=>Math.max(0,e-1))}));return{context:J.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}var P$=J.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=GQ(),l=o$(),u=j$(!0)!=null,{context:d,hasClosePart:f}=N$(),p=c.useState(`open`),m=c.useState(`openMethod`),h=c.useState(`instantType`),g=c.useState(`transitionStatus`),_=c.useState(`popupProps`),v=c.useState(`titleElementId`),y=c.useState(`descriptionElementId`),b=c.useState(`modal`),x=c.useState(`mounted`),S=c.useState(`openChangeReason`),C=c.useState(`activeTriggerElement`),w=c.useState(`floatingRootContext`),T=w.useState(`floatingId`),E=c.useState(`disabled`),D=c.useState(`openOnHover`),O=c.useState(`closeDelay`);HB({open:p,ref:c.context.popupRef,onComplete(){p&&c.context.onOpenChangeComplete?.(!0)}}),zV(w,{enabled:D&&!E,closeDelay:O});let k=a===void 0?GB(c.context.popupRef):a,A=b!==!1&&f;c.useSyncedValue(`focusManagerModal`,A);let j=c.useStateSetter(`popupElement`),M=zE(`div`,e,{state:{open:p,side:l.side,align:l.align,instant:h,transitionStatus:g},ref:[t,c.context.popupRef,j],props:[_,{id:T,role:`dialog`,...WB,"aria-labelledby":v,"aria-describedby":y,onKeyDown(e){u&&tU.has(e.key)&&e.stopPropagation()}},T$(g),s],stateAttributesMapping:vO});return(0,X.jsx)(MB,{context:w,openInteractionType:m,modal:A,disabled:!x||S===`trigger-hover`,initialFocus:k,returnFocus:o,restoreFocus:`popup`,getInsideElements:()=>[c.context.beforeTriggerFocusGuardRef.current],previousFocusableElement:hD(C)?C:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:(0,X.jsx)(M$.Provider,{value:d,children:M})})}),F$=(0,J.forwardRef)(function({children:e,className:t,type:n=`button`,...r},i){return(0,X.jsxs)(`button`,{...r,ref:i,type:n,className:Q(`select caps-select caps-combobox-trigger w-full`,t),children:[(0,X.jsx)(`span`,{children:e}),(0,X.jsx)(tW,{className:`caps-select-chevron`,"aria-hidden":`true`})]})});function I$({defaultOpen:e,defaultValue:t,getKey:n,getSearchText:r,groupBy:i,id:a,isDisabled:o,items:s,onOpenChange:c,onCommit:l,multiple:u,controlledOpen:d,controlledKeys:f,trigger:p}){let m=`${a}-listbox`,[h,g]=(0,J.useState)(``),[_,v]=(0,J.useState)(!1),[y,b]=(0,J.useState)(t),[x,S]=(0,J.useState)(e),C=f??(y===null?[]:[y]),w=p?d??x:!0,T=(0,J.useMemo)(()=>{let e=h.trim().toLowerCase();return e?s.filter(t=>r(t).toLowerCase().includes(e)):s},[r,s,h]),E=oK({getKey:n,isDisabled:o,items:T});(0,J.useEffect)(()=>{if(E.activeKey!==null)return;let e=E.enabledItems.find(e=>C.includes(n(e)))??E.enabledItems[0];e&&E.setActiveKey(n(e))},[E.activeKey,E.enabledItems,E.setActiveKey,n,C]);let D=e=>{v(!1),e||g(``),d===void 0&&S(e),c?.(e)},O=e=>`${m}-option-${encodeURIComponent(e)}`,k=e=>{let t=n(e);f===void 0&&b(t),l(e),p&&!u&&D(!1)},A=e=>{v(!0),g(e.target.value),E.setActiveKey(null)},j=e=>{if(pG(e))return;let t;switch(e.key){case`ArrowDown`:t=[1,void 0];break;case`ArrowUp`:t=[-1,void 0];break;case`End`:t=[1,`end`];break;case`Home`:t=[-1,`start`]}t?(v(!0),e.preventDefault(),E.move(t[0],t[1])):e.key===`Enter`&&E.activeItem&&(e.preventDefault(),k(E.activeItem))},M=(0,J.useMemo)(()=>{if(!i)return[{label:``,items:T}];let e=new Map;for(let t of T){let n=i(t),r=e.get(n);r?r.push(t):e.set(n,[t])}return[...e].map(([e,t])=>({label:e,items:t}))},[T,i]);return{keyboardNavigation:_,onPointerMove:()=>{v(!1)},activeKey:E.activeKey,activeItem:E.activeItem,groups:M,inputValue:h,listboxId:m,onInputChange:A,onInputKeyDown:j,optionId:O,open:w,commit:k,selectedKeys:C,setOpen:D}}function L$(e){let{"aria-describedby":t,"aria-invalid":n,"aria-label":r,"aria-labelledby":i,"aria-required":a,activeTone:o=`neutral`,container:s,contentClassName:c,defaultOpen:l=!1,defaultValue:u=null,emptyMessage:d=`No matches`,getKey:f,getLabel:p,getSearchText:m=p,groupBy:h,id:g,inputProps:_,inputRef:v,isDisabled:y=()=>!1,items:b,onOpenChange:x,onValueChange:S,multiple:C,open:w,placeholder:T=`Search…`,renderItem:E,rootRef:D,trigger:O,triggerRef:k,value:A,...j}=e,M=e=>{let t=f(e);if(C){let e=A.includes(t)?A.filter(e=>e!==t):[...A,t];S?.(e,b.filter(t=>e.includes(f(t))))}else S?.(t,e)},N;C?N=A:A!==void 0&&(N=A===null?[]:[A]);let P=(0,J.useId)(),F=O?.props??_,I=g??F?.id??P,L={id:I,"aria-describedby":[t,F?.[`aria-describedby`]].filter(Boolean).join(` `)||void 0,"aria-invalid":n??F?.[`aria-invalid`],"aria-label":F?.[`aria-label`]??r,"aria-labelledby":F?.[`aria-labelledby`]??i,"aria-required":a??F?.[`aria-required`]},{keyboardNavigation:ee,onPointerMove:te,activeItem:ne,activeKey:re,commit:R,groups:ie,inputValue:ae,listboxId:z,onInputChange:oe,onInputKeyDown:se,open:ce,optionId:le,selectedKeys:ue,setOpen:de}=I$({defaultOpen:l,defaultValue:u,getKey:f,getSearchText:m,groupBy:h,id:I,isDisabled:y,items:b,onOpenChange:x,onCommit:M,multiple:C??!1,controlledOpen:w,controlledKeys:N,trigger:O});PU(()=>{O&&de(!1)});let fe=NU(`popover`),pe=s===void 0?fe:s,me=iK(`.caps-combobox-option[data-active="true"]:not(:disabled), [data-navigation="pointer"] .caps-combobox-option:hover:not(:disabled)`),he=(0,X.jsx)(eK,{..._,...O?{}:L,"aria-activedescendant":ne?le(f(ne)):void 0,"aria-autocomplete":`list`,"aria-controls":z,"aria-expanded":!0,className:Q(`input-sm`,_?.className),id:O?_?.id??`${I}-input`:I,onChange:e=>{_?.onChange?.(e),oe(e)},onKeyDown:e=>{_?.onKeyDown?.(e),e.defaultPrevented||se(e)},placeholder:_?.placeholder??T,ref:v,role:`combobox`,value:ae}),ge=(0,X.jsx)(`div`,{id:z,ref:me,className:`caps-combobox-list`,"data-navigation":ee?`keyboard`:`pointer`,onPointerMove:te,role:`listbox`,"aria-multiselectable":C??void 0,children:ie.every(e=>e.items.length===0)?(0,X.jsx)(`div`,{className:`px-md py-md text-sm text-base-content`,children:d}):ie.map(e=>(0,X.jsxs)(`div`,{"aria-label":e.label||void 0,role:e.label?`group`:void 0,children:[e.label?(0,X.jsx)(`div`,{className:`px-md pb-xs pt-sm text-xs text-base-content uppercase tracking-wider`,children:e.label}):null,e.items.map(e=>{let t=f(e),n=y(e),r=re===t,i={active:r,disabled:n,selected:ue.includes(t)};return(0,X.jsxs)(`button`,{"aria-disabled":n||void 0,"aria-selected":i.selected,className:`caps-combobox-option`,"data-active":r&&ee,disabled:n,id:le(t),onClick:()=>{R(e)},onMouseDown:e=>{e.preventDefault()},role:`option`,tabIndex:-1,type:`button`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`caps-combobox-check`,children:i.selected?(0,X.jsx)(eW,{}):null}),E?.(e,r,i)??p(e)]},t)})]},e.label))});return O?(0,X.jsx)(`div`,{...j,className:Q(j.className),ref:D,children:(0,X.jsxs)(ZQ,{modal:!0,onOpenChange:de,open:ce,children:[(0,X.jsx)(t$,{...L,"aria-haspopup":`dialog`,className:`btn`,ref:k,render:O}),pe===null?null:(0,X.jsx)(i$,{container:pe,children:(0,X.jsx)(k$,{align:`start`,side:`bottom`,sideOffset:4,children:(0,X.jsxs)(P$,{"data-active-tone":o,className:Q(`min-w-40 rounded-box border border-base-300 bg-base-100 p-xs shadow-lg outline-none caps-combobox-panel caps-combobox-popup`,c),children:[(0,X.jsx)(`div`,{className:`caps-combobox-search`,children:he}),ge]})})})]})}):(0,X.jsx)(`div`,{...j,className:Q(j.className),ref:D,children:(0,X.jsxs)(`div`,{className:Q(`caps-combobox-panel`,c),"data-active-tone":o,children:[(0,X.jsx)(`div`,{className:`caps-combobox-search`,children:he}),ge]})})}function R$({icon:e,caption:t}){return(0,X.jsxs)(`span`,{className:`caps-icon-choice-mark`,"aria-hidden":`true`,children:[(0,X.jsx)(`span`,{className:`caps-icon-choice-art`,children:e}),t?(0,X.jsx)(`span`,{className:`caps-icon-choice-caption`,children:t}):null,(0,X.jsx)(`span`,{className:`caps-icon-choice-lamp`})]})}var z$=(0,J.forwardRef)(function({label:e,icon:t,caption:n,appearance:r,className:i,...a},o){return(0,X.jsx)(`label`,{className:`caps-icon-choice`,"data-appearance":r===`compact`?r:void 0,children:(0,X.jsx)($G,{...a,appearance:r??`default`,"aria-label":e,className:Q(`caps-icon-choice-input`,i),indicator:(0,X.jsx)(R$,{icon:t,caption:n}),ref:o})})}),B$=(0,J.forwardRef)(function({label:e,icon:t,hint:n,className:r,...i},a){let o=(0,J.useId)(),s=[i[`aria-describedby`],n?o:null].filter(Boolean).join(` `)||void 0;return(0,X.jsx)(`label`,{className:`caps-check-key`,children:(0,X.jsx)($G,{...i,"aria-label":e,"aria-describedby":s,className:Q(`caps-check-key-input`,r),indicator:(0,X.jsxs)(`span`,{className:`caps-check-key-face`,"aria-hidden":`true`,children:[t?(0,X.jsx)(`span`,{className:`caps-check-key-icon`,children:t}):null,(0,X.jsxs)(`span`,{className:`caps-check-key-copy`,children:[(0,X.jsx)(`span`,{className:`caps-check-key-label`,children:e}),n?(0,X.jsx)(`span`,{className:`caps-check-key-hint`,id:o,children:n}):null]}),(0,X.jsx)(`span`,{className:`caps-check-key-lamp`})]}),ref:a})})});function V$({className:e,...t}){return(0,X.jsx)(`div`,{...t,className:Q(`caps-check-keys`,e)})}function H$({checked:e}){let t=`caps-radio-${(0,J.useId)().replaceAll(`:`,``)}`,n=(0,J.useRef)(null),r=(0,J.useRef)(e).current,i=(0,J.useRef)(e),a=(0,J.useRef)(null),o=mS(a),{reduced:s}=o;return(0,J.useLayoutEffect)(()=>{if(!n.current)return;let t=s||i.current===e;i.current=e;let r=e?4:0,a=xA(o,{ease:`outCubic`,duration:75}),c=e?bA(o,{bounce:.65,duration:300}):xA(o,{ease:`inCubic`,duration:100}),l=yT(n.current,t?{rx:r,ry:r,cy:6,duration:0}:{rx:[{to:e?3.5:4.15,...a},{to:r,...c}],ry:[{to:e?4.5:3.85,...a},{to:r,...c}],cy:[{to:e?5.85:6.1,...a},{to:6,...c}]});return()=>{l.cancel()}},[e,s,o]),(0,X.jsxs)(`svg`,{ref:a,className:`caps-radio-visual`,width:`24`,height:`24`,viewBox:`0 0 12 12`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsxs)(`defs`,{children:[(0,X.jsx)(wT,{id:`${t}-surface`,transform:`matrix(1 0 0 1 6 6)`}),(0,X.jsx)(TT,{id:`${t}-shadow`}),(0,X.jsx)(ET,{id:`${t}-inset`}),(0,X.jsx)(`clipPath`,{id:`${t}-well`,children:(0,X.jsx)(`circle`,{cx:`6`,cy:`6`,r:`5`})})]}),(0,X.jsx)(`circle`,{className:`caps-radio-track`,cx:`6`,cy:`6`,r:`5.5`,filter:`url(#${t}-inset)`}),(0,X.jsx)(`g`,{clipPath:`url(#${t}-well)`,children:(0,X.jsx)(`ellipse`,{ref:n,cx:`6`,cy:`6`,rx:r?4:0,ry:r?4:0,fill:`url(#${t}-surface)`,filter:`url(#${t}-shadow)`})})]})}var U$=(0,J.createContext)(null),W$=(0,J.forwardRef)(function({children:e,className:t,defaultValue:n,disabled:r=!1,name:i,onValueChange:a,orientation:o=`vertical`,value:s,...c},l){let u=(0,J.useId)(),d=(0,J.useRef)(null);(0,J.useImperativeHandle)(l,()=>{if(!d.current)throw Error(`RadioGroup is not mounted`);return d.current},[]);let f=i??`radio-group-${u}`,[p,m]=(0,J.useState)(n),h=s??p;return(0,J.useEffect)(()=>{let e=d.current?.form;if(!e||s!==void 0)return;let t=e=>{queueMicrotask(()=>{e.defaultPrevented||m(n)})};return e.addEventListener(`reset`,t),()=>{e.removeEventListener(`reset`,t)}},[s,n,c.form]),(0,X.jsx)(U$.Provider,{value:{disabled:r,name:f,onValueChange:e=>{s===void 0&&m(e),a?.(e)},value:h},children:(0,X.jsx)(`fieldset`,{...c,className:Q(`flex gap-md`,o===`horizontal`?`flex-row flex-wrap`:`flex-col`,t),disabled:r,role:c.role??`radiogroup`,ref:d,children:e})})}),G$=(0,J.forwardRef)(function({className:e,indicator:t,onChange:n,onClick:r,value:i,...a},o){let s=(0,J.useContext)(U$);if(!s)throw Error(`RadioGroupItem must be used inside <RadioGroup>`);let c=s.value===i,l=e=>{n?.(e),e.target.checked&&s.onValueChange?.(i)};return(0,X.jsxs)(`span`,{className:`caps-radio`,"data-checked":c,"data-custom-indicator":t!==void 0||void 0,children:[(0,X.jsx)(`input`,{...a,"aria-checked":c,checked:c,className:Q(`caps-radio-input`,e),disabled:s.disabled||a.disabled,name:s.name,onChange:l,onClick:r,ref:o,type:`radio`,value:i}),t===void 0?(0,X.jsx)(H$,{checked:c}):t]})}),K$=(0,J.forwardRef)(function({description:e,id:t,meta:n,title:r,...i},a){let o=(0,J.useContext)(U$),s=(0,J.useId)(),c=t??s,l=o?.value===i.value,u=o?.disabled===!0||i.disabled===!0;return(0,X.jsxs)(`label`,{className:`caps-choice-card`,"data-checked":l,"data-disabled":u||void 0,htmlFor:c,children:[(0,X.jsx)(G$,{...i,"aria-describedby":e?`${c}-description`:void 0,"aria-labelledby":`${c}-title`,id:c,ref:a}),(0,X.jsxs)(`span`,{className:`caps-choice-card-copy`,children:[(0,X.jsx)(`span`,{className:`caps-choice-card-title`,id:`${c}-title`,children:r}),e?(0,X.jsx)(`span`,{className:`caps-choice-card-description`,id:`${c}-description`,children:e}):null]}),n?(0,X.jsx)(`span`,{className:`caps-choice-card-meta`,children:n}):null]})}),q$=(0,J.forwardRef)(function({label:e,icon:t,caption:n,art:r=`dim`,className:i,...a},o){return(0,X.jsx)(`label`,{className:`caps-icon-choice`,"data-art":r===`color`?r:void 0,children:(0,X.jsx)(G$,{...a,"aria-label":e,className:Q(`caps-icon-choice-input`,i),indicator:(0,X.jsx)(R$,{icon:t,caption:n}),ref:o})})}),J$=(0,J.forwardRef)(function({label:e,color:t,className:n,...r},i){return(0,X.jsx)(`label`,{className:`caps-icon-choice`,"data-art":`color`,"data-swatch":``,title:e,children:(0,X.jsx)(G$,{...r,"aria-label":e,className:Q(`caps-icon-choice-input`,n),indicator:(0,X.jsx)(R$,{icon:(0,X.jsx)(`span`,{className:`caps-swatch-dot`,style:{backgroundColor:t}})}),ref:i})})}),Y$=(0,J.forwardRef)(function({className:e,invalid:t,...n},r){return(0,X.jsxs)(`span`,{className:`caps-select-shell`,children:[(0,X.jsx)(`select`,{...n,"aria-invalid":t?!0:n[`aria-invalid`]===!1?void 0:n[`aria-invalid`],className:Q(`select select-bordered caps-select w-full`,t&&`select-error`,e),ref:r}),!n.multiple&&(!n.size||n.size<=1)?(0,X.jsx)(tW,{className:`caps-select-chevron`,"aria-hidden":`true`}):null]})});function X$({checked:e}){let t=`caps-switch-${(0,J.useId)().replaceAll(`:`,``)}`,n=(0,J.useRef)(null),r=(0,J.useRef)(null),i=(0,J.useRef)(e).current,a=(0,J.useRef)(e),o=wS();return(0,J.useLayoutEffect)(()=>{if(!n.current||!r.current)return;let t=o||a.current===e;a.current=e;let i=e?16:8,s=pS(n.current),c=bA(s,{bounce:.25,duration:440}),l=xA(s,{ease:`inOutSine`,duration:100}),u=yT(n.current,t?{x:2,y:2,width:i,height:8,duration:0}:{x:[{to:e?2.5:1.5,...l},{to:2,...c}],y:[{to:1.5,...l},{to:2,...c}],height:[{to:9,...l},{to:8,...c}],width:[{to:e?7:16.5,...l},{to:i,...c}]}),d=yT(r.current,{gradientTransform:e?`matrix(2 0 0 1 10 6)`:`matrix(1 0 0 1 6 6)`,...t?{duration:0}:{delay:l.duration,...c}});return()=>{u.cancel(),d.cancel()}},[e,o]),(0,X.jsxs)(`svg`,{className:`caps-switch-visual`,width:`40`,height:`24`,viewBox:`0 0 20 12`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsxs)(`defs`,{children:[(0,X.jsx)(wT,{ref:r,id:`${t}-surface`,transform:i?`matrix(2 0 0 1 10 6)`:`matrix(1 0 0 1 6 6)`}),(0,X.jsx)(TT,{id:`${t}-shadow`}),(0,X.jsx)(ET,{id:`${t}-inset`}),(0,X.jsx)(`clipPath`,{id:`${t}-track`,children:(0,X.jsx)(`rect`,{x:`1`,y:`1`,width:`18`,height:`10`,rx:`5`})})]}),(0,X.jsx)(`rect`,{className:`caps-switch-track`,filter:`url(#${t}-inset)`,x:`0.5`,y:`0.5`,width:`19`,height:`11`,rx:`5.5`}),(0,X.jsx)(`g`,{clipPath:`url(#${t}-track)`,children:(0,X.jsx)(`rect`,{ref:n,x:`2`,y:`2`,width:i?16:8,height:`8`,rx:`4`,fill:`url(#${t}-surface)`,filter:`url(#${t}-shadow)`})})]})}var Z$=(0,J.forwardRef)(function({className:e,checked:t,defaultChecked:n=!1,onChange:r,onCheckedChange:i,...a},o){let s=(0,J.useRef)(null),[c,l]=(0,J.useState)(n),u=t??c;return(0,J.useImperativeHandle)(o,()=>{if(!s.current)throw Error(`Switch input is not mounted`);return s.current},[]),(0,J.useEffect)(()=>{let e=s.current?.form;if(!e||t!==void 0)return;let r=e=>{queueMicrotask(()=>{!e.defaultPrevented&&s.current&&l(n)})};return e.addEventListener(`reset`,r),()=>{e.removeEventListener(`reset`,r)}},[t,n,a.form]),(0,X.jsxs)(`span`,{className:`caps-switch`,"data-checked":u,children:[(0,X.jsx)(`input`,{...a,checked:u,className:Q(`caps-switch-input`,e),onChange:e=>{t===void 0&&l(e.target.checked),r?.(e),i?.(e.target.checked)},ref:s,role:`switch`,type:`checkbox`}),(0,X.jsx)(X$,{checked:u})]})}),Q$=kn(W),$$=kn(on),e1=kn(qn(ut)),t1=kn(rn(W)),n1=rn(mt(File)),r1=kn(n1),i1=Zn([W,ut,on,Nn,$n,rn(W),n1]),a1=kn(i1),o1=e=>Ce(Q$(e.state.value),()=>``),s1=e=>Ce($$(e.state.value),()=>!1),c1=e=>Ce(e1(e.state.value),()=>null),l1=e=>Ce(t1(e.state.value),()=>[]),u1=e=>Ce(r1(e.state.value),()=>[]),d1=e=>Ce(a1(e.state.value),()=>null);function f1({field:e,spec:t,locked:n,...r}){let[i,a]=(0,J.useState)(!1);return(0,X.jsxs)(RK,{children:[(0,X.jsx)(eK,{...r,name:t.name,disabled:n,type:i?`text`:`password`,autoComplete:`off`,spellCheck:!1,className:`caps-field-secret`,placeholder:t.placeholder,readOnly:t.readOnly,value:o1(e),onBlur:e.handleBlur,onChange:t=>{e.handleChange(t.currentTarget.value)}}),(0,X.jsx)(BT,{type:`button`,variant:`outline`,size:`icon`,"aria-label":i?`Hide`:`Show`,"aria-pressed":i,disabled:n,onClick:()=>{a(e=>!e)},children:i?(0,X.jsx)(iW,{"aria-hidden":`true`}):(0,X.jsx)(aW,{"aria-hidden":`true`})})]})}var p1={text:`text`,email:`email`,url:`url`,tel:`tel`};function m1({spec:e,field:t,locked:n,...r}){let i=u1(t),a=n||e.readOnly===!0,o=(0,J.useRef)(null);return(0,X.jsxs)(`div`,{className:`flex flex-col gap-sm`,children:[(0,X.jsx)(TS,{asChild:!0,children:(0,X.jsx)(`input`,{...r,ref:o,type:`file`,tabIndex:-1,required:r.required===!0&&i.length===0,name:e.name,accept:e.accept,multiple:e.multiple,disabled:a,onBlur:t.handleBlur,onChange:e=>{t.handleChange(Array.from(e.currentTarget.files??[])),e.currentTarget.value=``}})}),(0,X.jsx)(BT,{type:`button`,variant:`outline`,"aria-label":`Choose files for ${e.label}`,"aria-describedby":r[`aria-describedby`],"aria-invalid":r[`aria-invalid`],disabled:a,onBlur:t.handleBlur,onClick:()=>{o.current?.click()},children:`Choose files`}),(0,X.jsx)(zQ,{items:i.map((e,t)=>({id:String(t),name:e.name,preview:{kind:`file`},progress:0,progressLabel:`${String(e.size)} bytes`,statusLabel:`Selected`,actions:a?{}:{remove:{label:`Remove`,accessibleLabel:`Remove ${e.name}`}}})),onRemove:e=>{t.handleChange(i.filter((t,n)=>String(n)!==e))},onCancel:()=>void 0,onRetry:()=>void 0})]})}function h1({spec:e,field:t,locked:n,...r}){let i=e=>{t.handleChange(e)},a={...r,name:e.name,disabled:n,onBlur:t.handleBlur};switch(e.kind){case`text`:case`email`:case`url`:case`tel`:return(0,X.jsx)(eK,{...a,type:p1[e.kind],inputMode:e.kind===`text`?void 0:e.kind,autoComplete:e.autoComplete,placeholder:e.placeholder,maxLength:e.maxLength,readOnly:e.readOnly,value:o1(t),onChange:e=>{i(e.currentTarget.value)}});case`textarea`:return(0,X.jsx)(GG,{...a,rows:e.rows??3,placeholder:e.placeholder,maxLength:e.maxLength,readOnly:e.readOnly,value:o1(t),onChange:e=>{i(e.currentTarget.value)}});case`secret`:return(0,X.jsx)(f1,{...r,field:t,spec:e,locked:n});case`money`:return(0,X.jsxs)(RK,{children:[(0,X.jsx)(zK,{className:`caps-field-currency`,children:e.currency??`USD`}),(0,X.jsx)(eK,{...a,inputMode:`decimal`,autoComplete:`off`,className:`caps-field-amount`,placeholder:e.placeholder??`0.00`,readOnly:e.readOnly,value:o1(t),onChange:e=>{i(e.currentTarget.value)}})]});case`date`:return(0,X.jsx)(eK,{...a,type:`date`,readOnly:e.readOnly,value:o1(t),onChange:e=>{i(e.currentTarget.value)}});case`number`:return(0,X.jsx)(eq,{...a,...e.min===void 0?{}:{min:e.min},...e.max===void 0?{}:{max:e.max},...e.step===void 0?{}:{step:e.step},...e.unit===void 0?{}:{unit:e.unit},...e.wrap===void 0?{}:{wrap:e.wrap},disabled:n||e.readOnly===!0,decrementLabel:`Decrease ${e.label}`,incrementLabel:`Increase ${e.label}`,value:c1(t),onValueChange:e=>{t.handleChange(e)}});case`select`:return(0,X.jsxs)(Y$,{...a,value:o1(t),onChange:e=>{i(e.currentTarget.value)},children:[e.placeholder===void 0?null:(0,X.jsx)(`option`,{value:``,disabled:!0,children:e.placeholder}),e.options.map(e=>(0,X.jsx)(`option`,{value:e.value,disabled:e.disabled,children:e.label},e.value))]});case`combobox`:return(0,X.jsx)(L$,{id:r.id??e.name,"aria-describedby":r[`aria-describedby`],"aria-invalid":r[`aria-invalid`],"aria-required":r[`aria-required`],items:e.options,getKey:e=>e.value,getLabel:e=>e.label,isDisabled:t=>t.disabled||n||e.readOnly===!0,value:o1(t),...e.placeholder===void 0?{}:{placeholder:e.placeholder},trigger:(0,X.jsx)(F$,{name:e.name,disabled:n||e.readOnly===!0,onBlur:t.handleBlur,children:e.options.find(e=>e.value===o1(t))?.label??e.placeholder??`Choose…`}),inputProps:{"aria-label":`Search ${e.label}`,disabled:n||e.readOnly===!0},onValueChange:e=>{i(e??``),t.handleBlur()}});case`file`:return(0,X.jsx)(m1,{...r,spec:e,field:t,locked:n});case`checkbox`:return(0,X.jsx)($G,{...a,disabled:n||e.readOnly===!0,checked:s1(t),onChange:e=>{t.handleChange(e.currentTarget.checked)}});case`switch`:return(0,X.jsx)(Z$,{...a,disabled:n||e.readOnly===!0,checked:s1(t),onCheckedChange:e=>{t.handleChange(e)}});case`radio`:case`icon-radio`:case`checkboxes`:case`icon-checkboxes`:return null}}var g1=new Set([`radio`,`icon-radio`,`checkboxes`,`icon-checkboxes`]);function _1({spec:e,field:t,locked:n,error:r,layout:i}){let a=n||e.readOnly===!0,o=e.label;if(e.kind===`checkboxes`||e.kind===`icon-checkboxes`){let n=l1(t),s=(e,r)=>{t.handleChange(r?[...n,e]:n.filter(t=>t!==e))};return(0,X.jsx)(qK,{legend:o,icon:e.icon,layout:i,...i===`columns`?{legendTitle:o}:{},description:e.help,disabled:a,error:r??null,children:e.kind===`icon-checkboxes`?(0,X.jsx)(`div`,{className:`caps-field-icon-choices`,children:e.options.map(r=>(0,X.jsx)(z$,{name:e.name,value:r.value,label:r.label,...r.caption===void 0?{}:{caption:r.caption},icon:r.icon,disabled:r.disabled,checked:n.includes(r.value),onBlur:t.handleBlur,onChange:e=>{s(r.value,e.currentTarget.checked)}},r.value))}):(0,X.jsx)(V$,{children:e.options.map(r=>(0,X.jsx)(B$,{name:e.name,value:r.value,label:r.label,icon:r.icon,hint:r.description,disabled:r.disabled,checked:n.includes(r.value),onBlur:t.handleBlur,onChange:e=>{s(r.value,e.currentTarget.checked)}},r.value))})})}let s=e.options.some(e=>e.description!==void 0||e.meta!==void 0);return(0,X.jsx)(qK,{legend:o,icon:e.icon,layout:i,...i===`columns`?{legendTitle:o}:{},description:e.help,disabled:a,error:r??null,children:(0,X.jsx)(W$,{name:e.name,"aria-label":o,value:o1(t),onValueChange:e=>{t.handleChange(e),t.handleBlur()},orientation:e.kind===`icon-radio`||s?`horizontal`:`vertical`,children:e.options.map(t=>e.kind===`icon-radio`?(0,X.jsx)(q$,{value:t.value,label:t.label,...t.caption===void 0?{}:{caption:t.caption},icon:t.icon,disabled:t.disabled},t.value):s?(0,X.jsx)(K$,{value:t.value,title:t.label,description:t.description,meta:t.meta,disabled:t.disabled},t.value):(0,X.jsx)(YK,{label:t.label,orientation:`inline`,children:(0,X.jsx)(G$,{value:t.value,disabled:t.disabled})},t.value))})})}function v1({spec:e,field:t,locked:n,error:r,render:i,...a}){return i({name:e.name,label:e.label,help:e.help,value:d1(t),onChange:e=>{t.handleChange(e)},onBlur:t.handleBlur,error:r,disabled:n,id:a.id??e.name,"aria-describedby":a[`aria-describedby`],"aria-invalid":r!==void 0})}function y1({form:e,spec:t,locked:n,layout:r}){let i=TQ({form:e,name:t.name}),a=CQ(e.store,e=>e.submissionAttempts>0),o=i.state.meta.isBlurred||a?IQ(i.state.meta):void 0;if(t.render===void 0&&g1.has(t.kind))return(0,X.jsx)(_1,{spec:t,field:i,locked:n,error:o,layout:r});let s=r===`columns`?t.kind===`switch`||t.kind===`checkbox`?`horizontal`:`vertical`:t.kind===`checkbox`?`inline`:(t.layout??(t.kind===`switch`?`row`:`stacked`))===`row`?`horizontal`:`vertical`;return(0,X.jsx)(YK,{label:t.label,...r===`columns`?{labelTitle:t.label}:{},description:t.help,icon:t.icon,orientation:s,error:o,...t.required===void 0?{}:{required:t.required},...t.optional===void 0?{}:{optional:t.optional},children:t.render===void 0?(0,X.jsx)(h1,{spec:t,field:i,locked:n}):(0,X.jsx)(v1,{spec:t,field:i,locked:n,error:o,render:t.render})})}var b1=kn(xn(W,i1));function x1({form:e,spec:t,locked:n,layout:r}){let i=t.when;return CQ(e.store,e=>i===void 0||i(Ce(b1(e.values),()=>({}))))?(0,X.jsx)(y1,{form:e,spec:t,locked:n,layout:r}):null}function S1({form:e,section:t,locked:n,layout:r}){let i=t.fields.map(t=>(0,X.jsx)(x1,{form:e,spec:t,locked:n,layout:r},t.name));return t.title===void 0?i:(0,X.jsx)(KK,{title:t.title,description:t.description,layout:r,children:i})}function C1({model:e,names:t,disabled:n=!1,layout:r}){let i=e.form;return t===void 0?e.description.sections.map(e=>(0,X.jsx)(S1,{form:i,section:e,locked:n,layout:r},e.id??``)):t.map(t=>{let a=e.description.fields.find(e=>e.name===t);return a===void 0?null:(0,X.jsx)(x1,{form:i,spec:a,locked:n,layout:r},t)})}var w1=class{annotation;constructor(e){this.annotation=e}},T1=class{sections;constructor(e){this.sections=e}},E1=`caps/form`,D1=0;function O1(e){D1+=1;let t={[`${E1}:${String(D1)}`]:new w1(e)};return e.label!==void 0&&(t.title=e.label),e.help!==void 0&&(t.description=e.help),t}W.annotate(O1({kind:`secret`})).pipe(_t(`Secret`));var k1=e=>{let t=e.replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/[-_]+/g,` `).toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)};function A1(e){return Object.values(e??{}).reduce((e,t)=>t instanceof w1?{...e,...t.annotation}:e,{})}function j1(e){return e.reduce((e,t)=>({...e,...A1(t)}),{})}function M1(e){let t=e?.[E1];return t instanceof T1?t.sections:{}}var N1=kn(W);function P1(e){if(er(e))return Ze(N1(e.literal),{onNone:()=>null,onSome:e=>[e]});if(!Et(e))return null;let t=[];for(let n of e.types){if(Qt(n))continue;let e=P1(n);if(e===null)return null;t.push(...e)}return t}function F1(e){if(Jt(e))return{type:`string`,literals:[]};if(Xt(e))return{type:`number`,nullable:!1};if(Lt(e))return{type:`boolean`};let t=P1(e);if(t!==null)return{type:`string`,literals:t};if(Mt(e)){let[t]=e.rest;if(t===void 0)return null;if(Jt(t))return{type:`strings`,literals:[]};let n=P1(t);return n===null?null:{type:`strings`,literals:n}}if(Et(e)){let t=e.types.filter(e=>!Qt(e)&&!pt(e)),n=e.types.some(e=>pt(e)),[r]=t;if(t.length!==1||r===void 0)return null;let i=F1(r);return i?.type===`number`?{type:`number`,nullable:n}:n?null:i}return null}function I1(e){let t=e.ast;if(!kt(t))throw Error(`A schema form needs a Schema.Struct.`);return{fields:t.propertySignatures.map(e=>{let t=String(e.name),n=nn(e.type),r=j1([e.type.annotations,...(e.type.checks??[]).map(e=>e.annotations)]),i=r.kind===`file`?{type:`files`}:F1(n);if(i===null)throw Error(`Schema field "${t}" has no form control. Annotate it with field({ render }) or a kind.`);return{name:t,valueType:i,optional:e.type.context?.isOptional===!0,annotation:r,title:Nt(e.type),description:Hn(e.type)}}),sections:M1(Ft(t))}}function L1(e){let t=e,n=!1,r=!1;for(;;)if(t instanceof ne)n=!0,t=t.unwrap();else if(t instanceof o)r=!0,t=t.unwrap();else if(t instanceof D)t=t.unwrap();else if(t instanceof z)t=t.in;else return{node:t,optional:n,nullable:r}}function R1(e){if(e instanceof qe){let t=e.options.map(e=>R1(e));return t.some(e=>e===null)?null:t.flatMap(e=>e??[])}let t=e instanceof F?e.options:e instanceof lt?[...e.values]:null;if(t===null)return null;let n=t.map(e=>N1(e));return n.every(je)?n.map(e=>e.value):null}function z1(e){let{node:t,nullable:n}=L1(e);if(t instanceof g)return{type:`string`,literals:[]};if(t instanceof ie)return{type:`number`,nullable:n};if(t instanceof S)return{type:`boolean`};let r=R1(t);if(r!==null)return{type:`string`,literals:r};if(t instanceof m){let e=L1(t.element).node;if(e instanceof g)return{type:`strings`,literals:[]};let n=R1(e);return n===null?null:{type:`strings`,literals:n}}return null}function B1(e){let t=[e];for(;;){let e=t[t.length-1];if(e===void 0)break;let n=e instanceof ne||e instanceof o||e instanceof D?e.unwrap():e instanceof z?e.in:e;if(n===e)break;t.push(n)}return t.reverse().map(e=>O.get(e))}function V1(e){return B1(e).reduce((e,t)=>({...e,...t}),{})}function H1(e){return Object.entries(e.shape)}function U1(e){let t=L1(e).node;if(!(t instanceof y))throw Error(`A schema form needs a z.object.`);return{fields:H1(t).map(([e,t])=>{let n=j1(B1(t)),r=n.kind===`file`?{type:`files`}:z1(t);if(r===null)throw Error(`Schema field "${e}" has no form control. Annotate it with field({ render }) or a kind.`);let i=V1(t);return{name:e,valueType:r,optional:L1(t).optional,annotation:n,title:i.title,description:i.description}}),sections:M1(V1(e))}}function W1(e,t){let n=t.options??{};return(e.length>0?e:Object.keys(n)).map(e=>{let t=n[e],r=t===void 0?{}:t instanceof Object?t:{label:t};return{value:e,label:r.label??k1(e),description:r.description,meta:r.meta,icon:r.icon,caption:r.caption,disabled:r.disabled===!0}})}function G1(e,t){let n=t.some(e=>e.icon!==void 0);switch(e.type){case`boolean`:return`switch`;case`number`:return`number`;case`strings`:return n?`icon-checkboxes`:`checkboxes`;case`files`:return`file`;case`string`:return t.length===0?`text`:t.length>12?`combobox`:n?`icon-radio`:t.some(e=>e.description!==void 0||e.meta!==void 0)||t.length<=3?`radio`:`select`}}function K1(e,t){switch(e.type){case`boolean`:return!1;case`number`:return e.nullable?null:0;case`strings`:case`files`:return[];case`string`:return t[0]?.value??``}}function q1(e){let t=e instanceof T?U1(e):I1(e),n=t.fields.map((e,t)=>{let{kind:n,...r}=e.annotation,i=W1(e.valueType.type===`string`||e.valueType.type===`strings`?e.valueType.literals:[],e.annotation),a=r.help??e.description;return{...r,name:e.name,label:r.label??e.title??k1(e.name),help:a,kind:n??G1(e.valueType,i),options:i,optionalInSchema:e.optional,index:t}}),r={};t.fields.forEach((e,t)=>{let i=n[t];i&&(r[e.name]=K1(e.valueType,i.options))});let i=e=>e.order??e.index,a=e=>e.section!==void 0&&Object.hasOwn(t.sections,e.section)?e.section:null,o=e=>n.filter(t=>a(t)===e).sort((e,t)=>i(e)-i(t)),s=Object.entries(t.sections).map(([e,t])=>({id:e,title:t.title,description:t.description,fields:o(e)}));return{fields:n,sections:[{id:null,title:void 0,description:void 0,fields:o(null)},...s].filter(e=>e.fields.length>0),defaults:r}}function J1(e){let t=e instanceof T?e:zt(e);return{"~standard":{...t[`~standard`],validate:e=>{let n=t[`~standard`].validate(e);return n instanceof Promise?n.then(e=>Y1(e)):Y1(n)}}}}function Y1(e){return e.issues===void 0?e:{issues:e.issues.map(e=>e.path===void 0?e:{...e,path:e.path.slice(0,1)})}}var X1=`onServer`;function Z1(e){let t=e?.querySelector(`[aria-invalid="true"]`);t?.matches(`input, select, textarea, button, [tabindex]`)?t.focus():t?.querySelector(`input, select, textarea, button`)?.focus()}function Q1(e){return e.state.meta.errorMap.onServer!==void 0}function $1(e){e.setMeta(e=>({...e,errorMap:{...e.errorMap,[X1]:void 0}}))}function e0(e,t,n){e.setFieldMeta(t,e=>({...e,isBlurred:!0,errorMap:{...e.errorMap,[X1]:n}}))}function t0(e){let[t,n]=(0,J.useState)(null),[r,i]=(0,J.useState)(null),[a,o]=(0,J.useState)(e.defaultValues),[s,c]=(0,J.useState)(null);UZ(a,e.defaultValues)||(o(e.defaultValues),c(null));let{schema:l}=e,u=(0,J.useMemo)(()=>q1(l),[l]),d=(0,J.useMemo)(()=>J1(l),[l]),f=NQ({defaultValues:s??a,validators:{onChange:d,onSubmit:d},listeners:{onChange:({fieldApi:e})=>{n(null),i(null),Q1(e)&&$1(e)}},onSubmit:async({value:t,formApi:r})=>{n(null),i(null);let a=await J1(l)[`~standard`].validate(t);if(a.issues){n(a.issues[0]?.message??`Check the form and try again.`);return}let o;try{o=await e.onSubmit(a.value,t)??{kind:`saved`}}catch(t){console.error(`SchemaForm submit failed`,t),n(e.failure??`Couldn't save changes. Try again.`);return}if(o.kind===`refused`){n(o.error??null);let e=r;for(let[t,n]of Object.entries(o.fields??{}))n!==void 0&&n.length>0&&e0(e,t,n);return}let s=o.values??t;c(s),r.reset(s),i(o.message??`Saved`),e.onSaved?.(s)}});return{description:u,form:f,error:t,saved:r,discard:()=>{n(null),i(null),f.reset()},submit:()=>f.handleSubmit()}}function n0(e){return{dirty:CQ(e.form.store,e=>!e.isDefaultValue),submitting:CQ(e.form.store,e=>e.isSubmitting),canSubmit:CQ(e.form.store,e=>e.canSubmit)}}function r0({model:e,submitLabel:t=`Save changes`,discardLabel:n,onCancel:r,cancelLabel:i,allowClean:a,layout:o,footer:s,children:c,disabled:l=!1,...u}){let{submitting:d}=n0(e),f=(0,J.useRef)(null);return(0,X.jsxs)(WK,{...u,ref:f,layout:o,busy:d,noValidate:!0,onSubmit:t=>{t.preventDefault(),e.form.state.isSubmitting||e.submit().then(()=>{setTimeout(()=>{Z1(f.current)},0)})},children:[c??(0,X.jsx)(C1,{model:e,disabled:l,layout:o}),s===void 0?(0,X.jsx)(o0,{model:e,label:t,discardLabel:r===void 0?n:void 0,onCancel:r,cancelLabel:i,allowClean:a??r!==void 0,divider:r===void 0}):s]})}function i0({schema:e,defaultValues:t,onSubmit:n,onSaved:r,failure:i,...a}){let o=t0({schema:e,defaultValues:t,onSubmit:n,onSaved:r,failure:i});return(0,X.jsx)(r0,{...a,model:o})}function a0(e){return`model`in e?(0,X.jsx)(r0,{...e}):(0,X.jsx)(i0,{...e})}function o0({model:e,label:t,discardLabel:n,onCancel:r,cancelLabel:i=`Cancel`,allowClean:a=!1,dirtyLabel:o=`Unsaved changes`,buttonProps:s,...c}){let{dirty:l,submitting:u}=n0(e),d=u?null:e.saved&&!l?(0,X.jsx)(FG,{tone:`success`,size:`compact`,label:e.saved}):l?(0,X.jsx)(FG,{tone:`neutral`,size:`compact`,label:o}):null;return(0,X.jsxs)(UK,{...c,error:e.error,status:d,children:[r?(0,X.jsx)(BT,{type:`button`,variant:`ghost`,disabled:u,onClick:r,children:i}):n&&l?(0,X.jsx)(BT,{type:`button`,variant:`ghost`,disabled:u,onClick:e.discard,children:n}):null,(0,X.jsx)(BT,{...s,type:`submit`,loading:u,disabled:u||!l&&!a,title:!l&&!a?`No changes to save`:void 0,children:t})]})}var s0=e=>e,c0=(e,t)=>{let n=e[t];if(!n)throw Error(`Missing burger path: ${t}`);return n},l0={apiVersion:1,name:`burger`,palette:{bottomBun:`#e9c46a`,bunSpot:`#d4a373`,cheese:`#f4d03f`,dead:`#636e72`,deadTongue:`#b2bec3`,eye:`#2d3436`,lettuce:`#7cb342`,mouth:`#2d3436`,patty:`#5d4037`,tomato:`#e74c3c`,topBun:`#f4a261`,blush:`#feaae4`,tongue:`#f98284`,sweat:`#accce4`,white:`#ffffff`},build({scene:e,color:t}){let n=e.group({name:`root`}),r=e.group({parent:n,name:`body`,updateSort:!0});e.cylinder({parent:r,name:`bottom-bun`,backface:t(`bottomBun`),color:t(`bottomBun`),diameter:34,frontFace:t(`bunSpot`),length:6,rotate:{x:Math.PI/2},stroke:!1,translate:{y:8}}),e.cylinder({parent:r,name:`patty`,color:t(`patty`),diameter:36,frontFace:t(`patty`),length:4,rotate:{x:Math.PI/2},stroke:!1,translate:{y:3}}),e.cylinder({parent:r,name:`tomato`,color:t(`tomato`),diameter:34,frontFace:t(`tomato`),length:2,rotate:{x:Math.PI/2},stroke:!1,translate:{y:-2}});let i=e.hemisphere({parent:r,name:`top-bun`,backface:t(`bunSpot`),color:t(`topBun`),diameter:38,rotate:{x:Math.PI/2},stroke:!1,translate:{y:-3}});for(let[n,r]of[{x:-8,y:-6,z:14},{x:6,y:-8,z:13},{x:0,y:-10,z:12},{x:10,y:-4,z:13},{x:-5,y:-2,z:15},{x:4,y:-12,z:11}].entries())e.path({parent:i,name:`seed.${String(n+1)}`,path:[{x:0,y:0}],color:t(`bunSpot`),stroke:1.2,translate:r});let a=e.group({parent:r,name:`face`,translate:{y:-5,z:16}}),o=dr(e,t,a,{blushMode:`medium-alias`,hideMouth:!0}),s=e.group({parent:r,name:`burger.mouth`,translate:{y:1,z:10}}),c=s0({angry:[{x:-13,y:2},{x:13,y:2},{x:13,y:5},{bezier:[{x:7,y:4},{x:0,y:5},{x:-7,y:4}]},{x:-13,y:5}],happy:[{x:-12,y:0},{bezier:[{x:-6,y:3},{x:0,y:5},{x:6,y:3}]},{x:12,y:0},{x:13,y:2},{bezier:[{x:7,y:5},{x:0,y:7},{x:-7,y:5}]},{x:-13,y:2}],open:[{x:-10,y:0},{bezier:[{x:-10,y:5},{x:-5,y:8},{x:0,y:8}]},{bezier:[{x:5,y:8},{x:10,y:5},{x:10,y:0}]},{x:10,y:1},{bezier:[{x:5,y:6},{x:-5,y:6},{x:-10,y:1}]}],pout:[{x:-8,y:2},{bezier:[{x:0,y:5},{x:8,y:2},{x:8,y:4}]},{x:0,y:6},{x:-8,y:4}],sad:[{x:-12,y:3},{bezier:[{x:-6,y:0},{x:0,y:-1},{x:6,y:0}]},{x:12,y:3},{x:13,y:5},{bezier:[{x:7,y:2},{x:0,y:1},{x:-7,y:2}]},{x:-13,y:5}],small:[{x:-6,y:1},{x:6,y:1},{x:7,y:3},{x:0,y:2},{x:-7,y:3}],surprised:[],worried:[{x:-11,y:1},{bezier:[{x:-6,y:3},{x:-3,y:1},{x:0,y:2}]},{bezier:[{x:3,y:1},{x:6,y:3},{x:11,y:1}]},{x:12,y:3},{x:0,y:4},{x:-12,y:3}],dead:[{x:-12,y:1},{x:12,y:1},{x:13,y:4},{bezier:[{x:7,y:3},{x:0,y:4},{x:-7,y:3}]},{x:-13,y:4}],normal:[{x:-12,y:1},{x:12,y:1},{x:13,y:4},{bezier:[{x:7,y:3},{x:0,y:4},{x:-7,y:3}]},{x:-13,y:4}]}),l=s0({angry:[{x:-13,y:0},{x:13,y:0},{x:13,y:2},{bezier:[{x:7,y:1},{x:0,y:2},{x:-7,y:1}]},{x:-13,y:2}],happy:[{x:-12,y:2},{bezier:[{x:-6,y:0},{x:0,y:-1},{x:6,y:0}]},{x:12,y:2},{x:13,y:3},{bezier:[{x:7,y:1},{x:0,y:0},{x:-7,y:1}]},{x:-13,y:3}],open:[{x:-10,y:2},{bezier:[{x:-10,y:-3},{x:-5,y:-6},{x:0,y:-6}]},{bezier:[{x:5,y:-6},{x:10,y:-3},{x:10,y:2}]},{x:10,y:1},{bezier:[{x:5,y:-4},{x:-5,y:-4},{x:-10,y:1}]}],pout:[{x:-8,y:0},{bezier:[{x:-4,y:-1},{x:0,y:0},{x:4,y:-1}]},{x:8,y:0},{x:9,y:1},{x:0,y:1},{x:-9,y:1}],sad:[{x:-12,y:0},{bezier:[{x:-6,y:2},{x:0,y:3},{x:6,y:2}]},{x:12,y:0},{x:13,y:1},{bezier:[{x:7,y:3},{x:0,y:4},{x:-7,y:3}]},{x:-13,y:1}],small:[{x:-6,y:0},{bezier:[{x:-3,y:1},{x:0,y:0},{x:3,y:1}]},{x:6,y:0},{x:7,y:1},{x:0,y:1},{x:-7,y:1}],surprised:[{x:-13,y:2},{bezier:[{x:-7,y:-2},{x:0,y:-3},{x:7,y:-2}]},{x:13,y:2},{x:14,y:3},{bezier:[{x:8,y:0},{x:0,y:-1},{x:-8,y:0}]},{x:-14,y:3}],worried:[{x:-11,y:1},{bezier:[{x:-6,y:0},{x:-3,y:1},{x:0,y:0}]},{bezier:[{x:3,y:2},{x:6,y:0},{x:11,y:1}]},{x:12,y:2},{bezier:[{x:7,y:1},{x:0,y:1},{x:-7,y:1}]},{x:-12,y:2}],dead:[{x:-12,y:1},{bezier:[{x:-6,y:0},{x:0,y:-.5},{x:6,y:0}]},{x:12,y:1},{x:13,y:2},{bezier:[{x:7,y:1},{x:0,y:.5},{x:-7,y:1}]},{x:-13,y:2}],normal:[{x:-12,y:1},{bezier:[{x:-6,y:0},{x:0,y:-.5},{x:6,y:0}]},{x:12,y:1},{x:13,y:2},{bezier:[{x:7,y:1},{x:0,y:.5},{x:-7,y:1}]},{x:-13,y:2}]}),u={};for(let n of[`normal`,`happy`,`sad`,`angry`,`surprised`,`dead`,`small`,`worried`,`pout`,`open`]){let r=e.group({parent:s,name:`burger.mouth.${n}`}),i={y:n===`open`?2:n===`small`?.5:1.5,z:+(n===`pout`)};n===`surprised`?e.ellipse({parent:r,name:`cheese.${n}`,color:t(`cheese`),fill:!0,height:8,stroke:2,translate:{y:2,z:0},width:6}):e.path({parent:r,name:`cheese.${n}`,color:t(`cheese`),fill:!0,path:c0(c,n),stroke:2,translate:i});let a={y:n===`open`?1:n===`surprised`?-1:-.5,z:n===`pout`?2:1};e.path({parent:r,name:`lettuce.${n}`,color:t(`lettuce`),fill:!0,path:c0(l,n),stroke:1.5,translate:a}),u[n]=r}return{root:n,variants:{eyes:o.eyes,mouth:u,blush:o.blush}}},expressions:ur,activities:fr,defaultPresentation:{activity:`idle`,expression:`normal`}},u0=(e,t)=>{let n=e[t];if(!n)throw Error(`Missing cat face node: ${t}`);return n},d0=e=>e,f0={apiVersion:1,name:`cat`,palette:{body:`#ffe6c6`,eye:`#28282e`,mouth:`#28282e`,blush:`#feaae4`,dead:`#6c5671`,deadTongue:`#d9c8bf`,tongue:`#f98284`,stripes:`#dea38b`,sweat:`#accce4`,white:`#ffffff`},build({scene:e,color:t}){let n=e.group({name:`root`}),r=e.group({parent:n,name:`body`,updateSort:!0});e.path({parent:r,name:`body.sphere`,path:[{x:0,y:0}],color:t(`body`),stroke:32});for(let n of[-1,1])e.path({parent:r,name:`ear.${n<0?`left`:`right`}`,color:t(`body`),fill:!0,path:[{x:-6,y:0},{x:6,y:0},{x:0,y:-10}],rotate:{z:.6*n},stroke:3,translate:{x:9*n,y:-10}});let i=e.group({parent:r,name:`face`,translate:{z:20}}),a=dr(e,t,i,{hideMouth:!0}),o=e.group({parent:i,name:`cat.mouth`,translate:{y:6,z:2}}),s=(n,r,i)=>e.path({parent:o,name:`cat.mouth.${n}`,closed:!1,color:t(`mouth`),path:r,stroke:i}),c=d0({normal:s(`normal`,[{x:-2,y:-1},{x:0,y:0},{x:2,y:-1}],1.5),sad:s(`sad`,[{x:-2.5,y:2},{bezier:[{x:0,y:0},{x:2.5,y:2},{x:2.5,y:2}]}],1.5),angry:s(`angry`,[{x:-3,y:1},{x:3,y:1}],2),small:s(`small`,[{x:-1.5,y:0},{x:1.5,y:0}],1),worried:s(`worried`,[{x:-2,y:1},{bezier:[{x:-.5,y:.5},{x:.5,y:.5},{x:2,y:1}]}],1)}),l=e.group({parent:o,name:`cat.mouth.happy`,translate:{y:1}});e.path({parent:l,closed:!1,color:t(`mouth`),path:[{x:-2.5,y:1},{bezier:[{x:0,y:3},{x:2.5,y:1},{x:2.5,y:1}]}],stroke:1.5}),e.ellipse({parent:l,width:2,height:1.5,stroke:0,fill:!0,color:t(`tongue`),translate:{y:2}}),c.happy=l,c.surprised=e.ellipse({parent:o,name:`cat.mouth.surprised`,width:2.5,height:3,stroke:1.5,fill:!0,color:t(`mouth`),translate:{y:1}});let u=e.group({parent:o,name:`cat.mouth.dead`,translate:{y:3}});e.ellipse({parent:u,width:2.5,height:1.5,stroke:1.5,fill:!0,color:t(`dead`)}),e.ellipse({parent:u,width:1.2,height:.8,stroke:0,fill:!0,color:t(`deadTongue`),translate:{y:.5}}),c.dead=u,c.pout=e.ellipse({parent:o,name:`cat.mouth.pout`,width:2,height:2.5,stroke:1.5,fill:!0,color:t(`mouth`),translate:{y:1}}),c.open=e.ellipse({parent:o,name:`cat.mouth.open`,width:4,height:5,stroke:1.5,fill:!0,color:t(`mouth`),translate:{y:1}});let d=e.group({parent:i,name:`whiskers`,translate:{y:5,z:2}});for(let n of[-1,1]){let r=n*12;for(let[i,a]of[-2,0,2].entries())e.path({parent:d,name:`whisker.${n<0?`left`:`right`}.${String(i)}`,closed:!1,color:t(`eye`),path:[{x:0,y:a},{x:n*8,y:a+(i-1)*1.5}],stroke:.8,translate:{x:r,y:a*.5}})}let f={normal:u0(c,`normal`),happy:c.happy,sad:u0(c,`sad`),angry:u0(c,`angry`),surprised:c.surprised,dead:c.dead,small:u0(c,`small`),worried:u0(c,`worried`),pout:c.pout,open:c.open};return{root:n,variants:{eyes:a.eyes,mouth:f,blush:a.blush}}},expressions:ur,activities:{...fr,listening:{motion:{target:`root`,rotate:{x:-.2},durationMs:300,repeat:`yoyo`},mouseInfluence:.3},thinking:{motion:{target:`root`,rotate:{z:.1},durationMs:800,repeat:`yoyo`},mouseInfluence:0}},defaultPresentation:{activity:`idle`,expression:`normal`}},p0={apiVersion:1,name:`mushroom`,palette:{body:`#fff7e4`,cap:`#f98284`,capSpot:`#ffe6c6`,eye:`#28282e`,mouth:`#28282e`,dead:`#6c5671`,deadTongue:`#d9c8bf`,tongue:`#f98284`,sweat:`#accce4`,white:`#ffffff`},build({scene:e,color:t}){let n=e.group({name:`root`}),r=e.group({parent:n,name:`body`,updateSort:!0});e.hemisphere({parent:r,name:`body.hemisphere`,backface:t(`cap`),color:t(`body`),diameter:32,rotate:{x:3*Math.PI/2},stroke:!1,translate:{y:2}});let i=e.hemisphere({parent:r,name:`cap.hemisphere`,backface:t(`capSpot`),color:t(`cap`),diameter:42,rotate:{x:Math.PI/2},stroke:!1,translate:{y:2}});e.path({parent:i,name:`cap.spot.front`,path:[{x:0,y:0}],color:t(`capSpot`),stroke:12,translate:{x:-8,y:8,z:12}}),e.path({parent:i,name:`cap.spot.top`,path:[{x:0,y:0}],color:t(`capSpot`),stroke:18,translate:{x:8,y:-4,z:13}});let a=e.group({parent:r,name:`face`,translate:{y:7,z:8}}),o=dr(e,t,a,{blushMode:`none`});return{root:n,variants:{eyes:o.eyes,mouth:o.mouth,blush:o.blush}}},expressions:ur,activities:{...fr,error:{geometry:{eyes:`dead`,mouth:`dead`},motion:{target:`root`,rotate:{x:.9},durationMs:600,repeat:`none`},mouseInfluence:.1}},defaultPresentation:{activity:`idle`,expression:`sleepy`}},m0={mushroom:[`cap`,`capSpot`],cat:[`body`,`stripes`],burger:[`topBun`,`bottomBun`]},h0={mushroom:p0,cat:f0,burger:l0};function g0(e){let t=cr(lr(h0[e])),n=or.parse(t.data);return{controls:t.controls,expressions:Object.keys(n.expressions),identitySlots:m0[e]}}var _0=new Map;function v0(e){let t=_0.get(e);return t||(t=g0(e),_0.set(e,t)),t}var y0=Object.freeze({get mushroom(){return v0(`mushroom`)},get cat(){return v0(`cat`)},get burger(){return v0(`burger`)}}),b0={mushroom:`Shiitake`,cat:`Cat`,burger:`Burger`},x0=[[`Rose`,`#f98284`,`#ffe6c6`],[`Peach`,`#f6a55c`,`#ffe9c9`],[`Gold`,`#f2d06b`,`#fff6d1`],[`Leaf`,`#9bd47a`,`#e6f8d8`],[`Mint`,`#5fc7b4`,`#d9f6ef`],[`Sky`,`#6aaee8`,`#dcefff`],[`Lilac`,`#9b8cf0`,`#ebe6ff`],[`Plum`,`#e58bd6`,`#fbe2f6`]];function S0(e,t){if(t===e.character)return e;let n=y0[e.character].identitySlots,r=y0[t].identitySlots,i=Object.fromEntries(r.flatMap((t,r)=>{let i=n[r];return Object.hasOwn(e.appearance,i)?[[t,e.appearance[i]]]:[]}));return{...e,character:t,appearance:i,expression:`normal`}}function C0(e,[,t,n]){let r=y0[e.character].identitySlots;return{...e,appearance:{...e.appearance,...Object.fromEntries(r.map((e,r)=>[e,r===0?t:n]))}}}function w0(e,t){let n=0;for(let e of t)n+=e.codePointAt(0)??0;return C0(e,x0[n%x0.length]??x0[0])}function T0({value:e,disabled:t=!1,onChange:n}){let r=y0[e.character].identitySlots,i=x0.find(([,t,n])=>r.every((r,i)=>e.appearance[r]===(i===0?t:n)))?.[0]??``;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(qK,{legend:`Avatar`,icon:(0,X.jsx)(Xq,{name:`agent`}),layout:`columns`,disabled:t,children:(0,X.jsx)(W$,{"aria-label":`Character`,className:`caps-field-icon-choices`,disabled:t,orientation:`horizontal`,value:e.character,onValueChange:t=>{n(S0(e,Bh.shape.character.parse(t)))},children:Ih.map(t=>(0,X.jsx)(q$,{value:t,label:b0[t],caption:b0[t],art:`color`,icon:(0,X.jsx)(NX,{avatar:S0(e,t),name:b0[t],size:32})},t))})}),(0,X.jsx)(qK,{legend:`Colour`,icon:(0,X.jsx)(Xq,{name:`prints`}),layout:`columns`,disabled:t,children:(0,X.jsx)(W$,{"aria-label":`Colour`,className:`caps-field-icon-choices`,disabled:t,orientation:`horizontal`,value:i,onValueChange:t=>{let r=x0.find(([e])=>e===t);r&&n(C0(e,r))},children:x0.map(([e,t])=>(0,X.jsx)(J$,{value:e,label:e,color:t},e))})})]})}var E0=wn.check(Cn(1,{message:`Give your Agent a name.`}),H(256,{message:`Use at most 256 characters.`})),D0=kn(E0),O0=e=>e===`new`||e===`none`?e:e.computerId,k0=e=>e===`new`||e===`none`?e:{computerId:e},A0=e=>e?.[0]?.computerId??`none`;function j0(e,t){let n=Object.fromEntries(e.map(e=>[e.computerId,e.name]));n.new=`New Computer`,n.none=`No Computer`;let r={label:`Computer`,kind:`select`,icon:(0,X.jsx)(Xq,{name:`computer`}),options:n};return W.check(gt(e=>Object.hasOwn(n,e)||`Choose a Computer.`)).annotate(O1(t===null?r:{...r,help:t}))}var M0=Ot({family:`grove-agent-create-request`,version:1,kinds:{request:{prefix:`request`}}});function N0({create:e,computers:t,computersUnavailable:n,inputRef:r,error:i,onCancel:a}){let o=(0,J.useRef)(null),[s,c]=(0,J.useState)(()=>{let e=M0.request.generate();return w0(Wh(e),e)}),l=(0,J.useMemo)(()=>U({name:E0.annotate(O1({label:`Name`,icon:(0,X.jsx)(Xq,{name:`write`}),render:e=>(0,X.jsx)(eK,{ref:r,id:e.id,name:e.name,"aria-label":`New Agent name`,"aria-required":`true`,"aria-describedby":e[`aria-describedby`],"aria-invalid":e[`aria-invalid`],placeholder:`Name your Agent`,maxLength:256,disabled:e.disabled,value:e.value,onBlur:e.onBlur,onChange:t=>{e.onChange(t.currentTarget.value)}})})),computer:j0(t??[],n)}),[r,t,n]),u=t!==null,d={name:``,computer:A0(t)},f=t0({schema:l,defaultValues:d,onSubmit:async({name:t,computer:n})=>{let r=u?k0(n):void 0,i=o.current;if(i?.name!==t||(i.computer===void 0?void 0:O0(i.computer))!==(r===void 0?void 0:O0(r))||i.avatar!==s){let e={name:t,requestId:M0.request.generate(),avatar:s};i=r===void 0?e:{...e,computer:r}}return o.current=i,await e(i)?(o.current=null,{kind:`saved`,values:d}):{kind:`refused`}}}),{submitting:p,canSubmit:m,dirty:h}=n0(f);return(0,X.jsxs)(a0,{model:f,layout:`columns`,"aria-label":`Create Agent`,footer:(0,X.jsxs)(UK,{divider:!1,error:i,children:[(0,X.jsx)(BT,{type:`button`,variant:`ghost`,disabled:p,onClick:a,children:`Cancel`}),(0,X.jsx)(BT,{type:`submit`,className:`shrink-0 disabled:-outline-offset-1`,variant:`primary`,loading:p,disabled:p||!m||!h,children:`Create Agent`})]}),onSubmitCapture:e=>{Be(D0(f.form.state.values.name))&&e.currentTarget.querySelector(`input[name="name"]`)?.focus()},onChange:()=>{let e=f.form.state.values;(e.name.trim()!==o.current?.name||u&&o.current.computer!==void 0&&e.computer!==O0(o.current.computer))&&(o.current=null)},children:[(0,X.jsx)(C1,{model:f,names:u?[`name`,`computer`]:[`name`]}),(0,X.jsx)(T0,{value:s,disabled:p,onChange:e=>{c(e),o.current=null}})]})}function P0({open:e,pending:t,error:n,computers:r,create:i,onClose:a,returnFocus:o}){let s=(0,J.useRef)(null);return(0,X.jsx)(IU,{open:e,onOpenChange:e=>{!e&&!t&&a()},children:(0,X.jsxs)(VU,{className:`flex flex-col gap-lg`,initialFocus:s,finalFocus:o,keepMounted:!1,children:[(0,X.jsxs)(UU,{children:[(0,X.jsx)(WU,{children:`New Agent`}),(0,X.jsx)(GU,{children:`Agents chat, write and make little games with you.`})]}),r.status===`loading`?(0,X.jsx)(`p`,{role:`status`,children:`Loading your Computers…`}):(0,X.jsx)(N0,{create:i,computers:r.status===`offered`?r.computers:r.status===`unavailable`?[]:null,computersUnavailable:r.status===`unavailable`?r.message:null,inputRef:s,error:n,onCancel:a})]})})}function F0({open:e,agents:t,defaultAgentId:n,start:r,pending:i,onClose:a,onNewAgent:o,returnFocus:s}){let c=t0({schema:(0,J.useMemo)(()=>U({agentId:W.check(gt(e=>t.some(t=>t.agentId===e)||`Choose an Agent.`)).annotate(O1({label:`Agent`,kind:`select`,options:Object.fromEntries(t.map(e=>[e.agentId,YX(e)]))}))}),[t]),defaultValues:{agentId:n??``},onSubmit:async({agentId:e})=>{let t=await r(e);if(t)return{kind:`refused`,error:t}}}),{submitting:l,canSubmit:u}=n0(c);return(0,X.jsx)(IU,{open:e,onOpenChange:e=>{!e&&!i&&!c.form.state.isSubmitting&&a()},children:(0,X.jsxs)(VU,{className:`flex flex-col gap-lg`,keepMounted:!1,finalFocus:s,children:[(0,X.jsxs)(UU,{children:[(0,X.jsx)(WU,{children:`New conversation`}),(0,X.jsx)(GU,{children:`Choose who to talk with.`})]}),t.length===0?(0,X.jsxs)(`div`,{className:`grid gap-sm`,children:[(0,X.jsx)(`p`,{children:`No Agent has conversation access yet.`}),o?(0,X.jsx)(BT,{onClick:o,children:`New Agent`}):null,(0,X.jsx)(BT,{variant:`ghost`,onClick:a,children:`Cancel`})]}):(0,X.jsx)(a0,{model:c,"aria-label":`New conversation`,footer:(0,X.jsxs)(UK,{divider:!1,error:c.error,children:[(0,X.jsx)(BT,{type:`button`,variant:`ghost`,disabled:l||i,onClick:a,children:`Cancel`}),(0,X.jsx)(BT,{type:`submit`,loading:l||i,disabled:!u||l||i,children:`Start`})]})})]})})}var I0=J.useLayoutEffect;function L0(e,t,n){J.useEffect(()=>{if(!e.current||n||typeof IntersectionObserver!=`function`)return()=>t();let r=new IntersectionObserver(e=>{t(e.pop())},{rootMargin:`100px`});return r.observe(e.current),()=>{r.disconnect(),t()}},[t,n,e])}function R0(e){let t=J.useRef(null);return J.useImperativeHandle(e,()=>t.current,[]),t}function z0(e){return e[e.length-1]}function B0(e){return typeof e==`function`}function V0(e,t){return B0(e)?e(t):e}var H0=Object.prototype.hasOwnProperty,U0=Object.prototype.propertyIsEnumerable;function W0(e){for(let t in e)if(H0.call(e,t))return!0;return!1}var G0=()=>Object.create(null),K0=(e,t)=>q0(e,t,G0);function q0(e,t,n=()=>({}),r=0){if(e===t)return e;if(r>500)return t;let i=t,a=Z0(e)&&Z0(i);if(!a&&!(Y0(e)&&Y0(i)))return i;let o=a?e:J0(e);if(!o)return i;let s=a?i:J0(i);if(!s)return i;let c=o.length,l=s.length,u=a?Array(l):n(),d=0;for(let t=0;t<l;t++){let o=a?t:s[t],l=e[o],f=i[o];if(l===f){u[o]=l,(a?t<c:H0.call(e,o))&&d++;continue}if(l===null||f===null||typeof l!=`object`||typeof f!=`object`){u[o]=f;continue}let p=q0(l,f,n,r+1);u[o]=p,p===l&&d++}return c===l&&d===c?e:u}function J0(e){let t=Object.keys(e);if(t.length!==Object.getOwnPropertyNames(e).length)return!1;let n=Object.getOwnPropertySymbols(e);if(n.length===0)return t;for(let r of n){if(!U0.call(e,r))return!1;t.push(r)}return t}function Y0(e){if(!X0(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!X0(n)||!n.hasOwnProperty(`isPrototypeOf`))}function X0(e){return Object.prototype.toString.call(e)===`[object Object]`}function Z0(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Q0(e,t,n){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0,i=e.length;r<i;r++)if(!Q0(e[r],t[r],n))return!1;return!0}if(Y0(e)&&Y0(t)){let r=n?.ignoreUndefined??!0;if(n?.partial){for(let i in t)if((!r||t[i]!==void 0)&&!Q0(e[i],t[i],n))return!1;return!0}let i=0;if(!r)i=Object.keys(e).length;else for(let t in e)e[t]!==void 0&&i++;let a=0;for(let o in t)if((!r||t[o]!==void 0)&&(a++,a>i||!Q0(e[o],t[o],n)))return!1;return i===a}return!1}var $0=/[\x00-\x1f\x7f"<>`{}]/g;function e2(e){return e.replace($0,e=>`%`+e.charCodeAt(0).toString(16).toUpperCase().padStart(2,`0`))}function t2(e){let t;try{t=decodeURI(e)}catch{t=e.replaceAll(/%[0-9A-F]{2}/gi,e=>{try{return decodeURI(e)}catch{return e}})}return e2(t)}var n2=[`http:`,`https:`,`mailto:`,`tel:`];function r2(e,t){if(!e)return!1;try{let n=new URL(e);return!t.has(n.protocol)}catch{return!1}}function i2(e){if(!e||!/[%\\\x00-\x1f\x7f]/.test(e)&&!e.startsWith(`//`))return{path:e,handledProtocolRelativeURL:!1};let t=/%25|%5C/gi,n=0,r=``,i;for(;(i=t.exec(e))!==null;)r+=t2(e.slice(n,i.index))+i[0],n=t.lastIndex;r+=t2(n?e.slice(n):e);let a=!1;return r.startsWith(`//`)&&(a=!0,r=`/`+r.replace(/^\/+/,``)),{path:r,handledProtocolRelativeURL:a}}function a2(e){return/\s|[^\u0000-\u007F]/.test(e)?e.replace(/\s|[^\u0000-\u007F]/gu,encodeURIComponent):e}function o2(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function s2(){throw Error(`Invariant failed`)}function c2(e){let t=new Map,n,r,i=e=>{e.next&&(e.prev?(e.prev.next=e.next,e.next.prev=e.prev,e.next=void 0,r&&(r.next=e,e.prev=r)):(e.next.prev=void 0,n=e.next,e.next=void 0,r&&(e.prev=r,r.next=e)),r=e)};return{get(e){let n=t.get(e);if(n)return i(n),n.value},set(a,o){if(t.size>=e&&n){let e=n;t.delete(e.key),e.next&&(n=e.next,e.next.prev=void 0),e===r&&(r=void 0)}let s=t.get(a);if(s)s.value=o,i(s);else{let e={key:a,value:o,prev:r};r&&(r.next=e),r=e,n||=e,t.set(a,e)}},clear(){t.clear(),n=void 0,r=void 0}}}var l2=4,u2=5;function d2(e){let t=e.indexOf(`{`);if(t===-1)return null;let n=e.indexOf(`}`,t);return n===-1||t+1>=e.length?null:[t,n]}function f2(e,t,n=new Uint16Array(6)){let r=e.indexOf(`/`,t),i=r===-1?e.length:r,a=e.substring(t,i);if(!a||!a.includes(`$`))return n[0]=0,n[1]=t,n[2]=t,n[3]=i,n[4]=i,n[5]=i,n;if(a===`$`){let r=e.length;return n[0]=2,n[1]=t,n[2]=t,n[3]=r,n[4]=r,n[5]=r,n}if(a.charCodeAt(0)===36)return n[0]=1,n[1]=t,n[2]=t+1,n[3]=i,n[4]=i,n[5]=i,n;let o=d2(a);if(o){let[r,s]=o,c=a.charCodeAt(r+1);if(c===45){if(r+2<a.length&&a.charCodeAt(r+2)===36){let e=r+3,a=s;if(e<a)return n[0]=3,n[1]=t+r,n[2]=t+e,n[3]=t+a,n[4]=t+s+1,n[5]=i,n}}else if(c===36){let a=r+1,o=r+2;return o===s?(n[0]=2,n[1]=t+r,n[2]=t+a,n[3]=t+o,n[4]=t+s+1,n[5]=e.length,n):(n[0]=1,n[1]=t+r,n[2]=t+o,n[3]=t+s,n[4]=t+s+1,n[5]=i,n)}}return n[0]=0,n[1]=t,n[2]=t,n[3]=i,n[4]=i,n[5]=i,n}function p2(e,t,n,r,i,a,o,s){s?.(n);let c=r;{let r=n.fullPath??n.from,s=n.options,l=r.length,u=s?.caseSensitive??e,d=s?.params?.parse??s?.parseParams;for(;c<l;){let e=f2(r,c,t),n,s=c,l=e[5];c=l+1,a++;let f=e[0];switch(f){case 0:{let t=r.substring(e[2],e[3]),o=t,s;u?s=i.static??=new Map:(o=t.toLowerCase(),s=i.staticInsensitive??=new Map);let c=s.get(o);if(c)n=c;else{let e=h2(r);e.parent=i,e.depth=a,n=e,s.set(o,e)}break}case 1:case 3:case 2:{let t=r.substring(s,e[1]),c=r.substring(e[4],l),p=u&&!!(t||c),m=t?p?t:t.toLowerCase():void 0,h=c?p?c:c.toLowerCase():void 0,g=f===1?i.dynamic:f===3?i.optional:i.wildcard,_=f!==2&&!d&&g?.find(e=>!e.parse&&e.caseSensitive===p&&e.prefix===m&&e.suffix===h);if(_)n=_;else{let e=g2(f,r,p,m,h);n=e,e.parent=i,e.depth=a;let t;t=f===1?i.dynamic??=[]:f===3?i.optional??=[]:i.wildcard??=[],t.push(e),t.length===2&&o?.push(t)}break}}i=n}if(d&&n.children&&!n.isRoot&&n.id&&n.id.charCodeAt(n.id.lastIndexOf(`/`)+1)===95){let e=h2(r);e.kind=u2,e.parent=i,a++,e.depth=a,i.pathless??=[],i.pathless.push(e),i=e}let f=(n.path||!n.children)&&!n.isRoot;if(f&&r.endsWith(`/`)){let e=h2(r);e.kind=l2,e.parent=i,a++,e.depth=a,i.index=e,i=e}i.parse=d??null,i.priority=s?.params?.priority??0,f&&!i.route&&(i.route=n,i.fullPath=r)}if(n.children)for(let r of n.children)p2(e,t,r,c,i,a,o,s)}function m2(e,t){if(e.parse&&!t.parse)return-1;if(!e.parse&&t.parse)return 1;if(e.parse&&t.parse&&(e.priority||t.priority))return t.priority-e.priority;if(e.prefix&&t.prefix&&e.prefix!==t.prefix){if(e.prefix.startsWith(t.prefix))return-1;if(t.prefix.startsWith(e.prefix))return 1}if(e.suffix&&t.suffix&&e.suffix!==t.suffix){if(e.suffix.endsWith(t.suffix))return-1;if(t.suffix.endsWith(e.suffix))return 1}return e.prefix&&!t.prefix?-1:!e.prefix&&t.prefix?1:e.suffix&&!t.suffix?-1:!e.suffix&&t.suffix?1:e.caseSensitive&&!t.caseSensitive?-1:!e.caseSensitive&&t.caseSensitive?1:0}function h2(e){return{kind:0,depth:0,pathless:null,index:null,static:null,staticInsensitive:null,dynamic:null,optional:null,wildcard:null,route:null,fullPath:e,parent:null,parse:null,priority:0}}function g2(e,t,n,r,i){return{kind:e,depth:0,pathless:null,index:null,static:null,staticInsensitive:null,dynamic:null,optional:null,wildcard:null,route:null,fullPath:t,parent:null,parse:null,priority:0,caseSensitive:n,prefix:r,suffix:i}}function _2(e,t){let n=h2(`/`),r=new Uint16Array(6),i=[];for(let t of e)p2(!1,r,t,1,n,0,i);for(let e of i)e.sort(m2);t.masksTree=n,t.flatCache=c2(1e3)}function v2(e,t){e||=`/`;let n=t.flatCache.get(e);if(n)return n;let r=C2(e,t.masksTree);return t.flatCache.set(e,r),r}function y2(e,t,n,r,i){e||=`/`,r||=`/`;let a=t?`case\0${e}`:e,o=i.singleCache.get(a);return o||(o=h2(`/`),p2(t,new Uint16Array(6),{from:e},1,o,0),i.singleCache.set(a,o)),C2(r,o,n)}function b2(e,t,n=!1){let r=n?e:`nofuzz\0${e}`,i=t.matchCache.get(r);if(i!==void 0)return i;e||=`/`;let a;try{a=C2(e,t.segmentTree,n)}catch(e){if(e instanceof URIError)a=null;else throw e}return a&&(a.branch=T2(a.route)),t.matchCache.set(r,a),a}function x2(e){return e===`/`?e:e.replace(/\/{1,}$/,``)}function S2(e,t=!1,n){let r=h2(e.fullPath),i=new Uint16Array(6),a=[],o={},s={},c=0;p2(t,i,e,1,r,0,a,e=>{if(n?.(e,c),e.id in o&&s2(),o[e.id]=e,c!==0&&e.path){let t=x2(e.fullPath);(!s[t]||e.fullPath.endsWith(`/`))&&(s[t]=e)}c++});for(let e of a)e.sort(m2);return{processedTree:{segmentTree:r,singleCache:c2(1e3),matchCache:c2(1e3),flatCache:null,masksTree:null},routesById:o,routesByPath:s}}function C2(e,t,n=!1){let r=e.split(`/`),i=D2(e,r,t,n);if(!i)return null;let[a]=w2(e,r,i);return{route:i.node.route,rawParams:a}}function w2(e,t,n){let r=E2(n.node),i=null,a=Object.create(null),o=n.extract?.part??0,s=n.extract?.node??0,c=n.extract?.path??0,l=n.extract?.segment??0;for(;s<r.length;o++,s++,c++,l++){let u=r[s];if(u.kind===l2)break;if(u.kind===u2){l--,o--,c--;continue}let d=t[o],f=c;if(d&&(c+=d.length),u.kind===1){i??=n.node.fullPath.split(`/`);let e=i[l],t=u.prefix?.length??0;if(e.charCodeAt(t)===123){let n=u.suffix?.length??0,r=e.substring(t+2,e.length-n-1),i=d.substring(t,d.length-n);a[r]=decodeURIComponent(i)}else{let t=e.substring(1);a[t]=decodeURIComponent(d)}}else if(u.kind===3){if(n.skipped&1<<s){o--,c=f-1;continue}i??=n.node.fullPath.split(`/`);let e=i[l],t=u.prefix?.length??0,r=u.suffix?.length??0,p=e.substring(t+3,e.length-r-1),m=u.suffix||u.prefix?d.substring(t,d.length-r):d;m&&(a[p]=decodeURIComponent(m))}else if(u.kind===2){let t=u,n=e.substring(f+(t.prefix?.length??0),e.length-(t.suffix?.length??0)),r=decodeURIComponent(n);a[`*`]=r,a._splat=r;break}}return n.rawParams&&Object.assign(a,n.rawParams),[a,{part:o,node:s,path:c,segment:l}]}function T2(e){let t=[e];for(;e.parentRoute;)e=e.parentRoute,t.push(e);return t.reverse(),t}function E2(e){let t=Array(e.depth+1);do t[e.depth]=e,e=e.parent;while(e);return t}function D2(e,t,n,r){if(e===`/`&&n.index)return{node:n.index,skipped:0};let i=!z0(t),a=i&&e!==`/`,o=t.length-+!!i,s=[{node:n,index:1,skipped:0,statics:0,dynamics:0,optionals:0}],c=null,l=null;for(;s.length;){let n=s.pop(),{node:i,index:u,skipped:d,statics:f,dynamics:p,optionals:m}=n,{extract:h,rawParams:g}=n;if(i.kind===2&&i.route&&!j2(l,n))continue;if(i.parse){if(!A2(e,t,n))continue;g=n.rawParams,h=n.extract}r&&i.route&&i.kind!==l2&&j2(c,n)&&(c=n);let _=u===o;if(_&&(i.route&&(!a||i.kind===l2||i.kind===2)&&j2(l,n)&&(l=n),!i.optional&&!i.wildcard&&!i.index&&!i.pathless))continue;let v=_?void 0:t[u],y;if(_&&i.index){let n={node:i.index,index:u,skipped:d,statics:f,dynamics:p,optionals:m,extract:h,rawParams:g},r=!0;if(i.index.parse&&(A2(e,t,n)||(r=!1)),r){if(!p&&!m&&!d&&k2(f,o))return n;j2(l,n)&&(l=n)}}if(i.wildcard)for(let e=i.wildcard.length-1;e>=0;e--){let n=i.wildcard[e],{prefix:r,suffix:a}=n;if(!(r&&(_||!(n.caseSensitive?v:y??=v.toLowerCase()).startsWith(r)))){if(a){if(_)continue;let e=t.slice(u).join(`/`).slice(-a.length);if((n.caseSensitive?e:e.toLowerCase())!==a)continue}s.push({node:n,index:o,skipped:d,statics:f,dynamics:p,optionals:m,extract:h,rawParams:g})}}if(i.optional){let e=d|1<<i.depth+1;for(let t=i.optional.length-1;t>=0;t--){let n=i.optional[t];s.push({node:n,index:u,skipped:e,statics:f,dynamics:p,optionals:m,extract:h,rawParams:g})}if(!_)for(let e=i.optional.length-1;e>=0;e--){let t=i.optional[e],{prefix:n,suffix:r}=t;if(n||r){let e=t.caseSensitive?v:y??=v.toLowerCase();if(n&&!e.startsWith(n)||r&&!e.endsWith(r))continue}s.push({node:t,index:u+1,skipped:d,statics:f,dynamics:p,optionals:m+O2(o,u),extract:h,rawParams:g})}}if(!_&&i.dynamic&&v)for(let e=i.dynamic.length-1;e>=0;e--){let t=i.dynamic[e],{prefix:n,suffix:r}=t;if(n||r){let e=t.caseSensitive?v:y??=v.toLowerCase();if(n&&!e.startsWith(n)||r&&!e.endsWith(r))continue}s.push({node:t,index:u+1,skipped:d,statics:f,dynamics:p+O2(o,u),optionals:m,extract:h,rawParams:g})}if(!_&&i.staticInsensitive){let e=i.staticInsensitive.get(y??=v.toLowerCase());e&&s.push({node:e,index:u+1,skipped:d,statics:f+O2(o,u),dynamics:p,optionals:m,extract:h,rawParams:g})}if(!_&&i.static){let e=i.static.get(v);e&&s.push({node:e,index:u+1,skipped:d,statics:f+O2(o,u),dynamics:p,optionals:m,extract:h,rawParams:g})}if(i.pathless)for(let e=i.pathless.length-1;e>=0;e--){let t=i.pathless[e];s.push({node:t,index:u,skipped:d,statics:f,dynamics:p,optionals:m,extract:h,rawParams:g})}}if(l)return l;if(r&&c){let n=c.index;for(let e=0;e<c.index;e++)n+=t[e].length;let r=n===e.length?`/`:e.slice(n);return c.rawParams??=Object.create(null),c.rawParams[`**`]=decodeURIComponent(r),c}return null}function O2(e,t){return 2**(e-t-1)}function k2(e,t){return e===2**(t-1)-1}function A2(e,t,n){let r,i;try{[r,i]=w2(e,t,n)}catch{return null}if(n.rawParams=r,n.extract=i,!n.node.parse)return!0;try{if(n.node.parse(r)===!1)return null}catch{}return!0}function j2(e,t){return!e||t.statics>e.statics||t.statics===e.statics&&(t.dynamics>e.dynamics||t.dynamics===e.dynamics&&(t.optionals>e.optionals||t.optionals===e.optionals&&((t.node.kind===l2)>(e.node.kind===l2)||t.node.kind===l2==(e.node.kind===l2)&&t.node.depth>e.node.depth)))}function M2(e){return N2(e.filter(e=>e!==void 0).join(`/`))}function N2(e){return e.replace(/\/{2,}/g,`/`)}function P2(e){return e===`/`?e:e.replace(/^\/{1,}/,``)}function F2(e){let t=e.length;return t>1&&e[t-1]===`/`?e.replace(/\/{1,}$/,``):e}function I2(e){return F2(P2(e))}function L2(e,t){return e?.endsWith(`/`)&&e!==`/`&&e!==`${t}/`?e.slice(0,-1):e}function R2(e,t,n){return L2(e,n)===L2(t,n)}function z2({base:e,to:t,trailingSlash:n=`never`,cache:r}){let i=t===`.`,a=t.startsWith(`/`),o;if(r){o=a?t:i?e:e+`\0`+t;let n=r.get(o);if(n)return n}let s;if(i)s=e.split(`/`);else if(a)s=t.split(`/`);else{for(s=e.split(`/`);s.length>1&&z0(s)===``;)s.pop();let n=t.split(`/`);for(let e=0,t=n.length;e<t;e++){let r=n[e];r===``?e?e===t-1&&s.push(r):s=[r]:r===`..`?s.length>1?s.pop():s=[``]:r===`.`||s.push(r)}}s.length>1&&(z0(s)===``?n===`never`&&s.pop():n===`always`&&s.push(``));let c=N2(s.join(`/`))||`/`;return o&&r&&r.set(o,c),c}function B2(e){let t=new Map(e.map(e=>[encodeURIComponent(e),e])),n=Array.from(t.keys()).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`|`),r=new RegExp(n,`g`);return e=>e.replace(r,e=>t.get(e)??e)}function V2(e,t,n){let r=t[e];return typeof r==`string`?e===`_splat`?/^[a-zA-Z0-9\-._~!/]*$/.test(r)?r:r.split(`/`).map(e=>U2(e,n)).join(`/`):U2(r,n):r}function H2({path:e,params:t,decoder:n,...r}){let i=!1,a=Object.create(null);if(!e||e===`/`)return{interpolatedPath:`/`,usedParams:a,isMissingParams:i};if(!e.includes(`$`))return{interpolatedPath:e,usedParams:a,isMissingParams:i};let o=e.length,s=0,c,l=``;for(;s<o;){let r=s;c=f2(e,r,c);let o=c[5];if(s=o+1,r===o)continue;let u=c[0];if(u===0){l+=`/`+e.substring(r,o);continue}if(u===2){let s=t._splat;a._splat=s,a[`*`]=s;let u=e.substring(r,c[1]),d=e.substring(c[4],o);if(!s){i=!0,(u||d)&&(l+=`/`+u+d);continue}let f=V2(`_splat`,t,n);l+=`/`+u+f+d;continue}if(u===1){let s=e.substring(c[2],c[3]);!i&&!(s in t)&&(i=!0),a[s]=t[s];let u=e.substring(r,c[1]),d=e.substring(c[4],o),f=V2(s,t,n)??`undefined`;l+=`/`+u+f+d;continue}if(u===3){let i=e.substring(c[2],c[3]),s=t[i];if(s==null)continue;a[i]=s;let u=e.substring(r,c[1]),d=e.substring(c[4],o),f=V2(i,t,n)??``;l+=`/`+u+f+d;continue}}return e.endsWith(`/`)&&(l+=`/`),{usedParams:a,interpolatedPath:l||`/`,isMissingParams:i}}function U2(e,t){let n=encodeURIComponent(e);return t?.(n)??n}function W2(e){return e?.isNotFound===!0}function G2(){try{return sessionStorage}catch{return}}var K2=`tsr-scroll-restoration-v1_3`,q2=G2();function J2(){try{return JSON.parse(q2?.getItem(`tsr-scroll-restoration-v1_3`)||`{}`)}catch{return{}}}function Y2(){try{q2?.setItem(K2,JSON.stringify(X2))}catch{}}var X2=J2(),Z2=`data-scroll-restoration-id`,Q2=e=>e.state.__TSR_key||e.href;function $2(e){let t=e.getAttribute(Z2);if(t)return`[${Z2}="${t}"]`;let n=``,r=e,i;for(;i=r.parentNode;){let e=1,t=r;for(;t=t.previousElementSibling;)e++;let a=`${r.localName}:nth-child(${e})`;n=n?`${a} > ${n}`:a,r=i}return n}var e4=!1,t4=`window`;function n4(e){try{return typeof e==`function`?e():document.querySelector(e)}catch{}}function r4(e){let t=new Set;for(let n of e){if(n===t4)continue;let e=n4(n);e&&t.add(e)}return t}function i4(e,t){let n=t??e.options.scrollRestoration,r=e._scroll;n&&(r.restoring=!0);let i=e.options.getScrollRestorationKey||Q2,a=new Set,o=e=>{let t=X2[e]||={};for(let e of a)e===document?t[t4]={scrollX,scrollY}:e.isConnected&&(t[$2(e)]={scrollX:e.scrollLeft,scrollY:e.scrollTop})};n&&!r.restoration&&(r.restoration=!0,e4=!1,history.scrollRestoration=`manual`,document.addEventListener(`scroll`,e=>{e4||a.add(e.target)},!0),e.subscribe(`onBeforeLoad`,e=>{e.fromLocation&&o(i(e.fromLocation)),a.clear()}),addEventListener(`pagehide`,()=>{o(i(e.stores.resolvedLocation.get()??e.stores.location.get())),Y2()})),!r.reset&&(r.reset=!0,e.subscribe(`onRendered`,t=>{let n=e.options.scrollRestorationBehavior,o=e.options.scrollToTopSelectors,s=r.next,c=r.hash,l;if(a.clear(),r.next=!0,r.hash=!1,typeof e.options.scrollRestoration==`function`&&!e.options.scrollRestoration({location:e.latestLocation}))return;let u=i(t.toLocation),d=t.fromLocation&&i(t.fromLocation);if(r.restoring&&d&&d!==u){let e=X2[d];if(e){let t=X2[u];for(let n in e){if(n===t4){if(s)continue}else{let e=n4(n);if(!e||s&&o&&(l??=r4(o),l.has(e)))continue}t||=X2[u]={},t[n]??=e[n]}}}e4=!0;try{let e=t.toLocation.hash,i=t.toLocation.state.__hashScrollIntoViewOptions??!0,a=!1;if(s){!e&&o&&(l??=r4(o));let t=e&&i&&c,s=r.restoring?X2[u]:void 0;if(s)for(let e in s){let{scrollX:r,scrollY:i}=s[e];if(e===t4){if(t)continue;scrollTo({top:i,left:r,behavior:n}),a=!0}else{let t=n4(e);t&&(t.scrollLeft=r,t.scrollTop=i,l?.delete(t))}}if(!e){let e={top:0,left:0,behavior:n};if(a||scrollTo(e),l)for(let t of l)t.scrollTo(e)}}!a&&e&&i&&document.getElementById(e)?.scrollIntoView(i)}finally{e4=!1}}))}function a4(e,t=String){let n=new URLSearchParams;for(let r in e){let i=e[r];i!==void 0&&n.set(r,t(i))}return n.toString()}function o4(e){return e?e===`false`?!1:e===`true`?!0:e*0==0&&+e+``===e?+e:e:``}function s4(e){let t=new URLSearchParams(e),n=Object.create(null);for(let[e,r]of t.entries()){let t=n[e];t==null?n[e]=o4(r):Array.isArray(t)?t.push(o4(r)):n[e]=[t,o4(r)]}return n}var c4=/^(?:\s|["[{\d-]|fa|nu|tr)/,l4=d4(JSON.parse),u4=f4(JSON.stringify,JSON.parse);function d4(e){return t=>{t[0]===`?`&&(t=t.substring(1));let n=s4(t);for(let t in n){let r=n[t];if(typeof r==`string`)try{n[t]=e(r)}catch{}}return n}}function f4(e,t){let n=t===JSON.parse;function r(r){if(r&&typeof r==`object`)try{return e(r)}catch{}else if(t&&typeof r==`string`){if(n&&!c4.test(r))return r;try{return t(r),e(r)}catch{}}return r}return e=>{let t=a4(e,r);return t?`?${t}`:``}}var p4=`__root__`;function m4(e){if(e.statusCode=e.statusCode||e.code||307,!e._builtLocation&&!e.reloadDocument&&typeof e.href==`string`)try{new URL(e.href),e.reloadDocument=!0}catch{}let t=new Headers(e.headers);e.href&&t.get(`Location`)===null&&t.set(`Location`,e.href);let n=new Response(null,{status:e.statusCode,headers:t});if(n.options=e,e.throw)throw n;return n}function h4(e){return e instanceof Response&&!!e.options}function g4(e){return{input:({url:t})=>{for(let n of e)t=v4(n,t);return t},output:({url:t})=>{for(let n=e.length-1;n>=0;n--)t=y4(e[n],t);return t}}}function _4(e){let t=I2(e.basepath),n=`/${t}`,r=e.caseSensitive?n:n.toLowerCase(),i=`${r}/`;return{input:({url:t})=>{let a=e.caseSensitive?t.pathname:t.pathname.toLowerCase();return a===r?t.pathname=`/`:a.startsWith(i)&&(t.pathname=t.pathname.slice(n.length)),t},output:({url:e})=>(e.pathname=M2([`/`,t,e.pathname]),e)}}function v4(e,t){let n=e?.input?.({url:t});if(n){if(typeof n==`string`)return new URL(n);if(n instanceof URL)return n}return t}function y4(e,t){let n=e?.output?.({url:t});if(n){if(typeof n==`string`)return new URL(n);if(n instanceof URL)return n}return t}function b4(e,t){let{createMutableStore:n,createReadonlyStore:r,batch:i}=t,a=new Map,o=n(`idle`),s=n(e),c=n(void 0),l=n([]),u=r(()=>l.get().map(e=>a.get(e).get())),d=r(()=>({status:o.get(),isLoading:o.get()===`pending`,matches:u.get(),location:s.get(),resolvedLocation:c.get()}));function f(e){let t=a.get(e);return t||(t=n(void 0),a.set(e,t)),t}let p={status:o,location:s,resolvedLocation:c,ids:l,matches:u,byRoute:a,__store:d,getMatchStore:f,setMatches:m};function m(e){let t=l.get(),n=e.map(e=>e.routeId);i(()=>{o2(t,n)||l.set(n);for(let e of t)n.includes(e)||a.get(e).set(()=>void 0);for(let t of e){let e=f(t.routeId);e.get()!==t&&e.set(t)}})}return p}var x4=`__TSR_index`,S4=`popstate`,C4=`beforeunload`;function w4(e){let t=e.getLocation(),n=new Set,r=r=>{t=e.getLocation(),n.forEach(e=>e({location:t,action:r}))},i=n=>{e.notifyOnIndexChange??!0?r(n):t=e.getLocation()},a=async({task:n,navigateOpts:r,...i})=>{if(r?.ignoreBlocker??!1){n();return}let a=e.getBlockers?.()??[],o=i.type===`PUSH`||i.type===`REPLACE`;if(typeof document<`u`&&a.length&&o)for(let n of a){let r=k4(i.path,i.state);if(await n.blockerFn({currentLocation:t,nextLocation:r,action:i.type})){e.onBlocked?.();return}}n()};return{get location(){return t},get length(){return e.getLength()},subscribers:n,subscribe:e=>(n.add(e),()=>{n.delete(e)}),push:(n,i,o)=>{let s=t.state[x4];i=T4(s+1,i),a({task:()=>{e.pushState(n,i),r({type:`PUSH`})},navigateOpts:o,type:`PUSH`,path:n,state:i})},replace:(n,i,o)=>{let s=t.state[x4];i=T4(s,i),a({task:()=>{e.replaceState(n,i),r({type:`REPLACE`})},navigateOpts:o,type:`REPLACE`,path:n,state:i})},go:(t,n)=>{a({task:()=>{e.go(t),i({type:`GO`,index:t})},navigateOpts:n,type:`GO`})},back:t=>{a({task:()=>{e.back(t?.ignoreBlocker??!1),i({type:`BACK`})},navigateOpts:t,type:`BACK`})},forward:t=>{a({task:()=>{e.forward(t?.ignoreBlocker??!1),i({type:`FORWARD`})},navigateOpts:t,type:`FORWARD`})},canGoBack:()=>t.state[x4]!==0,createHref:t=>e.createHref(t),block:t=>{if(!e.setBlockers)return()=>{};let n=e.getBlockers?.()??[];return e.setBlockers([...n,t]),()=>{let n=e.getBlockers?.()??[];e.setBlockers?.(n.filter(e=>e!==t))}},flush:()=>e.flush?.(),destroy:()=>e.destroy?.(),notify:r}}function T4(e,t){t||={};let n=A4();return{...t,key:n,__TSR_key:n,[x4]:e}}function E4(e){let t=e?.window??(typeof document<`u`?window:void 0),n=t.history.pushState,r=t.history.replaceState,i=[],a=()=>i,o=e=>i=e,s=e?.createHref??(e=>e),c=e?.parseLocation??(()=>k4(`${t.location.pathname}${t.location.search}${t.location.hash}`,t.history.state));if(!t.history.state?.__TSR_key&&!t.history.state?.key){let e=A4();t.history.replaceState({[x4]:0,key:e,__TSR_key:e},``)}let l=c(),u,d=!1,f=!1,p=!1,m=!1,h=()=>l,g,_=()=>{g&&(S._ignoreSubscribers=!0,(g[2]?t.history.pushState:t.history.replaceState)(g[1],``,g[0]),S._ignoreSubscribers=!1,g=void 0,u=void 0)},v=(e,t,n)=>{let r=s(t),i=!!g;i||(u=l),l=k4(t,n),g=[r,n,g?.[2]||e],i||queueMicrotask(()=>_())},y=e=>{l=c(),S.notify({type:e})},b=async()=>{if(f){f=!1;return}let e=c(),n=e.state[x4]-l.state[x4],r=n===1,i=n===-1,o=!r&&!i||d;d=!1;let s=o?`GO`:i?`BACK`:`FORWARD`,u=o?{type:`GO`,index:n}:{type:i?`BACK`:`FORWARD`};if(p)p=!1;else{let n=a();if(typeof document<`u`&&n.length){for(let r of n)if(await r.blockerFn({currentLocation:l,nextLocation:e,action:s})){f=!0,t.history.go(1),S.notify(u);return}}}l=c(),S.notify(u)},x=e=>{if(m){m=!1;return}let t=!1,n=a();if(typeof document<`u`&&n.length)for(let e of n){let n=e.enableBeforeUnload??!0;if(n===!0){t=!0;break}if(typeof n==`function`&&n()===!0){t=!0;break}}if(t)return e.preventDefault(),e.returnValue=``},S=w4({getLocation:h,getLength:()=>t.history.length,pushState:(e,t)=>v(!0,e,t),replaceState:(e,t)=>v(!1,e,t),back:e=>(e&&(p=!0),m=!0,t.history.back()),forward:e=>{e&&(p=!0),m=!0,t.history.forward()},go:e=>{d=!0,t.history.go(e)},createHref:e=>s(e),flush:_,destroy:()=>{t.history.pushState=n,t.history.replaceState=r,t.removeEventListener(C4,x,{capture:!0}),t.removeEventListener(S4,b)},onBlocked:()=>{u&&l!==u&&(l=u)},getBlockers:a,setBlockers:o,notifyOnIndexChange:!1});return t.addEventListener(C4,x,{capture:!0}),t.addEventListener(S4,b),t.history.pushState=function(...e){let r=n.apply(t.history,e);return S._ignoreSubscribers||y(`PUSH`),r},t.history.replaceState=function(...e){let n=r.apply(t.history,e);return S._ignoreSubscribers||y(`REPLACE`),n},S}function D4(e={initialEntries:[`/`]}){let t=e.initialEntries,n=e.initialIndex?Math.min(Math.max(e.initialIndex,0),t.length-1):t.length-1,r=t.map((e,t)=>T4(t,void 0)),i=()=>k4(t[n],r[n]),a=[];return w4({getLocation:i,getLength:()=>t.length,pushState:(e,i)=>{n<t.length-1&&(t.splice(n+1),r.splice(n+1)),r.push(i),t.push(e),n=Math.max(t.length-1,0)},replaceState:(e,i)=>{r[n]=i,t[n]=e},back:()=>{n=Math.max(n-1,0)},forward:()=>{n=Math.min(n+1,t.length-1)},go:e=>{n=Math.min(Math.max(n+e,0),t.length-1)},createHref:e=>e,getBlockers:()=>a,setBlockers:e=>a=e})}function O4(e){let t=e.replace(/[\x00-\x1f\x7f]/g,``);return t.startsWith(`//`)&&(t=`/`+t.replace(/^\/+/,``)),t}function k4(e,t){let n=O4(e),r=n.indexOf(`#`),i=n.indexOf(`?`),a=A4();return{href:n,pathname:n.substring(0,r>0?i>0?Math.min(r,i):r:i>0?i:n.length),hash:r>-1?n.substring(r):``,search:i>-1?n.slice(i,r===-1?void 0:r):``,state:t||{[x4]:0,key:a,__TSR_key:a}}}function A4(){return(Math.random()+1).toString(36).substring(7)}function j4(e){return e.options.loader||e.options.beforeLoad||e.lazyFn||e.options.component?.preload||e.options.pendingComponent?.preload}function M4(e,t){return{fromLocation:t,toLocation:e,pathChanged:t?.pathname!==e.pathname,hrefChanged:t?.href!==e.href,hashChanged:t?.hash!==e.hash}}function N4({key:e,__TSR_key:t,__TSR_index:n,__hashScrollIntoViewOptions:r,...i}){return i}function P4(e,t,n,r){for(let i of t){if(r?.()===!1)return;n.some(e=>e.routeId===i.routeId)||e.routesById[i.routeId].options.onLeave?.(i)}for(let i of n){if(r?.()===!1)return;e.routesById[i.routeId].options[t.some(e=>e.routeId===i.routeId)?`onStay`:`onEnter`]?.(i)}}var F4=class{constructor(e,t){this.tempLocationKey=`${Math.round(Math.random()*1e7)}`,this._scroll={next:!0},this.subscribers=new Set,this._cache=new Map,this._committed=[],this.routeBranchCache=new WeakMap,this.lightweightCache=new WeakMap,this.startTransition=async e=>(e(),!1),this.update=e=>{let t=this.options,n=this.basepath??t?.basepath??`/`,r=this.basepath===void 0,i=t?.rewrite;if(this.options={...t,...e},this.isServer=this.options.isServer??!1??typeof document>`u`,this.protocolAllowlist=new Set(this.options.protocolAllowlist),this.options.pathParamsAllowedCharacters&&(this.pathParamsDecoder=B2(this.options.pathParamsAllowedCharacters)),(!this.history||this.options.history&&this.options.history!==this.history)&&(this.history=this.options.history?this.options.history:E4()),this.origin=this.options.origin,this.origin||=window?.origin&&window.origin!==`null`?window.origin:`http://localhost`,this.history&&this.updateLatestLocation(),this.options.routeTree!==this.routeTree){this.routeTree=this.options.routeTree;let e;this.resolvePathCache=c2(1e3),e=this.buildRouteTree(),this.setRoutes(e)}if(!this.stores&&this.latestLocation){let e=this.getStoreConfig(this);this.batch=e.batch,this.stores=b4(this.latestLocation,e),i4(this)}let a=this.options.basepath??`/`,o=this.options.rewrite;if(r||n!==a||i!==o){this.basepath=a;let e=[],t=I2(a);t&&t!==`/`&&e.push(_4({basepath:a})),o&&e.push(o),this.rewrite=e.length===0?void 0:e.length===1?e[0]:g4(e),this.history&&this.updateLatestLocation(),this.stores&&this.stores.location.set(this.latestLocation)}},this.updateLatestLocation=()=>{this.latestLocation=this.parseLocation(this.history.location,this.latestLocation)},this.buildRouteTree=()=>{let e=S2(this.routeTree,this.options.caseSensitive,(e,t)=>{e.init({originalIndex:t})});return this.options.routeMasks&&_2(this.options.routeMasks,e.processedTree),e},this.subscribe=(e,t)=>{let n={eventType:e,fn:t};return this.subscribers.add(n),()=>{this.subscribers.delete(n)}},this.emit=e=>{for(let t of this.subscribers)if(t.eventType===e.type)try{t.fn(e)}catch(e){console.error(e)}},this.parseLocation=(e,t)=>{let n=({pathname:e,search:n,hash:r,href:i,state:a})=>{if(!this.rewrite&&!/[ \x00-\x1f\x7f\u0080-\uffff]/.test(e)){let i=this.options.parseSearch(n),o=this.options.stringifySearch(i);return{href:e+o+r,publicHref:e+o+r,pathname:i2(e).path,external:!1,searchStr:o,search:K0(t?.search,i),hash:i2(r.slice(1)).path,state:q0(t?.state,a)}}let o=new URL(i,this.origin),s=v4(this.rewrite,o),c=this.options.parseSearch(s.search),l=this.options.stringifySearch(c);return s.search=l,{href:s.href.replace(s.origin,``),publicHref:i,pathname:i2(s.pathname).path,external:!!this.rewrite&&s.origin!==this.origin,searchStr:l,search:K0(t?.search,c),hash:i2(s.hash.slice(1)).path,state:q0(t?.state,a)}},r=n(e),{__tempLocation:i,__tempKey:a}=r.state;if(i&&(!a||a===this.tempLocationKey)){let e=n(i);return e.state.key=r.state.key,e.state.__TSR_key=r.state.__TSR_key,delete e.state.__tempLocation,{...e,maskedLocation:r}}return r},this.resolvePathWithBase=(e,t)=>z2({base:e,to:t.includes(`//`)?N2(t):t,trailingSlash:this.options.trailingSlash,cache:this.resolvePathCache}),this.matchRoutes=(e,t,n)=>typeof e==`string`?this.matchRoutesInternal({pathname:e,search:t},n):this.matchRoutesInternal(e,t),this.getMatchedRoutes=e=>{let t=Object.create(null),n=b2(F2(e),this.processedTree,!0);return n&&Object.assign(t,n.rawParams),[n?.branch||[this.routesById.__root__],t,n?.route]},this.buildLocation=e=>{let t=(t={})=>{let n=t._fromLocation||this._pendingLocation||this.latestLocation,r=this.matchRoutesLightweight(n);t.from;let i=t.unsafeRelative===`path`?n.pathname:t.from??r[1],a=t.to?`${t.to}`:void 0,o=r[2],s=Object.assign(Object.create(null),r[3]),c=a?.charCodeAt(0)===47?`/`:this.resolvePathWithBase(i,`.`),l=a?this.resolvePathWithBase(c,a):c,u=V4(t.params,s),d=this.routesByPath[F2(l)],f;if(d)f=this.getRouteBranch(d);else if(l.includes(`$`))f=[];else{let[e,t,n]=this.getMatchedRoutes(l);f=e,this.options.notFoundRoute&&(!n||n.path!==`/`&&t[`**`])&&(f=[...f,this.options.notFoundRoute])}if(f.length&&W0(u))for(let e of f){let t=e.options.params?.stringify??e.options.stringifyParams;if(t)try{Object.assign(u,t(u))}catch{}}let p=e.leaveParams?l:i2(H2({path:l,params:u,decoder:this.pathParamsDecoder,server:this.isServer}).interpolatedPath).path,m=o;if(e._includeValidateSearch&&this.options.search?.strict){let e={};f.forEach(t=>{if(t.options.validateSearch)try{Object.assign(e,R4(t.options.validateSearch,{...e,...m}))}catch{}}),m=e}m=z4(m,t,f,e._includeValidateSearch),m=K0(o,m);let h=this.options.stringifySearch(m),g=t.hash===!0?n.hash:t.hash?V0(t.hash,n.hash):void 0,_=g?`#${g}`:``,v=t.state===!0?n.state:t.state?V0(t.state,n.state):{};v=q0(n.state,v);let y=`${p}${h}${_}`,b,x,S=!1;if(this.rewrite){let e=new URL(y,this.origin),t=y4(this.rewrite,e);b=e.href.replace(e.origin,``),t.origin===this.origin?x=t.pathname+t.search+t.hash:(x=t.href,S=!0)}else b=a2(y),x=b;return{publicHref:x,href:b,pathname:p,search:m,searchStr:h,state:v,hash:g??``,external:S,unmaskOnReload:t.unmaskOnReload}},n=(n={},r)=>{let i=t(n),a=r?t(r):void 0;if(!a){let n=Object.create(null);if(this.options.routeMasks){let o=v2(i.pathname,this.processedTree);if(o){Object.assign(n,o.rawParams);let{from:i,params:s,...c}=o.route,l=V4(s,n);r={from:e.from,...c,params:l},a=t(r)}}}return a&&(i.maskedLocation=a),i};return e.mask?n(e,{from:e.from,...e.mask}):n(e)},this.commitLocation=async({viewTransition:e,ignoreBlocker:t,...n})=>{let r,i=F2(this.latestLocation.href)===F2(n.href)&&Q0(N4(n.state),N4(this.latestLocation.state)),a=this._commitPromise,o,s=new Promise(e=>{o=e});if(s.resolve=()=>{o(),a?.resolve()},this._commitPromise=s,i)this.load();else{let{maskedLocation:i,hashScrollIntoView:a,...o}=n;i&&(o={...i,state:{...i.state,__tempKey:void 0,__tempLocation:{...o,search:o.searchStr,state:{...o.state,__tempKey:void 0,__tempLocation:void 0,__TSR_key:void 0,key:void 0}}}},(o.unmaskOnReload??this.options.unmaskOnReload??!1)&&(o.state.__tempKey=this.tempLocationKey)),o.state.__hashScrollIntoViewOptions=a??this.options.defaultHashScrollIntoView??!0,this.shouldViewTransition=e,r=n.replace?`REPLACE`:`PUSH`,this.history[r===`REPLACE`?`replace`:`push`](o.publicHref,o.state,{ignoreBlocker:t}),this.history.subscribers.size||this.load({action:{type:r}})}return this._scroll.next=n.resetScroll??!0,this._commitPromise},this.buildAndCommitLocation=({replace:e,resetScroll:t,hashScrollIntoView:n,viewTransition:r,ignoreBlocker:i,_redirects:a,href:o,...s}={})=>{if(o){let t=this.history.location.state.__TSR_index,n=k4(o,{__TSR_index:e?t:t+1}),r=new URL(n.pathname,this.origin);s.to=v4(this.rewrite,r).pathname,s.search=this.options.parseSearch(n.search),s.hash=n.hash.slice(1)}let c=this.buildLocation({...s,_includeValidateSearch:!0});a&&(c._redirects=a),this._pendingLocation=c;let l=this.commitLocation({...c,viewTransition:r,replace:e,resetScroll:t,hashScrollIntoView:n,ignoreBlocker:i});return queueMicrotask(()=>{this._pendingLocation===c&&(this._pendingLocation=void 0)}),l},this.navigate=async({to:e,reloadDocument:t,href:n,publicHref:r,...i})=>{let a=!1;if(n)try{new URL(`${n}`),a=!0}catch{}if(a&&!t&&(t=!0),t){if(e!==void 0||!n){let t=this.buildLocation({to:e,...i});n??=t.publicHref,r??=t.publicHref}let t=!a&&r?r:n;if(r2(t,this.protocolAllowlist))return;if(!i.ignoreBlocker){let e=this.history.getBlockers?.()??[];for(let t of e)if(t?.blockerFn&&await t.blockerFn({currentLocation:this.latestLocation,nextLocation:this.latestLocation,action:`PUSH`}))return}i.replace?window.location.replace(t):window.location.href=t;return}return this.buildAndCommitLocation({...i,href:n,to:e,_isNavigate:!0})},this.load=async e=>{this.updateLatestLocation(),e?.action&&(this._scroll.hash=e.action.type===`PUSH`||e.action.type===`REPLACE`),await N3(this,e)},this.startViewTransition=e=>{let t=this.shouldViewTransition??this.options.defaultViewTransition;if(this.shouldViewTransition=void 0,t&&typeof document.startViewTransition==`function`){let n;if(typeof t==`object`&&window.CSS?.supports?.(`selector(:active-view-transition-type(a))`)){let r=this.latestLocation,i=this.stores.resolvedLocation.get(),a=typeof t.types==`function`?t.types(M4(r,i)):t.types;if(a===!1)return e();n={update:e,types:a}}else n=e;return document.startViewTransition(n).updateCallbackDone}return e()},this.invalidate=e=>{let t=this._committed,n=e?.filter,r=this._preloads,i=new Set([...t,...this._cache.values(),...[...r?.values()??[]].flat(),...this._tx?.[3]??[]].filter(e=>!n||n(e)).map(e=>e.id)),a=[];for(let[e,t]of r??[])t.some(e=>i.has(e.id))&&(r.delete(e),a.push(e));let o=t=>{if(i.has(t.id)){let n=this.routesById[t.routeId],r={...t,invalid:!0,...(e?.forcePending||t.status===`error`||t.status===`notFound`)&&j4(n)?{status:`pending`,error:void 0}:void 0};return t._flight=void 0,r}return t};this._committed=t.map(o);for(let[t,n]of this._cache)i.has(t)&&(n.invalid=!0,e?.forcePending&&(n.status=`pending`));for(let e of i)this._flights?.delete(e);for(let e of a)e.abort();return this.shouldViewTransition=!1,this.load({sync:e?.sync})},this.resolveRedirect=e=>{let t=e.headers.get(`Location`);if(!e.options.href||e.options._builtLocation){let t=(e.options._builtLocation??this.buildLocation(e.options)).publicHref||`/`;e.options.href=t,e.headers.set(`Location`,t)}else if(t)try{let n=new URL(t);if(this.origin&&n.origin===this.origin){let t=n.pathname+n.search+n.hash;e.options.href=t,e.headers.set(`Location`,t)}}catch{}if(e.options.href&&!e.options._builtLocation&&r2(e.options.href,this.protocolAllowlist))throw Error(`Redirect blocked: unsafe protocol`);return e.headers.get(`Location`)||e.headers.set(`Location`,e.options.href),e},this.clearCache=e=>{let t=this._cache,n=this._preloads,r=e?.filter,i=[],a=[];for(let[e,n]of t)(!r||r(n))&&(a.push(e),i.push(n));let o=[];for(let[e,t]of n??[])(!r||t.some(r))&&(o.push(e),i.push(...t));for(let e of a)t.delete(e);for(let e of o)n.delete(e);for(let e of i){let t=e._flight;e._flight=void 0,t&&!--t[2]&&(this._flights?.get(e.id)===t&&this._flights.delete(e.id),o.push(t[1]))}for(let e of o)e.abort()},this.loadRouteChunk=G4,this.preloadRoute=e=>P3(this,e),this.matchRoute=(e,t)=>{let n={...e,to:e.to?this.resolvePathWithBase(e.from||``,e.to):void 0,params:e.params||{},leaveParams:!0},r=this.buildLocation(n),i=this.stores.status.get()===`pending`;if(t?.pending&&!i)return!1;let a=t?.pending??!i?this.latestLocation:this.stores.resolvedLocation.get()||this.stores.location.get(),o=y2(r.pathname,t?.caseSensitive??!1,t?.fuzzy??!1,a.pathname,this.processedTree);return!o||e.params&&!Q0(o.rawParams,e.params,{partial:!0})?!1:t?.includeSearch??!0?Q0(a.search,r.search,{partial:!0})?o.rawParams:!1:o.rawParams},this.getStoreConfig=t,this.update({defaultPreloadDelay:50,defaultPendingMs:1e3,defaultPendingMinMs:500,context:void 0,...e,caseSensitive:e.caseSensitive??!1,notFoundMode:e.notFoundMode??`fuzzy`,stringifySearch:e.stringifySearch??u4,parseSearch:e.parseSearch??l4,protocolAllowlist:e.protocolAllowlist??n2}),self.__TSR_ROUTER__=this}isShell(){return!!this.options.isShell}get state(){return this.stores.__store.get()}setRoutes({routesById:e,routesByPath:t,processedTree:n}){this.routesById=e,this.routesByPath=t,this.processedTree=n;let r=this.options.notFoundRoute;r&&(r.init({originalIndex:99999999999}),this.routesById[r.id]=r)}getRouteBranch(e){let t=this.routeBranchCache.get(e);return t||(t=T2(e),this.routeBranchCache.set(e,t)),t}matchRoutesInternal(e,t){let[n,r,i]=this.getMatchedRoutes(e.pathname),a=n,o=!1;(i?i.path!==`/`&&r[`**`]:F2(e.pathname))&&(this.options.notFoundRoute?a=[...a,this.options.notFoundRoute]:o=!0);let s=o?B4(this.options.notFoundMode,a):void 0,c=Array(a.length),l=this._committed,u=(e,t)=>{let n=l[t];return n?.routeId===e.id?n:e===this.options.notFoundRoute?l.find(t=>t.routeId===e.id):void 0},d;for(let n=0;n<a.length;n++){let i=a[n],o=c[n-1],l,f,p;{let n=o?.search??e.search,r=o?._strictSearch??void 0;try{let e=R4(i.options.validateSearch,{...n})??void 0;l={...n,...e},f={...r,...e}}catch(e){let r=e;if(e instanceof I4||(r=new I4(e.message,{cause:e})),t?.throwOnError)throw r;l=n,f={},p=r}}let m=``,h=``;try{m=i.options.loaderDeps?.({search:l})??``,h=m&&JSON.stringify(m)||``}catch(e){if(t?.throwOnError)throw e;p??=e}let{interpolatedPath:g,usedParams:_}=H2({path:i.fullPath,params:r,decoder:this.pathParamsDecoder,server:this.isServer}),v=i.id+g+h,y=u(i,n),b=this._cache.get(v)??(y?.id===v?y:void 0);d=b?._strictParams??Object.assign(_,d);let x;if(!b)try{H4(i,d)}catch(e){if(x=W2(e)||h4(e)?e:new L4(e.message,{cause:e}),t?.throwOnError)throw x}let S=y?`stay`:`enter`,C;if(b)C={...b,cause:S,search:K0(y?y.search:b.search,l),_strictSearch:f,searchError:p};else{let e=j4(i)?`pending`:`success`;C={id:v,ssr:i.options.ssr,index:n,routeId:i.id,params:y?.params??d,_strictParams:d,pathname:g,updatedAt:Date.now(),search:y?K0(y.search,l):l,_strictSearch:f,searchError:p,status:e,isFetching:!1,error:void 0,paramsError:x,context:{},abortController:t?._controller??new AbortController,cause:S,loaderDeps:y?q0(y.loaderDeps,m):m,invalid:!1,preload:!1,staticData:i.options.staticData||{},fullPath:i.fullPath}}let w=s===i.id;C._notFound&&!w&&(C.error=void 0),C._notFound=w,c[n]=C}for(let e=0;e<c.length;e++){let n=c[e];n.params=n.cause===`stay`?K0(n.params,d):d,t?._controller&&(n.context={})}return c}matchRoutesLightweight(e){let t=z0(this.stores.ids.get()),n=t?this.stores.byRoute.get(t).get():void 0,r=n?.id,i=this.lightweightCache.get(e);if(i&&i[0]===r)return i[1];let[a,o]=this.getMatchedRoutes(e.pathname),s=z0(a),c={...e.search};for(let e of a)try{Object.assign(c,R4(e.options.validateSearch,c))}catch{}let l=n&&n.routeId===s.id&&n.pathname===e.pathname,u;if(l)u=n.params;else{let e=Object.assign(Object.create(null),o);for(let t of a)try{H4(t,e)}catch{}u=e}let d=[a,s.fullPath,c,u];return this.lightweightCache.set(e,[r,d]),d}},I4=class extends Error{},L4=class extends Error{};function R4(e,t){if(e==null)return{};if(`~standard`in e){let n=e[`~standard`].validate(t);if(n instanceof Promise)throw new I4(`Async validation not supported`);if(n.issues)throw new I4(JSON.stringify(n.issues,void 0,2),{cause:n});return n.value}return`parse`in e?e.parse(t):typeof e==`function`?e(t):{}}function z4(e,t,n,r){let i=[];for(let e of n){let t=e.options;`search`in t?t.search?.middlewares&&i.push(...t.search.middlewares):(t.preSearchFilters||t.postSearchFilters)&&i.push(({search:e,next:n})=>{let r=n(t.preSearchFilters?t.preSearchFilters.reduce((e,t)=>t(e),e):e);return t.postSearchFilters?t.postSearchFilters.reduce((e,t)=>t(e),r):r});let n=t.validateSearch;n&&i.push(({search:e,next:t,meta:i})=>{let a=t(e);if(r)try{let e=R4(n,a);if(i&&e)for(let t in e)t in a||(i.defaulted||=new Map).set(t,e[t]);return{...a,...e}}catch{}return a})}let a=(e,n,r)=>{if(e>=i.length){if(!t.search)return{};if(t.search===!0)return n;let e=V0(t.search,n);return r&&(r.explicit=e),e}return i[e]({search:n,next:(t,n)=>{if(n){let n=r||{};return{search:a(e+1,t,n),meta:n}}return a(e+1,t,r)},meta:r})};return a(0,e)}function B4(e,t){if(e!==`root`){let e;for(let n=t.length-1;n>=0;n--){let r=t[n];if(r.options.notFoundComponent)return r.id;e||=r.children&&r.id}if(e)return e}return p4}function V4(e,t){return e===!1||e===null?Object.create(null):(e??!0)===!0?t:Object.assign(t,V0(e,t))}function H4(e,t){let n=e.options.params?.parse??e.options.parseParams;n&&Object.assign(t,n(t))}function U4(e,t){return e.options[t]?.preload?.()}function W4(e,t){let n=U4(e,`component`),r=U4(e,`pendingComponent`),i=t&&r?r.then(t):r;return t&&!r&&t(),n&&i?Promise.all([n,i]).then(()=>{}):n??i}function G4(e,t,n){let r=()=>t===!1?void 0:t?U4(e,t):W4(e,n),i=e._lazy;if(i)return i===!0?r():i.then(r);if(!e.lazyFn)return r();let a=e.lazyFn().then(t=>{{let{id:n,...r}=t.options;Object.assign(e.options,r),e._lazy=!0}},t=>{throw e._lazy=void 0,t});return e._lazy=a,a.then(r)}function K4(e){let t=e.findIndex(e=>e.status!==`success`||e._notFound)+1;return t&&t<e.length?e.slice(0,t):e}var q4=0,J4=1,Y4=2,X4=3,Z4=4;function Q4(e){return typeof e[0]==`number`}function $4(e,t){return t.aborted?Promise.race([Promise.reject(t),e]):new Promise((n,r)=>{let i=()=>r(t);t.addEventListener(`abort`,i,{once:!0}),Promise.resolve(e).then(n,r).finally(()=>t.removeEventListener(`abort`,i))})}function e3(e,t){return e.routesById[t.routeId]}function t3(e,t,n){return h4(e)?[X4,e]:W2(e)?(e.routeId||=n,[Y4,e]):(t&&typeof e?.then==`function`&&(e=Error(`A Promise was thrown`,{cause:e})),t?[J4,e]:[q4,e])}function n3(e,t){let n=t3(t,!0,e.id);if(n[0]!==J4)return n;try{e.options.onError?.(n[1])}catch(t){n=t3(t,!0,e.id)}return n}function r3(e,t,n){return n[0].signal.aborted||!n[2]()?(n[0].abort(),[Z4]):n3(e,t)}function i3(e,t){return n=>e.navigate({...n,_fromLocation:t})}async function a3(e,t,n,r,i,a){let[o,s]=t,c=n[0].signal,l=!!n[4];for(let t=n[7]??0;t<r;t++){let r=s[t],i=e3(e,r);r.abortController=n[0];let u=s[t-1]?.context??e.options.context??{},d={params:r.params,location:o,navigate:i3(e,o),buildLocation:e.buildLocation,cause:l?`preload`:r.cause,abortController:n[0],preload:l,matches:s,routeId:i.id},f=u;try{let e=r._ctx;!e&&i.options.context&&(e=r._ctx=i.options.context({...d,deps:r.loaderDeps,context:u})||{}),f={...u,...e},r.context=f}catch(a){return s3(e,r),[t,r3(i,a,n)]}if(c.aborted||!n[2]())return n[0].abort(),[t,[Z4]];let p=r.paramsError??r.searchError;if(p!==void 0)return s3(e,r),[t,r3(i,p,n)];let m=i.options.beforeLoad;if(!m)continue;let h={...d,search:r.search,context:f,...e.options.additionalContext},g=r.status;g===`success`&&t>=a&&(r.status=`pending`),n[8]?.();try{u3(e,r,`beforeLoad`,n[0]);let a=await $4(m(h),c);if(!n[2]())return n[0].abort(),[t,[Z4]];let o=t3(a,!1,i.id);if(o[0]!==q4)return s3(e,r),[t,o];r.context={...f,...a}}catch(a){return s3(e,r),[t,r3(i,a,n)]}finally{g===`success`&&r.status===`pending`&&(r.status=`success`),u3(e,r,!1,n[0])}}i()}function o3(e,t,n){if(!(!n||--n[2])){if(e._flights?.get(t.id)===n){let n=e._tx;if(n&&!n[0].signal.aborted&&!n[3].includes(t)&&n[3].some(e=>e.id===t.id)&&n[3].some(e=>e.isFetching===`beforeLoad`))return;e._flights.delete(t.id)}return n[1]}}function s3(e,t){let n=t._flight;t._flight=void 0,o3(e,t,n)?.abort()}function c3(e,t,n,r){let i=[];for(let a of t)if(!n?.includes(a)){let t=a._flight;if(a._flight=void 0,r&&t?.[2]===1&&e._flights?.get(a.id)===t&&n?.some(e=>e.id===a.id))t[2]=0;else{let n=o3(e,a,t);n&&i.push(n)}}for(let e of i)e.abort()}function l3(e){for(let t of e){let e=t._flight;e&&e[2]++}}function u3(e,t,n,r){if(t.isFetching=n,r&&e._tx?.[0]!==r)return;let i=e.stores.byRoute.get(t.routeId),a=i?.get();a?.id===t.id&&i.set({...a,isFetching:n})}function d3(e,t,n,r,i,a,o){let s=t[0];return{params:n.params,location:s,navigate:i3(e,s),cause:o?`preload`:n.cause,abortController:i,preload:o,deps:n.loaderDeps,parentMatchPromise:a,context:n.context,route:r,...e.options.additionalContext}}async function f3(e,t,n,r,i,a,o,s){let c=s.signal;if(c.aborted)return[Z4];if(!i)return[q4,void 0];let l=n._flight;u3(e,n,`loader`,s);try{if(!l){let s=new AbortController;l=[Promise.resolve().then(()=>i(d3(e,t,n,r,s,a,o))).then(e=>t3(e,!1,r.id),e=>t3(e,!0,r.id)).then(t=>(t[0]!==q4&&e._flights?.get(n.id)===l&&(e._flights.delete(n.id),l[2]||s.abort()),t[0]===J4&&l[2]?n3(r,t[1]):t)),s,1],(e._flights??=new Map).set(n.id,l)}return n._flight=l,n.abortController=l[1],await $4(l[0],c)}catch(t){if(t!==c)throw t;return s3(e,n),[Z4]}finally{u3(e,n,!1,s)}}function p3(e,t,n){t[0]===q4?(e.loaderData=t[1],e.error=void 0,e.status=`success`,e.invalid=!1,e.updatedAt=Date.now(),e.preload=n):t[0]!==X4&&(e.status=`success`,e.error=void 0,e.invalid=!0)}function m3(e,t,n){let r=e._cache.get(t.id);if(r!==n||e._committed.some(e=>e.id===t.id&&e._flight===t._flight))return;let i={...t,_notFound:void 0,context:{}};i._flight&&i._flight[2]++,e._cache.set(t.id,i),r&&s3(e,r)}function h3(e,t){return t[0]===J4||t[0]===Y4?{...e,status:t[0]===J4?`error`:`notFound`,error:t[1],_flight:void 0}:e}function g3(e,t,n,r,i,a,o){let s=t[1][n],c=e3(e,s),l=!!a[4],u=e._cache.get(s.id),d,f=!1,p;try{if(s.status===`success`&&(d=c.options.shouldReload,typeof d==`function`&&(d=d(d3(e,t,s,c,a[0],i,l))),a[2]()||(a[0].abort(),p=[Z4])),!p){if(s.status!==`success`)f=!0;else{let t=a[4]||s.preload?c.options.preloadStaleTime??e.options.defaultPreloadStaleTime??3e4:c.options.staleTime??e.options.defaultStaleTime??0;f=!!(s.invalid||d||d===void 0&&Date.now()-s.updatedAt>=t&&(a[6]||s.cause===`enter`||a[3].some(e=>e.routeId===s.routeId&&e.id!==s.id)))}}}catch(t){s.invalid=!0,s3(e,s),p=r3(c,t,a)}let m=c.options.loader,h=typeof m==`function`?m:m?.handler,g=(!l||c.options.preload!==!1)&&m?e._flights?.get(s.id):void 0;g===s._flight||p?g=void 0:g&&!f&&!l&&d===void 0?f=!0:f||(g=void 0);let _=!!(m&&f&&s.status===`success`&&!l&&!a[5]&&((typeof m==`function`?void 0:m?.staleReloadMode)??e.options.defaultStaleReloadMode)!==`blocking`),v=f&&(!l||c.options.preload!==!1),y=v&&!_&&(s.status!==`success`||!!m),b=c.lazyFn&&c._lazy!==!0?a[8]:void 0;if(v&&!m&&(s.invalid=!1,s.updatedAt=Date.now()),g&&g[2]++,y){let t=s._flight;s._flight=g,o3(e,s,t)?.abort(),s.status===`success`&&n>=o&&(s.status=`pending`),a[8]?.()}v||(s.isFetching=!1);let x=(p?Promise.resolve(p):y?f3(e,t,s,c,h,i,l,a[0]):Promise.resolve([q4,s.loaderData])).then(t=>(y&&(p3(s,t,l),t[0]===q4&&(m&&!a[0].signal.aborted&&m3(e,s,u),s.status=`pending`)),t)),S=$4(Promise.resolve().then(()=>G4(c,void 0,b)),a[0].signal).then(()=>void 0,e=>[n,r3(c,e,a)]).then(e=>x.then(t=>(y&&!e&&t[0]===q4&&s.status===`pending`&&a[2]()&&(s.status=`success`,a[8]?.()),e)));if(r.push([n,x,S]),!_)return x.then(e=>h3(s,e));let C={...s,status:`pending`,preload:!1,_flight:g};s.invalid=!1,s.isFetching=`loader`;let w=f3(e,t,C,c,h,i,!1,a[0]).then(e=>(s.isFetching=!1,p3(C,e,!1),e));return(t[2]??=[]).push([n,w,S,C]),w.then(e=>h3(C,e))}async function _3(e,t,n,r,i=0){let a=n?.[1][1],o=a?.routeId?t.findIndex(e=>e.routeId===a.routeId):n?.[0]??t.length-1;o<0&&(o=0);for(let n=o;n>=0;n--){let i=e3(e,t[n]),a=G4(i,!1);if(a)try{await $4(a,r)}catch(e){if(e===r)throw e}if(i.options.notFoundComponent)return n}return a?.routeId?o:i}function v3(e,t){t[2]&&=(c3(e,t[2].map(e=>e[3])),void 0)}async function y3(e,t,n,r){let i;try{await Promise.all(e.map(e=>e[1].then(async t=>{let a=e[0];if(!(r&&a>=await r)){if(t[0]>=X4)throw[a,t];!i&&t[0]!==q4&&(i=[a,t],await Promise.all((n??[]).map(e=>{if(!(e[0]<=a))return e[1].then(t=>{if(t[0]===X4)throw[e[0],t]})})))}})))}catch(e){return e}return t??i}async function b3(e,t,n,r,i,a,o){let s=t[1],c=await a,l=!1,u=s.findIndex(e=>e._notFound),d=t=>t[1][0]===Y4?_3(e,s,t,r.signal):t[0],f=u<0?s.length:u;if((c?.[1][0]??0)>=X4)f=0;else if(c){f=c[2]??=await d(c);for(let e of n){if(e[0]>=f)break;let t=await e[1];if(t[0]!==q4&&t[0]<X4&&!(`loaderData`in s[e[0]])){c=[e[0],t],f=c[2]=await d(c);break}}}for(let e of n){if(e[0]>=f)break;let t=await e[2];if(t){c=t;break}}if((c?.[1][0]??0)>=X4){let n=c[1];if(n[0]!==X4||n[1].options.reloadDocument||i<20)return v3(e,t),n;l=!0,c=[0,[J4,Error(`Too many redirects`)]]}let p=c?c[2]??await d(c):u;if(p>=0){let i=c?.[1],a=i?.[0],u=s[p],d=i?.[1],f=()=>{i&&(u._notFound=void 0,a===J4?u.status=`error`:(d.routeId=u.routeId,u.routeId===e.routeTree.id?(u.status=`success`,u._notFound=!0):u.status=`notFound`),u.error=d,u.isFetching=!1)};f();let m=e3(e,u);try{await $4(i?Promise.resolve().then(()=>G4(m,a===J4?`errorComponent`:`notFoundComponent`)):Promise.all([G4(m),G4(m,`notFoundComponent`)]),r.signal)}catch(n){if(n===r.signal)return v3(e,t),[Z4]}i?l&&(r.abort(),await Promise.all([...n.map(e=>e[1]),...n.map(e=>e[2]),...(t[2]??[]).map(e=>e[1])]),v3(e,t),c3(e,s),f()):(u.status=`success`,o?.())}return t}async function x3(e,t,n,r=0,i=t[1].length){let a=t[1];for(let t=r;t<i;t++){let r=a[t],i=e3(e,r).options;if(i.head||i.scripts)try{let t={ssr:e.options.ssr,matches:a,match:r,params:r.params,loaderData:r.loaderData},[o,s]=await $4(Promise.all([i.head?.(t),i.scripts?.(t)]),n);r.meta=o?.meta,r.links=o?.links,r.headScripts=o?.scripts,r.styles=o?.styles,r.scripts=s}catch(e){if(e===n)break;console.error(e)}if(r.status!==`success`||r._notFound)break}return t}async function S3(e,t,n,r){let i=[t,n],a=e.stores.matches.get(),o=n.findIndex(e=>e._notFound);if(e.options.notFoundMode!==`root`&&o>=0){let t=await _3(e,i[1],void 0,r[0].signal,o);t!==o&&(n[o]._notFound=void 0,n[t]._notFound=!0),o=t}let s=o<0?n.length:o+1,c=0;for(;c<s&&c!==o;){let e=n[c],t=r[3][c],i=a[c];if(t?.id!==e.id||t.status!==`success`||t._notFound||e.preload||i?.id!==e.id||i.status!==`success`||i._notFound)break;c++}let l=[],u=r[7]??0,d=u?Promise.resolve(i[1][u-1]):void 0,f=()=>{for(let t=u;t<s&&!r[0].signal.aborted;t++)d=g3(e,i,t,l,d,r,c)},p=await a3(e,i,r,s,f,c);if(p&&(r[5]=!0,s=p[0],p[1][0]===Y4?(p[2]=await _3(e,i[1],p,r[0].signal),s=Math.min(s,p[2]+1)):p[1][0]>=X4&&(s=0),f()),r[2]()&&!r[4]){let t=[];for(let[n,r]of e._flights??[])r[2]||(e._flights.delete(n),t.push(r[1]));for(let e of t)e.abort()}let m;try{let t=b3(e,i,l,r[0],r[1],y3(l,p,i[2]),r[8]);i[2]?.length&&(i[3]=y3(i[2],void 0,void 0,t.then(e=>Q4(e)?0:K4(e[1]).length,()=>0))),m=await t}catch(t){throw v3(e,i),t}return Q4(m)?m:x3(e,m,r[0].signal,r[7]===m[1].length?r[7]:0)}function C3(e,t){if(e._tx!==t)return;let n=e._pending,r=!1,i=n?.[0][3][n[1]]?.id;n?.[0]!==t&&(n&&t[3][n[1]]?.id===i?(n[0]=t,r=!0):(clearTimeout(n?.[3]),e._pending=n=void 0));let a=t[3],o=e.stores.matches.get(),s=-1,c,l,u,d=!1;for(let t=0;t<a.length;t++){let n=a[t],r=n.status===`success`;if(d=o[t]?.id===n.id&&o[t]?.status===`pending`,r&&!d)continue;let i=e3(e,n);if(c=r&&d||n.invalid?0:i.options.pendingMs??e.options.defaultPendingMs,u=i.options.pendingComponent??e.options.defaultPendingComponent,!u||typeof c!=`number`||c===1/0)return;s=t,l=i.options.pendingMinMs??e.options.defaultPendingMinMs??0;break}if(s<0)return;let f=a[s].id;if((!n||n[1]!==s||i!==f)&&(clearTimeout(n?.[3]),e._pending=n=[t,s,d?Date.now()+l:t[4]+c,void 0,d?Promise.resolve(!0):void 0,u]),n[4]&&!r&&n[5]===u)return;if(n[5]=u,!n[4]){clearTimeout(n[3]);let r=n[2]-Date.now();if(r>0){n[3]=setTimeout(()=>C3(e,t),r);return}n[2]=0}let p=a.map(e=>({...e,_flight:void 0}));p[s].status=`pending`;let m=e.startTransition(()=>e.stores.setMatches(p),p).then(t=>(t&&e._pending===n&&n[4]===m&&!n[2]&&(n[2]=Date.now()+l),t));n[4]=m}function w3(e,t){let n=e._pending;n?.[0]===t&&(clearTimeout(n[3]),e._pending=void 0)}function T3(e,t){e._committed=t,e.stores.setMatches(t)}function E3(e,t){c3(e,t[1]),v3(e,t)}function D3(e,t,n,r){let i=e._committed,a=e._cache;for(let e of n)e.preload=!1,r&&(e._assetEnd=void 0);let o=K4(n).length,s=new Map,c=Date.now();for(let t of[...i,...a.values()]){if(t.status!==`success`||n.some((e,n)=>e.id===t.id&&(n<o||e.status===`success`)))continue;let r=e3(e,t);!r.options.loader||c-t.updatedAt>=(t.preload?r.options.preloadGcTime??e.options.defaultPreloadGcTime??3e5:r.options.gcTime??e.options.defaultGcTime??3e5)||s.set(t.id,a.get(t.id)===t?t:{...t,_flight:void 0,isFetching:!1,context:{}})}t[3]=[],e._cache=s,T3(e,n),c3(e,[...a.values(),...i],[...n,...s.values()]),P4(e,i,n,()=>e._tx===t)}async function O3(e,t){let n=e._tx;for(;n&&n!==t;){if(await n[5],e._tx===n)return;n=e._tx}}async function k3(e,t,n){await e.navigate({...n.options,replace:!0,ignoreBlocker:!0,_redirects:t[1]+1})}function A3(e,t){w3(e,t),t[0].abort(),c3(e,t[3]),t[3]=[],e._tx===t&&(e.batch(()=>{e.stores.status.set(`idle`),e.stores.setMatches(e._committed)}),e._tx===t&&(e._commitPromise?.resolve(),e._commitPromise=void 0))}async function j3(e,t,n,r,i){let a=n.map(e=>({...e}));l3(a);for(let t of r)s3(e,a[t[0]]),a[t[0]]=t[3];let o=[t[2],a],s;try{s=await b3(e,o,r,t[0],t[1],i)}catch(t){throw c3(e,a),t}if(Q4(s)){c3(e,a),s[0]===X4&&e._tx===t&&e._committed===n&&await k3(e,t,s[1]);return}let c=await x3(e,s,t[0].signal);if(e._tx!==t||e._committed!==n){c3(e,c[1]);return}for(let t of c[1]){let n=e._cache.get(t.id);n?._flight&&n._flight===t._flight&&(e._cache.delete(t.id),s3(e,n))}T3(e,c[1]),c3(e,n,c[1])}async function M3(e,t,n,r,i,a){let o=[t[0],t[1],()=>e._tx===t&&!!t[3].length,e._committed,void 0,i,n,a,r],s=await S3(e,t[2],t[3],o);if(Q4(s)){s[0]===X4&&e._tx===t?(w3(e,t),c3(e,t[3]),t[3]=[],e._tx===t&&await k3(e,t,s[1])):A3(e,t);return}let c=e._pending;if(c?.[0]===t&&(clearTimeout(c[3]),c[4])){let n=t[0].signal,r=!1;try{r=await $4(c[4],n)}catch(e){if(e!==n)throw e}if(r&&e._pending===c&&c[0]===t){let e=c[2]-Date.now();if(e>0){try{await $4(new Promise(t=>{c[3]=setTimeout(t,e)}),n)}catch{}clearTimeout(c[3])}}}if(e._tx!==t){w3(e,t),E3(e,s);return}let l=t[2],u=M4(l,e.stores.resolvedLocation.get()),d=s[2];await e.startViewTransition(async()=>{if(e._tx!==t){E3(e,s);return}let n=await e.startTransition(()=>{w3(e,t),D3(e,t,s[1],a),e._tx===t&&(e.emit({type:`onLoad`,...u}),e._tx===t&&e.emit({type:`onBeforeRouteMount`,...u}))},s[1]);if(e._tx!==t){v3(e,s);return}d?.length&&j3(e,t,s[1],d,s[3]).catch(console.error),e.batch(()=>{e.stores.resolvedLocation.set(l),e.stores.status.set(`idle`),e._tx===t&&e.emit({type:`onResolved`,...u}),n&&e._tx===t&&e.emit({type:`onRendered`,...u})}),e._tx===t&&(e._commitPromise?.resolve(),e._commitPromise=void 0)})}async function N3(e,t){let n=e._tx,r=e.stores.resolvedLocation.get(),i=r??e.stores.location.get(),a=e.latestLocation,o=e._pendingLocation,s=o?.href===a.href?o._redirects??0:0,c=e._handoff,l=c?.[0](),u=new AbortController,d=e._preflight;if(e._preflight=u,l||c?.[1](),d?.abort(),u.signal.aborted){await O3(e,n);return}let f=M4(a,r);if(e.emit({type:`onBeforeNavigate`,...f}),u.signal.aborted||e.emit({type:`onBeforeLoad`,...f}),u.signal.aborted){await O3(e,n);return}let p=i.href===a.href,m,h=u;try{m=e.matchRoutes(a,{_controller:u}),l3(m)}catch(t){if(u.abort(),!h4(t)){await O3(e),e._commitPromise?.resolve(),e._commitPromise=void 0;return}await e.navigate({...t.options,replace:!0,ignoreBlocker:!0}),await O3(e,n);return}let g=l?c[1](m):void 0;if(g?h=l:l?.abort(),u.signal.aborted){c3(e,m),await O3(e,n);return}e._preflight=void 0;let _=[h,s,a,m,Date.now(),Promise.resolve().then(()=>M3(e,_,p,()=>C3(e,_),t?.sync,g)).catch(()=>{e._tx===_&&A3(e,_)})];if(e._tx=_,n){for(let t of e.stores.matches.get()){if(e._tx!==_)break;t.isFetching&&u3(e,t,!1)}n[0].abort(),c3(e,n[3],_[3],!0)}if(e._tx!==_){c3(e,_[3]),_[3]=[],await O3(e,_);return}e.batch(()=>{e.stores.status.set(`pending`),e.stores.location.set(a)}),!r&&!m.some(e=>e._notFound)&&C3(e,_);try{await _[5]}finally{await O3(e,_)}}async function P3(e,t,n=0){if(n>20)return;let r=t._builtLocation??e.buildLocation(t),i=e._committed,a=new AbortController,o;try{o=e.matchRoutes(r,{_controller:a}),l3(o)}catch(e){a.abort(),W2(e)||console.error(e);return}(e._preloads??=new Map).set(a,o);let s;try{let t;try{t=await S3(e,r,o,[a,n,()=>!0,i,!0])}finally{s=e._preloads.delete(a),c3(e,o),a.abort()}if(!Q4(t))return t[1];if(s&&t[0]===X4&&!t[1].options.reloadDocument)return P3(e,{...t[1].options,_fromLocation:r},n+1)}catch(e){W2(e)||console.error(e)}}var F3=`Error preloading route! ☝️`,I3=class{get to(){return this._to}get id(){return this._id}get path(){return this._path}get fullPath(){return this._fullPath}constructor(e){if(this.init=e=>{this.originalIndex=e.originalIndex;let t=this.options,n=!t?.path&&!t?.id;this.parentRoute=this.options.getParentRoute?.(),n?this._path=p4:this.parentRoute||s2();let r=n?p4:t?.path;r&&r!==`/`&&(r=P2(r));let i=t?.id||r,a=n?p4:M2([this.parentRoute.id===`__root__`?``:this.parentRoute.id,i]);r===`__root__`&&(r=`/`),a!==`__root__`&&(a=M2([`/`,a]));let o=a===`__root__`?`/`:M2([this.parentRoute.fullPath,r]);this._path=r,this._id=a,this._fullPath=o,this._to=F2(o)},this.addChildren=e=>this._addFileChildren(e),this._addFileChildren=e=>(Array.isArray(e)&&(this.children=e),typeof e==`object`&&e&&(this.children=Object.values(e)),this),this._addFileTypes=()=>this,this.updateLoader=e=>(Object.assign(this.options,e),this),this.update=e=>(Object.assign(this.options,e),this),this.lazy=e=>(this.lazyFn=e,this),this.redirect=e=>m4({from:this.fullPath,...e}),this.options=e||{},this.isRoot=!e?.getParentRoute,e?.id&&e?.path)throw Error(`Route cannot have both an 'id' and a 'path' option.`)}},L3=class extends I3{constructor(e){super(e)}};function R3(e){return(0,X.jsx)(z3,{...e})}var z3=class extends J.Component{constructor(...e){super(...e),this.state={error:null},this.reset=()=>{this.setState({error:null})}}static getDerivedStateFromProps(e,t){let n=e.getResetKey();return t.error&&t.resetKey!==n?{resetKey:n,error:null}:{resetKey:n}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){this.props.onCatch?.(e,t)}render(){let e=this.state.error;return e?J.createElement(this.props.errorComponent??B3,{error:e,reset:this.reset}):this.props.children}};function B3({error:e}){let[t,n]=J.useState(!1);return(0,X.jsxs)(`div`,{style:{padding:`.5rem`,maxWidth:`100%`},children:[(0,X.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`.5rem`},children:[(0,X.jsx)(`strong`,{style:{fontSize:`1rem`},children:`Something went wrong!`}),(0,X.jsx)(`button`,{style:{appearance:`none`,fontSize:`.6em`,border:`1px solid currentColor`,padding:`.1rem .2rem`,fontWeight:`bold`,borderRadius:`.25rem`},onClick:()=>n(e=>!e),children:t?`Hide Error`:`Show Error`})]}),(0,X.jsx)(`div`,{style:{height:`.25rem`}}),t?(0,X.jsx)(`div`,{children:(0,X.jsx)(`pre`,{style:{fontSize:`.7em`,border:`1px solid red`,borderRadius:`.25rem`,padding:`.3rem`,color:`red`,overflow:`auto`},children:e.message?(0,X.jsx)(`code`,{children:e.message}):null})}):null]})}function V3({children:e,fallback:t=null}){return(0,X.jsx)(J.Fragment,{children:H3()?e:t})}function H3(){return J.useSyncExternalStore(U3,()=>!0,()=>!1)}function U3(){return()=>{}}var W3=J.createContext(null);function G3(e){return J.useContext(W3)}var K3=J.createContext(void 0),q3=J.createContext(void 0),J3=(e=>(e[e.None=0]=`None`,e[e.Mutable=1]=`Mutable`,e[e.Watching=2]=`Watching`,e[e.RecursedCheck=4]=`RecursedCheck`,e[e.Recursed=8]=`Recursed`,e[e.Dirty=16]=`Dirty`,e[e.Pending=32]=`Pending`,e))(J3||{});function Y3({update:e,notify:t,unwatched:n}){return{link:r,unlink:i,propagate:a,checkDirty:o,shallowPropagate:s};function r(e,t,n){let r=t.depsTail;if(r!==void 0&&r.dep===e)return;let i=r===void 0?t.deps:r.nextDep;if(i!==void 0&&i.dep===e){i.version=n,t.depsTail=i;return}let a=e.subsTail;if(a!==void 0&&a.version===n&&a.sub===t)return;let o=t.depsTail=e.subsTail={version:n,dep:e,sub:t,prevDep:r,nextDep:i,prevSub:a,nextSub:void 0};i!==void 0&&(i.prevDep=o),r===void 0?t.deps=o:r.nextDep=o,a===void 0?e.subs=o:a.nextSub=o}function i(e,t=e.sub){let r=e.dep,i=e.prevDep,a=e.nextDep,o=e.nextSub,s=e.prevSub;return a===void 0?t.depsTail=i:a.prevDep=i,i===void 0?t.deps=a:i.nextDep=a,o===void 0?r.subsTail=s:o.prevSub=s,s===void 0?(r.subs=o)===void 0&&n(r):s.nextSub=o,a}function a(e){let n=e.nextSub,r;top:do{let i=e.sub,a=i.flags;if(a&60?a&12?a&4?!(a&48)&&c(e,i)?(i.flags=a|40,a&=1):a=0:i.flags=a&-9|32:a=0:i.flags=a|32,a&2&&t(i),a&1){let t=i.subs;if(t!==void 0){let i=(e=t).nextSub;i!==void 0&&(r={value:n,prev:r},n=i);continue}}if((e=n)!==void 0){n=e.nextSub;continue}for(;r!==void 0;)if(e=r.value,r=r.prev,e!==void 0){n=e.nextSub;continue top}break}while(!0)}function o(t,n){let r,i=0,a=!1;top:do{let o=t.dep,c=o.flags;if(n.flags&16)a=!0;else if((c&17)==17){if(e(o)){let e=o.subs;e.nextSub!==void 0&&s(e),a=!0}}else if((c&33)==33){(t.nextSub!==void 0||t.prevSub!==void 0)&&(r={value:t,prev:r}),t=o.deps,n=o,++i;continue}if(!a){let e=t.nextDep;if(e!==void 0){t=e;continue}}for(;i--;){let i=n.subs,o=i.nextSub!==void 0;if(o?(t=r.value,r=r.prev):t=i,a){if(e(n)){o&&s(i),n=t.sub;continue}a=!1}else n.flags&=-33;n=t.sub;let c=t.nextDep;if(c!==void 0){t=c;continue top}}return a}while(!0)}function s(e){do{let n=e.sub,r=n.flags;(r&48)==32&&(n.flags=r|16,(r&6)==2&&t(n))}while((e=e.nextSub)!==void 0)}function c(e,t){let n=t.depsTail;for(;n!==void 0;){if(n===e)return!0;n=n.prevDep}return!1}}function X3(e,t,n){let r=typeof e==`object`,i=r?e:void 0;return{next:(r?e.next:e)?.bind(i),error:(r?e.error:t)?.bind(i),complete:(r?e.complete:n)?.bind(i)}}var Z3=[],Q3=0,{link:$3,unlink:e6,propagate:t6,checkDirty:n6,shallowPropagate:r6}=Y3({update(e){return e._update()},notify(e){Z3[a6++]=e,e.flags&=~J3.Watching},unwatched(e){e.depsTail!==void 0&&(e.depsTail=void 0,e.flags=J3.Mutable|J3.Dirty,l6(e))}}),i6=0,a6=0,o6,s6=0;function c6(e){try{++s6,e()}finally{--s6||u6()}}function l6(e){let t=e.depsTail,n=t===void 0?e.deps:t.nextDep;for(;n!==void 0;)n=e6(n,e)}function u6(){if(!(s6>0)){for(;i6<a6;){let e=Z3[i6];Z3[i6++]=void 0,e.notify()}i6=0,a6=0}}function d6(e,t){let n=typeof e==`function`,r=e,i={_snapshot:n?void 0:e,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:n?J3.None:J3.Mutable,get(){return o6!==void 0&&$3(i,o6,Q3),i._snapshot},subscribe(e){let t=X3(e),n={current:!1},r=f6(()=>{i.get(),n.current?t.next?.(i._snapshot):n.current=!0});return{unsubscribe:()=>{r.stop()}}},_update(e){let a=o6,o=t?.compare??Object.is;if(n)o6=i,++Q3,i.depsTail=void 0;else if(e===void 0)return!1;n&&(i.flags=J3.Mutable|J3.RecursedCheck);try{let t=i._snapshot,a=typeof e==`function`?e(t):e===void 0&&n?r(t):e;return t===void 0||!o(t,a)?(i._snapshot=a,!0):!1}finally{o6=a,n&&(i.flags&=~J3.RecursedCheck),l6(i)}}};return n?(i.flags=J3.Mutable|J3.Dirty,i.get=function(){let e=i.flags;if(e&J3.Dirty||e&J3.Pending&&n6(i.deps,i)){if(i._update()){let e=i.subs;e!==void 0&&r6(e)}}else e&J3.Pending&&(i.flags=e&~J3.Pending);return o6!==void 0&&$3(i,o6,Q3),i._snapshot}):i.set=function(e){if(i._update(e)){let e=i.subs;e!==void 0&&(t6(e),r6(e),u6())}},i}function f6(e){let t=()=>{let t=o6;o6=n,++Q3,n.depsTail=void 0,n.flags=J3.Watching|J3.RecursedCheck;try{return e()}finally{o6=t,n.flags&=~J3.RecursedCheck,l6(n)}},n={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:J3.Watching|J3.RecursedCheck,notify(){let e=this.flags;e&J3.Dirty||e&J3.Pending&&n6(this.deps,this)?t():this.flags=J3.Watching},stop(){this.flags=J3.None,this.depsTail=void 0,l6(this)}};return t(),n}var p6=t((e=>{var t=mr();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,a=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue;function c(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),c=r[0].inst,u=r[1];return o(function(){c.value=n,c.getSnapshot=t,l(c)&&u({inst:c})},[e,n,t]),a(function(){return l(c)&&u({inst:c}),e(function(){l(c)&&u({inst:c})})},[e]),s(n),n}function l(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function u(e,t){return t()}var d=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?u:c;e.useSyncExternalStore=t.useSyncExternalStore===void 0?d:t.useSyncExternalStore})),m6=t(((e,t)=>{t.exports=p6()})),h6=t((e=>{var t=mr(),n=m6();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p}})),g6=t(((e,t)=>{t.exports=h6()}))();function _6(e,t){return e===t}function v6(e,t,n=_6){let r=(0,J.useCallback)(t=>{if(!e)return()=>{};let{unsubscribe:n}=e.subscribe(t);return n},[e]),i=(0,J.useCallback)(()=>e?.get(),[e]);return(0,g6.useSyncExternalStoreWithSelector)(r,i,i,t,n)}var y6={};function b6(e,t){let n=J.useRef();return r=>{let i=e?.select?e.select(r):r;return e?.structuralSharing??t.options.defaultStructuralSharing?n.current=q0(n.current,i):i}}function x6(e){let t=G3(),n=J.useContext(e.from?q3:K3),r=e.from??n,i=t.stores.getMatchStore(r),a=b6(e,t),o=v6(i,e=>e?a(e):y6);if(o!==y6)return o;(e.shouldThrow??!0)&&s2()}function S6(e){return x6({from:e.from,strict:e.strict,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.loaderData):t.loaderData})}function C6(e){let{select:t,...n}=e;return x6({...n,select:e=>t?t(e.loaderDeps):e.loaderDeps})}function w6(e){return x6({from:e.from,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,strict:e.strict,select:t=>{let n=e.strict===!1?t.params:t._strictParams;return e.select?e.select(n):n}})}function T6(e){return x6({from:e.from,strict:e.strict,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.search):t.search})}function E6(e){let t=G3();return J.useCallback(n=>t.navigate({...n,from:n.from??e?.from}),[e?.from,t])}function D6(e){return x6({...e,select:t=>e.select?e.select(t.context):t.context})}function O6(e){let t=J.useRef(e);return Q0(t.current,e,{ignoreUndefined:!1})||(t.current=e),t.current}function k6(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function A6(e,t,n){if(e?.external)return r2(e.href,n)?void 0:e.href;if(!V6(t)&&typeof t==`string`&&t.indexOf(`:`)!==-1)try{return new URL(t),r2(t,n)?void 0:t}catch{}}function j6(e,t,n,r,i,a){if(a)return!1;if(n?.exact){if(!R2(e.pathname,t.pathname,r))return!1}else{let n=L2(e.pathname,r),i=L2(t.pathname,r);if(!(n.startsWith(i)&&(n.length===i.length||n[i.length]===`/`)))return!1}return(n?.includeSearch??!0)&&!Q0(e.search,t.search,{partial:!n?.exact,ignoreUndefined:!n?.explicitUndefined})?!1:!n?.includeHash||i&&e.hash===t.hash}function M6(e,t){let n=G3(),r=R0(t),{activeProps:i,inactiveProps:a,activeOptions:o,to:s,preload:c,preloadDelay:l,preloadIntentProximity:u,hashScrollIntoView:d,replace:f,startTransition:p,resetScroll:m,viewTransition:h,children:g,target:_,disabled:v,style:y,className:b,onClick:x,onBlur:S,onFocus:C,onMouseEnter:w,onMouseLeave:T,onTouchStart:E,ignoreBlocker:D,params:O,search:k,hash:A,state:j,mask:M,reloadDocument:N,unsafeRelative:P,from:F,_fromLocation:I,...L}=e,ee=H3(),te=O6(e.search),ne=O6(e.params),re=O6(o),R=J.useMemo(()=>e,[n,e.from,e._fromLocation,e.hash,e.to,te,ne,e.state,e.mask,e.unsafeRelative]),ie=J.useCallback(e=>{let t=n.buildLocation({_fromLocation:e,...R}),r=B6(t.maskedLocation?t.maskedLocation.publicHref:t.publicHref,t.maskedLocation?t.maskedLocation.external:t.external,n.history,v),i=A6(r,s,n.protocolAllowlist);return[r?.href,i,j6(e,t,re,n.basepath,ee,i!==void 0)]},[re,v,ee,R,n,s]),[ae,z,oe]=v6(n.stores.location,ie,k6),se=oe?V0(i,{})??P6:N6,ce=oe?N6:V0(a,{})??N6,le=[b,se.className,ce.className].filter(Boolean).join(` `),ue=(y||se.style||ce.style)&&{...y,...se.style,...ce.style},de=J.useRef(!1),fe=e.reloadDocument||z||v?!1:c??n.options.defaultPreload,pe=l??n.options.defaultPreloadDelay??0,me=J.useCallback(()=>{n.preloadRoute(R).catch(e=>{console.warn(e),console.warn(F3)})},[n,R]),he=J.useCallback(e=>{if(!e){R6(r);return}if(!(e.isIntersecting??fe===`intent`)){e.isIntersecting===!1&&R6(r);return}if(!pe){me();return}L6.has(r)||L6.set(r,setTimeout(()=>{L6.delete(r),me()},pe))},[me,r,fe,pe]);L0(r,he,fe!==`viewport`),J.useEffect(()=>{de.current||fe===`render`&&(me(),de.current=!0)},[me,fe]);let ge=e=>{let t=e.currentTarget.getAttribute(`target`),r=_===void 0?t:_;!v&&!U6(e)&&!e.defaultPrevented&&(!r||r===`_self`)&&e.button===0&&(e.preventDefault(),n.navigate({...R,replace:f,resetScroll:m,hashScrollIntoView:d,startTransition:p,viewTransition:h,ignoreBlocker:D}))};if(z)return{...L,ref:r,href:z,...g&&{children:g},..._&&{target:_},...v&&{disabled:v},...y&&{style:y},...b&&{className:b},...x&&{onClick:x},...S&&{onBlur:S},...C&&{onFocus:C},...w&&{onMouseEnter:w},...T&&{onMouseLeave:T},...E&&{onTouchStart:E}};let _e=()=>{fe===`intent`&&me()},ve=()=>{fe===`intent`&&R6(r)};return{...L,...se,...ce,href:ae,ref:r,onClick:z6([x,ge]),onBlur:z6([S,ve]),onFocus:z6([C,he]),onMouseEnter:z6([w,he]),onMouseLeave:z6([T,ve]),onTouchStart:z6([E,_e]),disabled:!!v,target:_,...ue&&{style:ue},...le&&{className:le},...v&&F6,...oe&&I6}}var N6={},P6={className:`active`},F6={role:`link`,"aria-disabled":!0},I6={"data-status":`active`,"aria-current":`page`},L6=new WeakMap,R6=e=>{clearTimeout(L6.get(e)),L6.delete(e)},z6=e=>t=>{for(let n of e)if(n){if(t.defaultPrevented)return;n(t)}};function B6(e,t,n,r){if(!r)return t?{href:e,external:!0}:{href:n.createHref(e)||`/`,external:!1}}function V6(e){if(typeof e!=`string`)return!1;let t=e.charCodeAt(0);return t===47?e.charCodeAt(1)!==47:t===46}var H6=J.forwardRef((e,t)=>{let{_asChild:n,...r}=e,{type:i,...a}=M6(r,t),o=typeof r.children==`function`?r.children({isActive:a[`data-status`]===`active`}):r.children;if(!n){let{disabled:e,...t}=a;return J.createElement(`a`,t,o)}return J.createElement(n,a,o)});function U6(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}var W6=class extends I3{constructor(e){super(e),this.useMatch=e=>x6({select:e?.select,from:this.id,structuralSharing:e?.structuralSharing}),this.useRouteContext=e=>D6({...e,from:this.id}),this.useSearch=e=>T6({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useParams=e=>w6({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useLoaderDeps=e=>C6({...e,from:this.id}),this.useLoaderData=e=>S6({...e,from:this.id}),this.useNavigate=()=>E6({from:this.fullPath}),this.Link=J.forwardRef((e,t)=>(0,X.jsx)(H6,{ref:t,from:this.fullPath,...e}))}};function G6(e){return new W6(e)}var K6=class extends L3{constructor(e){super(e),this.useMatch=e=>x6({select:e?.select,from:this.id,structuralSharing:e?.structuralSharing}),this.useRouteContext=e=>D6({...e,from:this.id}),this.useSearch=e=>T6({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useParams=e=>w6({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useLoaderDeps=e=>C6({...e,from:this.id}),this.useLoaderData=e=>S6({...e,from:this.id}),this.useNavigate=()=>E6({from:this.fullPath}),this.Link=J.forwardRef((e,t)=>(0,X.jsx)(H6,{ref:t,from:this.fullPath,...e}))}};function q6(e){return new K6(e)}function J6(e){let t=G3(),n=`not-found-${v6(t.stores.location,e=>e.pathname)}-${v6(t.stores.status,e=>e)}`;return(0,X.jsx)(R3,{getResetKey:()=>n,onCatch:(t,n)=>{if(W2(t))e.onCatch?.(t,n);else throw t},errorComponent:({error:t})=>{if(W2(t))return e.fallback?.(t);throw t},children:e.children})}function Y6(){return(0,X.jsx)(`p`,{children:`Not Found`})}function X6(e){return(0,X.jsx)(X.Fragment,{children:e.children})}function Z6(e,t,n){return t.options.notFoundComponent?(0,X.jsx)(t.options.notFoundComponent,{...n}):e.options.defaultNotFoundComponent?(0,X.jsx)(e.options.defaultNotFoundComponent,{...n}):(0,X.jsx)(Y6,{})}function Q6(e,t){let n=t?.options.pendingComponent??e.options.defaultPendingComponent;return n?(0,X.jsx)(n,{}):null}var $6=(e,t)=>e[0]===t[0]&&e[1]===t[1],e8=(e,t,n)=>!t.isRoot||t.options.shellComponent||t.options.wrapInSuspense||n===!1||n===`data-only`||!e.ssr,t8=J.memo(function({routeId:e}){let t=G3();return(0,X.jsx)(n8,{router:t,match:v6(t.stores.getMatchStore(e),e=>e)})});function n8({router:e,match:t}){let n=e.routesById[t.routeId],r=Q6(e,n),i=n.options.errorComponent??e.options.defaultErrorComponent,a=n.options.onCatch??e.options.defaultOnCatch,o=n.isRoot?n.options.notFoundComponent??e.options.notFoundRoute?.options.component:n.options.notFoundComponent,s=t.ssr===!1||t.ssr===`data-only`,c=e8(e,n,t.ssr)&&(n.options.wrapInSuspense??r??(n.options.errorComponent?.preload||s))?J.Suspense:X6,l=i?R3:X6,u=o?J6:X6;return(0,X.jsxs)(n.isRoot?n.options.shellComponent??X6:X6,{children:[(0,X.jsx)(K3.Provider,{value:t.routeId,children:(0,X.jsx)(c,{fallback:r,children:(0,X.jsx)(l,{getResetKey:()=>t,errorComponent:i,onCatch:(e,n)=>{if(W2(e))throw e.routeId??=t.routeId,e;a?.(e,n)},children:(0,X.jsx)(u,{fallback:e=>{if(e.routeId??=t.routeId,e.routeId!==t.routeId)throw e;return J.createElement(o,e)},children:s?(0,X.jsx)(V3,{fallback:r,children:(0,X.jsx)(r8,{match:t})}):(0,X.jsx)(r8,{match:t})})})})}),null]})}var r8=J.memo(function({match:e}){let t=G3(),n=e.routeId,r=t.routesById[n],i=J.useMemo(()=>{let i=(r.options.remountDeps??t.options.defaultRemountDeps)?.({routeId:n,loaderDeps:e.loaderDeps,params:e._strictParams,search:e._strictSearch});return i?JSON.stringify(i):void 0},[n,e.loaderDeps,e._strictParams,e._strictSearch,r.options.remountDeps,t.options.defaultRemountDeps]),a=J.useMemo(()=>{let e=r.options.component??t.options.defaultComponent;return e?(0,X.jsx)(e,{},i):(0,X.jsx)(i8,{})},[i,r.options.component,t.options.defaultComponent]);if(e.status===`pending`){if(t.ssr&&!e8(t,r,e.ssr))return a;if(t._tx)throw t._tx[5];return Q6(t,r)}if(e.status===`notFound`)return Z6(t,r,e.error);if(e.status===`error`)throw e.error;return a}),i8=J.memo(function(){let e=G3(),t=J.useContext(K3),n,r,i;{let a=e.stores.getMatchStore(t);[n,r]=v6(a,e=>[!!e._notFound,e.error],$6),i=v6(e.stores.ids,e=>e[e.indexOf(t)+1])}if(n)return Z6(e,e.routesById[t],r);if(!i)return null;let a=(0,X.jsx)(t8,{routeId:i});return t===`__root__`?(0,X.jsx)(J.Suspense,{fallback:Q6(e),children:a}):a});function a8(e,t){let n=e[1];e.length=0,n?.(t)}function o8({t:e}){let t=G3(),n=t._rendered??=[];return t.startTransition=(r,i)=>new Promise((a,o)=>{a8(n,!1),n.push(i,a),e(t),J.startTransition(()=>{try{r()}catch(e){n[1]===a&&(n.length=0),o(e)}})}),I0(()=>{let e=t.history.subscribe(t.load);t.updateLatestLocation();let r=t.latestLocation,i=t.buildLocation({to:r.pathname,search:!0,params:!0,hash:!0,state:!0,_includeValidateSearch:!0});if(F2(r.publicHref)!==F2(i.publicHref))return t.commitLocation({...i,replace:!0,ignoreBlocker:!0}),e;let a=t.stores.resolvedLocation.get();return a?.href===r.href&&a.state.__TSR_key===r.state.__TSR_key?n.push(t.stores.matches.get(),e=>{e&&t.emit({type:`onRendered`,...M4(a,a)})}):t._tx||t.load().catch(console.error),e},[t,t.history]),null}function s8(){let e=G3(),t=e.routesById[p4],n=Q6(e,t),r=e.ssr?X6:J.Suspense,i=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(o8,{t:J.useState()[1]}),(0,X.jsx)(r,{fallback:n,children:(0,X.jsx)(c8,{})})]});return e.options.InnerWrap?(0,X.jsx)(e.options.InnerWrap,{children:i}):i}function c8(){let e=G3(),t=e._rendered,n=v6(e.stores.matches,e=>t[0]??e),r=n[0],i=r?.routeId;I0(()=>{t[0]===n&&a8(t,!0)},[t,n]);let a=i?(0,X.jsx)(t8,{routeId:i}):null;return(0,X.jsx)(K3.Provider,{value:i,children:e.options.disableGlobalCatchBoundary?a:(0,X.jsx)(R3,{getResetKey:()=>r,onCatch:void 0,children:a})})}var l8=e=>({createMutableStore:d6,createReadonlyStore:d6,batch:c6}),u8=e=>new d8(e),d8=class extends F4{constructor(e){super(e,l8)}};function f8({router:e,children:t,...n}){W0(n)&&e.update({...e.options,...n,context:{...e.options.context,...n.context}});let r=(0,X.jsx)(W3.Provider,{value:e,children:t});return e.options.Wrap?(0,X.jsx)(e.options.Wrap,{children:r}):r}function p8({router:e,...t}){return(0,X.jsx)(f8,{router:e,...t,children:(0,X.jsx)(s8,{})})}function m8(e){let t=G3({warn:e?.router===void 0}),n=e?.router||t;return v6(n.stores.__store,b6(e,n))}function h8(){return v6(G3().stores.location,e=>e.state.__TSR_index!==0)}var g8=(0,J.createContext)(null),_8=g8.Provider,v8=q6({validateSearch:B({agent:V().min(1).optional()}),component:()=>null}),y8=G6({getParentRoute:()=>v8,path:`/`}),b8=G6({getParentRoute:()=>v8,path:`/sessions/$agentId/$sessionId`,params:{parse:e=>B({agentId:V().min(1),sessionId:V().min(1)}).parse(e)}});function x8(){return u8({routeTree:v8.addChildren([y8,b8]),history:D4(),InnerWrap:({children:e})=>(0,X.jsxs)(X.Fragment,{children:[(0,J.useContext)(g8),e]}),defaultPendingMs:0,defaultPendingMinMs:0})}function S8(e,t){let n=m8({router:e,select:e=>e.location.search}),r=x6({from:b8.id,shouldThrow:!1});Hm(t,{canGoBack:h8(),onBack:()=>e.history.canGoBack()?(e.history.back(),!0):!1});let i=(0,J.useCallback)(t=>{e.navigate({to:`.`,search:{agent:t??void 0},replace:!0})},[e]),a=(0,J.useCallback)((t,n)=>{e.navigate({to:`/sessions/$agentId/$sessionId`,params:{agentId:t,sessionId:n},search:!0})},[e]);return{agentFilterId:n.agent??null,setFilter:i,selection:r?.params,open:a}}var C8=wn.check(Cn(1,{message:`Give your Agent a name.`}),H(256,{message:`Use at most 256 characters.`}));function w8({agentId:e,name:t,rename:n}){let[r,i]=(0,J.useState)(!1),a=t0({schema:(0,J.useMemo)(()=>U({name:C8.annotate(O1({label:`Agent name`,render:e=>(0,X.jsx)(eK,{id:e.id,name:e.name,"aria-label":`Agent name`,"aria-invalid":e[`aria-invalid`],"aria-describedby":e[`aria-describedby`],autoFocus:!0,maxLength:256,disabled:e.disabled,value:e.value,onBlur:e.onBlur,onChange:t=>{e.onChange(t.currentTarget.value)}})}))}),[]),defaultValues:{name:t},onSubmit:async({name:r})=>r===t||await n(e,r)?(i(!1),{kind:`saved`,values:{name:r}}):{kind:`refused`}}),{submitting:o,canSubmit:s}=n0(a);return r?(0,X.jsxs)(a0,{model:a,"aria-label":`Rename Agent`,footer:null,className:`flex min-w-0 items-center gap-1`,children:[(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,X.jsx)(C1,{model:a,names:[`name`]})}),(0,X.jsx)(BT,{type:`submit`,size:`sm`,loading:o,disabled:o||!s,children:`Save`}),(0,X.jsx)(LG,{"aria-label":`Cancel rename`,type:`button`,icon:(0,X.jsx)(hW,{size:14,"aria-hidden":`true`}),onClick:()=>{i(!1)}})]}):(0,X.jsx)(LG,{"aria-label":`Rename Agent`,icon:(0,X.jsx)(cW,{size:14,"aria-hidden":`true`}),onClick:()=>{i(!0)}})}function T8({status:e,approving:t,onApprove:n}){return e?.status===`pending`?(0,X.jsx)(BT,{variant:`outline`,size:`sm`,className:`flex-none`,loading:t,disabled:t,onClick:n,children:`Allow App tools`}):null}var E8=U({text:W}),D8=br(structuredClone(dt(E8,{onExcessProperty:`error`}).schema));function O8(e){return[{id:`new-conversation`,title:`New conversation`,category:`Conversation`,description:`Start a new conversation with this Agent`,projections:{slash:{aliases:[`new`],order:20},palette:{}},handler:()=>{e().newConversation()}},{id:`permissions`,title:`App permissions`,category:`Conversation`,description:`Review what Grove may access`,projections:{slash:{aliases:[`permissions`],order:21},palette:{}},handler:()=>{e().openPermissions()}},{id:`set-draft`,title:`Set draft`,category:`Conversation`,description:`Replace the open writable Grove conversation's draft without sending it`,projections:{agent:{}},action:{inputSchema:D8,presentation:{type:`action`}},handler:({arguments:t})=>{let{text:n}=Ht(E8,{onExcessProperty:`error`})(t);return{accepted:e().setDraft(n)}}}]}function k8(e,t){let n=(0,J.useRef)(e);n.current=e;let r=(0,J.useMemo)(()=>O8(()=>n.current),[]),i=(0,J.useMemo)(()=>Zr(),[]);return(0,J.useEffect)(()=>{let e=i.contribute({sourceId:`grove`,namespace:`grove`,commands:r});return()=>{e.dispose()}},[r,i]),(0,J.useEffect)(()=>t?Ki(t,r):void 0,[r,t]),i}function A8(e){let t=na(),n=e?.capabilities.has(mg)===!0||e?.capabilities.has(hg)===!0,r=ib(n?e:null),i=e&&!n?{...r,status:`live`}:r,a=eb.of(e,`agents`),o=jo({...rb(e,rg,a,e=>e.list()),enabled:e?.capabilities.has(rg)===!0}),s=new Set(o.data?.map(e=>e.agentId)),c=o.isSuccess?JSON.stringify([...new Set(i.items.filter(e=>!(`kind`in e)).map(e=>e.agentId))].filter(e=>!s.has(e)).sort()):`[]`,{refetch:l}=o;(0,J.useEffect)(()=>{c!==`[]`&&i.items.length>0&&l()},[c,i.items,l]);let u=eb.of(e,`agent-computers`);return{directory:o,inbox:i,computerChoices:jo({...rb(e,ig,u,()=>{if(!e)throw Error(`No App connection`);return _g(e.capabilities)}),enabled:e?.capabilities.has(ig)===!0}),createAgent:Po({mutationFn:t=>{if(!e)throw Error(`No App connection`);return gg(e.capabilities,t)},onMutate:()=>({directoryKey:a}),onSettled:(e,n,r)=>{r.computer===`new`&&t.invalidateQueries({queryKey:u})},onSuccess:(e,n,r)=>{t.setQueryData(r.directoryKey,(t=[])=>t.some(t=>t.agentId===e.agentId)?t:[...t,e])}}),renameAgent:Po({mutationFn:t=>{if(!e)throw Error(`No App connection`);return sg(e.capabilities,t)},onSuccess:e=>{t.setQueryData(a,(t=[])=>t.map(t=>t.agentId===e.agentId?e:t))}}),setAgentAvatar:Po({mutationFn:t=>{if(!e)throw Error(`No App connection`);return ug(e.capabilities,t)},onSuccess:e=>{t.setQueryData(a,(t=[])=>t.map(t=>t.agentId===e.agentId?e:t))}})}}function j8(e,t){let n=na(),r=e?.capabilities.has(pg)===!0,i=eb.of(e,`agent-tool-policy`,t??`none`);return{canRead:r,status:jo({...rb(e,pg,i,e=>t===null?Promise.resolve(null):e.status({agentId:t})),enabled:r&&t!==null}),approve:Po({mutationFn:t=>{if(!e)throw Error(`No App connection`);return e.capabilities.require(pg).approve({agentId:t.agentId,level:`write`,expectedRevision:t.expectedRevision})},onSuccess:e=>{`error`in e||n.setQueryData(i,e)}})}}function M8({agentId:e,name:t,avatar:n,setAvatar:r}){let[i,a]=(0,J.useState)(null),[o,s]=(0,J.useState)(!1),c=(0,X.jsx)(NX,{avatar:n,name:t,size:24});return r===void 0?(0,X.jsx)(`span`,{className:`flex-none`,children:c}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(BT,{variant:`ghost`,size:`sm`,"aria-label":`Change avatar`,className:`flex-none p-0`,onClick:()=>{a(n)},children:c}),(0,X.jsx)(IU,{open:i!==null,onOpenChange:e=>{!e&&!o&&a(null)},children:(0,X.jsxs)(VU,{className:`flex flex-col gap-lg`,keepMounted:!1,children:[(0,X.jsxs)(UU,{children:[(0,X.jsxs)(WU,{children:[t,`'s avatar`]}),(0,X.jsxs)(GU,{children:[`Every conversation with `,t,` shows this look.`]})]}),i===null?null:(0,X.jsx)(T0,{value:i,disabled:o,onChange:a}),(0,X.jsxs)(HU,{children:[(0,X.jsx)(BT,{type:`button`,variant:`ghost`,disabled:o,onClick:()=>{a(null)},children:`Cancel`}),(0,X.jsx)(BT,{type:`button`,variant:`primary`,loading:o,disabled:o||i===null,onClick:()=>{i!==null&&(s(!0),r(e,i).then(e=>{s(!1),e&&a(null)}))},children:`Save`})]})]})})]})}var N8=(0,J.forwardRef)(function({className:e,orientation:t,variant:n=`grip`,value:r,min:i,max:a,onValueChange:o,onKeyDown:s,...c},l){return(0,X.jsx)(`div`,{...c,ref:l,className:Q(`caps-resize-handle`,e),"data-resize-variant":n,role:`separator`,"aria-orientation":t,"aria-valuemin":Math.round(i),"aria-valuemax":Math.round(a),"aria-valuenow":Math.round(r),tabIndex:c.tabIndex??0,onKeyDown:e=>{if(s?.(e),e.defaultPrevented)return;if(e.key===`Home`||e.key===`End`){e.preventDefault(),o(e.key===`Home`?i:a);return}let n=t===`horizontal`?e.key===`ArrowUp`?-32:e.key===`ArrowDown`?32:null:e.key===`ArrowLeft`?-32:e.key===`ArrowRight`?32:null;n!==null&&(e.preventDefault(),o(Math.min(a,Math.max(i,r+n))))},children:(0,X.jsx)(`span`,{className:`caps-resize-grip`,"aria-hidden":`true`})})});$({frames:new Map,order:[],tiles:[],minima:new Map,participating:new Set,mainSize:void 0,zoomed:null,gesture:null,restore:new Map});function P8(e,t=!0,n){let r=(0,J.useRef)(e);r.current=e;let i=(0,J.useRef)(null);return(0,J.useEffect)(()=>(t||i.current?.release(!0),()=>i.current?.release(!0)),[t]),(0,J.useEffect)(()=>{let e=()=>{i.current?.release(!0)};return n?.addEventListener(`abort`,e),()=>{n?.removeEventListener(`abort`,e)}},[n]),{onPointerDown:e=>{if(!t||n?.aborted||i.current||e.pointerType===`mouse`&&e.button!==0)return;let{currentTarget:a,pointerId:o}=e;if(a.setPointerCapture(o),!r.current.begin(e)){a.releasePointerCapture(o);return}let s=r.current.end,c=()=>{l(!0)},l=e=>{a.removeEventListener(`lostpointercapture`,c),i.current=null,s(e),a.hasPointerCapture(o)&&a.releasePointerCapture(o)};i.current={id:o,element:a,x:e.clientX,y:e.clientY,release:l},a.addEventListener(`lostpointercapture`,c)},onPointerMove:e=>{let t=i.current;t?.id===e.pointerId&&(r.current.move(e.clientX-t.x,e.clientY-t.y,e),t.x=e.clientX,t.y=e.clientY)},onPointerUp:e=>{i.current?.id===e.pointerId&&i.current.release(!1)},onPointerCancel:e=>{i.current?.id===e.pointerId&&i.current.release(!0)}}}(0,J.createContext)(null);var F8=(0,J.createContext)(null);(0,J.forwardRef)(function({layer:e,style:t,children:n,...r},i){let a=(0,J.useContext)(F8),o=a?.update,s=a?.roots.get(`dialog`),[c,l]=(0,J.useState)(!1);(0,J.useEffect)(()=>{if(!s)return;let e=()=>{l(Array.from(s.querySelectorAll(`*`)).some(e=>{let t=e.getBoundingClientRect();return t.width>0&&t.height>0}))};e();let t=new MutationObserver(e);return t.observe(s,{childList:!0,subtree:!0,attributes:!0}),()=>{t.disconnect()}},[s]);let u=(0,J.useRef)(null);(0,J.useImperativeHandle)(i,()=>u.current);let d=(0,J.useCallback)(t=>{u.current=t,o?.(e,t)},[o,e]);return(0,J.createElement)(`div`,{...r,ref:d,onFocusCapture:t=>{e===`windows`&&t.target instanceof Node&&t.currentTarget.contains(t.target)&&a?.dismiss?.(),r.onFocusCapture?.(t)},"data-maosaico-layer":e,inert:e===`windows`&&c?``:void 0,style:{position:`relative`,...t,isolation:`isolate`,zIndex:`var(--stipe-layer-${e})`}},n)});var I8={min:224,max:480,initial:320},L8={agentRailOpen:!0,listRailOpen:!0,listWidth:I8.initial},R8=`fungi.grove.layout.v1`,z8=kn(tr(U({agentRailOpen:on,listRailOpen:on,listWidth:gn.pipe(q(tn()))})));function B8(e){return Math.round(Math.min(I8.max,Math.max(I8.min,e)))}function V8(e){try{let t=e?.getItem(R8);if(t==null)return L8;let n=z8(t);return je(n)?{...n.value,listWidth:B8(n.value.listWidth)}:L8}catch(e){return console.warn(`Grove could not read its saved rail layout`,e),L8}}function H8(e,t){try{e?.setItem(R8,JSON.stringify(t))}catch(e){console.warn(`Grove could not save its rail layout`,e)}}function U8(){try{return globalThis.localStorage}catch(e){console.warn(`Grove rail layout storage is unavailable`,e);return}}function W8(){let[e,t]=(0,J.useState)(()=>V8(U8()));return(0,J.useEffect)(()=>{H8(U8(),e)},[e]),[e,t]}var G8={2:`h2`,3:`h3`,4:`h4`};function K8(e,t){let{reduced:n}=t,r=e&&!n,i=hS(t,600),[a,o]=(0,J.useState)(r);return(0,J.useEffect)(()=>{if(o(r),!r)return;let e=globalThis.setTimeout(()=>{o(!1)},i);return()=>{globalThis.clearTimeout(e)}},[r,i]),a}var q8=(0,J.forwardRef)(function({actions:e,className:t,description:n,headingLevel:r=2,suggestions:i,thinking:a=!1,title:o,visual:s,renderVisual:c,variant:l=`plain`,...u},d){let f=(0,J.useId)(),p=(0,J.useRef)(null),m=mS(p),h=K8(l===`speech`,m)&&!a,g=G8[r],_=c?c({speaking:h,thinking:a}):s,v=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(g,{ref:p,className:`empty-state-title`,id:u[`aria-labelledby`]?void 0:f,children:o}),(0,X.jsx)(`p`,{children:n}),i&&i.length>0?(0,X.jsx)(`ul`,{"aria-label":`Try one of these`,className:`empty-state-suggestions`,children:i.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsx)(BT,{size:`sm`,variant:`outline`,onClick:e.onSelect,children:e.label})},e.label))}):null,e?(0,X.jsx)(`div`,{className:`empty-state-actions`,children:e}):null]});return(0,X.jsxs)(`section`,{...u,"aria-labelledby":u[`aria-labelledby`]??f,className:Q(`empty-state`,l!==`plain`&&`empty-state-${l}`,t),ref:d,children:[_?(0,X.jsx)(`div`,{"aria-hidden":`true`,className:`empty-state-visual`,children:_}):null,l===`speech`?(0,X.jsx)(`div`,{className:`empty-state-bubble`,children:v}):v]})});function J8({description:e,icon:t,label:n,density:r=`regular`,appearance:i=`plain`,iconSize:a=`default`,size:o,trailing:s,...c}){return(0,X.jsxs)(BT,{...c,className:Q(`caps-action-row`,i===`card`&&`caps-action-row-card`,r===`compact`?`h-auto min-h-10 w-full justify-start gap-xs px-xs py-2xs text-left`:`h-auto min-h-14 w-full justify-start gap-sm px-sm py-xs text-left`,c.className),size:o??(r===`compact`?`default`:`lg`),variant:c.variant??`ghost`,children:[t?(0,X.jsx)(`span`,{className:r===`compact`?`grid ${a===`lg`?`size-8`:`size-7`} shrink-0 place-items-center [&_:is(svg,.caps-monogram)]:size-5`:`grid ${a===`lg`?`size-12`:`size-10`} shrink-0 place-items-center [&_:is(svg,.caps-monogram)]:size-7`,children:t}):null,(0,X.jsxs)(`span`,{className:`caps-action-row-copy`,children:[(0,X.jsx)(`span`,{className:`caps-action-row-label max-w-full truncate`,children:n}),e?(0,X.jsx)(`span`,{className:`caps-action-row-description max-w-full truncate`,children:e}):null]}),s?(0,X.jsx)(`span`,{className:`caps-action-row-trailing`,children:s}):null]})}function Y8(e,t,n,r,i){let a=[];r&&a.push({kind:`hint`,key:`loading`,loading:!0});let o=0,s=[...e.active,...e.settled],c=new Map(s.map(e=>[JX(e.agentId,e.sessionId),e]));for(let e of[`Needs you`,`Working`,`Ready`,`Finished`]){let n=t.filter(t=>t.shelf===e).flatMap(e=>{let t=c.get(e.key);return t===void 0?[]:[t]});if(n.length!==0){a.push({kind:`heading`,key:e,title:e,gap:o++>0});for(let t of n)a.push({kind:`session`,key:JX(t.agentId,t.sessionId),shelf:e,session:t})}}if(e.unavailable.length>0){a.push({kind:`heading`,key:`Unavailable`,title:`Unavailable`,gap:o>0});for(let t of e.unavailable)a.push({kind:`unavailable`,key:JX(t.agentId,t.sessionId),session:t})}if(n.length>0){a.push({kind:`heading`,key:`Websites`,title:`Websites`,gap:a.length>0});for(let e of n)a.push({kind:`website`,key:`website:${e.bindingId}:${e.conversation.sessionId}`,website:e})}return a.length===0&&!i&&a.push({kind:`hint`,key:`empty`,loading:!1}),a}function X8({viewport:e,view:t,agents:n,loading:r,failed:i,pendingSelection:a,selectedAgentId:o,selectedSessionId:s,onSelect:c,onDelete:l,deleting:u,websites:d,selectedWebsite:f,onSelectWebsite:p}){let m=o!==null&&s!==null?JX(o,s):null,[h,g]=(0,J.useState)(!1),[_,v]=(0,J.useState)(!1),y=h||_,[b,x]=(0,J.useState)(0),[S,C]=(0,J.useState)({placements:null,openKey:m,reopened:b}),w=(0,J.useMemo)(()=>WX(S.placements,[...t.active,...t.settled],{openKey:S.openKey===m?m:null,held:y,reorder:S.openKey!==m||S.reopened!==b}),[S,t,m,y,b]);(0,J.useEffect)(()=>{!y&&(S.placements!==w||S.openKey!==m||S.reopened!==b)&&C({placements:w,openKey:m,reopened:b})},[y,S,w,m,b]),(0,J.useEffect)(()=>{let t=e.current;if(t===null)return;let n=t.clientWidth>0&&t.clientHeight>0,r=`ResizeObserver`in globalThis?new ResizeObserver(([e])=>{let t=e.contentRect.width>0&&e.contentRect.height>0;t&&!n&&x(e=>e+1),n=t}):void 0;r?.observe(t);let i=()=>{document.visibilityState===`visible`&&x(e=>e+1)};return document.addEventListener(`visibilitychange`,i),()=>{r?.disconnect(),document.removeEventListener(`visibilitychange`,i)}},[e]);let T=(0,J.useMemo)(()=>Y8(t,w,d,r,i),[t,w,d,r,i]),E=(0,J.useCallback)(e=>T[e]?.key??e,[T]),D=GW({count:T.length,getScrollElement:()=>e.current,getItemKey:E,estimateSize:e=>T[e]?.kind===`heading`?24:44,measureElement:(e,t,n)=>{let r=LW(e,t,n);return r>0?r:LW(e,void 0,n)||n.options.estimateSize(n.indexFromElement(e))},initialRect:{width:320,height:800},overscan:5,useFlushSync:!1});return(0,X.jsx)(`div`,{className:`inbox-list px-1 py-1`,onPointerEnter:()=>{g(!0)},onPointerLeave:()=>{g(!1)},onFocusCapture:()=>{v(!0)},onBlurCapture:e=>{e.currentTarget.contains(e.relatedTarget)||v(!1)},children:(0,X.jsx)(`div`,{style:{height:D.getTotalSize(),position:`relative`,width:`100%`},children:D.getVirtualItems().map(e=>{let t=T[e.index],r=t.kind===`session`||t.kind===`unavailable`?t.session:null,i=r?n.get(r.agentId):void 0;return(0,X.jsx)(`div`,{"data-index":e.index,ref:D.measureElement,"data-inbox-shelf":t.kind===`session`?t.shelf:t.kind===`unavailable`?`Unavailable`:void 0,className:t.kind===`heading`?`inbox-shelf`:void 0,style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${String(e.start)}px)`,paddingTop:t.kind===`heading`&&t.gap?4:0},children:t.kind===`heading`?(0,X.jsx)(Hx,{style:{paddingBottom:0},children:t.title}):t.kind===`hint`?(0,X.jsx)(`p`,{className:t.loading?`inbox-empty m-0 px-2 py-3 text-sm text-(--stipe-fg-muted)`:`m-0 px-2 py-3 text-xs text-(--stipe-fg-muted)`,role:t.loading?`status`:void 0,children:t.loading?`Loading conversations…`:`No conversations yet.`}):t.kind===`website`?(0,X.jsx)(J8,{appearance:`plain`,density:`compact`,className:`inbox-row${f?.bindingId===t.website.bindingId&&f.conversation.sessionId===t.website.conversation.sessionId?` is-selected bg-base-300`:``}`,"data-testid":`inbox-website-row`,label:t.website.conversation.label||`Website visitor`,description:(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,X.jsx)(Xq,{name:`internet`,size:14}),t.website.siteLabel]}),trailing:t.website.conversation.held?(0,X.jsx)(`span`,{className:`text-xs`,children:t.website.conversation.heldByYou?`You're replying`:`With a teammate`}):t.website.conversation.needsYou?(0,X.jsx)(FG,{size:`compact`,tone:`accent`,title:t.website.conversation.needsYou.reason}):null,onClick:()=>{p(t.website)},variant:`ghost`}):t.kind===`unavailable`?i?(0,X.jsx)(Q8,{agent:i,row:t.session}):null:i?(0,X.jsx)(Z8,{agent:i,session:t.session,attention:t.session.unseen,pending:a?.agentId===t.session.agentId&&a.sessionId===t.session.sessionId,selected:o===t.session.agentId&&s===t.session.sessionId,onDelete:l&&i.sessionOperations.includes(`agent.manage`)?()=>{l(t.session.agentId,t.session.sessionId)}:void 0,deleting:u?.agentId===t.session.agentId&&u.sessionId===t.session.sessionId,onSelect:()=>{c(t.session.agentId,t.session.sessionId)}}):null},e.key)})})})}function Z8({agent:e,session:t,attention:n,pending:r,selected:i,onSelect:a,onDelete:o,deleting:s}){let c=LX(t.state),l=t.state===`errored`,u=(0,X.jsxs)(`span`,{className:`inbox-row-activity inline-grid shrink-0 grid-cols-[1rem_7ch] items-center gap-1.5 text-[0.6875rem]`,children:[(0,X.jsxs)(`span`,{className:`inbox-row-status flex items-center justify-center`,children:[r||c||l?(0,X.jsx)(`span`,{className:`sr-only`,children:r?`Opening`:FX[t.state]}):null,r||c?(0,X.jsx)(FG,{size:`compact`,title:r?`Opening`:FX[t.state],motion:t.state===`running`||r?`pulse`:`none`,tone:r?`neutral`:t.state===`needs_you`?`accent`:`info`}):l?(0,X.jsx)(FG,{size:`compact`,title:FX.errored,tone:`error`}):n?(0,X.jsx)(FG,{size:`compact`,title:`Finished since your last visit`,tone:`neutral`}):null]}),(0,X.jsx)(`time`,{className:`inbox-row-age min-w-0 truncate text-right tabular-nums text-(--stipe-fg-muted)`,dateTime:new Date(t.lastActivityAt).toISOString(),children:$8(t.lastActivityAt)})]});return(0,X.jsxs)(`div`,{className:`relative group`,children:[(0,X.jsx)(J8,{"aria-current":i?`page`:void 0,"aria-label":`${t.title||`Untitled session`} — ${YX(e)}${n?` — Finished since your last visit`:``}${t.ready?` — Ready`:c||l?` — ${FX[t.state]}`:``}`,"aria-busy":r||void 0,appearance:`plain`,className:`inbox-row pr-9${i?` is-selected bg-base-300`:``}`,"data-attention":n?`true`:`false`,"data-pending":r?`true`:`false`,"data-session-id":t.sessionId,"data-status":t.state,"data-testid":`inbox-session-row`,density:`compact`,description:YX(e),label:t.title||`Untitled session`,onClick:a,trailing:u,variant:`ghost`}),o?(0,X.jsx)(LG,{"aria-label":`Delete conversation ${t.title||`Untitled session`}`,title:`Delete conversation`,icon:(0,X.jsx)(mW,{}),iconSize:`sm`,size:`sm`,className:`absolute right-1 top-1/2 -translate-y-1/2 opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 max-[899px]:opacity-100`,disabled:c||s,onClick:o}):null]})}function Q8({agent:e,row:t}){return(0,X.jsxs)(`div`,{className:`inbox-row is-unavailable flex min-h-11 w-full items-center gap-2 rounded-field border-(length:--border) border-transparent px-2 py-1 pr-9 text-left text-base-content`,"data-session-id":t.sessionId,"data-testid":`inbox-unavailable-row`,role:`group`,children:[(0,X.jsxs)(`span`,{className:`inbox-row-copy flex min-w-0 flex-1 flex-col`,children:[(0,X.jsx)(`strong`,{className:`truncate text-sm font-medium`,children:`Conversation unavailable`}),(0,X.jsxs)(`small`,{className:`truncate text-xs text-(--stipe-fg-muted)`,children:[YX(e),` `,(0,X.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),` This saved conversation could not be read.`]})]}),(0,X.jsx)(`span`,{className:`inbox-row-activity inline-grid shrink-0 grid-cols-[1rem_7ch] items-center gap-1.5 text-[0.6875rem]`,children:(0,X.jsx)(`span`,{className:`inbox-row-status flex items-center justify-center`,children:(0,X.jsx)(FG,{size:`compact`,tone:`error`,title:`This saved conversation could not be read`})})})]})}function $8(e){let t=Math.max(0,Date.now()-e);return t<6e4?`now`:t<36e5?`${String(Math.floor(t/6e4))}m`:t<864e5?`${String(Math.floor(t/36e5))}h`:new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}var e5=V().min(1).max(256),t5=Ue().int().nonnegative();ge(`state`,[me({state:tt(`agent`),version:t5}),me({state:tt(`requested`),version:t5,reason:V().max(4e3),at:Ue().int().nonnegative()}),me({state:tt(`person`),version:t5,memberId:e5,memberName:V().min(1).max(128),since:Ue().int().nonnegative()})]);var n5=me({bindingId:e5,agentId:e5,origins:Se(V().min(1).max(2048)).min(1).max(16),lifecycle:C([`active`,`suspended`])}),r5=me({sessionId:e5,label:V().max(4096),lastEventAt:Ue().int().nonnegative(),needsYou:me({at:Ue().int().nonnegative(),reason:V().max(4e3)}).nullable(),held:Je(),heldByYou:Je(),heldByName:V().min(1).max(128).nullable(),holdVersion:Ue().int().nonnegative()}),i5=me({bindingId:e5}).extend({sessionId:e5});i5.extend({requestId:V().min(1).max(128),text:V().trim().min(1).max(4e3)});var a5=me({expectedVersion:t5,confirm:Je()});i5.extend(a5.shape),i5.extend({expectedVersion:t5});var o5=me({websites:Se(n5).max(1e3)}),s5=me({conversations:Se(r5).max(100)});me({conversation:r5});var c5=me({status:tt(`sent`)}),l5=Gm(`channels.read`,1,Ie(()=>Km({list:Jm(qm(o5)),conversations:Jm(qm(s5))}))),u5=Gm(`channels.personal.manage`,1,Ie(()=>Km({hold:Jm(qm(r5)),release:Jm(qm(r5)),dismiss:Jm(qm(r5)),reply:Jm(qm(c5))})));function d5(e,t){let n=!1,r=async()=>{try{return await t.read()}catch(e){if(!(e instanceof cn)||e.boundary!==`runtime`||e.cause!==`unavailable`)throw e;if(await new Promise(e=>setTimeout(e,150)),n)throw Error(`Conversation opening cancelled`,{cause:e});return t.read()}},i,a=new Promise((e,t)=>{i=()=>{t(Error(`Conversation opening cancelled`))}});return{ready:Promise.race([r(),a]).then(r=>{if(n)throw Error(`Conversation opening cancelled`);iF(e,t,r)}),close:()=>{n=!0,i()}}}function f5(e){return class{#e;constructor(t){this.#e=new Rg(t,{fetch:(t,n)=>e(t,n)})}get readyState(){return this.#e.readyState}addEventListener(e,t,n){this.#e.addEventListener(e,t,n)}close(){this.#e.close()}}}function p5(e){let{connection:t,queryClient:n,services:r}=e,i=null,a=null,o=null,s=!1,c=(e,t)=>e?.agentId===t.agentId&&e.sessionId===t.sessionId,l=e=>!s&&i===e,u=(u,d,f=!1)=>{if(s)return;let p={agentId:u,sessionId:d};if(c(i,p)||(i?.close(),i=null,e.onPending(null),e.onError(null),c(a,p)))return;let m=null,h=!1,g={...p,close:()=>{h||(h=!0,m?.())}};i=g,e.onPending(p),(async()=>{try{let s=await r.openAgent(t.capabilities,{agentId:u});if(!l(g)){await s.close();return}let c=r.createClient({baseUrl:s.baseUrl,eventSource:f5(s.fetch),fetch:s.fetch}),f=c.session(d),p=d5(n,f);if(m=()=>{p.close(),Promise.allSettled([c.close(),s.close()])},await p.ready,e.reportsSelection!==!1&&await t.ui.reportAgentSessionSelection({agentId:u,sessionId:d}),!l(g))return;let h={agentId:u,sessionId:d,session:f},_=o;i=null,a=h,o=g.close,e.onConversation(h),e.onPending(null),_?.()}catch(t){console.error(`Chat Session opening failed`,t),g.close(),l(g)&&(i=null,e.onPending(null),e.onError(f?`That Session could not be opened. ${a?`The current conversation remains open.`:`Choose another Session from the list.`}`:`Could not open this Session${t instanceof Error?`: ${t.message}`:``}. ${a?`The previous conversation remains open.`:`Try opening it again.`}`))}})()},d=()=>{if(s)return;let n=i!==null||a!==null;i?.close(),i=null,o?.(),o=null,a=null,e.onPending(null),e.onConversation(null),e.onError(null),!(!n||e.reportsSelection===!1)&&t.ui.reportAgentSessionSelection(null).catch(e=>{console.error(`Chat Session selection could not be reported`,e)})};return{select:u,clear:d,close:()=>{d(),s=!0}}}function m5(e,t){async function n(e){if(e.type!==`prompt`||(e.images?.length??0)>0)throw new Y(`Website conversations support text replies only`,{code:`COMMAND_NOT_DECLARED`,retryable:!1});if(!t.canReply())throw new Y(`Use Take over to reply to this visitor`,{code:`CAPABILITY_DENIED`,retryable:!1});return await t.reply({bindingId:t.bindingId,sessionId:t.sessionId,requestId:e.requestId,text:e.text}),{status:`recorded`}}return{latestPending:()=>Promise.resolve(null),withdraw:t=>e.withdraw(t),address:e.address,read:t=>e.read(t),watch:t=>e.watch(t),extension:()=>({call:()=>Promise.reject(new Y(`Website Session controls are unavailable`,{code:`COMMAND_NOT_DECLARED`,retryable:!1}))}),command:n}}function h5(e,t){(0,J.useSyncExternalStore)(t=>e?.capabilities.subscribe(t)??(()=>void 0),()=>e?.capabilities.version??0);let n=na(),[r,i]=(0,J.useState)(null),[a,o]=(0,J.useState)(null),[s,c]=(0,J.useState)(null),l=e?.capabilities.has(l5)===!0,u=e?.capabilities.has(u5)===!0,d=jo({...rb(e,l5,eb.of(e,`websites`),e=>e.list()),enabled:l}),f=l?d.data?.websites??[]:[],p=ko({queries:f.map(t=>({...rb(e,l5,eb.of(e,`website-conversations`,t.bindingId),e=>e.conversations({bindingId:t.bindingId})),enabled:l}))}),m=f.flatMap((e,t)=>(p[t]?.data?.conversations??[]).map(t=>({bindingId:e.bindingId,agentId:e.agentId,siteLabel:e.origins.map(e=>new URL(e).host).join(`, `),conversation:t}))).sort((e,t)=>t.conversation.lastEventAt-e.conversation.lastEventAt),h=m.find(e=>e.bindingId===r?.bindingId&&e.conversation.sessionId===r.sessionId),g=(0,J.useMemo)(()=>e===null?null:p5({connection:e,queryClient:n,services:t,onPending:()=>void 0,onConversation:o,onError:c}),[e,n,t]);(0,J.useEffect)(()=>()=>{g?.close()},[g]),(0,J.useEffect)(()=>{l||g?.clear()},[l,g]);let _=Po({mutationFn:t=>{if(e===null)throw Error(`No App connection`);let n=e.capabilities.require(u5);return t.kind===`hold`?n.hold({bindingId:t.bindingId,sessionId:t.sessionId,expectedVersion:t.expectedVersion,confirm:t.confirm}):n.release({bindingId:t.bindingId,sessionId:t.sessionId,expectedVersion:t.expectedVersion,confirm:t.confirm})},onSuccess:(t,r)=>{n.setQueryData(eb.of(e,`website-conversations`,r.bindingId),e=>e===void 0?void 0:{conversations:e.conversations.map(e=>e.sessionId===t.sessionId?t:e)})}}),v=h?.bindingId,y=h?.conversation.sessionId,b=h?.conversation.heldByYou===!0,x=(0,J.useMemo)(()=>a===null||v===void 0||y===void 0||e===null?null:m5(a.session,{bindingId:v,sessionId:y,canReply:()=>b&&e.capabilities.has(u5),reply:t=>e.capabilities.require(u5).reply(t)}),[e,a,v,y,b]),S=(0,J.useCallback)(()=>{g?.clear(),i(null),o(null),_.reset()},[g,_.reset]);return{canRead:l,canManage:u,rows:m,selected:h,session:x,action:_,openingError:s,loading:l&&(d.isPending||p.some(e=>e.isPending)),failed:l&&(d.isError||p.some(e=>e.isError)),clear:S,select:e=>{l&&(h?.bindingId!==e.bindingId||h.conversation.sessionId!==e.conversation.sessionId||a===null)&&(i({bindingId:e.bindingId,sessionId:e.conversation.sessionId}),o(null),_.reset(),g?.select(e.agentId,e.conversation.sessionId))}}}function g5({inbox:e}){let{selected:t,session:n,action:r,canManage:i,openingError:a}=e,[o,s]=(0,J.useState)(null);if((0,J.useEffect)(()=>{s(null)},[t?.bindingId,t?.conversation.sessionId,i]),t===void 0)return null;let c=t.conversation;return(0,X.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,"aria-label":`Website conversation`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-base-300 p-2`,children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1 text-sm`,children:c.heldByYou?`You're replying. The Agent is paused.`:c.held?`${c.heldByName??`A teammate`} is replying.`:`The Agent is replying. Take over to answer as yourself.`}),i?(0,X.jsx)(BT,{size:`sm`,disabled:r.isPending,onClick:()=>{let e={bindingId:t.bindingId,sessionId:c.sessionId};c.heldByYou?r.mutate({kind:`release`,...e,expectedVersion:c.holdVersion,confirm:!1}):c.held?s({...e,version:c.holdVersion,name:c.heldByName??`A teammate`}):r.mutate({kind:`hold`,...e,expectedVersion:c.holdVersion,confirm:!1})},children:c.heldByYou?`Hand back to Agent`:`Take over`}):null]}),(0,X.jsx)(IU,{open:o!==null,onOpenChange:e=>{e||s(null)},children:(0,X.jsxs)(VU,{children:[(0,X.jsxs)(UU,{children:[(0,X.jsxs)(WU,{children:[o?.name,` is replying — take over?`]}),(0,X.jsx)(GU,{children:`You will reply as yourself. Their replies stop until they take over again.`})]}),(0,X.jsxs)(HU,{children:[(0,X.jsx)(KU,{render:(0,X.jsx)(BT,{variant:`outline`}),children:`Cancel`}),(0,X.jsx)(BT,{disabled:r.isPending||!i,onClick:()=>{o!==null&&(r.mutate({kind:`hold`,bindingId:o.bindingId,sessionId:o.sessionId,expectedVersion:o.version,confirm:!0}),s(null))},children:`Take over`})]})]})}),i?null:(0,X.jsx)(`p`,{className:`p-3 text-sm`,children:`Allow takeover in Grove's App permissions to reply. Your Team permissions still apply.`}),r.isError?(0,X.jsx)(`p`,{role:`alert`,className:`p-2 text-sm text-error`,children:`This conversation changed or website access was removed. Refresh and try again.`}):null,a?(0,X.jsx)(`p`,{role:`alert`,className:`p-2 text-sm text-error`,children:a}):null,n?(0,X.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,X.jsx)(_X,{authorOf:Pt,disambiguateAuthors:!0,session:n,markdownPolicy:`visitor`,composerActionVariant:`outline`},`${t.bindingId}:${c.sessionId}`)}):null]})}var _5=(0,J.lazy)(async()=>({default:(await sr(()=>import(`./parakeet-conversation-C7vaUI2C.js`),__vite__mapDeps([12,1,2,3,4,5,13]))).ParakeetConversation})),v5={openAgent:bg,createClient:hn},y5=[`agent.list`,`agent.manage`,`agent.read`,`agent.send`],b5=[`agent.read`,`agent.send`,`agent.manage`],x5=Ot({family:`grove-session-create-request`,version:1,kinds:{request:{prefix:`request`}}});async function S5(e,t,n,r){let i=await n.openAgent(e.capabilities,{agentId:t}),a=n.createClient({baseUrl:i.baseUrl,eventSource:f5(i.fetch),fetch:i.fetch});try{return await r(a)}finally{Promise.allSettled([a.close(),i.close()])}}function C5({open:e,renderConversation:t,connection:n,commands:r,composeDraft:i,onPrefilled:a,onForked:o,onOpen:s,label:c=`Conversation`}){let l=e.session;return(0,J.useEffect)(()=>{let e=BL(r,l,{sourceId:`grove-session`,namespace:`session`,sessionResumeAvailable:!1,forkAvailable:!0,onForked:o});return()=>{e.dispose()}},[r,l,o]),(0,X.jsx)(`section`,{className:`inbox-conversation min-h-0 min-w-0 flex-1`,"data-inbox-conversation":!0,"aria-label":c,children:t?t(e,i,s):(0,X.jsx)(J.Suspense,{fallback:(0,X.jsx)(`p`,{className:`p-3 text-sm text-(--stipe-fg-muted)`,role:`status`,children:`Opening conversation…`}),children:(0,X.jsx)(_5,{session:l,draftIdentity:{agentId:e.agentId,sessionId:e.sessionId},connection:n,commands:r,prefill:i,onPrefilled:a,onOpen:s})})})}function w5(e){return Bm(e.connection),(0,X.jsx)(T5,{...e},JSON.stringify(eb.of(e.connection)))}function T5(e){let t=(0,J.useMemo)(x8,[e.connection]);return(0,X.jsx)(_8,{value:(0,X.jsx)(E5,{...e,router:t}),children:(0,X.jsx)(p8,{router:t})})}function E5({router:e,connection:t,services:n=v5}){let{agentFilterId:r,setFilter:i,selection:a,open:o}=S8(e,t?.window.navigation),s=na(),c=h5(t,n),{directory:l,inbox:u,computerChoices:d,createAgent:f,renameAgent:p,setAgentAvatar:m}=A8(t),h=l.data??[],g=l.isPending&&(t?.capabilities.has(rg)??!0),_=l.error?.message??null,v=f.isPending,y=Po({mutationFn:e=>{if(!t)throw Error(`No App connection`);return S5(t,e.agentId,n,t=>t.createSession(e.requestId))}}),b=Po({mutationFn:e=>{if(!t)throw Error(`No App connection`);return S5(t,e.agentId,n,t=>t.deleteSession(e.sessionId))},onSuccess:(t,n)=>{a?.agentId===n.agentId&&a.sessionId===n.sessionId&&(_e?.clear(),e.navigate({to:`/`,search:!0,replace:!0})),u.refresh()}}),x=y.isPending?y.variables.agentId:null,[S,C]=(0,J.useState)(null),[w,T]=(0,J.useState)(null),[E,D]=(0,J.useState)(!1),O=w?.agentId??null,k=w?.sessionId??null,[A,j]=(0,J.useState)(null),M=(0,J.useRef)(null),[N,P]=W8(),{agentRailOpen:F,listRailOpen:I,listWidth:L}=N,ee=e=>{P(t=>({...t,agentRailOpen:e(t.agentRailOpen)}))},te=e=>{P(t=>({...t,listRailOpen:e(t.listRailOpen)}))},ne=e=>{P(t=>({...t,listWidth:B8(e(t.listWidth))}))},re=P8({begin:()=>!0,move:e=>{ne(t=>t+e)},end:()=>void 0}),[R,ie]=(0,J.useState)(!1),ae=nZ(),z=(0,J.useRef)(null),[oe,se]=(0,J.useState)(null),ce=f.error?.message??null,le=f.data,ue=(0,J.useRef)(null),[de,fe]=(0,J.useState)(null),[pe,me]=(0,J.useState)(null),he=Bm(t)?.openRequest??null,ge=(0,J.useRef)(null),_e=(0,J.useMemo)(()=>t===null?null:p5({connection:t,queryClient:s,services:n,onPending:C,onConversation:T,onError:fe}),[t,s,n]);(0,J.useEffect)(()=>{if(_e!==null)return()=>{ue.current=null,_e.close()}},[_e]);let[ve,ye]=(0,J.useState)(null),be=(0,J.useMemo)(()=>Zr(),[]),xe=(0,J.useMemo)(()=>t===null?null:p5({connection:t,queryClient:s,services:n,onPending:()=>void 0,onConversation:ye,onError:fe,reportsSelection:!1}),[t,s,n]);(0,J.useEffect)(()=>xe===null?void 0:()=>{xe.close()},[xe]);let Se=(0,J.useCallback)(e=>{let t=t=>e.params.find(e=>e.key===t)?.value,n=t(`agent`),r=t(`session`);n!==void 0&&r!==void 0&&xe?.select(n,r)},[xe]),Ce=(0,J.useRef)(null),we=(0,J.useCallback)((e,t,n=!1)=>{_e!==null&&(y.isError&&y.reset(),c.clear(),D(!1),Ce.current={agentId:e,sessionId:t},_e.select(e,t,n),o(e,t))},[_e,o,c.clear,y.isError,y.reset]),Te=a?.agentId,Ee=a?.sessionId;(0,J.useEffect)(()=>{let e=Ce.current;Ce.current=null,Te===void 0||Ee===void 0?_e?.clear():(e?.agentId!==Te||e.sessionId!==Ee)&&_e?.select(Te,Ee)},[_e,Te,Ee]);let De=(0,J.useCallback)(e=>{w&&(we(w.agentId,e),u.refresh())},[w,we,u.refresh]);(0,J.useEffect)(()=>{if(!t||he===null){he===null&&(ge.current=null);return}if(he.kind!==`navigate`||ge.current===he.requestId)return;let e=he.params.find(e=>e.key===`agent`)?.value,n=he.params.find(e=>e.key===`session`)?.value;!e||!n||(ge.current=he.requestId,i(e),we(e,n,!0))},[t,he,we,i]);let Oe=(0,J.useCallback)(async e=>{if(!t||v||!t.capabilities.has(ig))return!1;try{let t=await f.mutateAsync(e);return i(t.agentId),se(t.agentId),j(null),!0}catch{return!1}},[t,v,f.mutateAsync,i]),ke=(0,J.useCallback)(async e=>{if(!t||x!==null)return`Conversation creation is unavailable.`;fe(null);let n=ue.current?.agentId===e?ue.current:{agentId:e,requestId:x5.request.generate()};ue.current=n;try{let t=await y.mutateAsync(n);we(e,t),u.refresh(),j(null),ie(!1),ue.current===n&&(ue.current=null);return}catch(e){return console.error(`Grove conversation creation failed`,e),e instanceof Error?e.message:`Couldn't start the conversation.`}},[t,we,x,y.mutateAsync,u.refresh]);(0,J.useEffect)(()=>{if(!(!t||he?.kind!==`compose`)&&ge.current!==he.requestId&&!(!w&&g)&&(ge.current=he.requestId,me({requestId:he.requestId,text:he.text}),!w)){let e=t.capabilities.has(hg)?h.find(e=>e.sessionOperations.includes(`agent.read`)&&e.sessionOperations.includes(`agent.send`)&&e.sessionOperations.includes(`agent.manage`)):void 0;e?ke(e.agentId):j(`agent`)}},[h,t,g,w,he,ke]);let Ae=k8({setDraft:e=>S!==null||!w||!t?.capabilities.has(hg)||!h.some(e=>e.agentId===w.agentId&&e.sessionOperations.includes(`agent.send`))?!1:(me({requestId:ch(),text:e}),!0),newConversation:()=>{w&&ke(w.agentId)},openPermissions:()=>{t?.ui.requestAppPermissions({}).catch(e=>{console.error(`Chat inbox or permission request failed`,e)})}},t?.commands),je=new Set(c.rows.map(e=>`${e.agentId}:${e.conversation.sessionId}`)),Me=u.items.filter(e=>!(`kind`in e)).filter(e=>!je.has(`${e.agentId}:${e.sessionId}`)),Ne=ko({queries:(w?[w.session]:[]).map(e=>({...rF(e),enabled:!1}))}).at(0)?.data?.snapshot,Pe=(0,J.useMemo)(()=>w&&Ne?{agentId:w.agentId,sessionId:w.sessionId,state:mM(Ne)}:void 0,[w,Ne]),Fe=(0,J.useMemo)(()=>KX(h,E&&c.canRead?[]:Me,r,Pe),[r,h,Me,E,c.canRead,Pe]),Ie=(0,J.useMemo)(()=>{let e=new Map;for(let t of Me)`state`in t&&(t.state===`needs_you`?e.set(t.agentId,`speaking`):t.state===`running`&&!e.has(t.agentId)&&e.set(t.agentId,`thinking`));return e},[Me]),Le=(0,J.useMemo)(()=>new Map(h.map(e=>[e.agentId,e])),[h]),Re=(0,J.useRef)(null),B=Me.find(e=>e.agentId===O&&e.sessionId===k),ze=B!==void 0&&B.state!==`unavailable`,Be=B!==void 0&&B.state!==`unavailable`?B.settledAt:void 0;(0,J.useEffect)(()=>{!ze||O===null||k===null||u.visit(O,k).catch(e=>{console.error(`Chat inbox or permission request failed`,e)})},[ze,Be,O,k,u.visit]);let Ve=u.status===`loading`,He=u.status===`error`,Ue=t?.capabilities.has(ig)??!1,We=t?.capabilities.has(hg)??!1,Ge=h.filter(e=>e.sessionOperations.includes(`agent.read`)&&e.sessionOperations.includes(`agent.send`)&&e.sessionOperations.includes(`agent.manage`)),Ke=Ge.find(e=>e.agentId===(oe??r))??Ge.at(0),qe=We&&Ke!==void 0,Je=()=>{t?.ui.requestAppPermissions({agents:y5}).catch(e=>{console.error(`Chat inbox or permission request failed`,e)})},Ye=le&&(!le.sessionOperations.includes(`agent.read`)||!le.sessionOperations.includes(`agent.send`)||!le.sessionOperations.includes(`agent.manage`))?`Agent created. Allow Grove to read, send messages and manage its sessions to start a conversation.`:pe&&!w&&!qe&&f.isIdle?`Choose an Agent to compose your game idea.`:null,Xe=(0,J.useMemo)(()=>KX(h,Me,null,Pe),[h,Me,Pe]),Ze=(e,t)=>{ie(!1),we(e,t)},Qe=()=>{z.current=document.activeElement instanceof HTMLElement?document.activeElement:null,ie(!0)};Vm(t,[...ae?[{kind:`button`,id:`agents`,text:`Agents`,expanded:F,title:F?`Hide Agents`:`Show Agents`},{kind:`button`,id:`conversations`,text:`Conversations`,expanded:I,title:I?`Hide conversations`:`Show conversations`}]:[{kind:`button`,id:`agents`,text:`Agents and conversations`,opens:`dialog`,expanded:R}],...ve===null?[]:[{kind:`button`,id:`close-beside`,text:`Close beside`,title:`Close beside conversation`}]],e=>{if(A!==null)return!1;if(e.itemId===`close-beside`&&ve!==null)xe?.clear();else if(ae&&e.itemId===`agents`)ee(e=>!e);else if(ae&&e.itemId===`conversations`)te(e=>!e);else if(!ae&&e.itemId===`agents`)R?ie(!1):Qe();else return!1;return!0});let $e=e=>{i(e),se(e);let t=[...Xe.active,...Xe.settled].filter(t=>t.agentId===e).sort((e,t)=>t.lastActivityAt-e.lastActivityAt).at(0);t&&Ze(e,t.sessionId)},et={"--grove-list-width":`${String(L)}px`},tt=w?Le.get(w.agentId):void 0,V=r===null?void 0:Le.get(r),nt=t?.capabilities.has(og)??!1,rt=t?.capabilities.has(lg)??!1,it=j8(t,V?.agentId??null),at=Fe.active.length+Fe.settled.length,ot=(0,J.useCallback)(async(e,n)=>{if(!t)return!1;try{return await p.mutateAsync({agentId:e,name:n}),!0}catch{return!1}},[t,p.mutateAsync]),st=(0,J.useCallback)(async(e,n)=>{if(!t)return!1;try{return await m.mutateAsync({agentId:e,avatar:n}),!0}catch{return!1}},[t,m.mutateAsync]),ct=(0,J.useCallback)(()=>{let e=it.status.data;!V||e==null||it.approve.mutate({agentId:V.agentId,expectedRevision:e.revision})},[V,it.status.data,it.approve]),lt=(0,J.useCallback)(e=>{!t||v||x!==null||e===`agent`&&!Ue||(A===null&&(M.current=R?z.current:document.activeElement instanceof HTMLElement?document.activeElement:null),ie(!1),e===`session`&&se(tt?.agentId??r??Ge.at(0)?.agentId??null),j(e))},[t,v,x,Ue,A,R,tt?.agentId,r,Ge]);(0,J.useEffect)(()=>{let e=e=>{e.defaultPrevented||e.repeat||!e.ctrlKey||e.altKey||e.metaKey||e.key.toLowerCase()!==`n`||!t||e.shiftKey&&!Ue||(e.preventDefault(),lt(e.shiftKey?`agent`:`session`))};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[t,Ue,lt]);let ut=y.isError?y.variables:null,dt=ut&&A!==`session`?(0,X.jsx)(zx,{className:w||c.selected?`inbox-error m-2`:`inbox-empty m-auto max-w-[28rem]`,tone:`error`,title:`Couldn't start the conversation.`,description:y.error?.message,action:(0,X.jsx)(BT,{variant:`outline`,onClick:()=>void ke(ut.agentId),children:`Retry`})}):null;return(0,X.jsxs)(`main`,{className:`inbox-app grove-shell relative flex h-dvh min-h-0 bg-base-200 font-sans text-base-content`,"data-inbox-app":!0,"data-conversation":!!w||c.selected!==void 0,children:[t?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(P0,{open:A===`agent`,pending:v,error:ce,computers:d.isError?{status:`unavailable`,message:`Your Computers could not be loaded. New Computer and No Computer still work.`}:d.isPending?{status:`loading`}:d.data===null?{status:`not-offered`}:{status:`offered`,computers:d.data},create:Oe,onClose:()=>{j(null)},returnFocus:M}),A===`session`?(0,X.jsx)(F0,{open:!0,agents:We?Ge:[],defaultAgentId:Ke?.agentId??null,start:ke,pending:x!==null,onClose:()=>{j(null)},onNewAgent:Ue?()=>{j(`agent`)}:void 0,returnFocus:M}):null]}):null,(0,X.jsxs)(rZ,{open:R,onOpenChange:ie,returnFocus:z,children:[(0,X.jsx)(ZX,{open:F,agents:h,agentActivity:Ie,agentFilterId:r,websitesSelected:E,websitesVisible:c.canRead,canCreate:t!==null&&Ue,createOpen:A===`agent`,onAll:()=>{i(null),D(!1)},onWebsites:()=>{i(null),D(!0)},onAgent:e=>{D(!1),$e(e)},onCreate:()=>{lt(`agent`)}}),(0,X.jsxs)(`aside`,{id:`grove-list-rail`,className:`inbox-sidebar group relative min-h-0 min-w-0 flex-1 flex-col border-r border-base-300 min-[900px]:w-[var(--grove-list-width)] min-[900px]:flex-none ${I?`flex`:`flex min-[900px]:hidden`}`,style:et,"aria-label":`Conversations`,children:[ae?(0,X.jsx)(N8,{"aria-label":`Conversation list width`,"aria-controls":`grove-list-rail`,className:`absolute right-0 top-1/2 z-10 translate-x-1/2 -translate-y-1/2`,orientation:`vertical`,value:L,min:I8.min,max:I8.max,onValueChange:e=>{ne(()=>e)},onDoubleClick:()=>{ne(()=>I8.initial)},...re}):null,(0,X.jsxs)(`header`,{className:`inbox-header flex h-10 flex-none items-center gap-1 border-b border-base-300 pl-3 pr-1`,children:[V?(0,X.jsx)(M8,{agentId:V.agentId,name:YX(V),avatar:V.avatar,...rt?{setAvatar:st}:{}},V.agentId):null,(0,X.jsx)(Hx,{className:`min-w-0 flex-1 truncate`,children:E&&c.canRead?`Websites`:V?YX(V):`All Agents`}),V&&nt?(0,X.jsx)(w8,{agentId:V.agentId,name:V.name,rename:ot},V.agentId):null,t&&(qe||Ue)?(0,X.jsx)(LG,{"aria-label":`New conversation`,"aria-haspopup":`dialog`,icon:(0,X.jsx)(fW,{}),iconSize:`sm`,size:`sm`,onClick:()=>{lt(`session`)}}):null]}),V&&it.canRead?(0,X.jsx)(T8,{status:it.status.data,approving:it.approve.isPending,onApprove:ct}):null,Ye?(0,X.jsx)(zx,{tone:`info`,title:Ye,action:(0,X.jsx)(BT,{variant:`ghost`,onClick:()=>{t?.ui.requestAppPermissions({agents:b5}).catch(e=>{console.error(`Chat inbox or permission request failed`,e)})},children:`Allow conversation access`})}):null,t&&h.length>0&&!qe&&!Ue?(0,X.jsxs)(`section`,{className:`inbox-create inbox-access flex flex-col items-start gap-3 border-b border-base-300 py-2`,"aria-labelledby":`inbox-agent-access-title`,children:[(0,X.jsx)(Kx,{level:2,id:`inbox-agent-access-title`,className:`inbox-access-title m-0`,children:`Let Grove manage your Agents`}),(0,X.jsx)(`p`,{children:`Grove creates Agents and carries their conversations. Your Team decides what it may do.`}),(0,X.jsx)(BT,{size:`sm`,onClick:Je,children:`Allow Agent access`})]}):null,b.error?(0,X.jsx)(zx,{tone:`error`,title:b.error.message}):null,_?(0,X.jsx)(zx,{className:`inbox-error`,tone:`error`,title:_,action:(0,X.jsx)(BT,{variant:`ghost`,size:`sm`,onClick:()=>{l.refetch()},children:`Try again`})}):null,He?(0,X.jsx)(zx,{className:`inbox-error`,tone:`error`,title:`Conversations are unavailable.`,action:(0,X.jsx)(BT,{variant:`ghost`,size:`sm`,onClick:()=>{u.refresh()},children:`Retry conversations`})}):null,(0,X.jsx)(DA,{ref:Re,className:`inbox-surface min-h-0 flex-1`,"aria-label":`Conversations`,children:t?g?(0,X.jsx)(`p`,{className:`inbox-empty m-0 px-2 py-3 text-sm text-(--stipe-fg-muted)`,role:`status`,children:`Loading Agents…`}):(0,X.jsx)(X8,{viewport:Re,view:Fe,agents:Le,loading:Ve||c.loading,failed:!!_||He||c.failed,pendingSelection:S,selectedAgentId:O,selectedSessionId:k,onSelect:Ze,onDelete:We?(e,t)=>{b.mutate({agentId:e,sessionId:t})}:void 0,deleting:b.isPending?b.variables:null,websites:c.rows.filter(e=>r===null||e.agentId===r),selectedWebsite:c.selected,onSelectWebsite:e=>{_e?.clear(),ie(!1),c.select(e)}}):(0,X.jsx)(`p`,{className:`inbox-empty m-0 px-2 py-3 text-sm text-(--stipe-fg-muted)`,children:`Connect to the host to browse Agents.`})},r)]})]}),(0,X.jsxs)(`section`,{className:`inbox-conversation-shell flex min-h-0 min-w-0 flex-1 flex-col`,"aria-label":`Conversation`,children:[(0,X.jsx)(QX,{app:t}),de?(0,X.jsx)(zx,{className:`inbox-error m-2`,tone:`error`,title:de}):null,w||c.selected?dt:null,c.selected?(0,X.jsx)(g5,{inbox:c}):w?(0,X.jsx)(C5,{open:w,connection:t,commands:Ae,renderConversation:n.renderConversation,composeDraft:pe,onPrefilled:()=>{me(null)},onForked:De,onOpen:Se}):!t||g?null:h.length===0&&!_?(0,X.jsx)(q8,{className:`inbox-empty m-auto max-w-[28rem]`,variant:`speech`,thinking:v,renderVisual:({speaking:e,thinking:t})=>(0,X.jsx)(PX,{className:`h-full w-full`,state:{activity:t?`thinking`:e?`speaking`:`idle`,expression:`normal`}}),title:Ue?`No one's here yet.`:`Welcome to Grove`,description:Ue?`Agents chat, write and make little games with you. Name someone?`:`Let Grove find your Agents, create new ones, and open conversations. Your Team controls this access.`,actions:Ue?(0,X.jsx)(BT,{onClick:()=>{lt(`agent`)},children:`Name your first Agent`}):(0,X.jsx)(BT,{onClick:Je,children:`Allow Agent access`})}):dt??(0,X.jsx)(q8,{className:`inbox-empty m-auto max-w-[28rem]`,variant:`panel`,title:at>0?`Pick up a conversation`:Ke?`Say hello to ${YX(Ke)}`:`No conversations yet`,description:at>0?`Choose one from the list, or ask for something new. A tiny game is a good start.`:`Ask for anything. Try: “Make me a tiny game where a mushroom catches raindrops.”`,actions:(0,X.jsxs)(X.Fragment,{children:[ae||at===0?null:(0,X.jsx)(BT,{variant:`outline`,"aria-haspopup":`dialog`,"aria-controls":`grove-nav`,"aria-expanded":R,onClick:Qe,children:`Agents and conversations`}),qe?(0,X.jsx)(BT,{variant:`outline`,loading:x===Ke.agentId,disabled:x!==null,onClick:()=>void ke(Ke.agentId),children:at>0?`Ask ${YX(Ke)} something`:`Start a conversation`}):null]})})]}),ve===null?null:(0,X.jsx)(`section`,{className:`inbox-conversation-shell flex min-h-0 min-w-0 flex-1 flex-col border-l border-base-300`,"aria-label":`Beside conversation`,"data-inbox-beside":!0,children:(0,X.jsx)(C5,{open:ve,connection:t,commands:be,renderConversation:n.renderConversation,composeDraft:null,onPrefilled:()=>void 0,onForked:e=>{xe?.select(ve.agentId,e)},onOpen:Se,label:`Beside conversation`})})]})}var D5=document.getElementById(`inbox-root`);if(!D5)throw Error(`Inbox root is missing`);Lm(D5,{name:`Grove`,queryClient:nb()},({app:e})=>(0,J.createElement)(w5,{connection:e}));export{oC as $,BT as A,nw as B,QF as C,gj as D,qM as E,Vw as F,_C as G,BC as H,Fw as I,mC as J,pC as K,vw as L,iT as M,Uw as N,oj as O,Bw as P,lC as Q,hw as R,XF as S,ZF as T,WC as U,KC as V,hC as W,UC as X,gC as Y,VC as Z,rW as _,jo as _t,RK as a,Wx as at,QI as b,mr as bt,lG as c,Gx as ct,iG as d,eb as dt,MS as et,rG as f,qm as ft,$W as g,Gm as gt,eG as h,Ym as ht,YY as i,TS as it,vT as j,ej as k,sG as l,Kx as lt,QW as m,Jm as mt,l0 as n,nC as nt,LK as o,qx as ot,tG as p,Km as pt,fC as q,uX as r,jS as rt,eK as s,Jx as st,f0 as t,RS as tt,oG as u,Q as ut,eW as v,ea as vt,iI as w,oI as x,cL as y,yr as yt,cw as z};
|
|
174
|
+
`),header:e.label,...e.language===void 0?{}:{language:e.language}}),(0,X.jsx)(tX,{hidden:i,onShowAll:n})]})}}}function iX({call:e,tool:t,disclosure:n,onToggle:r,mediaClaimed:i}){let a=`${e.id}:full`,o=FP(n,a,!1),s=()=>{r(a,!1)};return(0,X.jsxs)(`div`,{className:`space-y-1.5 py-1.5 pr-2`,"data-parakeet-call-body":!0,children:[e.error===void 0?null:(0,X.jsx)(`p`,{className:`not-prose m-0 font-mono text-[11px] text-error`,role:`alert`,children:e.error}),e.sections.map((e,t)=>(0,X.jsx)(rX,{full:o,onShowAll:s,section:e},`${e.kind}:${String(t)}`)),(i?[]:t?.result?.content??[]).filter(e=>e.type===`image`).map((t,n)=>(0,X.jsx)(`img`,{alt:`Tool result`,className:`max-w-full`,src:`data:${t.mimeType};base64,${t.data}`,style:{maxHeight:400}},`${e.id}-image-${String(n)}`))]})}function aX({call:e,tool:t,disclosureId:n,size:r,disclosure:i,onToggle:a,renderToolActions:o,claimsToolMedia:s}){let c=PP(e),l=FP(i,n,c),u=e.status===`running`;return(0,X.jsxs)(`div`,{"data-parakeet-call":e.kind,"data-status":e.status,children:[(0,X.jsx)(IK,{leading:(0,X.jsx)(Xq,{name:jN[e.kind],size:16}),onOpenChange:()=>{a(n,c)},open:l,size:r,summary:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`text-base-content`,children:u?e.activeVerb:e.verb}),` `,(0,X.jsx)(`span`,{className:`font-mono`,children:e.label})]}),tone:e.status===`error`?`error`:`neutral`,trailing:(0,X.jsxs)(X.Fragment,{children:[e.exitCode===void 0?null:(0,X.jsxs)(YY,{size:`sm`,tone:`error`,children:[`exit `,String(e.exitCode)]}),e.durationMs===void 0?null:(0,X.jsx)(`span`,{children:CP(e.durationMs)}),(0,X.jsx)(FG,{motion:u?`bounce`:`none`,title:e.status===`unknown`?`result unavailable`:e.status,tone:AN(e.status)})]}),children:(0,X.jsx)(iX,{call:e,disclosure:i,onToggle:a,mediaClaimed:t!==void 0&&s?.(t)===!0,tool:t})}),e.live===void 0?null:(0,X.jsx)(`pre`,{className:nX,"aria-label":`Live tool output`,children:NN(e,l).map((e,t)=>(0,X.jsx)(`span`,{className:`block whitespace-pre`,children:e||`\xA0`},String(t)))}),e.status===`completed`&&t?.result!==void 0?o?.(t):null]})}var oX=(0,J.memo)(function({group:e,disclosure:t,onToggle:n,renderToolActions:r,claimsToolMedia:i}){let a=MP(e),o=FP(t,e.id,a),s=e.status===`running`,c=e.active,l=e.calls.length===1?e.calls[0]:void 0;return l===void 0?(0,X.jsxs)(`div`,{className:`px-1`,children:[(0,X.jsx)(IK,{className:`[&>.caps-disclosure-panel]:hidden`,leading:(0,X.jsx)(Xq,{name:`list`,size:16}),onOpenChange:()=>{n(e.id,a)},open:o,summary:s&&c!==void 0?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`text-base-content`,children:c.activeVerb}),` `,(0,X.jsx)(`span`,{className:`font-mono`,children:c.label}),` ·`,` `,String(e.calls.length),` `,e.calls.length===1?`call`:`calls`]}):(0,X.jsxs)(`span`,{className:`text-base-content`,children:[e.summary,` · `,String(e.calls.length),` `,e.calls.length===1?`call`:`calls`]}),tone:e.status===`error`?`error`:`neutral`,trailing:(0,X.jsxs)(X.Fragment,{children:[e.failedCount>0?(0,X.jsxs)(`span`,{className:`text-error`,children:[String(e.failedCount),` failed`]}):null,e.durationMs===void 0?null:(0,X.jsx)(`span`,{children:CP(e.durationMs)}),(0,X.jsx)(FG,{motion:s?`bounce`:`none`,title:e.status===`unknown`?`result unavailable`:e.status,tone:AN(e.status)})]})}),NP(e,o).map(a=>(0,X.jsx)(aX,{call:a,disclosure:t,disclosureId:a.id,onToggle:n,renderToolActions:r,claimsToolMedia:i,size:`row`,tool:e.tools.find(e=>e.id===a.id)},a.id)),e.status===`completed`&&e.calls.length>3?(0,X.jsx)(`button`,{"aria-expanded":o,className:`btn btn-ghost btn-xs text-dim`,onClick:()=>{n(e.id,a)},type:`button`,children:o?`Show less`:`Show all ${String(e.calls.length)} calls`}):null]}):(0,X.jsx)(`div`,{className:`px-1`,children:(0,X.jsx)(aX,{call:l,disclosure:t,disclosureId:l.id,onToggle:n,renderToolActions:r,claimsToolMedia:i,size:`row`,tool:e.tools[0]})})}),sX=()=>void 0,cX={nothing_to_compact:`nothing to compact`,failed:`compaction failed`,stale:`compaction skipped: the context moved on`,insufficient:`compaction skipped: the summary would not fit`},lX=(0,J.memo)(function({item:e,onDismissFailed:t,onCancelQueued:n,cancellingQueued:r=!1,renderToolActions:i,claimsToolMedia:a,renderAssistantAttachment:o,formatAssistantText:s,toolDisclosure:c=jP,onToggleTool:l=sX}){switch(e.kind){case`user_message`:{let i=e.status===`pending`||e.status===`queued`,a=e.requestId,o=e.commandId,s=e.status===`queued`&&o!==void 0&&n!==void 0?(0,X.jsx)(`div`,{className:`flex justify-end px-3`,children:(0,X.jsx)(BT,{"aria-label":`Cancel queued message`,disabled:r,size:`sm`,variant:`ghost`,onClick:()=>{n(o)},children:`Cancel`})}):null,u=a===void 0||t===void 0?null:(0,X.jsx)(BT,{"aria-label":`Dismiss failed prompt`,variant:`outline`,size:`xs`,onClick:()=>{t(a)},type:`button`,children:`Dismiss`}),d=e.status===`failed`?(0,X.jsxs)(`div`,{className:`flex items-center gap-2 px-3 text-xs text-error`,role:`alert`,children:[(0,X.jsx)(`span`,{children:e.author?.kind===`agent`?`That Agent message didn’t make it through.`:`Your prompt didn’t make it through.`}),u]}):null;if(e.author?.kind===`agent`){let t=FP(c,e.id,!1);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:e.status===`confirmed`?`px-3 text-xs`:`px-3 text-xs opacity-60`,"data-agent-message":e.author.id,"data-author":e.author.id,children:[(0,X.jsx)(KY,{pending:i}),(0,X.jsxs)(`button`,{"aria-expanded":t,className:`text-dim flex w-full min-w-0 items-center gap-sm text-left`,onClick:()=>{l(e.id,!1)},type:`button`,children:[(0,X.jsx)(`span`,{className:`flex shrink-0`,children:(0,X.jsx)(Xq,{name:`agent`,size:16})}),(0,X.jsx)(`span`,{className:`shrink-0`,children:e.author.name}),t?null:(0,X.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`· `,e.text]})]}),t?(0,X.jsx)(`div`,{className:`whitespace-pre-wrap break-words pl-3`,children:e.text}):null]}),d,s]})}return(0,X.jsxs)(X.Fragment,{children:[e.author?(0,X.jsx)(`div`,{className:`px-3 text-xs text-dim`,"data-author":e.author.id,children:e.author.name}):null,(0,X.jsx)(qY,{pending:i,speaker:`user`,children:e.text}),d,s]})}case`assistant_message`:return MM(e)?(0,X.jsxs)(X.Fragment,{children:[e.author?(0,X.jsx)(`div`,{className:`px-3 text-xs text-dim`,"data-author":e.author.id,children:e.author.name}):null,(0,X.jsx)(qY,{isError:e.isError===!0,pending:e.pending,speaker:`agent`,...e.thinking?{thinking:e.thinking}:{},children:s?.(e.text)??e.text}),e.isError&&e.repeatCount!==void 0?(0,X.jsxs)(`span`,{className:`px-3 text-error`,children:[`x`,e.repeatCount]}):null,e.isError&&e.errorDetail?(0,X.jsx)(`p`,{className:`px-3 text-dim`,children:e.errorDetail}):null,e.isError&&e.providerError!==void 0?(0,X.jsx)(`div`,{className:`px-3 text-error`,"data-provider-error":e.id,children:(0,X.jsxs)(`details`,{children:[(0,X.jsx)(`summary`,{children:`Provider details (latest response)`}),(0,X.jsx)(`pre`,{className:`whitespace-pre-wrap`,children:e.providerError})]})}):null,!e.pending&&!e.isError?o?.(e.text):null]}):null;case`tool_group`:return(0,X.jsx)(oX,{disclosure:c,group:e,onToggle:l,renderToolActions:i,claimsToolMedia:a});case`compaction_divider`:return(0,X.jsx)(`div`,{className:`divider text-dim my-2 text-xs`,role:`separator`,children:e.tokensAfter===null?`compacted · the agent’s memory starts below`:`compacted ${NA(e.tokensBefore)} → ${NA(e.tokensAfter)}`});case`compaction_notice`:return(0,X.jsxs)(`div`,{className:`px-3 text-xs ${e.result===`failed`?`text-error`:`text-dim`}`,role:`status`,children:[`· `,cX[e.result],e.diagnostic===null?``:`: ${e.diagnostic}`]})}});function uX({disambiguateAuthors:e,visitor:t,composerActionVariant:n,empty:r,commands:i,renderToolActions:a,claimsToolMedia:o,renderAssistantAttachment:s,formatAssistantText:c,onLink:l,onOpen:u}){let d=(0,J.useRef)(null),[f]=(0,J.useState)(()=>Zr()),p=cR({enabled:t===void 0,commands:i??f,origin:`browser`,keys:{newline:`Shift+Enter`},busy:fX()}),m=iz(i??f),h=rI(),{draft:g}=QF(),_=ZL(p.awaiting,g)?.key,v=ZF(),y=(0,J.useMemo)(()=>cz(h,v.commandAnchors,v.positionAnchors),[h,v.commandAnchors,v.positionAnchors]);return(0,X.jsxs)(`div`,{className:`parakeet flex h-full flex-col items-stretch`,"data-parakeet":`standalone`,"data-testid":`parakeet-view`,onClickCapture:e=>{let t=e.target instanceof Element?e.target.closest(`a[href]`):null;t instanceof HTMLAnchorElement&&l?.(t.href)&&e.preventDefault()},children:[(0,X.jsxs)(`div`,{className:`flex h-full w-full flex-col border-r border-base-300`,children:[(0,X.jsx)(mX,{disambiguateAuthors:t===void 0&&e===!0,clientActions:m,onOpen:u,focusAfterJump:d,empty:r,renderToolActions:a,claimsToolMedia:o,renderAssistantAttachment:s,formatAssistantText:c}),h.some(({entryId:e,value:t})=>t.panel.some(t=>JSON.stringify([e,t.id])!==_))?(0,X.jsx)(`section`,{"aria-label":`Session extension controls`,className:`w-full shrink-0 border-t border-base-300 bg-base-100`,children:h.map(({entryId:e,value:t})=>{let n={...t,panel:t.panel.filter(t=>JSON.stringify([e,t.id])!==_)},r=n.panel.length===0?void 0:y.omitted.find(t=>t.entryId===e),i=n.panel.length===0?[]:y.unanchored.filter(t=>t.entryId===e).flatMap(({cell:e})=>e.rows.map(t=>({...t,id:`unanchored:${e.id}:${t.id}`})));return(0,X.jsx)(Sq,{entryId:e,rows:[...n.panel,...r===void 0?[]:[{id:`omitted:${e}`,title:`${String(r.count)} earlier change${r.count===1?``:`s`} omitted`,tone:`muted`}],...i],actions:m,onOpen:u},e)})}):null,(0,X.jsx)(hX,{clientActions:m}),(0,X.jsx)(gX,{visitor:t,textareaRef:d,composerActionVariant:n,slash:p})]}),t===void 0?(0,X.jsx)(pX,{slash:p}):null]})}var dX=new Set([`cancelling`,`queued`,`retrying`,`sending`,`streaming`,`thinking`]);function fX(){return dX.has(nI().status)}function pX({slash:e}){let t=e.interactions.open;return(0,X.jsx)(IU,{open:t!==void 0,onOpenChange:t=>{t||e.store.close()},children:(0,X.jsx)(VU,{className:`w-[min(32rem,calc(100vw-2rem))] rounded-box bg-base-100 p-md shadow-lg`,keepMounted:!1,children:t===void 0?null:(0,X.jsx)(rq,{host:t.host,onClose:e.store.close},t.key)})})}function mX({disambiguateAuthors:e,clientActions:t,onOpen:n,focusAfterJump:r,empty:i,renderToolActions:a,claimsToolMedia:o,renderAssistantAttachment:s,formatAssistantText:c}){let l=$F(),u=ZF(),d=(0,J.useCallback)(e=>{u.cancelQueued(e)},[u.cancelQueued]),f=(0,J.useMemo)(()=>BA(e?[...u.settled,...u.tail].flatMap(e=>`author`in e&&e.author?[e.author]:[]):[]),[e,u.settled,u.tail]),p=cz(rI(),u.commandAnchors,u.positionAnchors),m=p.before.map(({entryId:e,cell:r})=>(0,X.jsx)(Sq,{entryId:e,rows:r.rows,actions:t,onOpen:n},`${e}:${r.id}`)),[h,g]=(0,J.useState)(jP),_=(0,J.useCallback)((e,t)=>{g(n=>IP(n,e,t))},[]),v=nI(),y=(0,J.useRef)(null),b=(0,J.useRef)(void 0),x=u.settled.length+u.tail.length,S=(0,J.useCallback)(e=>e<u.settled.length?u.settled[e]:u.tail[e-u.settled.length],[u.settled,u.tail]),C=GW({anchorTo:`end`,count:x,estimateSize:()=>72,followOnAppend:`auto`,getItemKey:JW(u.settled,u.tail),getScrollElement:()=>y.current,initialRect:{height:800,width:800},overscan:6,useFlushSync:!1}),w=C.getVirtualItems(),T=C.isAtEnd(),[E,D]=(0,J.useState)(0),O=x>0?S(x-1)?.id:void 0,k=(0,J.useRef)({count:x,lastItem:O});(0,J.useEffect)(()=>{let e=k.current;k.current={count:x,lastItem:O},T?D(0):e.lastItem!==void 0&&O!==e.lastItem&&D(t=>t+Math.max(1,x-e.count))},[T,x,O]);let A=(w[0]?.index??1/0)<3,{hasMoreHistory:j,hasNewerHistory:M,loadingOlderHistory:N,loadOlderHistory:P,loadNewerHistory:F}=u,I=(0,J.useRef)(!1);(0,J.useEffect)(()=>{if(!A){I.current=!1;return}j&&!N&&!I.current&&(I.current=!0,P())},[j,P,N,A]);let L=(0,J.useCallback)(()=>{D(0),b.current=void 0,u.jumpToLatest(),C.scrollToEnd({behavior:`smooth`})},[C,u]);return(0,X.jsxs)(`div`,{className:`prose relative min-h-0 flex-1`,children:[(0,X.jsx)(`div`,{"aria-live":`polite`,"aria-atomic":`true`,className:`sr-only`,children:hq(v.status,v.viewState)}),v.observation.status===`unavailable`?(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-1 text-xs text-dim`,role:`status`,children:[(0,X.jsx)(`span`,{children:v.observation.reason}),(0,X.jsx)(BT,{variant:`outline`,size:`xs`,onClick:()=>void v.reconnect(),type:`button`,children:`Reconnect`})]}):null,(0,X.jsx)(`div`,{className:`h-full min-h-0 overflow-y-auto`,"data-chat-scroller":!0,ref:y,onScroll:e=>{let t=e.currentTarget.scrollTop;b.current!==void 0&&t<b.current&&u.pinVisibleHistory(),b.current=t},onWheel:e=>{let t=y.current;t===null||N||(e.deltaY<0&&u.pinVisibleHistory(),e.deltaY<0&&t.scrollTop<=1&&j&&P(),e.deltaY>0&&t.scrollTop+t.clientHeight>=t.scrollHeight-1&&M&&F())},style:{overscrollBehavior:`contain`},children:x>0?(0,X.jsx)(`div`,{className:`relative w-full`,style:{height:`${String(C.getTotalSize())}px`},children:w.map(e=>{let r=S(e.index);return r===void 0?null:(0,X.jsxs)(`div`,{"data-index":e.index,"data-parakeet-entry":r.kind===`user_message`?`user`:r.kind,"data-parakeet-id":r.id,"data-status":r.kind===`assistant_message`?r.isError?`error`:void 0:r.kind===`compaction_divider`||r.kind===`compaction_notice`?void 0:r.status,"data-tone":r.kind===`assistant_message`&&r.isError?`error`:void 0,ref:C.measureElement,style:{left:0,position:`absolute`,top:0,transform:`translateY(${String(e.start)}px)`,width:`100%`},children:[e.index===0?m:null,(0,X.jsx)(lX,{item:`author`in r&&r.author&&f.has(r.author.id)?{...r,author:{...r.author,name:f.get(r.author.id)??r.author.name}}:r,onDismissFailed:l,onCancelQueued:d,cancellingQueued:u.cancellingQueued,onToggleTool:_,renderToolActions:a,claimsToolMedia:o,renderAssistantAttachment:s,formatAssistantText:c,toolDisclosure:h}),p.after.get(r.id)?.map(({entryId:e,cell:r})=>(0,X.jsx)(Sq,{entryId:e,rows:r.rows,actions:t,onOpen:n},`${e}:${r.id}`))]},e.key)})}):m.length>0?m:j?null:i??(0,X.jsx)(`div`,{className:`flex h-full items-center justify-center text-center`,children:(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`mb-1 text-xs text-base-content`,children:`Ready`}),(0,X.jsx)(`p`,{className:`text-[10px] text-dim`,children:`What would you like to build?`})]})})}),x>0?(0,X.jsx)(xW,{direction:`forward`,unread:E,focusAfterJump:r,onJump:L,scrollerRef:y}):null]})}function hX({clientActions:e}){let{viewState:t}=nI(),n=rI(),r=t.kind===`idle`?n.find(({value:e})=>e.waiting!==null):void 0;return(0,X.jsx)(X.Fragment,{children:r?.value.waiting===void 0||r.value.waiting===null?null:(0,X.jsxs)(`div`,{className:`flex items-center gap-2 px-3 text-xs`,children:[(0,X.jsx)(`span`,{children:r.value.waiting.summary}),(0,X.jsx)(BT,{size:`xs`,variant:`outline`,disabled:!e.enabled||e.state.get(r.value.waiting.cancel)?.pending===!0,onClick:()=>{r.value.waiting!==null&&e.execute(r.entryId,r.value.waiting.cancel,!0)},children:r.value.waiting.cancel.label})]})})}function gX({visitor:e,textareaRef:t,composerActionVariant:n,slash:r}){let i=QF(),a=nI(),o=rI(),s=ZF();(0,J.useEffect)(()=>{i.failure!==void 0&&t.current?.focus()},[i.failure,t]);let c=(0,J.useCallback)(()=>{i.cancel()},[i.cancel]),l={queuedRecall:e===void 0?i:void 0,onImagesChange:e===void 0?i.setImages:void 0,statusChips:o.flatMap(({value:e})=>e.chips).sort((e,t)=>e.order-t.order).map(({row:e})=>e.title),actionVariant:n,draft:i.draft,failure:i.failure,failureCause:a.viewState.kind===`error`?a.viewState.cause:void 0,admissionError:i.admissionError,onAbort:c,onChange:i.setDraft,onRetry:i.retry,onSend:r.submit,slash:e===void 0?r:void 0,placeholder:e===void 0?void 0:`Ask ${e.agentName}…`,showFooter:e===void 0,status:a.status,viewState:a.viewState,textareaRef:t,model:s.model,usage:s.usage,context:a.context};return(0,X.jsx)(bq,{...l})}function _X({authorOf:e,disambiguateAuthors:t,visitor:n,markdownPolicy:r=`session`,composerActionVariant:i,empty:a,session:o,clients:s,renderToolActions:c,claimsToolMedia:l,renderAssistantAttachment:u,formatAssistantText:d,commands:f,onLink:p,onOpen:m}){return(0,X.jsx)(HY.Provider,{value:r,children:(0,X.jsx)(XF,{session:o,clients:s,authorOf:e,children:(0,X.jsx)(uX,{disambiguateAuthors:t,visitor:n,composerActionVariant:i,empty:a,renderToolActions:c,claimsToolMedia:l,renderAssistantAttachment:u,formatAssistantText:d,commands:f,onLink:p,onOpen:m})})})}function vX(e){let t=2166136261;for(let n of e)t^=n.codePointAt(0)??0,t=Math.imul(t,16777619)>>>0;return t}var yX=[`primary`,`secondary`,`accent`,`info`,`success`,`warning`];function bX(e){return yX[vX(e)%yX.length]??`primary`}var xX=(0,J.forwardRef)(function({className:e,name:t,seed:n,size:r=`default`,subject:i=`actor`,variant:a=`initial`,...o},s){let c=Array.from(t.trim())[0]?.toLocaleUpperCase()??`?`;return(0,X.jsx)(`span`,{"aria-hidden":`true`,...o,className:Q(`caps-monogram`,e),"data-subject":i===`actor`?void 0:i,"data-size":r==="default"?void 0:r,"data-tone":bX(n??t),ref:s,children:a===`specimen`?(0,X.jsx)(`svg`,{viewBox:`0 0 48 48`,width:`80%`,height:`80%`,fill:`none`,"aria-hidden":`true`,children:(0,X.jsxs)(`g`,{transform:`rotate(${String((n??t).split(``).reduce((e,t)=>e+(t.codePointAt(0)??0),0)%360)} 24 24)`,stroke:`currentColor`,strokeWidth:`1.5`,children:[Array.from({length:20},(e,t)=>(0,X.jsx)(`path`,{d:`M24 19 Q19 12 24 5`,transform:`rotate(${String(t*18)} 24 24)`},t)),(0,X.jsx)(`circle`,{cx:`24`,cy:`24`,r:`5`})]})}):c})}),SX=(0,J.createContext)(null),CX=(0,J.createContext)(void 0);function wX(e){let t=(0,J.useContext)(CX);return e??t}var TX=(0,J.forwardRef)(function({service:e,src:t,activity:n,expression:r,appearance:i,renderStyle:a,performance:o,timeMs:s,paused:c=!1,onState:l,...u},d){let f=wX(s),p=f!==void 0,m=(0,J.useContext)(SX),h=e??m;if(!h)throw Error(`Sprite needs a configured SpriteProvider or service`);let g=(0,J.useRef)(null),_=(0,J.useRef)(null),v=(0,J.useRef)(l);return v.current=l,(0,J.useImperativeHandle)(d,()=>{if(!g.current)throw Error(`Sprite host is not mounted`);return g.current}),(0,J.useEffect)(()=>{if(!g.current)return;let e=h.mount(g.current),t=e.subscribe(e=>{g.current&&(g.current.dataset.spriteStatus=e.status),v.current?.(e)});return _.current=e,()=>{t(),e.dispose().catch(e=>{console.error(`Sprite cleanup failed`,e)}),_.current=null}},[h]),(0,J.useEffect)(()=>{let e=_.current;if(!e)return;let s={src:t};n!==void 0&&(s={...s,activity:n}),r!==void 0&&(s={...s,expression:r}),i!==void 0&&(s={...s,appearance:i}),a!==void 0&&(s={...s,renderStyle:a}),o!==void 0&&(s={...s,performance:o}),f!==void 0&&(s={...s,timeMs:f}),e.set(s)},[h,t,n,r,i,a,o,f]),(0,J.useEffect)(()=>{_.current?.pause(c||p)},[h,c,p]),(0,X.jsx)(`div`,{...u,ref:g})});function EX(e){return{src:{local:e.character},appearance:e.appearance,expression:e.expression,renderStyle:e.renderStyle}}function DX(e){for(let[t,n]of Object.entries({maxBytes:e.maxBytes,maxTotalBytes:e.maxTotalBytes,maxRequests:e.maxRequests}))if(!Number.isSafeInteger(n)||n<=0)throw Error(`Avatar ${t} must be a positive safe integer`);let t=new Set(e.allowedOrigins.map(e=>new URL(e).origin)),n=e.fetch??globalThis.fetch;return()=>{let r=0,i=0;return async(a,o,s=e.baseURL)=>{let c=new URL(a,s);if(![`http:`,`https:`].includes(c.protocol)||!t.has(c.origin)||c.username||c.password)throw Error(`Avatar asset is not admitted: ${c.origin}`);if(i+=1,i>e.maxRequests)throw Error(`Avatar asset request limit reached`);let l=await n(c.href,{signal:o,redirect:`error`});if(!l.ok)throw Error(`Avatar asset request failed: ${String(l.status)}`);let u=Number(l.headers.get(`content-length`));if(u>e.maxBytes||u>e.maxTotalBytes-r)throw await l.body?.cancel(),Error(`Avatar asset exceeds the byte limit`);let d=l.body?.getReader();if(!d)throw Error(`Avatar asset has no response body`);let f=[],p=0;try{for(;;){o.throwIfAborted();let t=await d.read();if(t.done)break;if(p+=t.value.byteLength,p>e.maxBytes)throw Error(`Avatar asset exceeds the byte limit`);if(t.value.byteLength>e.maxTotalBytes-r)throw Error(`Avatar selection exceeds the total byte limit`);r+=t.value.byteLength,f.push(t.value)}}catch(e){let t=await d.cancel().then(()=>({kind:`cancelled`}),e=>({kind:`failed`,error:e instanceof Error?e:Error(String(e))}));throw t.kind===`failed`?AggregateError([e,t.error],`Avatar asset read and cancellation failed`,{cause:e}):e}finally{d.releaseLock()}let m=new Uint8Array(p),h=0;for(let e of f)m.set(e,h),h+=e.byteLength;return{url:c.href,bytes:m,contentType:l.headers.get(`content-type`)??`application/octet-stream`}}}}var OX=(e,t)=>{let n=ir.safeParse(e);return n.success?{kind:`local`,key:n.data.local}:{kind:`remote`,url:new URL(V().parse(e),t).href}},kX=e=>e instanceof Error?e:Error(String(e),{cause:e}),AX=e=>Sn(e)?kX(vt(e.cause)):Error(`Unexpected Sprite success`);function jX(e){let t=e.maxPixels??4194304;if(!Number.isSafeInteger(t)||t<=0)throw Error(`Sprite pixel limit must be a positive safe integer`);let n=e.assets??{baseURL:`https://sprite.invalid/`,allowedOrigins:[],maxBytes:1,maxTotalBytes:1,maxRequests:1},r=DX(n),i=new WeakSet,a=new WeakMap,o=e=>{let t=OX(e,n.baseURL);return t.kind===`remote`?t.url:`local:${t.key}`};return{mount(s){if(i.has(s))throw Error(`A Sprite already owns this target`);i.add(s);let c=_e(ln()),l=new Set,u={status:`empty`},d,f,p=0,m=!1,h,g,_,v=!1,y=!1,b=s.ownerDocument.defaultView?.matchMedia(`(prefers-reduced-motion: reduce)`),x=e=>{if(!(v&&e.status!==`destroyed`)){u=e;for(let t of l)try{t(e)}catch(e){console.error(`Sprite state observer failed`,e)}}},S=e=>{f?.controller.abort(),f?.holder.remove(),x({status:`error`,error:e}),T().catch(t=>{x({status:`error`,error:AggregateError([e,t],`Avatar failed and cleanup also failed`)})})},C=Fh(s),w=()=>{let e=y||s.ownerDocument.hidden||b?.matches===!0;C.still(e);try{f?.native?.pause(e)}catch(e){S(kX(e))}};_e(Rn(c,ze(()=>{s.ownerDocument.removeEventListener(`visibilitychange`,w),b?.removeEventListener(`change`,w),C.dispose()}))),s.ownerDocument.addEventListener(`visibilitychange`,w),b?.addEventListener(`change`,w);let T=async()=>{if(g)return g;let e=f;if(!e)return;f=void 0,e.controller.abort(),e.holder.remove();let t=Ye(Un(e.scope,Tn)).then(e=>{if(Sn(e))throw AX(e)});g=t;try{await t}finally{g===t&&(g=void 0)}},E=e=>{let t=e.native,n=e.document,r=d;if(!t||!n||!r||f!==e)return;let i=r.activity??`idle`,a=r.expression??t.expressions[0]??null,o,s;try{o=ar(n.controls,r.appearance),s=lh.parse(r.renderStyle??`plain`)}catch(e){let t=kX(e);u.status===`ready`?u.updateError?.message!==t.message&&x({...u,updateError:t}):S(t);return}let c={requestedActivity:i,requestedExpression:a,activity:t.activities.includes(i)?i:`idle`,expression:a!==null&&t.expressions.includes(a)?a:t.expressions[0]??null,appearance:o,renderStyle:s,fallback:!t.activities.includes(i)||a!==null&&!t.expressions.includes(a)},l=r.performance===void 0?c:{...c,performance:r.performance};r.timeMs!==void 0&&(l={...l,timeMs:r.timeMs});let p=JSON.stringify([l.activity,l.expression,l.appearance,l.timeMs]);if(C.set(s,e.holder),p!==e.appliedKey||r.performance!==e.appliedPerformance||u.status!==`ready`||u.presentation.renderStyle!==s||u.updateError!==void 0||u.presentation.requestedActivity!==i||u.presentation.requestedExpression!==a)try{if((p!==e.appliedKey||r.performance!==e.appliedPerformance)&&t.set(l),e.appliedKey=p,e.appliedPerformance=r.performance,w(),f===e){let t={status:`ready`,document:n,presentation:l};x(e.progress===void 0?t:{...t,progress:e.progress})}}catch(e){S(kX(e))}},D=async(i,a,o)=>{let c=r(),l=_e(ln()),d=new AbortController,m=s.ownerDocument.createElement(`div`);m.style.cssText=`width:100%;height:100%;position:relative`;let h={key:a,scope:l,controller:d,holder:m};f=h,_e(Rn(l,ze(()=>{m.remove()}))),s.append(m);let g=Me(function*(){let r,a,o=n.baseURL,s=OX(i.src,n.baseURL);if(s.kind===`remote`){let t=yield*st({try:()=>c(s.url,d.signal),catch:kX});o=t.url,r=rr.parse(JSON.parse(new TextDecoder().decode(t.bytes)));let n=e.renderers&&Object.hasOwn(e.renderers,r.renderer)?e.renderers[r.renderer]:void 0;if(!n)throw Error(`Renderer is not installed: ${r.renderer}`);a=(yield*st({try:n,catch:kX})).default}else{let t=s.key,n=e.characters&&Object.hasOwn(e.characters,t)?e.characters[t]:void 0;if(!n)throw Error(`Character is not installed: ${t}`);let i=yield*st({try:n,catch:kX});r=rr.parse(i.document),a=i.render}d.signal.throwIfAborted();let l=yield*a({target:m,document:r,signal:d.signal,maxPixels:t,reportError:e=>{f===h&&!d.signal.aborted&&S(e)},reportProgress:e=>{f!==h||d.signal.aborted||(h.progress=e,u.status===`ready`&&x({...u,progress:e}))},assetURL:e=>Me(function*(){let t=yield*st({try:()=>c(e,d.signal,o),catch:kX});return yield*Qe(ze(()=>URL.createObjectURL(new Blob([t.bytes],{type:t.contentType}))),e=>ze(()=>{URL.revokeObjectURL(e)}))})});if(!l.activities.includes(`idle`))throw Error(`Character has no idle fallback`);return l.pause(!0),{native:l,document:r}}).pipe(Wn(l)),_=await Ye(g,{signal:d.signal});if(!(v||o!==p||f!==h)){if(Sn(_)){let e=AX(_);try{await T(),x({status:`error`,error:e})}catch(t){x({status:`error`,error:AggregateError([e,t],`Avatar load and cleanup failed`)})}return}h.native=_.value.native,h.document=_.value.document,E(h)}},O=async()=>{let e=e=>v||e!==p;for(;m&&!v;){m=!1;let t=p;if(await T(),e(t)||!d)continue;let n=await a.get(s);if(n?.kind===`failed`)throw n.error;e(t)||(x({status:`loading`}),await D(d,o(d.src),t))}},k=()=>{m=!0,f?.controller.abort(),f?.holder.remove(),!h&&(h=O().catch(e=>{x({status:`error`,error:kX(e)})}).finally(()=>{h=void 0,m&&!v&&k()}))};return{get state(){return u},subscribe(e){return l.add(e),()=>l.delete(e)},set(e){if(v)throw Error(`Sprite is destroyed`);d=e;let t=o(e.src);f?.key===t&&u.status===`ready`?E(f):(f?.key!==t||u.status===`error`)&&(p+=1,k())},pause(e){if(v)throw Error(`Sprite is destroyed`);y=e,w()},dispose(){return _||(v=!0,p+=1,i.delete(s),f?.controller.abort(),f?.holder.remove(),x({status:`destroyed`}),_=(async()=>{await h,await T();let e=await Ye(Un(c,Tn));if(Sn(e))throw AX(e)})(),a.set(s,_.then(()=>({kind:`closed`}),e=>({kind:`failed`,error:kX(e)}))),_)}}}}}var MX=jX({characters:{mushroom:async()=>(await sr(async()=>{let{default:e}=await import(`./mushroom-ur0TNKww.js`);return{default:e}},__vite__mapDeps([6,7,2,8,1]))).default,cat:async()=>(await sr(async()=>{let{default:e}=await import(`./cat-CRMM8U8H.js`);return{default:e}},__vite__mapDeps([9,7,2,8,1,10]))).default,burger:async()=>(await sr(async()=>{let{default:e}=await import(`./burger-DGewjCsv.js`);return{default:e}},__vite__mapDeps([11,7,2,8,1,10]))).default}}),NX=(0,J.memo)(function({activity:e=`idle`,avatar:t,className:n,name:r,size:i=24,timeMs:a}){let o=wX(a),[s,c]=(0,J.useState)(!1),l=(0,J.useMemo)(()=>EX(t),[t]);return(0,X.jsxs)(`span`,{"aria-hidden":`true`,className:`relative inline-block shrink-0 ${n??``}`,"data-agent-head":s?`ready`:`loading`,style:{height:i,width:i},children:[s?null:(0,X.jsx)(xX,{className:`absolute inset-0`,name:r,seed:r}),(0,X.jsx)(TX,{activity:e,...o===void 0?{}:{timeMs:o},appearance:l.appearance,className:`absolute inset-0`,expression:l.expression,onState:e=>{c(e.status===`ready`)},paused:o!==void 0||e===`idle`,renderStyle:l.renderStyle,service:MX,src:l.src})]})}),PX=(0,J.memo)(function({avatar:e,className:t=`h-12 w-12 shrink-0`,service:n=MX,state:r}){let i=(0,J.useMemo)(()=>e?EX(e):void 0,[e]);return(0,X.jsx)(TX,{"aria-hidden":`true`,className:t,service:n,src:i?.src??{local:`mushroom`},...i?{appearance:i.appearance,renderStyle:i.renderStyle}:{},...r})}),FX={needs_you:`Waiting for you`,running:`Working`,errored:`Failed`,done:`Done`},IX={needs_you:0,errored_unseen:1,running:2,recent:3};function LX(e){return e===`running`||e===`needs_you`}function RX(e,t){return e!==void 0&&(t===void 0||e>t)}function zX(e,t){switch(e){case`needs_you`:return`needs_you`;case`running`:return`running`;case`errored`:return t?`errored_unseen`:`recent`;case`done`:return`recent`}}function BX(e,t){return IX[e.tier]-IX[t.tier]||(t.settledAt??t.createdAt)-(e.settledAt??e.createdAt)||e.agentId.localeCompare(t.agentId)||e.sessionId.localeCompare(t.sessionId)}var VX=[`Needs you`,`Working`,`Ready`,`Finished`];function HX(e){return e.tier===`running`?`Working`:e.shelf===`active`?`Needs you`:e.ready?`Ready`:`Finished`}function UX(e){return{key:JX(e.agentId,e.sessionId),shelf:HX(e),attention:e.tier===`needs_you`||e.tier===`errored_unseen`?`${e.tier}:${String(e.settledAt??e.createdAt)}`:null}}function WX(e,t,n){let r=new Map(t.map(e=>[JX(e.agentId,e.sessionId),e]));if(e!==null&&e.length>0&&n.held)return e;let i=[...t].sort((e,t)=>(t.settledAt??t.createdAt)-(e.settledAt??e.createdAt)||e.agentId.localeCompare(t.agentId)||e.sessionId.localeCompare(t.sessionId)),a=new Map(e?.map(e=>[e.key,e])),o=i.map(UX).filter(e=>{let t=a.get(e.key);return t===void 0||e.key!==n.openKey&&e.attention!==null&&e.attention!==t.attention}),s=new Set(o.map(e=>e.key)),c=a.get(n.openKey??``),l=c===void 0?-1:(e??[]).filter(e=>e.shelf===c.shelf).findIndex(e=>e.key===c.key),u=VX.flatMap(t=>{let a;a=e===null||n.reorder?i.map(UX).filter(e=>e.shelf===t):[...o.filter(e=>e.shelf===t),...e.filter(e=>e.shelf===t&&!s.has(e.key)).flatMap(e=>{let t=r.get(e.key);return t===void 0?[]:[{...e,attention:UX(t).attention}]})];let u=c===void 0?void 0:r.get(c.key);return c!==void 0&&u!==void 0&&(a=a.filter(e=>e.key!==c.key),c.shelf===t&&a.splice(Math.min(l,a.length),0,{...c,attention:UX(u).attention})),a});return e!==null&&u.length===e.length&&u.every((t,n)=>t.key===e[n]?.key&&t.shelf===e[n]?.shelf&&t.attention===e[n]?.attention)?e:u}function GX(e){switch(e.kind){case`idle`:return`done`;case`waiting_for_you`:return`needs_you`;case`error`:return`errored`;default:return`running`}}function KX(e,t,n=null,r){let i=new Set(e.map(e=>e.agentId));return qX(t.filter(e=>!(`kind`in e)&&i.has(e.agentId)&&(n===null||e.agentId===n)),r)}function qX(e,t){let n=[],r=[];for(let i of e){if(`kind`in i)continue;if(i.state===`unavailable`){r.push({agentId:i.agentId,sessionId:i.sessionId});continue}let e=RX(i.settledAt,i.visitedAt),a=t?.agentId===i.agentId&&t.sessionId===i.sessionId?t.state:void 0,o=a?GX(a):i.state,s=a?a.kind===`idle`:o===`done`&&i.settledAt===void 0,c=zX(o,e);n.push({...i,state:o,ready:s,unseen:e,tier:c,shelf:c===`recent`?`settled`:`active`})}return n.sort(BX),{active:n.filter(e=>e.shelf===`active`),settled:n.filter(e=>e.shelf===`settled`),unavailable:r.sort((e,t)=>e.agentId.localeCompare(t.agentId)||e.sessionId.localeCompare(t.sessionId))}}function JX(e,t){return`${e}\u0000${t}`}function YX(e){return e.name}function XX({children:e}){return(0,X.jsx)(`span`,{className:`grove-rail-mark grid size-full place-items-center`,children:e})}function ZX({open:e,agents:t,agentActivity:n,agentFilterId:r,websitesSelected:i,websitesVisible:a,canCreate:o,createOpen:s,onAll:c,onWebsites:l,onAgent:u,onCreate:d}){let[f,p]=(0,J.useState)(null),m=`grove-rail-cell relative size-12 rounded-field p-0`,h=r===null&&!(i&&a);return(0,X.jsxs)(`nav`,{id:`grove-agent-rail`,"aria-label":`Agents`,className:`grove-rail min-h-0 w-16 flex-none flex-col items-center gap-1 border-r border-base-300 py-2 ${e?`flex`:`flex min-[900px]:hidden`}`,children:[(0,X.jsx)(BT,{variant:`ghost`,"aria-label":`All Agents`,"aria-pressed":h,className:`${m} text-xs ${h?`bg-base-300`:``}`,onClick:c,children:(0,X.jsx)(XX,{children:`All`})}),a?(0,X.jsx)(BT,{variant:`ghost`,"aria-label":`Websites`,"aria-pressed":i,className:`${m} ${i?`bg-base-300`:``}`,onClick:l,children:(0,X.jsx)(XX,{children:(0,X.jsx)(Xq,{name:`internet`,size:28})})}):null,(0,X.jsx)(DA,{className:`w-full flex-1`,style:{width:`100%`},children:(0,X.jsx)(`div`,{className:`flex flex-col items-center gap-1 py-1`,children:t.map(e=>(0,X.jsx)(BT,{variant:`ghost`,"aria-label":YX(e),title:YX(e),"aria-pressed":r===e.agentId&&!i,"data-agent-id":e.agentId,className:`${m} ${r===e.agentId&&!i?`bg-base-300`:``}`,onPointerEnter:()=>{p(e.agentId)},onPointerLeave:()=>{p(null)},onFocus:()=>{p(e.agentId)},onBlur:()=>{p(null)},onClick:()=>{u(e.agentId)},children:(0,X.jsx)(XX,{children:(0,X.jsx)(NX,{activity:n.get(e.agentId)??(f===e.agentId?`thinking`:`idle`),avatar:e.avatar,name:YX(e),size:32})})},e.agentId))})}),o?(0,X.jsx)(BT,{variant:`ghost`,"aria-label":`New Agent`,"aria-expanded":s,"aria-haspopup":`dialog`,className:`${m} mt-auto`,onClick:d,children:(0,X.jsx)(`span`,{className:`grove-rail-mark grid size-full place-items-center`,children:(0,X.jsx)(lW,{size:20})})}):null]})}function QX({app:e}){let[t,n]=(0,J.useState)(null),r=jo({queryKey:eb.of(e,`team-inbox-notices`,t),enabled:e!==null&&(e.capabilities.has(mg)||e.capabilities.has(hg)),queryFn:async()=>{if(!e)throw Error(`No App connection`);let n=await Sg(e.capabilities);try{return await Jy(n,t)}finally{await n.close()}}});return!r.isError&&!r.data?.items.length?null:(0,X.jsx)(`section`,{"aria-label":`Team notices`,className:`min-h-0 shrink-0`,children:(0,X.jsxs)(DA,{className:`max-h-52 border-b border-base-300`,children:[r.isError?(0,X.jsx)(`p`,{role:`alert`,className:`text-sm`,children:`Team notices unavailable.`}):(0,X.jsx)(Bx,{density:`compact`,className:`px-3 py-2`,children:r.data.items.map(e=>(0,X.jsx)(Vx,{children:(0,X.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[auto_minmax(0,1fr)] gap-x-[var(--spacing-xs)]`,children:[(0,X.jsx)(FG,{className:`col-span-2 grid grid-cols-subgrid`,size:`compact`,tone:`warning`,label:`kind`in e?`Seller closed`:`Installed App safety notice`}),(0,X.jsx)(`p`,{className:`m-0 col-start-2 text-sm [overflow-wrap:anywhere]`,children:`kind`in e?`${e.sellerName} closed. Your installation of ${e.displayName} continues; no new purchases are available.`:`${e.displayName} was removed. Fungi will disable it on your Team.`})]})},e.dispositionId))}),r.data?.next?(0,X.jsx)(BT,{variant:`ghost`,size:`sm`,onClick:()=>{n(r.data.next)},children:`Older notices`}):null,t===null?null:(0,X.jsx)(BT,{variant:`ghost`,size:`sm`,onClick:()=>{n(null)},children:`Newest notices`})]})})}var $X=`(min-width: 900px)`;function eZ(e){let t=globalThis.matchMedia($X);return t.addEventListener(`change`,e),()=>{t.removeEventListener(`change`,e)}}function tZ(){return globalThis.matchMedia($X).matches}function nZ(){return(0,J.useSyncExternalStore)(eZ,tZ,()=>!0)}function rZ({open:e,onOpenChange:t,returnFocus:n,children:r}){let i=nZ(),[a,o]=(0,J.useState)(null);return(0,X.jsxs)(IU,{open:i||e,modal:!i,disablePointerDismissal:i,onOpenChange:e=>{i||t(e)},children:[(0,X.jsx)(`div`,{ref:o,className:`contents`}),(0,X.jsxs)(RU,{container:a,keepMounted:!0,className:`contents`,children:[i?null:(0,X.jsx)(zU,{className:`grove-nav-scrim z-30 bg-base-200`}),(0,X.jsx)(BU,{id:`grove-nav`,role:i?`presentation`:`dialog`,"aria-label":i?void 0:`Agents and conversations`,initialFocus:!i&&void 0,finalFocus:!i&&n,className:`grove-nav min-h-0 flex-none rounded-none p-0 overflow-visible max-w-none max-h-none ${i?`static flex w-auto shadow-none`:`fixed inset-y-0 left-0 z-40 w-[min(22rem,88vw)] data-[open]:flex`}`,children:r})]})]})}function iZ({update:e,notify:t,unwatched:n}){return{link:r,unlink:i,propagate:a,checkDirty:o,shallowPropagate:s};function r(e,t,n){let r=t.depsTail;if(r!==void 0&&r.dep===e)return;let i=r===void 0?t.deps:r.nextDep;if(i!==void 0&&i.dep===e){i.version=n,t.depsTail=i;return}let a=e.subsTail;if(a!==void 0&&a.version===n&&a.sub===t)return;let o=t.depsTail=e.subsTail={version:n,dep:e,sub:t,prevDep:r,nextDep:i,prevSub:a,nextSub:void 0};i!==void 0&&(i.prevDep=o),r===void 0?t.deps=o:r.nextDep=o,a===void 0?e.subs=o:a.nextSub=o}function i(e,t=e.sub){let r=e.dep,i=e.prevDep,a=e.nextDep,o=e.nextSub,s=e.prevSub;return a===void 0?t.depsTail=i:a.prevDep=i,i===void 0?t.deps=a:i.nextDep=a,o===void 0?r.subsTail=s:o.prevSub=s,s===void 0?(r.subs=o)===void 0&&n(r):s.nextSub=o,a}function a(e){let n=e.nextSub,r;top:do{let i=e.sub,a=i.flags;if(a&60?a&12?a&4?!(a&48)&&c(e,i)?(i.flags=a|40,a&=1):a=0:i.flags=a&-9|32:a=0:i.flags=a|32,a&2&&t(i),a&1){let t=i.subs;if(t!==void 0){let i=(e=t).nextSub;i!==void 0&&(r={value:n,prev:r},n=i);continue}}if((e=n)!==void 0){n=e.nextSub;continue}for(;r!==void 0;)if(e=r.value,r=r.prev,e!==void 0){n=e.nextSub;continue top}break}while(!0)}function o(t,n){let r,i=0,a=!1;top:do{let o=t.dep,c=o.flags;if(n.flags&16)a=!0;else if((c&17)==17){if(e(o)){let e=o.subs;e.nextSub!==void 0&&s(e),a=!0}}else if((c&33)==33){(t.nextSub!==void 0||t.prevSub!==void 0)&&(r={value:t,prev:r}),t=o.deps,n=o,++i;continue}if(!a){let e=t.nextDep;if(e!==void 0){t=e;continue}}for(;i--;){let i=n.subs,o=i.nextSub!==void 0;if(o?(t=r.value,r=r.prev):t=i,a){if(e(n)){o&&s(i),n=t.sub;continue}a=!1}else n.flags&=-33;n=t.sub;let c=t.nextDep;if(c!==void 0){t=c;continue top}}return a}while(!0)}function s(e){do{let n=e.sub,r=n.flags;(r&48)==32&&(n.flags=r|16,(r&6)==2&&t(n))}while((e=e.nextSub)!==void 0)}function c(e,t){let n=t.depsTail;for(;n!==void 0;){if(n===e)return!0;n=n.prevDep}return!1}}function aZ(e,t,n){let r=typeof e==`object`,i=r?e:void 0;return{next:(r?e.next:e)?.bind(i),error:(r?e.error:t)?.bind(i),complete:(r?e.complete:n)?.bind(i)}}var oZ=[],sZ=0,{link:cZ,unlink:lZ,propagate:uZ,checkDirty:dZ,shallowPropagate:fZ}=iZ({update(e){return e._update()},notify(e){oZ[mZ++]=e,e.flags&=-3},unwatched(e){e.depsTail!==void 0&&(e.depsTail=void 0,e.flags=17,vZ(e))}}),pZ=0,mZ=0,hZ,gZ=0;function _Z(e){try{++gZ,e()}finally{--gZ||yZ()}}function vZ(e){let t=e.depsTail,n=t===void 0?e.deps:t.nextDep;for(;n!==void 0;)n=lZ(n,e)}function yZ(){if(!(gZ>0)){for(;pZ<mZ;){let e=oZ[pZ];oZ[pZ++]=void 0,e.notify()}pZ=0,mZ=0}}function bZ(e,t){let n=typeof e==`function`,r=e,i={_snapshot:n?void 0:e,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:+!n,get(){return hZ!==void 0&&cZ(i,hZ,sZ),i._snapshot},subscribe(e){let t=aZ(e),n={current:!1},r=xZ(()=>{i.get(),n.current?t.next?.(i._snapshot):n.current=!0});return{unsubscribe:()=>{r.stop()}}},_update(e){let a=hZ,o=t?.compare??Object.is;if(n)hZ=i,++sZ,i.depsTail=void 0;else if(e===void 0)return!1;n&&(i.flags=5);try{let t=i._snapshot,a=typeof e==`function`?e(t):e===void 0&&n?r(t):e;return t===void 0||!o(t,a)?(i._snapshot=a,!0):!1}finally{hZ=a,n&&(i.flags&=-5),vZ(i)}}};return n?(i.flags=17,i.get=function(){let e=i.flags;if(e&16||e&32&&dZ(i.deps,i)){if(i._update()){let e=i.subs;e!==void 0&&fZ(e)}}else e&32&&(i.flags=e&-33);return hZ!==void 0&&cZ(i,hZ,sZ),i._snapshot}):i.set=function(e){if(i._update(e)){let e=i.subs;e!==void 0&&(uZ(e),fZ(e),yZ())}},i}function xZ(e){let t=()=>{let t=hZ;hZ=n,++sZ,n.depsTail=void 0,n.flags=6;try{return e()}finally{hZ=t,n.flags&=-5,vZ(n)}},n={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:6,notify(){let e=this.flags;e&16||e&32&&dZ(this.deps,this)?t():this.flags=2},stop(){this.flags=0,this.depsTail=void 0,vZ(this)}};return t(),n}var SZ=class{constructor(e,t){this.atom=bZ(e),this.get=this.get.bind(this),this.setState=this.setState.bind(this),this.subscribe=this.subscribe.bind(this),t&&(this.actions=t(this))}setState(e){this.atom.set(e)}get state(){return this.atom.get()}get(){return this.state}subscribe(e){return this.atom.subscribe(aZ(e))}},CZ=class{constructor(e){this.atom=bZ(e)}get state(){return this.atom.get()}get(){return this.state}subscribe(e){return this.atom.subscribe(aZ(e))}};function wZ(e,t){return typeof e==`function`?new CZ(e):t?new SZ(e,t):new SZ(e)}var TZ=class{constructor(e,t){this.fn=e,this.options=t,this.lastExecutionTime=0,this.isPending=!1,this.maybeExecute=(...e)=>{let t=Date.now()-this.lastExecutionTime;if(this.options.leading&&t>=this.options.wait)this.execute(...e);else if(this.lastArgs=e,!this.timeoutId&&this.options.trailing){let e=this.options.wait-t;this.isPending=!0,this.timeoutId=setTimeout(()=>{this.lastArgs!==void 0&&this.execute(...this.lastArgs)},e)}},this.execute=(...e)=>{this.fn(...e),this.options.onExecute?.(e,this),this.lastExecutionTime=Date.now(),this.clearTimeout(),this.lastArgs=void 0,this.isPending=!1},this.flush=()=>{this.isPending&&this.lastArgs&&this.execute(...this.lastArgs)},this.cancel=()=>{this.clearTimeout(),this.lastArgs=void 0,this.isPending=!1},this.clearTimeout=()=>{this.timeoutId&&=(clearTimeout(this.timeoutId),void 0)},this.options.leading===void 0&&this.options.trailing===void 0&&(this.options.leading=!0,this.options.trailing=!0)}};function EZ(e,t){return new TZ(e,t).maybeExecute}var DZ=class{#e=!0;#t;#n;#r;#i;#a;#o;#s;#c=0;#l=5;#u=!1;#d=!1;#f=null;#p=()=>{this.debugLog(`Connected to event bus`),this.#a=!0,this.#u=!1,this.debugLog(`Emitting queued events`,this.#i),this.#i.forEach(e=>this.emitEventToBus(e)),this.#i=[],this.stopConnectLoop(),this.#n().removeEventListener(`tanstack-connect-success`,this.#p)};#m=()=>{if(this.#c<this.#l){this.#c++,this.dispatchCustomEvent(`tanstack-connect`,{});return}this.#n().removeEventListener(`tanstack-connect`,this.#m),this.#d=!0,this.debugLog(`Max retries reached, giving up on connection`),this.stopConnectLoop()};#h=()=>{this.#u||(this.#u=!0,this.#n().addEventListener(`tanstack-connect-success`,this.#p),this.#m())};constructor({pluginId:e,debug:t=!1,enabled:n=!0,reconnectEveryMs:r=300}){this.#t=e,this.#e=n,this.#n=this.getGlobalTarget,this.#r=t,this.debugLog(` Initializing event subscription for plugin`,this.#t),this.#i=[],this.#a=!1,this.#d=!1,this.#o=null,this.#s=r}startConnectLoop(){this.#o!==null||this.#a||(this.debugLog(`Starting connect loop (every ${this.#s}ms)`),this.#o=setInterval(this.#m,this.#s))}stopConnectLoop(){this.#u=!1,this.#o!==null&&(clearInterval(this.#o),this.#o=null,this.#i=[],this.debugLog(`Stopped connect loop`))}debugLog(...e){this.#r&&console.log(`🌴 [tanstack-devtools:${this.#t}-plugin]`,...e)}getGlobalTarget(){if(typeof globalThis<`u`&&globalThis.__TANSTACK_EVENT_TARGET__)return this.debugLog(`Using global event target`),globalThis.__TANSTACK_EVENT_TARGET__;if(typeof window<`u`&&window.addEventListener!==void 0)return this.debugLog(`Using window as event target`),window;let e=typeof EventTarget<`u`?new EventTarget:void 0;return e===void 0||e.addEventListener===void 0?(this.debugLog(`No event mechanism available, running in non-web environment`),{addEventListener:()=>{},removeEventListener:()=>{},dispatchEvent:()=>!1}):(this.debugLog(`Using new EventTarget as fallback`),e)}getPluginId(){return this.#t}dispatchCustomEventShim(e,t){try{let n=new Event(e,{detail:t});this.#n().dispatchEvent(n)}catch{this.debugLog(`Failed to dispatch shim event`)}}dispatchCustomEvent(e,t){try{this.#n().dispatchEvent(new CustomEvent(e,{detail:t}))}catch{this.dispatchCustomEventShim(e,t)}}emitEventToBus(e){this.debugLog(`Emitting event to client bus`,e),this.dispatchCustomEvent(`tanstack-dispatch-event`,e)}createEventPayload(e,t){return{type:`${this.#t}:${e}`,payload:t,pluginId:this.#t}}emit(e,t){if(!this.#e){this.debugLog(`Event bus client is disabled, not emitting event`,e,t);return}if(this.#f&&(this.debugLog(`Emitting event to internal event target`,e,t),this.#f.dispatchEvent(new CustomEvent(`${this.#t}:${e}`,{detail:this.createEventPayload(e,t)}))),this.#d){this.debugLog(`Previously failed to connect, not emitting to bus`);return}if(!this.#a){this.debugLog(`Bus not available, will be pushed as soon as connected`),this.#i.push(this.createEventPayload(e,t)),typeof CustomEvent<`u`&&!this.#u&&(this.#h(),this.startConnectLoop());return}return this.emitEventToBus(this.createEventPayload(e,t))}on(e,t,n){let r=n?.withEventTarget??!1,i=`${this.#t}:${e}`;if(r&&(this.#f||=new EventTarget,this.#f.addEventListener(i,e=>{t(e.detail)})),!this.#e)return this.debugLog(`Event bus client is disabled, not registering event`,i),()=>{};let a=e=>{this.debugLog(`Received event from bus`,e.detail),t(e.detail)};return this.#n().addEventListener(i,a),this.debugLog(`Registered event to bus`,i),()=>{r&&this.#f?.removeEventListener(i,a),this.#n().removeEventListener(i,a)}}onAll(e){if(!this.#e)return this.debugLog(`Event bus client is disabled, not registering event`),()=>{};let t=t=>{let n=t.detail;e(n)};return this.#n().addEventListener(`tanstack-devtools-global`,t),()=>this.#n().removeEventListener(`tanstack-devtools-global`,t)}onAllPluginEvents(e){if(!this.#e)return this.debugLog(`Event bus client is disabled, not registering event`),()=>{};let t=t=>{let n=t.detail;this.#t&&n.pluginId!==this.#t||e(n)};return this.#n().addEventListener(`tanstack-devtools-global`,t),()=>this.#n().removeEventListener(`tanstack-devtools-global`,t)}},OZ=new class extends DZ{constructor(){super({pluginId:`form-devtools`,reconnectEveryMs:1e3})}};function kZ(e,t){return typeof e==`function`?e(t):e}function AZ(e,t){return RZ(t).reduce((e,t)=>{if(e===null)return null;if(e!==void 0)return e[t]},e)}function jZ(e,t,n){let r=RZ(t);function i(e){if(!r.length)return kZ(n,e);let t=r.shift();if(typeof t==`string`||typeof t==`number`&&!Array.isArray(e))return typeof e==`object`?(e===null&&(e={}),{...e,[t]:i(e[t])}):{[t]:i()};if(Array.isArray(e)&&typeof t==`number`){let n=e.slice(0,t);return[...n.length?n:Array(t),i(e[t]),...e.slice(t+1)]}return[...Array(t),i()]}return i(e)}function MZ(e,t){let n=RZ(t);function r(e){if(!e)return;if(n.length===1){let t=n[0];if(Array.isArray(e)&&typeof t==`number`)return e.filter((e,n)=>n!==t);let{[t]:r,...i}=e;return i}let t=n.shift();if((typeof t==`string`||typeof t==`number`&&!Array.isArray(e))&&typeof e==`object`)return{...e,[t]:r(e[t])};if(typeof t==`number`&&Array.isArray(e)){if(t>=e.length)return e;let n=e.slice(0,t);return[...n.length?n:Array(t),r(e[t]),...e.slice(t+1)]}throw Error(`It seems we have created an infinite loop in deleteBy. `)}return r(e)}var NZ=46,PZ=91,FZ=93,IZ=48,LZ=57;function RZ(e){if(Array.isArray(e))return[...e];if(typeof e!=`string`)throw Error(`Path must be a string.`);let t=e.length,n=[],r=+(t>0&&e.charCodeAt(0)===PZ),i=!0,a=-1;for(let o=r;o<=t;o++){let s=o<t?e.charCodeAt(o):-1;if(o===t||s===NZ||s===PZ||s===FZ){let t=o-r;if(t>0){let a=i&&(t===1||e.charCodeAt(r)!==IZ),s=e.slice(r,o);if(a){let e=parseInt(s,10);t<=15||String(e)===s?n.push(e):n.push(s)}else n.push(s)}else a!==FZ&&(a!==-1||s!==FZ)&&(a!==s||s!==NZ&&s!==PZ)&&n.push(``);r=o+1,i=!0}else(s<IZ||s>LZ)&&(i=!1);a=s}return n.length||n.push(``),n}function zZ(e){return!(Array.isArray(e)&&e.length===0)}function BZ(e,t){return t.validationLogic({form:t.form,group:t.group,validators:t.validators,event:{type:e,fieldName:t.fieldName,async:!1},runValidation:e=>e.validators.filter(Boolean).map(e=>({cause:e.cause,validate:e.fn}))})}function VZ(e,t){let{asyncDebounceMs:n}=t,{onBlurAsyncDebounceMs:r,onChangeAsyncDebounceMs:i,onDynamicAsyncDebounceMs:a}=t.validators||{},o=n??0;return t.validationLogic({form:t.form,group:t.group,validators:t.validators,event:{type:e,fieldName:t.fieldName,async:!0},runValidation:t=>t.validators.filter(Boolean).map(t=>{let n=t?.cause||e,s=o;switch(n){case`change`:s=i??o;break;case`blur`:s=r??o;break;case`dynamic`:s=a??o;break;case`submit`:s=0}return e===`submit`&&(s=0),{cause:n,validate:t.fn,debounceMs:s}})})}var HZ=e=>!!e&&typeof e==`object`&&`fields`in e;function UZ(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!t.has(n)||!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length||n.length===0&&!Array.isArray(e)&&!Array.isArray(t)&&(Object.getPrototypeOf(e)!==Object.prototype||Object.getPrototypeOf(t)!==Object.prototype))return!1;for(let i of n)if(!r.includes(i)||!UZ(e[i],t[i]))return!1;return!0}var WZ=({newFormValidatorError:e,isPreviousErrorFromFormValidator:t,previousErrorValue:n})=>e?{newErrorValue:e,newSource:`form`}:t?{newErrorValue:void 0,newSource:void 0}:n?{newErrorValue:n,newSource:`field`}:{newErrorValue:void 0,newSource:void 0},GZ=({formLevelError:e,fieldLevelError:t})=>t?{newErrorValue:t,newSource:`field`}:e?{newErrorValue:e,newSource:`form`}:{newErrorValue:void 0,newSource:void 0};function KZ(e,t){return e==null?t:{...e,...t}}for(var qZ=256,JZ=[],YZ;qZ--;)JZ[qZ]=(qZ+256).toString(16).substring(1);function XZ(){let e=0,t,n=``;if(!YZ||qZ+16>256){for(YZ=Array(256),e=256;e--;)YZ[e]=256*Math.random()|0;e=0,qZ=0}for(;e<16;e++)t=YZ[qZ+e],n+=e===6?JZ[t&15|64]:e===8?JZ[t&63|128]:JZ[t],e&1&&e>1&&e<11&&(n+=`-`);return qZ++,n}var ZZ=EZ(e=>OZ.emit(`form-state`,{id:e.formId,state:e.store.state}),{wait:300});function QZ(e){if(typeof e!=`object`||!e)return e;if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++)t[n]=QZ(e[n]);return t}if(e instanceof Map){let t=new Map;return e.forEach((e,n)=>{t.set(n,QZ(e))}),t}if(e instanceof Set){let t=new Set;return e.forEach(e=>{t.add(QZ(e))}),t}let t={};for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=QZ(e[n]));return t}function $Z(e,t){return t===e||t.startsWith(`${e}.`)||t.startsWith(`${e}[`)}var eQ=e=>{if(!e.validators)return e.runValidation({validators:[],form:e.form});let t=e.event.async,n=t?void 0:{fn:e.validators.onMount,cause:`mount`},r={fn:t?e.validators.onChangeAsync:e.validators.onChange,cause:`change`},i={fn:t?e.validators.onBlurAsync:e.validators.onBlur,cause:`blur`},a={fn:t?e.validators.onSubmitAsync:e.validators.onSubmit,cause:`submit`},o=t?void 0:{fn:()=>void 0,cause:`server`};switch(e.event.type){case`mount`:return e.runValidation({validators:[n],form:e.form});case`submit`:return e.runValidation({validators:[r,i,a,o],form:e.form});case`server`:return e.runValidation({validators:[],form:e.form});case`blur`:return e.runValidation({validators:[i,o],form:e.form});case`change`:return e.runValidation({validators:[r,o],form:e.form});default:throw Error(`Unknown validation event type: ${e.event.type}`)}};function tQ(e,t){let n=new Map;for(let r of e){let e=r.path??[],i=t,a=``;for(let t=0;t<e.length;t++){let n=e[t];if(n===void 0)continue;let r=typeof n==`object`?n.key:n,o=Number(r);a+=Array.isArray(i)&&!Number.isNaN(o)?`[${o}]`:(t>0?`.`:``)+String(r),i=typeof i==`object`&&i?i[r]:void 0}n.set(a,(n.get(a)??[]).concat(r))}return Object.fromEntries(n)}var nQ=(e,t)=>{let n=tQ(e,t);return{form:n,fields:n}},rQ={validate({value:e,validationSource:t},n){let r=n[`~standard`].validate(e);if(r instanceof Promise)throw Error(`async function passed to sync validator`);if(r.issues)return t===`field`?r.issues:nQ(r.issues,e)},async validateAsync({value:e,validationSource:t},n){let r=await n[`~standard`].validate(e);if(r.issues)return t===`field`?r.issues:nQ(r.issues,e)}},iQ=e=>!!e&&`~standard`in e,aQ={isValidating:!1,isTouched:!1,isBlurred:!1,isDirty:!1,isPristine:!0,isValid:!0,isDefaultValue:!0,errors:[],errorMap:{},errorSourceMap:{},_arrayVersion:0,_pendingValidationsCount:0};function oQ(e){function t(t){let n=e.getFieldMeta(t)??aQ;e.setFieldMeta(t,{...n,_arrayVersion:(n._arrayVersion||0)+1})}function n(n,r,i){t(n);let a=s(n,r,`move`,i),c=Math.min(r,i),u=Math.max(r,i);for(let e=c;e<=u;e++)a.push(o(n,e));let d=Object.keys(e.fieldInfo).reduce((t,i)=>(i.startsWith(o(n,r))&&t.set(i,e.getFieldMeta(i)),t),new Map);l(a,r<i?`up`:`down`),Object.keys(e.fieldInfo).filter(e=>e.startsWith(o(n,i))).forEach(t=>{let a=t.replace(o(n,i),o(n,r)),s=d.get(a);s&&e.setFieldMeta(t,s)})}function r(e,n){t(e),l(s(e,n,`remove`),`up`)}function i(n,r,i){t(n),s(n,r,`swap`,i).forEach(t=>{if(!t.toString().startsWith(o(n,r)))return;let a=t.toString().replace(o(n,r),o(n,i)),[s,c]=[e.getFieldMeta(t),e.getFieldMeta(a)];s&&e.setFieldMeta(a,s),c&&e.setFieldMeta(t,c)})}function a(n,r){t(n);let i=s(n,r,`insert`);l(i,`down`),i.forEach(t=>{t.toString().startsWith(o(n,r))&&e.setFieldMeta(t,u())})}function o(e,t){return`${e}[${t}]`}function s(t,n,r,i){let a=[o(t,n)];switch(r){case`swap`:a.push(o(t,i));break;case`move`:{let[e,r]=[Math.min(n,i),Math.max(n,i)];for(let n=e;n<=r;n++)a.push(o(t,n));break}default:{let r=e.getFieldValue(t),i=Array.isArray(r)?r.length:0;for(let e=n+1;e<i;e++)a.push(o(t,e));break}}return Object.keys(e.fieldInfo).filter(e=>a.some(t=>e.startsWith(t)))}function c(e,t){return e.replace(/\[(\d+)\]/,(e,n)=>{let r=parseInt(n,10);return`[${t===`up`?r+1:Math.max(0,r-1)}]`})}function l(t,n){(n===`up`?t:[...t].reverse()).forEach(t=>{let r=c(t.toString(),n),i=e.getFieldMeta(r);i?e.setFieldMeta(t,i):e.setFieldMeta(t,u())})}let u=()=>aQ;return{bumpArrayVersion:t,handleArrayMove:n,handleArrayRemove:r,handleArraySwap:i,handleArrayInsert:a}}function sQ(e){return{values:e.values??{},errorMap:e.errorMap??{},fieldMetaBase:e.fieldMetaBase??{},formGroupStateBase:e.formGroupStateBase??{},isSubmitted:e.isSubmitted??!1,isSubmitting:e.isSubmitting??!1,isValidating:e.isValidating??!1,submissionAttempts:e.submissionAttempts??0,isSubmitSuccessful:e.isSubmitSuccessful??!1,validationMetaMap:e.validationMetaMap??{onChange:void 0,onBlur:void 0,onSubmit:void 0,onMount:void 0,onServer:void 0,onDynamic:void 0}}}var cQ=class{constructor(e){this.options={},this.fieldInfo={},this.formGroupApis=new Set,this.mount=()=>{let e=this.store.subscribe(()=>{ZZ(this)}),t=OZ.on(`request-form-state`,e=>{e.payload.id===this._formId&&OZ.emit(`form-api`,{id:this._formId,state:this.store.state,options:this.options})}),n=OZ.on(`request-form-reset`,e=>{e.payload.id===this._formId&&this.reset()}),r=OZ.on(`request-form-force-submit`,e=>{e.payload.id===this._formId&&(this._devtoolsSubmissionOverride=!0,this.handleSubmit(),this._devtoolsSubmissionOverride=!1)}),i=()=>{r(),n(),t(),e.unsubscribe(),OZ.emit(`form-unmounted`,{id:this._formId})};this.options.listeners?.onMount?.({formApi:this});let{onMount:a}=this.options.validators||{};return OZ.emit(`form-api`,{id:this._formId,state:this.store.state,options:this.options}),a&&this.validateSync(`mount`),i},this.update=e=>{if(!e)return;let t=this.options;this.options=e;let n=e.defaultValues&&!UZ(e.defaultValues,t.defaultValues)&&!this.state.isTouched,r=!UZ(e.defaultState,t.defaultState)&&!this.state.isTouched;if(!(!n&&!r)){if(_Z(()=>{this.baseStore.setState(()=>sQ(Object.assign({},this.state,r?e.defaultState:{},n?{values:e.defaultValues}:{})))}),n){let e=oQ(this);for(let t of Object.keys(this.fieldInfo))Array.isArray(this.getFieldValue(t))&&e.bumpArrayVersion(t)}OZ.emit(`form-api`,{id:this._formId,state:this.store.state,options:this.options})}},this.reset=(e,t)=>{let{fieldMeta:n}=this.state,r=this.resetFieldMeta(n);e&&!t?.keepDefaultValues&&(this.options={...this.options,defaultValues:e}),this.baseStore.setState(()=>{let t=e??this.options.defaultValues??this.options.defaultState?.values;return e||Object.values(this.fieldInfo).forEach(e=>{e.instance&&e.instance.options.defaultValue!==void 0&&(t=jZ(t,e.instance.name,e.instance.options.defaultValue))}),sQ({...this.options.defaultState,values:t,fieldMetaBase:r})})},this.validateAllFields=async e=>{let t=[];return _Z(()=>{Object.values(this.fieldInfo).forEach(n=>{if(!n.instance)return;let r=n.instance;t.push(Promise.resolve().then(()=>r.validate(e,{skipFormValidation:!0,skipGroupValidation:!0}))),n.instance.store.state.meta.isTouched||n.instance.setMeta(e=>({...e,isTouched:!0}))})}),(await Promise.all(t)).flat()},this.validateArrayFieldsStartingFrom=async(e,t,n)=>{let r=this.getFieldValue(e),i=Array.isArray(r)?Math.max(r.length-1,0):null,a=[`${e}[${t}]`];for(let n=t+1;n<=(i??0);n++)a.push(`${e}[${n}]`);let o=Object.keys(this.fieldInfo).filter(e=>a.some(t=>e.startsWith(t))),s=[];return _Z(()=>{o.forEach(e=>{s.push(Promise.resolve().then(()=>this.validateField(e,n)))})}),(await Promise.all(s)).flat()},this.validateField=(e,t)=>{let n=this.fieldInfo[e]?.instance;if(!n){let{hasErrored:n}=this.validateSync(t);return n&&!this.options.asyncAlways?this.getFieldMeta(e)?.errors??[]:this.validateAsync(t).then(()=>this.getFieldMeta(e)?.errors??[])}return n.store.state.meta.isTouched||n.setMeta(e=>({...e,isTouched:!0})),n.validate(t)},this.validateSync=(e,t)=>{let n=BZ(e,{...this.options,form:this,group:t?.group,validationLogic:this.options.validationLogic||eQ}),r=!1,i={};return _Z(()=>{for(let e of n){if(!e.validate)continue;let{formError:n,fieldErrors:a}=lQ(this.runValidator({validate:e.validate,value:{value:this.state.values,formApi:this,validationSource:`form`},type:`validate`})),o=uQ(e.cause),s=new Set([...Object.keys(this.state.fieldMeta),...Object.keys(a||{})]);t?.filterFieldNames&&(s=new Set([...s].filter(t.filterFieldNames)));for(let e of s){if(this.baseStore.state.fieldMetaBase[e]===void 0&&!a?.[e])continue;let{errorMap:t,errorSourceMap:n}=this.getFieldMeta(e)??aQ,r=a?.[e],{newErrorValue:s,newSource:c}=WZ({newFormValidatorError:r,isPreviousErrorFromFormValidator:n?.[o]===`form`,previousErrorValue:t?.[o]});c===`form`&&(i[e]={...i[e],[o]:r}),t?.[o]!==s&&this.setFieldMeta(e,(e=aQ)=>({...e,errorMap:{...e.errorMap,[o]:s},errorSourceMap:{...e.errorSourceMap,[o]:c}}))}t?.dontUpdateFormErrorMap||this.state.errorMap?.[o]!==n&&this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[o]:n}})),(n||a)&&(r=!0)}if(t?.dontUpdateFormErrorMap)return;let a=uQ(`submit`);this.state.errorMap?.[a]&&e!==`submit`&&!r&&this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[a]:void 0}}));let o=uQ(`server`);this.state.errorMap?.[o]&&e!==`server`&&!r&&this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[o]:void 0}}))}),{hasErrored:r,fieldsErrorMap:i}},this.validateAsync=async(e,t)=>{let n=VZ(e,{...this.options,form:this,group:t?.group,validationLogic:this.options.validationLogic||eQ});this.state.isFormValidating||this.baseStore.setState(e=>({...e,isFormValidating:!0}));let r=[],i;for(let e of n){if(!e.validate)continue;let n=uQ(e.cause);this.state.validationMetaMap[n]?.lastAbortController.abort();let a=new AbortController;this.state.validationMetaMap[n]={lastAbortController:a},r.push(new Promise(async n=>{let r;try{r=await new Promise((t,n)=>{setTimeout(async()=>{if(a.signal.aborted)return t(void 0);try{t(await this.runValidator({validate:e.validate,value:{value:this.state.values,formApi:this,validationSource:`form`,signal:a.signal},type:`validateAsync`}))}catch(e){n(e)}},e.debounceMs)})}catch(e){r=e}let{formError:o,fieldErrors:s}=lQ(r);s&&(i=i?{...i,...s}:s);let c=uQ(e.cause),l=new Set([...Object.keys(this.state.fieldMeta),...Object.keys(i||{})]),u=Array.from(l);t?.filterFieldNames&&(u=u.filter(t.filterFieldNames));for(let e of u){if(this.baseStore.state.fieldMetaBase[e]===void 0&&!i?.[e])continue;let{errorMap:t,errorSourceMap:n}=this.getFieldMeta(e)??aQ,r=i?.[e],{newErrorValue:a,newSource:o}=WZ({newFormValidatorError:r,isPreviousErrorFromFormValidator:n?.[c]===`form`,previousErrorValue:t?.[c]});t?.[c]!==a&&this.setFieldMeta(e,(e=aQ)=>({...e,errorMap:{...e.errorMap,[c]:a},errorSourceMap:{...e.errorSourceMap,[c]:o}}))}t?.dontUpdateFormErrorMap||this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[c]:o}})),n(i?{fieldErrors:i,errorMapKey:c}:void 0)}))}let a=[],o={};if(r.length){a=await Promise.all(r);for(let e of a)if(e?.fieldErrors){let{errorMapKey:t}=e;for(let[n,r]of Object.entries(e.fieldErrors))o[n]={...o[n]||{},[t]:r}}}return this.baseStore.setState(e=>({...e,isFormValidating:!1})),o},this.validate=(e,t)=>{let{hasErrored:n,fieldsErrorMap:r}=this.validateSync(e,t);return n&&!this.options.asyncAlways?r:this.validateAsync(e,t)},this._handleSubmit=async e=>{this.baseStore.setState(e=>({...e,isSubmitted:!1,submissionAttempts:e.submissionAttempts+1,isSubmitSuccessful:!1})),_Z(()=>{Object.values(this.fieldInfo).forEach(e=>{e.instance&&(e.instance.store.state.meta.isTouched||e.instance.setMeta(e=>({...e,isTouched:!0})))})});let t=e??this.options.onSubmitMeta;if(!this.state.canSubmit&&!this._devtoolsSubmissionOverride&&this.baseStore.state.submissionAttempts<=1){this.options.onSubmitInvalid?.({value:this.state.values,formApi:this,meta:t});return}this.baseStore.setState(e=>({...e,isSubmitting:!0}));let n=()=>{this.baseStore.setState(e=>({...e,isSubmitting:!1}))};if(await this.validateAllFields(`submit`),!this.state.isFieldsValid){n(),this.options.onSubmitInvalid?.({value:this.state.values,formApi:this,meta:t}),OZ.emit(`form-submission`,{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!1,stage:`validateAllFields`,errors:Object.values(this.state.fieldMeta).map(e=>e.errors).flat()});return}if(await this.validate(`submit`),!this.state.isValid){n(),this.options.onSubmitInvalid?.({value:this.state.values,formApi:this,meta:t}),OZ.emit(`form-submission`,{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!1,stage:`validate`,errors:this.state.errors});return}_Z(()=>{Object.values(this.fieldInfo).forEach(e=>{e.instance?.triggerOnSubmitListener()})}),this.options.listeners?.onSubmit?.({formApi:this,meta:t});try{await this.options.onSubmit?.({value:this.state.values,formApi:this,meta:t}),_Z(()=>{this.baseStore.setState(e=>({...e,isSubmitted:!0,isSubmitSuccessful:!0})),OZ.emit(`form-submission`,{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!0}),n()})}catch(e){throw this.baseStore.setState(e=>({...e,isSubmitSuccessful:!1})),OZ.emit(`form-submission`,{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!1,stage:`inflight`,onError:e}),n(),e}},this.getFieldValue=e=>AZ(this.state.values,e),this.getFieldMeta=e=>this.state.fieldMeta[e],this.getFormGroupMeta=e=>this.formGroupMetaDerived.state[e],this.getFieldInfo=e=>this.fieldInfo[e]||={instance:null,validationMetaMap:{onChange:void 0,onBlur:void 0,onSubmit:void 0,onMount:void 0,onServer:void 0,onDynamic:void 0}},this.setFieldMeta=(e,t)=>{this.baseStore.setState(n=>({...n,fieldMetaBase:{...n.fieldMetaBase,[e]:kZ(t,n.fieldMetaBase[e])}}))},this.resetFieldMeta=e=>Object.keys(e).reduce((e,t)=>{let n=t;return e[n]=aQ,e},{}),this.setFieldValue=(e,t,n)=>{let r=n?.dontUpdateMeta??!1,i=n?.dontRunListeners??!1,a=n?.dontValidate??!1;_Z(()=>{r||this.setFieldMeta(e,e=>({...e,isTouched:!0,isDirty:!0,errorMap:{...e?.errorMap,onMount:void 0}})),this.baseStore.setState(n=>({...n,values:jZ(n.values,e,t)}))}),i||this.getFieldInfo(e).instance?.triggerOnChangeListener(),a||this.validateField(e,`change`)},this.deleteField=e=>{let t=[...Object.keys(this.fieldInfo).filter(t=>{let n=e.toString();return t!==n&&t.startsWith(n)}),e];this.baseStore.setState(e=>{let n={...e};return t.forEach(e=>{n.values=MZ(n.values,e),delete this.fieldInfo[e],delete n.fieldMetaBase[e]}),n})},this.pushFieldValue=(e,t,n)=>{this.setFieldValue(e,e=>[...Array.isArray(e)?e:[],t],n),oQ(this).bumpArrayVersion(e)},this.insertFieldValue=async(e,t,n,r)=>{this.setFieldValue(e,e=>[...e.slice(0,t),n,...e.slice(t)],KZ(r,{dontValidate:!0}));let i=r?.dontValidate??!1;i||await this.validateField(e,`change`),oQ(this).handleArrayInsert(e,t),i||await this.validateArrayFieldsStartingFrom(e,t,`change`)},this.replaceFieldValue=async(e,t,n,r)=>{this.setFieldValue(e,e=>e.map((e,r)=>r===t?n:e),KZ(r,{dontValidate:!0})),oQ(this).bumpArrayVersion(e),(r?.dontValidate??!1)||(await this.validateField(e,`change`),await this.validateArrayFieldsStartingFrom(e,t,`change`))},this.removeFieldValue=async(e,t,n)=>{let r=this.getFieldValue(e),i=Array.isArray(r)?Math.max(r.length-1,0):null;if(this.setFieldValue(e,e=>e.filter((e,n)=>n!==t),KZ(n,{dontValidate:!0})),oQ(this).handleArrayRemove(e,t),i!==null){let t=`${e}[${i}]`;this.deleteField(t)}(n?.dontValidate??!1)||(await this.validateField(e,`change`),await this.validateArrayFieldsStartingFrom(e,t,`change`))},this.swapFieldValues=(e,t,n,r)=>{this.setFieldValue(e,e=>{let r=e[t],i=e[n];return jZ(jZ(e,`${t}`,i),`${n}`,r)},KZ(r,{dontValidate:!0})),oQ(this).handleArraySwap(e,t,n),(r?.dontValidate??!1)||(this.validateField(e,`change`),this.validateField(`${e}[${t}]`,`change`),this.validateField(`${e}[${n}]`,`change`))},this.moveFieldValues=(e,t,n,r)=>{this.setFieldValue(e,e=>{let r=[...e];return r.splice(n,0,r.splice(t,1)[0]),r},KZ(r,{dontValidate:!0})),oQ(this).handleArrayMove(e,t,n),(r?.dontValidate??!1)||(this.validateField(e,`change`),this.validateField(`${e}[${t}]`,`change`),this.validateField(`${e}[${n}]`,`change`))},this.clearFieldValues=(e,t)=>{let n=this.getFieldValue(e),r=Array.isArray(n)?Math.max(n.length-1,0):null;if(this.setFieldValue(e,[],KZ(t,{dontValidate:!0})),oQ(this).bumpArrayVersion(e),r!==null)for(let t=0;t<=r;t++){let n=`${e}[${t}]`;this.deleteField(n)}(t?.dontValidate??!1)||this.validateField(e,`change`)},this.resetField=e=>{this.baseStore.setState(t=>{let n=this.getFieldInfo(e).instance?.options.defaultValue,r=AZ(this.options.defaultValues,e),i=n??r;return{...t,fieldMetaBase:{...t.fieldMetaBase,[e]:aQ},values:i===void 0?t.values:jZ(t.values,e,i)}})},this.setErrorMap=e=>{_Z(()=>{Object.entries(e).forEach(([e,t])=>{let n=e;if(HZ(t)){let{formError:e,fieldErrors:r}=lQ(t);for(let e of Object.keys(this.fieldInfo))this.getFieldMeta(e)&&this.setFieldMeta(e,t=>({...t,errorMap:{...t.errorMap,[n]:r?.[e]},errorSourceMap:{...t.errorSourceMap,[n]:`form`}}));this.baseStore.setState(t=>({...t,errorMap:{...t.errorMap,[n]:e}}))}else this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[n]:t}}))})})},this.getAllErrors=()=>({form:{errors:this.state.errors,errorMap:this.state.errorMap},fields:Object.entries(this.state.fieldMeta).reduce((e,[t,n])=>(Object.keys(n).length&&n.errors.length&&(e[t]={errors:n.errors,errorMap:n.errorMap}),e),{})}),this.parseValuesWithSchema=e=>rQ.validate({value:this.state.values,validationSource:`form`},e),this.parseValuesWithSchemaAsync=e=>rQ.validateAsync({value:this.state.values,validationSource:`form`},e),this.timeoutIds={validations:{},listeners:{},formListeners:{}},this._formId=e?.formId??XZ(),this._devtoolsSubmissionOverride=!1;let t=sQ({...e?.defaultState,values:e?.defaultValues??e?.defaultState?.values});if(e?.transform){t=e.transform({state:t}).state;for(let e of Object.keys(t.errorMap)){let n=t.errorMap[e];if(!(n===void 0||!HZ(n)))for(let r of Object.keys(n.fields)){let i=n.fields[r];if(i===void 0)continue;let a=t.fieldMetaBase[r];t.fieldMetaBase[r]={isTouched:!1,isValidating:!1,isBlurred:!1,isDirty:!1,_arrayVersion:0,_pendingValidationsCount:0,...a??{},errorSourceMap:{...a?.errorSourceMap??{},onChange:`form`},errorMap:{...a?.errorMap??{},[e]:i}}}}}this.baseStore=wZ(t);let n;this.fieldMetaDerived=wZ(e=>{let t=this.baseStore.get(),r=0,i={};for(let a of Object.keys(t.fieldMetaBase)){let o=t.fieldMetaBase[a],s=n?.fieldMetaBase[a],c=e?.[a],l=AZ(t.values,a),u=c?.errors;if(!s||o.errorMap!==s.errorMap){u=Object.values(o.errorMap??{}).filter(e=>e!==void 0);let e=this.getFieldInfo(a)?.instance;(!e||!e.options.disableErrorFlat)&&(u=u.flat(1))}let d=!zZ(u),f=!o.isDirty,p=UZ(l,this.getFieldInfo(a)?.instance?.options.defaultValue??AZ(this.options.defaultValues,a));if(c&&c.isPristine===f&&c.isValid===d&&c.isDefaultValue===p&&c.errors===u&&o===s){i[a]=c,r++;continue}i[a]={...o,errors:u??[],isPristine:f,isValid:d,isDefaultValue:p}}return Object.keys(t.fieldMetaBase).length?e&&r===Object.keys(t.fieldMetaBase).length?e:(n=this.baseStore.get(),i):i}),this.formGroupMetaDerived=wZ(e=>{let t=this.baseStore.get(),n=this.fieldMetaDerived.get(),r={};for(let i of this.formGroupApis){let a=i.name,o=t.formGroupStateBase[a]??{isSubmitted:!1,isSubmitting:!1,isValidating:!1,submissionAttempts:0,isSubmitSuccessful:!1},s=n[a],c=!1,l=!0,u=!1,d=!1,f=!0,p=!1;for(let e in n){if(e===a||!$Z(a,e))continue;let t=n[e];t&&(t.isValidating&&(c=!0),t.isValid||(l=!1),t.isTouched&&(u=!0),t.isBlurred&&(d=!0),t.isDefaultValue||(f=!1),t.isDirty&&(p=!0))}let m=!p,h=!!c||o.isValidating,g=s?.errorMap??{},_=s?.errorSourceMap??{},v=!!(g.onMount||Object.entries(n).some(([e,t])=>t&&e!==a&&$Z(a,e)&&t.errorMap.onMount)),y=e?.[a],b=y?.errors??[];(!y||y.__srcErrorMap!==g)&&(b=Object.values(g).reduce((e,t)=>{if(t===void 0)return e;if(t&&typeof t==`object`&&`fields`in t){let n=t.group;return n!==void 0&&e.push(n),e}return e.push(t),e},[]));let x=b.length===0,S=l&&x,C=i.options.canSubmitWhenInvalid??!1,w=o.submissionAttempts===0&&!u&&!v||!h&&!o.isSubmitting&&S||C;if(y&&y.errorMap===g&&y.errorSourceMap===_&&y.errors===b&&y.isFieldsValidating===c&&y.isFieldsValid===l&&y.isGroupValid===x&&y.isValid===S&&y.canSubmit===w&&y.isTouched===u&&y.isBlurred===d&&y.isPristine===m&&y.isDefaultValue===f&&y.isDirty===p&&y.isValidating===h&&y.isSubmitting===o.isSubmitting&&y.isSubmitted===o.isSubmitted&&y.submissionAttempts===o.submissionAttempts&&y.isSubmitSuccessful===o.isSubmitSuccessful){r[a]=y;continue}let T={...o,errorMap:g,errorSourceMap:_,_arrayVersion:s?._arrayVersion??0,isTouched:u,isBlurred:d,isDirty:p,isPristine:m,isDefaultValue:f,isValid:S,errors:b,isValidating:h,isFieldsValidating:c,isFieldsValid:l,isGroupValid:x,canSubmit:w};Object.defineProperty(T,"__srcErrorMap",{value:g,enumerable:!1,configurable:!0}),r[a]=T}return r});let r;this.store=wZ(e=>{let t=this.baseStore.get(),n=this.fieldMetaDerived.get(),i=Object.values(n).filter(Boolean),a=i.some(e=>e.isValidating),o=i.every(e=>e.isValid),s=i.some(e=>e.isTouched),c=i.some(e=>e.isBlurred),l=i.every(e=>e.isDefaultValue),u=s&&t.errorMap?.onMount,d=i.some(e=>e.isDirty),f=!d,p=!!(t.errorMap?.onMount||i.some(e=>e?.errorMap?.onMount)),m=!!a,h=e?.errors??[];(!r||t.errorMap!==r.errorMap)&&(h=Object.values(t.errorMap).reduce((e,t)=>t===void 0?e:t&&HZ(t)?(e.push(t.form),e):(e.push(t),e),[]));let g=h.length===0,_=o&&g,v=this.options.canSubmitWhenInvalid??!1,y=t.submissionAttempts===0&&!s&&!p||!m&&!t.isSubmitting&&_||v,b=t.errorMap;if(u&&(h=h.filter(e=>e!==t.errorMap.onMount),b=Object.assign(b,{onMount:void 0})),e&&r&&e.errorMap===b&&e.fieldMeta===this.fieldMetaDerived.state&&e.errors===h&&e.isFieldsValidating===a&&e.isFieldsValid===o&&e.isFormValid===g&&e.isValid===_&&e.canSubmit===y&&e.isTouched===s&&e.isBlurred===c&&e.isPristine===f&&e.isDefaultValue===l&&e.isDirty===d&&UZ(r,t))return e;let x={...t,errorMap:b,fieldMeta:this.fieldMetaDerived.state,errors:h,isFieldsValidating:a,isFieldsValid:o,isFormValid:g,isValid:_,canSubmit:y,isTouched:s,isBlurred:c,isPristine:f,isDefaultValue:l,isDirty:d};return r=this.baseStore.get(),x}),this.handleSubmit=this.handleSubmit.bind(this),this.update(e||{})}get state(){return this.store.state}get formId(){return this._formId}runValidator(e){return iQ(e.validate)?rQ[e.type](e.value,e.validate):e.validate(e.value)}handleSubmit(e){return this._handleSubmit(e)}};function lQ(e){return e?HZ(e)?{formError:lQ(e.form).formError,fieldErrors:e.fields}:{formError:e}:{formError:void 0}}function uQ(e){switch(e){case`submit`:return`onSubmit`;case`blur`:return`onBlur`;case`mount`:return`onMount`;case`server`:return`onServer`;case`dynamic`:return`onDynamic`;default:return`onChange`}}var dQ=class e{constructor(t){this.options={},this.mount=()=>{this.options.defaultValue!==void 0&&!this.getMeta().isTouched&&this.form.setFieldValue(this.name,this.options.defaultValue,{dontUpdateMeta:!0});let e=this.getInfo();e.instance=this,this.update(this.options);let{onMount:t}=this.options.validators||{};if(t){let e=this.runValidator({validate:t,value:{value:this.state.value,fieldApi:this,validationSource:`field`},type:`validate`});e&&this.setMeta(t=>({...t,errorMap:{...t?.errorMap,onMount:e},errorSourceMap:{...t?.errorSourceMap,onMount:`field`}}))}return this.options.listeners?.onMount?.({value:this.state.value,fieldApi:this}),()=>{for(let[e,t]of Object.entries(this.timeoutIds.validations))t&&(clearTimeout(t),this.timeoutIds.validations[e]=null);for(let[e,t]of Object.entries(this.timeoutIds.listeners))t&&(clearTimeout(t),this.timeoutIds.listeners[e]=null);for(let[e,t]of Object.entries(this.timeoutIds.formListeners))t&&(clearTimeout(t),this.timeoutIds.formListeners[e]=null);let e=this.form.fieldInfo[this.name];if(e&&e.instance===this){for(let[t,n]of Object.entries(e.validationMetaMap))n?.lastAbortController.abort(),e.validationMetaMap[t]=void 0;this.form.baseStore.setState(e=>({...e,fieldMetaBase:{...e.fieldMetaBase,[this.name]:{...aQ,isTouched:e.fieldMetaBase[this.name]?.isTouched??aQ.isTouched,isBlurred:e.fieldMetaBase[this.name]?.isBlurred??aQ.isBlurred,isDirty:e.fieldMetaBase[this.name]?.isDirty??aQ.isDirty}}})),e.instance=null,this.options.listeners?.onUnmount?.({value:this.state.value,fieldApi:this}),this.form.options.listeners?.onFieldUnmount?.({formApi:this.form,fieldApi:this})}}},this.update=e=>{this.options=e,this.name=e.name,!this.state.meta.isTouched&&this.options.defaultValue!==void 0&&(UZ(this.form.getFieldValue(this.name),e.defaultValue)||this.form.setFieldValue(this.name,e.defaultValue,{dontUpdateMeta:!0,dontValidate:!0,dontRunListeners:!0})),this.form.getFieldMeta(this.name)||this.form.setFieldMeta(this.name,this.state.meta)},this.getValue=()=>this.form.getFieldValue(this.name),this.setValue=(e,t)=>{this.form.setFieldValue(this.name,e,KZ(t,{dontRunListeners:!0,dontValidate:!0})),t?.dontRunListeners||this.triggerOnChangeListener(),t?.dontValidate||this.validate(`change`)},this.getMeta=()=>this.store.state.meta,this.setMeta=e=>this.form.setFieldMeta(this.name,e),this.getInfo=()=>this.form.getFieldInfo(this.name),this.pushValue=(e,t)=>{this.form.pushFieldValue(this.name,e,KZ(t,{dontRunListeners:!0})),t?.dontRunListeners||this.triggerOnChangeListener()},this.insertValue=(e,t,n)=>{this.form.insertFieldValue(this.name,e,t,KZ(n,{dontRunListeners:!0})),n?.dontRunListeners||this.triggerOnChangeListener()},this.replaceValue=(e,t,n)=>{this.form.replaceFieldValue(this.name,e,t,KZ(n,{dontRunListeners:!0})),n?.dontRunListeners||this.triggerOnChangeListener()},this.removeValue=(e,t)=>{this.form.removeFieldValue(this.name,e,KZ(t,{dontRunListeners:!0})),t?.dontRunListeners||this.triggerOnChangeListener()},this.swapValues=(e,t,n)=>{this.form.swapFieldValues(this.name,e,t,KZ(n,{dontRunListeners:!0})),n?.dontRunListeners||this.triggerOnChangeListener()},this.moveValue=(e,t,n)=>{this.form.moveFieldValues(this.name,e,t,KZ(n,{dontRunListeners:!0})),n?.dontRunListeners||this.triggerOnChangeListener()},this.clearValues=e=>{this.form.clearFieldValues(this.name,KZ(e,{dontRunListeners:!0})),e?.dontRunListeners||this.triggerOnChangeListener()},this.getLinkedFields=t=>{let n=Object.values(this.form.fieldInfo),r=[];for(let i of n){if(!i.instance||!(i.instance instanceof e))continue;let{onChangeListenTo:n,onBlurListenTo:a}=i.instance.options.validators||{};t===`change`&&n?.includes(this.name)&&r.push(i.instance),t===`blur`&&a?.includes(this.name)&&r.push(i.instance)}return r},this.validateSync=(e,t)=>{let n=BZ(e,{...this.options,form:this.form,fieldName:this.name,validationLogic:this.form.options.validationLogic||eQ}),r=this.getLinkedFields(e).reduce((t,n)=>{let r=BZ(e,{...n.options,form:n.form,fieldName:n.name,validationLogic:n.form.options.validationLogic||eQ});return r.forEach(e=>{e.field=n}),t.concat(r)},[]),i=!1;_Z(()=>{let e=(e,n)=>{let r=pQ(n.cause),a=n.validate?fQ(e.runValidator({validate:n.validate,value:{value:e.store.state.value,validationSource:`field`,fieldApi:e},type:`validate`})):void 0,o=t[r],{newErrorValue:s,newSource:c}=GZ({formLevelError:o,fieldLevelError:a});e.state.meta.errorMap?.[r]!==s&&e.setMeta(e=>({...e,errorMap:{...e.errorMap,[r]:s},errorSourceMap:{...e.errorSourceMap,[r]:c}})),s&&(i=!0)};for(let t of n)e(this,t);for(let t of r)t.validate&&e(t.field,t)});let a=pQ(`submit`);return this.state.meta.errorMap?.[a]&&e!==`submit`&&!i&&this.setMeta(e=>({...e,errorMap:{...e.errorMap,[a]:void 0},errorSourceMap:{...e.errorSourceMap,[a]:void 0}})),{hasErrored:i}},this.validateAsync=async(e,t)=>{let n=VZ(e,{...this.options,form:this.form,fieldName:this.name,validationLogic:this.form.options.validationLogic||eQ}),r=await t,i=this.getLinkedFields(e).reduce((t,n)=>{let r=VZ(e,{...n.options,form:n.form,fieldName:n.name,validationLogic:n.form.options.validationLogic||eQ});return r.forEach(e=>{e.field=n}),t.concat(r)},[]),a=[],o=[],s=n.some(e=>e.validate),c=Array.from(new Set(i.filter(e=>e.validate).map(e=>e.field)));_Z(()=>{s&&this.startValidation();for(let e of c)e.startValidation()});let l=(e,t,n)=>{let i=pQ(t.cause),a=e.getInfo();a.validationMetaMap[i]?.lastAbortController.abort();let o=new AbortController;a.validationMetaMap[i]={lastAbortController:o},n.push(new Promise(async n=>{let a;try{a=await new Promise((n,r)=>{e.timeoutIds.validations[t.cause]&&(clearTimeout(e.timeoutIds.validations[t.cause]),e.endValidation()),e.timeoutIds.validations[t.cause]=setTimeout(async()=>{if(o.signal.aborted)return n(void 0);try{n(await this.runValidator({validate:t.validate,value:{value:e.store.state.value,fieldApi:e,signal:o.signal,validationSource:`field`},type:`validateAsync`}))}catch(e){r(e)}},t.debounceMs)})}catch(e){a=e}if(o.signal.aborted)return n(void 0);let s=fQ(a),c=r[e.name]?.[i],{newErrorValue:l,newSource:u}=GZ({formLevelError:c,fieldLevelError:s});if(e.getInfo().instance!==e)return n(void 0);e.setMeta(e=>({...e,errorMap:{...e?.errorMap,[i]:l},errorSourceMap:{...e.errorSourceMap,[i]:u}})),n(l)}))};for(let e of n)e.validate&&l(this,e,a);for(let e of i)e.validate&&l(e.field,e,o);let u=[];return(a.length||o.length)&&(u=await Promise.all(a),await Promise.all(o)),_Z(()=>{s&&this.endValidation();for(let e of c)e.endValidation()}),u.filter(Boolean)},this.validate=(e,t)=>{if(!this.state.meta.isTouched)return[];let n=t?.skipGroupValidation?[]:Array.from(this.form.formGroupApis).filter(e=>this.name.startsWith(e.name)),r=(t?.skipFormValidation?{fieldsErrorMap:{}}:this.form.validateSync(e)).fieldsErrorMap[this.name]??{};if(!t?.skipFormValidation)for(let t of n){if(t.state.meta.submissionAttempts===0)continue;let{fieldsErrorMap:n}=this.form.validateSync(e,{group:t,dontUpdateFormErrorMap:!0,filterFieldNames:e=>$Z(t.name,e)});r={...r,...n[this.name]??{}}}let{hasErrored:i}=this.validateSync(e,r),a=new WeakMap;for(let t of n){let{hasErrored:n}=t.validateSync(e,{},{skipRelatedFieldValidation:!0});a.set(t,n)}if(i&&!this.options.asyncAlways){this.getInfo().validationMetaMap[pQ(e)]?.lastAbortController.abort();let t=[];for(let r of n)r.getInfo().validationMetaMap[pQ(e)]?.lastAbortController.abort(),t.push(r.state.meta.errors);return[...this.state.meta.errors,...t.flat()]}let o=t?.skipFormValidation?Promise.resolve({}):this.form.validateAsync(e),s=this.validateAsync(e,o),c=[];for(let t of n)a.get(t)&&!t.options.asyncAlways||c.push(t.validateAsync(e,o,{skipRelatedFieldValidation:!0}));return c.length===0?s:Promise.all([s,...c]).then(e=>e.flat())},this.handleChange=e=>{this.setValue(e)},this.handleBlur=()=>{this.state.meta.isTouched||this.setMeta(e=>({...e,isTouched:!0})),this.state.meta.isBlurred||this.setMeta(e=>({...e,isBlurred:!0})),this.validate(`blur`),this.triggerOnBlurListener()},this.setErrorMap=e=>{this.setMeta(t=>({...t,errorMap:{...t.errorMap,...e}}))},this.parseValueWithSchema=e=>rQ.validate({value:this.state.value,validationSource:`field`},e),this.parseValueWithSchemaAsync=e=>rQ.validateAsync({value:this.state.value,validationSource:`field`},e),this.triggerOnBlurListener=()=>{let e=this.form.options.listeners?.onBlurDebounceMs;e&&e>0?(this.timeoutIds.formListeners.blur&&clearTimeout(this.timeoutIds.formListeners.blur),this.timeoutIds.formListeners.blur=setTimeout(()=>{this.form.options.listeners?.onBlur?.({formApi:this.form,fieldApi:this})},e)):this.form.options.listeners?.onBlur?.({formApi:this.form,fieldApi:this});let t=this.options.listeners?.onBlurDebounceMs;t&&t>0?(this.timeoutIds.listeners.blur&&clearTimeout(this.timeoutIds.listeners.blur),this.timeoutIds.listeners.blur=setTimeout(()=>{this.options.listeners?.onBlur?.({value:this.state.value,fieldApi:this})},t)):this.options.listeners?.onBlur?.({value:this.state.value,fieldApi:this})},this.triggerOnChangeListener=()=>{let e=this.form.options.listeners?.onChangeDebounceMs;e&&e>0?(this.timeoutIds.formListeners.change&&clearTimeout(this.timeoutIds.formListeners.change),this.timeoutIds.formListeners.change=setTimeout(()=>{this.form.options.listeners?.onChange?.({formApi:this.form,fieldApi:this})},e)):this.form.options.listeners?.onChange?.({formApi:this.form,fieldApi:this});let t=this.options.listeners?.onChangeDebounceMs;t&&t>0?(this.timeoutIds.listeners.change&&clearTimeout(this.timeoutIds.listeners.change),this.timeoutIds.listeners.change=setTimeout(()=>{this.options.listeners?.onChange?.({value:this.state.value,fieldApi:this})},t)):this.options.listeners?.onChange?.({value:this.state.value,fieldApi:this});for(let e of this.form.formGroupApis)$Z(e.name,this.name)&&e.triggerOnChangeListener()},this.triggerOnSubmitListener=()=>{this.options.listeners?.onSubmit?.({value:this.state.value,fieldApi:this})},this.form=t.form,this.name=t.name,this.options=t,this.timeoutIds={validations:{},listeners:{},formListeners:{}},this.store=wZ(e=>{this.form.store.get();let n=this.form.getFieldMeta(this.name)??{...aQ,...t.defaultMeta},r=this.form.getFieldValue(this.name);return!n.isTouched&&r===void 0&&this.options.defaultValue!==void 0&&!UZ(r,this.options.defaultValue)&&(r=this.options.defaultValue),e&&e.value===r&&e.meta===n?e:{value:r,meta:n}})}get state(){return this.store.state}runValidator(e){return iQ(e.validate)?rQ[e.type](e.value,e.validate):e.validate(e.value)}startValidation(){this.setMeta(e=>{let t=e._pendingValidationsCount+1;return{...e,_pendingValidationsCount:t,isValidating:t>0&&!e.isValidating||e.isValidating}})}endValidation(){this.setMeta(e=>{let t=Math.max(0,e._pendingValidationsCount-1);return{...e,_pendingValidationsCount:t,isValidating:t===0&&e.isValidating?!1:e.isValidating}})}};function fQ(e){if(e)return e}function pQ(e){switch(e){case`submit`:return`onSubmit`;case`blur`:return`onBlur`;case`mount`:return`onMount`;case`server`:return`onServer`;case`dynamic`:return`onDynamic`;default:return`onChange`}}function mQ(e){return{isSubmitted:e.isSubmitted??!1,isSubmitting:e.isSubmitting??!1,isValidating:e.isValidating??!1,submissionAttempts:e.submissionAttempts??0,isSubmitSuccessful:e.isSubmitSuccessful??!1}}function hQ(e){return{...aQ,...e,errors:[],isPristine:!0,isValid:!0,isDefaultValue:!0,isFieldsValidating:!1,isFieldsValid:!0,isGroupValid:!0,canSubmit:!0,isSubmitting:!1,isSubmitted:!1,isValidating:!1,submissionAttempts:0,isSubmitSuccessful:!1}}var gQ=class e{constructor(t){this.options={},this.setFormGroupState=e=>{this.form.baseStore.setState(t=>{let n=t.formGroupStateBase[this.name]??mQ({});return{...t,formGroupStateBase:{...t.formGroupStateBase,[this.name]:e(n)}}})},this._lastDistributedFieldNames={},this.update=e=>{this.options=e,this.name=e.name,!this.state.meta.isTouched&&this.options.defaultValue!==void 0&&(UZ(this.form.getFieldValue(this.name),e.defaultValue)||this.form.setFieldValue(this.name,e.defaultValue,{dontUpdateMeta:!0,dontValidate:!0,dontRunListeners:!0})),this.form.getFieldMeta(this.name)||this.form.setFieldMeta(this.name,{...aQ,...this.options.defaultMeta})},this.mount=()=>{this.update(this.options),this.form.formGroupApis.add(this),this.fieldInfo.instance=this,this.form.baseStore.setState(e=>({...e,formGroupStateBase:{...e.formGroupStateBase,[this.name]:e.formGroupStateBase[this.name]??mQ({...this.options.defaultState})}}));let{onMount:e}=this.options.validators||{};if(e){let t=this.runValidator({validate:e,value:{value:this.state.value,groupApi:this,validationSource:`form`},type:`validate`}),n=t,r;vQ(t)&&(n=t.group,r=t.fields);let i=_Q(n);i&&this.setMeta(e=>({...e,errorMap:{...e.errorMap,onMount:i},errorSourceMap:{...e.errorSourceMap,onMount:`field`}})),this.distributeFieldErrors(`onMount`,r)}return this.options.listeners?.onMount?.({value:this.state.value,groupApi:this}),()=>{for(let[e,t]of Object.entries(this.timeoutIds.validations))t&&(clearTimeout(t),this.timeoutIds.validations[e]=null);for(let[e,t]of Object.entries(this.timeoutIds.listeners))t&&(clearTimeout(t),this.timeoutIds.listeners[e]=null);for(let[e,t]of Object.entries(this.timeoutIds.formListeners))t&&(clearTimeout(t),this.timeoutIds.formListeners[e]=null);if(this.fieldInfo.instance===this){for(let[e,t]of Object.entries(this.fieldInfo.validationMetaMap))t?.lastAbortController.abort(),this.fieldInfo.validationMetaMap[e]=void 0;this.form.formGroupApis.delete(this),this.form.baseStore.setState(e=>({...e,formGroupStateBase:{...e.formGroupStateBase,[this.name]:mQ({})}})),this.fieldInfo.instance=null,this.options.listeners?.onUnmount?.({value:this.state.value,groupApi:this})}}},this.setValue=(e,t)=>{this.form.setFieldValue(this.name,e,KZ(t,{dontRunListeners:!0,dontValidate:!0})),t?.dontRunListeners||this.triggerOnChangeListener(),t?.dontValidate||this.validate(`change`)},this.getMeta=()=>this.store.state.meta,this.setMeta=e=>this.form.setFieldMeta(this.name,e),this.getInfo=()=>this.fieldInfo,this.getRelatedFields=()=>{let e=Object.values(this.form.fieldInfo),t=[];for(let n of e)n.instance&&n.instance instanceof dQ&&n.instance.name.startsWith(this.name)&&t.push(n.instance);return t},this.getRelatedFieldMetasDerived=()=>{let e=Object.entries(this.form.fieldMetaDerived.state),t=[];for(let[n,r]of e)n!==this.name&&$Z(this.name,n)&&t.push({...r,name:n});return t},this.buildChildFieldName=e=>e===``?this.name:e.startsWith(`[`)?`${this.name}${e}`:`${this.name}.${e}`,this.distributeFieldErrors=(e,t)=>{let n=this._lastDistributedFieldNames[e]??new Set,r=new Set;if(t)for(let[e,n]of Object.entries(t))n!=null&&n!==!1&&r.add(this.buildChildFieldName(e));let i=new Set([...n,...r]),a=!1;for(let n of i){let r=n.startsWith(this.name+`[`)?n.slice(this.name.length):n.slice(this.name.length+1),i=t?.[r],o=this.form.getFieldMeta(n);if(!o&&!i)continue;let s=o?.errorMap[e],{newErrorValue:c,newSource:l}=WZ({newFormValidatorError:i,isPreviousErrorFromFormValidator:o?.errorSourceMap[e]===`form`,previousErrorValue:s});c&&(a=!0),(s!==c||o?.errorSourceMap[e]!==l)&&this.form.setFieldMeta(n,(t=aQ)=>({...t,errorMap:{...t.errorMap,[e]:c},errorSourceMap:{...t.errorSourceMap,[e]:l}}))}return this._lastDistributedFieldNames[e]=r,a},this.validateSync=(t,n,r={})=>{let i=BZ(t,{...this.options,form:this.form,group:this,validationLogic:this.options.validationLogic||this.form.options.validationLogic||eQ}),a=(r.skipRelatedFieldValidation?[]:this.getRelatedFields()).reduce((e,n)=>{let r=BZ(t,{...n.options,form:n.form,validationLogic:n.form.options.validationLogic||eQ});return r.forEach(e=>{e.field=n}),e.concat(r)},[]),o=!1;_Z(()=>{let t=(t,r)=>{let i=bQ(r.cause),a=t===this,s;r.validate&&(s=t.runValidator({validate:r.validate,value:{value:t.store.state.value,validationSource:a?`form`:`field`,...t instanceof e?{groupApi:t}:{fieldApi:t}},type:`validate`}));let c=s,l;a&&vQ(s)&&(c=s.group,l=s.fields);let u=_Q(c),d=n[i],{newErrorValue:f,newSource:p}=GZ({formLevelError:d,fieldLevelError:u});t.state.meta.errorMap?.[i]!==f&&t.setMeta(e=>({...e,errorMap:{...e.errorMap,[i]:f},errorSourceMap:{...e.errorSourceMap,[i]:p}})),f&&(o=!0),a&&this.distributeFieldErrors(i,l)&&(o=!0)};for(let e of i)t(this,e);for(let e of a)e.validate&&t(e.field,e)});let s=bQ(`submit`);return this.state.meta.errorMap?.[s]&&t!==`submit`&&!o&&this.setMeta(e=>({...e,errorMap:{...e.errorMap,[s]:void 0},errorSourceMap:{...e.errorSourceMap,[s]:void 0}})),{hasErrored:o}},this.validateAsync=async(t,n,r={})=>{let i=VZ(t,{...this.options,form:this.form,group:this,validationLogic:this.options.validationLogic||this.form.options.validationLogic||eQ}),a=await n,o=r.skipRelatedFieldValidation?[]:this.getRelatedFields(),s=o.reduce((e,n)=>{let r=VZ(t,{...n.options,form:n.form,validationLogic:n.form.options.validationLogic||eQ});return r.forEach(e=>{e.field=n}),e.concat(r)},[]),c=[],l=[],u=i.some(e=>e.validate)||s.some(e=>e.validate);if(u){this.state.meta.isValidating||this.setMeta(e=>({...e,isValidating:!0}));for(let e of o)e.setMeta(e=>({...e,isValidating:!0}))}let d=(t,n,r)=>{let i=bQ(n.cause),o=t.getInfo();o.validationMetaMap[i]?.lastAbortController.abort();let s=new AbortController;o.validationMetaMap[i]={lastAbortController:s};let c=t===this;r.push(new Promise(async r=>{let o;try{o=await new Promise((r,i)=>{t.timeoutIds.validations[n.cause]&&clearTimeout(t.timeoutIds.validations[n.cause]),t.timeoutIds.validations[n.cause]=setTimeout(async()=>{if(s.signal.aborted)return r(void 0);try{r(await this.runValidator({validate:n.validate,value:{value:t.store.state.value,signal:s.signal,validationSource:c?`form`:`field`,...t instanceof e?{groupApi:t}:{fieldApi:t}},type:`validateAsync`}))}catch(e){i(e)}},n.debounceMs)})}catch(e){o=e}if(s.signal.aborted)return r(void 0);let l=o,u;c&&vQ(o)&&(l=o.group,u=o.fields);let d=_Q(l),f=a[t.name]?.[i],{newErrorValue:p,newSource:m}=GZ({formLevelError:f,fieldLevelError:d});if(t.getInfo().instance!==t)return r(void 0);t.setMeta(e=>({...e,errorMap:{...e?.errorMap,[i]:p},errorSourceMap:{...e.errorSourceMap,[i]:m}})),c&&this.distributeFieldErrors(i,u),r(p)}))};for(let e of i)e.validate&&d(this,e,c);for(let e of s)e.validate&&d(e.field,e,l);let f=[];if((c.length||l.length)&&(f=await Promise.all(c),await Promise.all(l)),u){this.setMeta(e=>({...e,isValidating:!1}));for(let e of o)e.setMeta(e=>({...e,isValidating:!1}))}return f.filter(Boolean)},this.validateAllFields=async e=>{let t=[];return _Z(()=>{Object.values(this.getRelatedFields()).forEach(n=>{t.push(Promise.resolve().then(()=>n.validate(e,{skipFormValidation:!0,skipGroupValidation:!0}))),n.store.state.meta.isTouched||n.setMeta(e=>({...e,isTouched:!0}))})}),(await Promise.all(t)).flat()},this.validateArrayFieldsStartingFrom=(e,t,n)=>this.form.validateArrayFieldsStartingFrom(e,t,n),this.validateField=(e,t)=>this.form.validateField(e,t),this.getFieldValue=e=>this.form.getFieldValue(e),this.getFieldMeta=e=>this.form.getFieldMeta(e),this.setFieldMeta=(e,t)=>this.form.setFieldMeta(e,t),this.setFieldValue=(e,t)=>this.form.setFieldValue(e,t),this.deleteField=e=>this.form.deleteField(e),this.pushFieldValue=(e,t)=>this.form.pushFieldValue(e,t),this.insertFieldValue=(e,t,n)=>this.form.insertFieldValue(e,t,n),this.replaceFieldValue=(e,t,n)=>this.form.replaceFieldValue(e,t,n),this.swapFieldValues=(e,t,n)=>this.form.swapFieldValues(e,t,n),this.moveFieldValues=(e,t,n)=>this.form.moveFieldValues(e,t,n),this.clearFieldValues=e=>this.form.clearFieldValues(e),this.resetField=e=>this.form.resetField(e),this.removeFieldValue=(e,t)=>this.form.removeFieldValue(e,t),this.areRelatedFieldsValid=()=>Object.values(this.getRelatedFields()).every(e=>e.state.meta.isValid),this.validate=(e,t)=>{let{fieldsErrorMap:n}=t?.skipFormValidation?{fieldsErrorMap:{}}:this.form.validateSync(e,{dontUpdateFormErrorMap:!0,filterFieldNames:e=>$Z(this.name,e)}),{hasErrored:r}=this.validateSync(e,n[this.name]??{},{skipRelatedFieldValidation:t?.skipRelatedFieldValidation});if(r&&!this.options.asyncAlways)return this.getInfo().validationMetaMap[bQ(e)]?.lastAbortController.abort(),this.state.meta.errors;let i=t?.skipFormValidation?Promise.resolve({}):this.form.validateAsync(e,{dontUpdateFormErrorMap:!0,filterFieldNames:e=>$Z(this.name,e)});return this.validateAsync(e,i,{skipRelatedFieldValidation:t?.skipRelatedFieldValidation})},this.triggerOnChangeListener=()=>{let e=this.form.options.listeners?.onChangeGroupDebounceMs;e&&e>0?(this.timeoutIds.formListeners.change&&clearTimeout(this.timeoutIds.formListeners.change),this.timeoutIds.formListeners.change=setTimeout(()=>{this.form.options.listeners?.onChangeGroup?.({formApi:this.form,groupApi:this})},e)):this.form.options.listeners?.onChangeGroup?.({formApi:this.form,groupApi:this});let t=this.options.listeners?.onChangeDebounceMs;t&&t>0?(this.timeoutIds.listeners.change&&clearTimeout(this.timeoutIds.listeners.change),this.timeoutIds.listeners.change=setTimeout(()=>{this.options.listeners?.onChange?.({value:this.state.value,groupApi:this})},t)):this.options.listeners?.onChange?.({value:this.state.value,groupApi:this})},this.triggerOnSubmitListener=()=>{this.options.listeners?.onSubmit?.({value:this.state.value,groupApi:this})},this._handleSubmit=async e=>{this.setFormGroupState(e=>({...e,isSubmitted:!1,submissionAttempts:e.submissionAttempts+1,isSubmitSuccessful:!1})),_Z(()=>{Object.values(this.getRelatedFields()).forEach(e=>{e.state.meta.isTouched||e.setMeta(e=>({...e,isTouched:!0}))})});let t=e??this.options.onSubmitMeta;this.setFormGroupState(e=>({...e,isSubmitting:!0}));let n=()=>{this.setFormGroupState(e=>({...e,isSubmitting:!1}))};if(await this.validateAllFields(`submit`),!this.areRelatedFieldsValid()){n(),this.options.onGroupSubmitInvalid?.({value:this.state.value,groupApi:this,meta:t});return}if(await this.validate(`submit`,{skipRelatedFieldValidation:!0}),!this.areRelatedFieldsValid()||!this.state.meta.isValid){n(),this.options.onGroupSubmitInvalid?.({value:this.state.value,groupApi:this,meta:t});return}_Z(()=>{Object.values(this.getRelatedFields()).forEach(e=>{e.options.listeners?.onGroupSubmit?.({value:e.state.value,fieldApi:e})})}),this.options.listeners?.onSubmit?.({groupApi:this,value:this.state.value});try{await this.options.onGroupSubmit?.({value:this.state.value,groupApi:this,meta:t}),_Z(()=>{this.setFormGroupState(e=>({...e,isSubmitted:!0,isSubmitSuccessful:!0})),n()})}catch(e){throw this.setFormGroupState(e=>({...e,isSubmitSuccessful:!1})),n(),e}},this.form=t.form,this.name=t.name,this.options=t,this.timeoutIds={validations:{},listeners:{},formListeners:{}},this.fieldInfo={instance:null,validationMetaMap:{onChange:void 0,onBlur:void 0,onSubmit:void 0,onMount:void 0,onServer:void 0,onDynamic:void 0}},this.store=wZ(e=>{this.form.formGroupMetaDerived.get(),this.form.baseStore.get();let n=this.form.getFormGroupMeta(this.name)??hQ(t.defaultMeta),r=this.form.getFieldValue(this.name);return!n.isTouched&&r===void 0&&this.options.defaultValue!==void 0&&!UZ(r,this.options.defaultValue)&&(r=this.options.defaultValue),e&&e.value===r&&e.meta===n?e:{value:r,meta:n}}),this.handleSubmit=this.handleSubmit.bind(this)}get state(){return this.store.state}runValidator(e){if(iQ(e.validate)){let t=rQ[e.type](e.value,e.validate);return e.type===`validate`?yQ(t):t.then(yQ)}return e.validate(e.value)}handleSubmit(e){return this._handleSubmit(e)}};function _Q(e){if(e)return e}function vQ(e){return!!e&&typeof e==`object`&&`fields`in e}function yQ(e){if(!e||typeof e!=`object`||!(`form`in e)&&!(`fields`in e))return e;let{form:t,fields:n,...r}=e;return{...r,group:t,fields:n}}function bQ(e){switch(e){case`submit`:return`onSubmit`;case`blur`:return`onBlur`;case`mount`:return`onMount`;case`server`:return`onServer`;case`dynamic`:return`onDynamic`;default:return`onChange`}}function xQ(e,t){if(!t)return;let n=Object.assign({},e,{state:QZ(e.state)});t(n),n.fieldInfo!==e.fieldInfo&&(e.fieldInfo=n.fieldInfo),n.options!==e.options&&(e.options=n.options);let r=Object.keys({values:null,validationMetaMap:null,fieldMetaBase:null,formGroupStateBase:null,isSubmitting:null,isSubmitted:null,isValidating:null,submissionAttempts:null,isSubmitSuccessful:null,_force_re_eval:null}).reduce((t,r)=>(e.state[r]!==n.state[r]&&(t[r]=n.state[r]),t),{});return _Z(()=>{Object.keys(r).length&&e.baseStore.setState(e=>({...e,...r})),n.state.errorMap!==e.state.errorMap&&e.setErrorMap(n.state.errorMap)}),n}function SQ(e,t){return e===t}function CQ(e,t=e=>e,n){let r=n?.compare??SQ,i=(0,J.useCallback)(t=>{let{unsubscribe:n}=e.subscribe(t);return n},[e]),a=(0,J.useCallback)(()=>e.get(),[e]);return(0,gV.useSyncExternalStoreWithSelector)(i,a,a,t,r)}var wQ=typeof window<`u`?J.useLayoutEffect:J.useEffect;function TQ(e){let[t,n]=(0,J.useState)(()=>({form:e.form,name:e.name})),[r,i]=(0,J.useState)(()=>new dQ({...e})),a=r;(t.form!==e.form||t.name!==e.name)&&(a=new dQ({...e}),i(a),n({form:e.form,name:e.name}));let o=CQ(a.store,e.mode===`array`?e=>e.meta._arrayVersion||0:e=>e.value),s=CQ(a.store,e=>e.meta.isTouched),c=CQ(a.store,e=>e.meta.isBlurred),l=CQ(a.store,e=>e.meta.isDirty),u=CQ(a.store,e=>e.meta.errorMap),d=CQ(a.store,e=>e.meta.errorSourceMap),f=CQ(a.store,e=>e.meta.isValidating),p=(0,J.useMemo)(()=>({...a,get state(){return{value:e.mode===`array`?a.state.value:o,get meta(){return{...a.state.meta,isTouched:s,isBlurred:c,isDirty:l,errorMap:u,errorSourceMap:d,isValidating:f}}}}}),[a,e.mode,o,s,c,l,u,d,f]);return wQ(a.mount,[a]),wQ(()=>{a.update(e)}),p}var EQ=(({children:e,...t})=>{let n=TQ(t),r=(0,J.useMemo)(()=>kZ(e,n),[e,n]);return(0,X.jsx)(X.Fragment,{children:r})});function DQ(){return(0,J.useState)(()=>XZ())[0]}var OQ=J,kQ=`18.3.1`.split(`.`)[0]===`17`?DQ:OQ.useId;function AQ(e){let[t,n]=(0,J.useState)(()=>({form:e.form,name:e.name})),[r,i]=(0,J.useState)(()=>new gQ({...e}));(t.form!==e.form||t.name!==e.name)&&(i(new gQ({...e})),n({form:e.form,name:e.name}));let a=CQ(r.store,e=>e.value),o=CQ(r.store,e=>e.meta.isTouched),s=CQ(r.store,e=>e.meta.isBlurred),c=CQ(r.store,e=>e.meta.isDirty),l=CQ(r.store,e=>e.meta.errorMap),u=CQ(r.store,e=>e.meta.errorSourceMap),d=CQ(r.store,e=>e.meta.isValidating),f=CQ(r.store,e=>e.meta.isSubmitting),p=CQ(r.store,e=>e.meta.isSubmitted),m=CQ(r.store,e=>e.meta.submissionAttempts),h=CQ(r.store,e=>e.meta.isSubmitSuccessful),g=CQ(r.store,e=>e.meta.canSubmit),_=CQ(r.store,e=>e.meta.isValid),v=CQ(r.store,e=>e.meta.isFieldsValid),y=CQ(r.store,e=>e.meta.isFieldsValidating),b=CQ(r.store,e=>e.meta.isGroupValid),x=(0,J.useMemo)(()=>({...r,handleSubmit:((...e)=>r._handleSubmit(...e)),get state(){return{...r.state,value:a,get meta(){return{...r.state.meta,isTouched:o,isBlurred:s,isDirty:c,errorMap:l,errorSourceMap:u,isValidating:d,isSubmitting:f,isSubmitted:p,submissionAttempts:m,isSubmitSuccessful:h,canSubmit:g,isValid:_,isFieldsValid:v,isFieldsValidating:y,isGroupValid:b}}}}}),[r,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b]);return wQ(r.mount,[r]),wQ(()=>{r.update(e)}),x}var jQ=(({children:e,...t})=>{let n=AQ(t),r=(0,J.useMemo)(()=>kZ(e,n),[e,n]);return(0,X.jsx)(X.Fragment,{children:r})});function MQ({form:e,selector:t=e=>e,children:n}){let r=CQ(e.store,t);return(0,X.jsx)(X.Fragment,{children:kZ(n,r)})}function NQ(e){let t=kQ(),[n,r]=(0,J.useState)(e?.formId),[i,a]=(0,J.useState)(()=>new cQ({...e,formId:e?.formId??t}));if(n!==e?.formId){let n=e?.formId??t;a(new cQ({...e,formId:n})),r(n)}let o=(0,J.useMemo)(()=>{let e={...i,handleSubmit:((...e)=>i._handleSubmit(...e)),get formId(){return i._formId},get state(){return i.store.state}};return e.Field=function(e){return(0,X.jsx)(EQ,{...e,form:i})},e.FormGroup=function(e){return(0,X.jsx)(jQ,{...e,form:i})},e.Subscribe=function(e){return(0,X.jsx)(MQ,{form:i,selector:e.selector,children:e.children})},e},[i]);wQ(i.mount,[]),wQ(()=>{i.update(e)});let s=(0,J.useRef)(!1);return wQ(()=>{s.current&&e?.transform&&xQ(i,e.transform)},[i,e?.transform]),wQ(()=>{s.current=!0}),o}var PQ=kn(W),FQ=kn(U({message:W}));function IQ(e){for(let t of e.errors){let e=et(Le(He(FQ(t),e=>e.message),()=>PQ(t)));if(e!==void 0&&e.length>0)return e}}var LQ={neutral:`progress-neutral`,primary:`progress-primary`,secondary:`progress-secondary`,accent:`progress-accent`,success:`progress-success`,info:`progress-info`,warning:`progress-warning`,error:`progress-error`},RQ=(0,J.forwardRef)(function({className:e,tone:t=`primary`,...n},r){return(0,X.jsx)(`progress`,{...n,"data-complete":n.value!==void 0&&Number(n.value)>=Number(n.max??1)?`true`:void 0,className:Q(`progress caps-gooey-motion caps-gooey-progress w-full`,LQ[t],e),ref:r})});(0,J.forwardRef)(function({label:e,value:t,max:n,tone:r=`info`,className:i,...a},o){return(0,X.jsxs)(`div`,{...a,ref:o,className:Q(`caps-game-meter`,i),children:[(0,X.jsxs)(`div`,{className:`caps-game-meter-readout`,children:[(0,X.jsx)(`span`,{children:e}),(0,X.jsxs)(`span`,{className:`caps-game-meter-value`,children:[t,` / `,n]})]}),(0,X.jsx)(RQ,{"aria-label":e,value:t,max:n,tone:r})]})});function zQ({className:e,items:t,onCancel:n,onRemove:r,onRetry:i,rowClassName:a}){return t.length?(0,X.jsx)(`div`,{"aria-live":`polite`,className:`caps-upload-queue flex w-full min-w-0 flex-col gap-sm ${e??``}`,"data-upload-rows":!0,children:t.map(e=>(0,X.jsx)(HQ,{item:e,onCancel:n,onRemove:r,onRetry:i,...a===void 0?{}:{rowClassName:a}},e.id))}):null}function BQ({action:e,id:t,onAction:n,retry:r=!1}){return e?(0,X.jsx)(LG,{"aria-label":e.accessibleLabel,title:e.label,variant:`ghost`,size:`xs`,className:`motion-reduce:transition-none`,icon:r?(0,X.jsx)(uW,{}):(0,X.jsx)(hW,{}),onClick:()=>void n(t),type:`button`}):null}function VQ({item:e}){return(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`span`,{className:`block min-w-0 truncate`,title:e.name,children:e.name}),(0,X.jsx)(`div`,{className:`caps-upload-details`,children:(0,X.jsxs)(`span`,{"aria-live":e.alert?`assertive`:void 0,className:`caps-upload-status min-w-0 break-words`,"data-upload-status":!0,role:e.alert?`alert`:void 0,children:[e.alert??e.statusLabel,` `,e.progressLabel]})})]})}function HQ({item:e,onCancel:t,onRemove:n,onRetry:r,rowClassName:i}){return(0,X.jsxs)(`div`,{className:`caps-upload-row grid w-full min-w-0 max-w-full grid-cols-[2rem_minmax(0,1fr)_auto] items-center gap-sm p-sm text-xs ${i??``}`,children:[e.preview.kind===`image`?(0,X.jsx)(`img`,{alt:``,className:`caps-upload-preview mask mask-squircle size-8 shrink-0 object-cover`,src:e.preview.url}):(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`caps-upload-preview mask mask-squircle flex size-8 shrink-0 items-center justify-center bg-base-300`,children:(0,X.jsx)(oW,{className:`size-4`})}),(0,X.jsx)(VQ,{item:e}),(0,X.jsx)(UQ,{actions:e.actions,id:e.id,onCancel:t,onRemove:n,onRetry:r}),(0,X.jsx)(RQ,{"aria-label":`${e.name} progress`,className:`caps-upload-progress`,tone:e.alert?`error`:e.progress===100?`success`:`accent`,max:100,value:e.progress??(e.alert?0:void 0)})]})}function UQ({actions:e,id:t,onCancel:n,onRemove:r,onRetry:i}){return(0,X.jsxs)(`div`,{className:`caps-upload-actions flex min-w-0 flex-wrap justify-end gap-xs`,children:[(0,X.jsx)(BQ,{action:e.retry,id:t,onAction:i,retry:!0}),(0,X.jsx)(BQ,{action:e.cancel,id:t,onAction:n}),(0,X.jsx)(BQ,{action:e.remove,id:t,onAction:r})]})}var WQ=J.createContext(void 0);function GQ(e){let t=J.useContext(WQ);if(t===void 0&&!e)throw Error(lE(47));return t}var KQ={...MV,disabled:e=>e.disabled,instantType:e=>e.instantType===`trigger-change`&&!MV.open(e)?void 0:e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,isPressOpenedByTrigger:(e,t)=>e.openChangeReason===`trigger-press`&&MV.isOpenedByTrigger(e,t),isTouchPressOpen:(e,t)=>t&&e.openMethod===`touch`&&e.openChangeReason===`trigger-press`,hasTriggerFocusGuards:(e,t)=>MV.isOpenedByTrigger(e,t)&&!e.focusManagerModal,modal:e=>e.modal,titleElementId:e=>e.titleElementId,descriptionElementId:e=>e.descriptionElementId,openOnHover:e=>e.openOnHover,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},qQ=class extends CV{constructor(e,t,n){let r=new rV;super(JQ(e,r,t,n),YQ(r),KQ)}setOpen=(e,t)=>{let n=t.reason===Sz,r=t.reason===`trigger-press`&&t.event.detail===0,i=!e&&(t.reason===`escape-key`||t.reason==null),a=ZB(t),o=this.select(`activeTriggerId`);if(!e&&t.reason===`close-press`&&t.trigger==null&&o!=null&&(t.trigger=this.context.triggerElements.getById(o)??this.select(`activeTriggerElement`)??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let s=()=>{let n=XB(this.state,e,t.trigger,a());n.openChangeReason=t.reason,this.update(n)};n?(this.context.stickIfOpen=!0,this.context.stickIfOpenTimeout.start(500,()=>{this.context.stickIfOpen=!1}),aI.flushSync(s)):s();let c;r?c=`click`:i?c=`dismiss`:t.reason===`focus-out`&&(c=`focus`),this.set(`instantType`,c)}};function JQ(e,t,n,r=!1){let i={...EV(t,n,r),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,openOnHover:!1,closeDelay:0,adaptiveOrigin:void 0,...e};return i.open&&e?.mounted===void 0&&(i.mounted=!0),i}function YQ(e){return{popupRef:J.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:J.createRef(),beforeTriggerFocusGuardRef:J.createRef(),beforeContentFocusGuardRef:J.createRef(),stickIfOpenTimeout:new oE,stickIfOpen:!0,triggerElements:e}}var XQ=fV(function({props:e}){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,modal:o=!1,handle:s,triggerId:c,defaultTriggerId:l=null}=e,u=QQ(s,{modal:o,open:r,openProp:n,activeTriggerId:l,triggerIdProp:c});u.useControlledProp(`openProp`,n),u.useControlledProp(`triggerIdProp`,c);let d=u.useState(`open`),f=u.useState(`mounted`),p=u.useState(`payload`);u.useContextCallback(`onOpenChange`,i),u.useContextCallback(`onOpenChangeComplete`,a),nV(u,d),$B(u);let{forceUnmount:m}=eV(d,u,()=>{u.context.stickIfOpen=!0,u.set(`openChangeReason`,null)});u.useSyncedValues({modal:o}),J.useEffect(()=>{d||u.context.stickIfOpenTimeout.clear()},[u,d]),J.useImperativeHandle(e.actionsRef,()=>({unmount:m,close:()=>u.setOpen(!1,yz(Dz))}),[m,u]);let h=d||f||s!=null;return(0,X.jsxs)(WQ.Provider,{value:u,children:[s&&(0,X.jsx)(qB,{handle:s,store:u}),h&&(0,X.jsx)($Q,{store:u,modal:o}),typeof t==`function`?t({payload:p}):t]})});function ZQ(e){return GQ(!0)?(0,X.jsx)(XQ,{props:e}):(0,X.jsx)(SB,{children:(0,X.jsx)(XQ,{props:e})})}function QQ(e,t){let n=KB((e,n)=>new qQ(t,e,n));return J.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function $Q({store:e,modal:t}){let n=IB(e.useState(`floatingRootContext`),{outsidePressEvent:{mouse:t===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}}),r=n.reference,i=n.floating;return tV(e,{activeTriggerProps:r,inactiveTriggerProps:r,popupProps:i}),null}function e$(e,t){function n(n,r,i){let a=n.currentTarget;aI.flushSync(()=>{e.setOpen(!1,yz(Tz,n.nativeEvent,a))}),Ak(a.isConnected?a:t.current,r,i)?.focus()}function r(t){n(t,-1,e.select(`positionerElement`))}function i(t){let r=e.select(`positionerElement`);r&&jk(t,r)?e.context.beforeContentFocusGuardRef.current?.focus():n(t,1,r)}return{handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}var t$=pV(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,handle:s,payload:c,openOnHover:l=!1,delay:u=300,closeDelay:d=0,id:f,...p}=e,m=GQ(!0),h=NV(s)??m;if(!h)throw Error(lE(74));let g=eD(f),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerPopupId`,g),x=J.useRef(null),{registerTrigger:S,isMountedByThisTrigger:C}=QB(g,x,h,{payload:c,disabled:a,openOnHover:l,closeDelay:d}),w=h.useState(`isPressOpenedByTrigger`,g),T=h.useState(`isTouchPressOpen`,l),E=h.useState(`hasTriggerFocusGuards`,g),D=VV(v,{enabled:!a&&l&&!T,mouseOnly:!0,move:!1,handleClose:YV(),restMs:u,delay:{close:d},triggerElementRef:x,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),O=NB(v,{stickIfOpen:QT(()=>h.context.stickIfOpen)}),k=kU(()=>h.select(`open`),e=>{h.set(`openMethod`,e)}),A=h.useState(`triggerProps`,C),{getButtonProps:j,buttonRef:M}=gz({disabled:a,native:o}),N={open(e){return w?gO.open(e):hO.open(e)}},{handlePreFocusGuardFocus:P,handleFocusTargetFocus:F}=e$(h,x),I=zE(`button`,e,{state:{disabled:a,open:y},ref:[M,t,S,x],props:[O.reference,D,A,k,{[oB]:``,id:g,"aria-haspopup":`dialog`,"aria-expanded":y,"aria-controls":b},p,j],stateAttributesMapping:N}),L=(0,X.jsx)(J.Fragment,{children:I},g);return E?(0,X.jsxs)(J.Fragment,{children:[(0,X.jsx)(Wz,{ref:h.context.beforeTriggerFocusGuardRef,onFocus:P}),L,(0,X.jsx)(Wz,{ref:h.context.triggerFocusTargetRef,onFocus:F})]}):L}),n$=J.createContext(void 0);function r$(){let e=J.useContext(n$);if(e===void 0)throw Error(lE(45));return e}var i$=J.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return GQ().useState(`mounted`)||n?(0,X.jsx)(n$.Provider,{value:n,children:(0,X.jsx)(pB,{ref:t,...r})}):null}),a$=J.createContext(void 0);function o$(){let e=J.useContext(a$);if(!e)throw Error(lE(46));return e}function s$(e){let{nodeId:t,externalTree:n,rootContext:r}=e,i=r.useState(`referenceElement`),a=r.useState(`floatingElement`),o=r.useState(`domReferenceElement`),s=r.useState(`open`),c=r.useState(`floatingId`),[l,u]=J.useState(null),d=J.useRef(null),f=yB(n),p=J.useMemo(()=>({reference:i,floating:a,domReference:o}),[i,a,o]),m=qH({...e,elements:{...p,...l&&{reference:l}}}),h=J.useCallback(e=>{let t=mD(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>e.getClientRects(),contextElement:e}:e;u(t),m.refs.setReference(t)},[m.refs]),g=J.useMemo(()=>({...m.refs,setPositionReference:h,domReference:d}),[m.refs,h]),_=J.useMemo(()=>({...m.elements,domReference:o}),[m.elements,o]),v=J.useMemo(()=>({...m,dataRef:r.context.dataRef,open:s,onOpenChange:r.setOpen,events:r.context.events,floatingId:c,refs:g,elements:_,nodeId:t,rootStore:r}),[m,g,_,t,r,s,c]);return Kk(()=>{o&&(d.current=o)},[o]),Kk(()=>{r.context.dataRef.current.floatingContext=v;let e=f?.nodesRef.current.find(e=>e.id===t);e&&(e.context=v)}),J.useMemo(()=>({...m,context:v,refs:g,elements:_,rootStore:r}),[m,g,_,v,r])}var c$=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=HO(e,t)||{};if(l==null)return{};let d=ok(u),f={x:n,y:r},p=JO(i),m=KO(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=s.floating[y]||a.floating[m],C=b/2-x/2,w=S/2-h[m]/2-1,T=Math.min(d[_],w),E=Math.min(d[v],w),D=T,O=S-h[m]-E,k=S/2-h[m]/2+C,A=VO(D,k,O),j=!c.arrow&&WO(i)!=null&&k!==A&&a.reference[m]/2-(k<D?T:E)-h[m]/2<0,M=j?k<D?k-D:k-O:0;return{[p]:f[p]+M,data:{[p]:A,centerOffset:k-A-M,...j&&{alignmentOffset:M}},reset:j}}}),l$=(e,t)=>{let{name:n,fn:r}=c$(e);return{name:n,fn:r,options:[e,t]}},u$={name:`hide`,async fn(e){let{width:t,height:n,x:r,y:i}=e.rects.reference,a=t===0&&n===0&&r===0&&i===0,o=await e.platform.detectOverflow(e,{elementContext:`reference`});return{data:{referenceHidden:o.top-n>=0||o.right-t>=0||o.bottom-n>=0||o.left-t>=0||a}}}},d$={sideX:`left`,sideY:`top`},f$=`--available-width`,p$=`--available-height`,m$=`--anchor-width`,h$=`--anchor-height`,g$=`--transform-origin`,_$=f$,v$=p$;function y$(e,t,n){let r=e===`inline-start`||e===`inline-end`;return{top:`top`,right:r?n?`inline-start`:`inline-end`:`right`,bottom:`bottom`,left:r?n?`inline-end`:`inline-start`:`left`}[t]}function b$(e,t,n){let{rects:r,placement:i}=e;return{side:y$(t,UO(i),n),align:WO(i)||`center`,anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function x$(e){return S$(e,s$)}function S$(e,t){let{anchor:n,positionMethod:r=`absolute`,side:i=`bottom`,sideOffset:a=0,align:o=`center`,alignOffset:s=0,collisionBoundary:c,collisionPadding:l=5,sticky:u=!1,arrowPadding:d=5,disableAnchorTracking:f=!1,inline:p,keepMounted:m=!1,floatingRootContext:h,mounted:g,collisionAvoidance:_,shift:v,nodeId:y,adaptiveOrigin:b,lazyFlip:x=!1,externalTree:S}=e,C=_.side||`flip`,w=_.align||`flip`,T=_.fallbackAxisSide||`end`,E=v?.crossAxis??!1,D=v?.rootBoundary,O=typeof n==`function`?n:void 0,k=QT(O),A=O?k:n,j=Iz(n),M=Iz(g),N=Zk()===`rtl`,[P,F]=J.useState(null);!g&&P!==null&&F(null);let I=x===`placement`,L=P?UO(P):null,ee=P&&I?WO(P)||`center`:null,te=L||{top:`top`,right:`right`,bottom:`bottom`,left:`left`,"inline-end":N?`left`:`right`,"inline-start":N?`right`:`left`}[i],ne=ee||o,re=ne===`center`?te:`${te}-${ne}`,R=l;typeof R==`number`?R={top:R,right:R,bottom:R,left:R}:R&&={top:R.top||0,right:R.right||0,bottom:R.bottom||0,left:R.left||0};let ie=+(i===`bottom`),ae=+(i===`top`),z=+(i===`right`),oe=+(i===`left`),se={boundary:c===`clipping-ancestors`?`clippingAncestors`:c,padding:R},ce=J.useRef(null),le=Iz(a),ue=Iz(s),de=typeof a==`function`?0:a,fe=typeof s==`function`?0:s,pe=[];p&&pe.push(p),pe.push(JH(e=>{let t=b$(e,i,N),n=typeof le.current==`function`?le.current(t):le.current,r=typeof ue.current==`function`?ue.current(t):ue.current;return{mainAxis:n,crossAxis:r,alignmentAxis:r}},[de,fe,N,i]));let me=w===`none`&&C!==`shift`,he=!me&&(u||E||C===`shift`),ge=C===`none`?null:ZH({...se,padding:{top:R.top+1+ie,right:R.right+1+oe,bottom:R.bottom+1+ae,left:R.left+1+z},mainAxis:!E&&C===`flip`,crossAxis:w===`flip`&&`alignment`,fallbackAxisSideDirection:T}),_e=me?null:YH({...se,rootBoundary:D,mainAxis:w!==`none`,crossAxis:he,limiter:u||E?void 0:XH(e=>{if(!ce.current)return{};let{width:t,height:n}=ce.current.getBoundingClientRect(),r=qO(UO(e.placement)),i=r===`y`?t:n,a=r===`y`?R.left+R.right:R.top+R.bottom;return{offset:i/2+a/2}})},[se,u,E,D,R,w]);C===`shift`||w===`shift`||ne===`center`?pe.push(_e,ge):pe.push(ge,_e),pe.push(QH({...se,apply({elements:{floating:e},availableWidth:t,availableHeight:n,rects:r}){if(!M.current)return;let i=e.style;i.setProperty(_$,`${t}px`),i.setProperty(v$,`${n}px`);let a=dD(e).devicePixelRatio||1,{x:o,y:s,width:c,height:l}=r.reference,u=(Math.round((o+c)*a)-Math.round(o*a))/a,d=(Math.round((s+l)*a)-Math.round(s*a))/a;i.setProperty(m$,`${u}px`),i.setProperty(h$,`${d}px`)}}),l$(e=>({element:ce.current||uk(e.elements.floating).createElement(`div`),padding:ce.current?d:0}),[d]),{name:`transformOrigin`,fn(e){let{elements:{floating:t},middlewareData:n,placement:r,platform:o,rects:s,y:c}=e,l=UO(r),u=WO(r),d=qO(l)===`y`,f=ce.current,p=typeof a==`function`?a(b$(e,i,N)):a,m;m=!f&&u&&Math.abs(d?n.shift?.x||0:n.shift?.y||0)<=1?u===`start`===(d&&o.isRTL?.(t)===!0)?`100%`:`0%`:`${(d?n.arrow?.x||0:n.arrow?.y||0)+(d?f?.clientWidth||0:f?.clientHeight||0)/2}px`;let h=l===`top`||l===`left`?`calc(100% + ${p}px)`:`${-p}px`;return he&&d&&Math.abs(n.shift?.y||0)>p&&(h=`${s.reference.y+s.reference.height/2-c}px`),t.style.setProperty(g$,d?`${m} ${h}`:`${h} ${m}`),{}}},u$,b),Kk(()=>{!g&&h&&h.update({referenceElement:null,floatingElement:null,domReferenceElement:null,positionReference:null})},[g,h]);let ve=J.useMemo(()=>({ancestorScroll:!f,elementResize:!f&&typeof ResizeObserver<`u`,layoutShift:!f&&typeof IntersectionObserver<`u`}),[f]),{refs:ye,elements:be,x:xe,y:Se,middlewareData:Ce,update:we,placement:Te,context:Ee,isPositioned:De,floatingStyles:Oe}=t({rootContext:h,open:m?g:void 0,placement:re,middleware:pe,strategy:r,whileElementsMounted:m?void 0:(...e)=>FH(...e,ve),nodeId:y,externalTree:S}),{sideX:ke,sideY:Ae}=Ce.adaptiveOrigin||d$,je=De?r:`fixed`,Me=J.useMemo(()=>{let e;return e=De?b?{position:je,[ke]:xe,[Ae]:Se}:{...Oe,position:je}:{position:je,top:0,left:0},e[_$]=`100vw`,e[v$]=`100vh`,De||(e.opacity=0),e},[b,je,ke,xe,Ae,Se,Oe,De]),Ne=J.useRef(null);Kk(()=>{if(!g)return;let e=j.current,t=typeof e==`function`?e():e,n=(C$(t)?t.current:t)||null;n!==Ne.current&&(ye.setPositionReference(n),Ne.current=n)},[g,ye,A,j]),J.useEffect(()=>{if(!g)return;let e=j.current;typeof e!=`function`&&C$(e)&&e.current!==Ne.current&&(ye.setPositionReference(e.current),Ne.current=e.current)},[g,ye,A,j]),J.useEffect(()=>{if(m&&g&&be.reference&&be.floating)return FH(be.reference,be.floating,we,ve)},[m,g,be,we,ve]);let Pe=UO(Te),Fe=y$(i,Pe,N),Ie=WO(Te)||`center`,Le=!!Ce.hide?.referenceHidden;Kk(()=>{x&&g&&De&&(Pe!==te||I&&Ie!==ne)&&F(Te)},[x,I,g,De,Te,Pe,Ie,te,ne]);let Re=J.useMemo(()=>({position:`absolute`,top:Ce.arrow?.y,left:Ce.arrow?.x}),[Ce.arrow]),B=Ce.arrow?.centerOffset!==0;return J.useMemo(()=>({positionerStyles:Me,arrowStyles:Re,arrowRef:ce,arrowUncentered:B,side:Fe,align:Ie,physicalSide:Pe,anchorHidden:Le,refs:ye,context:Ee,isPositioned:De,update:we}),[Me,Re,ce,B,Fe,Ie,Pe,Le,ye,Ee,De,we])}function C$(e){return e!=null&&`current`in e}function w$(e){let{store:t,domReference:n,positionerElement:r,open:i}=e,a=J.useRef(null),o=J.useRef(null),s=VB(r);Kk(()=>{i||(o.current?.abort(),o.current=null,t.state.instantType===`trigger-change`&&t.set(`instantType`,void 0))},[i,t]),Kk(()=>{let e=n,r=a.current;if(e&&(a.current=e),!r||!e||e===r||!t.select(`open`))return;t.set(`instantType`,void 0);let i=new AbortController;return o.current=i,s(()=>{t.select(`open`)&&t.set(`instantType`,`trigger-change`)},i.signal),()=>{i.abort()}},[n,s,t])}function T$(e){return e===`starting`?aB:rE}function E$(e,t,{styles:n,transitionStatus:r,props:i,refs:a,hidden:o,inert:s=!1}){let c={...n};return s&&(c.pointerEvents=`none`),zE(`div`,e,{state:t,ref:a,props:[{role:`presentation`,hidden:o,style:c},T$(r),i],stateAttributesMapping:_O})}var D$=20;function O$(e,t,n,r){let[i,a]=J.useState(!1);Kk(()=>{if(!e||!t||n==null){a(!1);return}let r=uk(n).documentElement.clientWidth,i=n.offsetWidth;a(r>0&&i>0&&i>=r-D$)},[e,t,n]),yU(e&&(!t||i),r)}var k$=J.forwardRef(function(e,t){let{render:n,className:r,style:i,anchor:a,positionMethod:o,side:s,align:c,sideOffset:l,alignOffset:u,collisionBoundary:d=`clipping-ancestors`,collisionPadding:f,arrowPadding:p,sticky:m,disableAnchorTracking:h=!1,collisionAvoidance:g=sB,..._}=e,v=GQ(),y=r$(),b=bB(),x=v.useState(`floatingRootContext`),S=v.useState(`mounted`),C=v.useState(`open`),w=v.useState(`openChangeReason`),T=v.useState(`activeTriggerElement`),E=v.useState(`modal`),D=v.useState(`openMethod`),O=v.useState(`positionerElement`),k=v.useState(`instantType`),A=v.useState(`transitionStatus`),j=x$({anchor:a,floatingRootContext:x,positionMethod:o,mounted:S,side:s,sideOffset:l,align:c,alignOffset:u,arrowPadding:p,collisionBoundary:d,collisionPadding:f,sticky:m,disableAnchorTracking:h,keepMounted:y,nodeId:b,collisionAvoidance:g,adaptiveOrigin:v.useState(`adaptiveOrigin`)});w$({store:v,domReference:x.useState(`domReferenceElement`),positionerElement:O,open:C});let M=E===!0&&w!==`trigger-hover`;O$(C&&M,D===`touch`,O,T);let N=v.useStateSetter(`positionerElement`),P=E$(e,{open:C,side:j.side,align:j.align,anchorHidden:j.anchorHidden,instant:k},{styles:j.positionerStyles,transitionStatus:A,props:_,refs:[t,N],hidden:!S,inert:!C});return(0,X.jsxs)(a$.Provider,{value:j,children:[S&&M&&(0,X.jsx)(sU,{inert:oU(!C),cutout:T}),(0,X.jsx)(xB,{id:b,children:P})]})}),A$=J.createContext(void 0);function j$(e){let t=J.useContext(A$);if(t===void 0&&!e)throw Error(lE(69));return t}var M$=J.createContext(void 0);function N$(){let[e,t]=J.useState(0),n=QT(()=>(t(e=>e+1),()=>{t(e=>Math.max(0,e-1))}));return{context:J.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}var P$=J.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=GQ(),l=o$(),u=j$(!0)!=null,{context:d,hasClosePart:f}=N$(),p=c.useState(`open`),m=c.useState(`openMethod`),h=c.useState(`instantType`),g=c.useState(`transitionStatus`),_=c.useState(`popupProps`),v=c.useState(`titleElementId`),y=c.useState(`descriptionElementId`),b=c.useState(`modal`),x=c.useState(`mounted`),S=c.useState(`openChangeReason`),C=c.useState(`activeTriggerElement`),w=c.useState(`floatingRootContext`),T=w.useState(`floatingId`),E=c.useState(`disabled`),D=c.useState(`openOnHover`),O=c.useState(`closeDelay`);HB({open:p,ref:c.context.popupRef,onComplete(){p&&c.context.onOpenChangeComplete?.(!0)}}),zV(w,{enabled:D&&!E,closeDelay:O});let k=a===void 0?GB(c.context.popupRef):a,A=b!==!1&&f;c.useSyncedValue(`focusManagerModal`,A);let j=c.useStateSetter(`popupElement`),M=zE(`div`,e,{state:{open:p,side:l.side,align:l.align,instant:h,transitionStatus:g},ref:[t,c.context.popupRef,j],props:[_,{id:T,role:`dialog`,...WB,"aria-labelledby":v,"aria-describedby":y,onKeyDown(e){u&&tU.has(e.key)&&e.stopPropagation()}},T$(g),s],stateAttributesMapping:vO});return(0,X.jsx)(MB,{context:w,openInteractionType:m,modal:A,disabled:!x||S===`trigger-hover`,initialFocus:k,returnFocus:o,restoreFocus:`popup`,getInsideElements:()=>[c.context.beforeTriggerFocusGuardRef.current],previousFocusableElement:hD(C)?C:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:(0,X.jsx)(M$.Provider,{value:d,children:M})})}),F$=(0,J.forwardRef)(function({children:e,className:t,type:n=`button`,...r},i){return(0,X.jsxs)(`button`,{...r,ref:i,type:n,className:Q(`select caps-select caps-combobox-trigger w-full`,t),children:[(0,X.jsx)(`span`,{children:e}),(0,X.jsx)(tW,{className:`caps-select-chevron`,"aria-hidden":`true`})]})});function I$({defaultOpen:e,defaultValue:t,getKey:n,getSearchText:r,groupBy:i,id:a,isDisabled:o,items:s,onOpenChange:c,onCommit:l,multiple:u,controlledOpen:d,controlledKeys:f,trigger:p}){let m=`${a}-listbox`,[h,g]=(0,J.useState)(``),[_,v]=(0,J.useState)(!1),[y,b]=(0,J.useState)(t),[x,S]=(0,J.useState)(e),C=f??(y===null?[]:[y]),w=p?d??x:!0,T=(0,J.useMemo)(()=>{let e=h.trim().toLowerCase();return e?s.filter(t=>r(t).toLowerCase().includes(e)):s},[r,s,h]),E=oK({getKey:n,isDisabled:o,items:T});(0,J.useEffect)(()=>{if(E.activeKey!==null)return;let e=E.enabledItems.find(e=>C.includes(n(e)))??E.enabledItems[0];e&&E.setActiveKey(n(e))},[E.activeKey,E.enabledItems,E.setActiveKey,n,C]);let D=e=>{v(!1),e||g(``),d===void 0&&S(e),c?.(e)},O=e=>`${m}-option-${encodeURIComponent(e)}`,k=e=>{let t=n(e);f===void 0&&b(t),l(e),p&&!u&&D(!1)},A=e=>{v(!0),g(e.target.value),E.setActiveKey(null)},j=e=>{if(pG(e))return;let t;switch(e.key){case`ArrowDown`:t=[1,void 0];break;case`ArrowUp`:t=[-1,void 0];break;case`End`:t=[1,`end`];break;case`Home`:t=[-1,`start`]}t?(v(!0),e.preventDefault(),E.move(t[0],t[1])):e.key===`Enter`&&E.activeItem&&(e.preventDefault(),k(E.activeItem))},M=(0,J.useMemo)(()=>{if(!i)return[{label:``,items:T}];let e=new Map;for(let t of T){let n=i(t),r=e.get(n);r?r.push(t):e.set(n,[t])}return[...e].map(([e,t])=>({label:e,items:t}))},[T,i]);return{keyboardNavigation:_,onPointerMove:()=>{v(!1)},activeKey:E.activeKey,activeItem:E.activeItem,groups:M,inputValue:h,listboxId:m,onInputChange:A,onInputKeyDown:j,optionId:O,open:w,commit:k,selectedKeys:C,setOpen:D}}function L$(e){let{"aria-describedby":t,"aria-invalid":n,"aria-label":r,"aria-labelledby":i,"aria-required":a,activeTone:o=`neutral`,container:s,contentClassName:c,defaultOpen:l=!1,defaultValue:u=null,emptyMessage:d=`No matches`,getKey:f,getLabel:p,getSearchText:m=p,groupBy:h,id:g,inputProps:_,inputRef:v,isDisabled:y=()=>!1,items:b,onOpenChange:x,onValueChange:S,multiple:C,open:w,placeholder:T=`Search…`,renderItem:E,rootRef:D,trigger:O,triggerRef:k,value:A,...j}=e,M=e=>{let t=f(e);if(C){let e=A.includes(t)?A.filter(e=>e!==t):[...A,t];S?.(e,b.filter(t=>e.includes(f(t))))}else S?.(t,e)},N;C?N=A:A!==void 0&&(N=A===null?[]:[A]);let P=(0,J.useId)(),F=O?.props??_,I=g??F?.id??P,L={id:I,"aria-describedby":[t,F?.[`aria-describedby`]].filter(Boolean).join(` `)||void 0,"aria-invalid":n??F?.[`aria-invalid`],"aria-label":F?.[`aria-label`]??r,"aria-labelledby":F?.[`aria-labelledby`]??i,"aria-required":a??F?.[`aria-required`]},{keyboardNavigation:ee,onPointerMove:te,activeItem:ne,activeKey:re,commit:R,groups:ie,inputValue:ae,listboxId:z,onInputChange:oe,onInputKeyDown:se,open:ce,optionId:le,selectedKeys:ue,setOpen:de}=I$({defaultOpen:l,defaultValue:u,getKey:f,getSearchText:m,groupBy:h,id:I,isDisabled:y,items:b,onOpenChange:x,onCommit:M,multiple:C??!1,controlledOpen:w,controlledKeys:N,trigger:O});PU(()=>{O&&de(!1)});let fe=NU(`popover`),pe=s===void 0?fe:s,me=iK(`.caps-combobox-option[data-active="true"]:not(:disabled), [data-navigation="pointer"] .caps-combobox-option:hover:not(:disabled)`),he=(0,X.jsx)(eK,{..._,...O?{}:L,"aria-activedescendant":ne?le(f(ne)):void 0,"aria-autocomplete":`list`,"aria-controls":z,"aria-expanded":!0,className:Q(`input-sm`,_?.className),id:O?_?.id??`${I}-input`:I,onChange:e=>{_?.onChange?.(e),oe(e)},onKeyDown:e=>{_?.onKeyDown?.(e),e.defaultPrevented||se(e)},placeholder:_?.placeholder??T,ref:v,role:`combobox`,value:ae}),ge=(0,X.jsx)(`div`,{id:z,ref:me,className:`caps-combobox-list`,"data-navigation":ee?`keyboard`:`pointer`,onPointerMove:te,role:`listbox`,"aria-multiselectable":C??void 0,children:ie.every(e=>e.items.length===0)?(0,X.jsx)(`div`,{className:`px-md py-md text-sm text-base-content`,children:d}):ie.map(e=>(0,X.jsxs)(`div`,{"aria-label":e.label||void 0,role:e.label?`group`:void 0,children:[e.label?(0,X.jsx)(`div`,{className:`px-md pb-xs pt-sm text-xs text-base-content uppercase tracking-wider`,children:e.label}):null,e.items.map(e=>{let t=f(e),n=y(e),r=re===t,i={active:r,disabled:n,selected:ue.includes(t)};return(0,X.jsxs)(`button`,{"aria-disabled":n||void 0,"aria-selected":i.selected,className:`caps-combobox-option`,"data-active":r&&ee,disabled:n,id:le(t),onClick:()=>{R(e)},onMouseDown:e=>{e.preventDefault()},role:`option`,tabIndex:-1,type:`button`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`caps-combobox-check`,children:i.selected?(0,X.jsx)(eW,{}):null}),E?.(e,r,i)??p(e)]},t)})]},e.label))});return O?(0,X.jsx)(`div`,{...j,className:Q(j.className),ref:D,children:(0,X.jsxs)(ZQ,{modal:!0,onOpenChange:de,open:ce,children:[(0,X.jsx)(t$,{...L,"aria-haspopup":`dialog`,className:`btn`,ref:k,render:O}),pe===null?null:(0,X.jsx)(i$,{container:pe,children:(0,X.jsx)(k$,{align:`start`,side:`bottom`,sideOffset:4,children:(0,X.jsxs)(P$,{"data-active-tone":o,className:Q(`min-w-40 rounded-box border border-base-300 bg-base-100 p-xs shadow-lg outline-none caps-combobox-panel caps-combobox-popup`,c),children:[(0,X.jsx)(`div`,{className:`caps-combobox-search`,children:he}),ge]})})})]})}):(0,X.jsx)(`div`,{...j,className:Q(j.className),ref:D,children:(0,X.jsxs)(`div`,{className:Q(`caps-combobox-panel`,c),"data-active-tone":o,children:[(0,X.jsx)(`div`,{className:`caps-combobox-search`,children:he}),ge]})})}function R$({icon:e,caption:t}){return(0,X.jsxs)(`span`,{className:`caps-icon-choice-mark`,"aria-hidden":`true`,children:[(0,X.jsx)(`span`,{className:`caps-icon-choice-art`,children:e}),t?(0,X.jsx)(`span`,{className:`caps-icon-choice-caption`,children:t}):null,(0,X.jsx)(`span`,{className:`caps-icon-choice-lamp`})]})}var z$=(0,J.forwardRef)(function({label:e,icon:t,caption:n,appearance:r,className:i,...a},o){return(0,X.jsx)(`label`,{className:`caps-icon-choice`,"data-appearance":r===`compact`?r:void 0,children:(0,X.jsx)($G,{...a,appearance:r??`default`,"aria-label":e,className:Q(`caps-icon-choice-input`,i),indicator:(0,X.jsx)(R$,{icon:t,caption:n}),ref:o})})}),B$=(0,J.forwardRef)(function({label:e,icon:t,hint:n,className:r,...i},a){let o=(0,J.useId)(),s=[i[`aria-describedby`],n?o:null].filter(Boolean).join(` `)||void 0;return(0,X.jsx)(`label`,{className:`caps-check-key`,children:(0,X.jsx)($G,{...i,"aria-label":e,"aria-describedby":s,className:Q(`caps-check-key-input`,r),indicator:(0,X.jsxs)(`span`,{className:`caps-check-key-face`,"aria-hidden":`true`,children:[t?(0,X.jsx)(`span`,{className:`caps-check-key-icon`,children:t}):null,(0,X.jsxs)(`span`,{className:`caps-check-key-copy`,children:[(0,X.jsx)(`span`,{className:`caps-check-key-label`,children:e}),n?(0,X.jsx)(`span`,{className:`caps-check-key-hint`,id:o,children:n}):null]}),(0,X.jsx)(`span`,{className:`caps-check-key-lamp`})]}),ref:a})})});function V$({className:e,...t}){return(0,X.jsx)(`div`,{...t,className:Q(`caps-check-keys`,e)})}function H$({checked:e}){let t=`caps-radio-${(0,J.useId)().replaceAll(`:`,``)}`,n=(0,J.useRef)(null),r=(0,J.useRef)(e).current,i=(0,J.useRef)(e),a=(0,J.useRef)(null),o=mS(a),{reduced:s}=o;return(0,J.useLayoutEffect)(()=>{if(!n.current)return;let t=s||i.current===e;i.current=e;let r=e?4:0,a=xA(o,{ease:`outCubic`,duration:75}),c=e?bA(o,{bounce:.65,duration:300}):xA(o,{ease:`inCubic`,duration:100}),l=yT(n.current,t?{rx:r,ry:r,cy:6,duration:0}:{rx:[{to:e?3.5:4.15,...a},{to:r,...c}],ry:[{to:e?4.5:3.85,...a},{to:r,...c}],cy:[{to:e?5.85:6.1,...a},{to:6,...c}]});return()=>{l.cancel()}},[e,s,o]),(0,X.jsxs)(`svg`,{ref:a,className:`caps-radio-visual`,width:`24`,height:`24`,viewBox:`0 0 12 12`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsxs)(`defs`,{children:[(0,X.jsx)(wT,{id:`${t}-surface`,transform:`matrix(1 0 0 1 6 6)`}),(0,X.jsx)(TT,{id:`${t}-shadow`}),(0,X.jsx)(ET,{id:`${t}-inset`}),(0,X.jsx)(`clipPath`,{id:`${t}-well`,children:(0,X.jsx)(`circle`,{cx:`6`,cy:`6`,r:`5`})})]}),(0,X.jsx)(`circle`,{className:`caps-radio-track`,cx:`6`,cy:`6`,r:`5.5`,filter:`url(#${t}-inset)`}),(0,X.jsx)(`g`,{clipPath:`url(#${t}-well)`,children:(0,X.jsx)(`ellipse`,{ref:n,cx:`6`,cy:`6`,rx:r?4:0,ry:r?4:0,fill:`url(#${t}-surface)`,filter:`url(#${t}-shadow)`})})]})}var U$=(0,J.createContext)(null),W$=(0,J.forwardRef)(function({children:e,className:t,defaultValue:n,disabled:r=!1,name:i,onValueChange:a,orientation:o=`vertical`,value:s,...c},l){let u=(0,J.useId)(),d=(0,J.useRef)(null);(0,J.useImperativeHandle)(l,()=>{if(!d.current)throw Error(`RadioGroup is not mounted`);return d.current},[]);let f=i??`radio-group-${u}`,[p,m]=(0,J.useState)(n),h=s??p;return(0,J.useEffect)(()=>{let e=d.current?.form;if(!e||s!==void 0)return;let t=e=>{queueMicrotask(()=>{e.defaultPrevented||m(n)})};return e.addEventListener(`reset`,t),()=>{e.removeEventListener(`reset`,t)}},[s,n,c.form]),(0,X.jsx)(U$.Provider,{value:{disabled:r,name:f,onValueChange:e=>{s===void 0&&m(e),a?.(e)},value:h},children:(0,X.jsx)(`fieldset`,{...c,className:Q(`flex gap-md`,o===`horizontal`?`flex-row flex-wrap`:`flex-col`,t),disabled:r,role:c.role??`radiogroup`,ref:d,children:e})})}),G$=(0,J.forwardRef)(function({className:e,indicator:t,onChange:n,onClick:r,value:i,...a},o){let s=(0,J.useContext)(U$);if(!s)throw Error(`RadioGroupItem must be used inside <RadioGroup>`);let c=s.value===i,l=e=>{n?.(e),e.target.checked&&s.onValueChange?.(i)};return(0,X.jsxs)(`span`,{className:`caps-radio`,"data-checked":c,"data-custom-indicator":t!==void 0||void 0,children:[(0,X.jsx)(`input`,{...a,"aria-checked":c,checked:c,className:Q(`caps-radio-input`,e),disabled:s.disabled||a.disabled,name:s.name,onChange:l,onClick:r,ref:o,type:`radio`,value:i}),t===void 0?(0,X.jsx)(H$,{checked:c}):t]})}),K$=(0,J.forwardRef)(function({description:e,id:t,meta:n,title:r,...i},a){let o=(0,J.useContext)(U$),s=(0,J.useId)(),c=t??s,l=o?.value===i.value,u=o?.disabled===!0||i.disabled===!0;return(0,X.jsxs)(`label`,{className:`caps-choice-card`,"data-checked":l,"data-disabled":u||void 0,htmlFor:c,children:[(0,X.jsx)(G$,{...i,"aria-describedby":e?`${c}-description`:void 0,"aria-labelledby":`${c}-title`,id:c,ref:a}),(0,X.jsxs)(`span`,{className:`caps-choice-card-copy`,children:[(0,X.jsx)(`span`,{className:`caps-choice-card-title`,id:`${c}-title`,children:r}),e?(0,X.jsx)(`span`,{className:`caps-choice-card-description`,id:`${c}-description`,children:e}):null]}),n?(0,X.jsx)(`span`,{className:`caps-choice-card-meta`,children:n}):null]})}),q$=(0,J.forwardRef)(function({label:e,icon:t,caption:n,art:r=`dim`,className:i,...a},o){return(0,X.jsx)(`label`,{className:`caps-icon-choice`,"data-art":r===`color`?r:void 0,children:(0,X.jsx)(G$,{...a,"aria-label":e,className:Q(`caps-icon-choice-input`,i),indicator:(0,X.jsx)(R$,{icon:t,caption:n}),ref:o})})}),J$=(0,J.forwardRef)(function({label:e,color:t,className:n,...r},i){return(0,X.jsx)(`label`,{className:`caps-icon-choice`,"data-art":`color`,"data-swatch":``,title:e,children:(0,X.jsx)(G$,{...r,"aria-label":e,className:Q(`caps-icon-choice-input`,n),indicator:(0,X.jsx)(R$,{icon:(0,X.jsx)(`span`,{className:`caps-swatch-dot`,style:{backgroundColor:t}})}),ref:i})})}),Y$=(0,J.forwardRef)(function({className:e,invalid:t,...n},r){return(0,X.jsxs)(`span`,{className:`caps-select-shell`,children:[(0,X.jsx)(`select`,{...n,"aria-invalid":t?!0:n[`aria-invalid`]===!1?void 0:n[`aria-invalid`],className:Q(`select select-bordered caps-select w-full`,t&&`select-error`,e),ref:r}),!n.multiple&&(!n.size||n.size<=1)?(0,X.jsx)(tW,{className:`caps-select-chevron`,"aria-hidden":`true`}):null]})});function X$({checked:e}){let t=`caps-switch-${(0,J.useId)().replaceAll(`:`,``)}`,n=(0,J.useRef)(null),r=(0,J.useRef)(null),i=(0,J.useRef)(e).current,a=(0,J.useRef)(e),o=wS();return(0,J.useLayoutEffect)(()=>{if(!n.current||!r.current)return;let t=o||a.current===e;a.current=e;let i=e?16:8,s=pS(n.current),c=bA(s,{bounce:.25,duration:440}),l=xA(s,{ease:`inOutSine`,duration:100}),u=yT(n.current,t?{x:2,y:2,width:i,height:8,duration:0}:{x:[{to:e?2.5:1.5,...l},{to:2,...c}],y:[{to:1.5,...l},{to:2,...c}],height:[{to:9,...l},{to:8,...c}],width:[{to:e?7:16.5,...l},{to:i,...c}]}),d=yT(r.current,{gradientTransform:e?`matrix(2 0 0 1 10 6)`:`matrix(1 0 0 1 6 6)`,...t?{duration:0}:{delay:l.duration,...c}});return()=>{u.cancel(),d.cancel()}},[e,o]),(0,X.jsxs)(`svg`,{className:`caps-switch-visual`,width:`40`,height:`24`,viewBox:`0 0 20 12`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsxs)(`defs`,{children:[(0,X.jsx)(wT,{ref:r,id:`${t}-surface`,transform:i?`matrix(2 0 0 1 10 6)`:`matrix(1 0 0 1 6 6)`}),(0,X.jsx)(TT,{id:`${t}-shadow`}),(0,X.jsx)(ET,{id:`${t}-inset`}),(0,X.jsx)(`clipPath`,{id:`${t}-track`,children:(0,X.jsx)(`rect`,{x:`1`,y:`1`,width:`18`,height:`10`,rx:`5`})})]}),(0,X.jsx)(`rect`,{className:`caps-switch-track`,filter:`url(#${t}-inset)`,x:`0.5`,y:`0.5`,width:`19`,height:`11`,rx:`5.5`}),(0,X.jsx)(`g`,{clipPath:`url(#${t}-track)`,children:(0,X.jsx)(`rect`,{ref:n,x:`2`,y:`2`,width:i?16:8,height:`8`,rx:`4`,fill:`url(#${t}-surface)`,filter:`url(#${t}-shadow)`})})]})}var Z$=(0,J.forwardRef)(function({className:e,checked:t,defaultChecked:n=!1,onChange:r,onCheckedChange:i,...a},o){let s=(0,J.useRef)(null),[c,l]=(0,J.useState)(n),u=t??c;return(0,J.useImperativeHandle)(o,()=>{if(!s.current)throw Error(`Switch input is not mounted`);return s.current},[]),(0,J.useEffect)(()=>{let e=s.current?.form;if(!e||t!==void 0)return;let r=e=>{queueMicrotask(()=>{!e.defaultPrevented&&s.current&&l(n)})};return e.addEventListener(`reset`,r),()=>{e.removeEventListener(`reset`,r)}},[t,n,a.form]),(0,X.jsxs)(`span`,{className:`caps-switch`,"data-checked":u,children:[(0,X.jsx)(`input`,{...a,checked:u,className:Q(`caps-switch-input`,e),onChange:e=>{t===void 0&&l(e.target.checked),r?.(e),i?.(e.target.checked)},ref:s,role:`switch`,type:`checkbox`}),(0,X.jsx)(X$,{checked:u})]})}),Q$=kn(W),$$=kn(on),e1=kn(qn(ut)),t1=kn(rn(W)),n1=rn(mt(File)),r1=kn(n1),i1=Zn([W,ut,on,Nn,$n,rn(W),n1]),a1=kn(i1),o1=e=>Ce(Q$(e.state.value),()=>``),s1=e=>Ce($$(e.state.value),()=>!1),c1=e=>Ce(e1(e.state.value),()=>null),l1=e=>Ce(t1(e.state.value),()=>[]),u1=e=>Ce(r1(e.state.value),()=>[]),d1=e=>Ce(a1(e.state.value),()=>null);function f1({field:e,spec:t,locked:n,...r}){let[i,a]=(0,J.useState)(!1);return(0,X.jsxs)(RK,{children:[(0,X.jsx)(eK,{...r,name:t.name,disabled:n,type:i?`text`:`password`,autoComplete:`off`,spellCheck:!1,className:`caps-field-secret`,placeholder:t.placeholder,readOnly:t.readOnly,value:o1(e),onBlur:e.handleBlur,onChange:t=>{e.handleChange(t.currentTarget.value)}}),(0,X.jsx)(BT,{type:`button`,variant:`outline`,size:`icon`,"aria-label":i?`Hide`:`Show`,"aria-pressed":i,disabled:n,onClick:()=>{a(e=>!e)},children:i?(0,X.jsx)(iW,{"aria-hidden":`true`}):(0,X.jsx)(aW,{"aria-hidden":`true`})})]})}var p1={text:`text`,email:`email`,url:`url`,tel:`tel`};function m1({spec:e,field:t,locked:n,...r}){let i=u1(t),a=n||e.readOnly===!0,o=(0,J.useRef)(null);return(0,X.jsxs)(`div`,{className:`flex flex-col gap-sm`,children:[(0,X.jsx)(TS,{asChild:!0,children:(0,X.jsx)(`input`,{...r,ref:o,type:`file`,tabIndex:-1,required:r.required===!0&&i.length===0,name:e.name,accept:e.accept,multiple:e.multiple,disabled:a,onBlur:t.handleBlur,onChange:e=>{t.handleChange(Array.from(e.currentTarget.files??[])),e.currentTarget.value=``}})}),(0,X.jsx)(BT,{type:`button`,variant:`outline`,"aria-label":`Choose files for ${e.label}`,"aria-describedby":r[`aria-describedby`],"aria-invalid":r[`aria-invalid`],disabled:a,onBlur:t.handleBlur,onClick:()=>{o.current?.click()},children:`Choose files`}),(0,X.jsx)(zQ,{items:i.map((e,t)=>({id:String(t),name:e.name,preview:{kind:`file`},progress:0,progressLabel:`${String(e.size)} bytes`,statusLabel:`Selected`,actions:a?{}:{remove:{label:`Remove`,accessibleLabel:`Remove ${e.name}`}}})),onRemove:e=>{t.handleChange(i.filter((t,n)=>String(n)!==e))},onCancel:()=>void 0,onRetry:()=>void 0})]})}function h1({spec:e,field:t,locked:n,...r}){let i=e=>{t.handleChange(e)},a={...r,name:e.name,disabled:n,onBlur:t.handleBlur};switch(e.kind){case`text`:case`email`:case`url`:case`tel`:return(0,X.jsx)(eK,{...a,type:p1[e.kind],inputMode:e.kind===`text`?void 0:e.kind,autoComplete:e.autoComplete,placeholder:e.placeholder,maxLength:e.maxLength,readOnly:e.readOnly,value:o1(t),onChange:e=>{i(e.currentTarget.value)}});case`textarea`:return(0,X.jsx)(GG,{...a,rows:e.rows??3,placeholder:e.placeholder,maxLength:e.maxLength,readOnly:e.readOnly,value:o1(t),onChange:e=>{i(e.currentTarget.value)}});case`secret`:return(0,X.jsx)(f1,{...r,field:t,spec:e,locked:n});case`money`:return(0,X.jsxs)(RK,{children:[(0,X.jsx)(zK,{className:`caps-field-currency`,children:e.currency??`USD`}),(0,X.jsx)(eK,{...a,inputMode:`decimal`,autoComplete:`off`,className:`caps-field-amount`,placeholder:e.placeholder??`0.00`,readOnly:e.readOnly,value:o1(t),onChange:e=>{i(e.currentTarget.value)}})]});case`date`:return(0,X.jsx)(eK,{...a,type:`date`,readOnly:e.readOnly,value:o1(t),onChange:e=>{i(e.currentTarget.value)}});case`number`:return(0,X.jsx)(eq,{...a,...e.min===void 0?{}:{min:e.min},...e.max===void 0?{}:{max:e.max},...e.step===void 0?{}:{step:e.step},...e.unit===void 0?{}:{unit:e.unit},...e.wrap===void 0?{}:{wrap:e.wrap},disabled:n||e.readOnly===!0,decrementLabel:`Decrease ${e.label}`,incrementLabel:`Increase ${e.label}`,value:c1(t),onValueChange:e=>{t.handleChange(e)}});case`select`:return(0,X.jsxs)(Y$,{...a,value:o1(t),onChange:e=>{i(e.currentTarget.value)},children:[e.placeholder===void 0?null:(0,X.jsx)(`option`,{value:``,disabled:!0,children:e.placeholder}),e.options.map(e=>(0,X.jsx)(`option`,{value:e.value,disabled:e.disabled,children:e.label},e.value))]});case`combobox`:return(0,X.jsx)(L$,{id:r.id??e.name,"aria-describedby":r[`aria-describedby`],"aria-invalid":r[`aria-invalid`],"aria-required":r[`aria-required`],items:e.options,getKey:e=>e.value,getLabel:e=>e.label,isDisabled:t=>t.disabled||n||e.readOnly===!0,value:o1(t),...e.placeholder===void 0?{}:{placeholder:e.placeholder},trigger:(0,X.jsx)(F$,{name:e.name,disabled:n||e.readOnly===!0,onBlur:t.handleBlur,children:e.options.find(e=>e.value===o1(t))?.label??e.placeholder??`Choose…`}),inputProps:{"aria-label":`Search ${e.label}`,disabled:n||e.readOnly===!0},onValueChange:e=>{i(e??``),t.handleBlur()}});case`file`:return(0,X.jsx)(m1,{...r,spec:e,field:t,locked:n});case`checkbox`:return(0,X.jsx)($G,{...a,disabled:n||e.readOnly===!0,checked:s1(t),onChange:e=>{t.handleChange(e.currentTarget.checked)}});case`switch`:return(0,X.jsx)(Z$,{...a,disabled:n||e.readOnly===!0,checked:s1(t),onCheckedChange:e=>{t.handleChange(e)}});case`radio`:case`icon-radio`:case`checkboxes`:case`icon-checkboxes`:return null}}var g1=new Set([`radio`,`icon-radio`,`checkboxes`,`icon-checkboxes`]);function _1({spec:e,field:t,locked:n,error:r,layout:i}){let a=n||e.readOnly===!0,o=e.label;if(e.kind===`checkboxes`||e.kind===`icon-checkboxes`){let n=l1(t),s=(e,r)=>{t.handleChange(r?[...n,e]:n.filter(t=>t!==e))};return(0,X.jsx)(qK,{legend:o,icon:e.icon,layout:i,...i===`columns`?{legendTitle:o}:{},description:e.help,disabled:a,error:r??null,children:e.kind===`icon-checkboxes`?(0,X.jsx)(`div`,{className:`caps-field-icon-choices`,children:e.options.map(r=>(0,X.jsx)(z$,{name:e.name,value:r.value,label:r.label,...r.caption===void 0?{}:{caption:r.caption},icon:r.icon,disabled:r.disabled,checked:n.includes(r.value),onBlur:t.handleBlur,onChange:e=>{s(r.value,e.currentTarget.checked)}},r.value))}):(0,X.jsx)(V$,{children:e.options.map(r=>(0,X.jsx)(B$,{name:e.name,value:r.value,label:r.label,icon:r.icon,hint:r.description,disabled:r.disabled,checked:n.includes(r.value),onBlur:t.handleBlur,onChange:e=>{s(r.value,e.currentTarget.checked)}},r.value))})})}let s=e.options.some(e=>e.description!==void 0||e.meta!==void 0);return(0,X.jsx)(qK,{legend:o,icon:e.icon,layout:i,...i===`columns`?{legendTitle:o}:{},description:e.help,disabled:a,error:r??null,children:(0,X.jsx)(W$,{name:e.name,"aria-label":o,value:o1(t),onValueChange:e=>{t.handleChange(e),t.handleBlur()},orientation:e.kind===`icon-radio`||s?`horizontal`:`vertical`,children:e.options.map(t=>e.kind===`icon-radio`?(0,X.jsx)(q$,{value:t.value,label:t.label,...t.caption===void 0?{}:{caption:t.caption},icon:t.icon,disabled:t.disabled},t.value):s?(0,X.jsx)(K$,{value:t.value,title:t.label,description:t.description,meta:t.meta,disabled:t.disabled},t.value):(0,X.jsx)(YK,{label:t.label,orientation:`inline`,children:(0,X.jsx)(G$,{value:t.value,disabled:t.disabled})},t.value))})})}function v1({spec:e,field:t,locked:n,error:r,render:i,...a}){return i({name:e.name,label:e.label,help:e.help,value:d1(t),onChange:e=>{t.handleChange(e)},onBlur:t.handleBlur,error:r,disabled:n,id:a.id??e.name,"aria-describedby":a[`aria-describedby`],"aria-invalid":r!==void 0})}function y1({form:e,spec:t,locked:n,layout:r}){let i=TQ({form:e,name:t.name}),a=CQ(e.store,e=>e.submissionAttempts>0),o=i.state.meta.isBlurred||a?IQ(i.state.meta):void 0;if(t.render===void 0&&g1.has(t.kind))return(0,X.jsx)(_1,{spec:t,field:i,locked:n,error:o,layout:r});let s=r===`columns`?t.kind===`switch`||t.kind===`checkbox`?`horizontal`:`vertical`:t.kind===`checkbox`?`inline`:(t.layout??(t.kind===`switch`?`row`:`stacked`))===`row`?`horizontal`:`vertical`;return(0,X.jsx)(YK,{label:t.label,...r===`columns`?{labelTitle:t.label}:{},description:t.help,icon:t.icon,orientation:s,error:o,...t.required===void 0?{}:{required:t.required},...t.optional===void 0?{}:{optional:t.optional},children:t.render===void 0?(0,X.jsx)(h1,{spec:t,field:i,locked:n}):(0,X.jsx)(v1,{spec:t,field:i,locked:n,error:o,render:t.render})})}var b1=kn(xn(W,i1));function x1({form:e,spec:t,locked:n,layout:r}){let i=t.when;return CQ(e.store,e=>i===void 0||i(Ce(b1(e.values),()=>({}))))?(0,X.jsx)(y1,{form:e,spec:t,locked:n,layout:r}):null}function S1({form:e,section:t,locked:n,layout:r}){let i=t.fields.map(t=>(0,X.jsx)(x1,{form:e,spec:t,locked:n,layout:r},t.name));return t.title===void 0?i:(0,X.jsx)(KK,{title:t.title,description:t.description,layout:r,children:i})}function C1({model:e,names:t,disabled:n=!1,layout:r}){let i=e.form;return t===void 0?e.description.sections.map(e=>(0,X.jsx)(S1,{form:i,section:e,locked:n,layout:r},e.id??``)):t.map(t=>{let a=e.description.fields.find(e=>e.name===t);return a===void 0?null:(0,X.jsx)(x1,{form:i,spec:a,locked:n,layout:r},t)})}var w1=class{annotation;constructor(e){this.annotation=e}},T1=class{sections;constructor(e){this.sections=e}},E1=`caps/form`,D1=0;function O1(e){D1+=1;let t={[`${E1}:${String(D1)}`]:new w1(e)};return e.label!==void 0&&(t.title=e.label),e.help!==void 0&&(t.description=e.help),t}W.annotate(O1({kind:`secret`})).pipe(_t(`Secret`));var k1=e=>{let t=e.replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/[-_]+/g,` `).toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)};function A1(e){return Object.values(e??{}).reduce((e,t)=>t instanceof w1?{...e,...t.annotation}:e,{})}function j1(e){return e.reduce((e,t)=>({...e,...A1(t)}),{})}function M1(e){let t=e?.[E1];return t instanceof T1?t.sections:{}}var N1=kn(W);function P1(e){if(er(e))return Ze(N1(e.literal),{onNone:()=>null,onSome:e=>[e]});if(!Et(e))return null;let t=[];for(let n of e.types){if(Qt(n))continue;let e=P1(n);if(e===null)return null;t.push(...e)}return t}function F1(e){if(Jt(e))return{type:`string`,literals:[]};if(Xt(e))return{type:`number`,nullable:!1};if(Lt(e))return{type:`boolean`};let t=P1(e);if(t!==null)return{type:`string`,literals:t};if(Mt(e)){let[t]=e.rest;if(t===void 0)return null;if(Jt(t))return{type:`strings`,literals:[]};let n=P1(t);return n===null?null:{type:`strings`,literals:n}}if(Et(e)){let t=e.types.filter(e=>!Qt(e)&&!pt(e)),n=e.types.some(e=>pt(e)),[r]=t;if(t.length!==1||r===void 0)return null;let i=F1(r);return i?.type===`number`?{type:`number`,nullable:n}:n?null:i}return null}function I1(e){let t=e.ast;if(!kt(t))throw Error(`A schema form needs a Schema.Struct.`);return{fields:t.propertySignatures.map(e=>{let t=String(e.name),n=nn(e.type),r=j1([e.type.annotations,...(e.type.checks??[]).map(e=>e.annotations)]),i=r.kind===`file`?{type:`files`}:F1(n);if(i===null)throw Error(`Schema field "${t}" has no form control. Annotate it with field({ render }) or a kind.`);return{name:t,valueType:i,optional:e.type.context?.isOptional===!0,annotation:r,title:Nt(e.type),description:Hn(e.type)}}),sections:M1(Ft(t))}}function L1(e){let t=e,n=!1,r=!1;for(;;)if(t instanceof ne)n=!0,t=t.unwrap();else if(t instanceof o)r=!0,t=t.unwrap();else if(t instanceof D)t=t.unwrap();else if(t instanceof z)t=t.in;else return{node:t,optional:n,nullable:r}}function R1(e){if(e instanceof qe){let t=e.options.map(e=>R1(e));return t.some(e=>e===null)?null:t.flatMap(e=>e??[])}let t=e instanceof F?e.options:e instanceof lt?[...e.values]:null;if(t===null)return null;let n=t.map(e=>N1(e));return n.every(je)?n.map(e=>e.value):null}function z1(e){let{node:t,nullable:n}=L1(e);if(t instanceof g)return{type:`string`,literals:[]};if(t instanceof ie)return{type:`number`,nullable:n};if(t instanceof S)return{type:`boolean`};let r=R1(t);if(r!==null)return{type:`string`,literals:r};if(t instanceof m){let e=L1(t.element).node;if(e instanceof g)return{type:`strings`,literals:[]};let n=R1(e);return n===null?null:{type:`strings`,literals:n}}return null}function B1(e){let t=[e];for(;;){let e=t[t.length-1];if(e===void 0)break;let n=e instanceof ne||e instanceof o||e instanceof D?e.unwrap():e instanceof z?e.in:e;if(n===e)break;t.push(n)}return t.reverse().map(e=>O.get(e))}function V1(e){return B1(e).reduce((e,t)=>({...e,...t}),{})}function H1(e){return Object.entries(e.shape)}function U1(e){let t=L1(e).node;if(!(t instanceof y))throw Error(`A schema form needs a z.object.`);return{fields:H1(t).map(([e,t])=>{let n=j1(B1(t)),r=n.kind===`file`?{type:`files`}:z1(t);if(r===null)throw Error(`Schema field "${e}" has no form control. Annotate it with field({ render }) or a kind.`);let i=V1(t);return{name:e,valueType:r,optional:L1(t).optional,annotation:n,title:i.title,description:i.description}}),sections:M1(V1(e))}}function W1(e,t){let n=t.options??{};return(e.length>0?e:Object.keys(n)).map(e=>{let t=n[e],r=t===void 0?{}:t instanceof Object?t:{label:t};return{value:e,label:r.label??k1(e),description:r.description,meta:r.meta,icon:r.icon,caption:r.caption,disabled:r.disabled===!0}})}function G1(e,t){let n=t.some(e=>e.icon!==void 0);switch(e.type){case`boolean`:return`switch`;case`number`:return`number`;case`strings`:return n?`icon-checkboxes`:`checkboxes`;case`files`:return`file`;case`string`:return t.length===0?`text`:t.length>12?`combobox`:n?`icon-radio`:t.some(e=>e.description!==void 0||e.meta!==void 0)||t.length<=3?`radio`:`select`}}function K1(e,t){switch(e.type){case`boolean`:return!1;case`number`:return e.nullable?null:0;case`strings`:case`files`:return[];case`string`:return t[0]?.value??``}}function q1(e){let t=e instanceof T?U1(e):I1(e),n=t.fields.map((e,t)=>{let{kind:n,...r}=e.annotation,i=W1(e.valueType.type===`string`||e.valueType.type===`strings`?e.valueType.literals:[],e.annotation),a=r.help??e.description;return{...r,name:e.name,label:r.label??e.title??k1(e.name),help:a,kind:n??G1(e.valueType,i),options:i,optionalInSchema:e.optional,index:t}}),r={};t.fields.forEach((e,t)=>{let i=n[t];i&&(r[e.name]=K1(e.valueType,i.options))});let i=e=>e.order??e.index,a=e=>e.section!==void 0&&Object.hasOwn(t.sections,e.section)?e.section:null,o=e=>n.filter(t=>a(t)===e).sort((e,t)=>i(e)-i(t)),s=Object.entries(t.sections).map(([e,t])=>({id:e,title:t.title,description:t.description,fields:o(e)}));return{fields:n,sections:[{id:null,title:void 0,description:void 0,fields:o(null)},...s].filter(e=>e.fields.length>0),defaults:r}}function J1(e){let t=e instanceof T?e:zt(e);return{"~standard":{...t[`~standard`],validate:e=>{let n=t[`~standard`].validate(e);return n instanceof Promise?n.then(e=>Y1(e)):Y1(n)}}}}function Y1(e){return e.issues===void 0?e:{issues:e.issues.map(e=>e.path===void 0?e:{...e,path:e.path.slice(0,1)})}}var X1=`onServer`;function Z1(e){let t=e?.querySelector(`[aria-invalid="true"]`);t?.matches(`input, select, textarea, button, [tabindex]`)?t.focus():t?.querySelector(`input, select, textarea, button`)?.focus()}function Q1(e){return e.state.meta.errorMap.onServer!==void 0}function $1(e){e.setMeta(e=>({...e,errorMap:{...e.errorMap,[X1]:void 0}}))}function e0(e,t,n){e.setFieldMeta(t,e=>({...e,isBlurred:!0,errorMap:{...e.errorMap,[X1]:n}}))}function t0(e){let[t,n]=(0,J.useState)(null),[r,i]=(0,J.useState)(null),[a,o]=(0,J.useState)(e.defaultValues),[s,c]=(0,J.useState)(null);UZ(a,e.defaultValues)||(o(e.defaultValues),c(null));let{schema:l}=e,u=(0,J.useMemo)(()=>q1(l),[l]),d=(0,J.useMemo)(()=>J1(l),[l]),f=NQ({defaultValues:s??a,validators:{onChange:d,onSubmit:d},listeners:{onChange:({fieldApi:e})=>{n(null),i(null),Q1(e)&&$1(e)}},onSubmit:async({value:t,formApi:r})=>{n(null),i(null);let a=await J1(l)[`~standard`].validate(t);if(a.issues){n(a.issues[0]?.message??`Check the form and try again.`);return}let o;try{o=await e.onSubmit(a.value,t)??{kind:`saved`}}catch(t){console.error(`SchemaForm submit failed`,t),n(e.failure??`Couldn't save changes. Try again.`);return}if(o.kind===`refused`){n(o.error??null);let e=r;for(let[t,n]of Object.entries(o.fields??{}))n!==void 0&&n.length>0&&e0(e,t,n);return}let s=o.values??t;c(s),r.reset(s),i(o.message??`Saved`),e.onSaved?.(s)}});return{description:u,form:f,error:t,saved:r,discard:()=>{n(null),i(null),f.reset()},submit:()=>f.handleSubmit()}}function n0(e){return{dirty:CQ(e.form.store,e=>!e.isDefaultValue),submitting:CQ(e.form.store,e=>e.isSubmitting),canSubmit:CQ(e.form.store,e=>e.canSubmit)}}function r0({model:e,submitLabel:t=`Save changes`,discardLabel:n,onCancel:r,cancelLabel:i,allowClean:a,layout:o,footer:s,children:c,disabled:l=!1,...u}){let{submitting:d}=n0(e),f=(0,J.useRef)(null);return(0,X.jsxs)(WK,{...u,ref:f,layout:o,busy:d,noValidate:!0,onSubmit:t=>{t.preventDefault(),e.form.state.isSubmitting||e.submit().then(()=>{setTimeout(()=>{Z1(f.current)},0)})},children:[c??(0,X.jsx)(C1,{model:e,disabled:l,layout:o}),s===void 0?(0,X.jsx)(o0,{model:e,label:t,discardLabel:r===void 0?n:void 0,onCancel:r,cancelLabel:i,allowClean:a??r!==void 0,divider:r===void 0}):s]})}function i0({schema:e,defaultValues:t,onSubmit:n,onSaved:r,failure:i,...a}){let o=t0({schema:e,defaultValues:t,onSubmit:n,onSaved:r,failure:i});return(0,X.jsx)(r0,{...a,model:o})}function a0(e){return`model`in e?(0,X.jsx)(r0,{...e}):(0,X.jsx)(i0,{...e})}function o0({model:e,label:t,discardLabel:n,onCancel:r,cancelLabel:i=`Cancel`,allowClean:a=!1,dirtyLabel:o=`Unsaved changes`,buttonProps:s,...c}){let{dirty:l,submitting:u}=n0(e),d=u?null:e.saved&&!l?(0,X.jsx)(FG,{tone:`success`,size:`compact`,label:e.saved}):l?(0,X.jsx)(FG,{tone:`neutral`,size:`compact`,label:o}):null;return(0,X.jsxs)(UK,{...c,error:e.error,status:d,children:[r?(0,X.jsx)(BT,{type:`button`,variant:`ghost`,disabled:u,onClick:r,children:i}):n&&l?(0,X.jsx)(BT,{type:`button`,variant:`ghost`,disabled:u,onClick:e.discard,children:n}):null,(0,X.jsx)(BT,{...s,type:`submit`,loading:u,disabled:u||!l&&!a,title:!l&&!a?`No changes to save`:void 0,children:t})]})}var s0=e=>e,c0=(e,t)=>{let n=e[t];if(!n)throw Error(`Missing burger path: ${t}`);return n},l0={apiVersion:1,name:`burger`,palette:{bottomBun:`#e9c46a`,bunSpot:`#d4a373`,cheese:`#f4d03f`,dead:`#636e72`,deadTongue:`#b2bec3`,eye:`#2d3436`,lettuce:`#7cb342`,mouth:`#2d3436`,patty:`#5d4037`,tomato:`#e74c3c`,topBun:`#f4a261`,blush:`#feaae4`,tongue:`#f98284`,sweat:`#accce4`,white:`#ffffff`},build({scene:e,color:t}){let n=e.group({name:`root`}),r=e.group({parent:n,name:`body`,updateSort:!0});e.cylinder({parent:r,name:`bottom-bun`,backface:t(`bottomBun`),color:t(`bottomBun`),diameter:34,frontFace:t(`bunSpot`),length:6,rotate:{x:Math.PI/2},stroke:!1,translate:{y:8}}),e.cylinder({parent:r,name:`patty`,color:t(`patty`),diameter:36,frontFace:t(`patty`),length:4,rotate:{x:Math.PI/2},stroke:!1,translate:{y:3}}),e.cylinder({parent:r,name:`tomato`,color:t(`tomato`),diameter:34,frontFace:t(`tomato`),length:2,rotate:{x:Math.PI/2},stroke:!1,translate:{y:-2}});let i=e.hemisphere({parent:r,name:`top-bun`,backface:t(`bunSpot`),color:t(`topBun`),diameter:38,rotate:{x:Math.PI/2},stroke:!1,translate:{y:-3}});for(let[n,r]of[{x:-8,y:-6,z:14},{x:6,y:-8,z:13},{x:0,y:-10,z:12},{x:10,y:-4,z:13},{x:-5,y:-2,z:15},{x:4,y:-12,z:11}].entries())e.path({parent:i,name:`seed.${String(n+1)}`,path:[{x:0,y:0}],color:t(`bunSpot`),stroke:1.2,translate:r});let a=e.group({parent:r,name:`face`,translate:{y:-5,z:16}}),o=dr(e,t,a,{blushMode:`medium-alias`,hideMouth:!0}),s=e.group({parent:r,name:`burger.mouth`,translate:{y:1,z:10}}),c=s0({angry:[{x:-13,y:2},{x:13,y:2},{x:13,y:5},{bezier:[{x:7,y:4},{x:0,y:5},{x:-7,y:4}]},{x:-13,y:5}],happy:[{x:-12,y:0},{bezier:[{x:-6,y:3},{x:0,y:5},{x:6,y:3}]},{x:12,y:0},{x:13,y:2},{bezier:[{x:7,y:5},{x:0,y:7},{x:-7,y:5}]},{x:-13,y:2}],open:[{x:-10,y:0},{bezier:[{x:-10,y:5},{x:-5,y:8},{x:0,y:8}]},{bezier:[{x:5,y:8},{x:10,y:5},{x:10,y:0}]},{x:10,y:1},{bezier:[{x:5,y:6},{x:-5,y:6},{x:-10,y:1}]}],pout:[{x:-8,y:2},{bezier:[{x:0,y:5},{x:8,y:2},{x:8,y:4}]},{x:0,y:6},{x:-8,y:4}],sad:[{x:-12,y:3},{bezier:[{x:-6,y:0},{x:0,y:-1},{x:6,y:0}]},{x:12,y:3},{x:13,y:5},{bezier:[{x:7,y:2},{x:0,y:1},{x:-7,y:2}]},{x:-13,y:5}],small:[{x:-6,y:1},{x:6,y:1},{x:7,y:3},{x:0,y:2},{x:-7,y:3}],surprised:[],worried:[{x:-11,y:1},{bezier:[{x:-6,y:3},{x:-3,y:1},{x:0,y:2}]},{bezier:[{x:3,y:1},{x:6,y:3},{x:11,y:1}]},{x:12,y:3},{x:0,y:4},{x:-12,y:3}],dead:[{x:-12,y:1},{x:12,y:1},{x:13,y:4},{bezier:[{x:7,y:3},{x:0,y:4},{x:-7,y:3}]},{x:-13,y:4}],normal:[{x:-12,y:1},{x:12,y:1},{x:13,y:4},{bezier:[{x:7,y:3},{x:0,y:4},{x:-7,y:3}]},{x:-13,y:4}]}),l=s0({angry:[{x:-13,y:0},{x:13,y:0},{x:13,y:2},{bezier:[{x:7,y:1},{x:0,y:2},{x:-7,y:1}]},{x:-13,y:2}],happy:[{x:-12,y:2},{bezier:[{x:-6,y:0},{x:0,y:-1},{x:6,y:0}]},{x:12,y:2},{x:13,y:3},{bezier:[{x:7,y:1},{x:0,y:0},{x:-7,y:1}]},{x:-13,y:3}],open:[{x:-10,y:2},{bezier:[{x:-10,y:-3},{x:-5,y:-6},{x:0,y:-6}]},{bezier:[{x:5,y:-6},{x:10,y:-3},{x:10,y:2}]},{x:10,y:1},{bezier:[{x:5,y:-4},{x:-5,y:-4},{x:-10,y:1}]}],pout:[{x:-8,y:0},{bezier:[{x:-4,y:-1},{x:0,y:0},{x:4,y:-1}]},{x:8,y:0},{x:9,y:1},{x:0,y:1},{x:-9,y:1}],sad:[{x:-12,y:0},{bezier:[{x:-6,y:2},{x:0,y:3},{x:6,y:2}]},{x:12,y:0},{x:13,y:1},{bezier:[{x:7,y:3},{x:0,y:4},{x:-7,y:3}]},{x:-13,y:1}],small:[{x:-6,y:0},{bezier:[{x:-3,y:1},{x:0,y:0},{x:3,y:1}]},{x:6,y:0},{x:7,y:1},{x:0,y:1},{x:-7,y:1}],surprised:[{x:-13,y:2},{bezier:[{x:-7,y:-2},{x:0,y:-3},{x:7,y:-2}]},{x:13,y:2},{x:14,y:3},{bezier:[{x:8,y:0},{x:0,y:-1},{x:-8,y:0}]},{x:-14,y:3}],worried:[{x:-11,y:1},{bezier:[{x:-6,y:0},{x:-3,y:1},{x:0,y:0}]},{bezier:[{x:3,y:2},{x:6,y:0},{x:11,y:1}]},{x:12,y:2},{bezier:[{x:7,y:1},{x:0,y:1},{x:-7,y:1}]},{x:-12,y:2}],dead:[{x:-12,y:1},{bezier:[{x:-6,y:0},{x:0,y:-.5},{x:6,y:0}]},{x:12,y:1},{x:13,y:2},{bezier:[{x:7,y:1},{x:0,y:.5},{x:-7,y:1}]},{x:-13,y:2}],normal:[{x:-12,y:1},{bezier:[{x:-6,y:0},{x:0,y:-.5},{x:6,y:0}]},{x:12,y:1},{x:13,y:2},{bezier:[{x:7,y:1},{x:0,y:.5},{x:-7,y:1}]},{x:-13,y:2}]}),u={};for(let n of[`normal`,`happy`,`sad`,`angry`,`surprised`,`dead`,`small`,`worried`,`pout`,`open`]){let r=e.group({parent:s,name:`burger.mouth.${n}`}),i={y:n===`open`?2:n===`small`?.5:1.5,z:+(n===`pout`)};n===`surprised`?e.ellipse({parent:r,name:`cheese.${n}`,color:t(`cheese`),fill:!0,height:8,stroke:2,translate:{y:2,z:0},width:6}):e.path({parent:r,name:`cheese.${n}`,color:t(`cheese`),fill:!0,path:c0(c,n),stroke:2,translate:i});let a={y:n===`open`?1:n===`surprised`?-1:-.5,z:n===`pout`?2:1};e.path({parent:r,name:`lettuce.${n}`,color:t(`lettuce`),fill:!0,path:c0(l,n),stroke:1.5,translate:a}),u[n]=r}return{root:n,variants:{eyes:o.eyes,mouth:u,blush:o.blush}}},expressions:ur,activities:fr,defaultPresentation:{activity:`idle`,expression:`normal`}},u0=(e,t)=>{let n=e[t];if(!n)throw Error(`Missing cat face node: ${t}`);return n},d0=e=>e,f0={apiVersion:1,name:`cat`,palette:{body:`#ffe6c6`,eye:`#28282e`,mouth:`#28282e`,blush:`#feaae4`,dead:`#6c5671`,deadTongue:`#d9c8bf`,tongue:`#f98284`,stripes:`#dea38b`,sweat:`#accce4`,white:`#ffffff`},build({scene:e,color:t}){let n=e.group({name:`root`}),r=e.group({parent:n,name:`body`,updateSort:!0});e.path({parent:r,name:`body.sphere`,path:[{x:0,y:0}],color:t(`body`),stroke:32});for(let n of[-1,1])e.path({parent:r,name:`ear.${n<0?`left`:`right`}`,color:t(`body`),fill:!0,path:[{x:-6,y:0},{x:6,y:0},{x:0,y:-10}],rotate:{z:.6*n},stroke:3,translate:{x:9*n,y:-10}});let i=e.group({parent:r,name:`face`,translate:{z:20}}),a=dr(e,t,i,{hideMouth:!0}),o=e.group({parent:i,name:`cat.mouth`,translate:{y:6,z:2}}),s=(n,r,i)=>e.path({parent:o,name:`cat.mouth.${n}`,closed:!1,color:t(`mouth`),path:r,stroke:i}),c=d0({normal:s(`normal`,[{x:-2,y:-1},{x:0,y:0},{x:2,y:-1}],1.5),sad:s(`sad`,[{x:-2.5,y:2},{bezier:[{x:0,y:0},{x:2.5,y:2},{x:2.5,y:2}]}],1.5),angry:s(`angry`,[{x:-3,y:1},{x:3,y:1}],2),small:s(`small`,[{x:-1.5,y:0},{x:1.5,y:0}],1),worried:s(`worried`,[{x:-2,y:1},{bezier:[{x:-.5,y:.5},{x:.5,y:.5},{x:2,y:1}]}],1)}),l=e.group({parent:o,name:`cat.mouth.happy`,translate:{y:1}});e.path({parent:l,closed:!1,color:t(`mouth`),path:[{x:-2.5,y:1},{bezier:[{x:0,y:3},{x:2.5,y:1},{x:2.5,y:1}]}],stroke:1.5}),e.ellipse({parent:l,width:2,height:1.5,stroke:0,fill:!0,color:t(`tongue`),translate:{y:2}}),c.happy=l,c.surprised=e.ellipse({parent:o,name:`cat.mouth.surprised`,width:2.5,height:3,stroke:1.5,fill:!0,color:t(`mouth`),translate:{y:1}});let u=e.group({parent:o,name:`cat.mouth.dead`,translate:{y:3}});e.ellipse({parent:u,width:2.5,height:1.5,stroke:1.5,fill:!0,color:t(`dead`)}),e.ellipse({parent:u,width:1.2,height:.8,stroke:0,fill:!0,color:t(`deadTongue`),translate:{y:.5}}),c.dead=u,c.pout=e.ellipse({parent:o,name:`cat.mouth.pout`,width:2,height:2.5,stroke:1.5,fill:!0,color:t(`mouth`),translate:{y:1}}),c.open=e.ellipse({parent:o,name:`cat.mouth.open`,width:4,height:5,stroke:1.5,fill:!0,color:t(`mouth`),translate:{y:1}});let d=e.group({parent:i,name:`whiskers`,translate:{y:5,z:2}});for(let n of[-1,1]){let r=n*12;for(let[i,a]of[-2,0,2].entries())e.path({parent:d,name:`whisker.${n<0?`left`:`right`}.${String(i)}`,closed:!1,color:t(`eye`),path:[{x:0,y:a},{x:n*8,y:a+(i-1)*1.5}],stroke:.8,translate:{x:r,y:a*.5}})}let f={normal:u0(c,`normal`),happy:c.happy,sad:u0(c,`sad`),angry:u0(c,`angry`),surprised:c.surprised,dead:c.dead,small:u0(c,`small`),worried:u0(c,`worried`),pout:c.pout,open:c.open};return{root:n,variants:{eyes:a.eyes,mouth:f,blush:a.blush}}},expressions:ur,activities:{...fr,listening:{motion:{target:`root`,rotate:{x:-.2},durationMs:300,repeat:`yoyo`},mouseInfluence:.3},thinking:{motion:{target:`root`,rotate:{z:.1},durationMs:800,repeat:`yoyo`},mouseInfluence:0}},defaultPresentation:{activity:`idle`,expression:`normal`}},p0={apiVersion:1,name:`mushroom`,palette:{body:`#fff7e4`,cap:`#f98284`,capSpot:`#ffe6c6`,eye:`#28282e`,mouth:`#28282e`,dead:`#6c5671`,deadTongue:`#d9c8bf`,tongue:`#f98284`,sweat:`#accce4`,white:`#ffffff`},build({scene:e,color:t}){let n=e.group({name:`root`}),r=e.group({parent:n,name:`body`,updateSort:!0});e.hemisphere({parent:r,name:`body.hemisphere`,backface:t(`cap`),color:t(`body`),diameter:32,rotate:{x:3*Math.PI/2},stroke:!1,translate:{y:2}});let i=e.hemisphere({parent:r,name:`cap.hemisphere`,backface:t(`capSpot`),color:t(`cap`),diameter:42,rotate:{x:Math.PI/2},stroke:!1,translate:{y:2}});e.path({parent:i,name:`cap.spot.front`,path:[{x:0,y:0}],color:t(`capSpot`),stroke:12,translate:{x:-8,y:8,z:12}}),e.path({parent:i,name:`cap.spot.top`,path:[{x:0,y:0}],color:t(`capSpot`),stroke:18,translate:{x:8,y:-4,z:13}});let a=e.group({parent:r,name:`face`,translate:{y:7,z:8}}),o=dr(e,t,a,{blushMode:`none`});return{root:n,variants:{eyes:o.eyes,mouth:o.mouth,blush:o.blush}}},expressions:ur,activities:{...fr,error:{geometry:{eyes:`dead`,mouth:`dead`},motion:{target:`root`,rotate:{x:.9},durationMs:600,repeat:`none`},mouseInfluence:.1}},defaultPresentation:{activity:`idle`,expression:`sleepy`}},m0={mushroom:[`cap`,`capSpot`],cat:[`body`,`stripes`],burger:[`topBun`,`bottomBun`]},h0={mushroom:p0,cat:f0,burger:l0};function g0(e){let t=cr(lr(h0[e])),n=or.parse(t.data);return{controls:t.controls,expressions:Object.keys(n.expressions),identitySlots:m0[e]}}var _0=new Map;function v0(e){let t=_0.get(e);return t||(t=g0(e),_0.set(e,t)),t}var y0=Object.freeze({get mushroom(){return v0(`mushroom`)},get cat(){return v0(`cat`)},get burger(){return v0(`burger`)}}),b0={mushroom:`Shiitake`,cat:`Cat`,burger:`Burger`},x0=[[`Rose`,`#f98284`,`#ffe6c6`],[`Peach`,`#f6a55c`,`#ffe9c9`],[`Gold`,`#f2d06b`,`#fff6d1`],[`Leaf`,`#9bd47a`,`#e6f8d8`],[`Mint`,`#5fc7b4`,`#d9f6ef`],[`Sky`,`#6aaee8`,`#dcefff`],[`Lilac`,`#9b8cf0`,`#ebe6ff`],[`Plum`,`#e58bd6`,`#fbe2f6`]];function S0(e,t){if(t===e.character)return e;let n=y0[e.character].identitySlots,r=y0[t].identitySlots,i=Object.fromEntries(r.flatMap((t,r)=>{let i=n[r];return Object.hasOwn(e.appearance,i)?[[t,e.appearance[i]]]:[]}));return{...e,character:t,appearance:i,expression:`normal`}}function C0(e,[,t,n]){let r=y0[e.character].identitySlots;return{...e,appearance:{...e.appearance,...Object.fromEntries(r.map((e,r)=>[e,r===0?t:n]))}}}function w0(e,t){let n=0;for(let e of t)n+=e.codePointAt(0)??0;return C0(e,x0[n%x0.length]??x0[0])}function T0({value:e,disabled:t=!1,onChange:n}){let r=y0[e.character].identitySlots,i=x0.find(([,t,n])=>r.every((r,i)=>e.appearance[r]===(i===0?t:n)))?.[0]??``;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(qK,{legend:`Avatar`,icon:(0,X.jsx)(Xq,{name:`agent`}),layout:`columns`,disabled:t,children:(0,X.jsx)(W$,{"aria-label":`Character`,className:`caps-field-icon-choices`,disabled:t,orientation:`horizontal`,value:e.character,onValueChange:t=>{n(S0(e,Bh.shape.character.parse(t)))},children:Ih.map(t=>(0,X.jsx)(q$,{value:t,label:b0[t],caption:b0[t],art:`color`,icon:(0,X.jsx)(NX,{avatar:S0(e,t),name:b0[t],size:32})},t))})}),(0,X.jsx)(qK,{legend:`Colour`,icon:(0,X.jsx)(Xq,{name:`prints`}),layout:`columns`,disabled:t,children:(0,X.jsx)(W$,{"aria-label":`Colour`,className:`caps-field-icon-choices`,disabled:t,orientation:`horizontal`,value:i,onValueChange:t=>{let r=x0.find(([e])=>e===t);r&&n(C0(e,r))},children:x0.map(([e,t])=>(0,X.jsx)(J$,{value:e,label:e,color:t},e))})})]})}var E0=wn.check(Cn(1,{message:`Give your Agent a name.`}),H(256,{message:`Use at most 256 characters.`})),D0=kn(E0),O0=e=>e===`new`||e===`none`?e:e.computerId,k0=e=>e===`new`||e===`none`?e:{computerId:e},A0=e=>e?.[0]?.computerId??`none`;function j0(e,t){let n=Object.fromEntries(e.map(e=>[e.computerId,e.name]));n.new=`New Computer`,n.none=`No Computer`;let r={label:`Computer`,kind:`select`,icon:(0,X.jsx)(Xq,{name:`computer`}),options:n};return W.check(gt(e=>Object.hasOwn(n,e)||`Choose a Computer.`)).annotate(O1(t===null?r:{...r,help:t}))}var M0=Ot({family:`grove-agent-create-request`,version:1,kinds:{request:{prefix:`request`}}});function N0({create:e,computers:t,computersUnavailable:n,inputRef:r,error:i,onCancel:a}){let o=(0,J.useRef)(null),[s,c]=(0,J.useState)(()=>{let e=M0.request.generate();return w0(Wh(e),e)}),l=(0,J.useMemo)(()=>U({name:E0.annotate(O1({label:`Name`,icon:(0,X.jsx)(Xq,{name:`write`}),render:e=>(0,X.jsx)(eK,{ref:r,id:e.id,name:e.name,"aria-label":`New Agent name`,"aria-required":`true`,"aria-describedby":e[`aria-describedby`],"aria-invalid":e[`aria-invalid`],placeholder:`Name your Agent`,maxLength:256,disabled:e.disabled,value:e.value,onBlur:e.onBlur,onChange:t=>{e.onChange(t.currentTarget.value)}})})),computer:j0(t??[],n)}),[r,t,n]),u=t!==null,d={name:``,computer:A0(t)},f=t0({schema:l,defaultValues:d,onSubmit:async({name:t,computer:n})=>{let r=u?k0(n):void 0,i=o.current;if(i?.name!==t||(i.computer===void 0?void 0:O0(i.computer))!==(r===void 0?void 0:O0(r))||i.avatar!==s){let e={name:t,requestId:M0.request.generate(),avatar:s};i=r===void 0?e:{...e,computer:r}}return o.current=i,await e(i)?(o.current=null,{kind:`saved`,values:d}):{kind:`refused`}}}),{submitting:p,canSubmit:m,dirty:h}=n0(f);return(0,X.jsxs)(a0,{model:f,layout:`columns`,"aria-label":`Create Agent`,footer:(0,X.jsxs)(UK,{divider:!1,error:i,children:[(0,X.jsx)(BT,{type:`button`,variant:`ghost`,disabled:p,onClick:a,children:`Cancel`}),(0,X.jsx)(BT,{type:`submit`,className:`shrink-0 disabled:-outline-offset-1`,variant:`primary`,loading:p,disabled:p||!m||!h,children:`Create Agent`})]}),onSubmitCapture:e=>{Be(D0(f.form.state.values.name))&&e.currentTarget.querySelector(`input[name="name"]`)?.focus()},onChange:()=>{let e=f.form.state.values;(e.name.trim()!==o.current?.name||u&&o.current.computer!==void 0&&e.computer!==O0(o.current.computer))&&(o.current=null)},children:[(0,X.jsx)(C1,{model:f,names:u?[`name`,`computer`]:[`name`]}),(0,X.jsx)(T0,{value:s,disabled:p,onChange:e=>{c(e),o.current=null}})]})}function P0({open:e,pending:t,error:n,computers:r,create:i,onClose:a,returnFocus:o}){let s=(0,J.useRef)(null);return(0,X.jsx)(IU,{open:e,onOpenChange:e=>{!e&&!t&&a()},children:(0,X.jsxs)(VU,{className:`flex flex-col gap-lg`,initialFocus:s,finalFocus:o,keepMounted:!1,children:[(0,X.jsxs)(UU,{children:[(0,X.jsx)(WU,{children:`New Agent`}),(0,X.jsx)(GU,{children:`Agents chat, write and make little games with you.`})]}),r.status===`loading`?(0,X.jsx)(`p`,{role:`status`,children:`Loading your Computers…`}):(0,X.jsx)(N0,{create:i,computers:r.status===`offered`?r.computers:r.status===`unavailable`?[]:null,computersUnavailable:r.status===`unavailable`?r.message:null,inputRef:s,error:n,onCancel:a})]})})}function F0({open:e,agents:t,defaultAgentId:n,start:r,pending:i,onClose:a,onNewAgent:o,returnFocus:s}){let c=t0({schema:(0,J.useMemo)(()=>U({agentId:W.check(gt(e=>t.some(t=>t.agentId===e)||`Choose an Agent.`)).annotate(O1({label:`Agent`,kind:`select`,options:Object.fromEntries(t.map(e=>[e.agentId,YX(e)]))}))}),[t]),defaultValues:{agentId:n??``},onSubmit:async({agentId:e})=>{let t=await r(e);if(t)return{kind:`refused`,error:t}}}),{submitting:l,canSubmit:u}=n0(c);return(0,X.jsx)(IU,{open:e,onOpenChange:e=>{!e&&!i&&!c.form.state.isSubmitting&&a()},children:(0,X.jsxs)(VU,{className:`flex flex-col gap-lg`,keepMounted:!1,finalFocus:s,children:[(0,X.jsxs)(UU,{children:[(0,X.jsx)(WU,{children:`New conversation`}),(0,X.jsx)(GU,{children:`Choose who to talk with.`})]}),t.length===0?(0,X.jsxs)(`div`,{className:`grid gap-sm`,children:[(0,X.jsx)(`p`,{children:`No Agent has conversation access yet.`}),o?(0,X.jsx)(BT,{onClick:o,children:`New Agent`}):null,(0,X.jsx)(BT,{variant:`ghost`,onClick:a,children:`Cancel`})]}):(0,X.jsx)(a0,{model:c,"aria-label":`New conversation`,footer:(0,X.jsxs)(UK,{divider:!1,error:c.error,children:[(0,X.jsx)(BT,{type:`button`,variant:`ghost`,disabled:l||i,onClick:a,children:`Cancel`}),(0,X.jsx)(BT,{type:`submit`,loading:l||i,disabled:!u||l||i,children:`Start`})]})})]})})}var I0=J.useLayoutEffect;function L0(e,t,n){J.useEffect(()=>{if(!e.current||n||typeof IntersectionObserver!=`function`)return()=>t();let r=new IntersectionObserver(e=>{t(e.pop())},{rootMargin:`100px`});return r.observe(e.current),()=>{r.disconnect(),t()}},[t,n,e])}function R0(e){let t=J.useRef(null);return J.useImperativeHandle(e,()=>t.current,[]),t}function z0(e){return e[e.length-1]}function B0(e){return typeof e==`function`}function V0(e,t){return B0(e)?e(t):e}var H0=Object.prototype.hasOwnProperty,U0=Object.prototype.propertyIsEnumerable;function W0(e){for(let t in e)if(H0.call(e,t))return!0;return!1}var G0=()=>Object.create(null),K0=(e,t)=>q0(e,t,G0);function q0(e,t,n=()=>({}),r=0){if(e===t)return e;if(r>500)return t;let i=t,a=Z0(e)&&Z0(i);if(!a&&!(Y0(e)&&Y0(i)))return i;let o=a?e:J0(e);if(!o)return i;let s=a?i:J0(i);if(!s)return i;let c=o.length,l=s.length,u=a?Array(l):n(),d=0;for(let t=0;t<l;t++){let o=a?t:s[t],l=e[o],f=i[o];if(l===f){u[o]=l,(a?t<c:H0.call(e,o))&&d++;continue}if(l===null||f===null||typeof l!=`object`||typeof f!=`object`){u[o]=f;continue}let p=q0(l,f,n,r+1);u[o]=p,p===l&&d++}return c===l&&d===c?e:u}function J0(e){let t=Object.keys(e);if(t.length!==Object.getOwnPropertyNames(e).length)return!1;let n=Object.getOwnPropertySymbols(e);if(n.length===0)return t;for(let r of n){if(!U0.call(e,r))return!1;t.push(r)}return t}function Y0(e){if(!X0(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!X0(n)||!n.hasOwnProperty(`isPrototypeOf`))}function X0(e){return Object.prototype.toString.call(e)===`[object Object]`}function Z0(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Q0(e,t,n){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0,i=e.length;r<i;r++)if(!Q0(e[r],t[r],n))return!1;return!0}if(Y0(e)&&Y0(t)){let r=n?.ignoreUndefined??!0;if(n?.partial){for(let i in t)if((!r||t[i]!==void 0)&&!Q0(e[i],t[i],n))return!1;return!0}let i=0;if(!r)i=Object.keys(e).length;else for(let t in e)e[t]!==void 0&&i++;let a=0;for(let o in t)if((!r||t[o]!==void 0)&&(a++,a>i||!Q0(e[o],t[o],n)))return!1;return i===a}return!1}var $0=/[\x00-\x1f\x7f"<>`{}]/g;function e2(e){return e.replace($0,e=>`%`+e.charCodeAt(0).toString(16).toUpperCase().padStart(2,`0`))}function t2(e){let t;try{t=decodeURI(e)}catch{t=e.replaceAll(/%[0-9A-F]{2}/gi,e=>{try{return decodeURI(e)}catch{return e}})}return e2(t)}var n2=[`http:`,`https:`,`mailto:`,`tel:`];function r2(e,t){if(!e)return!1;try{let n=new URL(e);return!t.has(n.protocol)}catch{return!1}}function i2(e){if(!e||!/[%\\\x00-\x1f\x7f]/.test(e)&&!e.startsWith(`//`))return{path:e,handledProtocolRelativeURL:!1};let t=/%25|%5C/gi,n=0,r=``,i;for(;(i=t.exec(e))!==null;)r+=t2(e.slice(n,i.index))+i[0],n=t.lastIndex;r+=t2(n?e.slice(n):e);let a=!1;return r.startsWith(`//`)&&(a=!0,r=`/`+r.replace(/^\/+/,``)),{path:r,handledProtocolRelativeURL:a}}function a2(e){return/\s|[^\u0000-\u007F]/.test(e)?e.replace(/\s|[^\u0000-\u007F]/gu,encodeURIComponent):e}function o2(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function s2(){throw Error(`Invariant failed`)}function c2(e){let t=new Map,n,r,i=e=>{e.next&&(e.prev?(e.prev.next=e.next,e.next.prev=e.prev,e.next=void 0,r&&(r.next=e,e.prev=r)):(e.next.prev=void 0,n=e.next,e.next=void 0,r&&(e.prev=r,r.next=e)),r=e)};return{get(e){let n=t.get(e);if(n)return i(n),n.value},set(a,o){if(t.size>=e&&n){let e=n;t.delete(e.key),e.next&&(n=e.next,e.next.prev=void 0),e===r&&(r=void 0)}let s=t.get(a);if(s)s.value=o,i(s);else{let e={key:a,value:o,prev:r};r&&(r.next=e),r=e,n||=e,t.set(a,e)}},clear(){t.clear(),n=void 0,r=void 0}}}var l2=4,u2=5;function d2(e){let t=e.indexOf(`{`);if(t===-1)return null;let n=e.indexOf(`}`,t);return n===-1||t+1>=e.length?null:[t,n]}function f2(e,t,n=new Uint16Array(6)){let r=e.indexOf(`/`,t),i=r===-1?e.length:r,a=e.substring(t,i);if(!a||!a.includes(`$`))return n[0]=0,n[1]=t,n[2]=t,n[3]=i,n[4]=i,n[5]=i,n;if(a===`$`){let r=e.length;return n[0]=2,n[1]=t,n[2]=t,n[3]=r,n[4]=r,n[5]=r,n}if(a.charCodeAt(0)===36)return n[0]=1,n[1]=t,n[2]=t+1,n[3]=i,n[4]=i,n[5]=i,n;let o=d2(a);if(o){let[r,s]=o,c=a.charCodeAt(r+1);if(c===45){if(r+2<a.length&&a.charCodeAt(r+2)===36){let e=r+3,a=s;if(e<a)return n[0]=3,n[1]=t+r,n[2]=t+e,n[3]=t+a,n[4]=t+s+1,n[5]=i,n}}else if(c===36){let a=r+1,o=r+2;return o===s?(n[0]=2,n[1]=t+r,n[2]=t+a,n[3]=t+o,n[4]=t+s+1,n[5]=e.length,n):(n[0]=1,n[1]=t+r,n[2]=t+o,n[3]=t+s,n[4]=t+s+1,n[5]=i,n)}}return n[0]=0,n[1]=t,n[2]=t,n[3]=i,n[4]=i,n[5]=i,n}function p2(e,t,n,r,i,a,o,s){s?.(n);let c=r;{let r=n.fullPath??n.from,s=n.options,l=r.length,u=s?.caseSensitive??e,d=s?.params?.parse??s?.parseParams;for(;c<l;){let e=f2(r,c,t),n,s=c,l=e[5];c=l+1,a++;let f=e[0];switch(f){case 0:{let t=r.substring(e[2],e[3]),o=t,s;u?s=i.static??=new Map:(o=t.toLowerCase(),s=i.staticInsensitive??=new Map);let c=s.get(o);if(c)n=c;else{let e=h2(r);e.parent=i,e.depth=a,n=e,s.set(o,e)}break}case 1:case 3:case 2:{let t=r.substring(s,e[1]),c=r.substring(e[4],l),p=u&&!!(t||c),m=t?p?t:t.toLowerCase():void 0,h=c?p?c:c.toLowerCase():void 0,g=f===1?i.dynamic:f===3?i.optional:i.wildcard,_=f!==2&&!d&&g?.find(e=>!e.parse&&e.caseSensitive===p&&e.prefix===m&&e.suffix===h);if(_)n=_;else{let e=g2(f,r,p,m,h);n=e,e.parent=i,e.depth=a;let t;t=f===1?i.dynamic??=[]:f===3?i.optional??=[]:i.wildcard??=[],t.push(e),t.length===2&&o?.push(t)}break}}i=n}if(d&&n.children&&!n.isRoot&&n.id&&n.id.charCodeAt(n.id.lastIndexOf(`/`)+1)===95){let e=h2(r);e.kind=u2,e.parent=i,a++,e.depth=a,i.pathless??=[],i.pathless.push(e),i=e}let f=(n.path||!n.children)&&!n.isRoot;if(f&&r.endsWith(`/`)){let e=h2(r);e.kind=l2,e.parent=i,a++,e.depth=a,i.index=e,i=e}i.parse=d??null,i.priority=s?.params?.priority??0,f&&!i.route&&(i.route=n,i.fullPath=r)}if(n.children)for(let r of n.children)p2(e,t,r,c,i,a,o,s)}function m2(e,t){if(e.parse&&!t.parse)return-1;if(!e.parse&&t.parse)return 1;if(e.parse&&t.parse&&(e.priority||t.priority))return t.priority-e.priority;if(e.prefix&&t.prefix&&e.prefix!==t.prefix){if(e.prefix.startsWith(t.prefix))return-1;if(t.prefix.startsWith(e.prefix))return 1}if(e.suffix&&t.suffix&&e.suffix!==t.suffix){if(e.suffix.endsWith(t.suffix))return-1;if(t.suffix.endsWith(e.suffix))return 1}return e.prefix&&!t.prefix?-1:!e.prefix&&t.prefix?1:e.suffix&&!t.suffix?-1:!e.suffix&&t.suffix?1:e.caseSensitive&&!t.caseSensitive?-1:!e.caseSensitive&&t.caseSensitive?1:0}function h2(e){return{kind:0,depth:0,pathless:null,index:null,static:null,staticInsensitive:null,dynamic:null,optional:null,wildcard:null,route:null,fullPath:e,parent:null,parse:null,priority:0}}function g2(e,t,n,r,i){return{kind:e,depth:0,pathless:null,index:null,static:null,staticInsensitive:null,dynamic:null,optional:null,wildcard:null,route:null,fullPath:t,parent:null,parse:null,priority:0,caseSensitive:n,prefix:r,suffix:i}}function _2(e,t){let n=h2(`/`),r=new Uint16Array(6),i=[];for(let t of e)p2(!1,r,t,1,n,0,i);for(let e of i)e.sort(m2);t.masksTree=n,t.flatCache=c2(1e3)}function v2(e,t){e||=`/`;let n=t.flatCache.get(e);if(n)return n;let r=C2(e,t.masksTree);return t.flatCache.set(e,r),r}function y2(e,t,n,r,i){e||=`/`,r||=`/`;let a=t?`case\0${e}`:e,o=i.singleCache.get(a);return o||(o=h2(`/`),p2(t,new Uint16Array(6),{from:e},1,o,0),i.singleCache.set(a,o)),C2(r,o,n)}function b2(e,t,n=!1){let r=n?e:`nofuzz\0${e}`,i=t.matchCache.get(r);if(i!==void 0)return i;e||=`/`;let a;try{a=C2(e,t.segmentTree,n)}catch(e){if(e instanceof URIError)a=null;else throw e}return a&&(a.branch=T2(a.route)),t.matchCache.set(r,a),a}function x2(e){return e===`/`?e:e.replace(/\/{1,}$/,``)}function S2(e,t=!1,n){let r=h2(e.fullPath),i=new Uint16Array(6),a=[],o={},s={},c=0;p2(t,i,e,1,r,0,a,e=>{if(n?.(e,c),e.id in o&&s2(),o[e.id]=e,c!==0&&e.path){let t=x2(e.fullPath);(!s[t]||e.fullPath.endsWith(`/`))&&(s[t]=e)}c++});for(let e of a)e.sort(m2);return{processedTree:{segmentTree:r,singleCache:c2(1e3),matchCache:c2(1e3),flatCache:null,masksTree:null},routesById:o,routesByPath:s}}function C2(e,t,n=!1){let r=e.split(`/`),i=D2(e,r,t,n);if(!i)return null;let[a]=w2(e,r,i);return{route:i.node.route,rawParams:a}}function w2(e,t,n){let r=E2(n.node),i=null,a=Object.create(null),o=n.extract?.part??0,s=n.extract?.node??0,c=n.extract?.path??0,l=n.extract?.segment??0;for(;s<r.length;o++,s++,c++,l++){let u=r[s];if(u.kind===l2)break;if(u.kind===u2){l--,o--,c--;continue}let d=t[o],f=c;if(d&&(c+=d.length),u.kind===1){i??=n.node.fullPath.split(`/`);let e=i[l],t=u.prefix?.length??0;if(e.charCodeAt(t)===123){let n=u.suffix?.length??0,r=e.substring(t+2,e.length-n-1),i=d.substring(t,d.length-n);a[r]=decodeURIComponent(i)}else{let t=e.substring(1);a[t]=decodeURIComponent(d)}}else if(u.kind===3){if(n.skipped&1<<s){o--,c=f-1;continue}i??=n.node.fullPath.split(`/`);let e=i[l],t=u.prefix?.length??0,r=u.suffix?.length??0,p=e.substring(t+3,e.length-r-1),m=u.suffix||u.prefix?d.substring(t,d.length-r):d;m&&(a[p]=decodeURIComponent(m))}else if(u.kind===2){let t=u,n=e.substring(f+(t.prefix?.length??0),e.length-(t.suffix?.length??0)),r=decodeURIComponent(n);a[`*`]=r,a._splat=r;break}}return n.rawParams&&Object.assign(a,n.rawParams),[a,{part:o,node:s,path:c,segment:l}]}function T2(e){let t=[e];for(;e.parentRoute;)e=e.parentRoute,t.push(e);return t.reverse(),t}function E2(e){let t=Array(e.depth+1);do t[e.depth]=e,e=e.parent;while(e);return t}function D2(e,t,n,r){if(e===`/`&&n.index)return{node:n.index,skipped:0};let i=!z0(t),a=i&&e!==`/`,o=t.length-+!!i,s=[{node:n,index:1,skipped:0,statics:0,dynamics:0,optionals:0}],c=null,l=null;for(;s.length;){let n=s.pop(),{node:i,index:u,skipped:d,statics:f,dynamics:p,optionals:m}=n,{extract:h,rawParams:g}=n;if(i.kind===2&&i.route&&!j2(l,n))continue;if(i.parse){if(!A2(e,t,n))continue;g=n.rawParams,h=n.extract}r&&i.route&&i.kind!==l2&&j2(c,n)&&(c=n);let _=u===o;if(_&&(i.route&&(!a||i.kind===l2||i.kind===2)&&j2(l,n)&&(l=n),!i.optional&&!i.wildcard&&!i.index&&!i.pathless))continue;let v=_?void 0:t[u],y;if(_&&i.index){let n={node:i.index,index:u,skipped:d,statics:f,dynamics:p,optionals:m,extract:h,rawParams:g},r=!0;if(i.index.parse&&(A2(e,t,n)||(r=!1)),r){if(!p&&!m&&!d&&k2(f,o))return n;j2(l,n)&&(l=n)}}if(i.wildcard)for(let e=i.wildcard.length-1;e>=0;e--){let n=i.wildcard[e],{prefix:r,suffix:a}=n;if(!(r&&(_||!(n.caseSensitive?v:y??=v.toLowerCase()).startsWith(r)))){if(a){if(_)continue;let e=t.slice(u).join(`/`).slice(-a.length);if((n.caseSensitive?e:e.toLowerCase())!==a)continue}s.push({node:n,index:o,skipped:d,statics:f,dynamics:p,optionals:m,extract:h,rawParams:g})}}if(i.optional){let e=d|1<<i.depth+1;for(let t=i.optional.length-1;t>=0;t--){let n=i.optional[t];s.push({node:n,index:u,skipped:e,statics:f,dynamics:p,optionals:m,extract:h,rawParams:g})}if(!_)for(let e=i.optional.length-1;e>=0;e--){let t=i.optional[e],{prefix:n,suffix:r}=t;if(n||r){let e=t.caseSensitive?v:y??=v.toLowerCase();if(n&&!e.startsWith(n)||r&&!e.endsWith(r))continue}s.push({node:t,index:u+1,skipped:d,statics:f,dynamics:p,optionals:m+O2(o,u),extract:h,rawParams:g})}}if(!_&&i.dynamic&&v)for(let e=i.dynamic.length-1;e>=0;e--){let t=i.dynamic[e],{prefix:n,suffix:r}=t;if(n||r){let e=t.caseSensitive?v:y??=v.toLowerCase();if(n&&!e.startsWith(n)||r&&!e.endsWith(r))continue}s.push({node:t,index:u+1,skipped:d,statics:f,dynamics:p+O2(o,u),optionals:m,extract:h,rawParams:g})}if(!_&&i.staticInsensitive){let e=i.staticInsensitive.get(y??=v.toLowerCase());e&&s.push({node:e,index:u+1,skipped:d,statics:f+O2(o,u),dynamics:p,optionals:m,extract:h,rawParams:g})}if(!_&&i.static){let e=i.static.get(v);e&&s.push({node:e,index:u+1,skipped:d,statics:f+O2(o,u),dynamics:p,optionals:m,extract:h,rawParams:g})}if(i.pathless)for(let e=i.pathless.length-1;e>=0;e--){let t=i.pathless[e];s.push({node:t,index:u,skipped:d,statics:f,dynamics:p,optionals:m,extract:h,rawParams:g})}}if(l)return l;if(r&&c){let n=c.index;for(let e=0;e<c.index;e++)n+=t[e].length;let r=n===e.length?`/`:e.slice(n);return c.rawParams??=Object.create(null),c.rawParams[`**`]=decodeURIComponent(r),c}return null}function O2(e,t){return 2**(e-t-1)}function k2(e,t){return e===2**(t-1)-1}function A2(e,t,n){let r,i;try{[r,i]=w2(e,t,n)}catch{return null}if(n.rawParams=r,n.extract=i,!n.node.parse)return!0;try{if(n.node.parse(r)===!1)return null}catch{}return!0}function j2(e,t){return!e||t.statics>e.statics||t.statics===e.statics&&(t.dynamics>e.dynamics||t.dynamics===e.dynamics&&(t.optionals>e.optionals||t.optionals===e.optionals&&((t.node.kind===l2)>(e.node.kind===l2)||t.node.kind===l2==(e.node.kind===l2)&&t.node.depth>e.node.depth)))}function M2(e){return N2(e.filter(e=>e!==void 0).join(`/`))}function N2(e){return e.replace(/\/{2,}/g,`/`)}function P2(e){return e===`/`?e:e.replace(/^\/{1,}/,``)}function F2(e){let t=e.length;return t>1&&e[t-1]===`/`?e.replace(/\/{1,}$/,``):e}function I2(e){return F2(P2(e))}function L2(e,t){return e?.endsWith(`/`)&&e!==`/`&&e!==`${t}/`?e.slice(0,-1):e}function R2(e,t,n){return L2(e,n)===L2(t,n)}function z2({base:e,to:t,trailingSlash:n=`never`,cache:r}){let i=t===`.`,a=t.startsWith(`/`),o;if(r){o=a?t:i?e:e+`\0`+t;let n=r.get(o);if(n)return n}let s;if(i)s=e.split(`/`);else if(a)s=t.split(`/`);else{for(s=e.split(`/`);s.length>1&&z0(s)===``;)s.pop();let n=t.split(`/`);for(let e=0,t=n.length;e<t;e++){let r=n[e];r===``?e?e===t-1&&s.push(r):s=[r]:r===`..`?s.length>1?s.pop():s=[``]:r===`.`||s.push(r)}}s.length>1&&(z0(s)===``?n===`never`&&s.pop():n===`always`&&s.push(``));let c=N2(s.join(`/`))||`/`;return o&&r&&r.set(o,c),c}function B2(e){let t=new Map(e.map(e=>[encodeURIComponent(e),e])),n=Array.from(t.keys()).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`|`),r=new RegExp(n,`g`);return e=>e.replace(r,e=>t.get(e)??e)}function V2(e,t,n){let r=t[e];return typeof r==`string`?e===`_splat`?/^[a-zA-Z0-9\-._~!/]*$/.test(r)?r:r.split(`/`).map(e=>U2(e,n)).join(`/`):U2(r,n):r}function H2({path:e,params:t,decoder:n,...r}){let i=!1,a=Object.create(null);if(!e||e===`/`)return{interpolatedPath:`/`,usedParams:a,isMissingParams:i};if(!e.includes(`$`))return{interpolatedPath:e,usedParams:a,isMissingParams:i};let o=e.length,s=0,c,l=``;for(;s<o;){let r=s;c=f2(e,r,c);let o=c[5];if(s=o+1,r===o)continue;let u=c[0];if(u===0){l+=`/`+e.substring(r,o);continue}if(u===2){let s=t._splat;a._splat=s,a[`*`]=s;let u=e.substring(r,c[1]),d=e.substring(c[4],o);if(!s){i=!0,(u||d)&&(l+=`/`+u+d);continue}let f=V2(`_splat`,t,n);l+=`/`+u+f+d;continue}if(u===1){let s=e.substring(c[2],c[3]);!i&&!(s in t)&&(i=!0),a[s]=t[s];let u=e.substring(r,c[1]),d=e.substring(c[4],o),f=V2(s,t,n)??`undefined`;l+=`/`+u+f+d;continue}if(u===3){let i=e.substring(c[2],c[3]),s=t[i];if(s==null)continue;a[i]=s;let u=e.substring(r,c[1]),d=e.substring(c[4],o),f=V2(i,t,n)??``;l+=`/`+u+f+d;continue}}return e.endsWith(`/`)&&(l+=`/`),{usedParams:a,interpolatedPath:l||`/`,isMissingParams:i}}function U2(e,t){let n=encodeURIComponent(e);return t?.(n)??n}function W2(e){return e?.isNotFound===!0}function G2(){try{return sessionStorage}catch{return}}var K2=`tsr-scroll-restoration-v1_3`,q2=G2();function J2(){try{return JSON.parse(q2?.getItem(`tsr-scroll-restoration-v1_3`)||`{}`)}catch{return{}}}function Y2(){try{q2?.setItem(K2,JSON.stringify(X2))}catch{}}var X2=J2(),Z2=`data-scroll-restoration-id`,Q2=e=>e.state.__TSR_key||e.href;function $2(e){let t=e.getAttribute(Z2);if(t)return`[${Z2}="${t}"]`;let n=``,r=e,i;for(;i=r.parentNode;){let e=1,t=r;for(;t=t.previousElementSibling;)e++;let a=`${r.localName}:nth-child(${e})`;n=n?`${a} > ${n}`:a,r=i}return n}var e4=!1,t4=`window`;function n4(e){try{return typeof e==`function`?e():document.querySelector(e)}catch{}}function r4(e){let t=new Set;for(let n of e){if(n===t4)continue;let e=n4(n);e&&t.add(e)}return t}function i4(e,t){let n=t??e.options.scrollRestoration,r=e._scroll;n&&(r.restoring=!0);let i=e.options.getScrollRestorationKey||Q2,a=new Set,o=e=>{let t=X2[e]||={};for(let e of a)e===document?t[t4]={scrollX,scrollY}:e.isConnected&&(t[$2(e)]={scrollX:e.scrollLeft,scrollY:e.scrollTop})};n&&!r.restoration&&(r.restoration=!0,e4=!1,history.scrollRestoration=`manual`,document.addEventListener(`scroll`,e=>{e4||a.add(e.target)},!0),e.subscribe(`onBeforeLoad`,e=>{e.fromLocation&&o(i(e.fromLocation)),a.clear()}),addEventListener(`pagehide`,()=>{o(i(e.stores.resolvedLocation.get()??e.stores.location.get())),Y2()})),!r.reset&&(r.reset=!0,e.subscribe(`onRendered`,t=>{let n=e.options.scrollRestorationBehavior,o=e.options.scrollToTopSelectors,s=r.next,c=r.hash,l;if(a.clear(),r.next=!0,r.hash=!1,typeof e.options.scrollRestoration==`function`&&!e.options.scrollRestoration({location:e.latestLocation}))return;let u=i(t.toLocation),d=t.fromLocation&&i(t.fromLocation);if(r.restoring&&d&&d!==u){let e=X2[d];if(e){let t=X2[u];for(let n in e){if(n===t4){if(s)continue}else{let e=n4(n);if(!e||s&&o&&(l??=r4(o),l.has(e)))continue}t||=X2[u]={},t[n]??=e[n]}}}e4=!0;try{let e=t.toLocation.hash,i=t.toLocation.state.__hashScrollIntoViewOptions??!0,a=!1;if(s){!e&&o&&(l??=r4(o));let t=e&&i&&c,s=r.restoring?X2[u]:void 0;if(s)for(let e in s){let{scrollX:r,scrollY:i}=s[e];if(e===t4){if(t)continue;scrollTo({top:i,left:r,behavior:n}),a=!0}else{let t=n4(e);t&&(t.scrollLeft=r,t.scrollTop=i,l?.delete(t))}}if(!e){let e={top:0,left:0,behavior:n};if(a||scrollTo(e),l)for(let t of l)t.scrollTo(e)}}!a&&e&&i&&document.getElementById(e)?.scrollIntoView(i)}finally{e4=!1}}))}function a4(e,t=String){let n=new URLSearchParams;for(let r in e){let i=e[r];i!==void 0&&n.set(r,t(i))}return n.toString()}function o4(e){return e?e===`false`?!1:e===`true`?!0:e*0==0&&+e+``===e?+e:e:``}function s4(e){let t=new URLSearchParams(e),n=Object.create(null);for(let[e,r]of t.entries()){let t=n[e];t==null?n[e]=o4(r):Array.isArray(t)?t.push(o4(r)):n[e]=[t,o4(r)]}return n}var c4=/^(?:\s|["[{\d-]|fa|nu|tr)/,l4=d4(JSON.parse),u4=f4(JSON.stringify,JSON.parse);function d4(e){return t=>{t[0]===`?`&&(t=t.substring(1));let n=s4(t);for(let t in n){let r=n[t];if(typeof r==`string`)try{n[t]=e(r)}catch{}}return n}}function f4(e,t){let n=t===JSON.parse;function r(r){if(r&&typeof r==`object`)try{return e(r)}catch{}else if(t&&typeof r==`string`){if(n&&!c4.test(r))return r;try{return t(r),e(r)}catch{}}return r}return e=>{let t=a4(e,r);return t?`?${t}`:``}}var p4=`__root__`;function m4(e){if(e.statusCode=e.statusCode||e.code||307,!e._builtLocation&&!e.reloadDocument&&typeof e.href==`string`)try{new URL(e.href),e.reloadDocument=!0}catch{}let t=new Headers(e.headers);e.href&&t.get(`Location`)===null&&t.set(`Location`,e.href);let n=new Response(null,{status:e.statusCode,headers:t});if(n.options=e,e.throw)throw n;return n}function h4(e){return e instanceof Response&&!!e.options}function g4(e){return{input:({url:t})=>{for(let n of e)t=v4(n,t);return t},output:({url:t})=>{for(let n=e.length-1;n>=0;n--)t=y4(e[n],t);return t}}}function _4(e){let t=I2(e.basepath),n=`/${t}`,r=e.caseSensitive?n:n.toLowerCase(),i=`${r}/`;return{input:({url:t})=>{let a=e.caseSensitive?t.pathname:t.pathname.toLowerCase();return a===r?t.pathname=`/`:a.startsWith(i)&&(t.pathname=t.pathname.slice(n.length)),t},output:({url:e})=>(e.pathname=M2([`/`,t,e.pathname]),e)}}function v4(e,t){let n=e?.input?.({url:t});if(n){if(typeof n==`string`)return new URL(n);if(n instanceof URL)return n}return t}function y4(e,t){let n=e?.output?.({url:t});if(n){if(typeof n==`string`)return new URL(n);if(n instanceof URL)return n}return t}function b4(e,t){let{createMutableStore:n,createReadonlyStore:r,batch:i}=t,a=new Map,o=n(`idle`),s=n(e),c=n(void 0),l=n([]),u=r(()=>l.get().map(e=>a.get(e).get())),d=r(()=>({status:o.get(),isLoading:o.get()===`pending`,matches:u.get(),location:s.get(),resolvedLocation:c.get()}));function f(e){let t=a.get(e);return t||(t=n(void 0),a.set(e,t)),t}let p={status:o,location:s,resolvedLocation:c,ids:l,matches:u,byRoute:a,__store:d,getMatchStore:f,setMatches:m};function m(e){let t=l.get(),n=e.map(e=>e.routeId);i(()=>{o2(t,n)||l.set(n);for(let e of t)n.includes(e)||a.get(e).set(()=>void 0);for(let t of e){let e=f(t.routeId);e.get()!==t&&e.set(t)}})}return p}var x4=`__TSR_index`,S4=`popstate`,C4=`beforeunload`;function w4(e){let t=e.getLocation(),n=new Set,r=r=>{t=e.getLocation(),n.forEach(e=>e({location:t,action:r}))},i=n=>{e.notifyOnIndexChange??!0?r(n):t=e.getLocation()},a=async({task:n,navigateOpts:r,...i})=>{if(r?.ignoreBlocker??!1){n();return}let a=e.getBlockers?.()??[],o=i.type===`PUSH`||i.type===`REPLACE`;if(typeof document<`u`&&a.length&&o)for(let n of a){let r=k4(i.path,i.state);if(await n.blockerFn({currentLocation:t,nextLocation:r,action:i.type})){e.onBlocked?.();return}}n()};return{get location(){return t},get length(){return e.getLength()},subscribers:n,subscribe:e=>(n.add(e),()=>{n.delete(e)}),push:(n,i,o)=>{let s=t.state[x4];i=T4(s+1,i),a({task:()=>{e.pushState(n,i),r({type:`PUSH`})},navigateOpts:o,type:`PUSH`,path:n,state:i})},replace:(n,i,o)=>{let s=t.state[x4];i=T4(s,i),a({task:()=>{e.replaceState(n,i),r({type:`REPLACE`})},navigateOpts:o,type:`REPLACE`,path:n,state:i})},go:(t,n)=>{a({task:()=>{e.go(t),i({type:`GO`,index:t})},navigateOpts:n,type:`GO`})},back:t=>{a({task:()=>{e.back(t?.ignoreBlocker??!1),i({type:`BACK`})},navigateOpts:t,type:`BACK`})},forward:t=>{a({task:()=>{e.forward(t?.ignoreBlocker??!1),i({type:`FORWARD`})},navigateOpts:t,type:`FORWARD`})},canGoBack:()=>t.state[x4]!==0,createHref:t=>e.createHref(t),block:t=>{if(!e.setBlockers)return()=>{};let n=e.getBlockers?.()??[];return e.setBlockers([...n,t]),()=>{let n=e.getBlockers?.()??[];e.setBlockers?.(n.filter(e=>e!==t))}},flush:()=>e.flush?.(),destroy:()=>e.destroy?.(),notify:r}}function T4(e,t){t||={};let n=A4();return{...t,key:n,__TSR_key:n,[x4]:e}}function E4(e){let t=e?.window??(typeof document<`u`?window:void 0),n=t.history.pushState,r=t.history.replaceState,i=[],a=()=>i,o=e=>i=e,s=e?.createHref??(e=>e),c=e?.parseLocation??(()=>k4(`${t.location.pathname}${t.location.search}${t.location.hash}`,t.history.state));if(!t.history.state?.__TSR_key&&!t.history.state?.key){let e=A4();t.history.replaceState({[x4]:0,key:e,__TSR_key:e},``)}let l=c(),u,d=!1,f=!1,p=!1,m=!1,h=()=>l,g,_=()=>{g&&(S._ignoreSubscribers=!0,(g[2]?t.history.pushState:t.history.replaceState)(g[1],``,g[0]),S._ignoreSubscribers=!1,g=void 0,u=void 0)},v=(e,t,n)=>{let r=s(t),i=!!g;i||(u=l),l=k4(t,n),g=[r,n,g?.[2]||e],i||queueMicrotask(()=>_())},y=e=>{l=c(),S.notify({type:e})},b=async()=>{if(f){f=!1;return}let e=c(),n=e.state[x4]-l.state[x4],r=n===1,i=n===-1,o=!r&&!i||d;d=!1;let s=o?`GO`:i?`BACK`:`FORWARD`,u=o?{type:`GO`,index:n}:{type:i?`BACK`:`FORWARD`};if(p)p=!1;else{let n=a();if(typeof document<`u`&&n.length){for(let r of n)if(await r.blockerFn({currentLocation:l,nextLocation:e,action:s})){f=!0,t.history.go(1),S.notify(u);return}}}l=c(),S.notify(u)},x=e=>{if(m){m=!1;return}let t=!1,n=a();if(typeof document<`u`&&n.length)for(let e of n){let n=e.enableBeforeUnload??!0;if(n===!0){t=!0;break}if(typeof n==`function`&&n()===!0){t=!0;break}}if(t)return e.preventDefault(),e.returnValue=``},S=w4({getLocation:h,getLength:()=>t.history.length,pushState:(e,t)=>v(!0,e,t),replaceState:(e,t)=>v(!1,e,t),back:e=>(e&&(p=!0),m=!0,t.history.back()),forward:e=>{e&&(p=!0),m=!0,t.history.forward()},go:e=>{d=!0,t.history.go(e)},createHref:e=>s(e),flush:_,destroy:()=>{t.history.pushState=n,t.history.replaceState=r,t.removeEventListener(C4,x,{capture:!0}),t.removeEventListener(S4,b)},onBlocked:()=>{u&&l!==u&&(l=u)},getBlockers:a,setBlockers:o,notifyOnIndexChange:!1});return t.addEventListener(C4,x,{capture:!0}),t.addEventListener(S4,b),t.history.pushState=function(...e){let r=n.apply(t.history,e);return S._ignoreSubscribers||y(`PUSH`),r},t.history.replaceState=function(...e){let n=r.apply(t.history,e);return S._ignoreSubscribers||y(`REPLACE`),n},S}function D4(e={initialEntries:[`/`]}){let t=e.initialEntries,n=e.initialIndex?Math.min(Math.max(e.initialIndex,0),t.length-1):t.length-1,r=t.map((e,t)=>T4(t,void 0)),i=()=>k4(t[n],r[n]),a=[];return w4({getLocation:i,getLength:()=>t.length,pushState:(e,i)=>{n<t.length-1&&(t.splice(n+1),r.splice(n+1)),r.push(i),t.push(e),n=Math.max(t.length-1,0)},replaceState:(e,i)=>{r[n]=i,t[n]=e},back:()=>{n=Math.max(n-1,0)},forward:()=>{n=Math.min(n+1,t.length-1)},go:e=>{n=Math.min(Math.max(n+e,0),t.length-1)},createHref:e=>e,getBlockers:()=>a,setBlockers:e=>a=e})}function O4(e){let t=e.replace(/[\x00-\x1f\x7f]/g,``);return t.startsWith(`//`)&&(t=`/`+t.replace(/^\/+/,``)),t}function k4(e,t){let n=O4(e),r=n.indexOf(`#`),i=n.indexOf(`?`),a=A4();return{href:n,pathname:n.substring(0,r>0?i>0?Math.min(r,i):r:i>0?i:n.length),hash:r>-1?n.substring(r):``,search:i>-1?n.slice(i,r===-1?void 0:r):``,state:t||{[x4]:0,key:a,__TSR_key:a}}}function A4(){return(Math.random()+1).toString(36).substring(7)}function j4(e){return e.options.loader||e.options.beforeLoad||e.lazyFn||e.options.component?.preload||e.options.pendingComponent?.preload}function M4(e,t){return{fromLocation:t,toLocation:e,pathChanged:t?.pathname!==e.pathname,hrefChanged:t?.href!==e.href,hashChanged:t?.hash!==e.hash}}function N4({key:e,__TSR_key:t,__TSR_index:n,__hashScrollIntoViewOptions:r,...i}){return i}function P4(e,t,n,r){for(let i of t){if(r?.()===!1)return;n.some(e=>e.routeId===i.routeId)||e.routesById[i.routeId].options.onLeave?.(i)}for(let i of n){if(r?.()===!1)return;e.routesById[i.routeId].options[t.some(e=>e.routeId===i.routeId)?`onStay`:`onEnter`]?.(i)}}var F4=class{constructor(e,t){this.tempLocationKey=`${Math.round(Math.random()*1e7)}`,this._scroll={next:!0},this.subscribers=new Set,this._cache=new Map,this._committed=[],this.routeBranchCache=new WeakMap,this.lightweightCache=new WeakMap,this.startTransition=async e=>(e(),!1),this.update=e=>{let t=this.options,n=this.basepath??t?.basepath??`/`,r=this.basepath===void 0,i=t?.rewrite;if(this.options={...t,...e},this.isServer=this.options.isServer??!1??typeof document>`u`,this.protocolAllowlist=new Set(this.options.protocolAllowlist),this.options.pathParamsAllowedCharacters&&(this.pathParamsDecoder=B2(this.options.pathParamsAllowedCharacters)),(!this.history||this.options.history&&this.options.history!==this.history)&&(this.history=this.options.history?this.options.history:E4()),this.origin=this.options.origin,this.origin||=window?.origin&&window.origin!==`null`?window.origin:`http://localhost`,this.history&&this.updateLatestLocation(),this.options.routeTree!==this.routeTree){this.routeTree=this.options.routeTree;let e;this.resolvePathCache=c2(1e3),e=this.buildRouteTree(),this.setRoutes(e)}if(!this.stores&&this.latestLocation){let e=this.getStoreConfig(this);this.batch=e.batch,this.stores=b4(this.latestLocation,e),i4(this)}let a=this.options.basepath??`/`,o=this.options.rewrite;if(r||n!==a||i!==o){this.basepath=a;let e=[],t=I2(a);t&&t!==`/`&&e.push(_4({basepath:a})),o&&e.push(o),this.rewrite=e.length===0?void 0:e.length===1?e[0]:g4(e),this.history&&this.updateLatestLocation(),this.stores&&this.stores.location.set(this.latestLocation)}},this.updateLatestLocation=()=>{this.latestLocation=this.parseLocation(this.history.location,this.latestLocation)},this.buildRouteTree=()=>{let e=S2(this.routeTree,this.options.caseSensitive,(e,t)=>{e.init({originalIndex:t})});return this.options.routeMasks&&_2(this.options.routeMasks,e.processedTree),e},this.subscribe=(e,t)=>{let n={eventType:e,fn:t};return this.subscribers.add(n),()=>{this.subscribers.delete(n)}},this.emit=e=>{for(let t of this.subscribers)if(t.eventType===e.type)try{t.fn(e)}catch(e){console.error(e)}},this.parseLocation=(e,t)=>{let n=({pathname:e,search:n,hash:r,href:i,state:a})=>{if(!this.rewrite&&!/[ \x00-\x1f\x7f\u0080-\uffff]/.test(e)){let i=this.options.parseSearch(n),o=this.options.stringifySearch(i);return{href:e+o+r,publicHref:e+o+r,pathname:i2(e).path,external:!1,searchStr:o,search:K0(t?.search,i),hash:i2(r.slice(1)).path,state:q0(t?.state,a)}}let o=new URL(i,this.origin),s=v4(this.rewrite,o),c=this.options.parseSearch(s.search),l=this.options.stringifySearch(c);return s.search=l,{href:s.href.replace(s.origin,``),publicHref:i,pathname:i2(s.pathname).path,external:!!this.rewrite&&s.origin!==this.origin,searchStr:l,search:K0(t?.search,c),hash:i2(s.hash.slice(1)).path,state:q0(t?.state,a)}},r=n(e),{__tempLocation:i,__tempKey:a}=r.state;if(i&&(!a||a===this.tempLocationKey)){let e=n(i);return e.state.key=r.state.key,e.state.__TSR_key=r.state.__TSR_key,delete e.state.__tempLocation,{...e,maskedLocation:r}}return r},this.resolvePathWithBase=(e,t)=>z2({base:e,to:t.includes(`//`)?N2(t):t,trailingSlash:this.options.trailingSlash,cache:this.resolvePathCache}),this.matchRoutes=(e,t,n)=>typeof e==`string`?this.matchRoutesInternal({pathname:e,search:t},n):this.matchRoutesInternal(e,t),this.getMatchedRoutes=e=>{let t=Object.create(null),n=b2(F2(e),this.processedTree,!0);return n&&Object.assign(t,n.rawParams),[n?.branch||[this.routesById.__root__],t,n?.route]},this.buildLocation=e=>{let t=(t={})=>{let n=t._fromLocation||this._pendingLocation||this.latestLocation,r=this.matchRoutesLightweight(n);t.from;let i=t.unsafeRelative===`path`?n.pathname:t.from??r[1],a=t.to?`${t.to}`:void 0,o=r[2],s=Object.assign(Object.create(null),r[3]),c=a?.charCodeAt(0)===47?`/`:this.resolvePathWithBase(i,`.`),l=a?this.resolvePathWithBase(c,a):c,u=V4(t.params,s),d=this.routesByPath[F2(l)],f;if(d)f=this.getRouteBranch(d);else if(l.includes(`$`))f=[];else{let[e,t,n]=this.getMatchedRoutes(l);f=e,this.options.notFoundRoute&&(!n||n.path!==`/`&&t[`**`])&&(f=[...f,this.options.notFoundRoute])}if(f.length&&W0(u))for(let e of f){let t=e.options.params?.stringify??e.options.stringifyParams;if(t)try{Object.assign(u,t(u))}catch{}}let p=e.leaveParams?l:i2(H2({path:l,params:u,decoder:this.pathParamsDecoder,server:this.isServer}).interpolatedPath).path,m=o;if(e._includeValidateSearch&&this.options.search?.strict){let e={};f.forEach(t=>{if(t.options.validateSearch)try{Object.assign(e,R4(t.options.validateSearch,{...e,...m}))}catch{}}),m=e}m=z4(m,t,f,e._includeValidateSearch),m=K0(o,m);let h=this.options.stringifySearch(m),g=t.hash===!0?n.hash:t.hash?V0(t.hash,n.hash):void 0,_=g?`#${g}`:``,v=t.state===!0?n.state:t.state?V0(t.state,n.state):{};v=q0(n.state,v);let y=`${p}${h}${_}`,b,x,S=!1;if(this.rewrite){let e=new URL(y,this.origin),t=y4(this.rewrite,e);b=e.href.replace(e.origin,``),t.origin===this.origin?x=t.pathname+t.search+t.hash:(x=t.href,S=!0)}else b=a2(y),x=b;return{publicHref:x,href:b,pathname:p,search:m,searchStr:h,state:v,hash:g??``,external:S,unmaskOnReload:t.unmaskOnReload}},n=(n={},r)=>{let i=t(n),a=r?t(r):void 0;if(!a){let n=Object.create(null);if(this.options.routeMasks){let o=v2(i.pathname,this.processedTree);if(o){Object.assign(n,o.rawParams);let{from:i,params:s,...c}=o.route,l=V4(s,n);r={from:e.from,...c,params:l},a=t(r)}}}return a&&(i.maskedLocation=a),i};return e.mask?n(e,{from:e.from,...e.mask}):n(e)},this.commitLocation=async({viewTransition:e,ignoreBlocker:t,...n})=>{let r,i=F2(this.latestLocation.href)===F2(n.href)&&Q0(N4(n.state),N4(this.latestLocation.state)),a=this._commitPromise,o,s=new Promise(e=>{o=e});if(s.resolve=()=>{o(),a?.resolve()},this._commitPromise=s,i)this.load();else{let{maskedLocation:i,hashScrollIntoView:a,...o}=n;i&&(o={...i,state:{...i.state,__tempKey:void 0,__tempLocation:{...o,search:o.searchStr,state:{...o.state,__tempKey:void 0,__tempLocation:void 0,__TSR_key:void 0,key:void 0}}}},(o.unmaskOnReload??this.options.unmaskOnReload??!1)&&(o.state.__tempKey=this.tempLocationKey)),o.state.__hashScrollIntoViewOptions=a??this.options.defaultHashScrollIntoView??!0,this.shouldViewTransition=e,r=n.replace?`REPLACE`:`PUSH`,this.history[r===`REPLACE`?`replace`:`push`](o.publicHref,o.state,{ignoreBlocker:t}),this.history.subscribers.size||this.load({action:{type:r}})}return this._scroll.next=n.resetScroll??!0,this._commitPromise},this.buildAndCommitLocation=({replace:e,resetScroll:t,hashScrollIntoView:n,viewTransition:r,ignoreBlocker:i,_redirects:a,href:o,...s}={})=>{if(o){let t=this.history.location.state.__TSR_index,n=k4(o,{__TSR_index:e?t:t+1}),r=new URL(n.pathname,this.origin);s.to=v4(this.rewrite,r).pathname,s.search=this.options.parseSearch(n.search),s.hash=n.hash.slice(1)}let c=this.buildLocation({...s,_includeValidateSearch:!0});a&&(c._redirects=a),this._pendingLocation=c;let l=this.commitLocation({...c,viewTransition:r,replace:e,resetScroll:t,hashScrollIntoView:n,ignoreBlocker:i});return queueMicrotask(()=>{this._pendingLocation===c&&(this._pendingLocation=void 0)}),l},this.navigate=async({to:e,reloadDocument:t,href:n,publicHref:r,...i})=>{let a=!1;if(n)try{new URL(`${n}`),a=!0}catch{}if(a&&!t&&(t=!0),t){if(e!==void 0||!n){let t=this.buildLocation({to:e,...i});n??=t.publicHref,r??=t.publicHref}let t=!a&&r?r:n;if(r2(t,this.protocolAllowlist))return;if(!i.ignoreBlocker){let e=this.history.getBlockers?.()??[];for(let t of e)if(t?.blockerFn&&await t.blockerFn({currentLocation:this.latestLocation,nextLocation:this.latestLocation,action:`PUSH`}))return}i.replace?window.location.replace(t):window.location.href=t;return}return this.buildAndCommitLocation({...i,href:n,to:e,_isNavigate:!0})},this.load=async e=>{this.updateLatestLocation(),e?.action&&(this._scroll.hash=e.action.type===`PUSH`||e.action.type===`REPLACE`),await N3(this,e)},this.startViewTransition=e=>{let t=this.shouldViewTransition??this.options.defaultViewTransition;if(this.shouldViewTransition=void 0,t&&typeof document.startViewTransition==`function`){let n;if(typeof t==`object`&&window.CSS?.supports?.(`selector(:active-view-transition-type(a))`)){let r=this.latestLocation,i=this.stores.resolvedLocation.get(),a=typeof t.types==`function`?t.types(M4(r,i)):t.types;if(a===!1)return e();n={update:e,types:a}}else n=e;return document.startViewTransition(n).updateCallbackDone}return e()},this.invalidate=e=>{let t=this._committed,n=e?.filter,r=this._preloads,i=new Set([...t,...this._cache.values(),...[...r?.values()??[]].flat(),...this._tx?.[3]??[]].filter(e=>!n||n(e)).map(e=>e.id)),a=[];for(let[e,t]of r??[])t.some(e=>i.has(e.id))&&(r.delete(e),a.push(e));let o=t=>{if(i.has(t.id)){let n=this.routesById[t.routeId],r={...t,invalid:!0,...(e?.forcePending||t.status===`error`||t.status===`notFound`)&&j4(n)?{status:`pending`,error:void 0}:void 0};return t._flight=void 0,r}return t};this._committed=t.map(o);for(let[t,n]of this._cache)i.has(t)&&(n.invalid=!0,e?.forcePending&&(n.status=`pending`));for(let e of i)this._flights?.delete(e);for(let e of a)e.abort();return this.shouldViewTransition=!1,this.load({sync:e?.sync})},this.resolveRedirect=e=>{let t=e.headers.get(`Location`);if(!e.options.href||e.options._builtLocation){let t=(e.options._builtLocation??this.buildLocation(e.options)).publicHref||`/`;e.options.href=t,e.headers.set(`Location`,t)}else if(t)try{let n=new URL(t);if(this.origin&&n.origin===this.origin){let t=n.pathname+n.search+n.hash;e.options.href=t,e.headers.set(`Location`,t)}}catch{}if(e.options.href&&!e.options._builtLocation&&r2(e.options.href,this.protocolAllowlist))throw Error(`Redirect blocked: unsafe protocol`);return e.headers.get(`Location`)||e.headers.set(`Location`,e.options.href),e},this.clearCache=e=>{let t=this._cache,n=this._preloads,r=e?.filter,i=[],a=[];for(let[e,n]of t)(!r||r(n))&&(a.push(e),i.push(n));let o=[];for(let[e,t]of n??[])(!r||t.some(r))&&(o.push(e),i.push(...t));for(let e of a)t.delete(e);for(let e of o)n.delete(e);for(let e of i){let t=e._flight;e._flight=void 0,t&&!--t[2]&&(this._flights?.get(e.id)===t&&this._flights.delete(e.id),o.push(t[1]))}for(let e of o)e.abort()},this.loadRouteChunk=G4,this.preloadRoute=e=>P3(this,e),this.matchRoute=(e,t)=>{let n={...e,to:e.to?this.resolvePathWithBase(e.from||``,e.to):void 0,params:e.params||{},leaveParams:!0},r=this.buildLocation(n),i=this.stores.status.get()===`pending`;if(t?.pending&&!i)return!1;let a=t?.pending??!i?this.latestLocation:this.stores.resolvedLocation.get()||this.stores.location.get(),o=y2(r.pathname,t?.caseSensitive??!1,t?.fuzzy??!1,a.pathname,this.processedTree);return!o||e.params&&!Q0(o.rawParams,e.params,{partial:!0})?!1:t?.includeSearch??!0?Q0(a.search,r.search,{partial:!0})?o.rawParams:!1:o.rawParams},this.getStoreConfig=t,this.update({defaultPreloadDelay:50,defaultPendingMs:1e3,defaultPendingMinMs:500,context:void 0,...e,caseSensitive:e.caseSensitive??!1,notFoundMode:e.notFoundMode??`fuzzy`,stringifySearch:e.stringifySearch??u4,parseSearch:e.parseSearch??l4,protocolAllowlist:e.protocolAllowlist??n2}),self.__TSR_ROUTER__=this}isShell(){return!!this.options.isShell}get state(){return this.stores.__store.get()}setRoutes({routesById:e,routesByPath:t,processedTree:n}){this.routesById=e,this.routesByPath=t,this.processedTree=n;let r=this.options.notFoundRoute;r&&(r.init({originalIndex:99999999999}),this.routesById[r.id]=r)}getRouteBranch(e){let t=this.routeBranchCache.get(e);return t||(t=T2(e),this.routeBranchCache.set(e,t)),t}matchRoutesInternal(e,t){let[n,r,i]=this.getMatchedRoutes(e.pathname),a=n,o=!1;(i?i.path!==`/`&&r[`**`]:F2(e.pathname))&&(this.options.notFoundRoute?a=[...a,this.options.notFoundRoute]:o=!0);let s=o?B4(this.options.notFoundMode,a):void 0,c=Array(a.length),l=this._committed,u=(e,t)=>{let n=l[t];return n?.routeId===e.id?n:e===this.options.notFoundRoute?l.find(t=>t.routeId===e.id):void 0},d;for(let n=0;n<a.length;n++){let i=a[n],o=c[n-1],l,f,p;{let n=o?.search??e.search,r=o?._strictSearch??void 0;try{let e=R4(i.options.validateSearch,{...n})??void 0;l={...n,...e},f={...r,...e}}catch(e){let r=e;if(e instanceof I4||(r=new I4(e.message,{cause:e})),t?.throwOnError)throw r;l=n,f={},p=r}}let m=``,h=``;try{m=i.options.loaderDeps?.({search:l})??``,h=m&&JSON.stringify(m)||``}catch(e){if(t?.throwOnError)throw e;p??=e}let{interpolatedPath:g,usedParams:_}=H2({path:i.fullPath,params:r,decoder:this.pathParamsDecoder,server:this.isServer}),v=i.id+g+h,y=u(i,n),b=this._cache.get(v)??(y?.id===v?y:void 0);d=b?._strictParams??Object.assign(_,d);let x;if(!b)try{H4(i,d)}catch(e){if(x=W2(e)||h4(e)?e:new L4(e.message,{cause:e}),t?.throwOnError)throw x}let S=y?`stay`:`enter`,C;if(b)C={...b,cause:S,search:K0(y?y.search:b.search,l),_strictSearch:f,searchError:p};else{let e=j4(i)?`pending`:`success`;C={id:v,ssr:i.options.ssr,index:n,routeId:i.id,params:y?.params??d,_strictParams:d,pathname:g,updatedAt:Date.now(),search:y?K0(y.search,l):l,_strictSearch:f,searchError:p,status:e,isFetching:!1,error:void 0,paramsError:x,context:{},abortController:t?._controller??new AbortController,cause:S,loaderDeps:y?q0(y.loaderDeps,m):m,invalid:!1,preload:!1,staticData:i.options.staticData||{},fullPath:i.fullPath}}let w=s===i.id;C._notFound&&!w&&(C.error=void 0),C._notFound=w,c[n]=C}for(let e=0;e<c.length;e++){let n=c[e];n.params=n.cause===`stay`?K0(n.params,d):d,t?._controller&&(n.context={})}return c}matchRoutesLightweight(e){let t=z0(this.stores.ids.get()),n=t?this.stores.byRoute.get(t).get():void 0,r=n?.id,i=this.lightweightCache.get(e);if(i&&i[0]===r)return i[1];let[a,o]=this.getMatchedRoutes(e.pathname),s=z0(a),c={...e.search};for(let e of a)try{Object.assign(c,R4(e.options.validateSearch,c))}catch{}let l=n&&n.routeId===s.id&&n.pathname===e.pathname,u;if(l)u=n.params;else{let e=Object.assign(Object.create(null),o);for(let t of a)try{H4(t,e)}catch{}u=e}let d=[a,s.fullPath,c,u];return this.lightweightCache.set(e,[r,d]),d}},I4=class extends Error{},L4=class extends Error{};function R4(e,t){if(e==null)return{};if(`~standard`in e){let n=e[`~standard`].validate(t);if(n instanceof Promise)throw new I4(`Async validation not supported`);if(n.issues)throw new I4(JSON.stringify(n.issues,void 0,2),{cause:n});return n.value}return`parse`in e?e.parse(t):typeof e==`function`?e(t):{}}function z4(e,t,n,r){let i=[];for(let e of n){let t=e.options;`search`in t?t.search?.middlewares&&i.push(...t.search.middlewares):(t.preSearchFilters||t.postSearchFilters)&&i.push(({search:e,next:n})=>{let r=n(t.preSearchFilters?t.preSearchFilters.reduce((e,t)=>t(e),e):e);return t.postSearchFilters?t.postSearchFilters.reduce((e,t)=>t(e),r):r});let n=t.validateSearch;n&&i.push(({search:e,next:t,meta:i})=>{let a=t(e);if(r)try{let e=R4(n,a);if(i&&e)for(let t in e)t in a||(i.defaulted||=new Map).set(t,e[t]);return{...a,...e}}catch{}return a})}let a=(e,n,r)=>{if(e>=i.length){if(!t.search)return{};if(t.search===!0)return n;let e=V0(t.search,n);return r&&(r.explicit=e),e}return i[e]({search:n,next:(t,n)=>{if(n){let n=r||{};return{search:a(e+1,t,n),meta:n}}return a(e+1,t,r)},meta:r})};return a(0,e)}function B4(e,t){if(e!==`root`){let e;for(let n=t.length-1;n>=0;n--){let r=t[n];if(r.options.notFoundComponent)return r.id;e||=r.children&&r.id}if(e)return e}return p4}function V4(e,t){return e===!1||e===null?Object.create(null):(e??!0)===!0?t:Object.assign(t,V0(e,t))}function H4(e,t){let n=e.options.params?.parse??e.options.parseParams;n&&Object.assign(t,n(t))}function U4(e,t){return e.options[t]?.preload?.()}function W4(e,t){let n=U4(e,`component`),r=U4(e,`pendingComponent`),i=t&&r?r.then(t):r;return t&&!r&&t(),n&&i?Promise.all([n,i]).then(()=>{}):n??i}function G4(e,t,n){let r=()=>t===!1?void 0:t?U4(e,t):W4(e,n),i=e._lazy;if(i)return i===!0?r():i.then(r);if(!e.lazyFn)return r();let a=e.lazyFn().then(t=>{{let{id:n,...r}=t.options;Object.assign(e.options,r),e._lazy=!0}},t=>{throw e._lazy=void 0,t});return e._lazy=a,a.then(r)}function K4(e){let t=e.findIndex(e=>e.status!==`success`||e._notFound)+1;return t&&t<e.length?e.slice(0,t):e}var q4=0,J4=1,Y4=2,X4=3,Z4=4;function Q4(e){return typeof e[0]==`number`}function $4(e,t){return t.aborted?Promise.race([Promise.reject(t),e]):new Promise((n,r)=>{let i=()=>r(t);t.addEventListener(`abort`,i,{once:!0}),Promise.resolve(e).then(n,r).finally(()=>t.removeEventListener(`abort`,i))})}function e3(e,t){return e.routesById[t.routeId]}function t3(e,t,n){return h4(e)?[X4,e]:W2(e)?(e.routeId||=n,[Y4,e]):(t&&typeof e?.then==`function`&&(e=Error(`A Promise was thrown`,{cause:e})),t?[J4,e]:[q4,e])}function n3(e,t){let n=t3(t,!0,e.id);if(n[0]!==J4)return n;try{e.options.onError?.(n[1])}catch(t){n=t3(t,!0,e.id)}return n}function r3(e,t,n){return n[0].signal.aborted||!n[2]()?(n[0].abort(),[Z4]):n3(e,t)}function i3(e,t){return n=>e.navigate({...n,_fromLocation:t})}async function a3(e,t,n,r,i,a){let[o,s]=t,c=n[0].signal,l=!!n[4];for(let t=n[7]??0;t<r;t++){let r=s[t],i=e3(e,r);r.abortController=n[0];let u=s[t-1]?.context??e.options.context??{},d={params:r.params,location:o,navigate:i3(e,o),buildLocation:e.buildLocation,cause:l?`preload`:r.cause,abortController:n[0],preload:l,matches:s,routeId:i.id},f=u;try{let e=r._ctx;!e&&i.options.context&&(e=r._ctx=i.options.context({...d,deps:r.loaderDeps,context:u})||{}),f={...u,...e},r.context=f}catch(a){return s3(e,r),[t,r3(i,a,n)]}if(c.aborted||!n[2]())return n[0].abort(),[t,[Z4]];let p=r.paramsError??r.searchError;if(p!==void 0)return s3(e,r),[t,r3(i,p,n)];let m=i.options.beforeLoad;if(!m)continue;let h={...d,search:r.search,context:f,...e.options.additionalContext},g=r.status;g===`success`&&t>=a&&(r.status=`pending`),n[8]?.();try{u3(e,r,`beforeLoad`,n[0]);let a=await $4(m(h),c);if(!n[2]())return n[0].abort(),[t,[Z4]];let o=t3(a,!1,i.id);if(o[0]!==q4)return s3(e,r),[t,o];r.context={...f,...a}}catch(a){return s3(e,r),[t,r3(i,a,n)]}finally{g===`success`&&r.status===`pending`&&(r.status=`success`),u3(e,r,!1,n[0])}}i()}function o3(e,t,n){if(!(!n||--n[2])){if(e._flights?.get(t.id)===n){let n=e._tx;if(n&&!n[0].signal.aborted&&!n[3].includes(t)&&n[3].some(e=>e.id===t.id)&&n[3].some(e=>e.isFetching===`beforeLoad`))return;e._flights.delete(t.id)}return n[1]}}function s3(e,t){let n=t._flight;t._flight=void 0,o3(e,t,n)?.abort()}function c3(e,t,n,r){let i=[];for(let a of t)if(!n?.includes(a)){let t=a._flight;if(a._flight=void 0,r&&t?.[2]===1&&e._flights?.get(a.id)===t&&n?.some(e=>e.id===a.id))t[2]=0;else{let n=o3(e,a,t);n&&i.push(n)}}for(let e of i)e.abort()}function l3(e){for(let t of e){let e=t._flight;e&&e[2]++}}function u3(e,t,n,r){if(t.isFetching=n,r&&e._tx?.[0]!==r)return;let i=e.stores.byRoute.get(t.routeId),a=i?.get();a?.id===t.id&&i.set({...a,isFetching:n})}function d3(e,t,n,r,i,a,o){let s=t[0];return{params:n.params,location:s,navigate:i3(e,s),cause:o?`preload`:n.cause,abortController:i,preload:o,deps:n.loaderDeps,parentMatchPromise:a,context:n.context,route:r,...e.options.additionalContext}}async function f3(e,t,n,r,i,a,o,s){let c=s.signal;if(c.aborted)return[Z4];if(!i)return[q4,void 0];let l=n._flight;u3(e,n,`loader`,s);try{if(!l){let s=new AbortController;l=[Promise.resolve().then(()=>i(d3(e,t,n,r,s,a,o))).then(e=>t3(e,!1,r.id),e=>t3(e,!0,r.id)).then(t=>(t[0]!==q4&&e._flights?.get(n.id)===l&&(e._flights.delete(n.id),l[2]||s.abort()),t[0]===J4&&l[2]?n3(r,t[1]):t)),s,1],(e._flights??=new Map).set(n.id,l)}return n._flight=l,n.abortController=l[1],await $4(l[0],c)}catch(t){if(t!==c)throw t;return s3(e,n),[Z4]}finally{u3(e,n,!1,s)}}function p3(e,t,n){t[0]===q4?(e.loaderData=t[1],e.error=void 0,e.status=`success`,e.invalid=!1,e.updatedAt=Date.now(),e.preload=n):t[0]!==X4&&(e.status=`success`,e.error=void 0,e.invalid=!0)}function m3(e,t,n){let r=e._cache.get(t.id);if(r!==n||e._committed.some(e=>e.id===t.id&&e._flight===t._flight))return;let i={...t,_notFound:void 0,context:{}};i._flight&&i._flight[2]++,e._cache.set(t.id,i),r&&s3(e,r)}function h3(e,t){return t[0]===J4||t[0]===Y4?{...e,status:t[0]===J4?`error`:`notFound`,error:t[1],_flight:void 0}:e}function g3(e,t,n,r,i,a,o){let s=t[1][n],c=e3(e,s),l=!!a[4],u=e._cache.get(s.id),d,f=!1,p;try{if(s.status===`success`&&(d=c.options.shouldReload,typeof d==`function`&&(d=d(d3(e,t,s,c,a[0],i,l))),a[2]()||(a[0].abort(),p=[Z4])),!p){if(s.status!==`success`)f=!0;else{let t=a[4]||s.preload?c.options.preloadStaleTime??e.options.defaultPreloadStaleTime??3e4:c.options.staleTime??e.options.defaultStaleTime??0;f=!!(s.invalid||d||d===void 0&&Date.now()-s.updatedAt>=t&&(a[6]||s.cause===`enter`||a[3].some(e=>e.routeId===s.routeId&&e.id!==s.id)))}}}catch(t){s.invalid=!0,s3(e,s),p=r3(c,t,a)}let m=c.options.loader,h=typeof m==`function`?m:m?.handler,g=(!l||c.options.preload!==!1)&&m?e._flights?.get(s.id):void 0;g===s._flight||p?g=void 0:g&&!f&&!l&&d===void 0?f=!0:f||(g=void 0);let _=!!(m&&f&&s.status===`success`&&!l&&!a[5]&&((typeof m==`function`?void 0:m?.staleReloadMode)??e.options.defaultStaleReloadMode)!==`blocking`),v=f&&(!l||c.options.preload!==!1),y=v&&!_&&(s.status!==`success`||!!m),b=c.lazyFn&&c._lazy!==!0?a[8]:void 0;if(v&&!m&&(s.invalid=!1,s.updatedAt=Date.now()),g&&g[2]++,y){let t=s._flight;s._flight=g,o3(e,s,t)?.abort(),s.status===`success`&&n>=o&&(s.status=`pending`),a[8]?.()}v||(s.isFetching=!1);let x=(p?Promise.resolve(p):y?f3(e,t,s,c,h,i,l,a[0]):Promise.resolve([q4,s.loaderData])).then(t=>(y&&(p3(s,t,l),t[0]===q4&&(m&&!a[0].signal.aborted&&m3(e,s,u),s.status=`pending`)),t)),S=$4(Promise.resolve().then(()=>G4(c,void 0,b)),a[0].signal).then(()=>void 0,e=>[n,r3(c,e,a)]).then(e=>x.then(t=>(y&&!e&&t[0]===q4&&s.status===`pending`&&a[2]()&&(s.status=`success`,a[8]?.()),e)));if(r.push([n,x,S]),!_)return x.then(e=>h3(s,e));let C={...s,status:`pending`,preload:!1,_flight:g};s.invalid=!1,s.isFetching=`loader`;let w=f3(e,t,C,c,h,i,!1,a[0]).then(e=>(s.isFetching=!1,p3(C,e,!1),e));return(t[2]??=[]).push([n,w,S,C]),w.then(e=>h3(C,e))}async function _3(e,t,n,r,i=0){let a=n?.[1][1],o=a?.routeId?t.findIndex(e=>e.routeId===a.routeId):n?.[0]??t.length-1;o<0&&(o=0);for(let n=o;n>=0;n--){let i=e3(e,t[n]),a=G4(i,!1);if(a)try{await $4(a,r)}catch(e){if(e===r)throw e}if(i.options.notFoundComponent)return n}return a?.routeId?o:i}function v3(e,t){t[2]&&=(c3(e,t[2].map(e=>e[3])),void 0)}async function y3(e,t,n,r){let i;try{await Promise.all(e.map(e=>e[1].then(async t=>{let a=e[0];if(!(r&&a>=await r)){if(t[0]>=X4)throw[a,t];!i&&t[0]!==q4&&(i=[a,t],await Promise.all((n??[]).map(e=>{if(!(e[0]<=a))return e[1].then(t=>{if(t[0]===X4)throw[e[0],t]})})))}})))}catch(e){return e}return t??i}async function b3(e,t,n,r,i,a,o){let s=t[1],c=await a,l=!1,u=s.findIndex(e=>e._notFound),d=t=>t[1][0]===Y4?_3(e,s,t,r.signal):t[0],f=u<0?s.length:u;if((c?.[1][0]??0)>=X4)f=0;else if(c){f=c[2]??=await d(c);for(let e of n){if(e[0]>=f)break;let t=await e[1];if(t[0]!==q4&&t[0]<X4&&!(`loaderData`in s[e[0]])){c=[e[0],t],f=c[2]=await d(c);break}}}for(let e of n){if(e[0]>=f)break;let t=await e[2];if(t){c=t;break}}if((c?.[1][0]??0)>=X4){let n=c[1];if(n[0]!==X4||n[1].options.reloadDocument||i<20)return v3(e,t),n;l=!0,c=[0,[J4,Error(`Too many redirects`)]]}let p=c?c[2]??await d(c):u;if(p>=0){let i=c?.[1],a=i?.[0],u=s[p],d=i?.[1],f=()=>{i&&(u._notFound=void 0,a===J4?u.status=`error`:(d.routeId=u.routeId,u.routeId===e.routeTree.id?(u.status=`success`,u._notFound=!0):u.status=`notFound`),u.error=d,u.isFetching=!1)};f();let m=e3(e,u);try{await $4(i?Promise.resolve().then(()=>G4(m,a===J4?`errorComponent`:`notFoundComponent`)):Promise.all([G4(m),G4(m,`notFoundComponent`)]),r.signal)}catch(n){if(n===r.signal)return v3(e,t),[Z4]}i?l&&(r.abort(),await Promise.all([...n.map(e=>e[1]),...n.map(e=>e[2]),...(t[2]??[]).map(e=>e[1])]),v3(e,t),c3(e,s),f()):(u.status=`success`,o?.())}return t}async function x3(e,t,n,r=0,i=t[1].length){let a=t[1];for(let t=r;t<i;t++){let r=a[t],i=e3(e,r).options;if(i.head||i.scripts)try{let t={ssr:e.options.ssr,matches:a,match:r,params:r.params,loaderData:r.loaderData},[o,s]=await $4(Promise.all([i.head?.(t),i.scripts?.(t)]),n);r.meta=o?.meta,r.links=o?.links,r.headScripts=o?.scripts,r.styles=o?.styles,r.scripts=s}catch(e){if(e===n)break;console.error(e)}if(r.status!==`success`||r._notFound)break}return t}async function S3(e,t,n,r){let i=[t,n],a=e.stores.matches.get(),o=n.findIndex(e=>e._notFound);if(e.options.notFoundMode!==`root`&&o>=0){let t=await _3(e,i[1],void 0,r[0].signal,o);t!==o&&(n[o]._notFound=void 0,n[t]._notFound=!0),o=t}let s=o<0?n.length:o+1,c=0;for(;c<s&&c!==o;){let e=n[c],t=r[3][c],i=a[c];if(t?.id!==e.id||t.status!==`success`||t._notFound||e.preload||i?.id!==e.id||i.status!==`success`||i._notFound)break;c++}let l=[],u=r[7]??0,d=u?Promise.resolve(i[1][u-1]):void 0,f=()=>{for(let t=u;t<s&&!r[0].signal.aborted;t++)d=g3(e,i,t,l,d,r,c)},p=await a3(e,i,r,s,f,c);if(p&&(r[5]=!0,s=p[0],p[1][0]===Y4?(p[2]=await _3(e,i[1],p,r[0].signal),s=Math.min(s,p[2]+1)):p[1][0]>=X4&&(s=0),f()),r[2]()&&!r[4]){let t=[];for(let[n,r]of e._flights??[])r[2]||(e._flights.delete(n),t.push(r[1]));for(let e of t)e.abort()}let m;try{let t=b3(e,i,l,r[0],r[1],y3(l,p,i[2]),r[8]);i[2]?.length&&(i[3]=y3(i[2],void 0,void 0,t.then(e=>Q4(e)?0:K4(e[1]).length,()=>0))),m=await t}catch(t){throw v3(e,i),t}return Q4(m)?m:x3(e,m,r[0].signal,r[7]===m[1].length?r[7]:0)}function C3(e,t){if(e._tx!==t)return;let n=e._pending,r=!1,i=n?.[0][3][n[1]]?.id;n?.[0]!==t&&(n&&t[3][n[1]]?.id===i?(n[0]=t,r=!0):(clearTimeout(n?.[3]),e._pending=n=void 0));let a=t[3],o=e.stores.matches.get(),s=-1,c,l,u,d=!1;for(let t=0;t<a.length;t++){let n=a[t],r=n.status===`success`;if(d=o[t]?.id===n.id&&o[t]?.status===`pending`,r&&!d)continue;let i=e3(e,n);if(c=r&&d||n.invalid?0:i.options.pendingMs??e.options.defaultPendingMs,u=i.options.pendingComponent??e.options.defaultPendingComponent,!u||typeof c!=`number`||c===1/0)return;s=t,l=i.options.pendingMinMs??e.options.defaultPendingMinMs??0;break}if(s<0)return;let f=a[s].id;if((!n||n[1]!==s||i!==f)&&(clearTimeout(n?.[3]),e._pending=n=[t,s,d?Date.now()+l:t[4]+c,void 0,d?Promise.resolve(!0):void 0,u]),n[4]&&!r&&n[5]===u)return;if(n[5]=u,!n[4]){clearTimeout(n[3]);let r=n[2]-Date.now();if(r>0){n[3]=setTimeout(()=>C3(e,t),r);return}n[2]=0}let p=a.map(e=>({...e,_flight:void 0}));p[s].status=`pending`;let m=e.startTransition(()=>e.stores.setMatches(p),p).then(t=>(t&&e._pending===n&&n[4]===m&&!n[2]&&(n[2]=Date.now()+l),t));n[4]=m}function w3(e,t){let n=e._pending;n?.[0]===t&&(clearTimeout(n[3]),e._pending=void 0)}function T3(e,t){e._committed=t,e.stores.setMatches(t)}function E3(e,t){c3(e,t[1]),v3(e,t)}function D3(e,t,n,r){let i=e._committed,a=e._cache;for(let e of n)e.preload=!1,r&&(e._assetEnd=void 0);let o=K4(n).length,s=new Map,c=Date.now();for(let t of[...i,...a.values()]){if(t.status!==`success`||n.some((e,n)=>e.id===t.id&&(n<o||e.status===`success`)))continue;let r=e3(e,t);!r.options.loader||c-t.updatedAt>=(t.preload?r.options.preloadGcTime??e.options.defaultPreloadGcTime??3e5:r.options.gcTime??e.options.defaultGcTime??3e5)||s.set(t.id,a.get(t.id)===t?t:{...t,_flight:void 0,isFetching:!1,context:{}})}t[3]=[],e._cache=s,T3(e,n),c3(e,[...a.values(),...i],[...n,...s.values()]),P4(e,i,n,()=>e._tx===t)}async function O3(e,t){let n=e._tx;for(;n&&n!==t;){if(await n[5],e._tx===n)return;n=e._tx}}async function k3(e,t,n){await e.navigate({...n.options,replace:!0,ignoreBlocker:!0,_redirects:t[1]+1})}function A3(e,t){w3(e,t),t[0].abort(),c3(e,t[3]),t[3]=[],e._tx===t&&(e.batch(()=>{e.stores.status.set(`idle`),e.stores.setMatches(e._committed)}),e._tx===t&&(e._commitPromise?.resolve(),e._commitPromise=void 0))}async function j3(e,t,n,r,i){let a=n.map(e=>({...e}));l3(a);for(let t of r)s3(e,a[t[0]]),a[t[0]]=t[3];let o=[t[2],a],s;try{s=await b3(e,o,r,t[0],t[1],i)}catch(t){throw c3(e,a),t}if(Q4(s)){c3(e,a),s[0]===X4&&e._tx===t&&e._committed===n&&await k3(e,t,s[1]);return}let c=await x3(e,s,t[0].signal);if(e._tx!==t||e._committed!==n){c3(e,c[1]);return}for(let t of c[1]){let n=e._cache.get(t.id);n?._flight&&n._flight===t._flight&&(e._cache.delete(t.id),s3(e,n))}T3(e,c[1]),c3(e,n,c[1])}async function M3(e,t,n,r,i,a){let o=[t[0],t[1],()=>e._tx===t&&!!t[3].length,e._committed,void 0,i,n,a,r],s=await S3(e,t[2],t[3],o);if(Q4(s)){s[0]===X4&&e._tx===t?(w3(e,t),c3(e,t[3]),t[3]=[],e._tx===t&&await k3(e,t,s[1])):A3(e,t);return}let c=e._pending;if(c?.[0]===t&&(clearTimeout(c[3]),c[4])){let n=t[0].signal,r=!1;try{r=await $4(c[4],n)}catch(e){if(e!==n)throw e}if(r&&e._pending===c&&c[0]===t){let e=c[2]-Date.now();if(e>0){try{await $4(new Promise(t=>{c[3]=setTimeout(t,e)}),n)}catch{}clearTimeout(c[3])}}}if(e._tx!==t){w3(e,t),E3(e,s);return}let l=t[2],u=M4(l,e.stores.resolvedLocation.get()),d=s[2];await e.startViewTransition(async()=>{if(e._tx!==t){E3(e,s);return}let n=await e.startTransition(()=>{w3(e,t),D3(e,t,s[1],a),e._tx===t&&(e.emit({type:`onLoad`,...u}),e._tx===t&&e.emit({type:`onBeforeRouteMount`,...u}))},s[1]);if(e._tx!==t){v3(e,s);return}d?.length&&j3(e,t,s[1],d,s[3]).catch(console.error),e.batch(()=>{e.stores.resolvedLocation.set(l),e.stores.status.set(`idle`),e._tx===t&&e.emit({type:`onResolved`,...u}),n&&e._tx===t&&e.emit({type:`onRendered`,...u})}),e._tx===t&&(e._commitPromise?.resolve(),e._commitPromise=void 0)})}async function N3(e,t){let n=e._tx,r=e.stores.resolvedLocation.get(),i=r??e.stores.location.get(),a=e.latestLocation,o=e._pendingLocation,s=o?.href===a.href?o._redirects??0:0,c=e._handoff,l=c?.[0](),u=new AbortController,d=e._preflight;if(e._preflight=u,l||c?.[1](),d?.abort(),u.signal.aborted){await O3(e,n);return}let f=M4(a,r);if(e.emit({type:`onBeforeNavigate`,...f}),u.signal.aborted||e.emit({type:`onBeforeLoad`,...f}),u.signal.aborted){await O3(e,n);return}let p=i.href===a.href,m,h=u;try{m=e.matchRoutes(a,{_controller:u}),l3(m)}catch(t){if(u.abort(),!h4(t)){await O3(e),e._commitPromise?.resolve(),e._commitPromise=void 0;return}await e.navigate({...t.options,replace:!0,ignoreBlocker:!0}),await O3(e,n);return}let g=l?c[1](m):void 0;if(g?h=l:l?.abort(),u.signal.aborted){c3(e,m),await O3(e,n);return}e._preflight=void 0;let _=[h,s,a,m,Date.now(),Promise.resolve().then(()=>M3(e,_,p,()=>C3(e,_),t?.sync,g)).catch(()=>{e._tx===_&&A3(e,_)})];if(e._tx=_,n){for(let t of e.stores.matches.get()){if(e._tx!==_)break;t.isFetching&&u3(e,t,!1)}n[0].abort(),c3(e,n[3],_[3],!0)}if(e._tx!==_){c3(e,_[3]),_[3]=[],await O3(e,_);return}e.batch(()=>{e.stores.status.set(`pending`),e.stores.location.set(a)}),!r&&!m.some(e=>e._notFound)&&C3(e,_);try{await _[5]}finally{await O3(e,_)}}async function P3(e,t,n=0){if(n>20)return;let r=t._builtLocation??e.buildLocation(t),i=e._committed,a=new AbortController,o;try{o=e.matchRoutes(r,{_controller:a}),l3(o)}catch(e){a.abort(),W2(e)||console.error(e);return}(e._preloads??=new Map).set(a,o);let s;try{let t;try{t=await S3(e,r,o,[a,n,()=>!0,i,!0])}finally{s=e._preloads.delete(a),c3(e,o),a.abort()}if(!Q4(t))return t[1];if(s&&t[0]===X4&&!t[1].options.reloadDocument)return P3(e,{...t[1].options,_fromLocation:r},n+1)}catch(e){W2(e)||console.error(e)}}var F3=`Error preloading route! ☝️`,I3=class{get to(){return this._to}get id(){return this._id}get path(){return this._path}get fullPath(){return this._fullPath}constructor(e){if(this.init=e=>{this.originalIndex=e.originalIndex;let t=this.options,n=!t?.path&&!t?.id;this.parentRoute=this.options.getParentRoute?.(),n?this._path=p4:this.parentRoute||s2();let r=n?p4:t?.path;r&&r!==`/`&&(r=P2(r));let i=t?.id||r,a=n?p4:M2([this.parentRoute.id===`__root__`?``:this.parentRoute.id,i]);r===`__root__`&&(r=`/`),a!==`__root__`&&(a=M2([`/`,a]));let o=a===`__root__`?`/`:M2([this.parentRoute.fullPath,r]);this._path=r,this._id=a,this._fullPath=o,this._to=F2(o)},this.addChildren=e=>this._addFileChildren(e),this._addFileChildren=e=>(Array.isArray(e)&&(this.children=e),typeof e==`object`&&e&&(this.children=Object.values(e)),this),this._addFileTypes=()=>this,this.updateLoader=e=>(Object.assign(this.options,e),this),this.update=e=>(Object.assign(this.options,e),this),this.lazy=e=>(this.lazyFn=e,this),this.redirect=e=>m4({from:this.fullPath,...e}),this.options=e||{},this.isRoot=!e?.getParentRoute,e?.id&&e?.path)throw Error(`Route cannot have both an 'id' and a 'path' option.`)}},L3=class extends I3{constructor(e){super(e)}};function R3(e){return(0,X.jsx)(z3,{...e})}var z3=class extends J.Component{constructor(...e){super(...e),this.state={error:null},this.reset=()=>{this.setState({error:null})}}static getDerivedStateFromProps(e,t){let n=e.getResetKey();return t.error&&t.resetKey!==n?{resetKey:n,error:null}:{resetKey:n}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){this.props.onCatch?.(e,t)}render(){let e=this.state.error;return e?J.createElement(this.props.errorComponent??B3,{error:e,reset:this.reset}):this.props.children}};function B3({error:e}){let[t,n]=J.useState(!1);return(0,X.jsxs)(`div`,{style:{padding:`.5rem`,maxWidth:`100%`},children:[(0,X.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`.5rem`},children:[(0,X.jsx)(`strong`,{style:{fontSize:`1rem`},children:`Something went wrong!`}),(0,X.jsx)(`button`,{style:{appearance:`none`,fontSize:`.6em`,border:`1px solid currentColor`,padding:`.1rem .2rem`,fontWeight:`bold`,borderRadius:`.25rem`},onClick:()=>n(e=>!e),children:t?`Hide Error`:`Show Error`})]}),(0,X.jsx)(`div`,{style:{height:`.25rem`}}),t?(0,X.jsx)(`div`,{children:(0,X.jsx)(`pre`,{style:{fontSize:`.7em`,border:`1px solid red`,borderRadius:`.25rem`,padding:`.3rem`,color:`red`,overflow:`auto`},children:e.message?(0,X.jsx)(`code`,{children:e.message}):null})}):null]})}function V3({children:e,fallback:t=null}){return(0,X.jsx)(J.Fragment,{children:H3()?e:t})}function H3(){return J.useSyncExternalStore(U3,()=>!0,()=>!1)}function U3(){return()=>{}}var W3=J.createContext(null);function G3(e){return J.useContext(W3)}var K3=J.createContext(void 0),q3=J.createContext(void 0),J3=(e=>(e[e.None=0]=`None`,e[e.Mutable=1]=`Mutable`,e[e.Watching=2]=`Watching`,e[e.RecursedCheck=4]=`RecursedCheck`,e[e.Recursed=8]=`Recursed`,e[e.Dirty=16]=`Dirty`,e[e.Pending=32]=`Pending`,e))(J3||{});function Y3({update:e,notify:t,unwatched:n}){return{link:r,unlink:i,propagate:a,checkDirty:o,shallowPropagate:s};function r(e,t,n){let r=t.depsTail;if(r!==void 0&&r.dep===e)return;let i=r===void 0?t.deps:r.nextDep;if(i!==void 0&&i.dep===e){i.version=n,t.depsTail=i;return}let a=e.subsTail;if(a!==void 0&&a.version===n&&a.sub===t)return;let o=t.depsTail=e.subsTail={version:n,dep:e,sub:t,prevDep:r,nextDep:i,prevSub:a,nextSub:void 0};i!==void 0&&(i.prevDep=o),r===void 0?t.deps=o:r.nextDep=o,a===void 0?e.subs=o:a.nextSub=o}function i(e,t=e.sub){let r=e.dep,i=e.prevDep,a=e.nextDep,o=e.nextSub,s=e.prevSub;return a===void 0?t.depsTail=i:a.prevDep=i,i===void 0?t.deps=a:i.nextDep=a,o===void 0?r.subsTail=s:o.prevSub=s,s===void 0?(r.subs=o)===void 0&&n(r):s.nextSub=o,a}function a(e){let n=e.nextSub,r;top:do{let i=e.sub,a=i.flags;if(a&60?a&12?a&4?!(a&48)&&c(e,i)?(i.flags=a|40,a&=1):a=0:i.flags=a&-9|32:a=0:i.flags=a|32,a&2&&t(i),a&1){let t=i.subs;if(t!==void 0){let i=(e=t).nextSub;i!==void 0&&(r={value:n,prev:r},n=i);continue}}if((e=n)!==void 0){n=e.nextSub;continue}for(;r!==void 0;)if(e=r.value,r=r.prev,e!==void 0){n=e.nextSub;continue top}break}while(!0)}function o(t,n){let r,i=0,a=!1;top:do{let o=t.dep,c=o.flags;if(n.flags&16)a=!0;else if((c&17)==17){if(e(o)){let e=o.subs;e.nextSub!==void 0&&s(e),a=!0}}else if((c&33)==33){(t.nextSub!==void 0||t.prevSub!==void 0)&&(r={value:t,prev:r}),t=o.deps,n=o,++i;continue}if(!a){let e=t.nextDep;if(e!==void 0){t=e;continue}}for(;i--;){let i=n.subs,o=i.nextSub!==void 0;if(o?(t=r.value,r=r.prev):t=i,a){if(e(n)){o&&s(i),n=t.sub;continue}a=!1}else n.flags&=-33;n=t.sub;let c=t.nextDep;if(c!==void 0){t=c;continue top}}return a}while(!0)}function s(e){do{let n=e.sub,r=n.flags;(r&48)==32&&(n.flags=r|16,(r&6)==2&&t(n))}while((e=e.nextSub)!==void 0)}function c(e,t){let n=t.depsTail;for(;n!==void 0;){if(n===e)return!0;n=n.prevDep}return!1}}function X3(e,t,n){let r=typeof e==`object`,i=r?e:void 0;return{next:(r?e.next:e)?.bind(i),error:(r?e.error:t)?.bind(i),complete:(r?e.complete:n)?.bind(i)}}var Z3=[],Q3=0,{link:$3,unlink:e6,propagate:t6,checkDirty:n6,shallowPropagate:r6}=Y3({update(e){return e._update()},notify(e){Z3[a6++]=e,e.flags&=~J3.Watching},unwatched(e){e.depsTail!==void 0&&(e.depsTail=void 0,e.flags=J3.Mutable|J3.Dirty,l6(e))}}),i6=0,a6=0,o6,s6=0;function c6(e){try{++s6,e()}finally{--s6||u6()}}function l6(e){let t=e.depsTail,n=t===void 0?e.deps:t.nextDep;for(;n!==void 0;)n=e6(n,e)}function u6(){if(!(s6>0)){for(;i6<a6;){let e=Z3[i6];Z3[i6++]=void 0,e.notify()}i6=0,a6=0}}function d6(e,t){let n=typeof e==`function`,r=e,i={_snapshot:n?void 0:e,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:n?J3.None:J3.Mutable,get(){return o6!==void 0&&$3(i,o6,Q3),i._snapshot},subscribe(e){let t=X3(e),n={current:!1},r=f6(()=>{i.get(),n.current?t.next?.(i._snapshot):n.current=!0});return{unsubscribe:()=>{r.stop()}}},_update(e){let a=o6,o=t?.compare??Object.is;if(n)o6=i,++Q3,i.depsTail=void 0;else if(e===void 0)return!1;n&&(i.flags=J3.Mutable|J3.RecursedCheck);try{let t=i._snapshot,a=typeof e==`function`?e(t):e===void 0&&n?r(t):e;return t===void 0||!o(t,a)?(i._snapshot=a,!0):!1}finally{o6=a,n&&(i.flags&=~J3.RecursedCheck),l6(i)}}};return n?(i.flags=J3.Mutable|J3.Dirty,i.get=function(){let e=i.flags;if(e&J3.Dirty||e&J3.Pending&&n6(i.deps,i)){if(i._update()){let e=i.subs;e!==void 0&&r6(e)}}else e&J3.Pending&&(i.flags=e&~J3.Pending);return o6!==void 0&&$3(i,o6,Q3),i._snapshot}):i.set=function(e){if(i._update(e)){let e=i.subs;e!==void 0&&(t6(e),r6(e),u6())}},i}function f6(e){let t=()=>{let t=o6;o6=n,++Q3,n.depsTail=void 0,n.flags=J3.Watching|J3.RecursedCheck;try{return e()}finally{o6=t,n.flags&=~J3.RecursedCheck,l6(n)}},n={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:J3.Watching|J3.RecursedCheck,notify(){let e=this.flags;e&J3.Dirty||e&J3.Pending&&n6(this.deps,this)?t():this.flags=J3.Watching},stop(){this.flags=J3.None,this.depsTail=void 0,l6(this)}};return t(),n}var p6=t((e=>{var t=mr();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,a=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue;function c(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),c=r[0].inst,u=r[1];return o(function(){c.value=n,c.getSnapshot=t,l(c)&&u({inst:c})},[e,n,t]),a(function(){return l(c)&&u({inst:c}),e(function(){l(c)&&u({inst:c})})},[e]),s(n),n}function l(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function u(e,t){return t()}var d=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?u:c;e.useSyncExternalStore=t.useSyncExternalStore===void 0?d:t.useSyncExternalStore})),m6=t(((e,t)=>{t.exports=p6()})),h6=t((e=>{var t=mr(),n=m6();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p}})),g6=t(((e,t)=>{t.exports=h6()}))();function _6(e,t){return e===t}function v6(e,t,n=_6){let r=(0,J.useCallback)(t=>{if(!e)return()=>{};let{unsubscribe:n}=e.subscribe(t);return n},[e]),i=(0,J.useCallback)(()=>e?.get(),[e]);return(0,g6.useSyncExternalStoreWithSelector)(r,i,i,t,n)}var y6={};function b6(e,t){let n=J.useRef();return r=>{let i=e?.select?e.select(r):r;return e?.structuralSharing??t.options.defaultStructuralSharing?n.current=q0(n.current,i):i}}function x6(e){let t=G3(),n=J.useContext(e.from?q3:K3),r=e.from??n,i=t.stores.getMatchStore(r),a=b6(e,t),o=v6(i,e=>e?a(e):y6);if(o!==y6)return o;(e.shouldThrow??!0)&&s2()}function S6(e){return x6({from:e.from,strict:e.strict,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.loaderData):t.loaderData})}function C6(e){let{select:t,...n}=e;return x6({...n,select:e=>t?t(e.loaderDeps):e.loaderDeps})}function w6(e){return x6({from:e.from,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,strict:e.strict,select:t=>{let n=e.strict===!1?t.params:t._strictParams;return e.select?e.select(n):n}})}function T6(e){return x6({from:e.from,strict:e.strict,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.search):t.search})}function E6(e){let t=G3();return J.useCallback(n=>t.navigate({...n,from:n.from??e?.from}),[e?.from,t])}function D6(e){return x6({...e,select:t=>e.select?e.select(t.context):t.context})}function O6(e){let t=J.useRef(e);return Q0(t.current,e,{ignoreUndefined:!1})||(t.current=e),t.current}function k6(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function A6(e,t,n){if(e?.external)return r2(e.href,n)?void 0:e.href;if(!V6(t)&&typeof t==`string`&&t.indexOf(`:`)!==-1)try{return new URL(t),r2(t,n)?void 0:t}catch{}}function j6(e,t,n,r,i,a){if(a)return!1;if(n?.exact){if(!R2(e.pathname,t.pathname,r))return!1}else{let n=L2(e.pathname,r),i=L2(t.pathname,r);if(!(n.startsWith(i)&&(n.length===i.length||n[i.length]===`/`)))return!1}return(n?.includeSearch??!0)&&!Q0(e.search,t.search,{partial:!n?.exact,ignoreUndefined:!n?.explicitUndefined})?!1:!n?.includeHash||i&&e.hash===t.hash}function M6(e,t){let n=G3(),r=R0(t),{activeProps:i,inactiveProps:a,activeOptions:o,to:s,preload:c,preloadDelay:l,preloadIntentProximity:u,hashScrollIntoView:d,replace:f,startTransition:p,resetScroll:m,viewTransition:h,children:g,target:_,disabled:v,style:y,className:b,onClick:x,onBlur:S,onFocus:C,onMouseEnter:w,onMouseLeave:T,onTouchStart:E,ignoreBlocker:D,params:O,search:k,hash:A,state:j,mask:M,reloadDocument:N,unsafeRelative:P,from:F,_fromLocation:I,...L}=e,ee=H3(),te=O6(e.search),ne=O6(e.params),re=O6(o),R=J.useMemo(()=>e,[n,e.from,e._fromLocation,e.hash,e.to,te,ne,e.state,e.mask,e.unsafeRelative]),ie=J.useCallback(e=>{let t=n.buildLocation({_fromLocation:e,...R}),r=B6(t.maskedLocation?t.maskedLocation.publicHref:t.publicHref,t.maskedLocation?t.maskedLocation.external:t.external,n.history,v),i=A6(r,s,n.protocolAllowlist);return[r?.href,i,j6(e,t,re,n.basepath,ee,i!==void 0)]},[re,v,ee,R,n,s]),[ae,z,oe]=v6(n.stores.location,ie,k6),se=oe?V0(i,{})??P6:N6,ce=oe?N6:V0(a,{})??N6,le=[b,se.className,ce.className].filter(Boolean).join(` `),ue=(y||se.style||ce.style)&&{...y,...se.style,...ce.style},de=J.useRef(!1),fe=e.reloadDocument||z||v?!1:c??n.options.defaultPreload,pe=l??n.options.defaultPreloadDelay??0,me=J.useCallback(()=>{n.preloadRoute(R).catch(e=>{console.warn(e),console.warn(F3)})},[n,R]),he=J.useCallback(e=>{if(!e){R6(r);return}if(!(e.isIntersecting??fe===`intent`)){e.isIntersecting===!1&&R6(r);return}if(!pe){me();return}L6.has(r)||L6.set(r,setTimeout(()=>{L6.delete(r),me()},pe))},[me,r,fe,pe]);L0(r,he,fe!==`viewport`),J.useEffect(()=>{de.current||fe===`render`&&(me(),de.current=!0)},[me,fe]);let ge=e=>{let t=e.currentTarget.getAttribute(`target`),r=_===void 0?t:_;!v&&!U6(e)&&!e.defaultPrevented&&(!r||r===`_self`)&&e.button===0&&(e.preventDefault(),n.navigate({...R,replace:f,resetScroll:m,hashScrollIntoView:d,startTransition:p,viewTransition:h,ignoreBlocker:D}))};if(z)return{...L,ref:r,href:z,...g&&{children:g},..._&&{target:_},...v&&{disabled:v},...y&&{style:y},...b&&{className:b},...x&&{onClick:x},...S&&{onBlur:S},...C&&{onFocus:C},...w&&{onMouseEnter:w},...T&&{onMouseLeave:T},...E&&{onTouchStart:E}};let _e=()=>{fe===`intent`&&me()},ve=()=>{fe===`intent`&&R6(r)};return{...L,...se,...ce,href:ae,ref:r,onClick:z6([x,ge]),onBlur:z6([S,ve]),onFocus:z6([C,he]),onMouseEnter:z6([w,he]),onMouseLeave:z6([T,ve]),onTouchStart:z6([E,_e]),disabled:!!v,target:_,...ue&&{style:ue},...le&&{className:le},...v&&F6,...oe&&I6}}var N6={},P6={className:`active`},F6={role:`link`,"aria-disabled":!0},I6={"data-status":`active`,"aria-current":`page`},L6=new WeakMap,R6=e=>{clearTimeout(L6.get(e)),L6.delete(e)},z6=e=>t=>{for(let n of e)if(n){if(t.defaultPrevented)return;n(t)}};function B6(e,t,n,r){if(!r)return t?{href:e,external:!0}:{href:n.createHref(e)||`/`,external:!1}}function V6(e){if(typeof e!=`string`)return!1;let t=e.charCodeAt(0);return t===47?e.charCodeAt(1)!==47:t===46}var H6=J.forwardRef((e,t)=>{let{_asChild:n,...r}=e,{type:i,...a}=M6(r,t),o=typeof r.children==`function`?r.children({isActive:a[`data-status`]===`active`}):r.children;if(!n){let{disabled:e,...t}=a;return J.createElement(`a`,t,o)}return J.createElement(n,a,o)});function U6(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}var W6=class extends I3{constructor(e){super(e),this.useMatch=e=>x6({select:e?.select,from:this.id,structuralSharing:e?.structuralSharing}),this.useRouteContext=e=>D6({...e,from:this.id}),this.useSearch=e=>T6({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useParams=e=>w6({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useLoaderDeps=e=>C6({...e,from:this.id}),this.useLoaderData=e=>S6({...e,from:this.id}),this.useNavigate=()=>E6({from:this.fullPath}),this.Link=J.forwardRef((e,t)=>(0,X.jsx)(H6,{ref:t,from:this.fullPath,...e}))}};function G6(e){return new W6(e)}var K6=class extends L3{constructor(e){super(e),this.useMatch=e=>x6({select:e?.select,from:this.id,structuralSharing:e?.structuralSharing}),this.useRouteContext=e=>D6({...e,from:this.id}),this.useSearch=e=>T6({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useParams=e=>w6({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useLoaderDeps=e=>C6({...e,from:this.id}),this.useLoaderData=e=>S6({...e,from:this.id}),this.useNavigate=()=>E6({from:this.fullPath}),this.Link=J.forwardRef((e,t)=>(0,X.jsx)(H6,{ref:t,from:this.fullPath,...e}))}};function q6(e){return new K6(e)}function J6(e){let t=G3(),n=`not-found-${v6(t.stores.location,e=>e.pathname)}-${v6(t.stores.status,e=>e)}`;return(0,X.jsx)(R3,{getResetKey:()=>n,onCatch:(t,n)=>{if(W2(t))e.onCatch?.(t,n);else throw t},errorComponent:({error:t})=>{if(W2(t))return e.fallback?.(t);throw t},children:e.children})}function Y6(){return(0,X.jsx)(`p`,{children:`Not Found`})}function X6(e){return(0,X.jsx)(X.Fragment,{children:e.children})}function Z6(e,t,n){return t.options.notFoundComponent?(0,X.jsx)(t.options.notFoundComponent,{...n}):e.options.defaultNotFoundComponent?(0,X.jsx)(e.options.defaultNotFoundComponent,{...n}):(0,X.jsx)(Y6,{})}function Q6(e,t){let n=t?.options.pendingComponent??e.options.defaultPendingComponent;return n?(0,X.jsx)(n,{}):null}var $6=(e,t)=>e[0]===t[0]&&e[1]===t[1],e8=(e,t,n)=>!t.isRoot||t.options.shellComponent||t.options.wrapInSuspense||n===!1||n===`data-only`||!e.ssr,t8=J.memo(function({routeId:e}){let t=G3();return(0,X.jsx)(n8,{router:t,match:v6(t.stores.getMatchStore(e),e=>e)})});function n8({router:e,match:t}){let n=e.routesById[t.routeId],r=Q6(e,n),i=n.options.errorComponent??e.options.defaultErrorComponent,a=n.options.onCatch??e.options.defaultOnCatch,o=n.isRoot?n.options.notFoundComponent??e.options.notFoundRoute?.options.component:n.options.notFoundComponent,s=t.ssr===!1||t.ssr===`data-only`,c=e8(e,n,t.ssr)&&(n.options.wrapInSuspense??r??(n.options.errorComponent?.preload||s))?J.Suspense:X6,l=i?R3:X6,u=o?J6:X6;return(0,X.jsxs)(n.isRoot?n.options.shellComponent??X6:X6,{children:[(0,X.jsx)(K3.Provider,{value:t.routeId,children:(0,X.jsx)(c,{fallback:r,children:(0,X.jsx)(l,{getResetKey:()=>t,errorComponent:i,onCatch:(e,n)=>{if(W2(e))throw e.routeId??=t.routeId,e;a?.(e,n)},children:(0,X.jsx)(u,{fallback:e=>{if(e.routeId??=t.routeId,e.routeId!==t.routeId)throw e;return J.createElement(o,e)},children:s?(0,X.jsx)(V3,{fallback:r,children:(0,X.jsx)(r8,{match:t})}):(0,X.jsx)(r8,{match:t})})})})}),null]})}var r8=J.memo(function({match:e}){let t=G3(),n=e.routeId,r=t.routesById[n],i=J.useMemo(()=>{let i=(r.options.remountDeps??t.options.defaultRemountDeps)?.({routeId:n,loaderDeps:e.loaderDeps,params:e._strictParams,search:e._strictSearch});return i?JSON.stringify(i):void 0},[n,e.loaderDeps,e._strictParams,e._strictSearch,r.options.remountDeps,t.options.defaultRemountDeps]),a=J.useMemo(()=>{let e=r.options.component??t.options.defaultComponent;return e?(0,X.jsx)(e,{},i):(0,X.jsx)(i8,{})},[i,r.options.component,t.options.defaultComponent]);if(e.status===`pending`){if(t.ssr&&!e8(t,r,e.ssr))return a;if(t._tx)throw t._tx[5];return Q6(t,r)}if(e.status===`notFound`)return Z6(t,r,e.error);if(e.status===`error`)throw e.error;return a}),i8=J.memo(function(){let e=G3(),t=J.useContext(K3),n,r,i;{let a=e.stores.getMatchStore(t);[n,r]=v6(a,e=>[!!e._notFound,e.error],$6),i=v6(e.stores.ids,e=>e[e.indexOf(t)+1])}if(n)return Z6(e,e.routesById[t],r);if(!i)return null;let a=(0,X.jsx)(t8,{routeId:i});return t===`__root__`?(0,X.jsx)(J.Suspense,{fallback:Q6(e),children:a}):a});function a8(e,t){let n=e[1];e.length=0,n?.(t)}function o8({t:e}){let t=G3(),n=t._rendered??=[];return t.startTransition=(r,i)=>new Promise((a,o)=>{a8(n,!1),n.push(i,a),e(t),J.startTransition(()=>{try{r()}catch(e){n[1]===a&&(n.length=0),o(e)}})}),I0(()=>{let e=t.history.subscribe(t.load);t.updateLatestLocation();let r=t.latestLocation,i=t.buildLocation({to:r.pathname,search:!0,params:!0,hash:!0,state:!0,_includeValidateSearch:!0});if(F2(r.publicHref)!==F2(i.publicHref))return t.commitLocation({...i,replace:!0,ignoreBlocker:!0}),e;let a=t.stores.resolvedLocation.get();return a?.href===r.href&&a.state.__TSR_key===r.state.__TSR_key?n.push(t.stores.matches.get(),e=>{e&&t.emit({type:`onRendered`,...M4(a,a)})}):t._tx||t.load().catch(console.error),e},[t,t.history]),null}function s8(){let e=G3(),t=e.routesById[p4],n=Q6(e,t),r=e.ssr?X6:J.Suspense,i=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(o8,{t:J.useState()[1]}),(0,X.jsx)(r,{fallback:n,children:(0,X.jsx)(c8,{})})]});return e.options.InnerWrap?(0,X.jsx)(e.options.InnerWrap,{children:i}):i}function c8(){let e=G3(),t=e._rendered,n=v6(e.stores.matches,e=>t[0]??e),r=n[0],i=r?.routeId;I0(()=>{t[0]===n&&a8(t,!0)},[t,n]);let a=i?(0,X.jsx)(t8,{routeId:i}):null;return(0,X.jsx)(K3.Provider,{value:i,children:e.options.disableGlobalCatchBoundary?a:(0,X.jsx)(R3,{getResetKey:()=>r,onCatch:void 0,children:a})})}var l8=e=>({createMutableStore:d6,createReadonlyStore:d6,batch:c6}),u8=e=>new d8(e),d8=class extends F4{constructor(e){super(e,l8)}};function f8({router:e,children:t,...n}){W0(n)&&e.update({...e.options,...n,context:{...e.options.context,...n.context}});let r=(0,X.jsx)(W3.Provider,{value:e,children:t});return e.options.Wrap?(0,X.jsx)(e.options.Wrap,{children:r}):r}function p8({router:e,...t}){return(0,X.jsx)(f8,{router:e,...t,children:(0,X.jsx)(s8,{})})}function m8(e){let t=G3({warn:e?.router===void 0}),n=e?.router||t;return v6(n.stores.__store,b6(e,n))}function h8(){return v6(G3().stores.location,e=>e.state.__TSR_index!==0)}var g8=(0,J.createContext)(null),_8=g8.Provider,v8=q6({validateSearch:B({agent:V().min(1).optional()}),component:()=>null}),y8=G6({getParentRoute:()=>v8,path:`/`}),b8=G6({getParentRoute:()=>v8,path:`/sessions/$agentId/$sessionId`,params:{parse:e=>B({agentId:V().min(1),sessionId:V().min(1)}).parse(e)}});function x8(){return u8({routeTree:v8.addChildren([y8,b8]),history:D4(),InnerWrap:({children:e})=>(0,X.jsxs)(X.Fragment,{children:[(0,J.useContext)(g8),e]}),defaultPendingMs:0,defaultPendingMinMs:0})}function S8(e,t){let n=m8({router:e,select:e=>e.location.search}),r=x6({from:b8.id,shouldThrow:!1});Hm(t,{canGoBack:h8(),onBack:()=>e.history.canGoBack()?(e.history.back(),!0):!1});let i=(0,J.useCallback)(t=>{e.navigate({to:`.`,search:{agent:t??void 0},replace:!0})},[e]),a=(0,J.useCallback)((t,n)=>{e.navigate({to:`/sessions/$agentId/$sessionId`,params:{agentId:t,sessionId:n},search:!0})},[e]);return{agentFilterId:n.agent??null,setFilter:i,selection:r?.params,open:a}}var C8=wn.check(Cn(1,{message:`Give your Agent a name.`}),H(256,{message:`Use at most 256 characters.`}));function w8({agentId:e,name:t,rename:n}){let[r,i]=(0,J.useState)(!1),a=t0({schema:(0,J.useMemo)(()=>U({name:C8.annotate(O1({label:`Agent name`,render:e=>(0,X.jsx)(eK,{id:e.id,name:e.name,"aria-label":`Agent name`,"aria-invalid":e[`aria-invalid`],"aria-describedby":e[`aria-describedby`],autoFocus:!0,maxLength:256,disabled:e.disabled,value:e.value,onBlur:e.onBlur,onChange:t=>{e.onChange(t.currentTarget.value)}})}))}),[]),defaultValues:{name:t},onSubmit:async({name:r})=>r===t||await n(e,r)?(i(!1),{kind:`saved`,values:{name:r}}):{kind:`refused`}}),{submitting:o,canSubmit:s}=n0(a);return r?(0,X.jsxs)(a0,{model:a,"aria-label":`Rename Agent`,footer:null,className:`flex min-w-0 items-center gap-1`,children:[(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,X.jsx)(C1,{model:a,names:[`name`]})}),(0,X.jsx)(BT,{type:`submit`,size:`sm`,loading:o,disabled:o||!s,children:`Save`}),(0,X.jsx)(LG,{"aria-label":`Cancel rename`,type:`button`,icon:(0,X.jsx)(hW,{size:14,"aria-hidden":`true`}),onClick:()=>{i(!1)}})]}):(0,X.jsx)(LG,{"aria-label":`Rename Agent`,icon:(0,X.jsx)(cW,{size:14,"aria-hidden":`true`}),onClick:()=>{i(!0)}})}function T8({status:e,approving:t,onApprove:n}){return e?.status===`pending`?(0,X.jsx)(BT,{variant:`outline`,size:`sm`,className:`flex-none`,loading:t,disabled:t,onClick:n,children:`Allow App tools`}):null}var E8=U({text:W}),D8=br(structuredClone(dt(E8,{onExcessProperty:`error`}).schema));function O8(e){return[{id:`new-conversation`,title:`New conversation`,category:`Conversation`,description:`Start a new conversation with this Agent`,projections:{slash:{aliases:[`new`],order:20},palette:{}},handler:()=>{e().newConversation()}},{id:`permissions`,title:`App permissions`,category:`Conversation`,description:`Review what Grove may access`,projections:{slash:{aliases:[`permissions`],order:21},palette:{}},handler:()=>{e().openPermissions()}},{id:`set-draft`,title:`Set draft`,category:`Conversation`,description:`Replace the open writable Grove conversation's draft without sending it`,projections:{agent:{}},action:{inputSchema:D8,presentation:{type:`action`}},handler:({arguments:t})=>{let{text:n}=Ht(E8,{onExcessProperty:`error`})(t);return{accepted:e().setDraft(n)}}}]}function k8(e,t){let n=(0,J.useRef)(e);n.current=e;let r=(0,J.useMemo)(()=>O8(()=>n.current),[]),i=(0,J.useMemo)(()=>Zr(),[]);return(0,J.useEffect)(()=>{let e=i.contribute({sourceId:`grove`,namespace:`grove`,commands:r});return()=>{e.dispose()}},[r,i]),(0,J.useEffect)(()=>t?Ki(t,r):void 0,[r,t]),i}function A8(e){let t=na(),n=e?.capabilities.has(mg)===!0||e?.capabilities.has(hg)===!0,r=ib(n?e:null),i=e&&!n?{...r,status:`live`}:r,a=eb.of(e,`agents`),o=jo({...rb(e,rg,a,e=>e.list()),enabled:e?.capabilities.has(rg)===!0}),s=new Set(o.data?.map(e=>e.agentId)),c=o.isSuccess?JSON.stringify([...new Set(i.items.filter(e=>!(`kind`in e)).map(e=>e.agentId))].filter(e=>!s.has(e)).sort()):`[]`,{refetch:l}=o;(0,J.useEffect)(()=>{c!==`[]`&&i.items.length>0&&l()},[c,i.items,l]);let u=eb.of(e,`agent-computers`);return{directory:o,inbox:i,computerChoices:jo({...rb(e,ig,u,()=>{if(!e)throw Error(`No App connection`);return _g(e.capabilities)}),enabled:e?.capabilities.has(ig)===!0}),createAgent:Po({mutationFn:t=>{if(!e)throw Error(`No App connection`);return gg(e.capabilities,t)},onMutate:()=>({directoryKey:a}),onSettled:(e,n,r)=>{r.computer===`new`&&t.invalidateQueries({queryKey:u})},onSuccess:(e,n,r)=>{t.setQueryData(r.directoryKey,(t=[])=>t.some(t=>t.agentId===e.agentId)?t:[...t,e])}}),renameAgent:Po({mutationFn:t=>{if(!e)throw Error(`No App connection`);return sg(e.capabilities,t)},onSuccess:e=>{t.setQueryData(a,(t=[])=>t.map(t=>t.agentId===e.agentId?e:t))}}),setAgentAvatar:Po({mutationFn:t=>{if(!e)throw Error(`No App connection`);return ug(e.capabilities,t)},onSuccess:e=>{t.setQueryData(a,(t=[])=>t.map(t=>t.agentId===e.agentId?e:t))}})}}function j8(e,t){let n=na(),r=e?.capabilities.has(pg)===!0,i=eb.of(e,`agent-tool-policy`,t??`none`);return{canRead:r,status:jo({...rb(e,pg,i,e=>t===null?Promise.resolve(null):e.status({agentId:t})),enabled:r&&t!==null}),approve:Po({mutationFn:t=>{if(!e)throw Error(`No App connection`);return e.capabilities.require(pg).approve({agentId:t.agentId,level:`write`,expectedRevision:t.expectedRevision})},onSuccess:e=>{`error`in e||n.setQueryData(i,e)}})}}function M8({agentId:e,name:t,avatar:n,setAvatar:r}){let[i,a]=(0,J.useState)(null),[o,s]=(0,J.useState)(!1),c=(0,X.jsx)(NX,{avatar:n,name:t,size:24});return r===void 0?(0,X.jsx)(`span`,{className:`flex-none`,children:c}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(BT,{variant:`ghost`,size:`sm`,"aria-label":`Change avatar`,className:`flex-none p-0`,onClick:()=>{a(n)},children:c}),(0,X.jsx)(IU,{open:i!==null,onOpenChange:e=>{!e&&!o&&a(null)},children:(0,X.jsxs)(VU,{className:`flex flex-col gap-lg`,keepMounted:!1,children:[(0,X.jsxs)(UU,{children:[(0,X.jsxs)(WU,{children:[t,`'s avatar`]}),(0,X.jsxs)(GU,{children:[`Every conversation with `,t,` shows this look.`]})]}),i===null?null:(0,X.jsx)(T0,{value:i,disabled:o,onChange:a}),(0,X.jsxs)(HU,{children:[(0,X.jsx)(BT,{type:`button`,variant:`ghost`,disabled:o,onClick:()=>{a(null)},children:`Cancel`}),(0,X.jsx)(BT,{type:`button`,variant:`primary`,loading:o,disabled:o||i===null,onClick:()=>{i!==null&&(s(!0),r(e,i).then(e=>{s(!1),e&&a(null)}))},children:`Save`})]})]})})]})}var N8=(0,J.forwardRef)(function({className:e,orientation:t,variant:n=`grip`,value:r,min:i,max:a,onValueChange:o,onKeyDown:s,...c},l){return(0,X.jsx)(`div`,{...c,ref:l,className:Q(`caps-resize-handle`,e),"data-resize-variant":n,role:`separator`,"aria-orientation":t,"aria-valuemin":Math.round(i),"aria-valuemax":Math.round(a),"aria-valuenow":Math.round(r),tabIndex:c.tabIndex??0,onKeyDown:e=>{if(s?.(e),e.defaultPrevented)return;if(e.key===`Home`||e.key===`End`){e.preventDefault(),o(e.key===`Home`?i:a);return}let n=t===`horizontal`?e.key===`ArrowUp`?-32:e.key===`ArrowDown`?32:null:e.key===`ArrowLeft`?-32:e.key===`ArrowRight`?32:null;n!==null&&(e.preventDefault(),o(Math.min(a,Math.max(i,r+n))))},children:(0,X.jsx)(`span`,{className:`caps-resize-grip`,"aria-hidden":`true`})})});$({frames:new Map,order:[],tiles:[],minima:new Map,participating:new Set,mainSize:void 0,zoomed:null,gesture:null,restore:new Map});function P8(e,t=!0,n){let r=(0,J.useRef)(e);r.current=e;let i=(0,J.useRef)(null);return(0,J.useEffect)(()=>(t||i.current?.release(!0),()=>i.current?.release(!0)),[t]),(0,J.useEffect)(()=>{let e=()=>{i.current?.release(!0)};return n?.addEventListener(`abort`,e),()=>{n?.removeEventListener(`abort`,e)}},[n]),{onPointerDown:e=>{if(!t||n?.aborted||i.current||e.pointerType===`mouse`&&e.button!==0)return;let{currentTarget:a,pointerId:o}=e;if(a.setPointerCapture(o),!r.current.begin(e)){a.releasePointerCapture(o);return}let s=r.current.end,c=()=>{l(!0)},l=e=>{a.removeEventListener(`lostpointercapture`,c),i.current=null,s(e),a.hasPointerCapture(o)&&a.releasePointerCapture(o)};i.current={id:o,element:a,x:e.clientX,y:e.clientY,release:l},a.addEventListener(`lostpointercapture`,c)},onPointerMove:e=>{let t=i.current;t?.id===e.pointerId&&(r.current.move(e.clientX-t.x,e.clientY-t.y,e),t.x=e.clientX,t.y=e.clientY)},onPointerUp:e=>{i.current?.id===e.pointerId&&i.current.release(!1)},onPointerCancel:e=>{i.current?.id===e.pointerId&&i.current.release(!0)}}}(0,J.createContext)(null);var F8=(0,J.createContext)(null);(0,J.forwardRef)(function({layer:e,style:t,children:n,...r},i){let a=(0,J.useContext)(F8),o=a?.update,s=a?.roots.get(`dialog`),[c,l]=(0,J.useState)(!1);(0,J.useEffect)(()=>{if(!s)return;let e=()=>{l(Array.from(s.querySelectorAll(`*`)).some(e=>{let t=e.getBoundingClientRect();return t.width>0&&t.height>0}))};e();let t=new MutationObserver(e);return t.observe(s,{childList:!0,subtree:!0,attributes:!0}),()=>{t.disconnect()}},[s]);let u=(0,J.useRef)(null);(0,J.useImperativeHandle)(i,()=>u.current);let d=(0,J.useCallback)(t=>{u.current=t,o?.(e,t)},[o,e]);return(0,J.createElement)(`div`,{...r,ref:d,onFocusCapture:t=>{e===`windows`&&t.target instanceof Node&&t.currentTarget.contains(t.target)&&a?.dismiss?.(),r.onFocusCapture?.(t)},"data-maosaico-layer":e,inert:e===`windows`&&c?``:void 0,style:{position:`relative`,...t,isolation:`isolate`,zIndex:`var(--stipe-layer-${e})`}},n)});var I8={min:224,max:480,initial:320},L8={agentRailOpen:!0,listRailOpen:!0,listWidth:I8.initial},R8=`fungi.grove.layout.v1`,z8=kn(tr(U({agentRailOpen:on,listRailOpen:on,listWidth:gn.pipe(q(tn()))})));function B8(e){return Math.round(Math.min(I8.max,Math.max(I8.min,e)))}function V8(e){try{let t=e?.getItem(R8);if(t==null)return L8;let n=z8(t);return je(n)?{...n.value,listWidth:B8(n.value.listWidth)}:L8}catch(e){return console.warn(`Grove could not read its saved rail layout`,e),L8}}function H8(e,t){try{e?.setItem(R8,JSON.stringify(t))}catch(e){console.warn(`Grove could not save its rail layout`,e)}}function U8(){try{return globalThis.localStorage}catch(e){console.warn(`Grove rail layout storage is unavailable`,e);return}}function W8(){let[e,t]=(0,J.useState)(()=>V8(U8()));return(0,J.useEffect)(()=>{H8(U8(),e)},[e]),[e,t]}var G8={2:`h2`,3:`h3`,4:`h4`};function K8(e,t){let{reduced:n}=t,r=e&&!n,i=hS(t,600),[a,o]=(0,J.useState)(r);return(0,J.useEffect)(()=>{if(o(r),!r)return;let e=globalThis.setTimeout(()=>{o(!1)},i);return()=>{globalThis.clearTimeout(e)}},[r,i]),a}var q8=(0,J.forwardRef)(function({actions:e,className:t,description:n,headingLevel:r=2,suggestions:i,thinking:a=!1,title:o,visual:s,renderVisual:c,variant:l=`plain`,...u},d){let f=(0,J.useId)(),p=(0,J.useRef)(null),m=mS(p),h=K8(l===`speech`,m)&&!a,g=G8[r],_=c?c({speaking:h,thinking:a}):s,v=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(g,{ref:p,className:`empty-state-title`,id:u[`aria-labelledby`]?void 0:f,children:o}),(0,X.jsx)(`p`,{children:n}),i&&i.length>0?(0,X.jsx)(`ul`,{"aria-label":`Try one of these`,className:`empty-state-suggestions`,children:i.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsx)(BT,{size:`sm`,variant:`outline`,onClick:e.onSelect,children:e.label})},e.label))}):null,e?(0,X.jsx)(`div`,{className:`empty-state-actions`,children:e}):null]});return(0,X.jsxs)(`section`,{...u,"aria-labelledby":u[`aria-labelledby`]??f,className:Q(`empty-state`,l!==`plain`&&`empty-state-${l}`,t),ref:d,children:[_?(0,X.jsx)(`div`,{"aria-hidden":`true`,className:`empty-state-visual`,children:_}):null,l===`speech`?(0,X.jsx)(`div`,{className:`empty-state-bubble`,children:v}):v]})});function J8({description:e,icon:t,label:n,density:r=`regular`,appearance:i=`plain`,iconSize:a=`default`,size:o,trailing:s,...c}){return(0,X.jsxs)(BT,{...c,className:Q(`caps-action-row`,i===`card`&&`caps-action-row-card`,r===`compact`?`h-auto min-h-10 w-full justify-start gap-xs px-xs py-2xs text-left`:`h-auto min-h-14 w-full justify-start gap-sm px-sm py-xs text-left`,c.className),size:o??(r===`compact`?`default`:`lg`),variant:c.variant??`ghost`,children:[t?(0,X.jsx)(`span`,{className:r===`compact`?`grid ${a===`lg`?`size-8`:`size-7`} shrink-0 place-items-center [&_:is(svg,.caps-monogram)]:size-5`:`grid ${a===`lg`?`size-12`:`size-10`} shrink-0 place-items-center [&_:is(svg,.caps-monogram)]:size-7`,children:t}):null,(0,X.jsxs)(`span`,{className:`caps-action-row-copy`,children:[(0,X.jsx)(`span`,{className:`caps-action-row-label max-w-full truncate`,children:n}),e?(0,X.jsx)(`span`,{className:`caps-action-row-description max-w-full truncate`,children:e}):null]}),s?(0,X.jsx)(`span`,{className:`caps-action-row-trailing`,children:s}):null]})}function Y8(e,t,n,r,i){let a=[];r&&a.push({kind:`hint`,key:`loading`,loading:!0});let o=0,s=[...e.active,...e.settled],c=new Map(s.map(e=>[JX(e.agentId,e.sessionId),e]));for(let e of[`Needs you`,`Working`,`Ready`,`Finished`]){let n=t.filter(t=>t.shelf===e).flatMap(e=>{let t=c.get(e.key);return t===void 0?[]:[t]});if(n.length!==0){a.push({kind:`heading`,key:e,title:e,gap:o++>0});for(let t of n)a.push({kind:`session`,key:JX(t.agentId,t.sessionId),shelf:e,session:t})}}if(e.unavailable.length>0){a.push({kind:`heading`,key:`Unavailable`,title:`Unavailable`,gap:o>0});for(let t of e.unavailable)a.push({kind:`unavailable`,key:JX(t.agentId,t.sessionId),session:t})}if(n.length>0){a.push({kind:`heading`,key:`Websites`,title:`Websites`,gap:a.length>0});for(let e of n)a.push({kind:`website`,key:`website:${e.bindingId}:${e.conversation.sessionId}`,website:e})}return a.length===0&&!i&&a.push({kind:`hint`,key:`empty`,loading:!1}),a}function X8({viewport:e,view:t,agents:n,loading:r,failed:i,pendingSelection:a,selectedAgentId:o,selectedSessionId:s,onSelect:c,onDelete:l,deleting:u,websites:d,selectedWebsite:f,onSelectWebsite:p}){let m=o!==null&&s!==null?JX(o,s):null,[h,g]=(0,J.useState)(!1),[_,v]=(0,J.useState)(!1),y=h||_,[b,x]=(0,J.useState)(0),[S,C]=(0,J.useState)({placements:null,openKey:m,reopened:b}),w=(0,J.useMemo)(()=>WX(S.placements,[...t.active,...t.settled],{openKey:S.openKey===m?m:null,held:y,reorder:S.openKey!==m||S.reopened!==b}),[S,t,m,y,b]);(0,J.useEffect)(()=>{!y&&(S.placements!==w||S.openKey!==m||S.reopened!==b)&&C({placements:w,openKey:m,reopened:b})},[y,S,w,m,b]),(0,J.useEffect)(()=>{let t=e.current;if(t===null)return;let n=t.clientWidth>0&&t.clientHeight>0,r=`ResizeObserver`in globalThis?new ResizeObserver(([e])=>{let t=e.contentRect.width>0&&e.contentRect.height>0;t&&!n&&x(e=>e+1),n=t}):void 0;r?.observe(t);let i=()=>{document.visibilityState===`visible`&&x(e=>e+1)};return document.addEventListener(`visibilitychange`,i),()=>{r?.disconnect(),document.removeEventListener(`visibilitychange`,i)}},[e]);let T=(0,J.useMemo)(()=>Y8(t,w,d,r,i),[t,w,d,r,i]),E=(0,J.useCallback)(e=>T[e]?.key??e,[T]),D=GW({count:T.length,getScrollElement:()=>e.current,getItemKey:E,estimateSize:e=>T[e]?.kind===`heading`?24:44,measureElement:(e,t,n)=>{let r=LW(e,t,n);return r>0?r:LW(e,void 0,n)||n.options.estimateSize(n.indexFromElement(e))},initialRect:{width:320,height:800},overscan:5,useFlushSync:!1});return(0,X.jsx)(`div`,{className:`inbox-list px-1 py-1`,onPointerEnter:()=>{g(!0)},onPointerLeave:()=>{g(!1)},onFocusCapture:()=>{v(!0)},onBlurCapture:e=>{e.currentTarget.contains(e.relatedTarget)||v(!1)},children:(0,X.jsx)(`div`,{style:{height:D.getTotalSize(),position:`relative`,width:`100%`},children:D.getVirtualItems().map(e=>{let t=T[e.index],r=t.kind===`session`||t.kind===`unavailable`?t.session:null,i=r?n.get(r.agentId):void 0;return(0,X.jsx)(`div`,{"data-index":e.index,ref:D.measureElement,"data-inbox-shelf":t.kind===`session`?t.shelf:t.kind===`unavailable`?`Unavailable`:void 0,className:t.kind===`heading`?`inbox-shelf`:void 0,style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${String(e.start)}px)`,paddingTop:t.kind===`heading`&&t.gap?4:0},children:t.kind===`heading`?(0,X.jsx)(Hx,{style:{paddingBottom:0},children:t.title}):t.kind===`hint`?(0,X.jsx)(`p`,{className:t.loading?`inbox-empty m-0 px-2 py-3 text-sm text-(--stipe-fg-muted)`:`m-0 px-2 py-3 text-xs text-(--stipe-fg-muted)`,role:t.loading?`status`:void 0,children:t.loading?`Loading conversations…`:`No conversations yet.`}):t.kind===`website`?(0,X.jsx)(J8,{appearance:`plain`,density:`compact`,className:`inbox-row${f?.bindingId===t.website.bindingId&&f.conversation.sessionId===t.website.conversation.sessionId?` is-selected bg-base-300`:``}`,"data-testid":`inbox-website-row`,label:t.website.conversation.label||`Website visitor`,description:(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,X.jsx)(Xq,{name:`internet`,size:14}),t.website.siteLabel]}),trailing:t.website.conversation.held?(0,X.jsx)(`span`,{className:`text-xs`,children:t.website.conversation.heldByYou?`You're replying`:`With a teammate`}):t.website.conversation.needsYou?(0,X.jsx)(FG,{size:`compact`,tone:`accent`,title:t.website.conversation.needsYou.reason}):null,onClick:()=>{p(t.website)},variant:`ghost`}):t.kind===`unavailable`?i?(0,X.jsx)(Q8,{agent:i,row:t.session}):null:i?(0,X.jsx)(Z8,{agent:i,session:t.session,attention:t.session.unseen,pending:a?.agentId===t.session.agentId&&a.sessionId===t.session.sessionId,selected:o===t.session.agentId&&s===t.session.sessionId,onDelete:l&&i.sessionOperations.includes(`agent.manage`)?()=>{l(t.session.agentId,t.session.sessionId)}:void 0,deleting:u?.agentId===t.session.agentId&&u.sessionId===t.session.sessionId,onSelect:()=>{c(t.session.agentId,t.session.sessionId)}}):null},e.key)})})})}function Z8({agent:e,session:t,attention:n,pending:r,selected:i,onSelect:a,onDelete:o,deleting:s}){let c=LX(t.state),l=t.state===`errored`,u=(0,X.jsxs)(`span`,{className:`inbox-row-activity inline-grid shrink-0 grid-cols-[1rem_7ch] items-center gap-1.5 text-[0.6875rem]`,children:[(0,X.jsxs)(`span`,{className:`inbox-row-status flex items-center justify-center`,children:[r||c||l?(0,X.jsx)(`span`,{className:`sr-only`,children:r?`Opening`:FX[t.state]}):null,r||c?(0,X.jsx)(FG,{size:`compact`,title:r?`Opening`:FX[t.state],motion:t.state===`running`||r?`pulse`:`none`,tone:r?`neutral`:t.state===`needs_you`?`accent`:`info`}):l?(0,X.jsx)(FG,{size:`compact`,title:FX.errored,tone:`error`}):n?(0,X.jsx)(FG,{size:`compact`,title:`Finished since your last visit`,tone:`neutral`}):null]}),(0,X.jsx)(`time`,{className:`inbox-row-age min-w-0 truncate text-right tabular-nums text-(--stipe-fg-muted)`,dateTime:new Date(t.lastActivityAt).toISOString(),children:$8(t.lastActivityAt)})]});return(0,X.jsxs)(`div`,{className:`relative group`,children:[(0,X.jsx)(J8,{"aria-current":i?`page`:void 0,"aria-label":`${t.title||`Untitled session`} — ${YX(e)}${n?` — Finished since your last visit`:``}${t.ready?` — Ready`:c||l?` — ${FX[t.state]}`:``}`,"aria-busy":r||void 0,appearance:`plain`,className:`inbox-row pr-9${i?` is-selected bg-base-300`:``}`,"data-attention":n?`true`:`false`,"data-pending":r?`true`:`false`,"data-session-id":t.sessionId,"data-status":t.state,"data-testid":`inbox-session-row`,density:`compact`,description:YX(e),label:t.title||`Untitled session`,onClick:a,trailing:u,variant:`ghost`}),o?(0,X.jsx)(LG,{"aria-label":`Delete conversation ${t.title||`Untitled session`}`,title:`Delete conversation`,icon:(0,X.jsx)(mW,{}),iconSize:`sm`,size:`sm`,className:`absolute right-1 top-1/2 -translate-y-1/2 opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 max-[899px]:opacity-100`,disabled:c||s,onClick:o}):null]})}function Q8({agent:e,row:t}){return(0,X.jsxs)(`div`,{className:`inbox-row is-unavailable flex min-h-11 w-full items-center gap-2 rounded-field border-(length:--border) border-transparent px-2 py-1 pr-9 text-left text-base-content`,"data-session-id":t.sessionId,"data-testid":`inbox-unavailable-row`,role:`group`,children:[(0,X.jsxs)(`span`,{className:`inbox-row-copy flex min-w-0 flex-1 flex-col`,children:[(0,X.jsx)(`strong`,{className:`truncate text-sm font-medium`,children:`Conversation unavailable`}),(0,X.jsxs)(`small`,{className:`truncate text-xs text-(--stipe-fg-muted)`,children:[YX(e),` `,(0,X.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),` This saved conversation could not be read.`]})]}),(0,X.jsx)(`span`,{className:`inbox-row-activity inline-grid shrink-0 grid-cols-[1rem_7ch] items-center gap-1.5 text-[0.6875rem]`,children:(0,X.jsx)(`span`,{className:`inbox-row-status flex items-center justify-center`,children:(0,X.jsx)(FG,{size:`compact`,tone:`error`,title:`This saved conversation could not be read`})})})]})}function $8(e){let t=Math.max(0,Date.now()-e);return t<6e4?`now`:t<36e5?`${String(Math.floor(t/6e4))}m`:t<864e5?`${String(Math.floor(t/36e5))}h`:new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}var e5=V().min(1).max(256),t5=Ue().int().nonnegative();ge(`state`,[me({state:tt(`agent`),version:t5}),me({state:tt(`requested`),version:t5,reason:V().max(4e3),at:Ue().int().nonnegative()}),me({state:tt(`person`),version:t5,memberId:e5,memberName:V().min(1).max(128),since:Ue().int().nonnegative()})]);var n5=me({bindingId:e5,agentId:e5,origins:Se(V().min(1).max(2048)).min(1).max(16),lifecycle:C([`active`,`suspended`])}),r5=me({sessionId:e5,label:V().max(4096),lastEventAt:Ue().int().nonnegative(),needsYou:me({at:Ue().int().nonnegative(),reason:V().max(4e3)}).nullable(),held:Je(),heldByYou:Je(),heldByName:V().min(1).max(128).nullable(),holdVersion:Ue().int().nonnegative()}),i5=me({bindingId:e5}).extend({sessionId:e5});i5.extend({requestId:V().min(1).max(128),text:V().trim().min(1).max(4e3)});var a5=me({expectedVersion:t5,confirm:Je()});i5.extend(a5.shape),i5.extend({expectedVersion:t5});var o5=me({websites:Se(n5).max(1e3)}),s5=me({conversations:Se(r5).max(100)});me({conversation:r5});var c5=me({status:tt(`sent`)}),l5=Gm(`channels.read`,1,Ie(()=>Km({list:Jm(qm(o5)),conversations:Jm(qm(s5))}))),u5=Gm(`channels.personal.manage`,1,Ie(()=>Km({hold:Jm(qm(r5)),release:Jm(qm(r5)),dismiss:Jm(qm(r5)),reply:Jm(qm(c5))})));function d5(e,t){let n=!1,r=async()=>{try{return await t.read()}catch(e){if(!(e instanceof cn)||e.boundary!==`runtime`||e.cause!==`unavailable`)throw e;if(await new Promise(e=>setTimeout(e,150)),n)throw Error(`Conversation opening cancelled`,{cause:e});return t.read()}},i,a=new Promise((e,t)=>{i=()=>{t(Error(`Conversation opening cancelled`))}});return{ready:Promise.race([r(),a]).then(r=>{if(n)throw Error(`Conversation opening cancelled`);iF(e,t,r)}),close:()=>{n=!0,i()}}}function f5(e){return class{#e;constructor(t){this.#e=new Rg(t,{fetch:(t,n)=>e(t,n)})}get readyState(){return this.#e.readyState}addEventListener(e,t,n){this.#e.addEventListener(e,t,n)}close(){this.#e.close()}}}function p5(e){let{connection:t,queryClient:n,services:r}=e,i=null,a=null,o=null,s=!1,c=(e,t)=>e?.agentId===t.agentId&&e.sessionId===t.sessionId,l=e=>!s&&i===e,u=(u,d,f=!1)=>{if(s)return;let p={agentId:u,sessionId:d};if(c(i,p)||(i?.close(),i=null,e.onPending(null),e.onError(null),c(a,p)))return;let m=null,h=!1,g={...p,close:()=>{h||(h=!0,m?.())}};i=g,e.onPending(p),(async()=>{try{let s=await r.openAgent(t.capabilities,{agentId:u});if(!l(g)){await s.close();return}let c=r.createClient({baseUrl:s.baseUrl,eventSource:f5(s.fetch),fetch:s.fetch}),f=c.session(d),p=d5(n,f);if(m=()=>{p.close(),Promise.allSettled([c.close(),s.close()])},await p.ready,e.reportsSelection!==!1&&await t.ui.reportAgentSessionSelection({agentId:u,sessionId:d}),!l(g))return;let h={agentId:u,sessionId:d,session:f},_=o;i=null,a=h,o=g.close,e.onConversation(h),e.onPending(null),_?.()}catch(t){console.error(`Chat Session opening failed`,t),g.close(),l(g)&&(i=null,e.onPending(null),e.onError(f?`That Session could not be opened. ${a?`The current conversation remains open.`:`Choose another Session from the list.`}`:`Could not open this Session${t instanceof Error?`: ${t.message}`:``}. ${a?`The previous conversation remains open.`:`Try opening it again.`}`))}})()},d=()=>{if(s)return;let n=i!==null||a!==null;i?.close(),i=null,o?.(),o=null,a=null,e.onPending(null),e.onConversation(null),e.onError(null),!(!n||e.reportsSelection===!1)&&t.ui.reportAgentSessionSelection(null).catch(e=>{console.error(`Chat Session selection could not be reported`,e)})};return{select:u,clear:d,close:()=>{d(),s=!0}}}function m5(e,t){async function n(e){if(e.type!==`prompt`||(e.images?.length??0)>0)throw new Y(`Website conversations support text replies only`,{code:`COMMAND_NOT_DECLARED`,retryable:!1});if(!t.canReply())throw new Y(`Use Take over to reply to this visitor`,{code:`CAPABILITY_DENIED`,retryable:!1});return await t.reply({bindingId:t.bindingId,sessionId:t.sessionId,requestId:e.requestId,text:e.text}),{status:`recorded`}}return{latestPending:()=>Promise.resolve(null),withdraw:t=>e.withdraw(t),address:e.address,read:t=>e.read(t),watch:t=>e.watch(t),extension:()=>({call:()=>Promise.reject(new Y(`Website Session controls are unavailable`,{code:`COMMAND_NOT_DECLARED`,retryable:!1}))}),command:n}}function h5(e,t){(0,J.useSyncExternalStore)(t=>e?.capabilities.subscribe(t)??(()=>void 0),()=>e?.capabilities.version??0);let n=na(),[r,i]=(0,J.useState)(null),[a,o]=(0,J.useState)(null),[s,c]=(0,J.useState)(null),l=e?.capabilities.has(l5)===!0,u=e?.capabilities.has(u5)===!0,d=jo({...rb(e,l5,eb.of(e,`websites`),e=>e.list()),enabled:l}),f=l?d.data?.websites??[]:[],p=ko({queries:f.map(t=>({...rb(e,l5,eb.of(e,`website-conversations`,t.bindingId),e=>e.conversations({bindingId:t.bindingId})),enabled:l}))}),m=f.flatMap((e,t)=>(p[t]?.data?.conversations??[]).map(t=>({bindingId:e.bindingId,agentId:e.agentId,siteLabel:e.origins.map(e=>new URL(e).host).join(`, `),conversation:t}))).sort((e,t)=>t.conversation.lastEventAt-e.conversation.lastEventAt),h=m.find(e=>e.bindingId===r?.bindingId&&e.conversation.sessionId===r.sessionId),g=(0,J.useMemo)(()=>e===null?null:p5({connection:e,queryClient:n,services:t,onPending:()=>void 0,onConversation:o,onError:c}),[e,n,t]);(0,J.useEffect)(()=>()=>{g?.close()},[g]),(0,J.useEffect)(()=>{l||g?.clear()},[l,g]);let _=Po({mutationFn:t=>{if(e===null)throw Error(`No App connection`);let n=e.capabilities.require(u5);return t.kind===`hold`?n.hold({bindingId:t.bindingId,sessionId:t.sessionId,expectedVersion:t.expectedVersion,confirm:t.confirm}):n.release({bindingId:t.bindingId,sessionId:t.sessionId,expectedVersion:t.expectedVersion,confirm:t.confirm})},onSuccess:(t,r)=>{n.setQueryData(eb.of(e,`website-conversations`,r.bindingId),e=>e===void 0?void 0:{conversations:e.conversations.map(e=>e.sessionId===t.sessionId?t:e)})}}),v=h?.bindingId,y=h?.conversation.sessionId,b=h?.conversation.heldByYou===!0,x=(0,J.useMemo)(()=>a===null||v===void 0||y===void 0||e===null?null:m5(a.session,{bindingId:v,sessionId:y,canReply:()=>b&&e.capabilities.has(u5),reply:t=>e.capabilities.require(u5).reply(t)}),[e,a,v,y,b]),S=(0,J.useCallback)(()=>{g?.clear(),i(null),o(null),_.reset()},[g,_.reset]);return{canRead:l,canManage:u,rows:m,selected:h,session:x,action:_,openingError:s,loading:l&&(d.isPending||p.some(e=>e.isPending)),failed:l&&(d.isError||p.some(e=>e.isError)),clear:S,select:e=>{l&&(h?.bindingId!==e.bindingId||h.conversation.sessionId!==e.conversation.sessionId||a===null)&&(i({bindingId:e.bindingId,sessionId:e.conversation.sessionId}),o(null),_.reset(),g?.select(e.agentId,e.conversation.sessionId))}}}function g5({inbox:e}){let{selected:t,session:n,action:r,canManage:i,openingError:a}=e,[o,s]=(0,J.useState)(null);if((0,J.useEffect)(()=>{s(null)},[t?.bindingId,t?.conversation.sessionId,i]),t===void 0)return null;let c=t.conversation;return(0,X.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,"aria-label":`Website conversation`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-base-300 p-2`,children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1 text-sm`,children:c.heldByYou?`You're replying. The Agent is paused.`:c.held?`${c.heldByName??`A teammate`} is replying.`:`The Agent is replying. Take over to answer as yourself.`}),i?(0,X.jsx)(BT,{size:`sm`,disabled:r.isPending,onClick:()=>{let e={bindingId:t.bindingId,sessionId:c.sessionId};c.heldByYou?r.mutate({kind:`release`,...e,expectedVersion:c.holdVersion,confirm:!1}):c.held?s({...e,version:c.holdVersion,name:c.heldByName??`A teammate`}):r.mutate({kind:`hold`,...e,expectedVersion:c.holdVersion,confirm:!1})},children:c.heldByYou?`Hand back to Agent`:`Take over`}):null]}),(0,X.jsx)(IU,{open:o!==null,onOpenChange:e=>{e||s(null)},children:(0,X.jsxs)(VU,{children:[(0,X.jsxs)(UU,{children:[(0,X.jsxs)(WU,{children:[o?.name,` is replying — take over?`]}),(0,X.jsx)(GU,{children:`You will reply as yourself. Their replies stop until they take over again.`})]}),(0,X.jsxs)(HU,{children:[(0,X.jsx)(KU,{render:(0,X.jsx)(BT,{variant:`outline`}),children:`Cancel`}),(0,X.jsx)(BT,{disabled:r.isPending||!i,onClick:()=>{o!==null&&(r.mutate({kind:`hold`,bindingId:o.bindingId,sessionId:o.sessionId,expectedVersion:o.version,confirm:!0}),s(null))},children:`Take over`})]})]})}),i?null:(0,X.jsx)(`p`,{className:`p-3 text-sm`,children:`Allow takeover in Grove's App permissions to reply. Your Team permissions still apply.`}),r.isError?(0,X.jsx)(`p`,{role:`alert`,className:`p-2 text-sm text-error`,children:`This conversation changed or website access was removed. Refresh and try again.`}):null,a?(0,X.jsx)(`p`,{role:`alert`,className:`p-2 text-sm text-error`,children:a}):null,n?(0,X.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,X.jsx)(_X,{authorOf:Pt,disambiguateAuthors:!0,session:n,markdownPolicy:`visitor`,composerActionVariant:`outline`},`${t.bindingId}:${c.sessionId}`)}):null]})}var _5=(0,J.lazy)(async()=>({default:(await sr(()=>import(`./parakeet-conversation-DYlN7oL9.js`),__vite__mapDeps([12,1,2,3,4,5,13]))).ParakeetConversation})),v5={openAgent:bg,createClient:hn},y5=[`agent.list`,`agent.manage`,`agent.read`,`agent.send`],b5=[`agent.read`,`agent.send`,`agent.manage`],x5=Ot({family:`grove-session-create-request`,version:1,kinds:{request:{prefix:`request`}}});async function S5(e,t,n,r){let i=await n.openAgent(e.capabilities,{agentId:t}),a=n.createClient({baseUrl:i.baseUrl,eventSource:f5(i.fetch),fetch:i.fetch});try{return await r(a)}finally{Promise.allSettled([a.close(),i.close()])}}function C5({open:e,renderConversation:t,connection:n,commands:r,composeDraft:i,onPrefilled:a,onForked:o,onOpen:s,label:c=`Conversation`}){let l=e.session;return(0,J.useEffect)(()=>{let e=BL(r,l,{sourceId:`grove-session`,namespace:`session`,sessionResumeAvailable:!1,forkAvailable:!0,onForked:o});return()=>{e.dispose()}},[r,l,o]),(0,X.jsx)(`section`,{className:`inbox-conversation min-h-0 min-w-0 flex-1`,"data-inbox-conversation":!0,"aria-label":c,children:t?t(e,i,s):(0,X.jsx)(J.Suspense,{fallback:(0,X.jsx)(`p`,{className:`p-3 text-sm text-(--stipe-fg-muted)`,role:`status`,children:`Opening conversation…`}),children:(0,X.jsx)(_5,{session:l,draftIdentity:{agentId:e.agentId,sessionId:e.sessionId},connection:n,commands:r,prefill:i,onPrefilled:a,onOpen:s})})})}function w5(e){return Bm(e.connection),(0,X.jsx)(T5,{...e},JSON.stringify(eb.of(e.connection)))}function T5(e){let t=(0,J.useMemo)(x8,[e.connection]);return(0,X.jsx)(_8,{value:(0,X.jsx)(E5,{...e,router:t}),children:(0,X.jsx)(p8,{router:t})})}function E5({router:e,connection:t,services:n=v5}){let{agentFilterId:r,setFilter:i,selection:a,open:o}=S8(e,t?.window.navigation),s=na(),c=h5(t,n),{directory:l,inbox:u,computerChoices:d,createAgent:f,renameAgent:p,setAgentAvatar:m}=A8(t),h=l.data??[],g=l.isPending&&(t?.capabilities.has(rg)??!0),_=l.error?.message??null,v=f.isPending,y=Po({mutationFn:e=>{if(!t)throw Error(`No App connection`);return S5(t,e.agentId,n,t=>t.createSession(e.requestId))}}),b=Po({mutationFn:e=>{if(!t)throw Error(`No App connection`);return S5(t,e.agentId,n,t=>t.deleteSession(e.sessionId))},onSuccess:(t,n)=>{a?.agentId===n.agentId&&a.sessionId===n.sessionId&&(_e?.clear(),e.navigate({to:`/`,search:!0,replace:!0})),u.refresh()}}),x=y.isPending?y.variables.agentId:null,[S,C]=(0,J.useState)(null),[w,T]=(0,J.useState)(null),[E,D]=(0,J.useState)(!1),O=w?.agentId??null,k=w?.sessionId??null,[A,j]=(0,J.useState)(null),M=(0,J.useRef)(null),[N,P]=W8(),{agentRailOpen:F,listRailOpen:I,listWidth:L}=N,ee=e=>{P(t=>({...t,agentRailOpen:e(t.agentRailOpen)}))},te=e=>{P(t=>({...t,listRailOpen:e(t.listRailOpen)}))},ne=e=>{P(t=>({...t,listWidth:B8(e(t.listWidth))}))},re=P8({begin:()=>!0,move:e=>{ne(t=>t+e)},end:()=>void 0}),[R,ie]=(0,J.useState)(!1),ae=nZ(),z=(0,J.useRef)(null),[oe,se]=(0,J.useState)(null),ce=f.error?.message??null,le=f.data,ue=(0,J.useRef)(null),[de,fe]=(0,J.useState)(null),[pe,me]=(0,J.useState)(null),he=Bm(t)?.openRequest??null,ge=(0,J.useRef)(null),_e=(0,J.useMemo)(()=>t===null?null:p5({connection:t,queryClient:s,services:n,onPending:C,onConversation:T,onError:fe}),[t,s,n]);(0,J.useEffect)(()=>{if(_e!==null)return()=>{ue.current=null,_e.close()}},[_e]);let[ve,ye]=(0,J.useState)(null),be=(0,J.useMemo)(()=>Zr(),[]),xe=(0,J.useMemo)(()=>t===null?null:p5({connection:t,queryClient:s,services:n,onPending:()=>void 0,onConversation:ye,onError:fe,reportsSelection:!1}),[t,s,n]);(0,J.useEffect)(()=>xe===null?void 0:()=>{xe.close()},[xe]);let Se=(0,J.useCallback)(e=>{let t=t=>e.params.find(e=>e.key===t)?.value,n=t(`agent`),r=t(`session`);n!==void 0&&r!==void 0&&xe?.select(n,r)},[xe]),Ce=(0,J.useRef)(null),we=(0,J.useCallback)((e,t,n=!1)=>{_e!==null&&(y.isError&&y.reset(),c.clear(),D(!1),Ce.current={agentId:e,sessionId:t},_e.select(e,t,n),o(e,t))},[_e,o,c.clear,y.isError,y.reset]),Te=a?.agentId,Ee=a?.sessionId;(0,J.useEffect)(()=>{let e=Ce.current;Ce.current=null,Te===void 0||Ee===void 0?_e?.clear():(e?.agentId!==Te||e.sessionId!==Ee)&&_e?.select(Te,Ee)},[_e,Te,Ee]);let De=(0,J.useCallback)(e=>{w&&(we(w.agentId,e),u.refresh())},[w,we,u.refresh]);(0,J.useEffect)(()=>{if(!t||he===null){he===null&&(ge.current=null);return}if(he.kind!==`navigate`||ge.current===he.requestId)return;let e=he.params.find(e=>e.key===`agent`)?.value,n=he.params.find(e=>e.key===`session`)?.value;!e||!n||(ge.current=he.requestId,i(e),we(e,n,!0))},[t,he,we,i]);let Oe=(0,J.useCallback)(async e=>{if(!t||v||!t.capabilities.has(ig))return!1;try{let t=await f.mutateAsync(e);return i(t.agentId),se(t.agentId),j(null),!0}catch{return!1}},[t,v,f.mutateAsync,i]),ke=(0,J.useCallback)(async e=>{if(!t||x!==null)return`Conversation creation is unavailable.`;fe(null);let n=ue.current?.agentId===e?ue.current:{agentId:e,requestId:x5.request.generate()};ue.current=n;try{let t=await y.mutateAsync(n);we(e,t),u.refresh(),j(null),ie(!1),ue.current===n&&(ue.current=null);return}catch(e){return console.error(`Grove conversation creation failed`,e),e instanceof Error?e.message:`Couldn't start the conversation.`}},[t,we,x,y.mutateAsync,u.refresh]);(0,J.useEffect)(()=>{if(!(!t||he?.kind!==`compose`)&&ge.current!==he.requestId&&!(!w&&g)&&(ge.current=he.requestId,me({requestId:he.requestId,text:he.text}),!w)){let e=t.capabilities.has(hg)?h.find(e=>e.sessionOperations.includes(`agent.read`)&&e.sessionOperations.includes(`agent.send`)&&e.sessionOperations.includes(`agent.manage`)):void 0;e?ke(e.agentId):j(`agent`)}},[h,t,g,w,he,ke]);let Ae=k8({setDraft:e=>S!==null||!w||!t?.capabilities.has(hg)||!h.some(e=>e.agentId===w.agentId&&e.sessionOperations.includes(`agent.send`))?!1:(me({requestId:ch(),text:e}),!0),newConversation:()=>{w&&ke(w.agentId)},openPermissions:()=>{t?.ui.requestAppPermissions({}).catch(e=>{console.error(`Chat inbox or permission request failed`,e)})}},t?.commands),je=new Set(c.rows.map(e=>`${e.agentId}:${e.conversation.sessionId}`)),Me=u.items.filter(e=>!(`kind`in e)).filter(e=>!je.has(`${e.agentId}:${e.sessionId}`)),Ne=ko({queries:(w?[w.session]:[]).map(e=>({...rF(e),enabled:!1}))}).at(0)?.data?.snapshot,Pe=(0,J.useMemo)(()=>w&&Ne?{agentId:w.agentId,sessionId:w.sessionId,state:mM(Ne)}:void 0,[w,Ne]),Fe=(0,J.useMemo)(()=>KX(h,E&&c.canRead?[]:Me,r,Pe),[r,h,Me,E,c.canRead,Pe]),Ie=(0,J.useMemo)(()=>{let e=new Map;for(let t of Me)`state`in t&&(t.state===`needs_you`?e.set(t.agentId,`speaking`):t.state===`running`&&!e.has(t.agentId)&&e.set(t.agentId,`thinking`));return e},[Me]),Le=(0,J.useMemo)(()=>new Map(h.map(e=>[e.agentId,e])),[h]),Re=(0,J.useRef)(null),B=Me.find(e=>e.agentId===O&&e.sessionId===k),ze=B!==void 0&&B.state!==`unavailable`,Be=B!==void 0&&B.state!==`unavailable`?B.settledAt:void 0;(0,J.useEffect)(()=>{!ze||O===null||k===null||u.visit(O,k).catch(e=>{console.error(`Chat inbox or permission request failed`,e)})},[ze,Be,O,k,u.visit]);let Ve=u.status===`loading`,He=u.status===`error`,Ue=t?.capabilities.has(ig)??!1,We=t?.capabilities.has(hg)??!1,Ge=h.filter(e=>e.sessionOperations.includes(`agent.read`)&&e.sessionOperations.includes(`agent.send`)&&e.sessionOperations.includes(`agent.manage`)),Ke=Ge.find(e=>e.agentId===(oe??r))??Ge.at(0),qe=We&&Ke!==void 0,Je=()=>{t?.ui.requestAppPermissions({agents:y5}).catch(e=>{console.error(`Chat inbox or permission request failed`,e)})},Ye=le&&(!le.sessionOperations.includes(`agent.read`)||!le.sessionOperations.includes(`agent.send`)||!le.sessionOperations.includes(`agent.manage`))?`Agent created. Allow Grove to read, send messages and manage its sessions to start a conversation.`:pe&&!w&&!qe&&f.isIdle?`Choose an Agent to compose your game idea.`:null,Xe=(0,J.useMemo)(()=>KX(h,Me,null,Pe),[h,Me,Pe]),Ze=(e,t)=>{ie(!1),we(e,t)},Qe=()=>{z.current=document.activeElement instanceof HTMLElement?document.activeElement:null,ie(!0)};Vm(t,[...ae?[{kind:`button`,id:`agents`,text:`Agents`,expanded:F,title:F?`Hide Agents`:`Show Agents`},{kind:`button`,id:`conversations`,text:`Conversations`,expanded:I,title:I?`Hide conversations`:`Show conversations`}]:[{kind:`button`,id:`agents`,text:`Agents and conversations`,opens:`dialog`,expanded:R}],...ve===null?[]:[{kind:`button`,id:`close-beside`,text:`Close beside`,title:`Close beside conversation`}]],e=>{if(A!==null)return!1;if(e.itemId===`close-beside`&&ve!==null)xe?.clear();else if(ae&&e.itemId===`agents`)ee(e=>!e);else if(ae&&e.itemId===`conversations`)te(e=>!e);else if(!ae&&e.itemId===`agents`)R?ie(!1):Qe();else return!1;return!0});let $e=e=>{i(e),se(e);let t=[...Xe.active,...Xe.settled].filter(t=>t.agentId===e).sort((e,t)=>t.lastActivityAt-e.lastActivityAt).at(0);t&&Ze(e,t.sessionId)},et={"--grove-list-width":`${String(L)}px`},tt=w?Le.get(w.agentId):void 0,V=r===null?void 0:Le.get(r),nt=t?.capabilities.has(og)??!1,rt=t?.capabilities.has(lg)??!1,it=j8(t,V?.agentId??null),at=Fe.active.length+Fe.settled.length,ot=(0,J.useCallback)(async(e,n)=>{if(!t)return!1;try{return await p.mutateAsync({agentId:e,name:n}),!0}catch{return!1}},[t,p.mutateAsync]),st=(0,J.useCallback)(async(e,n)=>{if(!t)return!1;try{return await m.mutateAsync({agentId:e,avatar:n}),!0}catch{return!1}},[t,m.mutateAsync]),ct=(0,J.useCallback)(()=>{let e=it.status.data;!V||e==null||it.approve.mutate({agentId:V.agentId,expectedRevision:e.revision})},[V,it.status.data,it.approve]),lt=(0,J.useCallback)(e=>{!t||v||x!==null||e===`agent`&&!Ue||(A===null&&(M.current=R?z.current:document.activeElement instanceof HTMLElement?document.activeElement:null),ie(!1),e===`session`&&se(tt?.agentId??r??Ge.at(0)?.agentId??null),j(e))},[t,v,x,Ue,A,R,tt?.agentId,r,Ge]);(0,J.useEffect)(()=>{let e=e=>{e.defaultPrevented||e.repeat||!e.ctrlKey||e.altKey||e.metaKey||e.key.toLowerCase()!==`n`||!t||e.shiftKey&&!Ue||(e.preventDefault(),lt(e.shiftKey?`agent`:`session`))};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[t,Ue,lt]);let ut=y.isError?y.variables:null,dt=ut&&A!==`session`?(0,X.jsx)(zx,{className:w||c.selected?`inbox-error m-2`:`inbox-empty m-auto max-w-[28rem]`,tone:`error`,title:`Couldn't start the conversation.`,description:y.error?.message,action:(0,X.jsx)(BT,{variant:`outline`,onClick:()=>void ke(ut.agentId),children:`Retry`})}):null;return(0,X.jsxs)(`main`,{className:`inbox-app grove-shell relative flex h-dvh min-h-0 bg-base-200 font-sans text-base-content`,"data-inbox-app":!0,"data-conversation":!!w||c.selected!==void 0,children:[t?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(P0,{open:A===`agent`,pending:v,error:ce,computers:d.isError?{status:`unavailable`,message:`Your Computers could not be loaded. New Computer and No Computer still work.`}:d.isPending?{status:`loading`}:d.data===null?{status:`not-offered`}:{status:`offered`,computers:d.data},create:Oe,onClose:()=>{j(null)},returnFocus:M}),A===`session`?(0,X.jsx)(F0,{open:!0,agents:We?Ge:[],defaultAgentId:Ke?.agentId??null,start:ke,pending:x!==null,onClose:()=>{j(null)},onNewAgent:Ue?()=>{j(`agent`)}:void 0,returnFocus:M}):null]}):null,(0,X.jsxs)(rZ,{open:R,onOpenChange:ie,returnFocus:z,children:[(0,X.jsx)(ZX,{open:F,agents:h,agentActivity:Ie,agentFilterId:r,websitesSelected:E,websitesVisible:c.canRead,canCreate:t!==null&&Ue,createOpen:A===`agent`,onAll:()=>{i(null),D(!1)},onWebsites:()=>{i(null),D(!0)},onAgent:e=>{D(!1),$e(e)},onCreate:()=>{lt(`agent`)}}),(0,X.jsxs)(`aside`,{id:`grove-list-rail`,className:`inbox-sidebar group relative min-h-0 min-w-0 flex-1 flex-col border-r border-base-300 min-[900px]:w-[var(--grove-list-width)] min-[900px]:flex-none ${I?`flex`:`flex min-[900px]:hidden`}`,style:et,"aria-label":`Conversations`,children:[ae?(0,X.jsx)(N8,{"aria-label":`Conversation list width`,"aria-controls":`grove-list-rail`,className:`absolute right-0 top-1/2 z-10 translate-x-1/2 -translate-y-1/2`,orientation:`vertical`,value:L,min:I8.min,max:I8.max,onValueChange:e=>{ne(()=>e)},onDoubleClick:()=>{ne(()=>I8.initial)},...re}):null,(0,X.jsxs)(`header`,{className:`inbox-header flex h-10 flex-none items-center gap-1 border-b border-base-300 pl-3 pr-1`,children:[V?(0,X.jsx)(M8,{agentId:V.agentId,name:YX(V),avatar:V.avatar,...rt?{setAvatar:st}:{}},V.agentId):null,(0,X.jsx)(Hx,{className:`min-w-0 flex-1 truncate`,children:E&&c.canRead?`Websites`:V?YX(V):`All Agents`}),V&&nt?(0,X.jsx)(w8,{agentId:V.agentId,name:V.name,rename:ot},V.agentId):null,t&&(qe||Ue)?(0,X.jsx)(LG,{"aria-label":`New conversation`,"aria-haspopup":`dialog`,icon:(0,X.jsx)(fW,{}),iconSize:`sm`,size:`sm`,onClick:()=>{lt(`session`)}}):null]}),V&&it.canRead?(0,X.jsx)(T8,{status:it.status.data,approving:it.approve.isPending,onApprove:ct}):null,Ye?(0,X.jsx)(zx,{tone:`info`,title:Ye,action:(0,X.jsx)(BT,{variant:`ghost`,onClick:()=>{t?.ui.requestAppPermissions({agents:b5}).catch(e=>{console.error(`Chat inbox or permission request failed`,e)})},children:`Allow conversation access`})}):null,t&&h.length>0&&!qe&&!Ue?(0,X.jsxs)(`section`,{className:`inbox-create inbox-access flex flex-col items-start gap-3 border-b border-base-300 py-2`,"aria-labelledby":`inbox-agent-access-title`,children:[(0,X.jsx)(Kx,{level:2,id:`inbox-agent-access-title`,className:`inbox-access-title m-0`,children:`Let Grove manage your Agents`}),(0,X.jsx)(`p`,{children:`Grove creates Agents and carries their conversations. Your Team decides what it may do.`}),(0,X.jsx)(BT,{size:`sm`,onClick:Je,children:`Allow Agent access`})]}):null,b.error?(0,X.jsx)(zx,{tone:`error`,title:b.error.message}):null,_?(0,X.jsx)(zx,{className:`inbox-error`,tone:`error`,title:_,action:(0,X.jsx)(BT,{variant:`ghost`,size:`sm`,onClick:()=>{l.refetch()},children:`Try again`})}):null,He?(0,X.jsx)(zx,{className:`inbox-error`,tone:`error`,title:`Conversations are unavailable.`,action:(0,X.jsx)(BT,{variant:`ghost`,size:`sm`,onClick:()=>{u.refresh()},children:`Retry conversations`})}):null,(0,X.jsx)(DA,{ref:Re,className:`inbox-surface min-h-0 flex-1`,"aria-label":`Conversations`,children:t?g?(0,X.jsx)(`p`,{className:`inbox-empty m-0 px-2 py-3 text-sm text-(--stipe-fg-muted)`,role:`status`,children:`Loading Agents…`}):(0,X.jsx)(X8,{viewport:Re,view:Fe,agents:Le,loading:Ve||c.loading,failed:!!_||He||c.failed,pendingSelection:S,selectedAgentId:O,selectedSessionId:k,onSelect:Ze,onDelete:We?(e,t)=>{b.mutate({agentId:e,sessionId:t})}:void 0,deleting:b.isPending?b.variables:null,websites:c.rows.filter(e=>r===null||e.agentId===r),selectedWebsite:c.selected,onSelectWebsite:e=>{_e?.clear(),ie(!1),c.select(e)}}):(0,X.jsx)(`p`,{className:`inbox-empty m-0 px-2 py-3 text-sm text-(--stipe-fg-muted)`,children:`Connect to the host to browse Agents.`})},r)]})]}),(0,X.jsxs)(`section`,{className:`inbox-conversation-shell flex min-h-0 min-w-0 flex-1 flex-col`,"aria-label":`Conversation`,children:[(0,X.jsx)(QX,{app:t}),de?(0,X.jsx)(zx,{className:`inbox-error m-2`,tone:`error`,title:de}):null,w||c.selected?dt:null,c.selected?(0,X.jsx)(g5,{inbox:c}):w?(0,X.jsx)(C5,{open:w,connection:t,commands:Ae,renderConversation:n.renderConversation,composeDraft:pe,onPrefilled:()=>{me(null)},onForked:De,onOpen:Se}):!t||g?null:h.length===0&&!_?(0,X.jsx)(q8,{className:`inbox-empty m-auto max-w-[28rem]`,variant:`speech`,thinking:v,renderVisual:({speaking:e,thinking:t})=>(0,X.jsx)(PX,{className:`h-full w-full`,state:{activity:t?`thinking`:e?`speaking`:`idle`,expression:`normal`}}),title:Ue?`No one's here yet.`:`Welcome to Grove`,description:Ue?`Agents chat, write and make little games with you. Name someone?`:`Let Grove find your Agents, create new ones, and open conversations. Your Team controls this access.`,actions:Ue?(0,X.jsx)(BT,{onClick:()=>{lt(`agent`)},children:`Name your first Agent`}):(0,X.jsx)(BT,{onClick:Je,children:`Allow Agent access`})}):dt??(0,X.jsx)(q8,{className:`inbox-empty m-auto max-w-[28rem]`,variant:`panel`,title:at>0?`Pick up a conversation`:Ke?`Say hello to ${YX(Ke)}`:`No conversations yet`,description:at>0?`Choose one from the list, or ask for something new. A tiny game is a good start.`:`Ask for anything. Try: “Make me a tiny game where a mushroom catches raindrops.”`,actions:(0,X.jsxs)(X.Fragment,{children:[ae||at===0?null:(0,X.jsx)(BT,{variant:`outline`,"aria-haspopup":`dialog`,"aria-controls":`grove-nav`,"aria-expanded":R,onClick:Qe,children:`Agents and conversations`}),qe?(0,X.jsx)(BT,{variant:`outline`,loading:x===Ke.agentId,disabled:x!==null,onClick:()=>void ke(Ke.agentId),children:at>0?`Ask ${YX(Ke)} something`:`Start a conversation`}):null]})})]}),ve===null?null:(0,X.jsx)(`section`,{className:`inbox-conversation-shell flex min-h-0 min-w-0 flex-1 flex-col border-l border-base-300`,"aria-label":`Beside conversation`,"data-inbox-beside":!0,children:(0,X.jsx)(C5,{open:ve,connection:t,commands:be,renderConversation:n.renderConversation,composeDraft:null,onPrefilled:()=>void 0,onForked:e=>{xe?.select(ve.agentId,e)},onOpen:Se,label:`Beside conversation`})})]})}var D5=document.getElementById(`inbox-root`);if(!D5)throw Error(`Inbox root is missing`);Lm(D5,{name:`Grove`,queryClient:nb()},({app:e})=>(0,J.createElement)(w5,{connection:e}));export{oC as $,BT as A,nw as B,QF as C,gj as D,qM as E,Vw as F,_C as G,BC as H,Fw as I,mC as J,pC as K,vw as L,iT as M,Uw as N,oj as O,Bw as P,lC as Q,hw as R,XF as S,ZF as T,WC as U,KC as V,hC as W,UC as X,gC as Y,VC as Z,rW as _,jo as _t,RK as a,Wx as at,QI as b,mr as bt,lG as c,Gx as ct,iG as d,eb as dt,MS as et,rG as f,qm as ft,$W as g,Gm as gt,eG as h,Ym as ht,YY as i,TS as it,vT as j,ej as k,sG as l,Kx as lt,QW as m,Jm as mt,l0 as n,nC as nt,LK as o,qx as ot,tG as p,Km as pt,fC as q,uX as r,jS as rt,eK as s,Jx as st,f0 as t,RS as tt,oG as u,Q as ut,eW as v,ea as vt,iI as w,oI as x,cL as y,yr as yt,cw as z};
|