@membank/dashboard 0.10.0 → 0.11.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/bin.mjs +73 -1
- package/dist/client/assets/AppLink-CcI58QNL.js +3 -0
- package/dist/client/assets/WorkspaceMemoryDetail-CKp3CCbn.js +1 -0
- package/dist/client/assets/_projectId-Eeq3OhFZ.js +4 -0
- package/dist/client/assets/_projectId._memoryId-BFlrz98g.js +1 -0
- package/dist/client/assets/collections-gO05Tpa7.js +19 -0
- package/dist/client/assets/index--CCYAGMc.js +48 -0
- package/dist/client/assets/index-BudjKWgr.css +2 -0
- package/dist/client/assets/popupStateMapping-CKjEg8lE.js +1 -0
- package/dist/client/assets/preload-helper-DEuj8E0K.js +1 -0
- package/dist/client/assets/review-CnySMKKH.js +1 -0
- package/dist/client/assets/routes-LNNp11yc.js +1 -0
- package/dist/client/assets/spinner-B9RlP5lt.js +1 -0
- package/dist/client/assets/textarea-BLDQQzbc.js +1 -0
- package/dist/client/index.html +5 -4
- package/dist/index.cjs +72 -0
- package/dist/index.mjs +73 -1
- package/package.json +1 -1
- package/dist/client/assets/WorkspaceMemoryDetail-B-SQPmf_.js +0 -1
- package/dist/client/assets/_projectId-ChOHT2g6.js +0 -40
- package/dist/client/assets/_projectId-DdCE-NRK.js +0 -4
- package/dist/client/assets/_projectId._memoryId-j78rWv7Z.js +0 -1
- package/dist/client/assets/collections-Ci78mgZL.js +0 -19
- package/dist/client/assets/index-DcreRb0E.js +0 -10
- package/dist/client/assets/index-RbnYc2mC.css +0 -2
- package/dist/client/assets/routes-CDZywPpw.js +0 -1
- package/dist/client/assets/typeColors-BREuYmod.js +0 -3
- /package/dist/client/assets/{_projectId.index-jEbJri1I.js → _projectId.index-8YNIf2cB.js} +0 -0
package/dist/bin.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import { Command } from "commander";
|
|
|
7
7
|
import ora from "ora";
|
|
8
8
|
import { createServer } from "node:net";
|
|
9
9
|
import { serve } from "@hono/node-server";
|
|
10
|
-
import { ActivityEventTypeSchema, DatabaseManager, EmbeddingService, QueryEngine, createActivityLogger, createActivityRepository, createMemoryRepository, createProjectRepository, createSynthesisAgentRunner, createSynthesisRepository, deleteMemory, isSynthesisEnabled, listEvents, revertMemory, revertSynthesis, runSynthesis, updateMemory } from "@membank/core";
|
|
10
|
+
import { ActivityEventTypeSchema, DatabaseManager, EmbeddingService, QueryEngine, clusterFlagged, createActivityLogger, createActivityRepository, createMemoryRepository, createProjectRepository, createSynthesisAgentRunner, createSynthesisRepository, deleteManyMemories, deleteMemory, isSynthesisEnabled, listEvents, mergeMemories, resolveReviewMany, revertMemory, revertSynthesis, runSynthesis, suggestMerge, updateMemory } from "@membank/core";
|
|
11
11
|
import { Hono } from "hono";
|
|
12
12
|
import open from "open";
|
|
13
13
|
//#region src/server/index.ts
|
|
@@ -94,6 +94,78 @@ function createApiApp(repo, projectRepo, embedder, queryEngine, synthRepo, activ
|
|
|
94
94
|
}
|
|
95
95
|
return c.json(memories);
|
|
96
96
|
});
|
|
97
|
+
app.get("/api/memories/flagged-clusters", (c) => {
|
|
98
|
+
const projectIdParam = c.req.query("projectId");
|
|
99
|
+
const project = projectIdParam ? projectRepo.list().find((p) => p.id === projectIdParam) : void 0;
|
|
100
|
+
const clusters = clusterFlagged(repo.listReviewEdges(project?.scopeHash));
|
|
101
|
+
const inActiveCluster = new Set(clusters.flatMap((cl) => cl.memoryIds));
|
|
102
|
+
const activeResults = clusters.map((cl) => {
|
|
103
|
+
const memories = repo.findManyById(cl.memoryIds);
|
|
104
|
+
const maxSimilarity = memories.reduce((max, m) => {
|
|
105
|
+
const sim = m.reviewEvents.reduce((ms, e) => Math.max(ms, e.similarity), 0);
|
|
106
|
+
return Math.max(max, sim);
|
|
107
|
+
}, 0);
|
|
108
|
+
return {
|
|
109
|
+
clusterId: cl.clusterId,
|
|
110
|
+
memories,
|
|
111
|
+
maxSimilarity,
|
|
112
|
+
isStale: false
|
|
113
|
+
};
|
|
114
|
+
});
|
|
115
|
+
const staleResults = repo.list({
|
|
116
|
+
needsReview: true,
|
|
117
|
+
...project && { projectId: project.id }
|
|
118
|
+
}).filter((m) => !inActiveCluster.has(m.id)).map((m) => ({
|
|
119
|
+
clusterId: m.id,
|
|
120
|
+
memories: [m],
|
|
121
|
+
maxSimilarity: 0,
|
|
122
|
+
isStale: true
|
|
123
|
+
}));
|
|
124
|
+
return c.json([...activeResults, ...staleResults].sort((a, b) => b.maxSimilarity - a.maxSimilarity));
|
|
125
|
+
});
|
|
126
|
+
app.post("/api/memories/merge", async (c) => {
|
|
127
|
+
const body = await c.req.json();
|
|
128
|
+
if (typeof body.keepId !== "string" || !Array.isArray(body.dropIds) || typeof body.mergedContent !== "string") return c.json({ error: "keepId, dropIds, and mergedContent are required" }, 400);
|
|
129
|
+
try {
|
|
130
|
+
const { kept } = await mergeMemories({
|
|
131
|
+
keepId: body.keepId,
|
|
132
|
+
dropIds: body.dropIds,
|
|
133
|
+
mergedContent: body.mergedContent
|
|
134
|
+
}, {
|
|
135
|
+
repo,
|
|
136
|
+
embedder,
|
|
137
|
+
activityLogger
|
|
138
|
+
});
|
|
139
|
+
return c.json(kept);
|
|
140
|
+
} catch (err) {
|
|
141
|
+
return c.json({ error: err instanceof Error ? err.message : String(err) }, 400);
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
app.post("/api/memories/merge-suggest", async (c) => {
|
|
145
|
+
if (!isSynthesisEnabled()) return c.json({ error: "Synthesis is disabled" }, 503);
|
|
146
|
+
const body = await c.req.json();
|
|
147
|
+
if (!Array.isArray(body.ids)) return c.json({ error: "ids array is required" }, 400);
|
|
148
|
+
const memories = body.ids.map((id) => repo.findById(id)).filter((m) => m !== void 0);
|
|
149
|
+
if (memories.length === 0) return c.json({ error: "No memories found for given ids" }, 404);
|
|
150
|
+
try {
|
|
151
|
+
const content = await suggestMerge(memories.map((m) => m.content));
|
|
152
|
+
return c.json({ content });
|
|
153
|
+
} catch (err) {
|
|
154
|
+
return c.json({ error: err instanceof Error ? err.message : String(err) }, 500);
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
app.post("/api/memories/delete-many", async (c) => {
|
|
158
|
+
const body = await c.req.json();
|
|
159
|
+
if (!Array.isArray(body.ids)) return c.json({ error: "ids array is required" }, 400);
|
|
160
|
+
const results = await deleteManyMemories(body.ids, repo, activityLogger);
|
|
161
|
+
return c.json(results);
|
|
162
|
+
});
|
|
163
|
+
app.post("/api/memories/resolve-many", async (c) => {
|
|
164
|
+
const body = await c.req.json();
|
|
165
|
+
if (!Array.isArray(body.ids)) return c.json({ error: "ids array is required" }, 400);
|
|
166
|
+
const results = resolveReviewMany(body.ids, repo);
|
|
167
|
+
return c.json(results);
|
|
168
|
+
});
|
|
97
169
|
app.get("/api/memories/:id", (c) => {
|
|
98
170
|
const memory = repo.findById(c.req.param("id"));
|
|
99
171
|
if (!memory) return c.json({ error: "Not found" }, 404);
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{A as e,Et as t,O as n,fn as r,hn as i,pn as a,wt as o}from"./collections-gO05Tpa7.js";var s=o(),c=r();function l(t){let n=(0,s.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 w-full min-w-0 flex-1 flex-col items-center justify-center gap-4 rounded-xl border-dashed p-6 text-center text-balance`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==a?(o=(0,c.jsx)(`div`,{"data-slot":`empty`,className:a,...i}),n[5]=i,n[6]=a,n[7]=o):o=n[7],o}n(`mb-2 flex shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg]:shrink-0`,{variants:{variant:{default:`bg-transparent`,icon:`flex size-8 shrink-0 items-center justify-center rounded-md bg-muted text-foreground [&_svg:not([class*='size-'])]:size-4`}},defaultVariants:{variant:`default`}});function u(t){let n=(0,s.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 tracking-tight`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==a?(o=(0,c.jsx)(`div`,{"data-slot":`empty-title`,className:a,...i}),n[5]=i,n[6]=a,n[7]=o):o=n[7],o}function d(t){let n=(0,s.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(`text-xs/relaxed text-muted-foreground [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==a?(o=(0,c.jsx)(`div`,{"data-slot":`empty-description`,className:a,...i}),n[5]=i,n[6]=a,n[7]=o):o=n[7],o}var f=`0000000000000000`,p=`global`;function m(e,t){let n=e.split(`
|
|
2
|
+
`),r=t.split(`
|
|
3
|
+
`),i=n.length,a=r.length,o=Array.from({length:i+1},()=>Array(a+1).fill(0));for(let e=1;e<=i;e++){let t=o[e],i=o[e-1];if(!(t===void 0||i===void 0))for(let o=1;o<=a;o++)n[e-1]===r[o-1]?t[o]=(i[o-1]??0)+1:t[o]=Math.max(i[o]??0,t[o-1]??0)}let s=[],c=i,l=a;for(;c>0||l>0;){let e=n[c-1],t=r[l-1],i=o[c],a=o[c-1];c>0&&l>0&&e===t?(s.push({kind:`context`,line:e??``}),c--,l--):l>0&&(c===0||(i?.[l-1]??0)>=(a?.[l]??0))?(s.push({kind:`added`,line:t??``}),l--):(s.push({kind:`removed`,line:e??``}),c--)}return s.reverse(),s}function h(t){let n=(0,s.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(`animate-pulse rounded-md bg-muted`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==a?(o=(0,c.jsx)(`div`,{"data-slot":`skeleton`,className:a,...i}),n[5]=i,n[6]=a,n[7]=o):o=n[7],o}var g=n(``,{variants:{type:{correction:``,preference:``,decision:``,learning:``,fact:``},tone:{text:``,bg:``}},compoundVariants:[{type:`correction`,tone:`text`,class:`text-correction`},{type:`preference`,tone:`text`,class:`text-preference`},{type:`decision`,tone:`text`,class:`text-decision`},{type:`learning`,tone:`text`,class:`text-learning`},{type:`fact`,tone:`text`,class:`text-fact`},{type:`correction`,tone:`bg`,class:`bg-correction`},{type:`preference`,tone:`bg`,class:`bg-preference`},{type:`decision`,tone:`bg`,class:`bg-decision`},{type:`learning`,tone:`bg`,class:`bg-learning`},{type:`fact`,tone:`bg`,class:`bg-fact`}],defaultVariants:{tone:`text`}}),_=t(i(a(),1).forwardRef((e,t)=>{let n=(0,s.c)(3),r;return n[0]!==e||n[1]!==t?(r=(0,c.jsx)(`a`,{ref:t,...e}),n[0]=e,n[1]=t,n[2]=r):r=n[2],r})),v=e=>{let t=(0,s.c)(2),n;return t[0]===e?n=t[1]:(n=(0,c.jsx)(_,{preload:`intent`,...e}),t[0]=e,t[1]=n),n};export{p as a,d as c,m as i,u as l,g as n,f as o,h as r,l as s,v as t};
|
|
@@ -0,0 +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};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{A as e,B as t,Ct as n,D as r,H as i,M as a,N as o,O as s,Ot as c,R as l,S as u,St as d,T as f,Tt as p,V as m,c as h,fn as g,hn as _,i as v,j as y,k as b,kt as x,lt as S,m as C,n as w,on as T,pn as E,r as D,t as O,ut as k,v as A,w as j,wt as M,x as N,xt as P,z as F}from"./collections-gO05Tpa7.js";import{a as I,d as L,i as R,n as z,o as ee,r as te,s as B}from"./preload-helper-DEuj8E0K.js";import{C as V,E as H,S as U,T as W,_ as G,a as K,b as q,c as ne,d as J,f as Y,g as re,h as ie,i as ae,l as oe,n as se,o as ce,p as le,r as ue,s as de,t as fe,u as pe,v as me,w as he,x as ge,y as _e}from"./WorkspaceMemoryDetail-CKp3CCbn.js";import{B as ve,Ct as ye,G as be,H as xe,J as Se,K as Ce,Ot as we,Pt as Te,U as Ee,V as De,W as Oe,Y as ke,_ as Ae,g as je,h as Me,p as Ne}from"./popupStateMapping-CKjEg8lE.js";import{a as Pe,i as Fe,n as Ie,r as Le,t as Re}from"./spinner-B9RlP5lt.js";import{c as ze,n as Be,p as Ve,s as He,u as Ue,y as We}from"./index--CCYAGMc.js";import{a as Ge,c as Ke,i as qe,l as Je,n as Ye,r as X,s as Xe,t as Ze}from"./AppLink-CcI58QNL.js";var Z=_(E(),1);function Qe(e){let t=x({warn:e?.router===void 0}),n=e?.router||t,r=(0,Z.useRef)(void 0);return c(n.stores.__store,t=>{if(e?.select){if(e.structuralSharing??n.options.defaultStructuralSharing){let n=T(r.current,e.select(t));return r.current=n,n}return e.select(t)}return t})}var $e=new Map([[`bold`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M228,48V96a12,12,0,0,1-12,12H168a12,12,0,0,1,0-24h19l-7.8-7.8a75.55,75.55,0,0,0-53.32-22.26h-.43A75.49,75.49,0,0,0,72.39,75.57,12,12,0,1,1,55.61,58.41a99.38,99.38,0,0,1,69.87-28.47H126A99.42,99.42,0,0,1,196.2,59.23L204,67V48a12,12,0,0,1,24,0ZM183.61,180.43a75.49,75.49,0,0,1-53.09,21.63h-.43A75.55,75.55,0,0,1,76.77,179.8L69,172H88a12,12,0,0,0,0-24H40a12,12,0,0,0-12,12v48a12,12,0,0,0,24,0V189l7.8,7.8A99.42,99.42,0,0,0,130,226.06h.56a99.38,99.38,0,0,0,69.87-28.47,12,12,0,0,0-16.78-17.16Z`}))],[`duotone`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M216,128a88,88,0,1,1-88-88A88,88,0,0,1,216,128Z`,opacity:`0.2`}),Z.createElement(`path`,{d:`M224,48V96a8,8,0,0,1-8,8H168a8,8,0,0,1,0-16h28.69L182.06,73.37a79.56,79.56,0,0,0-56.13-23.43h-.45A79.52,79.52,0,0,0,69.59,72.71,8,8,0,0,1,58.41,61.27a96,96,0,0,1,135,.79L208,76.69V48a8,8,0,0,1,16,0ZM186.41,183.29a80,80,0,0,1-112.47-.66L59.31,168H88a8,8,0,0,0,0-16H40a8,8,0,0,0-8,8v48a8,8,0,0,0,16,0V179.31l14.63,14.63A95.43,95.43,0,0,0,130,222.06h.53a95.36,95.36,0,0,0,67.07-27.33,8,8,0,0,0-11.18-11.44Z`}))],[`fill`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M224,48V96a8,8,0,0,1-8,8H168a8,8,0,0,1-5.66-13.66L180.65,72a79.48,79.48,0,0,0-54.72-22.09h-.45A79.52,79.52,0,0,0,69.59,72.71,8,8,0,0,1,58.41,61.27,96,96,0,0,1,192,60.7l18.36-18.36A8,8,0,0,1,224,48ZM186.41,183.29A80,80,0,0,1,75.35,184l18.31-18.31A8,8,0,0,0,88,152H40a8,8,0,0,0-8,8v48a8,8,0,0,0,13.66,5.66L64,195.3a95.42,95.42,0,0,0,66,26.76h.53a95.36,95.36,0,0,0,67.07-27.33,8,8,0,0,0-11.18-11.44Z`}))],[`light`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M222,48V96a6,6,0,0,1-6,6H168a6,6,0,0,1,0-12h33.52L183.47,72a81.51,81.51,0,0,0-57.53-24h-.46A81.5,81.5,0,0,0,68.19,71.28a6,6,0,1,1-8.38-8.58,93.38,93.38,0,0,1,65.67-26.76H126a93.45,93.45,0,0,1,66,27.53l18,18V48a6,6,0,0,1,12,0ZM187.81,184.72a81.5,81.5,0,0,1-57.29,23.34h-.46a81.51,81.51,0,0,1-57.53-24L54.48,166H88a6,6,0,0,0,0-12H40a6,6,0,0,0-6,6v48a6,6,0,0,0,12,0V174.48l18,18.05a93.45,93.45,0,0,0,66,27.53h.52a93.38,93.38,0,0,0,65.67-26.76,6,6,0,1,0-8.38-8.58Z`}))],[`regular`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M224,48V96a8,8,0,0,1-8,8H168a8,8,0,0,1,0-16h28.69L182.06,73.37a79.56,79.56,0,0,0-56.13-23.43h-.45A79.52,79.52,0,0,0,69.59,72.71,8,8,0,0,1,58.41,61.27a96,96,0,0,1,135,.79L208,76.69V48a8,8,0,0,1,16,0ZM186.41,183.29a80,80,0,0,1-112.47-.66L59.31,168H88a8,8,0,0,0,0-16H40a8,8,0,0,0-8,8v48a8,8,0,0,0,16,0V179.31l14.63,14.63A95.43,95.43,0,0,0,130,222.06h.53a95.36,95.36,0,0,0,67.07-27.33,8,8,0,0,0-11.18-11.44Z`}))],[`thin`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M220,48V96a4,4,0,0,1-4,4H168a4,4,0,0,1,0-8h38.34L184.89,70.54A84,84,0,0,0,66.8,69.85a4,4,0,1,1-5.6-5.72,92,92,0,0,1,129.34.76L212,86.34V48a4,4,0,0,1,8,0ZM189.2,186.15a83.44,83.44,0,0,1-58.68,23.91h-.47a83.52,83.52,0,0,1-58.94-24.6L49.66,164H88a4,4,0,0,0,0-8H40a4,4,0,0,0-4,4v48a4,4,0,0,0,8,0V169.66l21.46,21.45A91.43,91.43,0,0,0,130,218.06h.51a91.45,91.45,0,0,0,64.28-26.19,4,4,0,1,0-5.6-5.72Z`}))]]),et=new Map([[`bold`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M216,204H141l86.84-86.84a28,28,0,0,0,0-39.6L186.43,36.19a28,28,0,0,0-39.6,0L28.19,154.82a28,28,0,0,0,0,39.6l30.06,30.07A12,12,0,0,0,66.74,228H216a12,12,0,0,0,0-24ZM163.8,53.16a4,4,0,0,1,5.66,0l41.38,41.38a4,4,0,0,1,0,5.65L160,151l-47-47ZM71.71,204,45.16,177.45a4,4,0,0,1,0-5.65L96,121l47,47-36,36Z`}))],[`duotone`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M160,168l-48,48H66.75L36.69,185.94a16,16,0,0,1,0-22.63L96,104Z`,opacity:`0.2`}),Z.createElement(`path`,{d:`M225,80.4,183.6,39a24,24,0,0,0-33.94,0L31,157.66a24,24,0,0,0,0,33.94l30.06,30.06A8,8,0,0,0,66.74,224H216a8,8,0,0,0,0-16h-84.7L225,114.34A24,24,0,0,0,225,80.4ZM108.68,208H70.05L42.33,180.28a8,8,0,0,1,0-11.31L96,115.31,148.69,168Zm105-105L160,156.69,107.31,104,161,50.34a8,8,0,0,1,11.32,0l41.38,41.38a8,8,0,0,1,0,11.31Z`}))],[`fill`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M225,80.4,183.6,39a24,24,0,0,0-33.94,0L31,157.66a24,24,0,0,0,0,33.94l30.06,30.06A8,8,0,0,0,66.74,224H216a8,8,0,0,0,0-16h-84.7L225,114.34A24,24,0,0,0,225,80.4ZM213.67,103,160,156.69,107.31,104,161,50.34a8,8,0,0,1,11.32,0l41.38,41.38a8,8,0,0,1,0,11.31Z`}))],[`light`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M223.57,81.81,182.19,40.43a22,22,0,0,0-31.12,0L32.43,159.07a22,22,0,0,0,0,31.11L62.5,220.24A6,6,0,0,0,66.74,222H216a6,6,0,0,0,0-12H126.49l97.08-97.08A22,22,0,0,0,223.57,81.81ZM109.51,210H69.22l-28.3-28.3a10,10,0,0,1,0-14.15L96,112.48,151.52,168ZM215.08,104.44,160,159.51,104.48,104l55.08-55.07a10,10,0,0,1,14.14,0l41.38,41.37A10,10,0,0,1,215.08,104.44Z`}))],[`regular`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M225,80.4,183.6,39a24,24,0,0,0-33.94,0L31,157.66a24,24,0,0,0,0,33.94l30.06,30.06A8,8,0,0,0,66.74,224H216a8,8,0,0,0,0-16h-84.7L225,114.34A24,24,0,0,0,225,80.4ZM108.68,208H70.05L42.33,180.28a8,8,0,0,1,0-11.31L96,115.31,148.69,168Zm105-105L160,156.69,107.31,104,161,50.34a8,8,0,0,1,11.32,0l41.38,41.38a8,8,0,0,1,0,11.31Z`}))],[`thin`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M222.15,83.22,180.77,41.85a20,20,0,0,0-28.28,0L33.85,160.48a20,20,0,0,0,0,28.29l30.06,30.06A4,4,0,0,0,66.74,220H216a4,4,0,0,0,0-8H121.66L222.15,111.51A20,20,0,0,0,222.15,83.22ZM110.34,212H68.4L39.51,183.11a12,12,0,0,1,0-17L96,109.65,154.35,168ZM216.49,105.85,160,162.34,101.65,104l56.49-56.48a12,12,0,0,1,17,0l41.37,41.37A12,12,0,0,1,216.49,105.85Z`}))]]),tt=new Map([[`bold`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M232.49,215.51,185,168a92.12,92.12,0,1,0-17,17l47.53,47.54a12,12,0,0,0,17-17ZM44,112a68,68,0,1,1,68,68A68.07,68.07,0,0,1,44,112Z`}))],[`duotone`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M192,112a80,80,0,1,1-80-80A80,80,0,0,1,192,112Z`,opacity:`0.2`}),Z.createElement(`path`,{d:`M229.66,218.34,179.6,168.28a88.21,88.21,0,1,0-11.32,11.31l50.06,50.07a8,8,0,0,0,11.32-11.32ZM40,112a72,72,0,1,1,72,72A72.08,72.08,0,0,1,40,112Z`}))],[`fill`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M168,112a56,56,0,1,1-56-56A56,56,0,0,1,168,112Zm61.66,117.66a8,8,0,0,1-11.32,0l-50.06-50.07a88,88,0,1,1,11.32-11.31l50.06,50.06A8,8,0,0,1,229.66,229.66ZM112,184a72,72,0,1,0-72-72A72.08,72.08,0,0,0,112,184Z`}))],[`light`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M228.24,219.76l-51.38-51.38a86.15,86.15,0,1,0-8.48,8.48l51.38,51.38a6,6,0,0,0,8.48-8.48ZM38,112a74,74,0,1,1,74,74A74.09,74.09,0,0,1,38,112Z`}))],[`regular`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M229.66,218.34l-50.07-50.06a88.11,88.11,0,1,0-11.31,11.31l50.06,50.07a8,8,0,0,0,11.32-11.32ZM40,112a72,72,0,1,1,72,72A72.08,72.08,0,0,1,40,112Z`}))],[`thin`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M226.83,221.17l-52.7-52.7a84.1,84.1,0,1,0-5.66,5.66l52.7,52.7a4,4,0,0,0,5.66-5.66ZM36,112a76,76,0,1,1,76,76A76.08,76.08,0,0,1,36,112Z`}))]]),nt=new Map([[`bold`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M238.15,78.54,177.46,17.86a20,20,0,0,0-28.3,0L97.2,70c-12.43-3.33-36.68-5.72-61.74,14.5a20,20,0,0,0-1.6,29.73l45.46,45.47-39.8,39.8a12,12,0,0,0,17,17l39.8-39.81,45.47,45.46A20,20,0,0,0,155.91,228c.46,0,.93,0,1.4-.05A20,20,0,0,0,171.87,220c4.69-6.23,11-16.13,14.44-28s3.45-22.88.16-33.4l51.7-51.87A20,20,0,0,0,238.15,78.54Zm-74.26,68.79a12,12,0,0,0-2.23,13.84c3.43,6.86,6.9,21-6.28,40.65L54.08,100.53c21.09-14.59,39.53-6.64,41-6a11.67,11.67,0,0,0,13.81-2.29l54.43-54.61,55,55Z`}))],[`duotone`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M229.66,98.34,172.39,155.8c11.46,22.93-1.72,45.86-10.11,57a8,8,0,0,1-12,.83L42.34,105.76A8,8,0,0,1,43,93.85c29.65-23.92,57.4-10,57.4-10l57.27-57.46a8,8,0,0,1,11.31,0L229.66,87A8,8,0,0,1,229.66,98.34Z`,opacity:`0.2`}),Z.createElement(`path`,{d:`M235.32,81.37,174.63,20.69a16,16,0,0,0-22.63,0L98.37,74.49c-10.66-3.34-35-7.37-60.4,13.14a16,16,0,0,0-1.29,23.78L85,159.71,42.34,202.34a8,8,0,0,0,11.32,11.32L96.29,171l48.29,48.29A16,16,0,0,0,155.9,224c.38,0,.75,0,1.13,0a15.93,15.93,0,0,0,11.64-6.33c19.64-26.1,17.75-47.32,13.19-60L235.33,104A16,16,0,0,0,235.32,81.37ZM224,92.69h0l-57.27,57.46a8,8,0,0,0-1.49,9.22c9.46,18.93-1.8,38.59-9.34,48.62L48,100.08c12.08-9.74,23.64-12.31,32.48-12.31A40.13,40.13,0,0,1,96.81,91a8,8,0,0,0,9.25-1.51L163.32,32,224,92.68Z`}))],[`fill`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M235.33,104l-53.47,53.65c4.56,12.67,6.45,33.89-13.19,60A15.93,15.93,0,0,1,157,224c-.38,0-.75,0-1.13,0a16,16,0,0,1-11.32-4.69L96.29,171,53.66,213.66a8,8,0,0,1-11.32-11.32L85,159.71l-48.3-48.3A16,16,0,0,1,38,87.63c25.42-20.51,49.75-16.48,60.4-13.14L152,20.7a16,16,0,0,1,22.63,0l60.69,60.68A16,16,0,0,1,235.33,104Z`}))],[`light`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M233.91,82.79,173.22,22.1a14,14,0,0,0-19.81,0L98.93,76.77c-9.52-3.25-34-8.34-59.71,12.41A14,14,0,0,0,38.1,110l49.71,49.71-44.05,44a6,6,0,1,0,8.48,8.48l44.05-44.05L146,217.89a14,14,0,0,0,9.9,4.11q.49,0,1,0a14,14,0,0,0,10.19-5.54c19.72-26.21,17.15-47.23,12.46-59.3l54.37-54.55A14,14,0,0,0,233.91,82.79ZM225.42,94.1h0l-57.27,57.46a6,6,0,0,0-1.11,6.92c9.94,19.88-1.71,40.32-9.54,50.72a2,2,0,0,1-3,.2L46.58,101.51a2,2,0,0,1,.18-3c12.5-10.09,24.5-12.76,33.7-12.76a42.13,42.13,0,0,1,17.25,3.41A6,6,0,0,0,104.64,88L161.9,30.59a2,2,0,0,1,2.83,0l60.69,60.68A2,2,0,0,1,225.42,94.1Z`}))],[`regular`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M235.32,81.37,174.63,20.69a16,16,0,0,0-22.63,0L98.37,74.49c-10.66-3.34-35-7.37-60.4,13.14a16,16,0,0,0-1.29,23.78L85,159.71,42.34,202.34a8,8,0,0,0,11.32,11.32L96.29,171l48.29,48.29A16,16,0,0,0,155.9,224c.38,0,.75,0,1.13,0a15.93,15.93,0,0,0,11.64-6.33c19.64-26.1,17.75-47.32,13.19-60L235.33,104A16,16,0,0,0,235.32,81.37ZM224,92.69h0l-57.27,57.46a8,8,0,0,0-1.49,9.22c9.46,18.93-1.8,38.59-9.34,48.62L48,100.08c12.08-9.74,23.64-12.31,32.48-12.31A40.13,40.13,0,0,1,96.81,91a8,8,0,0,0,9.25-1.51L163.32,32,224,92.68Z`}))],[`thin`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M232.49,84.2,171.8,23.51a12,12,0,0,0-17,0L99.45,79.07c-8.08-3-32.79-9.45-59,11.67a12,12,0,0,0-1,17.84l51.13,51.13L45.17,205.17a4,4,0,0,0,5.66,5.66l45.46-45.47,51.12,51.12A12,12,0,0,0,155.9,220c.28,0,.57,0,.85,0a12,12,0,0,0,8.73-4.74c19.83-26.36,16.51-47.18,11.71-58.57l55.3-55.49A12,12,0,0,0,232.49,84.2Zm-5.66,11.31h0L169.56,153a4,4,0,0,0-.75,4.61c10.43,20.85-1.62,42-9.73,52.83a4,4,0,0,1-6,.4L45.17,102.93a4,4,0,0,1,.33-6C58.44,86.53,70.86,83.74,80.44,83.74A43.9,43.9,0,0,1,98.6,87.38a4,4,0,0,0,4.62-.75l57.27-57.46a4,4,0,0,1,5.66,0l60.68,60.69A4,4,0,0,1,226.83,95.51Z`}))]]),rt=new Map([[`bold`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M128,20A108,108,0,1,0,236,128,108.12,108.12,0,0,0,128,20Zm0,192a84,84,0,1,1,84-84A84.09,84.09,0,0,1,128,212Zm-12-80V80a12,12,0,0,1,24,0v52a12,12,0,0,1-24,0Zm28,40a16,16,0,1,1-16-16A16,16,0,0,1,144,172Z`}))],[`duotone`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z`,opacity:`0.2`}),Z.createElement(`path`,{d:`M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm-8-80V80a8,8,0,0,1,16,0v56a8,8,0,0,1-16,0Zm20,36a12,12,0,1,1-12-12A12,12,0,0,1,140,172Z`}))],[`fill`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm-8,56a8,8,0,0,1,16,0v56a8,8,0,0,1-16,0Zm8,104a12,12,0,1,1,12-12A12,12,0,0,1,128,184Z`}))],[`light`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M128,26A102,102,0,1,0,230,128,102.12,102.12,0,0,0,128,26Zm0,192a90,90,0,1,1,90-90A90.1,90.1,0,0,1,128,218Zm-6-82V80a6,6,0,0,1,12,0v56a6,6,0,0,1-12,0Zm16,36a10,10,0,1,1-10-10A10,10,0,0,1,138,172Z`}))],[`regular`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm-8-80V80a8,8,0,0,1,16,0v56a8,8,0,0,1-16,0Zm20,36a12,12,0,1,1-12-12A12,12,0,0,1,140,172Z`}))],[`thin`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M128,28A100,100,0,1,0,228,128,100.11,100.11,0,0,0,128,28Zm0,192a92,92,0,1,1,92-92A92.1,92.1,0,0,1,128,220Zm-4-84V80a4,4,0,0,1,8,0v56a4,4,0,0,1-8,0Zm12,36a8,8,0,1,1-8-8A8,8,0,0,1,136,172Z`}))]]),it=Z.forwardRef((e,t)=>Z.createElement(B,{ref:t,...e,weights:$e}));it.displayName=`ArrowsClockwiseIcon`;var at=it,ot=Z.forwardRef((e,t)=>Z.createElement(B,{ref:t,...e,weights:et}));ot.displayName=`EraserIcon`;var st=ot,ct=Z.forwardRef((e,t)=>Z.createElement(B,{ref:t,...e,weights:tt}));ct.displayName=`MagnifyingGlassIcon`;var lt=ct,ut=Z.forwardRef((e,t)=>Z.createElement(B,{ref:t,...e,weights:nt}));ut.displayName=`PushPinIcon`;var dt=ut,ft=Z.forwardRef((e,t)=>Z.createElement(B,{ref:t,...e,weights:rt}));ft.displayName=`WarningCircleIcon`;var pt=ft,Q=M();function mt(e){let t=(0,Q.c)(10),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=[],t[0]=n):n=t[0];let[r,i]=(0,Z.useState)(n),[a,o]=(0,Z.useState)(!1),{scope:s,type:c,since:l,limit:u}=e,d,f;t[1]!==u||t[2]!==s||t[3]!==l||t[4]!==c?(d=()=>{let e=!1;return o(!0),h({scope:s,type:c,since:l,limit:u}).then(t=>{e||i(t)}).catch(()=>{e||i([])}).finally(()=>{e||o(!1)}),()=>{e=!0}},f=[s,c,l,u],t[1]=u,t[2]=s,t[3]=l,t[4]=c,t[5]=d,t[6]=f):(d=t[5],f=t[6]),(0,Z.useEffect)(d,f);let p;return t[7]!==r||t[8]!==a?(p={events:r,loading:a},t[7]=r,t[8]=a,t[9]=p):p=t[9],p}var $=g(),ht={"memory.created":`Created`,"memory.updated":`Updated`,"memory.deleted":`Deleted`,"memory.flagged":`Flagged`,"memory.queried":`Queried`},gt={"memory.created":`default`,"memory.updated":`secondary`,"memory.deleted":`destructive`,"memory.flagged":`stale`,"memory.queried":`outline`};function _t(e){switch(e.eventType){case`memory.created`:return`Memory saved`;case`memory.updated`:return`Memory updated`;case`memory.deleted`:return`Memory deleted`;case`memory.flagged`:{let t=e.payload.similarity;return typeof t==`number`?`Flagged for review — ${Math.round(t*100)}% similar`:`Flagged for review`}case`memory.queried`:{let t=e.payload.resultCount;return typeof t==`number`?`Query returned ${t} result${t===1?``:`s`}`:`Query`}}}function vt(e){let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<1)return`just now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function yt(e){let t=(0,Q.c)(18),{event:n}=e,r=gt[n.eventType],i=ht[n.eventType],a;t[0]!==r||t[1]!==i?(a=(0,$.jsx)(ee,{variant:r,className:`shrink-0`,children:i}),t[0]=r,t[1]=i,t[2]=a):a=t[2];let o;t[3]===n?o=t[4]:(o=_t(n),t[3]=n,t[4]=o);let s;t[5]===o?s=t[6]:(s=(0,$.jsx)(`span`,{className:`flex-1 min-w-0 text-foreground truncate`,children:o}),t[5]=o,t[6]=s);let c;t[7]===n.memoryId?c=t[8]:(c=n.memoryId!==null&&(0,$.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground shrink-0 hidden sm:block`,children:n.memoryId.slice(0,8)}),t[7]=n.memoryId,t[8]=c);let l;t[9]===n.createdAt?l=t[10]:(l=vt(n.createdAt),t[9]=n.createdAt,t[10]=l);let u;t[11]===l?u=t[12]:(u=(0,$.jsx)(`span`,{className:`text-[11px] text-muted-foreground shrink-0`,children:l}),t[11]=l,t[12]=u);let d;return t[13]!==a||t[14]!==s||t[15]!==c||t[16]!==u?(d=(0,$.jsxs)(`li`,{className:`flex items-center gap-2 border-b border-border px-4 py-3 text-xs`,children:[a,s,c,u]}),t[13]=a,t[14]=s,t[15]=c,t[16]=u,t[17]=d):d=t[17],d}function bt(e){let t=new Map;for(let n of e){let e=n.createdAt.slice(0,10),r=t.get(e);r===void 0?t.set(e,[n]):r.push(n)}return Array.from(t.entries()).sort((e,t)=>t[0].localeCompare(e[0])).map(([e,t])=>({day:e,events:t}))}function xt(e){let t=new Date().toISOString().slice(0,10),n=new Date(Date.now()-864e5).toISOString().slice(0,10);return e===t?`Today`:e===n?`Yesterday`:new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})}function St(e){let t=(0,Q.c)(16),{scope:n}=e,r;t[0]===n?r=t[1]:(r={scope:n,limit:200},t[0]=n,t[1]=r);let{events:i,loading:a}=mt(r),o;t[2]===i?o=t[3]:(o=bt(i),t[2]=i,t[3]=o);let s=o;if(a&&i.length===0){let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`flex items-center justify-center h-24 text-xs font-mono text-muted-foreground`,children:`Loading…`}),t[4]=e):e=t[4],e}if(i.length===0){let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Xe,{className:`border-0 rounded-none p-0 h-32`,children:(0,$.jsx)(Je,{className:`text-xs font-mono font-normal`,children:`No activity yet`})}),t[5]=e):e=t[5],e}let c;t[6]===s?c=t[7]:(c=s.map(Ct),t[6]=s,t[7]=c);let l;t[8]===c?l=t[9]:(l=(0,$.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:c}),t[8]=c,t[9]=l);let u=i.length===1?`event`:`events`,d;t[10]!==i.length||t[11]!==u?(d=(0,$.jsxs)(`div`,{className:`px-4 py-2 border-t border-border shrink-0 text-[11px] font-mono text-muted-foreground`,children:[i.length,` `,u]}),t[10]=i.length,t[11]=u,t[12]=d):d=t[12];let f;return t[13]!==l||t[14]!==d?(f=(0,$.jsxs)(`div`,{className:`flex flex-col h-full`,children:[l,d]}),t[13]=l,t[14]=d,t[15]=f):f=t[15],f}function Ct(e){let{day:t,events:n}=e;return(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`div`,{className:`sticky top-0 z-10 bg-background/95 backdrop-blur-sm px-4 py-1.5 border-b border-border`,children:(0,$.jsx)(`span`,{className:`text-[11px] font-mono text-muted-foreground`,children:xt(t)})}),(0,$.jsx)(`ul`,{className:`m-0 p-0`,children:n.map(wt)})]},t)}function wt(e){return(0,$.jsx)(yt,{event:e},e.id)}var Tt=Z.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},elementsRef:{current:[]},nextIndexRef:{current:0}});function Et(){return Z.useContext(Tt)}function Dt(e){let{children:t,elementsRef:r,labelsRef:i,onMapChange:a}=e,o=m(a),s=Z.useRef(0),c=n(kt).current,l=n(Ot).current,[u,f]=Z.useState(0),p=Z.useRef(u),h=m((e,t)=>{l.set(e,t??null),p.current+=1,f(p.current)}),g=m(e=>{l.delete(e),p.current+=1,f(p.current)}),_=Z.useMemo(()=>{let e=new Map;return Array.from(l.keys()).filter(e=>e.isConnected).sort(At).forEach((t,n)=>{let r=l.get(t)??{};e.set(t,{...r,index:n})}),e},[l,u]);d(()=>{if(typeof MutationObserver!=`function`||_.size===0)return;let e=new MutationObserver(e=>{let t=new Set,n=e=>t.has(e)?t.delete(e):t.add(e);e.forEach(e=>{e.removedNodes.forEach(n),e.addedNodes.forEach(n)}),t.size===0&&(p.current+=1,f(p.current))});return _.forEach((t,n)=>{n.parentElement&&e.observe(n.parentElement,{childList:!0})}),()=>{e.disconnect()}},[_]),d(()=>{p.current===u&&(r.current.length!==_.size&&(r.current.length=_.size),i&&i.current.length!==_.size&&(i.current.length=_.size),s.current=_.size),o(_)},[o,_,r,i,u]),d(()=>()=>{r.current=[]},[r]),d(()=>()=>{i&&(i.current=[])},[i]);let v=m(e=>(c.add(e),()=>{c.delete(e)}));d(()=>{c.forEach(e=>e(_))},[c,_]);let y=Z.useMemo(()=>({register:h,unregister:g,subscribeMapChange:v,elementsRef:r,labelsRef:i,nextIndexRef:s}),[h,g,v,r,i,s]);return(0,$.jsx)(Tt.Provider,{value:y,children:t})}function Ot(){return new Map}function kt(){return new Set}function At(e,t){let n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_FOLLOWING||n&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:n&Node.DOCUMENT_POSITION_PRECEDING||n&Node.DOCUMENT_POSITION_CONTAINS?1:0}var jt=Z.createContext(void 0);function Mt(){let e=Z.useContext(jt);if(e===void 0)throw Error(P(64));return e}var Nt=function(e){return e.activationDirection=`data-activation-direction`,e.orientation=`data-orientation`,e}({}),Pt={tabActivationDirection:e=>({[Nt.activationDirection]:e})},Ft=Z.forwardRef(function(e,t){let{className:n,defaultValue:r=0,onValueChange:i,orientation:a=`horizontal`,render:s,value:c,style:l,...u}=e,f=Object.hasOwn(e,`defaultValue`),p=Z.useRef([]),[h,g]=Z.useState(()=>new Map),[_,v]=W({controlled:c,default:r,name:`Tabs`,state:`value`}),y=c!==void 0,[b,x]=Z.useState(()=>new Map),S=Z.useCallback(e=>{if(e===void 0)return null;for(let[t,n]of b.entries())if(n!=null&&e===(n.value??n.index))return t;return null},[b]),[C,w]=Z.useState(()=>({previousValue:_,tabActivationDirection:`none`})),{previousValue:T,tabActivationDirection:E}=C,D=E,O=!1;T!==_&&(D=It(T,_,a,b),O=T!=null&&_!=null&&S(_)==null);let k=O?T:_,A=T!==k||E!==D;d(()=>{A&&w({previousValue:k,tabActivationDirection:D})},[k,A,D]);let j=m((e,t)=>{t.activationDirection=It(_,e,a,b),i?.(e,t),!t.isCanceled&&v(e)}),M=m((e,t)=>{g(n=>{if(n.get(e)===t)return n;let r=new Map(n);return r.set(e,t),r})}),N=m((e,t)=>{g(n=>{if(!n.has(e)||n.get(e)!==t)return n;let r=new Map(n);return r.delete(e),r})}),P=Z.useCallback(e=>h.get(e),[h]),F=Z.useCallback(e=>{for(let t of b.values())if(e===t?.value)return t?.id},[b]),I=Z.useMemo(()=>({getTabElementBySelectedValue:S,getTabIdByPanelValue:F,getTabPanelIdByValue:P,onValueChange:j,orientation:a,registerMountedTabPanel:M,setTabMap:x,unregisterMountedTabPanel:N,tabActivationDirection:D,value:_}),[S,F,P,j,a,M,x,N,D,_]),L=Z.useMemo(()=>{for(let e of b.values())if(e!=null&&e.value===_)return e},[b,_]),R=Z.useMemo(()=>{for(let e of b.values())if(e!=null&&!e.disabled)return e.value},[b]);d(()=>{if(y||b.size===0)return;let e=L?.disabled;if(f&&e&&_===r||!e&&!(L==null&&_!==null))return;let t=R??null;_!==t&&(v(t),w(e=>e.tabActivationDirection===`none`?e:{...e,tabActivationDirection:`none`}))},[r,R,f,y,L,v,b,_]);let z=o(`div`,e,{state:{orientation:a,tabActivationDirection:D},ref:t,props:u,stateAttributesMapping:Pt});return(0,$.jsx)(jt.Provider,{value:I,children:(0,$.jsx)(Dt,{elementsRef:p,children:z})})});function It(e,t,n,r){if(e==null||t==null)return`none`;let i=null,a=null;for(let[n,o]of r.entries()){if(o==null)continue;let r=o.value??o.index;if(e===r&&(i=n),t===r&&(a=n),i!=null&&a!=null)break}if(i==null||a==null)return i!==a&&(typeof e==`number`||typeof e==`string`)&&typeof e==typeof t?n===`horizontal`?t>e?`right`:`left`:t>e?`down`:`up`:`none`;let o=i.getBoundingClientRect(),s=a.getBoundingClientRect();if(n===`horizontal`){if(s.left<o.left)return`left`;if(s.left>o.left)return`right`}else{if(s.top<o.top)return`up`;if(s.top>o.top)return`down`}return`none`}var Lt=`data-composite-item-active`,Rt=function(e){return e[e.None=0]=`None`,e[e.GuessFromOrder=1]=`GuessFromOrder`,e}({});function zt(e={}){let{label:t,metadata:n,textRef:r,indexGuessBehavior:i,index:a}=e,{register:o,unregister:s,subscribeMapChange:c,elementsRef:l,labelsRef:u,nextIndexRef:f}=Et(),p=Z.useRef(-1),[m,h]=Z.useState(a??(i===Rt.GuessFromOrder?()=>{if(p.current===-1){let e=f.current;f.current+=1,p.current=e}return p.current}:-1)),g=Z.useRef(null),_=Z.useCallback(e=>{if(g.current=e,m!==-1&&e!==null&&(l.current[m]=e,u)){let n=t!==void 0;u.current[m]=n?t:r?.current?.textContent??e.textContent}},[m,l,u,t,r]);return d(()=>{if(a!=null)return;let e=g.current;if(e)return o(e,n),()=>{s(e)}},[a,o,s,n]),d(()=>{if(a==null)return c(e=>{let t=g.current?e.get(g.current)?.index:null;t!=null&&h(t)})},[a,c,h]),Z.useMemo(()=>({ref:_,index:m}),[m,_])}function Bt(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=I(),{ref:a,index:o}=zt(e),s=n===o,c=Z.useRef(null),l=i(a,c);return{compositeProps:Z.useMemo(()=>({tabIndex:s?0:-1,onFocus(){r(o)},onMouseMove(){let e=c.current;if(!t||!e)return;let n=e.hasAttribute(`disabled`)||e.ariaDisabled===`true`;!s&&!n&&e.focus()}}),[s,r,o,t]),compositeRef:l,index:o}}var Vt=Z.createContext(void 0);function Ht(){let e=Z.useContext(Vt);if(e===void 0)throw Error(P(65));return e}var Ut=Z.forwardRef(function(e,t){let{className:n,disabled:r=!1,render:i,value:s,id:c,nativeButton:u=!0,style:f,...p}=e,{value:m,getTabPanelIdByValue:h,orientation:g}=Mt(),{activateOnFocus:_,highlightedTabIndex:v,onTabActivation:y,registerTabResizeObserverElement:b,setHighlightedTabIndex:x,tabsListElement:S}=Ht(),C=a(c),{compositeProps:w,compositeRef:T,index:E}=Bt({metadata:Z.useMemo(()=>({disabled:r,id:C,value:s}),[r,C,s])}),D=s===m,O=Z.useRef(!1),k=Z.useRef(null);Z.useEffect(()=>{let e=k.current;if(e)return b(e)},[b]),d(()=>{if(O.current){O.current=!1;return}if(!(D&&E>-1&&v!==E))return;let e=S;if(e!=null){let t=l(ye(e));if(t&&F(e,t))return}r||x(E)},[D,E,v,x,r,S]);let{getButtonProps:A,buttonRef:j}=te({disabled:r,native:u,focusableWhenDisabled:!0}),M=h(s),N=Z.useRef(!1),P=Z.useRef(!1);function I(e){D||r||y(s,we(Te,e.nativeEvent,void 0,{activationDirection:`none`}))}function L(e){D||(E>-1&&!r&&x(E),!r&&_&&(!N.current||N.current&&P.current)&&y(s,we(Te,e.nativeEvent,void 0,{activationDirection:`none`})))}function R(e){if(D||r)return;N.current=!0;function t(){N.current=!1,P.current=!1}(!e.button||e.button===0)&&(P.current=!0,ye(e.currentTarget).addEventListener(`pointerup`,t,{once:!0}))}return o(`button`,e,{state:{disabled:r,active:D,orientation:g},ref:[t,j,T,k],props:[w,{role:`tab`,"aria-controls":M,"aria-selected":D,id:C,onClick:I,onFocus:L,onPointerDown:R,[Lt]:D?``:void 0,onKeyDownCapture(){O.current=!0}},p,A]})}),Wt=function(e){return e.index=`data-index`,e.activationDirection=`data-activation-direction`,e.orientation=`data-orientation`,e.hidden=`data-hidden`,e[e.startingStyle=Me.startingStyle]=`startingStyle`,e[e.endingStyle=Me.endingStyle]=`endingStyle`,e}({}),Gt={...Pt,...je},Kt=Z.forwardRef(function(e,t){let{className:n,value:r,render:i,keepMounted:s=!1,style:c,...l}=e,{value:u,getTabIdByPanelValue:f,orientation:p,tabActivationDirection:m,registerMountedTabPanel:h,unregisterMountedTabPanel:g}=Mt(),_=a(),{ref:v,index:y}=zt({metadata:Z.useMemo(()=>({id:_,value:r}),[_,r])}),b=r===u,{mounted:x,transitionStatus:S,setMounted:C}=Ae(b),w=!x,T=f(r),E={hidden:w,orientation:p,tabActivationDirection:m,transitionStatus:S},D=Z.useRef(null),O=o(`div`,e,{state:E,ref:[t,v,D],props:[{"aria-labelledby":T,hidden:w,id:_,role:`tabpanel`,tabIndex:b?0:-1,inert:H(!b),[Wt.index]:y},l],stateAttributesMapping:Gt});return Ne({open:b,ref:D,onComplete(){b||C(!1)}}),d(()=>{if(!(w&&!s)&&_!=null)return h(r,_),()=>{g(r,_)}},[w,s,r,_,h,g]),s||x?O:null});function qt(e){return e==null||e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`}var Jt=[];function Yt(e){let{itemSizes:n,cols:r=1,loopFocus:a=!0,onLoop:o,dense:s=!1,orientation:c=`both`,direction:l,highlightedIndex:u,onHighlightedIndexChange:d,rootRef:f,enableHomeAndEndKeys:p=!1,stopEventPropagation:h=!1,disabledIndices:g,modifierKeys:_=Jt}=e,[v,y]=Z.useState(0),b=r>1,x=Z.useRef(null),S=i(x,f),C=Z.useRef([]),w=Z.useRef(!1),T=u??v,E=m((e,t=!1)=>{if((d??y)(e),t){let t=C.current[e];ge(x.current,t,l,c)}}),D=m(e=>{if(e.size===0||w.current)return;w.current=!0;let t=Array.from(e.keys()),n=t.find(e=>e?.hasAttribute(`data-composite-item-active`))??null,r=n?t.indexOf(n):-1;r!==-1&&E(r),ge(x.current,n,l,c)}),O=m((e,t,n)=>o?o?.(e,t,n,C):n),k=Z.useMemo(()=>({"aria-orientation":c===`both`?void 0:c,ref:S,onFocus(e){let n=x.current,r=t(e.nativeEvent);!n||r==null||!q(r)||r.setSelectionRange(0,r.value.length??0)},onKeyDown(e){let i=p?ne:pe;if(!i.has(e.key)||Xt(e,_)||!x.current)return;let u=l===`rtl`,d=u?J:Y,f={horizontal:d,vertical:oe,both:d}[c],m=u?Y:J,v={horizontal:m,vertical:le,both:m}[c],y=t(e.nativeEvent);if(y!=null&&q(y)&&!qt(y)){let t=y.selectionStart,n=y.selectionEnd,r=y.value??``;if(t==null||e.shiftKey||t!==n||e.key!==v&&t<r.length||e.key!==f&&t>0)return}let S=T,w=Ce(C,g),D=be(C,g);if(b){let t=n||Array.from({length:C.current.length},()=>({width:1,height:1})),i=ve(t,r,s),o=i.findIndex(e=>e!=null&&!ke(C.current,e,g)),l=i.reduce((e,t,n)=>t!=null&&!ke(C.current,t,g)?n:e,-1);S=i[Oe(i.map(e=>e==null?null:C.current[e]),{event:e,orientation:c,loopFocus:a,onLoop:O,cols:r,disabledIndices:Ee([...g||C.current.map((e,t)=>ke(C.current,t)?t:void 0),void 0],i),minIndex:o,maxIndex:l,prevIndex:xe(T>D?w:T,t,i,r,e.key===`ArrowDown`?`bl`:e.key===`ArrowRight`?`tr`:`tl`),rtl:u})]}let k={horizontal:[d],vertical:[oe],both:[d,oe]}[c],A={horizontal:[m],vertical:[le],both:[m,le]}[c],j=b?i:{horizontal:p?re:ie,vertical:p?_e:me,both:i}[c];p&&(e.key===`Home`?S=w:e.key===`End`&&(S=D)),S===T&&(k.includes(e.key)||A.includes(e.key))&&(a&&S===D&&k.includes(e.key)?(S=w,o&&(S=o(e,T,S,C))):a&&S===w&&A.includes(e.key)?(S=D,o&&(S=o(e,T,S,C))):S=De(C.current,{startingIndex:S,decrement:A.includes(e.key),disabledIndices:g})),S!==T&&!Se(C.current,S)&&(h&&e.stopPropagation(),j.has(e.key)&&e.preventDefault(),E(S,!0),queueMicrotask(()=>{C.current[S]?.focus()}))}}),[r,s,l,g,C,p,T,b,n,a,o,O,S,_,E,c,h]);return Z.useMemo(()=>({props:k,highlightedIndex:T,onHighlightedIndexChange:E,elementsRef:C,disabledIndices:g,onMapChange:D,relayKeyboardEvent:k.onKeyDown}),[k,T,E,C,g,D])}function Xt(e,t){for(let n of G.values())if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function Zt(e){let{render:t,className:n,style:r,refs:i=S,props:a=S,state:s=k,stateAttributesMapping:c,highlightedIndex:l,onHighlightedIndexChange:u,orientation:d,dense:f,itemSizes:p,loopFocus:m,onLoop:h,cols:g,enableHomeAndEndKeys:_,onMapChange:v,stopEventPropagation:y=!0,rootRef:b,disabledIndices:x,modifierKeys:C,highlightItemOnHover:w=!1,tag:T=`div`,...E}=e,{props:D,highlightedIndex:O,onHighlightedIndexChange:A,elementsRef:j,onMapChange:M,relayKeyboardEvent:N}=Yt({itemSizes:p,cols:g,loopFocus:m,onLoop:h,dense:f,orientation:d,highlightedIndex:l,onHighlightedIndexChange:u,rootRef:b,stopEventPropagation:y,enableHomeAndEndKeys:_,direction:We(),disabledIndices:x,modifierKeys:C}),P=o(T,e,{state:s,ref:i,props:[D,...a,E],stateAttributesMapping:c}),F=Z.useMemo(()=>({highlightedIndex:O,onHighlightedIndexChange:A,highlightItemOnHover:w,relayKeyboardEvent:N}),[O,A,w,N]);return(0,$.jsx)(R.Provider,{value:F,children:(0,$.jsx)(Dt,{elementsRef:j,onMapChange:e=>{v?.(e),M(e)},children:P})})}var Qt=Z.forwardRef(function(e,t){let{activateOnFocus:n=!1,className:r,loopFocus:i=!0,render:a,style:o,...s}=e,{onValueChange:c,orientation:l,value:u,setTabMap:d,tabActivationDirection:f}=Mt(),[p,h]=Z.useState(0),[g,_]=Z.useState(null),v=Z.useRef(new Set),y=Z.useRef(new Set),b=Z.useRef(null),x=m(()=>{v.current.forEach(e=>{e()})});Z.useEffect(()=>{if(typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>{v.current.size&&x()});return b.current=e,g&&e.observe(g),y.current.forEach(t=>{e.observe(t)}),()=>{e.disconnect(),b.current=null}},[g,x]);let C=m(e=>(v.current.add(e),()=>{v.current.delete(e)})),w=m(e=>(y.current.add(e),b.current?.observe(e),()=>{y.current.delete(e),b.current?.unobserve(e)})),T=m((e,t)=>{e!==u&&c(e,t)}),E={orientation:l,tabActivationDirection:f},D={"aria-orientation":l===`vertical`?`vertical`:void 0,role:`tablist`},O=Z.useMemo(()=>({activateOnFocus:n,highlightedTabIndex:p,registerIndicatorUpdateListener:C,registerTabResizeObserverElement:w,onTabActivation:T,setHighlightedTabIndex:h,tabsListElement:g}),[n,p,C,w,T,h,g]);return(0,$.jsx)(Vt.Provider,{value:O,children:(0,$.jsx)(Zt,{render:a,className:r,style:o,state:E,refs:[t,_],props:[D,s],stateAttributesMapping:Pt,highlightedIndex:p,enableHomeAndEndKeys:!0,loopFocus:i,orientation:l,onHighlightedIndexChange:h,onMapChange:d,disabledIndices:S})})});function $t(t){let n=(0,Q.c)(10),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?`horizontal`:a,s;n[4]===r?s=n[5]:(s=e(`group/tabs flex gap-2 data-horizontal:flex-col`,r),n[4]=r,n[5]=s);let c;return n[6]!==o||n[7]!==i||n[8]!==s?(c=(0,$.jsx)(Ft,{"data-slot":`tabs`,"data-orientation":o,className:s,...i}),n[6]=o,n[7]=i,n[8]=s,n[9]=c):c=n[9],c}var en=s(`group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none`,{variants:{variant:{default:`bg-muted`,line:`gap-1 bg-transparent`}},defaultVariants:{variant:`default`}});function tn(t){let n=(0,Q.c)(11),r,i,a;n[0]===t?(r=n[1],i=n[2],a=n[3]):({className:r,variant: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||n[5]!==o?(s=e(en({variant:o}),r),n[4]=r,n[5]=o,n[6]=s):s=n[6];let c;return n[7]!==i||n[8]!==s||n[9]!==o?(c=(0,$.jsx)(Qt,{"data-slot":`tabs-list`,"data-variant":o,className:s,...i}),n[7]=i,n[8]=s,n[9]=o,n[10]=c):c=n[10],c}function nn(t){let n=(0,Q.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(`relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-xs font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start group-data-vertical/tabs:py-[calc(--spacing(1.25))] hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 aria-disabled:pointer-events-none aria-disabled:opacity-50 dark:text-muted-foreground dark:hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5`,`group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent`,`data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground`,`after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==a?(o=(0,$.jsx)(Ut,{"data-slot":`tabs-trigger`,className:a,...i}),n[5]=i,n[6]=a,n[7]=o):o=n[7],o}function rn(t){let n=(0,Q.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-1 text-xs/relaxed outline-none`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==a?(o=(0,$.jsx)(Kt,{"data-slot":`tabs-content`,className:a,...i}),n[5]=i,n[6]=a,n[7]=o):o=n[7],o}function an(e){let t=(0,Q.c)(52),{projectId:n}=Be.useParams(),r=Be.useSearch(),i=L(),[a,o]=(0,Z.useState)(r.search),s=(0,Z.useRef)(null),c=(0,Z.useRef)(null),[l,u]=(0,Z.useState)(-1),[d,f]=(0,Z.useState)(null),p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=[],t[0]=p):p=t[0];let m=(0,Z.useRef)(p),h;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(h=[],t[1]=h):h=t[1];let{data:g,isLoading:_}=j(pn,h),v;if(t[2]!==n||t[3]!==r.needsReview||t[4]!==r.pinned||t[5]!==r.search||t[6]!==r.type||t[7]!==g){let e=g===void 0?[]:g,i;if(t[9]===n?i=t[10]:(i=e=>e.projects.some(e=>e.id===n),t[9]=n,t[10]=i),v=e.filter(i),r.type){let e;t[11]===r.type?e=t[12]:(e=e=>e.type===r.type,t[11]=r.type,t[12]=e),v=v.filter(e)}if(r.pinned&&(v=v.filter(fn)),r.needsReview&&(v=v.filter(dn)),r.search){let e=r.search.toLowerCase();v=v.filter(t=>t.content.toLowerCase().includes(e))}t[2]=n,t[3]=r.needsReview,t[4]=r.pinned,t[5]=r.search,t[6]=r.type,t[7]=g,t[8]=v}else v=t[8];let y,b;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(y=()=>()=>{s.current&&clearTimeout(s.current)},b=[],t[13]=y,t[14]=b):(y=t[13],b=t[14]),(0,Z.useEffect)(y,b);let x;t[15]!==v.length||t[16]!==l?(x=()=>{v.length===0?u(-1):l>=v.length&&u(v.length-1)},t[15]=v.length,t[16]=l,t[17]=x):x=t[17];let S;t[18]!==v.length||t[19]!==l?(S=[v.length,l],t[18]=v.length,t[19]=l,t[20]=S):S=t[20],(0,Z.useEffect)(x,S);let C,w;t[21]===l?(C=t[22],w=t[23]):(C=()=>{l>=0&&m.current[l]?.scrollIntoView({block:`nearest`})},w=[l],t[21]=l,t[22]=C,t[23]=w),(0,Z.useEffect)(C,w);let T;t[24]!==i||t[25]!==n?(T=e=>{o(e),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{i({to:`/$projectId`,params:{projectId:n},search:t=>({...t,search:e})})},300)},t[24]=i,t[25]=n,t[26]=T):T=t[26];let E=T,D=un,k;t[27]!==i||t[28]!==n||t[29]!==e?(k=t=>{O.delete(t),e===t&&i({to:`/$projectId`,params:{projectId:n},search:ln})},t[27]=i,t[28]=n,t[29]=e,t[30]=k):k=t[30];let A=k,M;t[31]!==v||t[32]!==i||t[33]!==n||t[34]!==e?(M=t=>{let r=v.findIndex(e=>e.id===t);r>=0&&u(r),i(e===t?{to:`/$projectId`,params:{projectId:n},search:cn}:{to:`/$projectId/$memoryId`,params:{projectId:n,memoryId:t},search:sn})},t[31]=v,t[32]=i,t[33]=n,t[34]=e,t[35]=M):M=t[35];let N=M,P=!!(r.search||r.type||r.pinned||r.needsReview),F;t[36]!==i||t[37]!==n?(F=()=>{s.current&&clearTimeout(s.current),o(``),i({to:`/$projectId`,params:{projectId:n},search:on})},t[36]=i,t[37]=n,t[38]=F):F=t[38];let I=F,R;return t[39]!==d||t[40]!==v||t[41]!==l||t[42]!==I||t[43]!==A||t[44]!==E||t[45]!==N||t[46]!==P||t[47]!==_||t[48]!==n||t[49]!==r||t[50]!==a?(R={projectId:n,search:r,searchInput:a,inputRef:c,isLoading:_,filtered:v,focusedIndex:l,setFocusedIndex:u,confirmingId:d,setConfirmingId:f,rowRefs:m,hasActiveFilters:P,handleSearchChange:E,handleClearFilters:I,handlePin:D,handleDelete:A,handleSelect:N},t[39]=d,t[40]=v,t[41]=l,t[42]=I,t[43]=A,t[44]=E,t[45]=N,t[46]=P,t[47]=_,t[48]=n,t[49]=r,t[50]=a,t[51]=R):R=t[51],R}function on(e){return{tab:e.tab}}function sn(e){return e}function cn(e){return e}function ln(e){return e}function un(e,t){O.update(e,e=>{e.pinned=!t})}function dn(e){return e.reviewEvents.length>0}function fn(e){return e.pinned}function pn(e){return e.from({m:O}).orderBy(mn,`desc`)}function mn(e){let{m:t}=e;return t.createdAt}function hn(t){let n=(0,Q.c)(18),{selectedId:r,projectId:i}=t,a=L(),o=(0,Z.useRef)(null),[s,c]=(0,Z.useState)(!1),l,u;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>{let e=requestAnimationFrame(()=>c(!0));return()=>cancelAnimationFrame(e)},u=[],n[0]=l,n[1]=u):(l=n[0],u=n[1]),(0,Z.useEffect)(l,u);let d;n[2]!==a||n[3]!==i?(d=()=>{a({to:`/$projectId`,params:{projectId:i},search:gn})},n[2]=a,n[3]=i,n[4]=d):d=n[4];let f=d,p,m;n[5]===f?(p=n[6],m=n[7]):(p=()=>{let e=e=>{e.key===`Escape`&&f()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},m=[f],n[5]=f,n[6]=p,n[7]=m),(0,Z.useEffect)(p,m);let h,g;n[8]===f?(h=n[9],g=n[10]):(h=()=>{let e=e=>{o.current&&!o.current.contains(e.target)&&f()};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},g=[f],n[8]=f,n[9]=h,n[10]=g),(0,Z.useEffect)(h,g);let _=s?`translate-x-0`:`translate-x-full`,v;n[11]===_?v=n[12]:(v=e(`absolute inset-y-0 right-0 w-[65ch] border-l border-border bg-card`,`flex flex-col overflow-hidden z-10`,`transition-transform duration-[180ms] ease-out`,_),n[11]=_,n[12]=v);let y;n[13]===r?y=n[14]:(y=(0,$.jsx)(fe,{id:r},r),n[13]=r,n[14]=y);let b;return n[15]!==y||n[16]!==v?(b=(0,$.jsx)(`div`,{ref:o,className:v,children:y}),n[15]=y,n[16]=v,n[17]=b):b=n[17],b}function gn(e){return e}var _n=6e4;function vn(e){let t=(0,Q.c)(27),[n,r]=(0,Z.useState)(null),[i,a]=(0,Z.useState)(!1),o,s;t[0]===e.scopeHash?(o=t[1],s=t[2]):(o=t=>t.from({s:v}).where(t=>{let{s:n}=t;return f(n.scope,e.scopeHash)}),s=[e.scopeHash],t[0]=e.scopeHash,t[1]=o,t[2]=s);let{data:c,isLoading:l}=j(o,s),d;t[3]===c?d=t[4]:(d=c===void 0?[]:c,t[3]=c,t[4]=d);let p=d[0]??null,m;t[5]===p?.inFlightSince?m=t[6]:(m=()=>{if(!p?.inFlightSince)return;let e=setInterval(yn,3e3);return()=>clearInterval(e)},t[5]=p?.inFlightSince,t[6]=m);let h=p?.inFlightSince,g;t[7]===h?g=t[8]:(g=[h],t[7]=h,t[8]=g),(0,Z.useEffect)(m,g);let _;t[9]===p?_=t[10]:(_=()=>{if(!p?.inFlightSince){a(!1);return}let e=_n-(Date.now()-new Date(p.inFlightSince).getTime());if(e<=0){a(!0);return}let t=setTimeout(()=>a(!0),e);return()=>clearTimeout(t)},t[9]=p,t[10]=_);let y=p?.inFlightSince,b;t[11]===y?b=t[12]:(b=[y],t[11]=y,t[12]=b),(0,Z.useEffect)(_,b);let x;t[13]===e.id?x=t[14]:(x=async()=>{r(null);try{await u(e.id),await D.invalidateQueries({queryKey:[`syntheses`]})}catch{r(`Failed to start synthesis`)}},t[13]=e.id,t[14]=x);let S=x,C;t[15]===e.id?C=t[16]:(C=async()=>{r(null),a(!1);try{await A(e.id),await D.invalidateQueries({queryKey:[`syntheses`]})}catch{r(`Failed to reset synthesis`)}},t[15]=e.id,t[16]=C);let w=C,T;t[17]===p?T=t[18]:(T=p!==null&&p.inFlightSince===null&&new Date(p.expiresAt)<new Date,t[17]=p,t[18]=T);let E=T,O;return t[19]!==n||t[20]!==l||t[21]!==E||t[22]!==i||t[23]!==w||t[24]!==S||t[25]!==p?(O={synthesis:p,isLoading:l,isStale:E,isStuck:i,error:n,run:S,reset:w},t[19]=n,t[20]=l,t[21]=E,t[22]=i,t[23]=w,t[24]=S,t[25]=p,t[26]=O):O=t[26],O}function yn(){D.invalidateQueries({queryKey:[`syntheses`]})}function bn(e){let[t,n]=(0,Z.useState)([]),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{let t=!1;return a(!0),C(e).then(e=>{t||n(e)}).catch(()=>{t||r.error(`Failed to load synthesis history`)}).finally(()=>{t||a(!1)}),()=>{t=!0}},[e]),{versions:t,isLoading:i,reverting:o,revert:async t=>{s(!0);try{return await N(e,t),await D.invalidateQueries({queryKey:[`syntheses`]}),n(await C(e)),!0}catch{return r.error(`Failed to revert synthesis — try again`),!1}finally{s(!1)}}}}function xn(e,t){let n={};for(let e of ze)n[e]=0;for(let r of e)r.projects.some(e=>e.id===t)&&n[r.type]++;return n}function Sn(e){let t=(0,Q.c)(2),n;t[0]===e?n=t[1]:(n={scope:e,limit:1},t[0]=e,t[1]=n);let{events:r}=mt(n);return r[0]?.createdAt??null}function Cn(e){let t=(0,Q.c)(7),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=[],t[0]=n):n=t[0];let{data:r}=j(En,n),i;t[1]===r?i=t[2]:(i=r===void 0?[]:r,t[1]=r,t[2]=i);let a=i,o;if(t[3]!==a||t[4]!==e){bb0:{let n=xn(a,e),r=ze.reduce((e,t)=>e+n[t],0);if(r===0){let e;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[6]=e):e=t[6],o=e;break bb0}o=ze.map(e=>({type:e,count:n[e],pct:Math.round(n[e]/r*100)})).filter(Tn).sort(wn)}t[3]=a,t[4]=e,t[5]=o}else o=t[5];return o}function wn(e,t){return t.count-e.count}function Tn(e){return e.count>0}function En(e){return e.from({m:O})}function Dn(e){let t=(0,Q.c)(19),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=[],t[0]=n):n=t[0];let{data:r}=j(kn,n),i;t[1]===r?i=t[2]:(i=r===void 0?[]:r,t[1]=r,t[2]=i);let a=i,o;if(t[3]!==a||t[4]!==e){let n;t[6]===e?n=t[7]:(n=t=>t.projects.some(t=>t.id===e),t[6]=e,t[7]=n),o=He(a.filter(n)),t[3]=a,t[4]=e,t[5]=o}else o=t[5];let s;t[8]===a?s=t[9]:(s=a.filter(On),t[8]=a,t[9]=s);let c=s.length,l;if(t[10]!==a||t[11]!==e){let n;t[13]===e?n=t[14]:(n=t=>t.pinned&&t.projects.some(t=>t.id===e),t[13]=e,t[14]=n),l=a.filter(n),t[10]=a,t[11]=e,t[12]=l}else l=t[12];let u;return t[15]!==o||t[16]!==s.length||t[17]!==l.length?(u={flaggedCount:o,pinnedGlobal:c,pinnedProject:l.length},t[15]=o,t[16]=s.length,t[17]=l.length,t[18]=u):u=t[18],u}function On(e){return e.pinned&&e.projects.length===0}function kn(e){return e.from({m:O})}function An(e){let t=(0,Q.c)(12),{project:n}=e,r=Sn(n.scopeHash),i;t[0]===n.name?i=t[1]:(i=(0,$.jsx)(`h2`,{className:`font-heading text-base font-semibold text-foreground truncate`,children:n.name}),t[0]=n.name,t[1]=i);let a;t[2]===n.scopeHash?a=t[3]:(a=(0,$.jsx)(`p`,{className:`font-mono text-[10px] text-muted-foreground/50 truncate`,children:n.scopeHash}),t[2]=n.scopeHash,t[3]=a);let o;t[4]!==i||t[5]!==a?(o=(0,$.jsxs)(`div`,{className:`min-w-0 space-y-0.5`,children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6];let s;t[7]===r?s=t[8]:(s=r&&(0,$.jsxs)(`span`,{className:`shrink-0 mt-0.5 font-mono text-[11px] text-muted-foreground/50`,children:[`active `,y(r)]}),t[7]=r,t[8]=s);let c;return t[9]!==o||t[10]!==s?(c=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-4 pb-6 border-b border-border`,children:[o,s]}),t[9]=o,t[10]=s,t[11]=c):c=t[11],c}function jn(t){let n=(0,Q.c)(4),{projectId:r}=t,i=Cn(r),a;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(`span`,{className:`text-[11px] uppercase tracking-wide text-muted-foreground`,children:`Composition`}),n[0]=a):a=n[0];let o;return n[1]!==i||n[2]!==r?(o=(0,$.jsxs)(`div`,{className:`space-y-3`,children:[a,i.length===0?(0,$.jsx)(`p`,{className:`font-mono text-[11px] text-muted-foreground/40`,children:`No memories yet.`}):(0,$.jsx)(`div`,{className:`space-y-3`,children:i.map(t=>{let{type:n,count:i,pct:a}=t;return(0,$.jsxs)(Ze,{to:`/$projectId`,params:{projectId:r},search:e=>({...e,tab:`memories`,type:n}),className:`group w-full cursor-pointer space-y-1.5 text-left`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`font-mono text-[11px] uppercase tracking-wide text-muted-foreground group-hover:text-foreground transition-colors`,children:n}),(0,$.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,$.jsx)(`span`,{className:`font-mono text-[11px] text-foreground/70`,children:i}),(0,$.jsxs)(`span`,{className:`font-mono text-[10px] text-muted-foreground/40 w-7 text-right`,children:[a,`%`]})]})]}),(0,$.jsx)(`div`,{className:`h-px rounded-full bg-border/60 overflow-hidden relative`,children:(0,$.jsx)(`div`,{className:e(`absolute inset-y-0 left-0 rounded-full opacity-60 group-hover:opacity-80 transition-opacity`,Ye({type:n,tone:`bg`})),style:{width:`${a}%`}})})]},n)})})]}),n[1]=i,n[2]=r,n[3]=o):o=n[3],o}function Mn(e){let t=(0,Q.c)(26),{project:n,synthesis:r,isStale:i,isStuck:a,isLoading:o}=e,{flaggedCount:s,pinnedGlobal:c,pinnedProject:l}=Dn(n.id),u=r?.inFlightSince!=null,d=r?.synthesizedAt??null,f;t[0]!==u||t[1]!==o||t[2]!==i||t[3]!==a||t[4]!==r||t[5]!==d?(f=Nn({synthesis:r,isLoading:o,isInFlight:u,isStuck:a,isStale:i,synthesizedAt:d}),t[0]=u,t[1]=o,t[2]=i,t[3]=a,t[4]=r,t[5]=d,t[6]=f):f=t[6];let p=f,m=c+l,h=s===0&&!i&&!a&&!!r&&!u,g;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(`span`,{className:`text-[11px] uppercase tracking-wide text-muted-foreground`,children:`Attention`}),t[7]=g):g=t[7];let _;t[8]!==s||t[9]!==n.id?(_=s>0&&(0,$.jsxs)(Ze,{to:`/review`,search:{projectId:n.id},className:`group flex w-full items-center justify-between text-destructive hover:text-destructive/80 transition-colors cursor-pointer`,children:[(0,$.jsxs)(`span`,{children:[s,` flagged for review`]}),(0,$.jsx)(`span`,{className:`opacity-0 group-hover:opacity-100 transition-opacity`,children:`→`})]}),t[8]=s,t[9]=n.id,t[10]=_):_=t[10];let v;t[11]!==p.className||t[12]!==p.text?(v=(0,$.jsx)(`div`,{className:p.className,children:p.text}),t[11]=p.className,t[12]=p.text,t[13]=v):v=t[13];let y;t[14]!==c||t[15]!==l||t[16]!==m?(y=m>0&&(0,$.jsxs)(`div`,{className:`text-muted-foreground/70`,children:[m,` pinned`,(0,$.jsxs)(`span`,{className:`text-muted-foreground/40`,children:[` `,`(`,[c>0&&`${c} global`,l>0&&`${l} here`].filter(Boolean).join(`, `),`)`]})]}),t[14]=c,t[15]=l,t[16]=m,t[17]=y):y=t[17];let b;t[18]!==h||t[19]!==m?(b=h&&m===0&&(0,$.jsx)(`div`,{className:`text-muted-foreground/30`,children:`Nothing flagged.`}),t[18]=h,t[19]=m,t[20]=b):b=t[20];let x;return t[21]!==_||t[22]!==v||t[23]!==y||t[24]!==b?(x=(0,$.jsxs)(`div`,{className:`space-y-3`,children:[g,(0,$.jsxs)(`div`,{className:`space-y-2.5 font-mono text-[11px]`,children:[_,v,y,b]})]}),t[21]=_,t[22]=v,t[23]=y,t[24]=b,t[25]=x):x=t[25],x}function Nn({synthesis:e,isLoading:t,isInFlight:n,isStuck:r,isStale:i,synthesizedAt:a}){return t&&!e?{text:`Loading…`,className:`text-muted-foreground/40`}:r?{text:`Synthesis stuck`,className:`text-destructive`}:n?{text:`Synthesizing…`,className:`text-muted-foreground/50`}:i?{text:a?`Synthesis stale · ${y(a)}`:`Synthesis stale`,className:`text-stale`}:e?{text:a?`Synthesis fresh · ${y(a)}`:`Synthesis ready`,className:`text-muted-foreground/70`}:{text:`No synthesis yet`,className:`text-muted-foreground/40`}}function Pn(e){let t=(0,Q.c)(14),{scope:n}=e,r;t[0]===n?r=t[1]:(r={scope:n,limit:4},t[0]=n,t[1]=r);let{events:i,loading:a}=mt(r),o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(`span`,{className:`text-[11px] uppercase tracking-wide text-muted-foreground`,children:`Recent Activity`}),t[2]=o):o=t[2];let s;t[3]===a?s=t[4]:(s=a&&(0,$.jsx)(`p`,{className:`font-mono text-[11px] text-muted-foreground/40`,children:`Loading…`}),t[3]=a,t[4]=s);let c;t[5]!==i.length||t[6]!==a?(c=!a&&i.length===0&&(0,$.jsx)(`p`,{className:`font-mono text-[11px] text-muted-foreground/40`,children:`No recent activity.`}),t[5]=i.length,t[6]=a,t[7]=c):c=t[7];let l;t[8]===i?l=t[9]:(l=i.length>0&&(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`ul`,{className:`-mx-4 border-t border-border/50`,children:i.map(In)}),(0,$.jsx)(Ze,{from:`/$projectId`,search:Fn,className:`mt-2 font-mono text-[11px] text-muted-foreground/50 hover:text-muted-foreground transition-colors`,children:`view all →`})]}),t[8]=i,t[9]=l);let u;return t[10]!==s||t[11]!==c||t[12]!==l?(u=(0,$.jsxs)(`div`,{className:`space-y-3`,children:[o,s,c,l]}),t[10]=s,t[11]=c,t[12]=l,t[13]=u):u=t[13],u}function Fn(e){return{...e,tab:`activity`}}function In(e){return(0,$.jsx)(yt,{event:e},e.id)}function Ln(e){let t=(0,Q.c)(2),{onReset:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`button`,{type:`button`,onClick:()=>void n(),className:`text-[11px] text-muted-foreground/60 hover:text-muted-foreground transition-colors underline underline-offset-2`,children:`Taking too long? Reset`}),t[0]=n,t[1]=r),r}var Rn=`Save (call save_memory) when: (1) user states a preference or makes a decision; (2) user corrects you; (3) you discover a working fix after a tool error; (4) you learn a non-obvious project fact. Type ∈ correction|preference|decision|learning|fact. When unsure, save.
|
|
2
|
+
Query (call query_memory) before: answering anything that touches prior decisions, and before exploration tasks (file reads, searches, web lookups) where past corrections or preferences may apply. Skip when clearly irrelevant (e.g. trivial arithmetic). Soft guideline, not a hard rule.`;function zn(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`)}function Bn(e,t,n,r){let i=[],a=ze.filter(t=>e[t]>0).map(t=>`${e[t]} ${t}${e[t]===1?``:`s`}`);if(a.length>0&&i.push(`<memory-stats>\n${a.join(`, `)}\n</memory-stats>`),r!==null&&r.inFlightSince===null&&r.content!==`pending`)i.push(`<synthesis>\n${r.content}\n</synthesis>`);else{let e=[...t,...n];if(e.length>0){let t=e.map(e=>` <memory type="${e.type}">${zn(e.content)}</memory>`);i.push(`<pinned-memories>\n${t.join(`
|
|
3
|
+
`)}\n</pinned-memories>`)}}return i.push(`<memory-guidance>\n${Rn}\n</memory-guidance>`),i.join(`
|
|
4
|
+
`)}function Vn(e){let t=(0,Q.c)(2),{tag:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsxs)(`span`,{className:`text-muted-foreground/40`,children:[`</`,n,`>`]}),t[0]=n,t[1]=r),r}function Hn(e){let t=(0,Q.c)(2),{tag:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsxs)(`span`,{className:`text-muted-foreground/40`,children:[`<`,n,`>`]}),t[0]=n,t[1]=r),r}function Un(e){let t=(0,Q.c)(9),{name:n,value:r,className:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsxs)(`span`,{className:`text-muted-foreground/30`,children:[` `,n,`="`]}),t[0]=n,t[1]=a);let o;t[2]!==i||t[3]!==r?(o=(0,$.jsx)(`span`,{className:i,children:r}),t[2]=i,t[3]=r,t[4]=o):o=t[4];let s;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(`span`,{className:`text-muted-foreground/30`,children:`"`}),t[5]=s):s=t[5];let c;return t[6]!==a||t[7]!==o?(c=(0,$.jsxs)($.Fragment,{children:[a,o,s]}),t[6]=a,t[7]=o,t[8]=c):c=t[8],c}function Wn(e){let t=(0,Q.c)(6),{isStuck:n,onReset:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,$.jsx)(Re,{className:`size-3`}),(0,$.jsx)(`span`,{className:`text-[11px]`,children:`Synthesizing…`})]}),t[0]=i):i=t[0];let a;t[1]!==n||t[2]!==r?(a=n&&(0,$.jsx)(Ln,{onReset:r}),t[1]=n,t[2]=r,t[3]=a):a=t[3];let o;return t[4]===a?o=t[5]:(o=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[i,a]}),t[4]=a,t[5]=o),o}function Gn(e){let t=(0,Q.c)(18),{version:n,reverting:r,onConfirm:i,onClose:a}=e,o;t[0]===n.version?o=t[1]:(o=(0,$.jsx)(ce,{children:(0,$.jsxs)(de,{children:[`Revert synthesis to version `,n.version,`?`]})}),t[0]=n.version,t[1]=o);let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The active synthesis 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,$.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,$.jsx)(z,{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,$.jsx)(z,{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,$.jsxs)(K,{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,$.jsxs)(ae,{children:[o,s,c,f]}),t[14]=o,t[15]=c,t[16]=f,t[17]=p):p=t[17],p}function Kn(e){let t=(0,Q.c)(29),{a:n,b:r,onClose:i}=e,a,o,s,c,l,u,d;if(t[0]!==n.content||t[1]!==n.version||t[2]!==r.content||t[3]!==r.version){let e=qe(n.content,r.content).map(Jn);o=ae,u=`max-w-2xl`,t[11]!==n.version||t[12]!==r.version?(d=(0,$.jsx)(ce,{children:(0,$.jsxs)(de,{children:[`Compare v`,n.version,` → v`,r.version]})}),t[11]=n.version,t[12]=r.version,t[13]=d):d=t[13],a=Ie,l=`max-h-[60vh]`,s=`text-[11px] font-mono leading-relaxed`,c=e.map(qn),t[0]=n.content,t[1]=n.version,t[2]=r.content,t[3]=r.version,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l,t[9]=u,t[10]=d}else a=t[4],o=t[5],s=t[6],c=t[7],l=t[8],u=t[9],d=t[10];let f;t[14]!==s||t[15]!==c?(f=(0,$.jsx)(`pre`,{className:s,children:c}),t[14]=s,t[15]=c,t[16]=f):f=t[16];let p;t[17]!==a||t[18]!==l||t[19]!==f?(p=(0,$.jsx)(a,{className:l,children:f}),t[17]=a,t[18]=l,t[19]=f,t[20]=p):p=t[20];let m;t[21]===i?m=t[22]:(m=(0,$.jsx)(K,{children:(0,$.jsx)(z,{variant:`outline`,size:`sm`,onClick:i,children:`Close`})}),t[21]=i,t[22]=m);let h;return t[23]!==o||t[24]!==u||t[25]!==d||t[26]!==p||t[27]!==m?(h=(0,$.jsxs)(o,{className:u,children:[d,p,m]}),t[23]=o,t[24]=u,t[25]=d,t[26]=p,t[27]=m,t[28]=h):h=t[28],h}function qn(t){return(0,$.jsxs)(`div`,{className:e(`px-2`,t.kind===`added`&&`bg-emerald-500/10 text-emerald-700 dark:text-emerald-400`,t.kind===`removed`&&`bg-rose-500/10 text-rose-700 dark:text-rose-400`,t.kind===`context`&&`text-muted-foreground`),children:[t.kind===`added`?`+ `:t.kind===`removed`?`- `:` `,t.line]},t.pos)}function Jn(e,t){return{...e,pos:t}}function Yn(t){let n=(0,Q.c)(41),{projectId:r}=t,{versions:i,isLoading:a,reverting:o,revert:s}=bn(r),[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(!1),f;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=[],n[0]=f):f=n[0];let[p,m]=(0,Z.useState)(f);if(!a&&i.length===0)return null;let h=p[0],g=p[1],_=h!==void 0&&g!==void 0,v;n[1]===u?v=n[2]:(v=e=>{u?m(t=>{if(t.some(t=>t.version===e.version))return t.filter(t=>t.version!==e.version);let n=[...t,e];return n.length>2?n.slice(-2):n}):l(e)},n[1]=u,n[2]=v);let b=v,x;n[3]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>{d(!1),m([])},n[3]=x):x=n[3];let S=x,C;n[4]!==s||n[5]!==c?(C=async()=>{c&&await s(c.version)&&l(null)},n[4]=s,n[5]=c,n[6]=C):C=n[6];let w=C,T=c!==null,E;n[7]===Symbol.for(`react.memo_cache_sentinel`)?(E=e=>!e&&l(null),n[7]=E):E=n[7];let D;n[8]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(`span`,{className:`transition-transform group-data-[open]:rotate-90`,children:`›`}),n[8]=D):D=n[8];let O=i.length>0?` (${i.length})`:``,k;n[9]===O?k=n[10]:(k=(0,$.jsxs)(he,{className:`flex items-center gap-1 cursor-pointer text-[11px] uppercase tracking-wide text-muted-foreground/60 hover:text-muted-foreground transition-colors select-none`,children:[D,`History`,O]}),n[9]=O,n[10]=k);let A;n[11]!==u||n[12]!==i.length?(A=i.length>=2&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>{u?S():d(!0)},className:`text-[11px] text-muted-foreground/50 hover:text-muted-foreground transition-colors`,children:u?`Cancel`:`Compare`}),n[11]=u,n[12]=i.length,n[13]=A):A=n[13];let j;n[14]!==A||n[15]!==k?(j=(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[k,A]}),n[14]=A,n[15]=k,n[16]=j):j=n[16];let M;n[17]!==u||n[18]!==p||n[19]!==b||n[20]!==a||n[21]!==i?(M=(0,$.jsx)(V,{className:`space-y-1 mt-1.5`,children:a?(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Loading…`}):(0,$.jsxs)($.Fragment,{children:[i.map(t=>(0,$.jsxs)(`button`,{type:`button`,className:e(`w-full text-left rounded border border-border px-2 py-1.5 space-y-0.5 hover:bg-muted transition-colors`,u&&p.some(e=>e.version===t.version)&&`border-primary/50 bg-primary/5`),onClick:()=>b(t),children:[(0,$.jsxs)(`div`,{className:`flex justify-between text-[11px] text-muted-foreground`,children:[(0,$.jsxs)(`span`,{className:`font-medium text-foreground`,children:[`v`,t.version]}),(0,$.jsx)(`span`,{children:y(t.synthesizedAt)})]}),(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground truncate`,children:t.content.slice(0,80)})]},t.version)),u&&p.length===1&&(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground/60 py-0.5`,children:`Select one more version to compare`})]})}),n[17]=u,n[18]=p,n[19]=b,n[20]=a,n[21]=i,n[22]=M):M=n[22];let N;n[23]!==j||n[24]!==M?(N=(0,$.jsxs)(U,{className:`group pt-1.5 border-t border-border/50`,children:[j,M]}),n[23]=j,n[24]=M,n[25]=N):N=n[25];let P;n[26]!==w||n[27]!==c||n[28]!==o?(P=c!==null&&(0,$.jsx)(Gn,{version:c,reverting:o,onConfirm:()=>void w(),onClose:()=>l(null)}),n[26]=w,n[27]=c,n[28]=o,n[29]=P):P=n[29];let F;n[30]!==N||n[31]!==P||n[32]!==T?(F=(0,$.jsxs)(ue,{open:T,onOpenChange:E,children:[N,P]}),n[30]=N,n[31]=P,n[32]=T,n[33]=F):F=n[33];let I;n[34]!==h||n[35]!==g||n[36]!==_?(I=_&&(0,$.jsx)(ue,{open:!0,onOpenChange:e=>!e&&S(),children:(0,$.jsx)(Kn,{a:h,b:g,onClose:S})}),n[34]=h,n[35]=g,n[36]=_,n[37]=I):I=n[37];let L;return n[38]!==F||n[39]!==I?(L=(0,$.jsxs)($.Fragment,{children:[F,I]}),n[38]=F,n[39]=I,n[40]=L):L=n[40],L}function Xn(e){let t=(0,Q.c)(17),{memory:n}=e,r;t[0]===n.content?r=t[1]:(r=n.content.length>140?`${n.content.slice(0,140)}…`:n.content,t[0]=n.content,t[1]=r);let i=r,a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(`span`,{className:`text-muted-foreground/40`,children:`<memory type="`}),t[2]=a):a=t[2];let o;t[3]===n.type?o=t[4]:(o=Ye({type:n.type}),t[3]=n.type,t[4]=o);let s;t[5]!==n.type||t[6]!==o?(s=(0,$.jsx)(`span`,{className:o,children:n.type}),t[5]=n.type,t[6]=o,t[7]=s):s=t[7];let c;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(`span`,{className:`text-muted-foreground/40`,children:`">`}),t[8]=c):c=t[8];let l;t[9]===i?l=t[10]:(l=zn(i),t[9]=i,t[10]=l);let u;t[11]===l?u=t[12]:(u=(0,$.jsx)(`span`,{className:`text-foreground/70`,children:l}),t[11]=l,t[12]=u);let d;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(`span`,{className:`text-muted-foreground/40`,children:`</memory>`}),t[13]=d):d=t[13];let f;return t[14]!==s||t[15]!==u?(f=(0,$.jsxs)(`div`,{className:`pl-3 leading-relaxed`,children:[a,s,c,u,d]}),t[14]=s,t[15]=u,t[16]=f):f=t[16],f}function Zn(e){let t=(0,Q.c)(2),{label:n,count:r}=e,i=`── ${n} (${r}) ──`,a;return t[0]===i?a=t[1]:(a=(0,$.jsx)(`div`,{className:`pl-3 text-[10px] text-muted-foreground/30 select-none`,children:i}),t[0]=i,t[1]=a),a}function Qn(t){let n=(0,Q.c)(60),{synthesis:r,isLoading:i,isStale:a,isStuck:o,error:s,onRun:c,onReset:l,projectId:u}=t,d=r?.inFlightSince!=null,f=d&&r?.content!==`pending`,p=!r&&!i&&!s,m=r!==null&&!d,h;n[0]!==d||n[1]!==r?(h=r?.synthesizedAt&&!d&&(0,$.jsx)(Un,{name:`updated`,value:y(r.synthesizedAt),className:`text-muted-foreground/60`}),n[0]=d,n[1]=r,n[2]=h):h=n[2];let g;n[3]!==i||n[4]!==r?(g=i&&!r&&(0,$.jsx)(Un,{name:`status`,value:`loading`,className:`text-muted-foreground/50`}),n[3]=i,n[4]=r,n[5]=g):g=n[5];let _;n[6]===s?_=n[7]:(_=s&&(0,$.jsx)(Un,{name:`status`,value:`error`,className:`text-destructive/70`}),n[6]=s,n[7]=_);let v;n[8]===p?v=n[9]:(v=p&&(0,$.jsx)(Un,{name:`status`,value:`empty`,className:`text-muted-foreground/50`}),n[8]=p,n[9]=v);let b;n[10]===d?b=n[11]:(b=d&&(0,$.jsx)(Un,{name:`status`,value:`generating`,className:`text-muted-foreground/50`}),n[10]=d,n[11]=b);let x;n[12]!==m||n[13]!==a?(x=m&&a&&(0,$.jsx)(Un,{name:`status`,value:`stale`,className:`text-stale`}),n[12]=m,n[13]=a,n[14]=x):x=n[14];let S;n[15]!==h||n[16]!==g||n[17]!==_||n[18]!==v||n[19]!==b||n[20]!==x?(S=(0,$.jsxs)(`span`,{className:`text-muted-foreground/40 text-[11px]`,children:[`<synthesis`,h,g,_,v,b,x,`>`]}),n[15]=h,n[16]=g,n[17]=_,n[18]=v,n[19]=b,n[20]=x,n[21]=S):S=n[21];let C;n[22]!==d||n[23]!==m||n[24]!==c?(C=(m||d)&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>void c(),"aria-label":`Regenerate synthesis`,className:`text-muted-foreground/40 hover:text-muted-foreground transition-colors p-0.5 rounded shrink-0`,children:(0,$.jsx)(at,{className:`size-3`})}),n[22]=d,n[23]=m,n[24]=c,n[25]=C):C=n[25];let w;n[26]!==S||n[27]!==C?(w=(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[S,C]}),n[26]=S,n[27]=C,n[28]=w):w=n[28];let T;n[29]!==c||n[30]!==p?(T=p&&(0,$.jsxs)(`div`,{className:`pl-3 space-y-2 py-0.5`,children:[(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground/50 leading-relaxed`,children:`Synthesis condenses your memories into a concise brief injected at the start of each session. Without it, only pinned memories are sent (see below).`}),(0,$.jsxs)(z,{size:`sm`,variant:`secondary`,onClick:()=>void c(),className:`gap-1.5 h-6 text-[11px] px-2`,children:[(0,$.jsx)(Fe,{weight:`fill`,className:`size-3`}),`Generate`]})]}),n[29]=c,n[30]=p,n[31]=T):T=n[31];let E;n[32]!==i||n[33]!==r?(E=i&&!r&&(0,$.jsxs)(`div`,{className:`pl-3 space-y-1.5 py-0.5`,children:[(0,$.jsx)(X,{className:`h-2.5 w-full`}),(0,$.jsx)(X,{className:`h-2.5 w-full`}),(0,$.jsx)(X,{className:`h-2.5 w-3/4`})]}),n[32]=i,n[33]=r,n[34]=E):E=n[34];let D;n[35]!==s||n[36]!==c?(D=s&&(0,$.jsxs)(`div`,{className:`pl-3 space-y-1 py-0.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,$.jsx)(pt,{weight:`fill`,className:`size-3 text-destructive mt-0.5 shrink-0`}),(0,$.jsx)(`p`,{className:`text-[11px] text-destructive leading-relaxed`,children:s})]}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void c(),className:`text-[11px] text-muted-foreground hover:text-foreground underline underline-offset-2 transition-colors`,children:`Retry`})]}),n[35]=s,n[36]=c,n[37]=D):D=n[37];let O;n[38]!==f||n[39]!==d||n[40]!==o||n[41]!==l?(O=d&&!f&&(0,$.jsxs)(`div`,{className:`pl-3 space-y-2 py-0.5`,children:[(0,$.jsx)(Wn,{isStuck:o,onReset:l}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(X,{className:`h-2.5 w-full`}),(0,$.jsx)(X,{className:`h-2.5 w-full`}),(0,$.jsx)(X,{className:`h-2.5 w-5/6`}),(0,$.jsx)(X,{className:`h-2.5 w-full`}),(0,$.jsx)(X,{className:`h-2.5 w-3/4`})]})]}),n[38]=f,n[39]=d,n[40]=o,n[41]=l,n[42]=O):O=n[42];let k;n[43]!==f||n[44]!==d||n[45]!==o||n[46]!==l||n[47]!==r?(k=r!==null&&(!d||f)&&(0,$.jsxs)(`div`,{className:e(`pl-3`,d&&`opacity-50`),children:[d&&(0,$.jsx)(`div`,{className:`mb-2`,children:(0,$.jsx)(Wn,{isStuck:o,onReset:l})}),(0,$.jsx)(Ie,{className:`h-40`,children:(0,$.jsx)(`div`,{className:`text-foreground/70 whitespace-pre-wrap leading-relaxed`,children:r.content})})]}),n[43]=f,n[44]=d,n[45]=o,n[46]=l,n[47]=r,n[48]=k):k=n[48];let A;n[49]===u?A=n[50]:(A=(0,$.jsx)(Yn,{projectId:u}),n[49]=u,n[50]=A);let j;n[51]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,$.jsx)(Vn,{tag:`synthesis`}),n[51]=j):j=n[51];let M;return n[52]!==T||n[53]!==E||n[54]!==D||n[55]!==O||n[56]!==k||n[57]!==A||n[58]!==w?(M=(0,$.jsxs)(`div`,{className:`p-3 space-y-1.5`,children:[w,T,E,D,O,k,A,j]}),n[52]=T,n[53]=E,n[54]=D,n[55]=O,n[56]=k,n[57]=A,n[58]=w,n[59]=M):M=n[59],M}function $n(e,t){let n=(0,Q.c)(33),[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(!1),s;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=[],n[0]=s):s=n[0];let{data:c}=j(tr,s),l;n[1]===c?l=n[2]:(l=c===void 0?[]:c,n[1]=c,n[2]=l);let u=l,d;n[3]===u?d=n[4]:(d=u.filter(er),n[3]=u,n[4]=d);let f=d,p;if(n[5]!==u||n[6]!==e.id){let t;n[8]===e.id?t=n[9]:(t=t=>t.pinned&&t.projects.some(t=>t.id===e.id),n[8]=e.id,n[9]=t),p=u.filter(t),n[5]=u,n[6]=e.id,n[7]=p}else p=n[7];let m=p,h;n[10]!==u||n[11]!==e.id?(h=xn(u,e.id),n[10]=u,n[11]=e.id,n[12]=h):h=n[12];let g=h,_=t!==null&&t.inFlightSince===null&&t.content!==`pending`?t:null,v;n[13]===g?v=n[14]:(v=ze.filter(e=>g[e]>0).map(e=>`${g[e]} ${e}${g[e]===1?``:`s`}`),n[13]=g,n[14]=v);let y=v,b=f.length>0||m.length>0,x=y.length>0||_!==null||b,S;n[15]!==f||n[16]!==m||n[17]!==g||n[18]!==t?(S=Bn(g,f,m,t),n[15]=f,n[16]=m,n[17]=g,n[18]=t,n[19]=S):S=n[19];let C=S,w;n[20]===C?w=n[21]:(w=()=>{navigator.clipboard.writeText(C).then(()=>{i(!0),setTimeout(()=>i(!1),1500)})},n[20]=C,n[21]=w);let T=w,E;return n[22]!==r||n[23]!==a||n[24]!==T||n[25]!==x||n[26]!==b||n[27]!==f||n[28]!==m||n[29]!==_||n[30]!==y||n[31]!==g?(E={pinnedGlobal:f,pinnedProject:m,stats:g,statParts:y,settledSynthesis:_,hasPinned:b,hasContent:x,copied:r,guidanceOpen:a,handleCopy:T,setGuidanceOpen:o},n[22]=r,n[23]=a,n[24]=T,n[25]=x,n[26]=b,n[27]=f,n[28]=m,n[29]=_,n[30]=y,n[31]=g,n[32]=E):E=n[32],E}function er(e){return e.pinned&&e.projects.length===0}function tr(e){return e.from({m:O})}function nr(e){let t=(0,Q.c)(46),{project:n,synthesis:r,isLoading:i,isStale:a,isStuck:o,error:s,onRun:c,onReset:l,label:u}=e,d=u===void 0?`Session context`:u,{pinnedGlobal:f,pinnedProject:p,statParts:m,settledSynthesis:h,hasPinned:g,hasContent:_,copied:v,guidanceOpen:y,handleCopy:b,setGuidanceOpen:x}=$n(n,r),S;t[0]===d?S=t[1]:(S=(0,$.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:d}),t[0]=d,t[1]=S);let C;t[2]!==v||t[3]!==b||t[4]!==_?(C=_&&(0,$.jsx)(`button`,{type:`button`,onClick:b,className:`text-xs text-muted-foreground/50 hover:text-muted-foreground transition-colors`,children:v?`Copied`:`Copy`}),t[2]=v,t[3]=b,t[4]=_,t[5]=C):C=t[5];let w;t[6]!==S||t[7]!==C?(w=(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[S,C]}),t[6]=S,t[7]=C,t[8]=w):w=t[8];let T;t[9]===m?T=t[10]:(T=m.length>0&&(0,$.jsxs)(`div`,{className:`p-3 space-y-0.5`,children:[(0,$.jsx)(Hn,{tag:`memory-stats`}),(0,$.jsx)(`div`,{className:`pl-3 text-foreground/70`,children:m.join(`, `)}),(0,$.jsx)(Vn,{tag:`memory-stats`})]}),t[9]=m,t[10]=T);let E;t[11]!==s||t[12]!==i||t[13]!==a||t[14]!==o||t[15]!==l||t[16]!==c||t[17]!==n.id||t[18]!==r?(E=(0,$.jsx)(Qn,{synthesis:r,isLoading:i,isStale:a,isStuck:o,error:s,onRun:c,onReset:l,projectId:n.id}),t[11]=s,t[12]=i,t[13]=a,t[14]=o,t[15]=l,t[16]=c,t[17]=n.id,t[18]=r,t[19]=E):E=t[19];let D;t[20]!==g||t[21]!==f||t[22]!==p||t[23]!==h?(D=h===null&&g&&(0,$.jsxs)(`div`,{className:`p-3 space-y-0.5`,children:[(0,$.jsx)(Hn,{tag:`pinned-memories`}),f.length>0&&(0,$.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,$.jsx)(Zn,{label:Ge,count:f.length}),f.map(ar)]}),p.length>0&&(0,$.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,$.jsx)(Zn,{label:`project`,count:p.length}),p.map(ir)]}),(0,$.jsx)(Vn,{tag:`pinned-memories`})]}),t[20]=g,t[21]=f,t[22]=p,t[23]=h,t[24]=D):D=t[24];let O;t[25]===x?O=t[26]:(O=()=>x(rr),t[25]=x,t[26]=O);let k;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(Hn,{tag:`memory-guidance`}),t[27]=k):k=t[27];let A=y?`▲`:`▼`,j;t[28]===A?j=t[29]:(j=(0,$.jsx)(`span`,{className:`text-[10px] ml-1`,children:A}),t[28]=A,t[29]=j);let M;t[30]!==j||t[31]!==O?(M=(0,$.jsxs)(`button`,{type:`button`,onClick:O,className:`flex items-center gap-1 text-muted-foreground/40 hover:text-muted-foreground/70 transition-colors w-full text-left`,children:[k,j]}),t[30]=j,t[31]=O,t[32]=M):M=t[32];let N;t[33]===y?N=t[34]:(N=y&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`pl-3 text-foreground/60 whitespace-pre-wrap leading-relaxed`,children:Rn}),(0,$.jsx)(Vn,{tag:`memory-guidance`})]}),t[33]=y,t[34]=N);let P;t[35]!==M||t[36]!==N?(P=(0,$.jsxs)(`div`,{className:`p-3 space-y-0.5`,children:[M,N]}),t[35]=M,t[36]=N,t[37]=P):P=t[37];let F;t[38]!==P||t[39]!==T||t[40]!==E||t[41]!==D?(F=(0,$.jsxs)(`div`,{className:`rounded-md bg-muted/40 font-mono text-xs divide-y divide-border/30 overflow-hidden`,children:[T,E,D,P]}),t[38]=P,t[39]=T,t[40]=E,t[41]=D,t[42]=F):F=t[42];let I;return t[43]!==F||t[44]!==w?(I=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[w,F]}),t[43]=F,t[44]=w,t[45]=I):I=t[45],I}function rr(e){return!e}function ir(e){return(0,$.jsx)(Xn,{memory:e},e.id)}function ar(e){return(0,$.jsx)(Xn,{memory:e},e.id)}function or(e){let t=(0,Q.c)(31),{project:n}=e,{synthesis:r,isLoading:i,isStale:a,isStuck:o,error:s,run:c,reset:l}=vn(n),u;t[0]===n?u=t[1]:(u=(0,$.jsx)(An,{project:n}),t[0]=n,t[1]=u);let d;t[2]===n.id?d=t[3]:(d=(0,$.jsx)(jn,{projectId:n.id}),t[2]=n.id,t[3]=d);let f;t[4]!==i||t[5]!==a||t[6]!==o||t[7]!==n||t[8]!==r?(f=(0,$.jsx)(Mn,{project:n,synthesis:r,isStale:a,isStuck:o,isLoading:i}),t[4]=i,t[5]=a,t[6]=o,t[7]=n,t[8]=r,t[9]=f):f=t[9];let p;t[10]===n.scopeHash?p=t[11]:(p=(0,$.jsx)(Pn,{scope:n.scopeHash}),t[10]=n.scopeHash,t[11]=p);let m;t[12]!==f||t[13]!==p?(m=(0,$.jsxs)(`div`,{className:`space-y-8`,children:[f,p]}),t[12]=f,t[13]=p,t[14]=m):m=t[14];let h;t[15]!==d||t[16]!==m?(h=(0,$.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-x-10 gap-y-8`,children:[d,m]}),t[15]=d,t[16]=m,t[17]=h):h=t[17];let g;t[18]!==s||t[19]!==i||t[20]!==a||t[21]!==o||t[22]!==n||t[23]!==l||t[24]!==c||t[25]!==r?(g=(0,$.jsx)(nr,{project:n,synthesis:r,isLoading:i,isStale:a,isStuck:o,error:s,onRun:c,onReset:l,label:`SESSION INJECTION PREVIEW`}),t[18]=s,t[19]=i,t[20]=a,t[21]=o,t[22]=n,t[23]=l,t[24]=c,t[25]=r,t[26]=g):g=t[26];let _;return t[27]!==u||t[28]!==h||t[29]!==g?(_=(0,$.jsx)(`div`,{className:`h-full flex flex-col overflow-hidden`,children:(0,$.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-8 py-6`,children:(0,$.jsxs)(`div`,{className:`max-w-[1100px] space-y-8`,children:[u,h,g]})})}),t[27]=u,t[28]=h,t[29]=g,t[30]=_):_=t[30],_}var sr=(0,Z.forwardRef)(function(t,n){let r=(0,Q.c)(70),{memory:i,selected:a,focused:o,confirming:s,onSelect:c,onPin:l,onDelete:u,onDeleteStart:d,onDeleteCancel:f}=t,p;r[0]===i.content?p=r[1]:(p=i.content.length>140?`${i.content.slice(0,140)}…`:i.content,r[0]=i.content,r[1]=p);let m=p,h=a&&`bg-accent/60`,g=o&&!a&&`bg-accent/20`,_=o&&`outline-none ring-1 ring-inset ring-primary/40`,v;r[2]!==h||r[3]!==g||r[4]!==_?(v=e(`group relative flex flex-col gap-1.5 border-b border-border px-4 py-3 transition-colors`,`hover:bg-accent/40`,h,g,_),r[2]=h,r[3]=g,r[4]=_,r[5]=v):v=r[5];let y=i.type,x=Ue[i.type],S;r[6]===i.type?S=r[7]:(S=b(i.type),r[6]=i.type,r[7]=S);let C;r[8]!==y||r[9]!==x||r[10]!==S?(C=(0,$.jsx)(ee,{variant:y,className:`mt-px shrink-0`,title:x,children:S}),r[8]=y,r[9]=x,r[10]=S,r[11]=C):C=r[11];let w;r[12]===m?w=r[13]:(w=(0,$.jsx)(`p`,{className:`flex-1 text-xs leading-relaxed text-foreground line-clamp-2 min-w-0 text-left`,children:m}),r[12]=m,r[13]=w);let T;r[14]!==c||r[15]!==w||r[16]!==C?(T=(0,$.jsxs)(z,{variant:`ghost`,onClick:c,className:`h-auto flex-1 min-w-0 items-start justify-start whitespace-normal p-0 font-normal hover:bg-transparent`,children:[C,w]}),r[14]=c,r[15]=w,r[16]=C,r[17]=T):T=r[17];let E=i.pinned?`opacity-100`:`opacity-0 group-hover:opacity-100 group-focus-within:opacity-100`,D;r[18]===E?D=r[19]:(D=e(`flex items-center gap-1 transition-opacity shrink-0`,E),r[18]=E,r[19]=D);let O=i.pinned?`Unpin`:`Pin`,k=i.pinned&&`text-primary`,A;r[20]===k?A=r[21]:(A=e(k),r[20]=k,r[21]=A);let j=i.pinned?`fill`:`regular`,M;r[22]===j?M=r[23]:(M=(0,$.jsx)(dt,{weight:j}),r[22]=j,r[23]=M);let N;r[24]!==l||r[25]!==O||r[26]!==A||r[27]!==M?(N=(0,$.jsx)(z,{variant:`ghost`,size:`icon-sm`,onClick:l,"aria-label":O,className:A,children:M}),r[24]=l,r[25]=O,r[26]=A,r[27]=M,r[28]=N):N=r[28];let P=s?u:d,F=s?`Confirm delete`:`Delete`,I=s?`text-destructive bg-destructive/10`:`hover:text-destructive`,L=i.pinned&&`opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition-opacity`,R;r[29]!==I||r[30]!==L?(R=e(I,L),r[29]=I,r[30]=L,r[31]=R):R=r[31];let te=s?`fill`:`regular`,B;r[32]===te?B=r[33]:(B=(0,$.jsx)(Le,{weight:te}),r[32]=te,r[33]=B);let V;r[34]!==f||r[35]!==P||r[36]!==F||r[37]!==R||r[38]!==B?(V=(0,$.jsx)(z,{variant:`ghost`,size:`icon-sm`,onClick:P,onBlur:f,"aria-label":F,className:R,children:B}),r[34]=f,r[35]=P,r[36]=F,r[37]=R,r[38]=B,r[39]=V):V=r[39];let H;r[40]!==D||r[41]!==N||r[42]!==V?(H=(0,$.jsxs)(`div`,{className:D,children:[N,V]}),r[40]=D,r[41]=N,r[42]=V,r[43]=H):H=r[43];let U;r[44]!==T||r[45]!==H?(U=(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[T,H]}),r[44]=T,r[45]=H,r[46]=U):U=r[46];let W;r[47]===i.tags?W=r[48]:(W=i.tags.length>0&&(0,$.jsx)(`div`,{className:`flex gap-1 flex-wrap`,children:i.tags.map(cr)}),r[47]=i.tags,r[48]=W);let G;r[49]===i.reviewEvents.length?G=r[50]:(G=i.reviewEvents.length>0&&(0,$.jsx)(`span`,{title:`Flagged for review — possible duplicate or conflict with another memory`,children:(0,$.jsx)(Ve,{weight:`fill`,className:`size-3 text-correction`})}),r[49]=i.reviewEvents.length,r[50]=G);let K;r[51]===i.projects?K=r[52]:(K=i.projects.length>0?(0,$.jsx)(`span`,{className:`text-[11px] text-muted-foreground truncate max-w-32`,children:i.projects.map(lr).join(`, `)}):(0,$.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`global`}),r[51]=i.projects,r[52]=K);let q;r[53]===i.updatedAt?q=r[54]:(q=new Date(i.updatedAt).toLocaleDateString(),r[53]=i.updatedAt,r[54]=q);let ne;r[55]===q?ne=r[56]:(ne=(0,$.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:q}),r[55]=q,r[56]=ne);let J;r[57]!==G||r[58]!==K||r[59]!==ne?(J=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 ml-auto`,children:[G,K,ne]}),r[57]=G,r[58]=K,r[59]=ne,r[60]=J):J=r[60];let Y;r[61]!==W||r[62]!==J?(Y=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 pl-[42px]`,children:[W,J]}),r[61]=W,r[62]=J,r[63]=Y):Y=r[63];let re;return r[64]!==f||r[65]!==n||r[66]!==U||r[67]!==Y||r[68]!==v?(re=(0,$.jsxs)(`li`,{ref:n,className:v,onMouseLeave:f,children:[U,Y]}),r[64]=f,r[65]=n,r[66]=U,r[67]=Y,r[68]=v,r[69]=re):re=r[69],re});function cr(e){return(0,$.jsx)(ee,{variant:`outline`,children:e},e)}function lr(e){return e.name}function ur(t){let n=(0,Q.c)(60),{selectedId:r,list:i}=t,{search:a,searchInput:o,inputRef:s,isLoading:c,filtered:l,focusedIndex:u,confirmingId:d,setConfirmingId:f,rowRefs:p,hasActiveFilters:m,handleSearchChange:h,handleClearFilters:g,handlePin:_,handleDelete:v,handleSelect:y}=i,b=l.length===1?`memory`:`memories`,x=a.search?` matching "${a.search}"`:``,S;n[0]!==l.length||n[1]!==b||n[2]!==x?(S=(0,$.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`sr-only`,children:[l.length,` `,b,x]}),n[0]=l.length,n[1]=b,n[2]=x,n[3]=S):S=n[3];let C;n[4]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(lt,{weight:`regular`,className:`absolute left-2.5 top-1/2 -translate-y-1/2 size-3.5 text-muted-foreground pointer-events-none`}),n[4]=C):C=n[4];let w;n[5]===h?w=n[6]:(w=e=>h(e.target.value),n[5]=h,n[6]=w);let T;n[7]!==s||n[8]!==o||n[9]!==w?(T=(0,$.jsxs)(`div`,{className:`relative flex-1 min-w-0`,children:[C,(0,$.jsx)(se,{ref:s,placeholder:`Search…`,value:o,onChange:w,className:`pl-7`,title:`Press / to focus`})]}),n[7]=s,n[8]=o,n[9]=w,n[10]=T):T=n[10];let E;n[11]!==g||n[12]!==m?(E=m&&(0,$.jsx)(z,{variant:`ghost`,size:`icon-sm`,onClick:g,"aria-label":`Clear filters`,title:`Clear all filters`,children:(0,$.jsx)(st,{weight:`regular`})}),n[11]=g,n[12]=m,n[13]=E):E=n[13];let D;n[14]!==T||n[15]!==E?(D=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 px-3 pt-3 pb-2 border-b border-border shrink-0`,children:[T,E]}),n[14]=T,n[15]=E,n[16]=D):D=n[16];let O;n[17]!==l.length||n[18]!==c?(O=c&&l.length===0&&(0,$.jsx)(`div`,{className:`flex items-center justify-center h-24 text-xs font-mono text-muted-foreground`,children:`Loading…`}),n[17]=l.length,n[18]=c,n[19]=O):O=n[19];let k;n[20]!==l.length||n[21]!==g||n[22]!==c||n[23]!==a.needsReview||n[24]!==a.pinned||n[25]!==a.search||n[26]!==a.type?(k=!c&&l.length===0&&(0,$.jsxs)(Xe,{className:`border-0 rounded-none p-0 h-32`,children:[a.search?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Je,{className:`text-xs font-mono font-normal`,children:[`No memories match “`,a.search,`”`]}),(0,$.jsx)(z,{variant:`link`,size:`sm`,onClick:g,children:`Clear search`})]}):(0,$.jsx)(Je,{className:`text-xs font-mono font-normal`,children:`No memories`}),(a.type||a.pinned||a.needsReview)&&(0,$.jsx)(Ke,{className:`text-[11px] font-mono`,children:`Filters are active — try clearing them in the left panel`})]}),n[20]=l.length,n[21]=g,n[22]=c,n[23]=a.needsReview,n[24]=a.pinned,n[25]=a.search,n[26]=a.type,n[27]=k):k=n[27];let A;if(n[28]!==d||n[29]!==l||n[30]!==u||n[31]!==v||n[32]!==_||n[33]!==y||n[34]!==p||n[35]!==r||n[36]!==f){let e;n[38]!==d||n[39]!==u||n[40]!==v||n[41]!==_||n[42]!==y||n[43]!==p||n[44]!==r||n[45]!==f?(e=(e,t)=>(0,$.jsx)(sr,{ref:e=>{p.current[t]=e},memory:e,selected:r===e.id,focused:u===t,confirming:d===e.id,onSelect:()=>y(e.id),onPin:()=>_(e.id,e.pinned),onDelete:()=>{v(e.id),f(null)},onDeleteStart:()=>f(e.id),onDeleteCancel:()=>f(null)},e.id),n[38]=d,n[39]=u,n[40]=v,n[41]=_,n[42]=y,n[43]=p,n[44]=r,n[45]=f,n[46]=e):e=n[46],A=l.map(e),n[28]=d,n[29]=l,n[30]=u,n[31]=v,n[32]=_,n[33]=y,n[34]=p,n[35]=r,n[36]=f,n[37]=A}else A=n[37];let j;n[47]===A?j=n[48]:(j=(0,$.jsx)(`ul`,{className:`m-0 p-0`,children:A}),n[47]=A,n[48]=j);let M;n[49]!==k||n[50]!==j||n[51]!==O?(M=(0,$.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[O,k,j]}),n[49]=k,n[50]=j,n[51]=O,n[52]=M):M=n[52];let N;n[53]===l.length?N=n[54]:(N=l.length>0&&(0,$.jsxs)(`div`,{className:e(`px-4 py-2 border-t border-border shrink-0`,`text-[11px] font-mono text-muted-foreground`),children:[l.length,` `,l.length===1?`memory`:`memories`]}),n[53]=l.length,n[54]=N);let P;return n[55]!==M||n[56]!==N||n[57]!==S||n[58]!==D?(P=(0,$.jsxs)(`div`,{className:`flex flex-col h-full`,children:[S,D,M,N]}),n[55]=M,n[56]=N,n[57]=S,n[58]=D,n[59]=P):P=n[59],P}var dr=s(`block w-full text-left py-1 px-4 text-xs font-mono transition-colors`,{variants:{active:{true:`text-primary bg-muted/50`,false:`text-muted-foreground hover:text-foreground hover:bg-muted/30`}},defaultVariants:{active:!1}}),fr=s(`flex items-center gap-2 px-4 py-1 text-xs font-mono transition-colors w-full text-left`,{variants:{active:{true:``,false:`text-muted-foreground hover:text-foreground`},color:{primary:``,destructive:``}},compoundVariants:[{active:!0,color:`primary`,class:`text-primary`},{active:!0,color:`destructive`,class:`text-destructive`}],defaultVariants:{active:!1,color:`primary`}});function pr(e){let t=(0,Q.c)(43),{projectName:n}=e,{projectId:r}=Be.useParams(),i=Be.useSearch(),a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsxs)(p,{to:`/`,className:`inline-flex items-center gap-1 text-[11px] font-mono text-muted-foreground hover:text-foreground transition-colors`,children:[(0,$.jsx)(Pe,{weight:`regular`,className:`size-3`}),`Projects`]}),t[0]=a):a=t[0];let o;t[1]===n?o=t[2]:(o=(0,$.jsxs)(`div`,{className:`px-4`,children:[a,(0,$.jsx)(`p`,{className:`text-xs font-mono font-medium text-foreground truncate mt-3 mb-4`,children:n})]}),t[1]=n,t[2]=o);let s;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(`p`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground font-mono mb-1 px-4`,children:`Types`}),t[3]=s):s=t[3];let c;t[4]===r?c=t[5]:(c={projectId:r},t[4]=r,t[5]=c);let l=!i.type,u;t[6]===l?u=t[7]:(u=dr({active:l}),t[6]=l,t[7]=u);let d;t[8]!==c||t[9]!==u?(d=(0,$.jsx)(Ze,{to:`/$projectId`,params:c,search:gr,className:u,children:`All`}),t[8]=c,t[9]=u,t[10]=d):d=t[10];let f;t[11]!==r||t[12]!==i.type?(f=ze.map(e=>(0,$.jsx)(Ze,{to:`/$projectId`,params:{projectId:r},search:t=>({...t,type:e}),className:dr({active:i.type===e}),children:b(e)},e)),t[11]=r,t[12]=i.type,t[13]=f):f=t[13];let m;t[14]!==d||t[15]!==f?(m=(0,$.jsxs)(`div`,{className:`mb-1`,children:[s,d,f]}),t[14]=d,t[15]=f,t[16]=m):m=t[16];let h;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(`div`,{className:`border-t border-border my-3`}),t[17]=h):h=t[17];let g;t[18]===r?g=t[19]:(g={projectId:r},t[18]=r,t[19]=g);let _;t[20]===i.pinned?_=t[21]:(_=fr({active:i.pinned,color:`primary`}),t[20]=i.pinned,t[21]=_);let v=i.pinned?`fill`:`regular`,y;t[22]===v?y=t[23]:(y=(0,$.jsx)(dt,{weight:v,className:`size-3 shrink-0`}),t[22]=v,t[23]=y);let x;t[24]!==g||t[25]!==_||t[26]!==y?(x=(0,$.jsxs)(Ze,{to:`/$projectId`,params:g,search:hr,className:_,children:[y,`Pinned only`]}),t[24]=g,t[25]=_,t[26]=y,t[27]=x):x=t[27];let S;t[28]===r?S=t[29]:(S={projectId:r},t[28]=r,t[29]=S);let C;t[30]===i.needsReview?C=t[31]:(C=fr({active:i.needsReview,color:`destructive`}),t[30]=i.needsReview,t[31]=C);let w=i.needsReview?`fill`:`regular`,T;t[32]===w?T=t[33]:(T=(0,$.jsx)(Ve,{weight:w,className:`size-3 shrink-0`}),t[32]=w,t[33]=T);let E;t[34]!==S||t[35]!==C||t[36]!==T?(E=(0,$.jsxs)(Ze,{to:`/$projectId`,params:S,search:mr,className:C,children:[T,`Needs review`]}),t[34]=S,t[35]=C,t[36]=T,t[37]=E):E=t[37];let D;return t[38]!==x||t[39]!==o||t[40]!==E||t[41]!==m?(D=(0,$.jsxs)(`nav`,{className:`flex flex-col h-full bg-background border-r border-border py-3 overflow-y-auto`,children:[o,m,h,x,E]}),t[38]=x,t[39]=o,t[40]=E,t[41]=m,t[42]=D):D=t[42],D}function mr(e){return{...e,needsReview:!e.needsReview}}function hr(e){return{...e,pinned:!e.pinned}}function gr(e){return{...e,type:void 0}}function _r(){let e=(0,Q.c)(38),{projectId:t}=Be.useParams(),{tab:n}=Be.useSearch(),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={from:Be.fullPath},e[0]=r):r=e[0];let i=L(r),a;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=[],e[1]=a):a=e[1];let{data:o}=j(vr,a),s;e[2]===o?s=e[3]:(s=o===void 0?[]:o,e[2]=o,e[3]=s);let c=s,l;if(e[4]!==t||e[5]!==c){let n;e[7]===t?n=e[8]:(n=e=>e.id===t,e[7]=t,e[8]=n),l=c.find(n),e[4]=t,e[5]=c,e[6]=l}else l=e[6];let u=l,d=u?.name??t,f;e[9]===t?f=e[10]:(f={select:e=>{let n=e.location.pathname,r=`/${t}/`;return n.startsWith(r)?n.slice(r.length):null}},e[9]=t,e[10]=f);let p=Qe(f),m=an(p),h;e[11]===d?h=e[12]:(h=(0,$.jsx)(`div`,{className:`w-50 shrink-0 overflow-hidden flex flex-col`,children:(0,$.jsx)(pr,{projectName:d})}),e[11]=d,e[12]=h);let g;e[13]===i?g=e[14]:(g=e=>i({search:t=>({...t,tab:e})}),e[13]=i,e[14]=g);let _;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsxs)(tn,{variant:`line`,className:`px-3 pt-2 pb-0 border-b border-border w-full rounded-none justify-start h-auto`,children:[(0,$.jsx)(nn,{value:`overview`,children:`Overview`}),(0,$.jsx)(nn,{value:`memories`,children:`Memories`}),(0,$.jsx)(nn,{value:`activity`,children:`Activity`})]}),e[15]=_):_=e[15];let v;e[16]===u?v=e[17]:(v=(0,$.jsx)(rn,{value:`overview`,className:`flex-1 min-h-0 overflow-hidden`,children:u?(0,$.jsx)(or,{project:u}):(0,$.jsxs)(Xe,{children:[(0,$.jsx)(Je,{children:`Project not found`}),(0,$.jsx)(Ke,{children:`This project may have been removed.`})]})}),e[16]=u,e[17]=v);let y;e[18]!==m||e[19]!==p?(y=(0,$.jsx)(rn,{value:`memories`,className:`flex-1 min-h-0 overflow-hidden`,children:(0,$.jsx)(ur,{selectedId:p,list:m})}),e[18]=m,e[19]=p,e[20]=y):y=e[20];let b=u?.scopeHash,x;e[21]===b?x=e[22]:(x=(0,$.jsx)(rn,{value:`activity`,className:`flex-1 min-h-0 overflow-hidden`,children:(0,$.jsx)(St,{scope:b})}),e[21]=b,e[22]=x);let S;e[23]!==y||e[24]!==x||e[25]!==g||e[26]!==v||e[27]!==n?(S=(0,$.jsxs)($t,{value:n,onValueChange:g,className:`flex flex-col h-full gap-0`,children:[_,v,y,x]}),e[23]=y,e[24]=x,e[25]=g,e[26]=v,e[27]=n,e[28]=S):S=e[28];let C;e[29]!==t||e[30]!==p?(C=p&&(0,$.jsx)(hn,{selectedId:p,projectId:t}),e[29]=t,e[30]=p,e[31]=C):C=e[31];let w;e[32]!==S||e[33]!==C?(w=(0,$.jsxs)(`div`,{className:`relative flex-1 min-w-0 border-x border-border overflow-hidden flex flex-col`,children:[S,C]}),e[32]=S,e[33]=C,e[34]=w):w=e[34];let T;return e[35]!==w||e[36]!==h?(T=(0,$.jsxs)(`div`,{className:`flex flex-1 min-h-0 w-full`,children:[h,w]}),e[35]=w,e[36]=h,e[37]=T):T=e[37],T}function vr(e){return e.from({p:w})}export{_r as component};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{fn as e,wt as t}from"./collections-gO05Tpa7.js";import{t as n}from"./WorkspaceMemoryDetail-CKp3CCbn.js";import{t as r}from"./index--CCYAGMc.js";var i=t(),a=e();function o(){let e=(0,i.c)(2),{memoryId:t}=r.useParams(),o;return e[0]===t?o=e[1]:(o=(0,a.jsx)(n,{id:t},t),e[0]=t,e[1]=o),o}export{o as component};
|