@membank/dashboard 0.11.1 → 0.12.0
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/client/assets/{WorkspaceMemoryDetail-CKp3CCbn.js → WorkspaceMemoryDetail-CZ7FQyUg.js} +1 -1
- package/dist/client/assets/_projectId-C3d9SktO.js +4 -0
- package/dist/client/assets/_projectId._memoryId-CnwcpM7O.js +1 -0
- package/dist/client/assets/index-COiBvFfe.js +48 -0
- package/dist/client/assets/index-DPTdGNbr.css +2 -0
- package/dist/client/assets/{review-CnySMKKH.js → review-HQFzICof.js} +1 -1
- package/dist/client/assets/routes-DP4ozk8t.js +1 -0
- package/dist/client/assets/{spinner-B9RlP5lt.js → spinner-CruJX5tp.js} +1 -1
- package/dist/client/assets/{AppLink-CcI58QNL.js → typeColors-C02qYd30.js} +2 -2
- package/dist/client/index.html +2 -2
- package/package.json +2 -2
- package/dist/client/assets/_projectId-Eeq3OhFZ.js +0 -4
- package/dist/client/assets/_projectId._memoryId-BFlrz98g.js +0 -1
- package/dist/client/assets/index--CCYAGMc.js +0 -48
- package/dist/client/assets/index-BudjKWgr.css +0 -2
- package/dist/client/assets/routes-LNNp11yc.js +0 -1
package/dist/client/assets/{WorkspaceMemoryDetail-CKp3CCbn.js → WorkspaceMemoryDetail-CZ7FQyUg.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as e,B as t,Ct as n,D as r,H as i,I as a,J as o,L as s,M as c,N as l,O as u,Ot as d,Q as f,R as p,St as m,T as h,U as g,V as _,_ as v,_t as y,a as b,at as x,b as S,bt as C,d as w,dt as T,et as E,fn as D,g as O,hn as k,it as A,k as j,kt as M,n as N,pn as P,pt as F,r as I,s as L,t as ee,tt as R,ut as z,vt as te,w as ne,wt as re,xt as B,yt as ie,z as V}from"./collections-gO05Tpa7.js";import{d as ae,n as H,o as oe,r as se,s as ce}from"./preload-helper-DEuj8E0K.js";import{Bt as le,C as ue,Ct as U,D as de,Dt as fe,Et as pe,F as me,Ht as he,I as ge,L as _e,M as ve,Mt as ye,N as be,Nt as xe,Ot as W,P as G,Pt as K,R as Se,Rt as Ce,S as we,St as Te,T as Ee,Tt as De,Ut as Oe,Vt as ke,_ as Ae,a as je,b as Me,bt as Ne,c as Pe,d as Fe,g as Ie,gt as Le,h as Re,j as ze,kt as Be,l as Ve,m as He,o as Ue,p as We,q as Ge,r as Ke,s as qe,t as Je,u as Ye,w as Xe,wt as q,x as Ze,y as Qe,yt as $e,z as et}from"./popupStateMapping-CKjEg8lE.js";import{S as tt,a as nt,b as J,c as rt,d as it,f as at,i as ot,n as st,r as ct,u as lt,x as ut}from"./index--CCYAGMc.js";import{t as dt}from"./textarea-BLDQQzbc.js";var ft=class{constructor(e){this.atom=ut(e)}setState(e){this.atom.set(e)}get state(){return this.atom.get()}get(){return this.state}subscribe(e){return this.atom.subscribe(tt(e))}},pt=class{constructor(e){this.atom=ut(e)}get state(){return this.atom.get()}get(){return this.state}subscribe(e){return this.atom.subscribe(tt(e))}};function mt(e){return typeof e==`function`?new pt(e):new ft(e)}var Y=k(P(),1);function ht(e,t){if(e===void 0)return{shouldBlockFn:()=>!0,withResolver:!1};if(`shouldBlockFn`in e)return e;if(typeof e==`function`){let n=!!(t??!0);return{shouldBlockFn:async()=>n?await e():!1,enableBeforeUnload:n,withResolver:!1}}let n=!!(e.condition??!0),r=e.blockerFn;return{shouldBlockFn:async()=>n&&r!==void 0?await r():n,enableBeforeUnload:n,withResolver:r===void 0}}function gt(e,t){let{shouldBlockFn:n,enableBeforeUnload:r=!0,disabled:i=!1,withResolver:a=!1}=ht(e,t),o=M(),{history:s}=o,[c,l]=Y.useState({status:`idle`,current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0});return Y.useEffect(()=>i?void 0:s.block({blockerFn:async e=>{function t(e){let t=o.parseLocation(e),n=o.getMatchedRoutes(t.pathname);return n.foundRoute===void 0?{routeId:`__notFound__`,fullPath:t.pathname,pathname:t.pathname,params:n.routeParams,search:o.options.parseSearch(e.search)}:{routeId:n.foundRoute.id,fullPath:n.foundRoute.fullPath,pathname:t.pathname,params:n.routeParams,search:o.options.parseSearch(e.search)}}let r=t(e.currentLocation),i=t(e.nextLocation);if(r.routeId===`__notFound__`&&i.routeId!==`__notFound__`)return!1;let s=await n({action:e.action,current:r,next:i});if(!a)return s;if(!s)return!1;let c=await new Promise(t=>{l({status:`blocked`,current:r,next:i,action:e.action,proceed:()=>t(!1),reset:()=>t(!0)})});return l({status:`idle`,current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0}),c},enableBeforeUnload:r}),[n,r,i,a,s,o]),c}var _t=0;function vt(e,t={}){let{preventScroll:n=!1,cancelPrevious:r=!0,sync:i=!1}=t;r&&cancelAnimationFrame(_t);let a=()=>e?.focus({preventScroll:n});if(i)return a(),T;let o=requestAnimationFrame(a);return _t=o,()=>{_t===o&&(cancelAnimationFrame(o),_t=0)}}var yt={inert:new WeakMap,"aria-hidden":new WeakMap},bt=`data-base-ui-inert`,xt={inert:new WeakSet,"aria-hidden":new WeakSet},St=new WeakMap,Ct=0;function wt(e){return xt[e]}function Tt(e){return e?x(e)?e.host:Tt(e.parentNode):null}var Et=(e,t)=>t.map(t=>{if(e.contains(t))return t;let n=Tt(t);return e.contains(n)?n:null}).filter(e=>e!=null),Dt=e=>{let t=new Set;return e.forEach(e=>{let n=e;for(;n&&!t.has(n);)t.add(n),n=n.parentNode}),t},Ot=(e,t,n)=>{let r=[],i=e=>{!e||n.has(e)||Array.from(e.children).forEach(e=>{o(e)!==`script`&&(t.has(e)?i(e):r.push(e))})};return i(e),r};function kt(e,t,n,r,{mark:i=!0,markerIgnoreElements:a=[]}){let o=r?`inert`:n?`aria-hidden`:null,s=null,c=null,l=Et(t,e),u=i?Et(t,a):[],d=new Set(u),f=i?Ot(t,Dt(l),new Set(l)).filter(e=>!d.has(e)):[],p=[],m=[];if(o){let e=yt[o],n=wt(o);c=n,s=e;let r=Et(t,Array.from(t.querySelectorAll(`[aria-live]`))),i=l.concat(r);Ot(t,Dt(i),new Set(i)).forEach(t=>{let r=t.getAttribute(o),i=r!==null&&r!==`false`,a=(e.get(t)||0)+1;e.set(t,a),p.push(t),a===1&&i&&n.add(t),i||t.setAttribute(o,o===`inert`?``:`true`)})}return i&&f.forEach(e=>{let t=(St.get(e)||0)+1;St.set(e,t),m.push(e),t===1&&e.setAttribute(bt,``)}),Ct+=1,()=>{s&&p.forEach(e=>{let t=(s.get(e)||0)-1;s.set(e,t),t||(!c?.has(e)&&o&&e.removeAttribute(o),c?.delete(e))}),i&&m.forEach(e=>{let t=(St.get(e)||0)-1;St.set(e,t),t||e.removeAttribute(bt)}),--Ct,Ct||(yt.inert=new WeakMap,yt[`aria-hidden`]=new WeakMap,xt.inert=new WeakSet,xt[`aria-hidden`]=new WeakSet,St=new WeakMap)}}function At(e,t={}){let{ariaHidden:n=!1,inert:r=!1,mark:i=!0,markerIgnoreElements:a=[]}=t,o=U(e[0]).body;return kt(e,o,n,r,{mark:i,markerIgnoreElements:a})}var X=D();function jt(e,n){let r=f(t(e));return e instanceof r.KeyboardEvent?`keyboard`:e instanceof r.FocusEvent?n||`keyboard`:`pointerType`in e?e.pointerType||`keyboard`:`touches`in e?`touch`:e instanceof r.MouseEvent?n||(e.detail===0?`keyboard`:`mouse`):``}var Mt=20,Nt=[];function Pt(){Nt=Nt.filter(e=>e.deref()?.isConnected)}function Ft(e){Pt(),e&&o(e)!==`body`&&(Nt.push(new WeakRef(e)),Nt.length>Mt&&(Nt=Nt.slice(-Mt)))}function It(){return Pt(),Nt[Nt.length-1]?.deref()}function Lt(e){return e?Se(e)?e:et(e)[0]||e:null}function Rt(e,t){if(e.hasAttribute(`tabindex`)&&!e.hasAttribute(`data-tabindex`)||!t.current.includes(`floating`)&&!e.getAttribute(`role`)?.includes(`dialog`))return;let n=G(e).filter(e=>{let t=e.getAttribute(`data-tabindex`)||``;return Se(e)||e.hasAttribute(`data-tabindex`)&&!t.startsWith(`-`)}),r=e.getAttribute(`tabindex`);t.current.includes(`floating`)||n.length===0?r!==`0`&&e.setAttribute(`tabindex`,`0`):(r!==`-1`||e.hasAttribute(`data-tabindex`)&&e.getAttribute(`data-tabindex`)!==`-1`)&&(e.setAttribute(`tabindex`,`-1`),e.setAttribute(`data-tabindex`,`-1`))}function zt(e){let{context:n,children:r,disabled:a=!1,initialFocus:o=!0,returnFocus:s=!0,restoreFocus:c=!1,modal:l=!0,closeOnFocusOut:u=!0,openInteractionType:d=``,nextFocusableElement:f,previousFocusableElement:h,beforeContentFocusGuardRef:v,externalTree:b,getInsideElements:x}=e,S=`rootStore`in n?n.rootStore:n,C=S.useState(`open`),w=S.useState(`domReferenceElement`),T=S.useState(`floatingElement`),{events:E,dataRef:D}=S.context,O=_(()=>D.current.floatingContext?.nodeId),k=o===!1,A=$e(w)&&k,j=Y.useRef([`content`]),M=pe(o),N=pe(s),P=pe(d),F=Xe(b),I=de(),L=Y.useRef(!1),ee=Y.useRef(!1),z=Y.useRef(!1),te=Y.useRef(null),ne=Y.useRef(``),re=Y.useRef(``),B=Y.useRef(null),ae=Y.useRef(null),H=i(B,v,I?.beforeInsideRef),oe=i(ae,I?.afterInsideRef),se=ie(),ce=ie(),ue=De(),xe=I!=null,G=Le(T),K=_((e=G)=>e?et(e):[]),Ce=_(()=>x?.().filter(e=>e!=null)??[]);Y.useEffect(()=>{if(a||!l)return;function e(e){e.key===`Tab`&&V(G,p(U(G)))&&K().length===0&&!A&&he(e)}return g(U(G),`keydown`,e)},[a,w,G,l,j,A,K]),Y.useEffect(()=>{if(a||!C)return;let e=U(G);function n(){z.current=!1}function r(e){let n=t(e),r=Ce();z.current=!(V(T,n)||V(w,n)||V(I?.portalNode,n)||r.some(e=>e===n||V(e,n))),re.current=e.pointerType||`keyboard`,n?.closest(`[data-base-ui-click-trigger]`)&&(ee.current=!0)}function i(){re.current=`keyboard`}return fe(g(e,`pointerdown`,r,!0),g(e,`pointerup`,n,!0),g(e,`pointercancel`,n,!0),g(e,`keydown`,i,!0))},[a,T,w,G,C,I,Ce]),Y.useEffect(()=>{if(a||!u)return;let e=U(G);function n(){ee.current=!0,ce.start(0,()=>{ee.current=!1})}function r(e){let n=t(e);Se(n)&&(te.current=n)}function i(n){let r=n.relatedTarget,i=n.currentTarget,a=t(n);queueMicrotask(()=>{let t=O(),o=S.context.triggerElements,s=Ce(),u=r?.hasAttribute(ze(`focus-guard`))&&[B.current,ae.current,I?.beforeInsideRef.current,I?.afterInsideRef.current,I?.beforeOutsideRef.current,I?.afterOutsideRef.current,we(h),we(f)].includes(r),d=!(V(w,r)||V(T,r)||V(r,T)||V(I?.portalNode,r)||s.some(e=>e===r||V(e,r))||r!=null&&o.hasElement(r)||o.hasMatchingElement(e=>V(e,r))||u||F&&(be(F.nodesRef.current,t).find(e=>V(e.context?.elements.floating,r)||V(e.context?.elements.domReference,r))||ve(F.nodesRef.current,t).find(e=>[e.context?.elements.floating,Le(e.context?.elements.floating)].includes(r)||e.context?.elements.domReference===r)));if(i===w&&G&&Rt(G,j),c&&i!==w&&!Ge(a)&&p(e)===e.body){if(R(G)&&(G.focus(),c===`popup`)){ue.request(()=>{G.focus()});return}let e=K(),t=te.current,n=(t&&e.includes(t)?t:null)||e[e.length-1]||G;R(n)&&n.focus()}if(D.current.insideReactTree){D.current.insideReactTree=!1;return}(A||!l)&&r&&d&&!ee.current&&(A||r!==It())&&(L.current=!0,S.setOpen(!1,W(ye,n)))})}function o(){z.current||(D.current.insideReactTree=!0,se.start(0,()=>{D.current.insideReactTree=!1}))}let s=R(w)?w:null;if(!(!T&&!s))return fe(s&&g(s,`focusout`,i),s&&g(s,`pointerdown`,n),T&&g(T,`focusin`,r),T&&g(T,`focusout`,i),T&&I&&g(T,`focusout`,o,!0))},[a,w,T,G,l,F,I,S,u,c,K,A,O,j,D,se,ce,ue,f,h,Ce]),Y.useEffect(()=>{if(a||!T||!C)return;let e=Array.from(I?.portalNode?.querySelectorAll(`[${ze(`portal`)}]`)||[]),t=(F?ve(F.nodesRef.current,O()):[]).find(e=>$e(e.context?.elements.domReference||null))?.context?.elements.domReference,n=At([T,...e,B.current,ae.current,I?.beforeOutsideRef.current,I?.afterOutsideRef.current,...Ce(),t,we(h),we(f),A?w:null].filter(e=>e!=null),{ariaHidden:l||A,mark:!1}),r=At([T,...e].filter(e=>e!=null));return()=>{r(),n()}},[C,a,w,T,l,j,I,A,F,O,f,h,Ce]),m(()=>{if(!C||a||!R(G))return;let e=p(U(G));queueMicrotask(()=>{let t=M.current,n=typeof t==`function`?t(P.current||``):t;if(n===void 0||n===!1||V(G,e))return;let r=null,i=()=>(r??=K(G),r[0]||G),a;a=n===!0||n===null?i():we(n),a||=i(),vt(a,{preventScroll:a===G})})},[a,C,G,k,K,M,P]),m(()=>{if(a||!G)return;let e=U(G);Ft(p(e));function t(e){if(e.open||(ne.current=jt(e.nativeEvent,re.current)),e.reason===`trigger-hover`&&e.nativeEvent.type===`mouseleave`&&(L.current=!0),e.reason===`outside-press`)if(e.nested)L.current=!1;else if(le(e.nativeEvent)||ke(e.nativeEvent))L.current=!1;else{let e=!1;U(G).createElement(`div`).focus({get preventScroll(){return e=!0,!1}}),e?L.current=!1:L.current=!0}}E.on(`openchange`,t);function n(){let e=N.current,t=typeof e==`function`?e(ne.current):e;if(t===void 0||t===!1)return null;if(t===null&&(t=!0),typeof t==`boolean`){let e=w||It();return e&&e.isConnected?e:null}let n=w||It();return we(t)||n||null}return()=>{E.off(`openchange`,t);let r=p(e),i=Ce(),a=V(T,r)||i.some(e=>e===r||V(e,r))||F&&be(F.nodesRef.current,O(),!1).some(e=>V(e.context?.elements.floating,r)),o=N.current,s=n();queueMicrotask(()=>{let t=Lt(s),n=typeof o!=`boolean`;o&&!L.current&&R(t)&&(!(!n&&t!==r&&r!==e.body)||a)&&t.focus({preventScroll:!0}),L.current=!1})}},[a,T,G,N,D,E,F,w,O,Ce]),m(()=>{if(!y||C||!T)return;let e=p(U(T));!R(e)||!Ne(e)||V(T,e)&&e.blur()},[C,T]),m(()=>{if(!(a||!I))return I.setFocusManagerState({modal:l,closeOnFocusOut:u,open:C,onOpenChange:S.setOpen,domReference:w}),()=>{I.setFocusManagerState(null)}},[a,I,l,C,S,u,w]),m(()=>{if(!(a||!G))return Rt(G,j),()=>{queueMicrotask(Pt)}},[a,G,j]);let Ee=!a&&(l?!A:!0)&&(xe||l);return(0,X.jsxs)(Y.Fragment,{children:[Ee&&(0,X.jsx)(Te,{"data-type":`inside`,ref:H,onFocus:e=>{if(l){let e=K();vt(e[e.length-1])}else I?.portalNode&&(L.current=!1,_e(e,I.portalNode)?me(w)?.focus():we(h??I.beforeOutsideRef)?.focus())}}),r,Ee&&(0,X.jsx)(Te,{"data-type":`inside`,ref:oe,onFocus:e=>{l?vt(K()[0]):I?.portalNode&&(u&&(L.current=!0),_e(e,I.portalNode)?ge(w)?.focus():we(f??I.afterOutsideRef)?.focus())}})]})}var Bt=new Map([[`select`,`listbox`],[`combobox`,`listbox`],[`label`,!1]]);function Vt(e,t={}){let n=`rootStore`in e?e.rootStore:e,r=n.useState(`open`),i=n.useState(`floatingId`),a=n.useState(`domReferenceElement`),o=n.useState(`floatingElement`),{role:c=`dialog`}=t,l=s(),u=a?.id||l,d=Y.useMemo(()=>Le(o)?.id||i,[o,i]),f=Bt.get(c)??c,p=ue()!=null,m=Y.useMemo(()=>f===`tooltip`||c===`label`?z:{"aria-haspopup":f===`alertdialog`?`dialog`:f,"aria-expanded":`false`,...f===`listbox`&&{role:`combobox`},...f===`menu`&&p&&{role:`menuitem`},...c===`select`&&{"aria-autocomplete":`none`},...c===`combobox`&&{"aria-autocomplete":`list`}},[f,p,c]),h=Y.useMemo(()=>f===`tooltip`||c===`label`?{[`aria-${c===`label`?`labelledby`:`describedby`}`]:r?d:void 0}:{...m,"aria-expanded":r?`true`:`false`,"aria-controls":r?d:void 0,...f===`menu`&&{id:u}},[f,d,r,u,c,m]),g=Y.useMemo(()=>{let e={id:d,...f&&{role:f}};return f===`tooltip`||c===`label`?e:{...e,...f===`menu`&&{"aria-labelledby":u}}},[f,d,u,c]),_=Y.useCallback(({active:e,selected:t})=>{let n={role:`option`,...e&&{id:`${d}-fui-option`}};switch(c){case`select`:case`combobox`:return{...n,"aria-selected":t};default:}return{}},[d,c]);return Y.useMemo(()=>({reference:h,floating:g,item:_,trigger:m}),[h,g,m,_])}function Ht(e){return a(19)?e:e?`true`:void 0}var Ut=new Map([[`bold`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M216.49,104.49l-80,80a12,12,0,0,1-17,0l-80-80a12,12,0,0,1,17-17L128,159l71.51-71.52a12,12,0,0,1,17,17Z`}))],[`duotone`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M208,96l-80,80L48,96Z`,opacity:`0.2`}),Y.createElement(`path`,{d:`M215.39,92.94A8,8,0,0,0,208,88H48a8,8,0,0,0-5.66,13.66l80,80a8,8,0,0,0,11.32,0l80-80A8,8,0,0,0,215.39,92.94ZM128,164.69,67.31,104H188.69Z`}))],[`fill`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,48,88H208a8,8,0,0,1,5.66,13.66Z`}))],[`light`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M212.24,100.24l-80,80a6,6,0,0,1-8.48,0l-80-80a6,6,0,0,1,8.48-8.48L128,167.51l75.76-75.75a6,6,0,0,1,8.48,8.48Z`}))],[`regular`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,90.34L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z`}))],[`thin`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M210.83,98.83l-80,80a4,4,0,0,1-5.66,0l-80-80a4,4,0,0,1,5.66-5.66L128,170.34l77.17-77.17a4,4,0,1,1,5.66,5.66Z`}))]]),Wt=Y.forwardRef((e,t)=>Y.createElement(ce,{ref:t,...e,weights:Ut}));Wt.displayName=`CaretDownIcon`;var Gt=Wt,Kt=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 qt(e,t){return new Kt(e,t).maybeExecute}var Jt=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)}},Z=new class extends Jt{constructor(){super({pluginId:`form-devtools`,reconnectEveryMs:1e3})}};function Yt(e,t){return typeof e==`function`?e(t):e}function Xt(e,t){return sn(t).reduce((e,t)=>{if(e===null)return null;if(e!==void 0)return e[t]},e)}function Zt(e,t,n){let r=sn(t);function i(e){if(!r.length)return Yt(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 Qt(e,t){let n=sn(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 $t=/^(\d+)$/gm,en=/\.(\d+)(?=\.)/gm,tn=/^(\d+)\./gm,nn=/\.(\d+$)/gm,rn=/\.{2,}/gm,an=`__int__`,on=`${an}$1`;function sn(e){if(Array.isArray(e))return[...e];if(typeof e!=`string`)throw Error(`Path must be a string.`);return e.replace(/(^\[)|]/gm,``).replace(/\[/g,`.`).replace($t,on).replace(en,`.${on}.`).replace(tn,`${on}.`).replace(nn,`.${on}`).replace(rn,`.`).split(`.`).map(e=>{if(e.startsWith(an)){let t=e.substring(7),n=parseInt(t,10);return String(n)===t?n:t}return e})}function cn(e){return!(Array.isArray(e)&&e.length===0)}function ln(e,t){return t.validationLogic({form:t.form,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 un(e,t){let{asyncDebounceMs:n}=t,{onBlurAsyncDebounceMs:r,onChangeAsyncDebounceMs:i,onDynamicAsyncDebounceMs:a}=t.validators||{},o=n??0;return t.validationLogic({form:t.form,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;break}return e===`submit`&&(s=0),{cause:n,validate:t.fn,debounceMs:s}})})}var dn=e=>!!e&&typeof e==`object`&&`fields`in e;function fn(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)return!1;for(let i of n)if(!r.includes(i)||!fn(e[i],t[i]))return!1;return!0}var pn=({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},mn=({formLevelError:e,fieldLevelError:t})=>t?{newErrorValue:t,newSource:`field`}:e?{newErrorValue:e,newSource:`form`}:{newErrorValue:void 0,newSource:void 0};function Q(e,t){return e==null?t:{...e,...t}}for(var hn=256,gn=[],_n;hn--;)gn[hn]=(hn+256).toString(16).substring(1);function vn(){let e=0,t,n=``;if(!_n||hn+16>256){for(_n=Array(256),e=256;e--;)_n[e]=256*Math.random()|0;e=0,hn=0}for(;e<16;e++)t=_n[hn+e],e===6?n+=gn[t&15|64]:e===8?n+=gn[t&63|128]:n+=gn[t],e&1&&e>1&&e<11&&(n+=`-`);return hn++,n}var yn=qt(e=>Z.emit(`form-state`,{id:e.formId,state:e.store.state}),{wait:300});function bn(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]=bn(e[n]);return t}if(e instanceof Map){let t=new Map;return e.forEach((e,n)=>{t.set(n,bn(e))}),t}if(e instanceof Set){let t=new Set;return e.forEach(e=>{t.add(bn(e))}),t}let t={};for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=bn(e[n]));return t}var xn=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 Sn(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);Array.isArray(i)&&!Number.isNaN(o)?a+=`[${o}]`:a+=(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 Cn=(e,t)=>{let n=Sn(e,t);return{form:n,fields:n}},wn={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:Cn(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:Cn(r.issues,e)}},Tn=e=>!!e&&`~standard`in e,En={isValidating:!1,isTouched:!1,isBlurred:!1,isDirty:!1,isPristine:!0,isValid:!0,isDefaultValue:!0,errors:[],errorMap:{},errorSourceMap:{}};function Dn(e){function t(t,n,r){let i=o(t,n,`move`,r),s=Math.min(n,r),l=Math.max(n,r);for(let e=s;e<=l;e++)i.push(a(t,e));let u=Object.keys(e.fieldInfo).reduce((r,i)=>(i.startsWith(a(t,n))&&r.set(i,e.getFieldMeta(i)),r),new Map);c(i,n<r?`up`:`down`),Object.keys(e.fieldInfo).filter(e=>e.startsWith(a(t,r))).forEach(i=>{let o=i.replace(a(t,r),a(t,n)),s=u.get(o);s&&e.setFieldMeta(i,s)})}function n(e,t){c(o(e,t,`remove`),`up`)}function r(t,n,r){o(t,n,`swap`,r).forEach(i=>{if(!i.toString().startsWith(a(t,n)))return;let o=i.toString().replace(a(t,n),a(t,r)),[s,c]=[e.getFieldMeta(i),e.getFieldMeta(o)];s&&e.setFieldMeta(o,s),c&&e.setFieldMeta(i,c)})}function i(t,n){let r=o(t,n,`insert`);c(r,`down`),r.forEach(r=>{r.toString().startsWith(a(t,n))&&e.setFieldMeta(r,l())})}function a(e,t){return`${e}[${t}]`}function o(t,n,r,i){let o=[a(t,n)];switch(r){case`swap`:o.push(a(t,i));break;case`move`:{let[e,r]=[Math.min(n,i),Math.max(n,i)];for(let n=e;n<=r;n++)o.push(a(t,n));break}default:{let r=e.getFieldValue(t),i=Array.isArray(r)?r.length:0;for(let e=n+1;e<i;e++)o.push(a(t,e));break}}return Object.keys(e.fieldInfo).filter(e=>o.some(t=>e.startsWith(t)))}function s(e,t){return e.replace(/\[(\d+)\]/,(e,n)=>{let r=parseInt(n,10);return`[${t===`up`?r+1:Math.max(0,r-1)}]`})}function c(t,n){(n===`up`?t:[...t].reverse()).forEach(t=>{let r=s(t.toString(),n),i=e.getFieldMeta(r);i?e.setFieldMeta(t,i):e.setFieldMeta(t,l())})}let l=()=>En;return{handleArrayMove:t,handleArrayRemove:n,handleArraySwap:r,handleArrayInsert:i}}function On(e){return{values:e.values??{},errorMap:e.errorMap??{},fieldMetaBase:e.fieldMetaBase??{},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 kn=class{constructor(e){this.options={},this.fieldInfo={},this.mount=()=>{let e=this.store.subscribe(()=>{yn(this)}),t=Z.on(`request-form-state`,e=>{e.payload.id===this._formId&&Z.emit(`form-api`,{id:this._formId,state:this.store.state,options:this.options})}),n=Z.on(`request-form-reset`,e=>{e.payload.id===this._formId&&this.reset()}),r=Z.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(),Z.emit(`form-unmounted`,{id:this._formId})};this.options.listeners?.onMount?.({formApi:this});let{onMount:a}=this.options.validators||{};return Z.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&&!fn(e.defaultValues,t.defaultValues)&&!this.state.isTouched,r=!fn(e.defaultState,t.defaultState)&&!this.state.isTouched;!n&&!r||(J(()=>{this.baseStore.setState(()=>On(Object.assign({},this.state,r?e.defaultState:{},n?{values:e.defaultValues}:{})))}),Z.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(()=>On({...this.options.defaultState,values:e??this.options.defaultValues??this.options.defaultState?.values,fieldMetaBase:r}))},this.validateAllFields=async e=>{let t=[];return J(()=>{Object.values(this.fieldInfo).forEach(n=>{if(!n.instance)return;let r=n.instance;t.push(Promise.resolve().then(()=>r.validate(e,{skipFormValidation:!0}))),n.instance.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 J(()=>{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.state.meta.isTouched||n.setMeta(e=>({...e,isTouched:!0})),n.validate(t)},this.validateSync=e=>{let t=ln(e,{...this.options,form:this,validationLogic:this.options.validationLogic||xn}),n=!1,r={};return J(()=>{for(let e of t){if(!e.validate)continue;let{formError:t,fieldErrors:i}=An(this.runValidator({validate:e.validate,value:{value:this.state.values,formApi:this,validationSource:`form`},type:`validate`})),a=jn(e.cause),o=new Set([...Object.keys(this.state.fieldMeta),...Object.keys(i||{})]);for(let e of o){if(this.baseStore.state.fieldMetaBase[e]===void 0&&!i?.[e])continue;let{errorMap:t,errorSourceMap:n}=this.getFieldMeta(e)??En,o=i?.[e],{newErrorValue:s,newSource:c}=pn({newFormValidatorError:o,isPreviousErrorFromFormValidator:n?.[a]===`form`,previousErrorValue:t?.[a]});c===`form`&&(r[e]={...r[e],[a]:o}),t?.[a]!==s&&this.setFieldMeta(e,(e=En)=>({...e,errorMap:{...e.errorMap,[a]:s},errorSourceMap:{...e.errorSourceMap,[a]:c}}))}this.state.errorMap?.[a]!==t&&this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[a]:t}})),(t||i)&&(n=!0)}let i=jn(`submit`);this.state.errorMap?.[i]&&e!==`submit`&&!n&&this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[i]:void 0}}));let a=jn(`server`);this.state.errorMap?.[a]&&e!==`server`&&!n&&this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[a]:void 0}}))}),{hasErrored:n,fieldsErrorMap:r}},this.validateAsync=async e=>{let t=un(e,{...this.options,form:this,validationLogic:this.options.validationLogic||xn});this.state.isFormValidating||this.baseStore.setState(e=>({...e,isFormValidating:!0}));let n=[],r;for(let e of t){if(!e.validate)continue;let t=jn(e.cause);this.state.validationMetaMap[t]?.lastAbortController.abort();let i=new AbortController;this.state.validationMetaMap[t]={lastAbortController:i},n.push(new Promise(async t=>{let n;try{n=await new Promise((t,n)=>{setTimeout(async()=>{if(i.signal.aborted)return t(void 0);try{t(await this.runValidator({validate:e.validate,value:{value:this.state.values,formApi:this,validationSource:`form`,signal:i.signal},type:`validateAsync`}))}catch(e){n(e)}},e.debounceMs)})}catch(e){n=e}let{formError:a,fieldErrors:o}=An(n);o&&(r=r?{...r,...o}:o);let s=jn(e.cause);for(let e of Object.keys(this.state.fieldMeta)){if(this.baseStore.state.fieldMetaBase[e]===void 0)continue;let t=this.getFieldMeta(e);if(!t)continue;let{errorMap:n,errorSourceMap:i}=t,a=r?.[e],{newErrorValue:o,newSource:c}=pn({newFormValidatorError:a,isPreviousErrorFromFormValidator:i?.[s]===`form`,previousErrorValue:n?.[s]});n?.[s]!==o&&this.setFieldMeta(e,e=>({...e,errorMap:{...e.errorMap,[s]:o},errorSourceMap:{...e.errorSourceMap,[s]:c}}))}this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[s]:a}})),t(r?{fieldErrors:r,errorMapKey:s}:void 0)}))}let i=[],a={};if(n.length){i=await Promise.all(n);for(let e of i)if(e?.fieldErrors){let{errorMapKey:t}=e;for(let[n,r]of Object.entries(e.fieldErrors))a[n]={...a[n]||{},[t]:r}}}return this.baseStore.setState(e=>({...e,isFormValidating:!1})),a},this.validate=e=>{let{hasErrored:t,fieldsErrorMap:n}=this.validateSync(e);return t&&!this.options.asyncAlways?n:this.validateAsync(e)},this._handleSubmit=async e=>{this.baseStore.setState(e=>({...e,isSubmitted:!1,submissionAttempts:e.submissionAttempts+1,isSubmitSuccessful:!1})),J(()=>{Object.values(this.fieldInfo).forEach(e=>{e.instance&&(e.instance.state.meta.isTouched||e.instance.setMeta(e=>({...e,isTouched:!0})))})});let t=e??this.options.onSubmitMeta;if(!this.state.canSubmit&&!this._devtoolsSubmissionOverride){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}),Z.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}),Z.emit(`form-submission`,{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!1,stage:`validate`,errors:this.state.errors});return}J(()=>{Object.values(this.fieldInfo).forEach(e=>{e.instance?.options.listeners?.onSubmit?.({value:e.instance.state.value,fieldApi:e.instance})})}),this.options.listeners?.onSubmit?.({formApi:this,meta:t});try{await this.options.onSubmit?.({value:this.state.values,formApi:this,meta:t}),J(()=>{this.baseStore.setState(e=>({...e,isSubmitted:!0,isSubmitSuccessful:!0})),Z.emit(`form-submission`,{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!0}),n()})}catch(e){throw this.baseStore.setState(e=>({...e,isSubmitSuccessful:!1})),Z.emit(`form-submission`,{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!1,stage:`inflight`,onError:e}),n(),e}},this.getFieldValue=e=>Xt(this.state.values,e),this.getFieldMeta=e=>this.state.fieldMeta[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]:Yt(t,n.fieldMetaBase[e])}}))},this.resetFieldMeta=e=>Object.keys(e).reduce((e,t)=>{let n=t;return e[n]=En,e},{}),this.setFieldValue=(e,t,n)=>{let r=n?.dontUpdateMeta??!1,i=n?.dontRunListeners??!1,a=n?.dontValidate??!1;J(()=>{r||this.setFieldMeta(e,e=>({...e,isTouched:!0,isDirty:!0,errorMap:{...e?.errorMap,onMount:void 0}})),this.baseStore.setState(n=>({...n,values:Zt(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=Qt(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)},this.insertFieldValue=async(e,t,n,r)=>{this.setFieldValue(e,e=>[...e.slice(0,t),n,...e.slice(t)],Q(r,{dontValidate:!0}));let i=r?.dontValidate??!1;i||await this.validateField(e,`change`),Dn(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),Q(r,{dontValidate:!0})),(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),Q(n,{dontValidate:!0})),Dn(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 Zt(Zt(e,`${t}`,i),`${n}`,r)},Q(r,{dontValidate:!0})),Dn(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},Q(r,{dontValidate:!0})),Dn(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,[],Q(t,{dontValidate:!0})),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=>({...t,fieldMetaBase:{...t.fieldMetaBase,[e]:En},values:this.options.defaultValues?Zt(t.values,e,Xt(this.options.defaultValues,e)):t.values}))},this.setErrorMap=e=>{J(()=>{Object.entries(e).forEach(([e,t])=>{let n=e;if(dn(t)){let{formError:e,fieldErrors:r}=An(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=>wn.validate({value:this.state.values,validationSource:`form`},e),this.parseValuesWithSchemaAsync=e=>wn.validateAsync({value:this.state.values,validationSource:`form`},e),this.timeoutIds={validations:{},listeners:{},formListeners:{}},this._formId=e?.formId??vn(),this._devtoolsSubmissionOverride=!1;let t=On({...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||!dn(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,...a??{},errorSourceMap:{...a?.errorSourceMap??{},onChange:`form`},errorMap:{...a?.errorMap??{},[e]:i}}}}}this.baseStore=mt(t);let n;this.fieldMetaDerived=mt(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=Xt(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=!cn(u),f=!o.isDirty,p=fn(l,Xt(this.options.defaultValues,a))||fn(l,this.getFieldInfo(a)?.instance?.options.defaultValue);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});let r;this.store=mt(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&&dn(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&&fn(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 Tn(e.validate)?wn[e.type](e.value,e.validate):e.validate(e.value)}handleSubmit(e){return this._handleSubmit(e)}};function An(e){return e?dn(e)?{formError:An(e.form).formError,fieldErrors:e.fields}:{formError:e}:{formError:void 0}}function jn(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 Mn=class{constructor(e){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]:{...En,isTouched:e.fieldMetaBase[this.name]?.isTouched??En.isTouched,isBlurred:e.fieldMetaBase[this.name]?.isBlurred??En.isBlurred,isDirty:e.fieldMetaBase[this.name]?.isDirty??En.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&&(fn(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,Q(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,Q(t,{dontRunListeners:!0})),t?.dontRunListeners||this.triggerOnChangeListener()},this.insertValue=(e,t,n)=>{this.form.insertFieldValue(this.name,e,t,Q(n,{dontRunListeners:!0})),n?.dontRunListeners||this.triggerOnChangeListener()},this.replaceValue=(e,t,n)=>{this.form.replaceFieldValue(this.name,e,t,Q(n,{dontRunListeners:!0})),n?.dontRunListeners||this.triggerOnChangeListener()},this.removeValue=(e,t)=>{this.form.removeFieldValue(this.name,e,Q(t,{dontRunListeners:!0})),t?.dontRunListeners||this.triggerOnChangeListener()},this.swapValues=(e,t,n)=>{this.form.swapFieldValues(this.name,e,t,Q(n,{dontRunListeners:!0})),n?.dontRunListeners||this.triggerOnChangeListener()},this.moveValue=(e,t,n)=>{this.form.moveFieldValues(this.name,e,t,Q(n,{dontRunListeners:!0})),n?.dontRunListeners||this.triggerOnChangeListener()},this.clearValues=e=>{this.form.clearFieldValues(this.name,Q(e,{dontRunListeners:!0})),e?.dontRunListeners||this.triggerOnChangeListener()},this.getLinkedFields=e=>{let t=Object.values(this.form.fieldInfo),n=[];for(let r of t){if(!r.instance)continue;let{onChangeListenTo:t,onBlurListenTo:i}=r.instance.options.validators||{};e===`change`&&t?.includes(this.name)&&n.push(r.instance),e===`blur`&&i?.includes(this.name)&&n.push(r.instance)}return n},this.validateSync=(e,t)=>{let n=ln(e,{...this.options,form:this.form,fieldName:this.name,validationLogic:this.form.options.validationLogic||xn}),r=this.getLinkedFields(e).reduce((t,n)=>{let r=ln(e,{...n.options,form:n.form,fieldName:n.name,validationLogic:n.form.options.validationLogic||xn});return r.forEach(e=>{e.field=n}),t.concat(r)},[]),i=!1;J(()=>{let e=(e,n)=>{let r=Pn(n.cause),a=n.validate?Nn(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}=mn({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=Pn(`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=un(e,{...this.options,form:this.form,fieldName:this.name,validationLogic:this.form.options.validationLogic||xn}),r=await t,i=this.getLinkedFields(e),a=i.reduce((t,n)=>{let r=un(e,{...n.options,form:n.form,fieldName:n.name,validationLogic:n.form.options.validationLogic||xn});return r.forEach(e=>{e.field=n}),t.concat(r)},[]),o=[],s=[],c=n.some(e=>e.validate)||a.some(e=>e.validate);if(c){this.state.meta.isValidating||this.setMeta(e=>({...e,isValidating:!0}));for(let e of i)e.setMeta(e=>({...e,isValidating:!0}))}let l=(e,t,n)=>{let i=Pn(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.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=Nn(a),c=r[e.name]?.[i],{newErrorValue:l,newSource:u}=mn({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,o);for(let e of a)e.validate&&l(e.field,e,s);let u=[];if((o.length||s.length)&&(u=await Promise.all(o),await Promise.all(s)),c){this.setMeta(e=>({...e,isValidating:!1}));for(let e of i)e.setMeta(e=>({...e,isValidating:!1}))}return u.filter(Boolean)},this.validate=(e,t)=>{if(!this.state.meta.isTouched)return[];let{fieldsErrorMap:n}=t?.skipFormValidation?{fieldsErrorMap:{}}:this.form.validateSync(e),{hasErrored:r}=this.validateSync(e,n[this.name]??{});if(r&&!this.options.asyncAlways)return this.getInfo().validationMetaMap[Pn(e)]?.lastAbortController.abort(),this.state.meta.errors;let i=t?.skipFormValidation?Promise.resolve({}):this.form.validateAsync(e);return this.validateAsync(e,i)},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=>wn.validate({value:this.state.value,validationSource:`field`},e),this.parseValueWithSchemaAsync=e=>wn.validateAsync({value:this.state.value,validationSource:`field`},e),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})},this.form=e.form,this.name=e.name,this.options=e,this.timeoutIds={validations:{},listeners:{},formListeners:{}},this.store=mt(t=>{this.form.store.get();let n=this.form.getFieldMeta(this.name)??{...En,...e.defaultMeta},r=this.form.getFieldValue(this.name);return!n.isTouched&&r===void 0&&this.options.defaultValue!==void 0&&!fn(r,this.options.defaultValue)&&(r=this.options.defaultValue),t&&t.value===r&&t.meta===n?t:{value:r,meta:n}})}get state(){return this.store.state}runValidator(e){return Tn(e.validate)?wn[e.type](e.value,e.validate):e.validate(e.value)}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})}};function Nn(e){if(e)return e}function Pn(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 Fn(e,t){if(!t)return;let n=Object.assign({},e,{state:bn(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,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 J(()=>{Object.keys(r).length&&e.baseStore.setState(e=>({...e,...r})),n.state.errorMap!==e.state.errorMap&&e.setErrorMap(n.state.errorMap)}),n}var In=typeof window<`u`?Y.useLayoutEffect:Y.useEffect;function Ln(e){let[t,n]=(0,Y.useState)(()=>({form:e.form,name:e.name})),[r,i]=(0,Y.useState)(()=>new Mn({...e}));(t.form!==e.form||t.name!==e.name)&&(i(new Mn({...e})),n({form:e.form,name:e.name}));let a=d(r.store,e.mode===`array`?e=>Object.keys(e.value??[]).length:e=>e.value),o=d(r.store,e=>e.meta.isTouched),s=d(r.store,e=>e.meta.isBlurred),c=d(r.store,e=>e.meta.isDirty),l=d(r.store,e=>e.meta.errorMap),u=d(r.store,e=>e.meta.errorSourceMap),f=d(r.store,e=>e.meta.isValidating),p=(0,Y.useMemo)(()=>{let t={...r,get state(){return{value:e.mode===`array`?r.state.value:a,get meta(){return{...r.state.meta,isTouched:o,isBlurred:s,isDirty:c,errorMap:l,errorSourceMap:u,isValidating:f}}}}};return t.Field=Rn,t},[r,e.mode,a,o,s,c,l,u,f]);return In(r.mount,[r]),In(()=>{r.update(e)}),p}var Rn=(({children:e,...t})=>{let n=Ln(t);return(0,X.jsx)(X.Fragment,{children:(0,Y.useMemo)(()=>Yt(e,n),[e,n])})});function zn(){return(0,Y.useState)(()=>vn())[0]}var Bn=Y,Vn=`19.2.5`.split(`.`)[0]===`17`?zn:Bn.useId;function Hn({form:e,selector:t=e=>e,children:n}){return(0,X.jsx)(X.Fragment,{children:Yt(n,d(e.store,t))})}function Un(e){let t=Vn(),[n,r]=(0,Y.useState)(e?.formId),[i,a]=(0,Y.useState)(()=>new kn({...e,formId:e?.formId??t}));if(n!==e?.formId){let n=e?.formId??t;a(new kn({...e,formId:n})),r(n)}let o=(0,Y.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)(Rn,{...e,form:i})},e.Subscribe=function(e){return(0,X.jsx)(Hn,{form:i,selector:e.selector,children:e.children})},e},[i]);In(i.mount,[]),In(()=>{i.update(e)});let s=(0,Y.useRef)(!1);return In(()=>{s.current&&e?.transform&&Fn(i,e.transform)},[i,e?.transform]),In(()=>{s.current=!0}),o}function Wn({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=Y.useRef(e!==void 0),[a,o]=Y.useState(t);return[i?e:a,Y.useCallback(e=>{i||o(e)},[])]}function Gn(e){let{open:t,defaultOpen:n,onOpenChange:r,disabled:i}=e,a=t!==void 0,[o,s]=Wn({controlled:t,default:n,name:`Collapsible`,state:`open`}),{mounted:l,setMounted:u,transitionStatus:d}=Ae(o,!0,!0),[f,p]=Y.useState(o),[{height:h,width:g},v]=Y.useState({height:void 0,width:void 0}),y=c(),[b,x]=Y.useState(),S=b??y,[C,w]=Y.useState(!1),[T,E]=Y.useState(!1),D=Y.useRef(null),O=Y.useRef(null),k=Y.useRef(null),A=Y.useRef(null),j=He(A,!1),M=_(e=>{let t=!o,n=W(Ce,e.nativeEvent);if(r(t,n),n.isCanceled)return;let i=A.current;O.current===`css-animation`&&i!=null&&i.style.removeProperty(`animation-name`),!C&&!T&&(O.current!=null&&O.current!==`css-animation`&&!l&&t&&u(!0),O.current===`css-animation`&&(!f&&t&&p(!0),!l&&t&&u(!0))),s(t),O.current===`none`&&l&&!t&&u(!1)});return m(()=>{a&&O.current===`none`&&!o&&u(!1)},[a,o,t,u]),Y.useMemo(()=>({abortControllerRef:D,animationTypeRef:O,disabled:i,handleTrigger:M,height:h,mounted:l,open:o,panelId:S,panelRef:A,runOnceAnimationsFinish:j,setDimensions:v,setHiddenUntilFound:w,setKeepMounted:E,setMounted:u,setOpen:s,setPanelIdState:x,setVisible:p,transitionDimensionRef:k,transitionStatus:d,visible:f,width:g}),[D,O,i,M,h,l,o,S,A,j,v,w,E,u,s,p,k,d,f,g])}var Kn=Y.createContext(void 0);function qn(){let e=Y.useContext(Kn);if(e===void 0)throw Error(B(15));return e}var Jn=function(e){return e.open=`data-open`,e.closed=`data-closed`,e[e.startingStyle=Re.startingStyle]=`startingStyle`,e[e.endingStyle=Re.endingStyle]=`endingStyle`,e}({}),Yn=function(e){return e.panelOpen=`data-panel-open`,e}({}),Xn={[Jn.open]:``},Zn={[Jn.closed]:``},Qn={open(e){return e?{[Yn.panelOpen]:``}:null}},$n={open(e){return e?Xn:Zn},...Ie},er=Y.forwardRef(function(e,t){let{render:n,className:r,defaultOpen:i=!1,disabled:a=!1,onOpenChange:o,open:s,style:c,...u}=e,d=_(o),f=Gn({open:s,defaultOpen:i,onOpenChange:d,disabled:a}),p=Y.useMemo(()=>({open:f.open,disabled:f.disabled,transitionStatus:f.transitionStatus}),[f.open,f.disabled,f.transitionStatus]),m=Y.useMemo(()=>({...f,onOpenChange:d,state:p}),[f,d,p]),h=l(`div`,e,{state:p,ref:t,props:u,stateAttributesMapping:$n});return(0,X.jsx)(Kn.Provider,{value:m,children:h})}),tr={...Qn,...Ie},nr=Y.forwardRef(function(e,t){let{panelId:n,open:r,handleTrigger:i,state:a,disabled:o}=qn(),{className:s,disabled:c=o,id:u,render:d,nativeButton:f=!0,style:p,...m}=e,{getButtonProps:h,buttonRef:g}=se({disabled:c,focusableWhenDisabled:!0,native:f}),_=Y.useMemo(()=>({"aria-controls":r?n:void 0,"aria-expanded":r,onClick:i}),[n,r,i]);return l(`button`,e,{state:a,ref:[t,g],props:[_,m,h],stateAttributesMapping:tr})}),rr=function(e){return e.disabled=`data-disabled`,e.orientation=`data-orientation`,e}({});function ir(e){let{abortControllerRef:t,animationTypeRef:n,externalRef:r,height:a,hiddenUntilFound:o,keepMounted:s,id:c,mounted:l,onOpenChange:u,open:d,panelRef:f,runOnceAnimationsFinish:p,setDimensions:h,setMounted:v,setOpen:y,setVisible:b,transitionDimensionRef:x,visible:S,width:w}=e,T=Y.useRef(!1),E=Y.useRef(null),D=Y.useRef(d),O=Y.useRef(d),k=De(),A=Y.useMemo(()=>n.current===`css-animation`?!S:!d&&!l,[d,l,S,n]),j=i(r,f,_(e=>{if(!e)return;if(n.current==null||x.current==null){let t=getComputedStyle(e),r=t.animationName!==`none`&&t.animationName!==``,i=t.transitionDuration!==`0s`&&t.transitionDuration!==``;r&&i||(t.animationName===`none`&&t.transitionDuration!==`0s`?n.current=`css-transition`:t.animationName!==`none`&&t.transitionDuration===`0s`?n.current=`css-animation`:n.current=`none`),e.getAttribute(rr.orientation)===`horizontal`||t.transitionProperty.indexOf(`width`)>-1?x.current=`width`:x.current=`height`}if(n.current!==`css-transition`)return;(a===void 0||w===void 0)&&(h({height:e.scrollHeight,width:e.scrollWidth}),O.current&&e.style.setProperty(`transition-duration`,`0s`));let t=-1,r=-1;return t=q.request(()=>{O.current=!1,r=q.request(()=>{setTimeout(()=>{e.style.removeProperty(`transition-duration`)})})}),()=>{q.cancel(t),q.cancel(r)}}));return m(()=>{if(n.current!==`css-transition`)return;let e=f.current;if(!e)return;let r=-1;if(t.current!=null&&(t.current.abort(),t.current=null),d){let t={"justify-content":e.style.justifyContent,"align-items":e.style.alignItems,"align-content":e.style.alignContent,"justify-items":e.style.justifyItems};Object.keys(t).forEach(t=>{e.style.setProperty(t,`initial`,`important`)}),!O.current&&!s&&e.setAttribute(Jn.startingStyle,``),h({height:e.scrollHeight,width:e.scrollWidth}),r=q.request(()=>{Object.entries(t).forEach(([t,n])=>{n===``?e.style.removeProperty(t):e.style.setProperty(t,n)})})}else{if(e.scrollHeight===0&&e.scrollWidth===0)return;h({height:e.scrollHeight,width:e.scrollWidth});let n=new AbortController;t.current=n;let r=n.signal,i=null,a=Jn.endingStyle;return i=new MutationObserver(o=>{o.some(e=>e.type===`attributes`&&e.attributeName===a)&&(i?.disconnect(),i=null,p(()=>{h({height:0,width:0}),e.style.removeProperty(`content-visibility`),v(!1),t.current===n&&(t.current=null)},r))}),i.observe(e,{attributes:!0,attributeFilter:[a]}),()=>{i?.disconnect(),k.cancel(),t.current===n&&(n.abort(),t.current=null)}}return()=>{q.cancel(r)}},[t,n,k,o,s,l,d,f,p,h,v]),m(()=>{if(n.current!==`css-animation`)return;let e=f.current;e&&(E.current=e.style.animationName||E.current,e.style.setProperty(`animation-name`,`none`),h({height:e.scrollHeight,width:e.scrollWidth}),!D.current&&!T.current&&e.style.removeProperty(`animation-name`),d?(t.current!=null&&(t.current.abort(),t.current=null),v(!0),b(!0)):(t.current=new AbortController,p(()=>{v(!1),b(!1),t.current=null},t.current.signal)))},[t,n,d,f,p,h,v,b,S]),C(()=>{let e=q.request(()=>{D.current=!1});return()=>q.cancel(e)}),m(()=>{if(!o)return;let e=f.current;if(!e)return;let t=-1,n=-1;return d&&T.current&&(e.style.transitionDuration=`0s`,h({height:e.scrollHeight,width:e.scrollWidth}),t=q.request(()=>{T.current=!1,n=q.request(()=>{setTimeout(()=>{e.style.removeProperty(`transition-duration`)})})})),()=>{q.cancel(t),q.cancel(n)}},[o,d,f,h]),m(()=>{let e=f.current;e&&o&&A&&(e.setAttribute(`hidden`,`until-found`),n.current===`css-transition`&&e.setAttribute(Jn.startingStyle,``))},[o,A,n,f]),Y.useEffect(function(){let e=f.current;if(!e)return;function t(e){T.current=!0,y(!0),u(!0,W(K,e))}return g(e,`beforematch`,t)},[u,f,y]),Y.useMemo(()=>({props:{hidden:A,id:c,ref:j}}),[A,c,j])}var ar=function(e){return e.collapsiblePanelHeight=`--collapsible-panel-height`,e.collapsiblePanelWidth=`--collapsible-panel-width`,e}({}),or=Y.forwardRef(function(e,t){let{className:n,hiddenUntilFound:r,keepMounted:i,render:a,id:o,style:s,...c}=e,{abortControllerRef:u,animationTypeRef:d,height:f,mounted:p,onOpenChange:h,open:g,panelId:_,panelRef:v,runOnceAnimationsFinish:y,setDimensions:b,setHiddenUntilFound:x,setKeepMounted:S,setMounted:C,setPanelIdState:w,setOpen:T,setVisible:E,state:D,transitionDimensionRef:O,visible:k,width:A,transitionStatus:j}=qn(),M=r??!1,N=i??!1;m(()=>{if(o)return w(o),()=>{w(void 0)}},[o,w]),m(()=>{x(M)},[x,M]),m(()=>{S(N)},[S,N]);let{props:P}=ir({abortControllerRef:u,animationTypeRef:d,externalRef:t,height:f,hiddenUntilFound:M,id:_,keepMounted:N,mounted:p,onOpenChange:h,open:g,panelRef:v,runOnceAnimationsFinish:y,setDimensions:b,setMounted:C,setOpen:T,setVisible:E,transitionDimensionRef:O,visible:k,width:A});We({open:g&&j===`idle`,ref:v,onComplete(){g&&b({height:void 0,width:void 0})}});let F=l(`div`,e,{state:Y.useMemo(()=>({...D,transitionStatus:j}),[D,j]),ref:[t,v],props:[P,{style:{[ar.collapsiblePanelHeight]:f===void 0?`auto`:`${f}px`,[ar.collapsiblePanelWidth]:A===void 0?`auto`:`${A}px`}},c],stateAttributesMapping:$n});return N||M||p?F:null}),$=re();function sr(e){let t=(0,$.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,X.jsx)(er,{"data-slot":`collapsible`,...n}),t[2]=n,t[3]=r),r}function cr(e){let t=(0,$.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,X.jsx)(nr,{"data-slot":`collapsible-trigger`,...n}),t[2]=n,t[3]=r),r}function lr(e){let t=(0,$.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,X.jsx)(or,{"data-slot":`collapsible-content`,...n}),t[2]=n,t[3]=r),r}var ur=Y.createContext(void 0);function dr(e){let t=Y.useContext(ur);if(e===!1&&t===void 0)throw Error(B(27));return t}var fr={...Ke,...Ie},pr=Y.forwardRef(function(e,t){let{render:n,className:r,style:i,forceRender:a=!1,...o}=e,{store:s}=dr(),c=s.useState(`open`),u=s.useState(`nested`),d=s.useState(`mounted`);return l(`div`,e,{state:{open:c,transitionStatus:s.useState(`transitionStatus`)},ref:[s.context.backdropRef,t],stateAttributesMapping:fr,props:[{role:`presentation`,hidden:!d,style:{userSelect:`none`,WebkitUserSelect:`none`}},o],enabled:a||!u})}),mr=Y.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,nativeButton:a=!0,style:o,...s}=e,{store:c}=dr(),u=c.useState(`open`);function d(e){u&&c.setOpen(!1,W(Be,e.nativeEvent))}let{getButtonProps:f,buttonRef:p}=se({disabled:i,native:a});return l(`button`,e,{state:{disabled:i},ref:[t,p],props:[{onClick:d},s,f]})}),hr=function(e){return e.nestedDialogs=`--nested-dialogs`,e}({}),gr=function(e){return e[e.open=Je.open]=`open`,e[e.closed=Je.closed]=`closed`,e[e.startingStyle=Je.startingStyle]=`startingStyle`,e[e.endingStyle=Je.endingStyle]=`endingStyle`,e.nested=`data-nested`,e.nestedDialogOpen=`data-nested-dialog-open`,e}({}),_r=Y.createContext(void 0);function vr(){let e=Y.useContext(_r);if(e===void 0)throw Error(B(26));return e}var yr=`ArrowUp`,br=`ArrowDown`,xr=`ArrowLeft`,Sr=`ArrowRight`,Cr=`Home`,wr=new Set([xr,Sr]),Tr=new Set([xr,Sr,Cr,`End`]),Er=new Set([yr,br]),Dr=new Set([yr,br,Cr,`End`]),Or=new Set([...wr,...Er]),kr=new Set([...Or,Cr,`End`]),Ar=new Set([yr,br,xr,Sr,Cr,`End`]),jr=new Set([`Shift`,`Control`,`Alt`,`Meta`]);function Mr(e){return R(e)&&e.tagName===`INPUT`}function Nr(e){return!!(Mr(e)&&e.selectionStart!=null||R(e)&&e.tagName===`TEXTAREA`)}function Pr(e,t,n,r){if(!e||!t||!t.scrollTo)return;let i=e.scrollLeft,a=e.scrollTop,o=e.clientWidth<e.scrollWidth,s=e.clientHeight<e.scrollHeight;if(o&&r!==`vertical`){let r=Fr(e,t,`left`),a=Ir(e),o=Ir(t);n===`ltr`&&(r+t.offsetWidth+o.scrollMarginRight>e.scrollLeft+e.clientWidth-a.scrollPaddingRight?i=r+t.offsetWidth+o.scrollMarginRight-e.clientWidth+a.scrollPaddingRight:r-o.scrollMarginLeft<e.scrollLeft+a.scrollPaddingLeft&&(i=r-o.scrollMarginLeft-a.scrollPaddingLeft)),n===`rtl`&&(r-o.scrollMarginRight<e.scrollLeft+a.scrollPaddingLeft?i=r-o.scrollMarginLeft-a.scrollPaddingLeft:r+t.offsetWidth+o.scrollMarginRight>e.scrollLeft+e.clientWidth-a.scrollPaddingRight&&(i=r+t.offsetWidth+o.scrollMarginRight-e.clientWidth+a.scrollPaddingRight))}if(s&&r!==`horizontal`){let n=Fr(e,t,`top`),r=Ir(e),i=Ir(t);n-i.scrollMarginTop<e.scrollTop+r.scrollPaddingTop?a=n-i.scrollMarginTop-r.scrollPaddingTop:n+t.offsetHeight+i.scrollMarginBottom>e.scrollTop+e.clientHeight-r.scrollPaddingBottom&&(a=n+t.offsetHeight+i.scrollMarginBottom-e.clientHeight+r.scrollPaddingBottom)}e.scrollTo({left:i,top:a,behavior:`auto`})}function Fr(e,t,n){let r=n===`left`?`offsetLeft`:`offsetTop`,i=0;for(;t.offsetParent&&(i+=t[r],t.offsetParent!==e);)t=t.offsetParent;return i}function Ir(e){let t=getComputedStyle(e);return{scrollMarginTop:parseFloat(t.scrollMarginTop)||0,scrollMarginRight:parseFloat(t.scrollMarginRight)||0,scrollMarginBottom:parseFloat(t.scrollMarginBottom)||0,scrollMarginLeft:parseFloat(t.scrollMarginLeft)||0,scrollPaddingTop:parseFloat(t.scrollPaddingTop)||0,scrollPaddingRight:parseFloat(t.scrollPaddingRight)||0,scrollPaddingBottom:parseFloat(t.scrollPaddingBottom)||0,scrollPaddingLeft:parseFloat(t.scrollPaddingLeft)||0}}var Lr={...Ke,...Ie,nestedDialogOpen(e){return e?{[gr.nestedDialogOpen]:``}:null}},Rr=Y.forwardRef(function(e,t){let{className:n,finalFocus:r,initialFocus:i,render:a,style:o,...s}=e,{store:c}=dr(),u=c.useState(`descriptionElementId`),d=c.useState(`disablePointerDismissal`),f=c.useState(`floatingRootContext`),p=c.useState(`popupProps`),m=c.useState(`modal`),h=c.useState(`mounted`),g=c.useState(`nested`),_=c.useState(`nestedOpenDialogCount`),v=c.useState(`open`),y=c.useState(`openMethod`),b=c.useState(`titleElementId`),x=c.useState(`transitionStatus`),S=c.useState(`role`);vr(),We({open:v,ref:c.context.popupRef,onComplete(){v&&c.context.onOpenChangeComplete?.(!0)}});function C(e){return e===`touch`?c.context.popupRef.current:!0}let w=i===void 0?C:i,T=l(`div`,e,{state:{open:v,nested:g,transitionStatus:x,nestedDialogOpen:_>0},props:[p,{"aria-labelledby":b??void 0,"aria-describedby":u??void 0,role:S,tabIndex:-1,hidden:!h,onKeyDown(e){Ar.has(e.key)&&e.stopPropagation()},style:{[hr.nestedDialogs]:_}},s],ref:[t,c.context.popupRef,c.useStateSetter(`popupElement`)],stateAttributesMapping:Lr});return(0,X.jsx)(zt,{context:f,openInteractionType:y,disabled:!h,closeOnFocusOut:!d,initialFocus:w,returnFocus:r,modal:m!==!1,restoreFocus:`popup`,children:T})}),zr=Y.forwardRef(function(e,t){let{cutout:n,...r}=e,i;if(n){let e=n.getBoundingClientRect();i=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${e.left}px ${e.top}px,${e.left}px ${e.bottom}px,${e.right}px ${e.bottom}px,${e.right}px ${e.top}px,${e.left}px ${e.top}px)`}return(0,X.jsx)(`div`,{ref:t,role:`presentation`,"data-base-ui-inert":``,...r,style:{position:`fixed`,inset:0,userSelect:`none`,WebkitUserSelect:`none`,clipPath:i}})}),Br=Y.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i}=dr(),a=i.useState(`mounted`),o=i.useState(`modal`),s=i.useState(`open`);return a||n?(0,X.jsx)(_r.Provider,{value:n,children:(0,X.jsxs)(Ee,{ref:t,...r,children:[a&&o===!0&&(0,X.jsx)(zr,{ref:i.context.internalBackdropRef,inert:Ht(!s)}),e.children]})}):null}),Vr={},Hr={},Ur=``;function Wr(e){if(typeof document>`u`)return!1;let t=U(e);return f(t).innerWidth-t.documentElement.clientWidth>0}function Gr(e){if(!(typeof CSS<`u`&&CSS.supports&&CSS.supports(`scrollbar-gutter`,`stable`))||typeof document>`u`)return!1;let t=U(e),n=t.documentElement,r=t.body,i=A(n)?n:r,a=i.style.overflowY,o=n.style.scrollbarGutter;n.style.scrollbarGutter=`stable`,i.style.overflowY=`scroll`;let s=i.offsetWidth;i.style.overflowY=`hidden`;let c=i.offsetWidth;return i.style.overflowY=a,n.style.scrollbarGutter=o,s===c}function Kr(e){let t=U(e),n=t.documentElement,r=t.body,i=A(n)?n:r,a={overflowY:i.style.overflowY,overflowX:i.style.overflowX};return Object.assign(i.style,{overflowY:`hidden`,overflowX:`hidden`}),()=>{Object.assign(i.style,a)}}function qr(e){let t=U(e),n=t.documentElement,r=t.body,i=f(n),a=0,o=0,s=!1,c=q.create();if(y&&(i.visualViewport?.scale??1)!==1)return()=>{};function l(){let t=i.getComputedStyle(n),c=i.getComputedStyle(r),l=(t.scrollbarGutter||``).includes(`both-edges`)?`stable both-edges`:`stable`;a=n.scrollTop,o=n.scrollLeft,Vr={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},Ur=n.style.scrollBehavior,Hr={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};let u=n.scrollHeight>n.clientHeight,d=n.scrollWidth>n.clientWidth,f=t.overflowY===`scroll`||c.overflowY===`scroll`,p=t.overflowX===`scroll`||c.overflowX===`scroll`,m=Math.max(0,i.innerWidth-r.clientWidth),h=Math.max(0,i.innerHeight-r.clientHeight),g=parseFloat(c.marginTop)+parseFloat(c.marginBottom),_=parseFloat(c.marginLeft)+parseFloat(c.marginRight),v=A(n)?n:r;if(s=Gr(e),s){n.style.scrollbarGutter=l,v.style.overflowY=`hidden`,v.style.overflowX=`hidden`;return}Object.assign(n.style,{scrollbarGutter:l,overflowY:`hidden`,overflowX:`hidden`}),(u||f)&&(n.style.overflowY=`scroll`),(d||p)&&(n.style.overflowX=`scroll`),Object.assign(r.style,{position:`relative`,height:g||h?`calc(100dvh - ${g+h}px)`:`100dvh`,width:_||m?`calc(100vw - ${_+m}px)`:`100vw`,boxSizing:`border-box`,overflow:`hidden`,scrollBehavior:`unset`}),r.scrollTop=a,r.scrollLeft=o,n.setAttribute(`data-base-ui-scroll-locked`,``),n.style.scrollBehavior=`unset`}function u(){Object.assign(n.style,Vr),Object.assign(r.style,Hr),s||(n.scrollTop=a,n.scrollLeft=o,n.removeAttribute(`data-base-ui-scroll-locked`),n.style.scrollBehavior=Ur)}function d(){u(),c.request(l)}l();let p=g(i,`resize`,d);return()=>{c.cancel(),u(),typeof i.removeEventListener==`function`&&p()}}var Jr=new class{lockCount=0;restore=null;timeoutLock=te.create();timeoutUnlock=te.create();acquire(e){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(e)),this.release}release=()=>{--this.lockCount,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(e){if(this.lockCount===0||this.restore!==null)return;let t=U(e).documentElement,n=f(t).getComputedStyle(t).overflowY;if(n===`hidden`||n===`clip`){this.restore=T;return}let r=F||!Wr(e);this.restore=r?Kr(e):qr(e)}};function Yr(e=!0,t=null){m(()=>{if(e)return Jr.acquire(t)},[e,t])}function Xr(e){let t=Y.useRef(``),n=Y.useCallback(n=>{n.defaultPrevented||(t.current=n.pointerType,e(n,n.pointerType))},[e]);return{onClick:Y.useCallback(n=>{if(n.detail===0){e(n,`keyboard`);return}`pointerType`in n?e(n,n.pointerType):e(n,t.current),t.current=``},[e]),onPointerDown:n}}function Zr(e,t){let n=Y.useRef(e),r=_(t);m(()=>{n.current!==e&&r(n.current)},[e,r]),m(()=>{n.current=e},[e])}function Qr(e){let[t,n]=Y.useState(null),r=_((t,r)=>{e||n(r||(F?`touch`:``))});Zr(e,t=>{t&&!e&&n(null)});let{onClick:i,onPointerDown:a}=Xr(r);return Y.useMemo(()=>({openMethod:t,triggerProps:{onClick:i,onPointerDown:a}}),[t,i,a])}function $r(e){let{store:n,parentContext:r,actionsRef:i,isDrawer:a}=e,o=n.useState(`open`),s=n.useState(`disablePointerDismissal`),c=n.useState(`modal`),l=n.useState(`popupElement`),{openMethod:u,triggerProps:d}=Qr(o);Ye(n);let{forceUnmount:f}=Fe(o,n),p=Y.useCallback(()=>{n.setOpen(!1,W(xe))},[n]);Y.useImperativeHandle(i,()=>({unmount:f,close:p}),[f,p]);let m=Ue({popupStore:n,onOpenChange:n.setOpen,treatPopupAsFloatingElement:!0}),[h,g]=Y.useState(0),[_,v]=Y.useState(0),y=h===0,b=Vt(m),x=Ze(m,{outsidePressEvent(){return n.context.internalBackdropRef.current||n.context.backdropRef.current?`intentional`:{mouse:c===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}},outsidePress(e){if(!n.context.outsidePressEnabledRef.current||`button`in e&&e.button!==0||`touches`in e&&e.touches.length!==1)return!1;let r=t(e);if(y&&!s){let e=r;return c&&(n.context.internalBackdropRef.current||n.context.backdropRef.current)?n.context.internalBackdropRef.current===e||n.context.backdropRef.current===e||V(e,l)&&!e?.hasAttribute(`data-base-ui-portal`):!0}return!1},escapeKey:y});Yr(o&&c===!0,l);let{getReferenceProps:S,getFloatingProps:C,getTriggerProps:w}=je([b,x]);n.useContextCallback(`onNestedDialogOpen`,(e,t)=>{g(e),v(t)}),n.useContextCallback(`onNestedDialogClose`,()=>{g(0),v(0)}),Y.useEffect(()=>(r?.onNestedDialogOpen&&o&&r.onNestedDialogOpen(h+1,_+ +!!a),r?.onNestedDialogClose&&!o&&r.onNestedDialogClose(),()=>{r?.onNestedDialogClose&&o&&r.onNestedDialogClose()}),[a,o,h,_,r]);let T=Y.useMemo(()=>S(d),[S,d]),E=Y.useMemo(()=>w(d),[w,d]),D=Y.useMemo(()=>C(),[C]);n.useSyncedValues({openMethod:u,activeTriggerProps:T,inactiveTriggerProps:E,popupProps:D,floatingRootContext:m,nestedOpenDialogCount:h,nestedOpenDrawerCount:_})}var ei={...Pe,modal:Me(e=>e.modal),nested:Me(e=>e.nested),nestedOpenDialogCount:Me(e=>e.nestedOpenDialogCount),nestedOpenDrawerCount:Me(e=>e.nestedOpenDrawerCount),disablePointerDismissal:Me(e=>e.disablePointerDismissal),openMethod:Me(e=>e.openMethod),descriptionElementId:Me(e=>e.descriptionElementId),titleElementId:Me(e=>e.titleElementId),viewportElement:Me(e=>e.viewportElement),role:Me(e=>e.role)},ti=class e extends Qe{constructor(e){super(ni(e),{popupRef:Y.createRef(),backdropRef:Y.createRef(),internalBackdropRef:Y.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:new Ve,onOpenChange:void 0,onOpenChangeComplete:void 0},ei)}setOpen=(e,t)=>{if(t.preventUnmountOnClose=()=>{this.set(`preventUnmountingOnClose`,!0)},!e&&t.trigger==null&&this.state.activeTriggerId!=null&&(t.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let n={open:e},r=t.trigger?.id??null;(r||e)&&(n.activeTriggerId=r,n.activeTriggerElement=t.trigger??null),this.update(n)};static useStore(t,r){let i=n(()=>new e(r)).current;return t??i}};function ni(e={}){return{...qe(),modal:!0,disablePointerDismissal:!1,popupElement:null,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:`dialog`,...e}}var ri=Y.createContext(!1);function ii(e){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,disablePointerDismissal:o=!1,modal:s=!0,actionsRef:c,handle:l,triggerId:u,defaultTriggerId:d=null}=e,f=dr(!0),p=Y.useContext(ri),m=!!f,h=ti.useStore(l?.store,{open:r,openProp:n,activeTriggerId:d,triggerIdProp:u,modal:s,disablePointerDismissal:o,nested:m});Oe(()=>{n===void 0&&h.state.open===!1&&r===!0&&h.update({open:!0,activeTriggerId:d})}),h.useControlledProp(`openProp`,n),h.useControlledProp(`triggerIdProp`,u),h.useSyncedValues({disablePointerDismissal:o,nested:m,modal:s}),h.useContextCallback(`onOpenChange`,i),h.useContextCallback(`onOpenChangeComplete`,a);let g=h.useState(`payload`);$r({store:h,actionsRef:c,parentContext:f?.store.context,isDrawer:p,onOpenChange:i,triggerIdProp:u});let _=Y.useMemo(()=>({store:h}),[h]);return(0,X.jsx)(ri.Provider,{value:!1,children:(0,X.jsx)(ur.Provider,{value:_,children:typeof t==`function`?t({payload:g}):t})})}var ai=Y.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,{store:s}=dr(),u=c(a);return s.useSyncedValueWithCleanup(`titleElementId`,u),l(`h2`,e,{ref:t,props:[{id:u},o]})});function oi(e){let t=(0,$.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,X.jsx)(ii,{"data-slot":`dialog`,...n}),t[2]=n,t[3]=r),r}function si(e){let t=(0,$.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,X.jsx)(Br,{"data-slot":`dialog-portal`,...n}),t[2]=n,t[3]=r),r}function ci(t){let n=(0,$.c)(8),r,i;n[0]===t?(r=n[1],i=n[2]):({className:r,...i}=t,n[0]=t,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=e(`fixed inset-0 isolate z-50 bg-black/80 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==a?(o=(0,X.jsx)(pr,{"data-slot":`dialog-overlay`,className:a,...i}),n[5]=i,n[6]=a,n[7]=o):o=n[7],o}function li(t){let n=(0,$.c)(15),r,i,a,o;n[0]===t?(r=n[1],i=n[2],a=n[3],o=n[4]):({className:i,children:r,showCloseButton:o,...a}=t,n[0]=t,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s=o===void 0?!0:o,c;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,X.jsx)(ci,{}),n[5]=c):c=n[5];let l;n[6]===i?l=n[7]:(l=e(`fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-xs/relaxed text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,i),n[6]=i,n[7]=l);let u;n[8]===s?u=n[9]:(u=s&&(0,X.jsxs)(mr,{"data-slot":`dialog-close`,render:(0,X.jsx)(H,{variant:`ghost`,className:`absolute top-2 right-2`,size:`icon-sm`}),children:[(0,X.jsx)(it,{}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Close`})]}),n[8]=s,n[9]=u);let d;return n[10]!==r||n[11]!==a||n[12]!==l||n[13]!==u?(d=(0,X.jsxs)(si,{children:[c,(0,X.jsxs)(Rr,{"data-slot":`dialog-content`,className:l,...a,children:[r,u]})]}),n[10]=r,n[11]=a,n[12]=l,n[13]=u,n[14]=d):d=n[14],d}function ui(t){let n=(0,$.c)(8),r,i;n[0]===t?(r=n[1],i=n[2]):({className:r,...i}=t,n[0]=t,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=e(`flex flex-col gap-1`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==a?(o=(0,X.jsx)(`div`,{"data-slot":`dialog-header`,className:a,...i}),n[5]=i,n[6]=a,n[7]=o):o=n[7],o}function di(t){let n=(0,$.c)(14),r,i,a,o;n[0]===t?(r=n[1],i=n[2],a=n[3],o=n[4]):({className:i,showCloseButton:o,children:r,...a}=t,n[0]=t,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s=o===void 0?!1:o,c;n[5]===i?c=n[6]:(c=e(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,i),n[5]=i,n[6]=c);let l;n[7]===s?l=n[8]:(l=s&&(0,X.jsx)(mr,{render:(0,X.jsx)(H,{variant:`outline`}),children:`Close`}),n[7]=s,n[8]=l);let u;return n[9]!==r||n[10]!==a||n[11]!==c||n[12]!==l?(u=(0,X.jsxs)(`div`,{"data-slot":`dialog-footer`,className:c,...a,children:[r,l]}),n[9]=r,n[10]=a,n[11]=c,n[12]=l,n[13]=u):u=n[13],u}function fi(t){let n=(0,$.c)(8),r,i;n[0]===t?(r=n[1],i=n[2]):({className:r,...i}=t,n[0]=t,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=e(`font-heading text-sm font-medium`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==a?(o=(0,X.jsx)(ai,{"data-slot":`dialog-title`,className:a,...i}),n[5]=i,n[6]=a,n[7]=o):o=n[7],o}function pi(t){let n=(0,$.c)(8),r,i;n[0]===t?(r=n[1],i=n[2]):({className:r,...i}=t,n[0]=t,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=e(`flex items-center gap-2 text-xs/relaxed leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==a?(o=(0,X.jsx)(`label`,{"data-slot":`label`,className:a,...i}),n[5]=i,n[6]=a,n[7]=o):o=n[7],o}function mi(t){let n=(0,$.c)(8),r,i;n[0]===t?(r=n[1],i=n[2]):({className:r,...i}=t,n[0]=t,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=e(`group/field-group @container/field-group flex w-full flex-col gap-4 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==a?(o=(0,X.jsx)(`div`,{"data-slot":`field-group`,className:a,...i}),n[5]=i,n[6]=a,n[7]=o):o=n[7],o}var hi=u(`group/field flex w-full gap-2 data-[invalid=true]:text-destructive`,{variants:{orientation:{vertical:`flex-col *:w-full [&>.sr-only]:w-auto`,horizontal:`flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px`,responsive:`flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px`}},defaultVariants:{orientation:`vertical`}});function gi(t){let n=(0,$.c)(11),r,i,a;n[0]===t?(r=n[1],i=n[2],a=n[3]):({className:r,orientation:a,...i}=t,n[0]=t,n[1]=r,n[2]=i,n[3]=a);let o=a===void 0?`vertical`:a,s;n[4]!==r||n[5]!==o?(s=e(hi({orientation:o}),r),n[4]=r,n[5]=o,n[6]=s):s=n[6];let c;return n[7]!==o||n[8]!==i||n[9]!==s?(c=(0,X.jsx)(`fieldset`,{"data-slot":`field`,"data-orientation":o,className:s,...i}),n[7]=o,n[8]=i,n[9]=s,n[10]=c):c=n[10],c}function _i(t){let n=(0,$.c)(8),r,i;n[0]===t?(r=n[1],i=n[2]):({className:r,...i}=t,n[0]=t,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=e(`group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border *:data-[slot=field]:p-2 dark:has-data-checked:bg-primary/10`,`has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==a?(o=(0,X.jsx)(pi,{"data-slot":`field-label`,className:a,...i}),n[5]=i,n[6]=a,n[7]=o):o=n[7],o}function vi(t){let n=(0,$.c)(15),r,i,a,o;n[0]===t?(r=n[1],i=n[2],a=n[3],o=n[4]):({className:i,children:r,errors:a,...o}=t,n[0]=t,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s;bb0:{if(r){s=r;break bb0}if(!a?.length){s=null;break bb0}let e;n[5]===a?e=n[6]:(e=[...new Map(a.map(bi)).values()],n[5]=a,n[6]=e);let t=e;if(t?.length===1){s=t[0]?.message;break bb0}let i;n[7]===t?i=n[8]:(i=(0,X.jsx)(`ul`,{className:`ml-4 flex list-disc flex-col gap-1`,children:t.map(yi)}),n[7]=t,n[8]=i),s=i}let c=s;if(!c)return null;let l;n[9]===i?l=n[10]:(l=e(`text-xs/relaxed font-normal text-destructive`,i),n[9]=i,n[10]=l);let u;return n[11]!==c||n[12]!==o||n[13]!==l?(u=(0,X.jsx)(`div`,{role:`alert`,"data-slot":`field-error`,className:l,...o,children:c}),n[11]=c,n[12]=o,n[13]=l,n[14]=u):u=n[14],u}function yi(e){return e?.message&&(0,X.jsx)(`li`,{children:e.message},e.message)}function bi(e){return[e?.message,e]}var xi=function(e){return e.disabled=`data-disabled`,e.valid=`data-valid`,e.invalid=`data-invalid`,e.touched=`data-touched`,e.dirty=`data-dirty`,e.filled=`data-filled`,e.focused=`data-focused`,e}({}),Si={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},Ci={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},wi={disabled:!1,...Ci},Ti={valid(e){return e===null?null:e?{[xi.valid]:``}:{[xi.invalid]:``}}},Ei=Y.createContext({invalid:void 0,name:void 0,validityData:{state:Si,errors:[],error:``,value:``,initialValue:null},setValidityData:T,disabled:void 0,touched:Ci.touched,setTouched:T,dirty:Ci.dirty,setDirty:T,filled:Ci.filled,setFilled:T,focused:Ci.focused,setFocused:T,validate:()=>null,validationMode:`onSubmit`,validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:wi,markedDirtyRef:{current:!1},registerFieldControl:T,validation:{getValidationProps:(e=z)=>e,getInputValidationProps:(e=z)=>e,inputRef:{current:null},commit:async()=>{}}});function Di(e=!0){let t=Y.useContext(Ei);if(t.setValidityData===T&&!e)throw Error(B(28));return t}var Oi=Y.createContext({controlId:void 0,registerControlId:T,labelId:void 0,setLabelId:T,messageIds:[],setMessageIds:T,getDescriptionProps:e=>e});function ki(){return Y.useContext(Oi)}function Ai(e={}){let{id:t,implicit:r=!1,controlRef:i}=e,{controlId:a,registerControlId:o}=ki(),s=c(t),l=r?a:void 0,u=n(()=>Symbol(`labelable-control`)),d=Y.useRef(!1),f=Y.useRef(t!=null),p=_(()=>{!d.current||o===T||(d.current=!1,o(u.current,void 0))});return m(()=>{if(o===T)return;let e;if(r){let n=i?.current;e=E(n)&&n.closest(`label`)!=null?t??null:l??s}else if(t!=null)f.current=!0,e=t;else if(f.current)e=s;else{p();return}if(e===void 0){p();return}d.current=!0,o(u.current,e)},[t,i,l,o,r,s,u,p]),Y.useEffect(()=>p,[p]),a??s}function ji(e,t){let{enabled:n=!0,getValue:r,id:i,value:a}=t,{registerFieldControl:o}=Di(),s=Y.useRef(null);s.current||=Symbol(),m(()=>{let t=s.current;if(!(!t||!n))return o(t,{controlRef:e,getValue:r,id:i,value:a}),()=>{o(t,void 0)}},[e,n,r,i,o,a])}var Mi=Y.forwardRef(function(e,t){let{render:n,className:r,id:i,name:a,value:o,disabled:s=!1,onValueChange:c,defaultValue:u,autoFocus:d=!1,style:f,...h}=e,{state:g,name:v,disabled:y,setTouched:b,setDirty:x,validityData:S,setFocused:C,setFilled:w,validationMode:T,validation:E}=Di(),D=y||s,O=v??a,k={...g,disabled:D},{labelId:A}=ki(),j=Ai({id:i});m(()=>{let e=o!=null;E.inputRef.current?.value||e&&o!==``?w(!0):e&&o===``&&w(!1)},[E.inputRef,w,o]);let M=Y.useRef(null);m(()=>{d&&M.current===p(U(M.current))&&C(!0)},[d,C]);let[N]=Wn({controlled:o,default:u,name:`FieldControl`,state:`value`}),P=o!==void 0,F=P?N:void 0,I=_(()=>E.inputRef.current?.value);return ji(E.inputRef,{id:j,value:F,getValue:I}),l(`input`,e,{ref:[t,M],state:k,props:[{id:j,disabled:D,name:O,ref:E.inputRef,"aria-labelledby":A,autoFocus:d,...P?{value:F}:{defaultValue:u},onChange(e){let t=e.currentTarget.value;c?.(t,W(K,e.nativeEvent)),x(t!==S.initialValue),w(t!==``)},onFocus(){C(!0)},onBlur(e){b(!0),C(!1),T===`onBlur`&&E.commit(e.currentTarget.value)},onKeyDown(e){e.currentTarget.tagName===`INPUT`&&e.key===`Enter`&&(b(!0),E.commit(e.currentTarget.value))}},E.getInputValidationProps(),h],stateAttributesMapping:Ti})}),Ni=Y.forwardRef(function(e,t){return(0,X.jsx)(Mi,{ref:t,...e})});function Pi(t){let n=(0,$.c)(10),r,i,a;n[0]===t?(r=n[1],i=n[2],a=n[3]):({className:r,type:a,...i}=t,n[0]=t,n[1]=r,n[2]=i,n[3]=a);let o;n[4]===r?o=n[5]:(o=e(`h-7 w-full min-w-0 rounded-md border border-input bg-input/20 px-2 py-0.5 text-sm transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-xs/relaxed file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 md:text-xs/relaxed dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,r),n[4]=r,n[5]=o);let s;return n[6]!==i||n[7]!==o||n[8]!==a?(s=(0,X.jsx)(Ni,{type:a,"data-slot":`input`,className:o,...i}),n[6]=i,n[7]=o,n[8]=a,n[9]=s):s=n[9],s}function Fi(t){let n=(0,$.c)(14),r,i,a;n[0]===t?(r=n[1],i=n[2],a=n[3]):({className:r,size:a,...i}=t,n[0]=t,n[1]=r,n[2]=i,n[3]=a);let o=a===void 0?`default`:a,s;n[4]===r?s=n[5]:(s=e(`group/native-select relative w-fit has-[select:disabled]:opacity-50`,r),n[4]=r,n[5]=s);let c;n[6]!==i||n[7]!==o?(c=(0,X.jsx)(`select`,{"data-slot":`native-select`,"data-size":o,className:`h-7 w-full min-w-0 appearance-none rounded-md border border-input bg-input/20 py-0.5 pr-6 pl-2 text-xs/relaxed transition-colors outline-none select-none selection:bg-primary selection:text-primary-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 disabled:pointer-events-none disabled:cursor-not-allowed aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 data-[size=sm]:h-6 data-[size=sm]:text-[0.625rem] dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,...i}),n[6]=i,n[7]=o,n[8]=c):c=n[8];let l;n[9]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,X.jsx)(Gt,{className:`pointer-events-none absolute top-1/2 right-1.5 size-3.5 -translate-y-1/2 text-muted-foreground select-none group-data-[size=sm]/native-select:size-3`,"aria-hidden":`true`,"data-slot":`native-select-icon`}),n[9]=l):l=n[9];let u;return n[10]!==o||n[11]!==s||n[12]!==c?(u=(0,X.jsxs)(`div`,{className:s,"data-slot":`native-select-wrapper`,"data-size":o,children:[c,l]}),n[10]=o,n[11]=s,n[12]=c,n[13]=u):u=n[13],u}function Ii(t){let n=(0,$.c)(8),r,i;n[0]===t?(r=n[1],i=n[2]):({className:r,...i}=t,n[0]=t,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=e(`bg-[Canvas] text-[CanvasText]`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==a?(o=(0,X.jsx)(`option`,{"data-slot":`native-select-option`,className:a,...i}),n[5]=i,n[6]=a,n[7]=o):o=n[7],o}function Li(e){let[t,n]=(0,Y.useState)([]),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(!1);return(0,Y.useEffect)(()=>{let t=!1;return a(!0),w(e).then(e=>{t||n(e)}).catch(()=>{t||r.error(`Failed to load history`)}).finally(()=>{t||a(!1)}),()=>{t=!0}},[e]),{versions:t,isLoading:i,reverting:o,revert:async t=>{s(!0);try{return await S(e,t),await I.invalidateQueries({queryKey:[`memories`]}),n(await w(e)),!0}catch{return r.error(`Failed to revert — try again`),!1}finally{s(!1)}}}}function Ri(e,t){let n=(0,$.c)(27),i,a;n[0]===e?(i=n[1],a=n[2]):(i=t=>t.from({m:ee}).where(t=>{let{m:n}=t;return h(n.id,e)}),a=[e],n[0]=e,n[1]=i,n[2]=a);let{data:o,isLoading:s}=ne(i,a),c;n[3]===o?c=n[4]:(c=o===void 0?[]:o,n[3]=o,n[4]=c);let l=c[0]??null,u;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=[],n[5]=u):u=n[5];let{data:d}=ne(Vi,u),f;n[6]===d?f=n[7]:(f=d===void 0?[]:d,n[6]=d,n[7]=f);let p=f,m;n[8]===e?m=n[9]:(m=()=>{O(e,{needsReview:!1}).then(Bi)},n[8]=e,n[9]=m);let g=m,_;n[10]===e?_=n[11]:(_=async t=>{try{return await b(e,t),await I.invalidateQueries({queryKey:[`memories`]}),!0}catch{return r.error(`Failed to add project — try again`),!1}},n[10]=e,n[11]=_);let y=_,x;n[12]===e?x=n[13]:(x=async t=>{try{await v(e,t),await I.invalidateQueries({queryKey:[`memories`]})}catch{r.error(`Failed to remove project — try again`)}},n[12]=e,n[13]=x);let S=x,C=zi,w;if(n[14]!==p||n[15]!==l?.projects){let e;n[17]===l?.projects?e=n[18]:(e=e=>!l?.projects.some(t=>t.id===e.id),n[17]=l?.projects,n[18]=e),w=p.filter(e),n[14]=p,n[15]=l?.projects,n[16]=w}else w=n[16];let T=w,E;return n[19]!==T||n[20]!==y||n[21]!==g||n[22]!==S||n[23]!==s||n[24]!==l||n[25]!==t?(E={memory:l,isLoading:s,availableProjects:T,handleApprove:g,handleAddProject:y,handleRemoveProject:S,handleDeleteConflicting:C,handleClose:t},n[19]=T,n[20]=y,n[21]=g,n[22]=S,n[23]=s,n[24]=l,n[25]=t,n[26]=E):E=n[26],E}async function zi(e){try{await L(e),await I.invalidateQueries({queryKey:[`memories`]})}catch{r.error(`Failed to delete — try again`)}}function Bi(){return I.invalidateQueries({queryKey:[`memories`]})}function Vi(e){return e.from({p:N})}var Hi=ot({content:nt().min(1,`Content is required.`),type:ct(rt),tagsInput:nt()});function Ui(e){let t=(0,$.c)(18),{version:n,reverting:r,onConfirm:i,onClose:a}=e,o;t[0]===n.version?o=t[1]:(o=(0,X.jsx)(ui,{children:(0,X.jsxs)(fi,{children:[`Revert to version `,n.version,`?`]})}),t[0]=n.version,t[1]=o);let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The current content will be archived as a new version before restoring this snapshot.`}),t[2]=s):s=t[2];let c;t[3]===n.content?c=t[4]:(c=(0,X.jsx)(`pre`,{className:`text-[11px] font-mono whitespace-pre-wrap rounded border border-border bg-muted px-2 py-1.5 max-h-40 overflow-y-auto`,children:n.content}),t[3]=n.content,t[4]=c);let l;t[5]===a?l=t[6]:(l=(0,X.jsx)(H,{variant:`outline`,size:`sm`,onClick:a,children:`Cancel`}),t[5]=a,t[6]=l);let u=r?`Reverting…`:`Revert`,d;t[7]!==i||t[8]!==r||t[9]!==u?(d=(0,X.jsx)(H,{variant:`default`,size:`sm`,disabled:r,onClick:i,children:u}),t[7]=i,t[8]=r,t[9]=u,t[10]=d):d=t[10];let f;t[11]!==l||t[12]!==d?(f=(0,X.jsxs)(di,{children:[l,d]}),t[11]=l,t[12]=d,t[13]=f):f=t[13];let p;return t[14]!==o||t[15]!==c||t[16]!==f?(p=(0,X.jsxs)(li,{children:[o,s,c,f]}),t[14]=o,t[15]=c,t[16]=f,t[17]=p):p=t[17],p}function Wi(e){let t=(0,$.c)(23),{memoryId:n}=e,{versions:r,isLoading:i,reverting:a,revert:o}=Li(n),[s,c]=(0,Y.useState)(null),l;t[0]!==o||t[1]!==s?(l=async()=>{s&&await o(s.version)&&c(null)},t[0]=o,t[1]=s,t[2]=l):l=t[2];let u=l;if(!i&&r.length===0)return null;let d=s!==null,f;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(f=e=>!e&&c(null),t[3]=f):f=t[3];let p;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,X.jsx)(`span`,{className:`transition-transform group-data-[open]:rotate-90`,children:`›`}),t[4]=p):p=t[4];let m=r.length>0?` (${r.length})`:``,h;t[5]===m?h=t[6]:(h=(0,X.jsxs)(cr,{className:`flex items-center gap-1 cursor-pointer text-[11px] uppercase tracking-wide text-muted-foreground hover:text-foreground transition-colors select-none w-full`,children:[p,`History`,m]}),t[5]=m,t[6]=h);let g;t[7]!==i||t[8]!==r?(g=i?(0,X.jsx)(`p`,{className:`text-[11px] font-mono text-muted-foreground`,children:`Loading…`}):r.map(e=>(0,X.jsxs)(`button`,{type:`button`,className:`w-full text-left rounded border border-border px-2 py-1.5 space-y-0.5 hover:bg-muted transition-colors`,onClick:()=>c(e),children:[(0,X.jsxs)(`div`,{className:`flex justify-between text-[11px] font-mono text-muted-foreground`,children:[(0,X.jsxs)(`span`,{className:`font-medium text-foreground`,children:[`v`,e.version]}),(0,X.jsx)(`span`,{children:new Date(e.createdAt).toLocaleString()})]}),(0,X.jsx)(`p`,{className:`text-[11px] font-mono text-muted-foreground truncate`,children:e.content.slice(0,80)})]},e.version)),t[7]=i,t[8]=r,t[9]=g):g=t[9];let _;t[10]===g?_=t[11]:(_=(0,X.jsx)(lr,{className:`space-y-1 mt-2`,children:g}),t[10]=g,t[11]=_);let v;t[12]!==h||t[13]!==_?(v=(0,X.jsxs)(sr,{className:`group pt-2 border-t border-border`,children:[h,_]}),t[12]=h,t[13]=_,t[14]=v):v=t[14];let y;t[15]!==u||t[16]!==a||t[17]!==s?(y=s!==null&&(0,X.jsx)(Ui,{version:s,reverting:a,onConfirm:()=>void u(),onClose:()=>c(null)}),t[15]=u,t[16]=a,t[17]=s,t[18]=y):y=t[18];let b;return t[19]!==y||t[20]!==d||t[21]!==v?(b=(0,X.jsxs)(oi,{open:d,onOpenChange:f,children:[v,y]}),t[19]=y,t[20]=d,t[21]=v,t[22]=b):b=t[22],b}function Gi(e){let t=(0,$.c)(12),{field:n,label:r,description:i,children:a}=e,o=n.state.meta.isTouched&&!n.state.meta.isValid,s;t[0]!==n.name||t[1]!==r?(s=(0,X.jsx)(_i,{htmlFor:n.name,className:`text-[11px] uppercase tracking-wide text-muted-foreground`,children:r}),t[0]=n.name,t[1]=r,t[2]=s):s=t[2];let c;t[3]!==n.state.meta.errors||t[4]!==o?(c=o&&(0,X.jsx)(vi,{errors:n.state.meta.errors}),t[3]=n.state.meta.errors,t[4]=o,t[5]=c):c=t[5];let l;return t[6]!==a||t[7]!==i||t[8]!==o||t[9]!==s||t[10]!==c?(l=(0,X.jsxs)(gi,{"data-invalid":o,children:[s,a,i,c]}),t[6]=a,t[7]=i,t[8]=o,t[9]=s,t[10]=c,t[11]=l):l=t[11],l}function Ki(e){let t=(0,$.c)(117),{memory:n,availableProjects:r,handleApprove:i,handleAddProject:a,handleRemoveProject:o,handleDeleteConflicting:s,handleClose:c}=e,[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(``),p,m;t[0]===l?(p=t[1],m=t[2]):(p=()=>{if(!l)return;let e=setTimeout(()=>u(!1),1500);return()=>clearTimeout(e)},m=[l],t[0]=l,t[1]=p,t[2]=m),(0,Y.useEffect)(p,m);let h=n.content,g=n.type,_;t[3]===n.tags?_=t[4]:(_=n.tags.join(`, `),t[3]=n.tags,t[4]=_);let v;t[5]!==n.content||t[6]!==n.type||t[7]!==_?(v={content:h,type:g,tagsInput:_},t[5]=n.content,t[6]=n.type,t[7]=_,t[8]=v):v=t[8];let y;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(y={onSubmit:Hi},t[9]=y):y=t[9];let b;t[10]!==n.content||t[11]!==n.id||t[12]!==n.tags||t[13]!==n.type?(b=e=>{let{value:t}=e,r=t.tagsInput.split(`,`).map(Qi).filter(Boolean);ee.update(n.id,e=>{t.content!==n.content&&(e.content=t.content),t.type!==n.type&&(e.type=t.type),JSON.stringify(r)!==JSON.stringify(n.tags)&&(e.tags=r)}),u(!0)},t[10]=n.content,t[11]=n.id,t[12]=n.tags,t[13]=n.type,t[14]=b):b=t[14];let x;t[15]!==v||t[16]!==b?(x={defaultValues:v,validators:y,onSubmit:b},t[15]=v,t[16]=b,t[17]=x):x=t[17];let S=Un(x),C;t[18]===S.state.isDirty?C=t[19]:(C={shouldBlockFn:()=>S.state.isDirty,withResolver:!0},t[18]=S.state.isDirty,t[19]=C);let w=gt(C),T;t[20]!==d||t[21]!==a?(T=async()=>{d&&await a(d)&&f(``)},t[20]=d,t[21]=a,t[22]=T):T=t[22];let E=T,D;t[23]===n.type?D=t[24]:(D=(0,X.jsx)(oe,{variant:n.type,children:n.type}),t[23]=n.type,t[24]=D);let O;t[25]===n.reviewEvents.length?O=t[26]:(O=n.reviewEvents.length>0&&(0,X.jsx)(oe,{variant:`destructive`,title:`Flagged for review — possible duplicate or conflict with another memory`,children:`needs review`}),t[25]=n.reviewEvents.length,t[26]=O);let k;t[27]===n.pinned?k=t[28]:(k=n.pinned&&(0,X.jsx)(oe,{variant:`default`,children:`pinned`}),t[27]=n.pinned,t[28]=k);let A;t[29]!==D||t[30]!==O||t[31]!==k?(A=(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[D,O,k]}),t[29]=D,t[30]=O,t[31]=k,t[32]=A):A=t[32];let j;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,X.jsx)(at,{weight:`regular`}),t[33]=j):j=t[33];let M;t[34]===c?M=t[35]:(M=(0,X.jsx)(H,{variant:`ghost`,size:`icon-sm`,onClick:c,"aria-label":`Close`,children:j}),t[34]=c,t[35]=M);let N;t[36]!==A||t[37]!==M?(N=(0,X.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2.5 border-b border-border shrink-0`,children:[A,M]}),t[36]=A,t[37]=M,t[38]=N):N=t[38];let P;t[39]===S.Field?P=t[40]:(P=(0,X.jsx)(S.Field,{name:`content`,children:Zi}),t[39]=S.Field,t[40]=P);let F;t[41]===S.Field?F=t[42]:(F=(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,X.jsx)(S.Field,{name:`type`,children:Yi}),(0,X.jsx)(S.Field,{name:`tagsInput`,children:Ji})]}),t[41]=S.Field,t[42]=F);let I;t[43]!==P||t[44]!==F?(I=(0,X.jsxs)(mi,{children:[P,F]}),t[43]=P,t[44]=F,t[45]=I):I=t[45];let L;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,X.jsx)(`p`,{className:`text-[11px] uppercase tracking-wide text-muted-foreground font-mono`,children:`Projects`}),t[46]=L):L=t[46];let R;t[47]===n.projects.length?R=t[48]:(R=n.projects.length===0&&(0,X.jsx)(`span`,{className:`text-[11px] font-mono text-muted-foreground`,children:`Global (no project)`}),t[47]=n.projects.length,t[48]=R);let z;if(t[49]!==o||t[50]!==n.projects){let e;t[52]===o?e=t[53]:(e=e=>(0,X.jsxs)(oe,{variant:`secondary`,className:`gap-1 rounded-full text-[11px]`,children:[e.name,(0,X.jsx)(`button`,{type:`button`,onClick:()=>void o(e.id),className:`hover:text-destructive transition-colors leading-none`,"aria-label":`Remove from ${e.name}`,children:(0,X.jsx)(at,{weight:`regular`,className:`size-2.5`})})]},e.id),t[52]=o,t[53]=e),z=n.projects.map(e),t[49]=o,t[50]=n.projects,t[51]=z}else z=t[51];let te;t[54]!==R||t[55]!==z?(te=(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[R,z]}),t[54]=R,t[55]=z,t[56]=te):te=t[56];let ne;t[57]!==d||t[58]!==r||t[59]!==E?(ne=r.length>0&&(0,X.jsxs)(`div`,{className:`flex gap-1`,children:[(0,X.jsxs)(Fi,{value:d,onChange:e=>f(e.target.value),size:`sm`,className:`flex-1`,children:[(0,X.jsx)(Ii,{value:``,children:`Add to project…`}),r.map(qi)]}),(0,X.jsx)(H,{variant:`outline`,size:`sm`,disabled:!d,onClick:()=>void E(),children:`+`})]}),t[57]=d,t[58]=r,t[59]=E,t[60]=ne):ne=t[60];let re;t[61]!==te||t[62]!==ne?(re=(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[L,te,ne]}),t[61]=te,t[62]=ne,t[63]=re):re=t[63];let B;t[64]!==s||t[65]!==n.reviewEvents?(B=n.reviewEvents.length>0&&(0,X.jsxs)(sr,{defaultOpen:!0,className:`group pt-2 border-t border-border`,children:[(0,X.jsxs)(cr,{className:`flex items-center gap-1 cursor-pointer text-[11px] uppercase tracking-wide text-muted-foreground hover:text-foreground transition-colors select-none w-full`,children:[(0,X.jsx)(`span`,{className:`transition-transform group-data-[open]:rotate-90`,children:`›`}),`Review reasons`]}),(0,X.jsx)(lr,{className:`space-y-2 mt-2`,children:n.reviewEvents.map(e=>(0,X.jsxs)(`div`,{className:`rounded border border-border p-2 space-y-1 text-[11px]`,children:[(0,X.jsxs)(`div`,{className:`flex justify-between text-muted-foreground`,children:[(0,X.jsxs)(`span`,{className:`font-medium text-destructive`,children:[Math.round(e.similarity*100),`% similarity match`]}),(0,X.jsx)(`span`,{children:new Date(e.createdAt).toLocaleString()})]}),e.conflictingMemoryId?(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsxs)(`div`,{className:`text-muted-foreground font-mono min-w-0`,children:[`Conflicting:`,` `,(0,X.jsx)(`span`,{className:`font-mono text-[10px]`,children:e.conflictingMemoryId})]}),(0,X.jsx)(H,{variant:`ghost`,size:`sm`,className:`text-destructive hover:text-destructive shrink-0 h-5 px-1.5 text-[10px]`,onClick:()=>{let t=e.conflictingMemoryId;t&&s(t)},children:`Delete conflicting`})]}):(0,X.jsx)(`div`,{className:`text-muted-foreground italic`,children:`Conflicting memory deleted`}),e.conflictContentSnapshot&&(0,X.jsxs)(sr,{children:[(0,X.jsx)(cr,{className:`text-muted-foreground hover:text-foreground transition-colors cursor-pointer`,children:`Show conflicting content ›`}),(0,X.jsx)(lr,{children:(0,X.jsx)(`p`,{className:`mt-1 text-foreground bg-muted rounded px-2 py-1 whitespace-pre-wrap font-mono`,children:e.conflictContentSnapshot})})]})]},e.id))})]}),t[64]=s,t[65]=n.reviewEvents,t[66]=B):B=t[66];let ie;t[67]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,X.jsxs)(cr,{className:`flex items-center gap-1 cursor-pointer text-[11px] uppercase tracking-wide text-muted-foreground hover:text-foreground transition-colors select-none w-full`,children:[(0,X.jsx)(`span`,{className:`transition-transform group-data-[open]:rotate-90`,children:`›`}),`Details`]}),t[67]=ie):ie=t[67];let V;t[68]===n.sourceHarness?V=t[69]:(V=n.sourceHarness&&(0,X.jsxs)(`div`,{className:`flex justify-between text-[11px] font-mono text-muted-foreground`,children:[(0,X.jsx)(`span`,{children:`Source`}),(0,X.jsx)(`span`,{children:n.sourceHarness})]}),t[68]=n.sourceHarness,t[69]=V);let ae;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,X.jsx)(`span`,{children:`Accessed`}),t[70]=ae):ae=t[70];let se;t[71]===n.accessCount?se=t[72]:(se=(0,X.jsxs)(`div`,{className:`flex justify-between text-[11px] font-mono text-muted-foreground`,children:[ae,(0,X.jsxs)(`span`,{children:[n.accessCount,`×`]})]}),t[71]=n.accessCount,t[72]=se);let ce;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,X.jsx)(`span`,{children:`Updated`}),t[73]=ce):ce=t[73];let le;t[74]===n.updatedAt?le=t[75]:(le=new Date(n.updatedAt).toLocaleString(),t[74]=n.updatedAt,t[75]=le);let ue;t[76]===le?ue=t[77]:(ue=(0,X.jsxs)(`div`,{className:`flex justify-between text-[11px] font-mono text-muted-foreground`,children:[ce,(0,X.jsx)(`span`,{children:le})]}),t[76]=le,t[77]=ue);let U;t[78]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,X.jsx)(`span`,{children:`Created`}),t[78]=U):U=t[78];let de;t[79]===n.createdAt?de=t[80]:(de=new Date(n.createdAt).toLocaleString(),t[79]=n.createdAt,t[80]=de);let fe;t[81]===de?fe=t[82]:(fe=(0,X.jsxs)(`div`,{className:`flex justify-between text-[11px] font-mono text-muted-foreground`,children:[U,(0,X.jsx)(`span`,{children:de})]}),t[81]=de,t[82]=fe);let pe;t[83]!==V||t[84]!==se||t[85]!==ue||t[86]!==fe?(pe=(0,X.jsxs)(sr,{className:`group pt-2 border-t border-border`,children:[ie,(0,X.jsxs)(lr,{className:`space-y-1 mt-2`,children:[V,se,ue,fe]})]}),t[83]=V,t[84]=se,t[85]=ue,t[86]=fe,t[87]=pe):pe=t[87];let me;t[88]===n.id?me=t[89]:(me=(0,X.jsx)(Wi,{memoryId:n.id}),t[88]=n.id,t[89]=me);let he;t[90]!==I||t[91]!==re||t[92]!==B||t[93]!==pe||t[94]!==me?(he=(0,X.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-4 py-4 space-y-4`,children:[I,re,B,pe,me]}),t[90]=I,t[91]=re,t[92]=B,t[93]=pe,t[94]=me,t[95]=he):he=t[95];let ge;t[96]===w?ge=t[97]:(ge=w.status===`blocked`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`text-xs font-mono text-destructive`,children:`Unsaved changes`}),(0,X.jsx)(H,{variant:`ghost`,size:`sm`,onClick:()=>w.proceed(),children:`Discard`}),(0,X.jsx)(H,{variant:`outline`,size:`sm`,onClick:()=>w.reset(),children:`Keep editing`})]}),t[96]=w,t[97]=ge);let _e;t[98]!==w.status||t[99]!==i||t[100]!==n.reviewEvents.length?(_e=n.reviewEvents.length>0&&w.status!==`blocked`&&(0,X.jsx)(H,{variant:`outline`,size:`sm`,onClick:i,title:`Mark as reviewed — this memory was flagged as a possible duplicate or conflict`,children:`Mark reviewed`}),t[98]=w.status,t[99]=i,t[100]=n.reviewEvents.length,t[101]=_e):_e=t[101];let ve;t[102]===Symbol.for(`react.memo_cache_sentinel`)?(ve=(0,X.jsx)(`div`,{className:`flex-1`}),t[102]=ve):ve=t[102];let ye=!S.state.isDirty,be;t[103]===S?be=t[104]:(be=()=>void S.handleSubmit(),t[103]=S,t[104]=be);let xe=l?`Saved`:`Save`,W;t[105]!==ye||t[106]!==be||t[107]!==xe?(W=(0,X.jsx)(H,{variant:`default`,size:`sm`,disabled:ye,onClick:be,children:xe}),t[105]=ye,t[106]=be,t[107]=xe,t[108]=W):W=t[108];let G;t[109]!==ge||t[110]!==_e||t[111]!==W?(G=(0,X.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-3 border-t border-border shrink-0`,children:[ge,_e,ve,W]}),t[109]=ge,t[110]=_e,t[111]=W,t[112]=G):G=t[112];let K;return t[113]!==N||t[114]!==he||t[115]!==G?(K=(0,X.jsxs)(`div`,{className:`flex flex-col h-full`,children:[N,he,G]}),t[113]=N,t[114]=he,t[115]=G,t[116]=K):K=t[116],K}function qi(e){return(0,X.jsx)(Ii,{value:e.id,children:e.name},e.id)}function Ji(e){return(0,X.jsx)(Gi,{field:e,label:`Tags`,children:(0,X.jsx)(Pi,{id:e.name,name:e.name,value:e.state.value,onBlur:e.handleBlur,onChange:t=>e.handleChange(t.target.value),placeholder:`tag1, tag2`,"aria-invalid":e.state.meta.isTouched&&!e.state.meta.isValid})})}function Yi(e){return(0,X.jsx)(Gi,{field:e,label:`Type`,description:(0,X.jsx)(`p`,{className:`text-[10px] text-muted-foreground leading-snug`,children:lt[e.state.value]}),children:(0,X.jsx)(Fi,{id:e.name,name:e.name,value:e.state.value,onBlur:e.handleBlur,onChange:t=>e.handleChange(t.target.value),className:`w-full`,children:rt.map(Xi)})})}function Xi(e){return(0,X.jsx)(Ii,{value:e,children:j(e)},e)}function Zi(e){return(0,X.jsx)(Gi,{field:e,label:`Content`,children:(0,X.jsx)(dt,{id:e.name,name:e.name,value:e.state.value,onBlur:e.handleBlur,onChange:t=>e.handleChange(t.target.value),rows:8,className:`min-h-32 font-heading text-sm`,"aria-invalid":e.state.meta.isTouched&&!e.state.meta.isValid})})}function Qi(e){return e.trim()}function $i(e){let t=(0,$.c)(13),{id:n}=e,{projectId:r}=st.useParams(),i=ae(),a;t[0]!==i||t[1]!==r?(a=()=>void i({to:`/$projectId`,params:{projectId:r},search:ea}),t[0]=i,t[1]=r,t[2]=a):a=t[2];let{memory:o,isLoading:s,availableProjects:c,handleApprove:l,handleAddProject:u,handleRemoveProject:d,handleDeleteConflicting:f,handleClose:p}=Ri(n,a);if(s||!o){let e=s?`Loading…`:`Memory not found`,n;return t[3]===e?n=t[4]:(n=(0,X.jsx)(`div`,{className:`flex items-center justify-center h-full text-xs font-mono text-muted-foreground`,children:e}),t[3]=e,t[4]=n),n}let m;return t[5]!==c||t[6]!==u||t[7]!==l||t[8]!==p||t[9]!==f||t[10]!==d||t[11]!==o?(m=(0,X.jsx)(Ki,{memory:o,availableProjects:c,handleApprove:l,handleAddProject:u,handleRemoveProject:d,handleDeleteConflicting:f,handleClose:p},o.id),t[5]=c,t[6]=u,t[7]=l,t[8]=p,t[9]=f,t[10]=d,t[11]=o,t[12]=m):m=t[12],m}function ea(e){return e}export{lr as C,Ht as E,sr as S,Wn as T,jr as _,di as a,Nr as b,kr as c,xr as d,Sr as f,Tr as g,wr as h,li as i,br as l,Cr as m,Pi as n,ui as o,yr as p,oi as r,fi as s,$i as t,Or as u,Er as v,cr as w,Pr as x,Dr as y};
|
|
1
|
+
import{A as e,B as t,Ct as n,D as r,H as i,I as a,J as o,L as s,M as c,N as l,O as u,Ot as d,Q as f,R as p,St as m,T as h,U as g,V as _,_ as v,_t as y,a as b,at as x,b as S,bt as C,d as w,dt as T,et as E,fn as D,g as O,hn as k,it as A,k as j,kt as M,n as N,pn as P,pt as F,r as I,s as L,t as ee,tt as R,ut as z,vt as te,w as ne,wt as re,xt as B,yt as ie,z as V}from"./collections-gO05Tpa7.js";import{d as ae,n as H,o as oe,r as se,s as ce}from"./preload-helper-DEuj8E0K.js";import{Bt as le,C as ue,Ct as U,D as de,Dt as fe,Et as pe,F as me,Ht as he,I as ge,L as _e,M as ve,Mt as ye,N as be,Nt as xe,Ot as W,P as G,Pt as K,R as Se,Rt as Ce,S as we,St as Te,T as Ee,Tt as De,Ut as Oe,Vt as ke,_ as Ae,a as je,b as Me,bt as Ne,c as Pe,d as Fe,g as Ie,gt as Le,h as Re,j as ze,kt as Be,l as Ve,m as He,o as Ue,p as We,q as Ge,r as Ke,s as qe,t as Je,u as Ye,w as Xe,wt as q,x as Ze,y as Qe,yt as $e,z as et}from"./popupStateMapping-CKjEg8lE.js";import{C as tt,S as J,f as nt,m as rt,n as it,o as at,p as ot,r as st,s as ct,u as lt,w as ut}from"./index-COiBvFfe.js";import{t as dt}from"./textarea-BLDQQzbc.js";var ft=class{constructor(e){this.atom=tt(e)}setState(e){this.atom.set(e)}get state(){return this.atom.get()}get(){return this.state}subscribe(e){return this.atom.subscribe(ut(e))}},pt=class{constructor(e){this.atom=tt(e)}get state(){return this.atom.get()}get(){return this.state}subscribe(e){return this.atom.subscribe(ut(e))}};function mt(e){return typeof e==`function`?new pt(e):new ft(e)}var Y=k(P(),1);function ht(e,t){if(e===void 0)return{shouldBlockFn:()=>!0,withResolver:!1};if(`shouldBlockFn`in e)return e;if(typeof e==`function`){let n=!!(t??!0);return{shouldBlockFn:async()=>n?await e():!1,enableBeforeUnload:n,withResolver:!1}}let n=!!(e.condition??!0),r=e.blockerFn;return{shouldBlockFn:async()=>n&&r!==void 0?await r():n,enableBeforeUnload:n,withResolver:r===void 0}}function gt(e,t){let{shouldBlockFn:n,enableBeforeUnload:r=!0,disabled:i=!1,withResolver:a=!1}=ht(e,t),o=M(),{history:s}=o,[c,l]=Y.useState({status:`idle`,current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0});return Y.useEffect(()=>i?void 0:s.block({blockerFn:async e=>{function t(e){let t=o.parseLocation(e),n=o.getMatchedRoutes(t.pathname);return n.foundRoute===void 0?{routeId:`__notFound__`,fullPath:t.pathname,pathname:t.pathname,params:n.routeParams,search:o.options.parseSearch(e.search)}:{routeId:n.foundRoute.id,fullPath:n.foundRoute.fullPath,pathname:t.pathname,params:n.routeParams,search:o.options.parseSearch(e.search)}}let r=t(e.currentLocation),i=t(e.nextLocation);if(r.routeId===`__notFound__`&&i.routeId!==`__notFound__`)return!1;let s=await n({action:e.action,current:r,next:i});if(!a)return s;if(!s)return!1;let c=await new Promise(t=>{l({status:`blocked`,current:r,next:i,action:e.action,proceed:()=>t(!1),reset:()=>t(!0)})});return l({status:`idle`,current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0}),c},enableBeforeUnload:r}),[n,r,i,a,s,o]),c}var _t=0;function vt(e,t={}){let{preventScroll:n=!1,cancelPrevious:r=!0,sync:i=!1}=t;r&&cancelAnimationFrame(_t);let a=()=>e?.focus({preventScroll:n});if(i)return a(),T;let o=requestAnimationFrame(a);return _t=o,()=>{_t===o&&(cancelAnimationFrame(o),_t=0)}}var yt={inert:new WeakMap,"aria-hidden":new WeakMap},bt=`data-base-ui-inert`,xt={inert:new WeakSet,"aria-hidden":new WeakSet},St=new WeakMap,Ct=0;function wt(e){return xt[e]}function Tt(e){return e?x(e)?e.host:Tt(e.parentNode):null}var Et=(e,t)=>t.map(t=>{if(e.contains(t))return t;let n=Tt(t);return e.contains(n)?n:null}).filter(e=>e!=null),Dt=e=>{let t=new Set;return e.forEach(e=>{let n=e;for(;n&&!t.has(n);)t.add(n),n=n.parentNode}),t},Ot=(e,t,n)=>{let r=[],i=e=>{!e||n.has(e)||Array.from(e.children).forEach(e=>{o(e)!==`script`&&(t.has(e)?i(e):r.push(e))})};return i(e),r};function kt(e,t,n,r,{mark:i=!0,markerIgnoreElements:a=[]}){let o=r?`inert`:n?`aria-hidden`:null,s=null,c=null,l=Et(t,e),u=i?Et(t,a):[],d=new Set(u),f=i?Ot(t,Dt(l),new Set(l)).filter(e=>!d.has(e)):[],p=[],m=[];if(o){let e=yt[o],n=wt(o);c=n,s=e;let r=Et(t,Array.from(t.querySelectorAll(`[aria-live]`))),i=l.concat(r);Ot(t,Dt(i),new Set(i)).forEach(t=>{let r=t.getAttribute(o),i=r!==null&&r!==`false`,a=(e.get(t)||0)+1;e.set(t,a),p.push(t),a===1&&i&&n.add(t),i||t.setAttribute(o,o===`inert`?``:`true`)})}return i&&f.forEach(e=>{let t=(St.get(e)||0)+1;St.set(e,t),m.push(e),t===1&&e.setAttribute(bt,``)}),Ct+=1,()=>{s&&p.forEach(e=>{let t=(s.get(e)||0)-1;s.set(e,t),t||(!c?.has(e)&&o&&e.removeAttribute(o),c?.delete(e))}),i&&m.forEach(e=>{let t=(St.get(e)||0)-1;St.set(e,t),t||e.removeAttribute(bt)}),--Ct,Ct||(yt.inert=new WeakMap,yt[`aria-hidden`]=new WeakMap,xt.inert=new WeakSet,xt[`aria-hidden`]=new WeakSet,St=new WeakMap)}}function At(e,t={}){let{ariaHidden:n=!1,inert:r=!1,mark:i=!0,markerIgnoreElements:a=[]}=t,o=U(e[0]).body;return kt(e,o,n,r,{mark:i,markerIgnoreElements:a})}var X=D();function jt(e,n){let r=f(t(e));return e instanceof r.KeyboardEvent?`keyboard`:e instanceof r.FocusEvent?n||`keyboard`:`pointerType`in e?e.pointerType||`keyboard`:`touches`in e?`touch`:e instanceof r.MouseEvent?n||(e.detail===0?`keyboard`:`mouse`):``}var Mt=20,Nt=[];function Pt(){Nt=Nt.filter(e=>e.deref()?.isConnected)}function Ft(e){Pt(),e&&o(e)!==`body`&&(Nt.push(new WeakRef(e)),Nt.length>Mt&&(Nt=Nt.slice(-Mt)))}function It(){return Pt(),Nt[Nt.length-1]?.deref()}function Lt(e){return e?Se(e)?e:et(e)[0]||e:null}function Rt(e,t){if(e.hasAttribute(`tabindex`)&&!e.hasAttribute(`data-tabindex`)||!t.current.includes(`floating`)&&!e.getAttribute(`role`)?.includes(`dialog`))return;let n=G(e).filter(e=>{let t=e.getAttribute(`data-tabindex`)||``;return Se(e)||e.hasAttribute(`data-tabindex`)&&!t.startsWith(`-`)}),r=e.getAttribute(`tabindex`);t.current.includes(`floating`)||n.length===0?r!==`0`&&e.setAttribute(`tabindex`,`0`):(r!==`-1`||e.hasAttribute(`data-tabindex`)&&e.getAttribute(`data-tabindex`)!==`-1`)&&(e.setAttribute(`tabindex`,`-1`),e.setAttribute(`data-tabindex`,`-1`))}function zt(e){let{context:n,children:r,disabled:a=!1,initialFocus:o=!0,returnFocus:s=!0,restoreFocus:c=!1,modal:l=!0,closeOnFocusOut:u=!0,openInteractionType:d=``,nextFocusableElement:f,previousFocusableElement:h,beforeContentFocusGuardRef:v,externalTree:b,getInsideElements:x}=e,S=`rootStore`in n?n.rootStore:n,C=S.useState(`open`),w=S.useState(`domReferenceElement`),T=S.useState(`floatingElement`),{events:E,dataRef:D}=S.context,O=_(()=>D.current.floatingContext?.nodeId),k=o===!1,A=$e(w)&&k,j=Y.useRef([`content`]),M=pe(o),N=pe(s),P=pe(d),F=Xe(b),I=de(),L=Y.useRef(!1),ee=Y.useRef(!1),z=Y.useRef(!1),te=Y.useRef(null),ne=Y.useRef(``),re=Y.useRef(``),B=Y.useRef(null),ae=Y.useRef(null),H=i(B,v,I?.beforeInsideRef),oe=i(ae,I?.afterInsideRef),se=ie(),ce=ie(),ue=De(),xe=I!=null,G=Le(T),K=_((e=G)=>e?et(e):[]),Ce=_(()=>x?.().filter(e=>e!=null)??[]);Y.useEffect(()=>{if(a||!l)return;function e(e){e.key===`Tab`&&V(G,p(U(G)))&&K().length===0&&!A&&he(e)}return g(U(G),`keydown`,e)},[a,w,G,l,j,A,K]),Y.useEffect(()=>{if(a||!C)return;let e=U(G);function n(){z.current=!1}function r(e){let n=t(e),r=Ce();z.current=!(V(T,n)||V(w,n)||V(I?.portalNode,n)||r.some(e=>e===n||V(e,n))),re.current=e.pointerType||`keyboard`,n?.closest(`[data-base-ui-click-trigger]`)&&(ee.current=!0)}function i(){re.current=`keyboard`}return fe(g(e,`pointerdown`,r,!0),g(e,`pointerup`,n,!0),g(e,`pointercancel`,n,!0),g(e,`keydown`,i,!0))},[a,T,w,G,C,I,Ce]),Y.useEffect(()=>{if(a||!u)return;let e=U(G);function n(){ee.current=!0,ce.start(0,()=>{ee.current=!1})}function r(e){let n=t(e);Se(n)&&(te.current=n)}function i(n){let r=n.relatedTarget,i=n.currentTarget,a=t(n);queueMicrotask(()=>{let t=O(),o=S.context.triggerElements,s=Ce(),u=r?.hasAttribute(ze(`focus-guard`))&&[B.current,ae.current,I?.beforeInsideRef.current,I?.afterInsideRef.current,I?.beforeOutsideRef.current,I?.afterOutsideRef.current,we(h),we(f)].includes(r),d=!(V(w,r)||V(T,r)||V(r,T)||V(I?.portalNode,r)||s.some(e=>e===r||V(e,r))||r!=null&&o.hasElement(r)||o.hasMatchingElement(e=>V(e,r))||u||F&&(be(F.nodesRef.current,t).find(e=>V(e.context?.elements.floating,r)||V(e.context?.elements.domReference,r))||ve(F.nodesRef.current,t).find(e=>[e.context?.elements.floating,Le(e.context?.elements.floating)].includes(r)||e.context?.elements.domReference===r)));if(i===w&&G&&Rt(G,j),c&&i!==w&&!Ge(a)&&p(e)===e.body){if(R(G)&&(G.focus(),c===`popup`)){ue.request(()=>{G.focus()});return}let e=K(),t=te.current,n=(t&&e.includes(t)?t:null)||e[e.length-1]||G;R(n)&&n.focus()}if(D.current.insideReactTree){D.current.insideReactTree=!1;return}(A||!l)&&r&&d&&!ee.current&&(A||r!==It())&&(L.current=!0,S.setOpen(!1,W(ye,n)))})}function o(){z.current||(D.current.insideReactTree=!0,se.start(0,()=>{D.current.insideReactTree=!1}))}let s=R(w)?w:null;if(!(!T&&!s))return fe(s&&g(s,`focusout`,i),s&&g(s,`pointerdown`,n),T&&g(T,`focusin`,r),T&&g(T,`focusout`,i),T&&I&&g(T,`focusout`,o,!0))},[a,w,T,G,l,F,I,S,u,c,K,A,O,j,D,se,ce,ue,f,h,Ce]),Y.useEffect(()=>{if(a||!T||!C)return;let e=Array.from(I?.portalNode?.querySelectorAll(`[${ze(`portal`)}]`)||[]),t=(F?ve(F.nodesRef.current,O()):[]).find(e=>$e(e.context?.elements.domReference||null))?.context?.elements.domReference,n=At([T,...e,B.current,ae.current,I?.beforeOutsideRef.current,I?.afterOutsideRef.current,...Ce(),t,we(h),we(f),A?w:null].filter(e=>e!=null),{ariaHidden:l||A,mark:!1}),r=At([T,...e].filter(e=>e!=null));return()=>{r(),n()}},[C,a,w,T,l,j,I,A,F,O,f,h,Ce]),m(()=>{if(!C||a||!R(G))return;let e=p(U(G));queueMicrotask(()=>{let t=M.current,n=typeof t==`function`?t(P.current||``):t;if(n===void 0||n===!1||V(G,e))return;let r=null,i=()=>(r??=K(G),r[0]||G),a;a=n===!0||n===null?i():we(n),a||=i(),vt(a,{preventScroll:a===G})})},[a,C,G,k,K,M,P]),m(()=>{if(a||!G)return;let e=U(G);Ft(p(e));function t(e){if(e.open||(ne.current=jt(e.nativeEvent,re.current)),e.reason===`trigger-hover`&&e.nativeEvent.type===`mouseleave`&&(L.current=!0),e.reason===`outside-press`)if(e.nested)L.current=!1;else if(le(e.nativeEvent)||ke(e.nativeEvent))L.current=!1;else{let e=!1;U(G).createElement(`div`).focus({get preventScroll(){return e=!0,!1}}),e?L.current=!1:L.current=!0}}E.on(`openchange`,t);function n(){let e=N.current,t=typeof e==`function`?e(ne.current):e;if(t===void 0||t===!1)return null;if(t===null&&(t=!0),typeof t==`boolean`){let e=w||It();return e&&e.isConnected?e:null}let n=w||It();return we(t)||n||null}return()=>{E.off(`openchange`,t);let r=p(e),i=Ce(),a=V(T,r)||i.some(e=>e===r||V(e,r))||F&&be(F.nodesRef.current,O(),!1).some(e=>V(e.context?.elements.floating,r)),o=N.current,s=n();queueMicrotask(()=>{let t=Lt(s),n=typeof o!=`boolean`;o&&!L.current&&R(t)&&(!(!n&&t!==r&&r!==e.body)||a)&&t.focus({preventScroll:!0}),L.current=!1})}},[a,T,G,N,D,E,F,w,O,Ce]),m(()=>{if(!y||C||!T)return;let e=p(U(T));!R(e)||!Ne(e)||V(T,e)&&e.blur()},[C,T]),m(()=>{if(!(a||!I))return I.setFocusManagerState({modal:l,closeOnFocusOut:u,open:C,onOpenChange:S.setOpen,domReference:w}),()=>{I.setFocusManagerState(null)}},[a,I,l,C,S,u,w]),m(()=>{if(!(a||!G))return Rt(G,j),()=>{queueMicrotask(Pt)}},[a,G,j]);let Ee=!a&&(l?!A:!0)&&(xe||l);return(0,X.jsxs)(Y.Fragment,{children:[Ee&&(0,X.jsx)(Te,{"data-type":`inside`,ref:H,onFocus:e=>{if(l){let e=K();vt(e[e.length-1])}else I?.portalNode&&(L.current=!1,_e(e,I.portalNode)?me(w)?.focus():we(h??I.beforeOutsideRef)?.focus())}}),r,Ee&&(0,X.jsx)(Te,{"data-type":`inside`,ref:oe,onFocus:e=>{l?vt(K()[0]):I?.portalNode&&(u&&(L.current=!0),_e(e,I.portalNode)?ge(w)?.focus():we(f??I.afterOutsideRef)?.focus())}})]})}var Bt=new Map([[`select`,`listbox`],[`combobox`,`listbox`],[`label`,!1]]);function Vt(e,t={}){let n=`rootStore`in e?e.rootStore:e,r=n.useState(`open`),i=n.useState(`floatingId`),a=n.useState(`domReferenceElement`),o=n.useState(`floatingElement`),{role:c=`dialog`}=t,l=s(),u=a?.id||l,d=Y.useMemo(()=>Le(o)?.id||i,[o,i]),f=Bt.get(c)??c,p=ue()!=null,m=Y.useMemo(()=>f===`tooltip`||c===`label`?z:{"aria-haspopup":f===`alertdialog`?`dialog`:f,"aria-expanded":`false`,...f===`listbox`&&{role:`combobox`},...f===`menu`&&p&&{role:`menuitem`},...c===`select`&&{"aria-autocomplete":`none`},...c===`combobox`&&{"aria-autocomplete":`list`}},[f,p,c]),h=Y.useMemo(()=>f===`tooltip`||c===`label`?{[`aria-${c===`label`?`labelledby`:`describedby`}`]:r?d:void 0}:{...m,"aria-expanded":r?`true`:`false`,"aria-controls":r?d:void 0,...f===`menu`&&{id:u}},[f,d,r,u,c,m]),g=Y.useMemo(()=>{let e={id:d,...f&&{role:f}};return f===`tooltip`||c===`label`?e:{...e,...f===`menu`&&{"aria-labelledby":u}}},[f,d,u,c]),_=Y.useCallback(({active:e,selected:t})=>{let n={role:`option`,...e&&{id:`${d}-fui-option`}};switch(c){case`select`:case`combobox`:return{...n,"aria-selected":t};default:}return{}},[d,c]);return Y.useMemo(()=>({reference:h,floating:g,item:_,trigger:m}),[h,g,m,_])}function Ht(e){return a(19)?e:e?`true`:void 0}var Ut=new Map([[`bold`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M216.49,104.49l-80,80a12,12,0,0,1-17,0l-80-80a12,12,0,0,1,17-17L128,159l71.51-71.52a12,12,0,0,1,17,17Z`}))],[`duotone`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M208,96l-80,80L48,96Z`,opacity:`0.2`}),Y.createElement(`path`,{d:`M215.39,92.94A8,8,0,0,0,208,88H48a8,8,0,0,0-5.66,13.66l80,80a8,8,0,0,0,11.32,0l80-80A8,8,0,0,0,215.39,92.94ZM128,164.69,67.31,104H188.69Z`}))],[`fill`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,48,88H208a8,8,0,0,1,5.66,13.66Z`}))],[`light`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M212.24,100.24l-80,80a6,6,0,0,1-8.48,0l-80-80a6,6,0,0,1,8.48-8.48L128,167.51l75.76-75.75a6,6,0,0,1,8.48,8.48Z`}))],[`regular`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,90.34L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z`}))],[`thin`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M210.83,98.83l-80,80a4,4,0,0,1-5.66,0l-80-80a4,4,0,0,1,5.66-5.66L128,170.34l77.17-77.17a4,4,0,1,1,5.66,5.66Z`}))]]),Wt=Y.forwardRef((e,t)=>Y.createElement(ce,{ref:t,...e,weights:Ut}));Wt.displayName=`CaretDownIcon`;var Gt=Wt,Kt=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 qt(e,t){return new Kt(e,t).maybeExecute}var Jt=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)}},Z=new class extends Jt{constructor(){super({pluginId:`form-devtools`,reconnectEveryMs:1e3})}};function Yt(e,t){return typeof e==`function`?e(t):e}function Xt(e,t){return sn(t).reduce((e,t)=>{if(e===null)return null;if(e!==void 0)return e[t]},e)}function Zt(e,t,n){let r=sn(t);function i(e){if(!r.length)return Yt(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 Qt(e,t){let n=sn(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 $t=/^(\d+)$/gm,en=/\.(\d+)(?=\.)/gm,tn=/^(\d+)\./gm,nn=/\.(\d+$)/gm,rn=/\.{2,}/gm,an=`__int__`,on=`${an}$1`;function sn(e){if(Array.isArray(e))return[...e];if(typeof e!=`string`)throw Error(`Path must be a string.`);return e.replace(/(^\[)|]/gm,``).replace(/\[/g,`.`).replace($t,on).replace(en,`.${on}.`).replace(tn,`${on}.`).replace(nn,`.${on}`).replace(rn,`.`).split(`.`).map(e=>{if(e.startsWith(an)){let t=e.substring(7),n=parseInt(t,10);return String(n)===t?n:t}return e})}function cn(e){return!(Array.isArray(e)&&e.length===0)}function ln(e,t){return t.validationLogic({form:t.form,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 un(e,t){let{asyncDebounceMs:n}=t,{onBlurAsyncDebounceMs:r,onChangeAsyncDebounceMs:i,onDynamicAsyncDebounceMs:a}=t.validators||{},o=n??0;return t.validationLogic({form:t.form,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;break}return e===`submit`&&(s=0),{cause:n,validate:t.fn,debounceMs:s}})})}var dn=e=>!!e&&typeof e==`object`&&`fields`in e;function fn(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)return!1;for(let i of n)if(!r.includes(i)||!fn(e[i],t[i]))return!1;return!0}var pn=({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},mn=({formLevelError:e,fieldLevelError:t})=>t?{newErrorValue:t,newSource:`field`}:e?{newErrorValue:e,newSource:`form`}:{newErrorValue:void 0,newSource:void 0};function Q(e,t){return e==null?t:{...e,...t}}for(var hn=256,gn=[],_n;hn--;)gn[hn]=(hn+256).toString(16).substring(1);function vn(){let e=0,t,n=``;if(!_n||hn+16>256){for(_n=Array(256),e=256;e--;)_n[e]=256*Math.random()|0;e=0,hn=0}for(;e<16;e++)t=_n[hn+e],e===6?n+=gn[t&15|64]:e===8?n+=gn[t&63|128]:n+=gn[t],e&1&&e>1&&e<11&&(n+=`-`);return hn++,n}var yn=qt(e=>Z.emit(`form-state`,{id:e.formId,state:e.store.state}),{wait:300});function bn(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]=bn(e[n]);return t}if(e instanceof Map){let t=new Map;return e.forEach((e,n)=>{t.set(n,bn(e))}),t}if(e instanceof Set){let t=new Set;return e.forEach(e=>{t.add(bn(e))}),t}let t={};for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=bn(e[n]));return t}var xn=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 Sn(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);Array.isArray(i)&&!Number.isNaN(o)?a+=`[${o}]`:a+=(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 Cn=(e,t)=>{let n=Sn(e,t);return{form:n,fields:n}},wn={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:Cn(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:Cn(r.issues,e)}},Tn=e=>!!e&&`~standard`in e,En={isValidating:!1,isTouched:!1,isBlurred:!1,isDirty:!1,isPristine:!0,isValid:!0,isDefaultValue:!0,errors:[],errorMap:{},errorSourceMap:{}};function Dn(e){function t(t,n,r){let i=o(t,n,`move`,r),s=Math.min(n,r),l=Math.max(n,r);for(let e=s;e<=l;e++)i.push(a(t,e));let u=Object.keys(e.fieldInfo).reduce((r,i)=>(i.startsWith(a(t,n))&&r.set(i,e.getFieldMeta(i)),r),new Map);c(i,n<r?`up`:`down`),Object.keys(e.fieldInfo).filter(e=>e.startsWith(a(t,r))).forEach(i=>{let o=i.replace(a(t,r),a(t,n)),s=u.get(o);s&&e.setFieldMeta(i,s)})}function n(e,t){c(o(e,t,`remove`),`up`)}function r(t,n,r){o(t,n,`swap`,r).forEach(i=>{if(!i.toString().startsWith(a(t,n)))return;let o=i.toString().replace(a(t,n),a(t,r)),[s,c]=[e.getFieldMeta(i),e.getFieldMeta(o)];s&&e.setFieldMeta(o,s),c&&e.setFieldMeta(i,c)})}function i(t,n){let r=o(t,n,`insert`);c(r,`down`),r.forEach(r=>{r.toString().startsWith(a(t,n))&&e.setFieldMeta(r,l())})}function a(e,t){return`${e}[${t}]`}function o(t,n,r,i){let o=[a(t,n)];switch(r){case`swap`:o.push(a(t,i));break;case`move`:{let[e,r]=[Math.min(n,i),Math.max(n,i)];for(let n=e;n<=r;n++)o.push(a(t,n));break}default:{let r=e.getFieldValue(t),i=Array.isArray(r)?r.length:0;for(let e=n+1;e<i;e++)o.push(a(t,e));break}}return Object.keys(e.fieldInfo).filter(e=>o.some(t=>e.startsWith(t)))}function s(e,t){return e.replace(/\[(\d+)\]/,(e,n)=>{let r=parseInt(n,10);return`[${t===`up`?r+1:Math.max(0,r-1)}]`})}function c(t,n){(n===`up`?t:[...t].reverse()).forEach(t=>{let r=s(t.toString(),n),i=e.getFieldMeta(r);i?e.setFieldMeta(t,i):e.setFieldMeta(t,l())})}let l=()=>En;return{handleArrayMove:t,handleArrayRemove:n,handleArraySwap:r,handleArrayInsert:i}}function On(e){return{values:e.values??{},errorMap:e.errorMap??{},fieldMetaBase:e.fieldMetaBase??{},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 kn=class{constructor(e){this.options={},this.fieldInfo={},this.mount=()=>{let e=this.store.subscribe(()=>{yn(this)}),t=Z.on(`request-form-state`,e=>{e.payload.id===this._formId&&Z.emit(`form-api`,{id:this._formId,state:this.store.state,options:this.options})}),n=Z.on(`request-form-reset`,e=>{e.payload.id===this._formId&&this.reset()}),r=Z.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(),Z.emit(`form-unmounted`,{id:this._formId})};this.options.listeners?.onMount?.({formApi:this});let{onMount:a}=this.options.validators||{};return Z.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&&!fn(e.defaultValues,t.defaultValues)&&!this.state.isTouched,r=!fn(e.defaultState,t.defaultState)&&!this.state.isTouched;!n&&!r||(J(()=>{this.baseStore.setState(()=>On(Object.assign({},this.state,r?e.defaultState:{},n?{values:e.defaultValues}:{})))}),Z.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(()=>On({...this.options.defaultState,values:e??this.options.defaultValues??this.options.defaultState?.values,fieldMetaBase:r}))},this.validateAllFields=async e=>{let t=[];return J(()=>{Object.values(this.fieldInfo).forEach(n=>{if(!n.instance)return;let r=n.instance;t.push(Promise.resolve().then(()=>r.validate(e,{skipFormValidation:!0}))),n.instance.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 J(()=>{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.state.meta.isTouched||n.setMeta(e=>({...e,isTouched:!0})),n.validate(t)},this.validateSync=e=>{let t=ln(e,{...this.options,form:this,validationLogic:this.options.validationLogic||xn}),n=!1,r={};return J(()=>{for(let e of t){if(!e.validate)continue;let{formError:t,fieldErrors:i}=An(this.runValidator({validate:e.validate,value:{value:this.state.values,formApi:this,validationSource:`form`},type:`validate`})),a=jn(e.cause),o=new Set([...Object.keys(this.state.fieldMeta),...Object.keys(i||{})]);for(let e of o){if(this.baseStore.state.fieldMetaBase[e]===void 0&&!i?.[e])continue;let{errorMap:t,errorSourceMap:n}=this.getFieldMeta(e)??En,o=i?.[e],{newErrorValue:s,newSource:c}=pn({newFormValidatorError:o,isPreviousErrorFromFormValidator:n?.[a]===`form`,previousErrorValue:t?.[a]});c===`form`&&(r[e]={...r[e],[a]:o}),t?.[a]!==s&&this.setFieldMeta(e,(e=En)=>({...e,errorMap:{...e.errorMap,[a]:s},errorSourceMap:{...e.errorSourceMap,[a]:c}}))}this.state.errorMap?.[a]!==t&&this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[a]:t}})),(t||i)&&(n=!0)}let i=jn(`submit`);this.state.errorMap?.[i]&&e!==`submit`&&!n&&this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[i]:void 0}}));let a=jn(`server`);this.state.errorMap?.[a]&&e!==`server`&&!n&&this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[a]:void 0}}))}),{hasErrored:n,fieldsErrorMap:r}},this.validateAsync=async e=>{let t=un(e,{...this.options,form:this,validationLogic:this.options.validationLogic||xn});this.state.isFormValidating||this.baseStore.setState(e=>({...e,isFormValidating:!0}));let n=[],r;for(let e of t){if(!e.validate)continue;let t=jn(e.cause);this.state.validationMetaMap[t]?.lastAbortController.abort();let i=new AbortController;this.state.validationMetaMap[t]={lastAbortController:i},n.push(new Promise(async t=>{let n;try{n=await new Promise((t,n)=>{setTimeout(async()=>{if(i.signal.aborted)return t(void 0);try{t(await this.runValidator({validate:e.validate,value:{value:this.state.values,formApi:this,validationSource:`form`,signal:i.signal},type:`validateAsync`}))}catch(e){n(e)}},e.debounceMs)})}catch(e){n=e}let{formError:a,fieldErrors:o}=An(n);o&&(r=r?{...r,...o}:o);let s=jn(e.cause);for(let e of Object.keys(this.state.fieldMeta)){if(this.baseStore.state.fieldMetaBase[e]===void 0)continue;let t=this.getFieldMeta(e);if(!t)continue;let{errorMap:n,errorSourceMap:i}=t,a=r?.[e],{newErrorValue:o,newSource:c}=pn({newFormValidatorError:a,isPreviousErrorFromFormValidator:i?.[s]===`form`,previousErrorValue:n?.[s]});n?.[s]!==o&&this.setFieldMeta(e,e=>({...e,errorMap:{...e.errorMap,[s]:o},errorSourceMap:{...e.errorSourceMap,[s]:c}}))}this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[s]:a}})),t(r?{fieldErrors:r,errorMapKey:s}:void 0)}))}let i=[],a={};if(n.length){i=await Promise.all(n);for(let e of i)if(e?.fieldErrors){let{errorMapKey:t}=e;for(let[n,r]of Object.entries(e.fieldErrors))a[n]={...a[n]||{},[t]:r}}}return this.baseStore.setState(e=>({...e,isFormValidating:!1})),a},this.validate=e=>{let{hasErrored:t,fieldsErrorMap:n}=this.validateSync(e);return t&&!this.options.asyncAlways?n:this.validateAsync(e)},this._handleSubmit=async e=>{this.baseStore.setState(e=>({...e,isSubmitted:!1,submissionAttempts:e.submissionAttempts+1,isSubmitSuccessful:!1})),J(()=>{Object.values(this.fieldInfo).forEach(e=>{e.instance&&(e.instance.state.meta.isTouched||e.instance.setMeta(e=>({...e,isTouched:!0})))})});let t=e??this.options.onSubmitMeta;if(!this.state.canSubmit&&!this._devtoolsSubmissionOverride){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}),Z.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}),Z.emit(`form-submission`,{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!1,stage:`validate`,errors:this.state.errors});return}J(()=>{Object.values(this.fieldInfo).forEach(e=>{e.instance?.options.listeners?.onSubmit?.({value:e.instance.state.value,fieldApi:e.instance})})}),this.options.listeners?.onSubmit?.({formApi:this,meta:t});try{await this.options.onSubmit?.({value:this.state.values,formApi:this,meta:t}),J(()=>{this.baseStore.setState(e=>({...e,isSubmitted:!0,isSubmitSuccessful:!0})),Z.emit(`form-submission`,{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!0}),n()})}catch(e){throw this.baseStore.setState(e=>({...e,isSubmitSuccessful:!1})),Z.emit(`form-submission`,{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!1,stage:`inflight`,onError:e}),n(),e}},this.getFieldValue=e=>Xt(this.state.values,e),this.getFieldMeta=e=>this.state.fieldMeta[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]:Yt(t,n.fieldMetaBase[e])}}))},this.resetFieldMeta=e=>Object.keys(e).reduce((e,t)=>{let n=t;return e[n]=En,e},{}),this.setFieldValue=(e,t,n)=>{let r=n?.dontUpdateMeta??!1,i=n?.dontRunListeners??!1,a=n?.dontValidate??!1;J(()=>{r||this.setFieldMeta(e,e=>({...e,isTouched:!0,isDirty:!0,errorMap:{...e?.errorMap,onMount:void 0}})),this.baseStore.setState(n=>({...n,values:Zt(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=Qt(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)},this.insertFieldValue=async(e,t,n,r)=>{this.setFieldValue(e,e=>[...e.slice(0,t),n,...e.slice(t)],Q(r,{dontValidate:!0}));let i=r?.dontValidate??!1;i||await this.validateField(e,`change`),Dn(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),Q(r,{dontValidate:!0})),(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),Q(n,{dontValidate:!0})),Dn(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 Zt(Zt(e,`${t}`,i),`${n}`,r)},Q(r,{dontValidate:!0})),Dn(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},Q(r,{dontValidate:!0})),Dn(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,[],Q(t,{dontValidate:!0})),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=>({...t,fieldMetaBase:{...t.fieldMetaBase,[e]:En},values:this.options.defaultValues?Zt(t.values,e,Xt(this.options.defaultValues,e)):t.values}))},this.setErrorMap=e=>{J(()=>{Object.entries(e).forEach(([e,t])=>{let n=e;if(dn(t)){let{formError:e,fieldErrors:r}=An(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=>wn.validate({value:this.state.values,validationSource:`form`},e),this.parseValuesWithSchemaAsync=e=>wn.validateAsync({value:this.state.values,validationSource:`form`},e),this.timeoutIds={validations:{},listeners:{},formListeners:{}},this._formId=e?.formId??vn(),this._devtoolsSubmissionOverride=!1;let t=On({...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||!dn(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,...a??{},errorSourceMap:{...a?.errorSourceMap??{},onChange:`form`},errorMap:{...a?.errorMap??{},[e]:i}}}}}this.baseStore=mt(t);let n;this.fieldMetaDerived=mt(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=Xt(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=!cn(u),f=!o.isDirty,p=fn(l,Xt(this.options.defaultValues,a))||fn(l,this.getFieldInfo(a)?.instance?.options.defaultValue);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});let r;this.store=mt(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&&dn(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&&fn(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 Tn(e.validate)?wn[e.type](e.value,e.validate):e.validate(e.value)}handleSubmit(e){return this._handleSubmit(e)}};function An(e){return e?dn(e)?{formError:An(e.form).formError,fieldErrors:e.fields}:{formError:e}:{formError:void 0}}function jn(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 Mn=class{constructor(e){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]:{...En,isTouched:e.fieldMetaBase[this.name]?.isTouched??En.isTouched,isBlurred:e.fieldMetaBase[this.name]?.isBlurred??En.isBlurred,isDirty:e.fieldMetaBase[this.name]?.isDirty??En.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&&(fn(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,Q(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,Q(t,{dontRunListeners:!0})),t?.dontRunListeners||this.triggerOnChangeListener()},this.insertValue=(e,t,n)=>{this.form.insertFieldValue(this.name,e,t,Q(n,{dontRunListeners:!0})),n?.dontRunListeners||this.triggerOnChangeListener()},this.replaceValue=(e,t,n)=>{this.form.replaceFieldValue(this.name,e,t,Q(n,{dontRunListeners:!0})),n?.dontRunListeners||this.triggerOnChangeListener()},this.removeValue=(e,t)=>{this.form.removeFieldValue(this.name,e,Q(t,{dontRunListeners:!0})),t?.dontRunListeners||this.triggerOnChangeListener()},this.swapValues=(e,t,n)=>{this.form.swapFieldValues(this.name,e,t,Q(n,{dontRunListeners:!0})),n?.dontRunListeners||this.triggerOnChangeListener()},this.moveValue=(e,t,n)=>{this.form.moveFieldValues(this.name,e,t,Q(n,{dontRunListeners:!0})),n?.dontRunListeners||this.triggerOnChangeListener()},this.clearValues=e=>{this.form.clearFieldValues(this.name,Q(e,{dontRunListeners:!0})),e?.dontRunListeners||this.triggerOnChangeListener()},this.getLinkedFields=e=>{let t=Object.values(this.form.fieldInfo),n=[];for(let r of t){if(!r.instance)continue;let{onChangeListenTo:t,onBlurListenTo:i}=r.instance.options.validators||{};e===`change`&&t?.includes(this.name)&&n.push(r.instance),e===`blur`&&i?.includes(this.name)&&n.push(r.instance)}return n},this.validateSync=(e,t)=>{let n=ln(e,{...this.options,form:this.form,fieldName:this.name,validationLogic:this.form.options.validationLogic||xn}),r=this.getLinkedFields(e).reduce((t,n)=>{let r=ln(e,{...n.options,form:n.form,fieldName:n.name,validationLogic:n.form.options.validationLogic||xn});return r.forEach(e=>{e.field=n}),t.concat(r)},[]),i=!1;J(()=>{let e=(e,n)=>{let r=Pn(n.cause),a=n.validate?Nn(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}=mn({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=Pn(`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=un(e,{...this.options,form:this.form,fieldName:this.name,validationLogic:this.form.options.validationLogic||xn}),r=await t,i=this.getLinkedFields(e),a=i.reduce((t,n)=>{let r=un(e,{...n.options,form:n.form,fieldName:n.name,validationLogic:n.form.options.validationLogic||xn});return r.forEach(e=>{e.field=n}),t.concat(r)},[]),o=[],s=[],c=n.some(e=>e.validate)||a.some(e=>e.validate);if(c){this.state.meta.isValidating||this.setMeta(e=>({...e,isValidating:!0}));for(let e of i)e.setMeta(e=>({...e,isValidating:!0}))}let l=(e,t,n)=>{let i=Pn(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.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=Nn(a),c=r[e.name]?.[i],{newErrorValue:l,newSource:u}=mn({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,o);for(let e of a)e.validate&&l(e.field,e,s);let u=[];if((o.length||s.length)&&(u=await Promise.all(o),await Promise.all(s)),c){this.setMeta(e=>({...e,isValidating:!1}));for(let e of i)e.setMeta(e=>({...e,isValidating:!1}))}return u.filter(Boolean)},this.validate=(e,t)=>{if(!this.state.meta.isTouched)return[];let{fieldsErrorMap:n}=t?.skipFormValidation?{fieldsErrorMap:{}}:this.form.validateSync(e),{hasErrored:r}=this.validateSync(e,n[this.name]??{});if(r&&!this.options.asyncAlways)return this.getInfo().validationMetaMap[Pn(e)]?.lastAbortController.abort(),this.state.meta.errors;let i=t?.skipFormValidation?Promise.resolve({}):this.form.validateAsync(e);return this.validateAsync(e,i)},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=>wn.validate({value:this.state.value,validationSource:`field`},e),this.parseValueWithSchemaAsync=e=>wn.validateAsync({value:this.state.value,validationSource:`field`},e),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})},this.form=e.form,this.name=e.name,this.options=e,this.timeoutIds={validations:{},listeners:{},formListeners:{}},this.store=mt(t=>{this.form.store.get();let n=this.form.getFieldMeta(this.name)??{...En,...e.defaultMeta},r=this.form.getFieldValue(this.name);return!n.isTouched&&r===void 0&&this.options.defaultValue!==void 0&&!fn(r,this.options.defaultValue)&&(r=this.options.defaultValue),t&&t.value===r&&t.meta===n?t:{value:r,meta:n}})}get state(){return this.store.state}runValidator(e){return Tn(e.validate)?wn[e.type](e.value,e.validate):e.validate(e.value)}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})}};function Nn(e){if(e)return e}function Pn(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 Fn(e,t){if(!t)return;let n=Object.assign({},e,{state:bn(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,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 J(()=>{Object.keys(r).length&&e.baseStore.setState(e=>({...e,...r})),n.state.errorMap!==e.state.errorMap&&e.setErrorMap(n.state.errorMap)}),n}var In=typeof window<`u`?Y.useLayoutEffect:Y.useEffect;function Ln(e){let[t,n]=(0,Y.useState)(()=>({form:e.form,name:e.name})),[r,i]=(0,Y.useState)(()=>new Mn({...e}));(t.form!==e.form||t.name!==e.name)&&(i(new Mn({...e})),n({form:e.form,name:e.name}));let a=d(r.store,e.mode===`array`?e=>Object.keys(e.value??[]).length:e=>e.value),o=d(r.store,e=>e.meta.isTouched),s=d(r.store,e=>e.meta.isBlurred),c=d(r.store,e=>e.meta.isDirty),l=d(r.store,e=>e.meta.errorMap),u=d(r.store,e=>e.meta.errorSourceMap),f=d(r.store,e=>e.meta.isValidating),p=(0,Y.useMemo)(()=>{let t={...r,get state(){return{value:e.mode===`array`?r.state.value:a,get meta(){return{...r.state.meta,isTouched:o,isBlurred:s,isDirty:c,errorMap:l,errorSourceMap:u,isValidating:f}}}}};return t.Field=Rn,t},[r,e.mode,a,o,s,c,l,u,f]);return In(r.mount,[r]),In(()=>{r.update(e)}),p}var Rn=(({children:e,...t})=>{let n=Ln(t);return(0,X.jsx)(X.Fragment,{children:(0,Y.useMemo)(()=>Yt(e,n),[e,n])})});function zn(){return(0,Y.useState)(()=>vn())[0]}var Bn=Y,Vn=`19.2.5`.split(`.`)[0]===`17`?zn:Bn.useId;function Hn({form:e,selector:t=e=>e,children:n}){return(0,X.jsx)(X.Fragment,{children:Yt(n,d(e.store,t))})}function Un(e){let t=Vn(),[n,r]=(0,Y.useState)(e?.formId),[i,a]=(0,Y.useState)(()=>new kn({...e,formId:e?.formId??t}));if(n!==e?.formId){let n=e?.formId??t;a(new kn({...e,formId:n})),r(n)}let o=(0,Y.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)(Rn,{...e,form:i})},e.Subscribe=function(e){return(0,X.jsx)(Hn,{form:i,selector:e.selector,children:e.children})},e},[i]);In(i.mount,[]),In(()=>{i.update(e)});let s=(0,Y.useRef)(!1);return In(()=>{s.current&&e?.transform&&Fn(i,e.transform)},[i,e?.transform]),In(()=>{s.current=!0}),o}function Wn({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=Y.useRef(e!==void 0),[a,o]=Y.useState(t);return[i?e:a,Y.useCallback(e=>{i||o(e)},[])]}function Gn(e){let{open:t,defaultOpen:n,onOpenChange:r,disabled:i}=e,a=t!==void 0,[o,s]=Wn({controlled:t,default:n,name:`Collapsible`,state:`open`}),{mounted:l,setMounted:u,transitionStatus:d}=Ae(o,!0,!0),[f,p]=Y.useState(o),[{height:h,width:g},v]=Y.useState({height:void 0,width:void 0}),y=c(),[b,x]=Y.useState(),S=b??y,[C,w]=Y.useState(!1),[T,E]=Y.useState(!1),D=Y.useRef(null),O=Y.useRef(null),k=Y.useRef(null),A=Y.useRef(null),j=He(A,!1),M=_(e=>{let t=!o,n=W(Ce,e.nativeEvent);if(r(t,n),n.isCanceled)return;let i=A.current;O.current===`css-animation`&&i!=null&&i.style.removeProperty(`animation-name`),!C&&!T&&(O.current!=null&&O.current!==`css-animation`&&!l&&t&&u(!0),O.current===`css-animation`&&(!f&&t&&p(!0),!l&&t&&u(!0))),s(t),O.current===`none`&&l&&!t&&u(!1)});return m(()=>{a&&O.current===`none`&&!o&&u(!1)},[a,o,t,u]),Y.useMemo(()=>({abortControllerRef:D,animationTypeRef:O,disabled:i,handleTrigger:M,height:h,mounted:l,open:o,panelId:S,panelRef:A,runOnceAnimationsFinish:j,setDimensions:v,setHiddenUntilFound:w,setKeepMounted:E,setMounted:u,setOpen:s,setPanelIdState:x,setVisible:p,transitionDimensionRef:k,transitionStatus:d,visible:f,width:g}),[D,O,i,M,h,l,o,S,A,j,v,w,E,u,s,p,k,d,f,g])}var Kn=Y.createContext(void 0);function qn(){let e=Y.useContext(Kn);if(e===void 0)throw Error(B(15));return e}var Jn=function(e){return e.open=`data-open`,e.closed=`data-closed`,e[e.startingStyle=Re.startingStyle]=`startingStyle`,e[e.endingStyle=Re.endingStyle]=`endingStyle`,e}({}),Yn=function(e){return e.panelOpen=`data-panel-open`,e}({}),Xn={[Jn.open]:``},Zn={[Jn.closed]:``},Qn={open(e){return e?{[Yn.panelOpen]:``}:null}},$n={open(e){return e?Xn:Zn},...Ie},er=Y.forwardRef(function(e,t){let{render:n,className:r,defaultOpen:i=!1,disabled:a=!1,onOpenChange:o,open:s,style:c,...u}=e,d=_(o),f=Gn({open:s,defaultOpen:i,onOpenChange:d,disabled:a}),p=Y.useMemo(()=>({open:f.open,disabled:f.disabled,transitionStatus:f.transitionStatus}),[f.open,f.disabled,f.transitionStatus]),m=Y.useMemo(()=>({...f,onOpenChange:d,state:p}),[f,d,p]),h=l(`div`,e,{state:p,ref:t,props:u,stateAttributesMapping:$n});return(0,X.jsx)(Kn.Provider,{value:m,children:h})}),tr={...Qn,...Ie},nr=Y.forwardRef(function(e,t){let{panelId:n,open:r,handleTrigger:i,state:a,disabled:o}=qn(),{className:s,disabled:c=o,id:u,render:d,nativeButton:f=!0,style:p,...m}=e,{getButtonProps:h,buttonRef:g}=se({disabled:c,focusableWhenDisabled:!0,native:f}),_=Y.useMemo(()=>({"aria-controls":r?n:void 0,"aria-expanded":r,onClick:i}),[n,r,i]);return l(`button`,e,{state:a,ref:[t,g],props:[_,m,h],stateAttributesMapping:tr})}),rr=function(e){return e.disabled=`data-disabled`,e.orientation=`data-orientation`,e}({});function ir(e){let{abortControllerRef:t,animationTypeRef:n,externalRef:r,height:a,hiddenUntilFound:o,keepMounted:s,id:c,mounted:l,onOpenChange:u,open:d,panelRef:f,runOnceAnimationsFinish:p,setDimensions:h,setMounted:v,setOpen:y,setVisible:b,transitionDimensionRef:x,visible:S,width:w}=e,T=Y.useRef(!1),E=Y.useRef(null),D=Y.useRef(d),O=Y.useRef(d),k=De(),A=Y.useMemo(()=>n.current===`css-animation`?!S:!d&&!l,[d,l,S,n]),j=i(r,f,_(e=>{if(!e)return;if(n.current==null||x.current==null){let t=getComputedStyle(e),r=t.animationName!==`none`&&t.animationName!==``,i=t.transitionDuration!==`0s`&&t.transitionDuration!==``;r&&i||(t.animationName===`none`&&t.transitionDuration!==`0s`?n.current=`css-transition`:t.animationName!==`none`&&t.transitionDuration===`0s`?n.current=`css-animation`:n.current=`none`),e.getAttribute(rr.orientation)===`horizontal`||t.transitionProperty.indexOf(`width`)>-1?x.current=`width`:x.current=`height`}if(n.current!==`css-transition`)return;(a===void 0||w===void 0)&&(h({height:e.scrollHeight,width:e.scrollWidth}),O.current&&e.style.setProperty(`transition-duration`,`0s`));let t=-1,r=-1;return t=q.request(()=>{O.current=!1,r=q.request(()=>{setTimeout(()=>{e.style.removeProperty(`transition-duration`)})})}),()=>{q.cancel(t),q.cancel(r)}}));return m(()=>{if(n.current!==`css-transition`)return;let e=f.current;if(!e)return;let r=-1;if(t.current!=null&&(t.current.abort(),t.current=null),d){let t={"justify-content":e.style.justifyContent,"align-items":e.style.alignItems,"align-content":e.style.alignContent,"justify-items":e.style.justifyItems};Object.keys(t).forEach(t=>{e.style.setProperty(t,`initial`,`important`)}),!O.current&&!s&&e.setAttribute(Jn.startingStyle,``),h({height:e.scrollHeight,width:e.scrollWidth}),r=q.request(()=>{Object.entries(t).forEach(([t,n])=>{n===``?e.style.removeProperty(t):e.style.setProperty(t,n)})})}else{if(e.scrollHeight===0&&e.scrollWidth===0)return;h({height:e.scrollHeight,width:e.scrollWidth});let n=new AbortController;t.current=n;let r=n.signal,i=null,a=Jn.endingStyle;return i=new MutationObserver(o=>{o.some(e=>e.type===`attributes`&&e.attributeName===a)&&(i?.disconnect(),i=null,p(()=>{h({height:0,width:0}),e.style.removeProperty(`content-visibility`),v(!1),t.current===n&&(t.current=null)},r))}),i.observe(e,{attributes:!0,attributeFilter:[a]}),()=>{i?.disconnect(),k.cancel(),t.current===n&&(n.abort(),t.current=null)}}return()=>{q.cancel(r)}},[t,n,k,o,s,l,d,f,p,h,v]),m(()=>{if(n.current!==`css-animation`)return;let e=f.current;e&&(E.current=e.style.animationName||E.current,e.style.setProperty(`animation-name`,`none`),h({height:e.scrollHeight,width:e.scrollWidth}),!D.current&&!T.current&&e.style.removeProperty(`animation-name`),d?(t.current!=null&&(t.current.abort(),t.current=null),v(!0),b(!0)):(t.current=new AbortController,p(()=>{v(!1),b(!1),t.current=null},t.current.signal)))},[t,n,d,f,p,h,v,b,S]),C(()=>{let e=q.request(()=>{D.current=!1});return()=>q.cancel(e)}),m(()=>{if(!o)return;let e=f.current;if(!e)return;let t=-1,n=-1;return d&&T.current&&(e.style.transitionDuration=`0s`,h({height:e.scrollHeight,width:e.scrollWidth}),t=q.request(()=>{T.current=!1,n=q.request(()=>{setTimeout(()=>{e.style.removeProperty(`transition-duration`)})})})),()=>{q.cancel(t),q.cancel(n)}},[o,d,f,h]),m(()=>{let e=f.current;e&&o&&A&&(e.setAttribute(`hidden`,`until-found`),n.current===`css-transition`&&e.setAttribute(Jn.startingStyle,``))},[o,A,n,f]),Y.useEffect(function(){let e=f.current;if(!e)return;function t(e){T.current=!0,y(!0),u(!0,W(K,e))}return g(e,`beforematch`,t)},[u,f,y]),Y.useMemo(()=>({props:{hidden:A,id:c,ref:j}}),[A,c,j])}var ar=function(e){return e.collapsiblePanelHeight=`--collapsible-panel-height`,e.collapsiblePanelWidth=`--collapsible-panel-width`,e}({}),or=Y.forwardRef(function(e,t){let{className:n,hiddenUntilFound:r,keepMounted:i,render:a,id:o,style:s,...c}=e,{abortControllerRef:u,animationTypeRef:d,height:f,mounted:p,onOpenChange:h,open:g,panelId:_,panelRef:v,runOnceAnimationsFinish:y,setDimensions:b,setHiddenUntilFound:x,setKeepMounted:S,setMounted:C,setPanelIdState:w,setOpen:T,setVisible:E,state:D,transitionDimensionRef:O,visible:k,width:A,transitionStatus:j}=qn(),M=r??!1,N=i??!1;m(()=>{if(o)return w(o),()=>{w(void 0)}},[o,w]),m(()=>{x(M)},[x,M]),m(()=>{S(N)},[S,N]);let{props:P}=ir({abortControllerRef:u,animationTypeRef:d,externalRef:t,height:f,hiddenUntilFound:M,id:_,keepMounted:N,mounted:p,onOpenChange:h,open:g,panelRef:v,runOnceAnimationsFinish:y,setDimensions:b,setMounted:C,setOpen:T,setVisible:E,transitionDimensionRef:O,visible:k,width:A});We({open:g&&j===`idle`,ref:v,onComplete(){g&&b({height:void 0,width:void 0})}});let F=l(`div`,e,{state:Y.useMemo(()=>({...D,transitionStatus:j}),[D,j]),ref:[t,v],props:[P,{style:{[ar.collapsiblePanelHeight]:f===void 0?`auto`:`${f}px`,[ar.collapsiblePanelWidth]:A===void 0?`auto`:`${A}px`}},c],stateAttributesMapping:$n});return N||M||p?F:null}),$=re();function sr(e){let t=(0,$.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,X.jsx)(er,{"data-slot":`collapsible`,...n}),t[2]=n,t[3]=r),r}function cr(e){let t=(0,$.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,X.jsx)(nr,{"data-slot":`collapsible-trigger`,...n}),t[2]=n,t[3]=r),r}function lr(e){let t=(0,$.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,X.jsx)(or,{"data-slot":`collapsible-content`,...n}),t[2]=n,t[3]=r),r}var ur=Y.createContext(void 0);function dr(e){let t=Y.useContext(ur);if(e===!1&&t===void 0)throw Error(B(27));return t}var fr={...Ke,...Ie},pr=Y.forwardRef(function(e,t){let{render:n,className:r,style:i,forceRender:a=!1,...o}=e,{store:s}=dr(),c=s.useState(`open`),u=s.useState(`nested`),d=s.useState(`mounted`);return l(`div`,e,{state:{open:c,transitionStatus:s.useState(`transitionStatus`)},ref:[s.context.backdropRef,t],stateAttributesMapping:fr,props:[{role:`presentation`,hidden:!d,style:{userSelect:`none`,WebkitUserSelect:`none`}},o],enabled:a||!u})}),mr=Y.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,nativeButton:a=!0,style:o,...s}=e,{store:c}=dr(),u=c.useState(`open`);function d(e){u&&c.setOpen(!1,W(Be,e.nativeEvent))}let{getButtonProps:f,buttonRef:p}=se({disabled:i,native:a});return l(`button`,e,{state:{disabled:i},ref:[t,p],props:[{onClick:d},s,f]})}),hr=function(e){return e.nestedDialogs=`--nested-dialogs`,e}({}),gr=function(e){return e[e.open=Je.open]=`open`,e[e.closed=Je.closed]=`closed`,e[e.startingStyle=Je.startingStyle]=`startingStyle`,e[e.endingStyle=Je.endingStyle]=`endingStyle`,e.nested=`data-nested`,e.nestedDialogOpen=`data-nested-dialog-open`,e}({}),_r=Y.createContext(void 0);function vr(){let e=Y.useContext(_r);if(e===void 0)throw Error(B(26));return e}var yr=`ArrowUp`,br=`ArrowDown`,xr=`ArrowLeft`,Sr=`ArrowRight`,Cr=`Home`,wr=new Set([xr,Sr]),Tr=new Set([xr,Sr,Cr,`End`]),Er=new Set([yr,br]),Dr=new Set([yr,br,Cr,`End`]),Or=new Set([...wr,...Er]),kr=new Set([...Or,Cr,`End`]),Ar=new Set([yr,br,xr,Sr,Cr,`End`]),jr=new Set([`Shift`,`Control`,`Alt`,`Meta`]);function Mr(e){return R(e)&&e.tagName===`INPUT`}function Nr(e){return!!(Mr(e)&&e.selectionStart!=null||R(e)&&e.tagName===`TEXTAREA`)}function Pr(e,t,n,r){if(!e||!t||!t.scrollTo)return;let i=e.scrollLeft,a=e.scrollTop,o=e.clientWidth<e.scrollWidth,s=e.clientHeight<e.scrollHeight;if(o&&r!==`vertical`){let r=Fr(e,t,`left`),a=Ir(e),o=Ir(t);n===`ltr`&&(r+t.offsetWidth+o.scrollMarginRight>e.scrollLeft+e.clientWidth-a.scrollPaddingRight?i=r+t.offsetWidth+o.scrollMarginRight-e.clientWidth+a.scrollPaddingRight:r-o.scrollMarginLeft<e.scrollLeft+a.scrollPaddingLeft&&(i=r-o.scrollMarginLeft-a.scrollPaddingLeft)),n===`rtl`&&(r-o.scrollMarginRight<e.scrollLeft+a.scrollPaddingLeft?i=r-o.scrollMarginLeft-a.scrollPaddingLeft:r+t.offsetWidth+o.scrollMarginRight>e.scrollLeft+e.clientWidth-a.scrollPaddingRight&&(i=r+t.offsetWidth+o.scrollMarginRight-e.clientWidth+a.scrollPaddingRight))}if(s&&r!==`horizontal`){let n=Fr(e,t,`top`),r=Ir(e),i=Ir(t);n-i.scrollMarginTop<e.scrollTop+r.scrollPaddingTop?a=n-i.scrollMarginTop-r.scrollPaddingTop:n+t.offsetHeight+i.scrollMarginBottom>e.scrollTop+e.clientHeight-r.scrollPaddingBottom&&(a=n+t.offsetHeight+i.scrollMarginBottom-e.clientHeight+r.scrollPaddingBottom)}e.scrollTo({left:i,top:a,behavior:`auto`})}function Fr(e,t,n){let r=n===`left`?`offsetLeft`:`offsetTop`,i=0;for(;t.offsetParent&&(i+=t[r],t.offsetParent!==e);)t=t.offsetParent;return i}function Ir(e){let t=getComputedStyle(e);return{scrollMarginTop:parseFloat(t.scrollMarginTop)||0,scrollMarginRight:parseFloat(t.scrollMarginRight)||0,scrollMarginBottom:parseFloat(t.scrollMarginBottom)||0,scrollMarginLeft:parseFloat(t.scrollMarginLeft)||0,scrollPaddingTop:parseFloat(t.scrollPaddingTop)||0,scrollPaddingRight:parseFloat(t.scrollPaddingRight)||0,scrollPaddingBottom:parseFloat(t.scrollPaddingBottom)||0,scrollPaddingLeft:parseFloat(t.scrollPaddingLeft)||0}}var Lr={...Ke,...Ie,nestedDialogOpen(e){return e?{[gr.nestedDialogOpen]:``}:null}},Rr=Y.forwardRef(function(e,t){let{className:n,finalFocus:r,initialFocus:i,render:a,style:o,...s}=e,{store:c}=dr(),u=c.useState(`descriptionElementId`),d=c.useState(`disablePointerDismissal`),f=c.useState(`floatingRootContext`),p=c.useState(`popupProps`),m=c.useState(`modal`),h=c.useState(`mounted`),g=c.useState(`nested`),_=c.useState(`nestedOpenDialogCount`),v=c.useState(`open`),y=c.useState(`openMethod`),b=c.useState(`titleElementId`),x=c.useState(`transitionStatus`),S=c.useState(`role`);vr(),We({open:v,ref:c.context.popupRef,onComplete(){v&&c.context.onOpenChangeComplete?.(!0)}});function C(e){return e===`touch`?c.context.popupRef.current:!0}let w=i===void 0?C:i,T=l(`div`,e,{state:{open:v,nested:g,transitionStatus:x,nestedDialogOpen:_>0},props:[p,{"aria-labelledby":b??void 0,"aria-describedby":u??void 0,role:S,tabIndex:-1,hidden:!h,onKeyDown(e){Ar.has(e.key)&&e.stopPropagation()},style:{[hr.nestedDialogs]:_}},s],ref:[t,c.context.popupRef,c.useStateSetter(`popupElement`)],stateAttributesMapping:Lr});return(0,X.jsx)(zt,{context:f,openInteractionType:y,disabled:!h,closeOnFocusOut:!d,initialFocus:w,returnFocus:r,modal:m!==!1,restoreFocus:`popup`,children:T})}),zr=Y.forwardRef(function(e,t){let{cutout:n,...r}=e,i;if(n){let e=n.getBoundingClientRect();i=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${e.left}px ${e.top}px,${e.left}px ${e.bottom}px,${e.right}px ${e.bottom}px,${e.right}px ${e.top}px,${e.left}px ${e.top}px)`}return(0,X.jsx)(`div`,{ref:t,role:`presentation`,"data-base-ui-inert":``,...r,style:{position:`fixed`,inset:0,userSelect:`none`,WebkitUserSelect:`none`,clipPath:i}})}),Br=Y.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i}=dr(),a=i.useState(`mounted`),o=i.useState(`modal`),s=i.useState(`open`);return a||n?(0,X.jsx)(_r.Provider,{value:n,children:(0,X.jsxs)(Ee,{ref:t,...r,children:[a&&o===!0&&(0,X.jsx)(zr,{ref:i.context.internalBackdropRef,inert:Ht(!s)}),e.children]})}):null}),Vr={},Hr={},Ur=``;function Wr(e){if(typeof document>`u`)return!1;let t=U(e);return f(t).innerWidth-t.documentElement.clientWidth>0}function Gr(e){if(!(typeof CSS<`u`&&CSS.supports&&CSS.supports(`scrollbar-gutter`,`stable`))||typeof document>`u`)return!1;let t=U(e),n=t.documentElement,r=t.body,i=A(n)?n:r,a=i.style.overflowY,o=n.style.scrollbarGutter;n.style.scrollbarGutter=`stable`,i.style.overflowY=`scroll`;let s=i.offsetWidth;i.style.overflowY=`hidden`;let c=i.offsetWidth;return i.style.overflowY=a,n.style.scrollbarGutter=o,s===c}function Kr(e){let t=U(e),n=t.documentElement,r=t.body,i=A(n)?n:r,a={overflowY:i.style.overflowY,overflowX:i.style.overflowX};return Object.assign(i.style,{overflowY:`hidden`,overflowX:`hidden`}),()=>{Object.assign(i.style,a)}}function qr(e){let t=U(e),n=t.documentElement,r=t.body,i=f(n),a=0,o=0,s=!1,c=q.create();if(y&&(i.visualViewport?.scale??1)!==1)return()=>{};function l(){let t=i.getComputedStyle(n),c=i.getComputedStyle(r),l=(t.scrollbarGutter||``).includes(`both-edges`)?`stable both-edges`:`stable`;a=n.scrollTop,o=n.scrollLeft,Vr={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},Ur=n.style.scrollBehavior,Hr={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};let u=n.scrollHeight>n.clientHeight,d=n.scrollWidth>n.clientWidth,f=t.overflowY===`scroll`||c.overflowY===`scroll`,p=t.overflowX===`scroll`||c.overflowX===`scroll`,m=Math.max(0,i.innerWidth-r.clientWidth),h=Math.max(0,i.innerHeight-r.clientHeight),g=parseFloat(c.marginTop)+parseFloat(c.marginBottom),_=parseFloat(c.marginLeft)+parseFloat(c.marginRight),v=A(n)?n:r;if(s=Gr(e),s){n.style.scrollbarGutter=l,v.style.overflowY=`hidden`,v.style.overflowX=`hidden`;return}Object.assign(n.style,{scrollbarGutter:l,overflowY:`hidden`,overflowX:`hidden`}),(u||f)&&(n.style.overflowY=`scroll`),(d||p)&&(n.style.overflowX=`scroll`),Object.assign(r.style,{position:`relative`,height:g||h?`calc(100dvh - ${g+h}px)`:`100dvh`,width:_||m?`calc(100vw - ${_+m}px)`:`100vw`,boxSizing:`border-box`,overflow:`hidden`,scrollBehavior:`unset`}),r.scrollTop=a,r.scrollLeft=o,n.setAttribute(`data-base-ui-scroll-locked`,``),n.style.scrollBehavior=`unset`}function u(){Object.assign(n.style,Vr),Object.assign(r.style,Hr),s||(n.scrollTop=a,n.scrollLeft=o,n.removeAttribute(`data-base-ui-scroll-locked`),n.style.scrollBehavior=Ur)}function d(){u(),c.request(l)}l();let p=g(i,`resize`,d);return()=>{c.cancel(),u(),typeof i.removeEventListener==`function`&&p()}}var Jr=new class{lockCount=0;restore=null;timeoutLock=te.create();timeoutUnlock=te.create();acquire(e){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(e)),this.release}release=()=>{--this.lockCount,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(e){if(this.lockCount===0||this.restore!==null)return;let t=U(e).documentElement,n=f(t).getComputedStyle(t).overflowY;if(n===`hidden`||n===`clip`){this.restore=T;return}let r=F||!Wr(e);this.restore=r?Kr(e):qr(e)}};function Yr(e=!0,t=null){m(()=>{if(e)return Jr.acquire(t)},[e,t])}function Xr(e){let t=Y.useRef(``),n=Y.useCallback(n=>{n.defaultPrevented||(t.current=n.pointerType,e(n,n.pointerType))},[e]);return{onClick:Y.useCallback(n=>{if(n.detail===0){e(n,`keyboard`);return}`pointerType`in n?e(n,n.pointerType):e(n,t.current),t.current=``},[e]),onPointerDown:n}}function Zr(e,t){let n=Y.useRef(e),r=_(t);m(()=>{n.current!==e&&r(n.current)},[e,r]),m(()=>{n.current=e},[e])}function Qr(e){let[t,n]=Y.useState(null),r=_((t,r)=>{e||n(r||(F?`touch`:``))});Zr(e,t=>{t&&!e&&n(null)});let{onClick:i,onPointerDown:a}=Xr(r);return Y.useMemo(()=>({openMethod:t,triggerProps:{onClick:i,onPointerDown:a}}),[t,i,a])}function $r(e){let{store:n,parentContext:r,actionsRef:i,isDrawer:a}=e,o=n.useState(`open`),s=n.useState(`disablePointerDismissal`),c=n.useState(`modal`),l=n.useState(`popupElement`),{openMethod:u,triggerProps:d}=Qr(o);Ye(n);let{forceUnmount:f}=Fe(o,n),p=Y.useCallback(()=>{n.setOpen(!1,W(xe))},[n]);Y.useImperativeHandle(i,()=>({unmount:f,close:p}),[f,p]);let m=Ue({popupStore:n,onOpenChange:n.setOpen,treatPopupAsFloatingElement:!0}),[h,g]=Y.useState(0),[_,v]=Y.useState(0),y=h===0,b=Vt(m),x=Ze(m,{outsidePressEvent(){return n.context.internalBackdropRef.current||n.context.backdropRef.current?`intentional`:{mouse:c===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}},outsidePress(e){if(!n.context.outsidePressEnabledRef.current||`button`in e&&e.button!==0||`touches`in e&&e.touches.length!==1)return!1;let r=t(e);if(y&&!s){let e=r;return c&&(n.context.internalBackdropRef.current||n.context.backdropRef.current)?n.context.internalBackdropRef.current===e||n.context.backdropRef.current===e||V(e,l)&&!e?.hasAttribute(`data-base-ui-portal`):!0}return!1},escapeKey:y});Yr(o&&c===!0,l);let{getReferenceProps:S,getFloatingProps:C,getTriggerProps:w}=je([b,x]);n.useContextCallback(`onNestedDialogOpen`,(e,t)=>{g(e),v(t)}),n.useContextCallback(`onNestedDialogClose`,()=>{g(0),v(0)}),Y.useEffect(()=>(r?.onNestedDialogOpen&&o&&r.onNestedDialogOpen(h+1,_+ +!!a),r?.onNestedDialogClose&&!o&&r.onNestedDialogClose(),()=>{r?.onNestedDialogClose&&o&&r.onNestedDialogClose()}),[a,o,h,_,r]);let T=Y.useMemo(()=>S(d),[S,d]),E=Y.useMemo(()=>w(d),[w,d]),D=Y.useMemo(()=>C(),[C]);n.useSyncedValues({openMethod:u,activeTriggerProps:T,inactiveTriggerProps:E,popupProps:D,floatingRootContext:m,nestedOpenDialogCount:h,nestedOpenDrawerCount:_})}var ei={...Pe,modal:Me(e=>e.modal),nested:Me(e=>e.nested),nestedOpenDialogCount:Me(e=>e.nestedOpenDialogCount),nestedOpenDrawerCount:Me(e=>e.nestedOpenDrawerCount),disablePointerDismissal:Me(e=>e.disablePointerDismissal),openMethod:Me(e=>e.openMethod),descriptionElementId:Me(e=>e.descriptionElementId),titleElementId:Me(e=>e.titleElementId),viewportElement:Me(e=>e.viewportElement),role:Me(e=>e.role)},ti=class e extends Qe{constructor(e){super(ni(e),{popupRef:Y.createRef(),backdropRef:Y.createRef(),internalBackdropRef:Y.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:new Ve,onOpenChange:void 0,onOpenChangeComplete:void 0},ei)}setOpen=(e,t)=>{if(t.preventUnmountOnClose=()=>{this.set(`preventUnmountingOnClose`,!0)},!e&&t.trigger==null&&this.state.activeTriggerId!=null&&(t.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let n={open:e},r=t.trigger?.id??null;(r||e)&&(n.activeTriggerId=r,n.activeTriggerElement=t.trigger??null),this.update(n)};static useStore(t,r){let i=n(()=>new e(r)).current;return t??i}};function ni(e={}){return{...qe(),modal:!0,disablePointerDismissal:!1,popupElement:null,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:`dialog`,...e}}var ri=Y.createContext(!1);function ii(e){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,disablePointerDismissal:o=!1,modal:s=!0,actionsRef:c,handle:l,triggerId:u,defaultTriggerId:d=null}=e,f=dr(!0),p=Y.useContext(ri),m=!!f,h=ti.useStore(l?.store,{open:r,openProp:n,activeTriggerId:d,triggerIdProp:u,modal:s,disablePointerDismissal:o,nested:m});Oe(()=>{n===void 0&&h.state.open===!1&&r===!0&&h.update({open:!0,activeTriggerId:d})}),h.useControlledProp(`openProp`,n),h.useControlledProp(`triggerIdProp`,u),h.useSyncedValues({disablePointerDismissal:o,nested:m,modal:s}),h.useContextCallback(`onOpenChange`,i),h.useContextCallback(`onOpenChangeComplete`,a);let g=h.useState(`payload`);$r({store:h,actionsRef:c,parentContext:f?.store.context,isDrawer:p,onOpenChange:i,triggerIdProp:u});let _=Y.useMemo(()=>({store:h}),[h]);return(0,X.jsx)(ri.Provider,{value:!1,children:(0,X.jsx)(ur.Provider,{value:_,children:typeof t==`function`?t({payload:g}):t})})}var ai=Y.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,{store:s}=dr(),u=c(a);return s.useSyncedValueWithCleanup(`titleElementId`,u),l(`h2`,e,{ref:t,props:[{id:u},o]})});function oi(e){let t=(0,$.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,X.jsx)(ii,{"data-slot":`dialog`,...n}),t[2]=n,t[3]=r),r}function si(e){let t=(0,$.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,X.jsx)(Br,{"data-slot":`dialog-portal`,...n}),t[2]=n,t[3]=r),r}function ci(t){let n=(0,$.c)(8),r,i;n[0]===t?(r=n[1],i=n[2]):({className:r,...i}=t,n[0]=t,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=e(`fixed inset-0 isolate z-50 bg-black/80 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==a?(o=(0,X.jsx)(pr,{"data-slot":`dialog-overlay`,className:a,...i}),n[5]=i,n[6]=a,n[7]=o):o=n[7],o}function li(t){let n=(0,$.c)(15),r,i,a,o;n[0]===t?(r=n[1],i=n[2],a=n[3],o=n[4]):({className:i,children:r,showCloseButton:o,...a}=t,n[0]=t,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s=o===void 0?!0:o,c;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,X.jsx)(ci,{}),n[5]=c):c=n[5];let l;n[6]===i?l=n[7]:(l=e(`fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-xs/relaxed text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,i),n[6]=i,n[7]=l);let u;n[8]===s?u=n[9]:(u=s&&(0,X.jsxs)(mr,{"data-slot":`dialog-close`,render:(0,X.jsx)(H,{variant:`ghost`,className:`absolute top-2 right-2`,size:`icon-sm`}),children:[(0,X.jsx)(ot,{}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Close`})]}),n[8]=s,n[9]=u);let d;return n[10]!==r||n[11]!==a||n[12]!==l||n[13]!==u?(d=(0,X.jsxs)(si,{children:[c,(0,X.jsxs)(Rr,{"data-slot":`dialog-content`,className:l,...a,children:[r,u]})]}),n[10]=r,n[11]=a,n[12]=l,n[13]=u,n[14]=d):d=n[14],d}function ui(t){let n=(0,$.c)(8),r,i;n[0]===t?(r=n[1],i=n[2]):({className:r,...i}=t,n[0]=t,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=e(`flex flex-col gap-1`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==a?(o=(0,X.jsx)(`div`,{"data-slot":`dialog-header`,className:a,...i}),n[5]=i,n[6]=a,n[7]=o):o=n[7],o}function di(t){let n=(0,$.c)(14),r,i,a,o;n[0]===t?(r=n[1],i=n[2],a=n[3],o=n[4]):({className:i,showCloseButton:o,children:r,...a}=t,n[0]=t,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s=o===void 0?!1:o,c;n[5]===i?c=n[6]:(c=e(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,i),n[5]=i,n[6]=c);let l;n[7]===s?l=n[8]:(l=s&&(0,X.jsx)(mr,{render:(0,X.jsx)(H,{variant:`outline`}),children:`Close`}),n[7]=s,n[8]=l);let u;return n[9]!==r||n[10]!==a||n[11]!==c||n[12]!==l?(u=(0,X.jsxs)(`div`,{"data-slot":`dialog-footer`,className:c,...a,children:[r,l]}),n[9]=r,n[10]=a,n[11]=c,n[12]=l,n[13]=u):u=n[13],u}function fi(t){let n=(0,$.c)(8),r,i;n[0]===t?(r=n[1],i=n[2]):({className:r,...i}=t,n[0]=t,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=e(`font-heading text-sm font-medium`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==a?(o=(0,X.jsx)(ai,{"data-slot":`dialog-title`,className:a,...i}),n[5]=i,n[6]=a,n[7]=o):o=n[7],o}function pi(t){let n=(0,$.c)(8),r,i;n[0]===t?(r=n[1],i=n[2]):({className:r,...i}=t,n[0]=t,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=e(`flex items-center gap-2 text-xs/relaxed leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==a?(o=(0,X.jsx)(`label`,{"data-slot":`label`,className:a,...i}),n[5]=i,n[6]=a,n[7]=o):o=n[7],o}function mi(t){let n=(0,$.c)(8),r,i;n[0]===t?(r=n[1],i=n[2]):({className:r,...i}=t,n[0]=t,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=e(`group/field-group @container/field-group flex w-full flex-col gap-4 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==a?(o=(0,X.jsx)(`div`,{"data-slot":`field-group`,className:a,...i}),n[5]=i,n[6]=a,n[7]=o):o=n[7],o}var hi=u(`group/field flex w-full gap-2 data-[invalid=true]:text-destructive`,{variants:{orientation:{vertical:`flex-col *:w-full [&>.sr-only]:w-auto`,horizontal:`flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px`,responsive:`flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px`}},defaultVariants:{orientation:`vertical`}});function gi(t){let n=(0,$.c)(11),r,i,a;n[0]===t?(r=n[1],i=n[2],a=n[3]):({className:r,orientation:a,...i}=t,n[0]=t,n[1]=r,n[2]=i,n[3]=a);let o=a===void 0?`vertical`:a,s;n[4]!==r||n[5]!==o?(s=e(hi({orientation:o}),r),n[4]=r,n[5]=o,n[6]=s):s=n[6];let c;return n[7]!==o||n[8]!==i||n[9]!==s?(c=(0,X.jsx)(`fieldset`,{"data-slot":`field`,"data-orientation":o,className:s,...i}),n[7]=o,n[8]=i,n[9]=s,n[10]=c):c=n[10],c}function _i(t){let n=(0,$.c)(8),r,i;n[0]===t?(r=n[1],i=n[2]):({className:r,...i}=t,n[0]=t,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=e(`group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border *:data-[slot=field]:p-2 dark:has-data-checked:bg-primary/10`,`has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==a?(o=(0,X.jsx)(pi,{"data-slot":`field-label`,className:a,...i}),n[5]=i,n[6]=a,n[7]=o):o=n[7],o}function vi(t){let n=(0,$.c)(15),r,i,a,o;n[0]===t?(r=n[1],i=n[2],a=n[3],o=n[4]):({className:i,children:r,errors:a,...o}=t,n[0]=t,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s;bb0:{if(r){s=r;break bb0}if(!a?.length){s=null;break bb0}let e;n[5]===a?e=n[6]:(e=[...new Map(a.map(bi)).values()],n[5]=a,n[6]=e);let t=e;if(t?.length===1){s=t[0]?.message;break bb0}let i;n[7]===t?i=n[8]:(i=(0,X.jsx)(`ul`,{className:`ml-4 flex list-disc flex-col gap-1`,children:t.map(yi)}),n[7]=t,n[8]=i),s=i}let c=s;if(!c)return null;let l;n[9]===i?l=n[10]:(l=e(`text-xs/relaxed font-normal text-destructive`,i),n[9]=i,n[10]=l);let u;return n[11]!==c||n[12]!==o||n[13]!==l?(u=(0,X.jsx)(`div`,{role:`alert`,"data-slot":`field-error`,className:l,...o,children:c}),n[11]=c,n[12]=o,n[13]=l,n[14]=u):u=n[14],u}function yi(e){return e?.message&&(0,X.jsx)(`li`,{children:e.message},e.message)}function bi(e){return[e?.message,e]}var xi=function(e){return e.disabled=`data-disabled`,e.valid=`data-valid`,e.invalid=`data-invalid`,e.touched=`data-touched`,e.dirty=`data-dirty`,e.filled=`data-filled`,e.focused=`data-focused`,e}({}),Si={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},Ci={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},wi={disabled:!1,...Ci},Ti={valid(e){return e===null?null:e?{[xi.valid]:``}:{[xi.invalid]:``}}},Ei=Y.createContext({invalid:void 0,name:void 0,validityData:{state:Si,errors:[],error:``,value:``,initialValue:null},setValidityData:T,disabled:void 0,touched:Ci.touched,setTouched:T,dirty:Ci.dirty,setDirty:T,filled:Ci.filled,setFilled:T,focused:Ci.focused,setFocused:T,validate:()=>null,validationMode:`onSubmit`,validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:wi,markedDirtyRef:{current:!1},registerFieldControl:T,validation:{getValidationProps:(e=z)=>e,getInputValidationProps:(e=z)=>e,inputRef:{current:null},commit:async()=>{}}});function Di(e=!0){let t=Y.useContext(Ei);if(t.setValidityData===T&&!e)throw Error(B(28));return t}var Oi=Y.createContext({controlId:void 0,registerControlId:T,labelId:void 0,setLabelId:T,messageIds:[],setMessageIds:T,getDescriptionProps:e=>e});function ki(){return Y.useContext(Oi)}function Ai(e={}){let{id:t,implicit:r=!1,controlRef:i}=e,{controlId:a,registerControlId:o}=ki(),s=c(t),l=r?a:void 0,u=n(()=>Symbol(`labelable-control`)),d=Y.useRef(!1),f=Y.useRef(t!=null),p=_(()=>{!d.current||o===T||(d.current=!1,o(u.current,void 0))});return m(()=>{if(o===T)return;let e;if(r){let n=i?.current;e=E(n)&&n.closest(`label`)!=null?t??null:l??s}else if(t!=null)f.current=!0,e=t;else if(f.current)e=s;else{p();return}if(e===void 0){p();return}d.current=!0,o(u.current,e)},[t,i,l,o,r,s,u,p]),Y.useEffect(()=>p,[p]),a??s}function ji(e,t){let{enabled:n=!0,getValue:r,id:i,value:a}=t,{registerFieldControl:o}=Di(),s=Y.useRef(null);s.current||=Symbol(),m(()=>{let t=s.current;if(!(!t||!n))return o(t,{controlRef:e,getValue:r,id:i,value:a}),()=>{o(t,void 0)}},[e,n,r,i,o,a])}var Mi=Y.forwardRef(function(e,t){let{render:n,className:r,id:i,name:a,value:o,disabled:s=!1,onValueChange:c,defaultValue:u,autoFocus:d=!1,style:f,...h}=e,{state:g,name:v,disabled:y,setTouched:b,setDirty:x,validityData:S,setFocused:C,setFilled:w,validationMode:T,validation:E}=Di(),D=y||s,O=v??a,k={...g,disabled:D},{labelId:A}=ki(),j=Ai({id:i});m(()=>{let e=o!=null;E.inputRef.current?.value||e&&o!==``?w(!0):e&&o===``&&w(!1)},[E.inputRef,w,o]);let M=Y.useRef(null);m(()=>{d&&M.current===p(U(M.current))&&C(!0)},[d,C]);let[N]=Wn({controlled:o,default:u,name:`FieldControl`,state:`value`}),P=o!==void 0,F=P?N:void 0,I=_(()=>E.inputRef.current?.value);return ji(E.inputRef,{id:j,value:F,getValue:I}),l(`input`,e,{ref:[t,M],state:k,props:[{id:j,disabled:D,name:O,ref:E.inputRef,"aria-labelledby":A,autoFocus:d,...P?{value:F}:{defaultValue:u},onChange(e){let t=e.currentTarget.value;c?.(t,W(K,e.nativeEvent)),x(t!==S.initialValue),w(t!==``)},onFocus(){C(!0)},onBlur(e){b(!0),C(!1),T===`onBlur`&&E.commit(e.currentTarget.value)},onKeyDown(e){e.currentTarget.tagName===`INPUT`&&e.key===`Enter`&&(b(!0),E.commit(e.currentTarget.value))}},E.getInputValidationProps(),h],stateAttributesMapping:Ti})}),Ni=Y.forwardRef(function(e,t){return(0,X.jsx)(Mi,{ref:t,...e})});function Pi(t){let n=(0,$.c)(10),r,i,a;n[0]===t?(r=n[1],i=n[2],a=n[3]):({className:r,type:a,...i}=t,n[0]=t,n[1]=r,n[2]=i,n[3]=a);let o;n[4]===r?o=n[5]:(o=e(`h-7 w-full min-w-0 rounded-md border border-input bg-input/20 px-2 py-0.5 text-sm transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-xs/relaxed file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 md:text-xs/relaxed dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,r),n[4]=r,n[5]=o);let s;return n[6]!==i||n[7]!==o||n[8]!==a?(s=(0,X.jsx)(Ni,{type:a,"data-slot":`input`,className:o,...i}),n[6]=i,n[7]=o,n[8]=a,n[9]=s):s=n[9],s}function Fi(t){let n=(0,$.c)(14),r,i,a;n[0]===t?(r=n[1],i=n[2],a=n[3]):({className:r,size:a,...i}=t,n[0]=t,n[1]=r,n[2]=i,n[3]=a);let o=a===void 0?`default`:a,s;n[4]===r?s=n[5]:(s=e(`group/native-select relative w-fit has-[select:disabled]:opacity-50`,r),n[4]=r,n[5]=s);let c;n[6]!==i||n[7]!==o?(c=(0,X.jsx)(`select`,{"data-slot":`native-select`,"data-size":o,className:`h-7 w-full min-w-0 appearance-none rounded-md border border-input bg-input/20 py-0.5 pr-6 pl-2 text-xs/relaxed transition-colors outline-none select-none selection:bg-primary selection:text-primary-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 disabled:pointer-events-none disabled:cursor-not-allowed aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 data-[size=sm]:h-6 data-[size=sm]:text-[0.625rem] dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,...i}),n[6]=i,n[7]=o,n[8]=c):c=n[8];let l;n[9]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,X.jsx)(Gt,{className:`pointer-events-none absolute top-1/2 right-1.5 size-3.5 -translate-y-1/2 text-muted-foreground select-none group-data-[size=sm]/native-select:size-3`,"aria-hidden":`true`,"data-slot":`native-select-icon`}),n[9]=l):l=n[9];let u;return n[10]!==o||n[11]!==s||n[12]!==c?(u=(0,X.jsxs)(`div`,{className:s,"data-slot":`native-select-wrapper`,"data-size":o,children:[c,l]}),n[10]=o,n[11]=s,n[12]=c,n[13]=u):u=n[13],u}function Ii(t){let n=(0,$.c)(8),r,i;n[0]===t?(r=n[1],i=n[2]):({className:r,...i}=t,n[0]=t,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=e(`bg-[Canvas] text-[CanvasText]`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==a?(o=(0,X.jsx)(`option`,{"data-slot":`native-select-option`,className:a,...i}),n[5]=i,n[6]=a,n[7]=o):o=n[7],o}function Li(e){let[t,n]=(0,Y.useState)([]),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(!1);return(0,Y.useEffect)(()=>{let t=!1;return a(!0),w(e).then(e=>{t||n(e)}).catch(()=>{t||r.error(`Failed to load history`)}).finally(()=>{t||a(!1)}),()=>{t=!0}},[e]),{versions:t,isLoading:i,reverting:o,revert:async t=>{s(!0);try{return await S(e,t),await I.invalidateQueries({queryKey:[`memories`]}),n(await w(e)),!0}catch{return r.error(`Failed to revert — try again`),!1}finally{s(!1)}}}}function Ri(e,t){let n=(0,$.c)(27),i,a;n[0]===e?(i=n[1],a=n[2]):(i=t=>t.from({m:ee}).where(t=>{let{m:n}=t;return h(n.id,e)}),a=[e],n[0]=e,n[1]=i,n[2]=a);let{data:o,isLoading:s}=ne(i,a),c;n[3]===o?c=n[4]:(c=o===void 0?[]:o,n[3]=o,n[4]=c);let l=c[0]??null,u;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=[],n[5]=u):u=n[5];let{data:d}=ne(Vi,u),f;n[6]===d?f=n[7]:(f=d===void 0?[]:d,n[6]=d,n[7]=f);let p=f,m;n[8]===e?m=n[9]:(m=()=>{O(e,{needsReview:!1}).then(Bi)},n[8]=e,n[9]=m);let g=m,_;n[10]===e?_=n[11]:(_=async t=>{try{return await b(e,t),await I.invalidateQueries({queryKey:[`memories`]}),!0}catch{return r.error(`Failed to add project — try again`),!1}},n[10]=e,n[11]=_);let y=_,x;n[12]===e?x=n[13]:(x=async t=>{try{await v(e,t),await I.invalidateQueries({queryKey:[`memories`]})}catch{r.error(`Failed to remove project — try again`)}},n[12]=e,n[13]=x);let S=x,C=zi,w;if(n[14]!==p||n[15]!==l?.projects){let e;n[17]===l?.projects?e=n[18]:(e=e=>!l?.projects.some(t=>t.id===e.id),n[17]=l?.projects,n[18]=e),w=p.filter(e),n[14]=p,n[15]=l?.projects,n[16]=w}else w=n[16];let T=w,E;return n[19]!==T||n[20]!==y||n[21]!==g||n[22]!==S||n[23]!==s||n[24]!==l||n[25]!==t?(E={memory:l,isLoading:s,availableProjects:T,handleApprove:g,handleAddProject:y,handleRemoveProject:S,handleDeleteConflicting:C,handleClose:t},n[19]=T,n[20]=y,n[21]=g,n[22]=S,n[23]=s,n[24]=l,n[25]=t,n[26]=E):E=n[26],E}async function zi(e){try{await L(e),await I.invalidateQueries({queryKey:[`memories`]})}catch{r.error(`Failed to delete — try again`)}}function Bi(){return I.invalidateQueries({queryKey:[`memories`]})}function Vi(e){return e.from({p:N})}var Hi=at({content:ct().min(1,`Content is required.`),type:st(lt),tagsInput:ct()});function Ui(e){let t=(0,$.c)(18),{version:n,reverting:r,onConfirm:i,onClose:a}=e,o;t[0]===n.version?o=t[1]:(o=(0,X.jsx)(ui,{children:(0,X.jsxs)(fi,{children:[`Revert to version `,n.version,`?`]})}),t[0]=n.version,t[1]=o);let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The current content will be archived as a new version before restoring this snapshot.`}),t[2]=s):s=t[2];let c;t[3]===n.content?c=t[4]:(c=(0,X.jsx)(`pre`,{className:`text-[11px] font-mono whitespace-pre-wrap rounded border border-border bg-muted px-2 py-1.5 max-h-40 overflow-y-auto`,children:n.content}),t[3]=n.content,t[4]=c);let l;t[5]===a?l=t[6]:(l=(0,X.jsx)(H,{variant:`outline`,size:`sm`,onClick:a,children:`Cancel`}),t[5]=a,t[6]=l);let u=r?`Reverting…`:`Revert`,d;t[7]!==i||t[8]!==r||t[9]!==u?(d=(0,X.jsx)(H,{variant:`default`,size:`sm`,disabled:r,onClick:i,children:u}),t[7]=i,t[8]=r,t[9]=u,t[10]=d):d=t[10];let f;t[11]!==l||t[12]!==d?(f=(0,X.jsxs)(di,{children:[l,d]}),t[11]=l,t[12]=d,t[13]=f):f=t[13];let p;return t[14]!==o||t[15]!==c||t[16]!==f?(p=(0,X.jsxs)(li,{children:[o,s,c,f]}),t[14]=o,t[15]=c,t[16]=f,t[17]=p):p=t[17],p}function Wi(e){let t=(0,$.c)(23),{memoryId:n}=e,{versions:r,isLoading:i,reverting:a,revert:o}=Li(n),[s,c]=(0,Y.useState)(null),l;t[0]!==o||t[1]!==s?(l=async()=>{s&&await o(s.version)&&c(null)},t[0]=o,t[1]=s,t[2]=l):l=t[2];let u=l;if(!i&&r.length===0)return null;let d=s!==null,f;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(f=e=>!e&&c(null),t[3]=f):f=t[3];let p;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,X.jsx)(`span`,{className:`transition-transform group-data-[open]:rotate-90`,children:`›`}),t[4]=p):p=t[4];let m=r.length>0?` (${r.length})`:``,h;t[5]===m?h=t[6]:(h=(0,X.jsxs)(cr,{className:`flex items-center gap-1 cursor-pointer text-[11px] uppercase tracking-wide text-muted-foreground hover:text-foreground transition-colors select-none w-full`,children:[p,`History`,m]}),t[5]=m,t[6]=h);let g;t[7]!==i||t[8]!==r?(g=i?(0,X.jsx)(`p`,{className:`text-[11px] font-mono text-muted-foreground`,children:`Loading…`}):r.map(e=>(0,X.jsxs)(`button`,{type:`button`,className:`w-full text-left rounded border border-border px-2 py-1.5 space-y-0.5 hover:bg-muted transition-colors`,onClick:()=>c(e),children:[(0,X.jsxs)(`div`,{className:`flex justify-between text-[11px] font-mono text-muted-foreground`,children:[(0,X.jsxs)(`span`,{className:`font-medium text-foreground`,children:[`v`,e.version]}),(0,X.jsx)(`span`,{children:new Date(e.createdAt).toLocaleString()})]}),(0,X.jsx)(`p`,{className:`text-[11px] font-mono text-muted-foreground truncate`,children:e.content.slice(0,80)})]},e.version)),t[7]=i,t[8]=r,t[9]=g):g=t[9];let _;t[10]===g?_=t[11]:(_=(0,X.jsx)(lr,{className:`space-y-1 mt-2`,children:g}),t[10]=g,t[11]=_);let v;t[12]!==h||t[13]!==_?(v=(0,X.jsxs)(sr,{className:`group pt-2 border-t border-border`,children:[h,_]}),t[12]=h,t[13]=_,t[14]=v):v=t[14];let y;t[15]!==u||t[16]!==a||t[17]!==s?(y=s!==null&&(0,X.jsx)(Ui,{version:s,reverting:a,onConfirm:()=>void u(),onClose:()=>c(null)}),t[15]=u,t[16]=a,t[17]=s,t[18]=y):y=t[18];let b;return t[19]!==y||t[20]!==d||t[21]!==v?(b=(0,X.jsxs)(oi,{open:d,onOpenChange:f,children:[v,y]}),t[19]=y,t[20]=d,t[21]=v,t[22]=b):b=t[22],b}function Gi(e){let t=(0,$.c)(12),{field:n,label:r,description:i,children:a}=e,o=n.state.meta.isTouched&&!n.state.meta.isValid,s;t[0]!==n.name||t[1]!==r?(s=(0,X.jsx)(_i,{htmlFor:n.name,className:`text-[11px] uppercase tracking-wide text-muted-foreground`,children:r}),t[0]=n.name,t[1]=r,t[2]=s):s=t[2];let c;t[3]!==n.state.meta.errors||t[4]!==o?(c=o&&(0,X.jsx)(vi,{errors:n.state.meta.errors}),t[3]=n.state.meta.errors,t[4]=o,t[5]=c):c=t[5];let l;return t[6]!==a||t[7]!==i||t[8]!==o||t[9]!==s||t[10]!==c?(l=(0,X.jsxs)(gi,{"data-invalid":o,children:[s,a,i,c]}),t[6]=a,t[7]=i,t[8]=o,t[9]=s,t[10]=c,t[11]=l):l=t[11],l}function Ki(e){let t=(0,$.c)(117),{memory:n,availableProjects:r,handleApprove:i,handleAddProject:a,handleRemoveProject:o,handleDeleteConflicting:s,handleClose:c}=e,[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(``),p,m;t[0]===l?(p=t[1],m=t[2]):(p=()=>{if(!l)return;let e=setTimeout(()=>u(!1),1500);return()=>clearTimeout(e)},m=[l],t[0]=l,t[1]=p,t[2]=m),(0,Y.useEffect)(p,m);let h=n.content,g=n.type,_;t[3]===n.tags?_=t[4]:(_=n.tags.join(`, `),t[3]=n.tags,t[4]=_);let v;t[5]!==n.content||t[6]!==n.type||t[7]!==_?(v={content:h,type:g,tagsInput:_},t[5]=n.content,t[6]=n.type,t[7]=_,t[8]=v):v=t[8];let y;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(y={onSubmit:Hi},t[9]=y):y=t[9];let b;t[10]!==n.content||t[11]!==n.id||t[12]!==n.tags||t[13]!==n.type?(b=e=>{let{value:t}=e,r=t.tagsInput.split(`,`).map(Qi).filter(Boolean);ee.update(n.id,e=>{t.content!==n.content&&(e.content=t.content),t.type!==n.type&&(e.type=t.type),JSON.stringify(r)!==JSON.stringify(n.tags)&&(e.tags=r)}),u(!0)},t[10]=n.content,t[11]=n.id,t[12]=n.tags,t[13]=n.type,t[14]=b):b=t[14];let x;t[15]!==v||t[16]!==b?(x={defaultValues:v,validators:y,onSubmit:b},t[15]=v,t[16]=b,t[17]=x):x=t[17];let S=Un(x),C;t[18]===S.state.isDirty?C=t[19]:(C={shouldBlockFn:()=>S.state.isDirty,withResolver:!0},t[18]=S.state.isDirty,t[19]=C);let w=gt(C),T;t[20]!==d||t[21]!==a?(T=async()=>{d&&await a(d)&&f(``)},t[20]=d,t[21]=a,t[22]=T):T=t[22];let E=T,D;t[23]===n.type?D=t[24]:(D=(0,X.jsx)(oe,{variant:n.type,children:n.type}),t[23]=n.type,t[24]=D);let O;t[25]===n.reviewEvents.length?O=t[26]:(O=n.reviewEvents.length>0&&(0,X.jsx)(oe,{variant:`destructive`,title:`Flagged for review — possible duplicate or conflict with another memory`,children:`needs review`}),t[25]=n.reviewEvents.length,t[26]=O);let k;t[27]===n.pinned?k=t[28]:(k=n.pinned&&(0,X.jsx)(oe,{variant:`default`,children:`pinned`}),t[27]=n.pinned,t[28]=k);let A;t[29]!==D||t[30]!==O||t[31]!==k?(A=(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[D,O,k]}),t[29]=D,t[30]=O,t[31]=k,t[32]=A):A=t[32];let j;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,X.jsx)(rt,{weight:`regular`}),t[33]=j):j=t[33];let M;t[34]===c?M=t[35]:(M=(0,X.jsx)(H,{variant:`ghost`,size:`icon-sm`,onClick:c,"aria-label":`Close`,children:j}),t[34]=c,t[35]=M);let N;t[36]!==A||t[37]!==M?(N=(0,X.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2.5 border-b border-border shrink-0`,children:[A,M]}),t[36]=A,t[37]=M,t[38]=N):N=t[38];let P;t[39]===S.Field?P=t[40]:(P=(0,X.jsx)(S.Field,{name:`content`,children:Zi}),t[39]=S.Field,t[40]=P);let F;t[41]===S.Field?F=t[42]:(F=(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,X.jsx)(S.Field,{name:`type`,children:Yi}),(0,X.jsx)(S.Field,{name:`tagsInput`,children:Ji})]}),t[41]=S.Field,t[42]=F);let I;t[43]!==P||t[44]!==F?(I=(0,X.jsxs)(mi,{children:[P,F]}),t[43]=P,t[44]=F,t[45]=I):I=t[45];let L;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,X.jsx)(`p`,{className:`text-[11px] uppercase tracking-wide text-muted-foreground font-mono`,children:`Projects`}),t[46]=L):L=t[46];let R;t[47]===n.projects.length?R=t[48]:(R=n.projects.length===0&&(0,X.jsx)(`span`,{className:`text-[11px] font-mono text-muted-foreground`,children:`Global (no project)`}),t[47]=n.projects.length,t[48]=R);let z;if(t[49]!==o||t[50]!==n.projects){let e;t[52]===o?e=t[53]:(e=e=>(0,X.jsxs)(oe,{variant:`secondary`,className:`gap-1 rounded-full text-[11px]`,children:[e.name,(0,X.jsx)(`button`,{type:`button`,onClick:()=>void o(e.id),className:`hover:text-destructive transition-colors leading-none`,"aria-label":`Remove from ${e.name}`,children:(0,X.jsx)(rt,{weight:`regular`,className:`size-2.5`})})]},e.id),t[52]=o,t[53]=e),z=n.projects.map(e),t[49]=o,t[50]=n.projects,t[51]=z}else z=t[51];let te;t[54]!==R||t[55]!==z?(te=(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[R,z]}),t[54]=R,t[55]=z,t[56]=te):te=t[56];let ne;t[57]!==d||t[58]!==r||t[59]!==E?(ne=r.length>0&&(0,X.jsxs)(`div`,{className:`flex gap-1`,children:[(0,X.jsxs)(Fi,{value:d,onChange:e=>f(e.target.value),size:`sm`,className:`flex-1`,children:[(0,X.jsx)(Ii,{value:``,children:`Add to project…`}),r.map(qi)]}),(0,X.jsx)(H,{variant:`outline`,size:`sm`,disabled:!d,onClick:()=>void E(),children:`+`})]}),t[57]=d,t[58]=r,t[59]=E,t[60]=ne):ne=t[60];let re;t[61]!==te||t[62]!==ne?(re=(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[L,te,ne]}),t[61]=te,t[62]=ne,t[63]=re):re=t[63];let B;t[64]!==s||t[65]!==n.reviewEvents?(B=n.reviewEvents.length>0&&(0,X.jsxs)(sr,{defaultOpen:!0,className:`group pt-2 border-t border-border`,children:[(0,X.jsxs)(cr,{className:`flex items-center gap-1 cursor-pointer text-[11px] uppercase tracking-wide text-muted-foreground hover:text-foreground transition-colors select-none w-full`,children:[(0,X.jsx)(`span`,{className:`transition-transform group-data-[open]:rotate-90`,children:`›`}),`Review reasons`]}),(0,X.jsx)(lr,{className:`space-y-2 mt-2`,children:n.reviewEvents.map(e=>(0,X.jsxs)(`div`,{className:`rounded border border-border p-2 space-y-1 text-[11px]`,children:[(0,X.jsxs)(`div`,{className:`flex justify-between text-muted-foreground`,children:[(0,X.jsxs)(`span`,{className:`font-medium text-destructive`,children:[Math.round(e.similarity*100),`% similarity match`]}),(0,X.jsx)(`span`,{children:new Date(e.createdAt).toLocaleString()})]}),e.conflictingMemoryId?(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsxs)(`div`,{className:`text-muted-foreground font-mono min-w-0`,children:[`Conflicting:`,` `,(0,X.jsx)(`span`,{className:`font-mono text-[10px]`,children:e.conflictingMemoryId})]}),(0,X.jsx)(H,{variant:`ghost`,size:`sm`,className:`text-destructive hover:text-destructive shrink-0 h-5 px-1.5 text-[10px]`,onClick:()=>{let t=e.conflictingMemoryId;t&&s(t)},children:`Delete conflicting`})]}):(0,X.jsx)(`div`,{className:`text-muted-foreground italic`,children:`Conflicting memory deleted`}),e.conflictContentSnapshot&&(0,X.jsxs)(sr,{children:[(0,X.jsx)(cr,{className:`text-muted-foreground hover:text-foreground transition-colors cursor-pointer`,children:`Show conflicting content ›`}),(0,X.jsx)(lr,{children:(0,X.jsx)(`p`,{className:`mt-1 text-foreground bg-muted rounded px-2 py-1 whitespace-pre-wrap font-mono`,children:e.conflictContentSnapshot})})]})]},e.id))})]}),t[64]=s,t[65]=n.reviewEvents,t[66]=B):B=t[66];let ie;t[67]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,X.jsxs)(cr,{className:`flex items-center gap-1 cursor-pointer text-[11px] uppercase tracking-wide text-muted-foreground hover:text-foreground transition-colors select-none w-full`,children:[(0,X.jsx)(`span`,{className:`transition-transform group-data-[open]:rotate-90`,children:`›`}),`Details`]}),t[67]=ie):ie=t[67];let V;t[68]===n.sourceHarness?V=t[69]:(V=n.sourceHarness&&(0,X.jsxs)(`div`,{className:`flex justify-between text-[11px] font-mono text-muted-foreground`,children:[(0,X.jsx)(`span`,{children:`Source`}),(0,X.jsx)(`span`,{children:n.sourceHarness})]}),t[68]=n.sourceHarness,t[69]=V);let ae;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,X.jsx)(`span`,{children:`Accessed`}),t[70]=ae):ae=t[70];let se;t[71]===n.accessCount?se=t[72]:(se=(0,X.jsxs)(`div`,{className:`flex justify-between text-[11px] font-mono text-muted-foreground`,children:[ae,(0,X.jsxs)(`span`,{children:[n.accessCount,`×`]})]}),t[71]=n.accessCount,t[72]=se);let ce;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,X.jsx)(`span`,{children:`Updated`}),t[73]=ce):ce=t[73];let le;t[74]===n.updatedAt?le=t[75]:(le=new Date(n.updatedAt).toLocaleString(),t[74]=n.updatedAt,t[75]=le);let ue;t[76]===le?ue=t[77]:(ue=(0,X.jsxs)(`div`,{className:`flex justify-between text-[11px] font-mono text-muted-foreground`,children:[ce,(0,X.jsx)(`span`,{children:le})]}),t[76]=le,t[77]=ue);let U;t[78]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,X.jsx)(`span`,{children:`Created`}),t[78]=U):U=t[78];let de;t[79]===n.createdAt?de=t[80]:(de=new Date(n.createdAt).toLocaleString(),t[79]=n.createdAt,t[80]=de);let fe;t[81]===de?fe=t[82]:(fe=(0,X.jsxs)(`div`,{className:`flex justify-between text-[11px] font-mono text-muted-foreground`,children:[U,(0,X.jsx)(`span`,{children:de})]}),t[81]=de,t[82]=fe);let pe;t[83]!==V||t[84]!==se||t[85]!==ue||t[86]!==fe?(pe=(0,X.jsxs)(sr,{className:`group pt-2 border-t border-border`,children:[ie,(0,X.jsxs)(lr,{className:`space-y-1 mt-2`,children:[V,se,ue,fe]})]}),t[83]=V,t[84]=se,t[85]=ue,t[86]=fe,t[87]=pe):pe=t[87];let me;t[88]===n.id?me=t[89]:(me=(0,X.jsx)(Wi,{memoryId:n.id}),t[88]=n.id,t[89]=me);let he;t[90]!==I||t[91]!==re||t[92]!==B||t[93]!==pe||t[94]!==me?(he=(0,X.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-4 py-4 space-y-4`,children:[I,re,B,pe,me]}),t[90]=I,t[91]=re,t[92]=B,t[93]=pe,t[94]=me,t[95]=he):he=t[95];let ge;t[96]===w?ge=t[97]:(ge=w.status===`blocked`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`text-xs font-mono text-destructive`,children:`Unsaved changes`}),(0,X.jsx)(H,{variant:`ghost`,size:`sm`,onClick:()=>w.proceed(),children:`Discard`}),(0,X.jsx)(H,{variant:`outline`,size:`sm`,onClick:()=>w.reset(),children:`Keep editing`})]}),t[96]=w,t[97]=ge);let _e;t[98]!==w.status||t[99]!==i||t[100]!==n.reviewEvents.length?(_e=n.reviewEvents.length>0&&w.status!==`blocked`&&(0,X.jsx)(H,{variant:`outline`,size:`sm`,onClick:i,title:`Mark as reviewed — this memory was flagged as a possible duplicate or conflict`,children:`Mark reviewed`}),t[98]=w.status,t[99]=i,t[100]=n.reviewEvents.length,t[101]=_e):_e=t[101];let ve;t[102]===Symbol.for(`react.memo_cache_sentinel`)?(ve=(0,X.jsx)(`div`,{className:`flex-1`}),t[102]=ve):ve=t[102];let ye=!S.state.isDirty,be;t[103]===S?be=t[104]:(be=()=>void S.handleSubmit(),t[103]=S,t[104]=be);let xe=l?`Saved`:`Save`,W;t[105]!==ye||t[106]!==be||t[107]!==xe?(W=(0,X.jsx)(H,{variant:`default`,size:`sm`,disabled:ye,onClick:be,children:xe}),t[105]=ye,t[106]=be,t[107]=xe,t[108]=W):W=t[108];let G;t[109]!==ge||t[110]!==_e||t[111]!==W?(G=(0,X.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-3 border-t border-border shrink-0`,children:[ge,_e,ve,W]}),t[109]=ge,t[110]=_e,t[111]=W,t[112]=G):G=t[112];let K;return t[113]!==N||t[114]!==he||t[115]!==G?(K=(0,X.jsxs)(`div`,{className:`flex flex-col h-full`,children:[N,he,G]}),t[113]=N,t[114]=he,t[115]=G,t[116]=K):K=t[116],K}function qi(e){return(0,X.jsx)(Ii,{value:e.id,children:e.name},e.id)}function Ji(e){return(0,X.jsx)(Gi,{field:e,label:`Tags`,children:(0,X.jsx)(Pi,{id:e.name,name:e.name,value:e.state.value,onBlur:e.handleBlur,onChange:t=>e.handleChange(t.target.value),placeholder:`tag1, tag2`,"aria-invalid":e.state.meta.isTouched&&!e.state.meta.isValid})})}function Yi(e){return(0,X.jsx)(Gi,{field:e,label:`Type`,description:(0,X.jsx)(`p`,{className:`text-[10px] text-muted-foreground leading-snug`,children:nt[e.state.value]}),children:(0,X.jsx)(Fi,{id:e.name,name:e.name,value:e.state.value,onBlur:e.handleBlur,onChange:t=>e.handleChange(t.target.value),className:`w-full`,children:lt.map(Xi)})})}function Xi(e){return(0,X.jsx)(Ii,{value:e,children:j(e)},e)}function Zi(e){return(0,X.jsx)(Gi,{field:e,label:`Content`,children:(0,X.jsx)(dt,{id:e.name,name:e.name,value:e.state.value,onBlur:e.handleBlur,onChange:t=>e.handleChange(t.target.value),rows:8,className:`min-h-32 font-heading text-sm`,"aria-invalid":e.state.meta.isTouched&&!e.state.meta.isValid})})}function Qi(e){return e.trim()}function $i(e){let t=(0,$.c)(13),{id:n}=e,{projectId:r}=it.useParams(),i=ae(),a;t[0]!==i||t[1]!==r?(a=()=>void i({to:`/$projectId`,params:{projectId:r},search:ea}),t[0]=i,t[1]=r,t[2]=a):a=t[2];let{memory:o,isLoading:s,availableProjects:c,handleApprove:l,handleAddProject:u,handleRemoveProject:d,handleDeleteConflicting:f,handleClose:p}=Ri(n,a);if(s||!o){let e=s?`Loading…`:`Memory not found`,n;return t[3]===e?n=t[4]:(n=(0,X.jsx)(`div`,{className:`flex items-center justify-center h-full text-xs font-mono text-muted-foreground`,children:e}),t[3]=e,t[4]=n),n}let m;return t[5]!==c||t[6]!==u||t[7]!==l||t[8]!==p||t[9]!==f||t[10]!==d||t[11]!==o?(m=(0,X.jsx)(Ki,{memory:o,availableProjects:c,handleApprove:l,handleAddProject:u,handleRemoveProject:d,handleDeleteConflicting:f,handleClose:p},o.id),t[5]=c,t[6]=u,t[7]=l,t[8]=p,t[9]=f,t[10]=d,t[11]=o,t[12]=m):m=t[12],m}function ea(e){return e}export{lr as C,Ht as E,sr as S,Wn as T,jr as _,di as a,Nr as b,kr as c,xr as d,Sr as f,Tr as g,wr as h,li as i,br as l,Cr as m,Pi as n,ui as o,yr as p,oi as r,fi as s,$i as t,Or as u,Er as v,cr as w,Pr as x,Dr as y};
|