@wrongstack/webui 0.292.0 → 0.292.1

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.
Files changed (23) hide show
  1. package/dist/assets/{AnalyticsDashboard-DausPJOP.js → AnalyticsDashboard-DM8YmJuy.js} +1 -1
  2. package/dist/assets/{AudienceMemoryPanel-di7dxMBb.js → AudienceMemoryPanel-BN1qR1rz.js} +1 -1
  3. package/dist/assets/{ChangesView-DPfs8VeV.js → ChangesView-PgFw9vKk.js} +1 -1
  4. package/dist/assets/{ChronicleDashboard-CMkQ7EBt.js → ChronicleDashboard-CtOiFCYV.js} +1 -1
  5. package/dist/assets/{CodeEditor-iYG6Q0ag.js → CodeEditor-B_KwrAhN.js} +1 -1
  6. package/dist/assets/{CronJobsPanel-CKQw0vat.js → CronJobsPanel-CVXW2Y-n.js} +1 -1
  7. package/dist/assets/{DebugDashboard-BeDOPYmE.js → DebugDashboard-BldwPA32.js} +1 -1
  8. package/dist/assets/{DesignGalleryView-DY3atfBB.js → DesignGalleryView-CUi5RBHH.js} +1 -1
  9. package/dist/assets/{GoalView-Dh27cG1z.js → GoalView-p7f1544B.js} +1 -1
  10. package/dist/assets/{KanbanView-DYa0iSlV.js → KanbanView-CD_x5YND.js} +1 -1
  11. package/dist/assets/{MemoryManager-D1_0SW_m.js → MemoryManager-BrCVqIJK.js} +1 -1
  12. package/dist/assets/{OfficeMapPanel-DTQPdV7a.js → OfficeMapPanel-D01rqjLt.js} +1 -1
  13. package/dist/assets/{SddHub-BW7ExYNe.js → SddHub-DLVIXlN6.js} +1 -1
  14. package/dist/assets/{SessionsDashboard-Cf_67b9g.js → SessionsDashboard-DsAc_Sx2.js} +1 -1
  15. package/dist/assets/{SetupScreen-fu9Qr5Qj.js → SetupScreen-KqV61-Ir.js} +1 -1
  16. package/dist/assets/{SkillDetailView-DHcDX_1A.js → SkillDetailView-CK7MB8Uo.js} +1 -1
  17. package/dist/assets/{TechStackView-CXE80hAc.js → TechStackView-nVNj4kWJ.js} +1 -1
  18. package/dist/assets/{index-BlCmdyyZ.css → index-BwEOo8R-.css} +1 -1
  19. package/dist/assets/{index-BLAy5CKD.js → index-Du90vd1u.js} +3 -3
  20. package/dist/index.html +2 -2
  21. package/dist/index.js +5 -5
  22. package/dist/index.js.map +2 -2
  23. package/package.json +6 -6
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Ai as t,Bn as n,Bt as r,Cn as i,Ct as a,Dt as o,Fi as s,Ft as c,Hr as l,Nt as u,Or as d,Rr as f,Vr as p,Wi as m,Yi as h,Yr as g,Yt as _,Zi as v,_ as y,_n as ee,_r as te,a as ne,aa as b,bt as re,cn as x,dn as S,dr as C,f as w,fn as T,gn as ie,hi as E,i as D,li as O,n as k,oi as ae,ot as oe,pr as se,qn as ce,qt as le,r as ue,rn as de,s as fe,tt as pe,wi as me,xi as he}from"./vendor-Di1mdAi5.js";import{n as ge}from"./ui-store-BepZz9CZ.js";import{i as A,t as _e}from"./useWebSocket-CRYUFxmO.js";import{t as ve}from"./ws-client-BWO_PH_X.js";import{t as j}from"./utils-C4qVQ63O.js";import{j as ye}from"./stores-JSLvWOQY.js";import{a as be,i as xe,n as Se,o as Ce,r as we,t as Te}from"./dialog-CNwwBFw3.js";import{t as M}from"./button-99L74zdE.js";import{t as N}from"./pagination-Ktuov5iD.js";import{t as P}from"./input-DXjUO_X9.js";import{S as Ee,g as De}from"./index-BLAy5CKD.js";import{_ as Oe,a as ke,b as Ae,c as F,d as je,f as Me,g as Ne,h as I,i as L,l as R,m as z,n as Pe,o as B,p as Fe,r as V,s as Ie,t as Le,u as Re,v as ze,y as H}from"./shared-aSCYBzAV.js";var U=e(b(),1),W=pe(),G=212,Be=188;function K(e){return e.length>14?`${e.slice(0,11)}…`:e}function Ve(e,t=58){let n=e.replace(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t-1)}…`:n}function He(e){return e.type===`symbol`?[e.path,e.symbol?`#${e.symbol}`:``].filter(Boolean).join(``):e.path??e.command??e.symbol??e.type}function Ue(e){return e===`active`?`border-success/45 bg-success/10 text-success`:e===`stale`?`border-warning/45 bg-warning/10 text-warning`:e===`contradicted`?`border-destructive/45 bg-destructive/10 text-destructive`:e===`superseded`?`border-warning/35 bg-warning/5 text-warning`:`border-border bg-muted/55 text-muted-foreground`}function We({data:e}){let{entry:t,center:n}=e;return(0,W.jsxs)(`div`,{className:n?`border border-primary/70 bg-card px-3 py-2.5 text-card-foreground shadow-[0_0_0_1px_hsl(var(--primary)/0.2),0_0_24px_hsl(var(--primary)/0.12)]`:`border border-border/80 bg-card/95 px-3 py-2.5 text-card-foreground shadow-lg`,style:{width:G},title:t.text,children:[(0,W.jsx)(fe,{type:`target`,position:y.Top,className:`!border-background !bg-muted-foreground`}),(0,W.jsx)(fe,{type:`source`,position:y.Bottom,className:`!border-background !bg-primary`}),(0,W.jsx)(fe,{type:`source`,position:y.Right,className:`!border-background !bg-primary`}),(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`border px-1.5 py-0.5 text-[9px] font-bold uppercase ${Ue(t.status)}`,children:t.status}),(0,W.jsx)(`span`,{className:`ml-auto truncate font-mono text-[9px] text-muted-foreground`,children:K(t.id)})]}),(0,W.jsx)(`p`,{className:`mt-2 line-clamp-2 text-[11px] leading-4 text-foreground/90`,children:Ve(t.text)}),(0,W.jsx)(`p`,{className:`mt-1 font-mono text-[9px] uppercase text-muted-foreground`,children:t.kind})]})}function Ge({data:e}){return(0,W.jsxs)(`div`,{className:`border border-info/40 bg-info/8 px-2.5 py-2 text-card-foreground shadow-lg`,style:{width:Be},title:e.label,children:[(0,W.jsx)(fe,{type:`target`,position:y.Left,className:`!border-background !bg-info`}),(0,W.jsx)(`p`,{className:`font-mono text-[9px] font-bold uppercase text-info`,children:e.anchor.type}),(0,W.jsx)(`p`,{className:`mt-1 truncate font-mono text-[10px] text-foreground/85`,children:e.label})]})}var Ke={memoryNode:We,anchorNode:Ge};function qe(e){return{id:e,revision:0,scope:`project`,kind:`fact`,status:`deleted`,text:`Memory is unavailable or has been removed.`,importance:0,confidence:0,freshness:0,tags:[],anchors:[],createdAt:``,updatedAt:``}}function Je({centerMemory:e,allMemories:t,graphEdges:n,loading:r=!1,error:i=null}){let a=`mem:${e.id}`,o=(0,U.useMemo)(()=>n.filter(e=>e.from===a&&e.to.startsWith(`mem:`)||e.to===a&&e.from.startsWith(`mem:`)).slice(0,24),[a,n]),{nodes:s,edges:c}=(0,U.useMemo)(()=>{let n=[],r=[],i=new Map(t.map(e=>[e.id,e]));n.push({id:e.id,type:`memoryNode`,position:{x:320-G/2,y:120},data:{entry:e,center:!0}});let s=[...e.supersededBy?[{id:e.supersededBy,relation:`superseded by`}]:[],...(e.supersedes??[]).map(e=>({id:e,relation:`supersedes`})),...(e.contradicts??[]).map(e=>({id:e,relation:`contradicts`}))];for(let e of o){let t=(e.from===a?e.to:e.from).slice(4);s.some(n=>n.id===t&&n.relation===e.relation)||s.push({id:t,relation:e.relation,weight:e.weight,evidence:e.evidence})}let c=320-(s.length-1)*220/2;return s.forEach((t,a)=>{let o=i.get(t.id)??qe(t.id),s=t.relation===`superseded by`,l=s?0:280+Math.floor(a/3)*130,u=s?320-G/2:c+a*220-G/2;n.push({id:`memory:${t.id}:${a}`,type:`memoryNode`,position:{x:u,y:l},data:{entry:o,center:!1}});let d=t.relation===`contradicts`,f=s?`memory:${t.id}:${a}`:e.id,p=s?e.id:`memory:${t.id}:${a}`;r.push({id:`relation:${t.relation}:${t.id}:${a}`,source:f,target:p,type:`smoothstep`,animated:!d,label:t.weight===void 0?t.relation:`${t.relation} ${t.weight.toFixed(2)}`,data:{evidence:t.evidence??[]},style:{stroke:d?`hsl(var(--destructive))`:`hsl(var(--primary))`,strokeWidth:1.7,...d?{strokeDasharray:`5 4`}:{}},labelStyle:{fill:d?`hsl(var(--destructive))`:`hsl(var(--muted-foreground))`,fontSize:9,fontWeight:700},labelBgStyle:{fill:`hsl(var(--card))`,fillOpacity:.9}})}),e.anchors.forEach((t,i)=>{let a=`anchor:${i}`;n.push({id:a,type:`anchorNode`,position:{x:540,y:120+(i-(e.anchors.length-1)/2)*66},data:{anchor:t,label:He(t)}}),r.push({id:`anchor-edge:${i}`,source:e.id,target:a,type:`smoothstep`,style:{stroke:`hsl(var(--info))`,strokeWidth:1.3}})}),{nodes:n,edges:r}},[t,e,a,o]);return s.length<=1&&!r&&!i?null:(0,W.jsxs)(`section`,{className:`overflow-hidden border border-border/75 bg-background/35`,"aria-label":`Memory relationship graph`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/70 bg-card/55 px-3 py-2`,children:[(0,W.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-muted-foreground`,children:`Relationship map`}),(0,W.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:r?`loading real graph…`:`${s.length} nodes · ${c.length} edges`})]}),i&&(0,W.jsx)(`p`,{className:`border-b border-destructive/25 bg-destructive/5 px-3 py-2 text-[10px] text-destructive`,children:i}),s.length>1&&(0,W.jsx)(`div`,{className:`h-[320px] w-full`,"aria-hidden":`true`,children:(0,W.jsxs)(w,{nodes:s,edges:c,nodeTypes:Ke,fitView:!0,fitViewOptions:{padding:.24,maxZoom:1.05},minZoom:.4,maxZoom:1.5,nodesConnectable:!1,elementsSelectable:!1,panOnScroll:!1,zoomOnScroll:!1,proOptions:{hideAttribution:!0},children:[(0,W.jsx)(ue,{variant:D.Dots,gap:18,size:1,color:`hsl(var(--muted-foreground) / 0.18)`}),(0,W.jsx)(ne,{showInteractive:!1,className:`!border-border !bg-card !shadow-lg`})]})}),o.some(e=>e.evidence?.length)&&(0,W.jsx)(`div`,{className:`grid gap-1 border-t border-border/70 bg-card/35 px-3 py-2`,children:o.filter(e=>e.evidence?.length).slice(0,12).map(e=>{let t=(e.from===a?e.to:e.from).slice(4);return(0,W.jsxs)(`p`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:[(0,W.jsx)(`span`,{className:`text-info`,children:e.relation}),` `,K(t),` · why:`,` `,e.evidence?.join(`, `)]},e.id)})})]})}function Ye({memory:e,allMemories:n,relatedMemories:r,graphEdges:i,graphLoading:o,graphError:s,onClose:c,onOpenMemory:l,onEdit:u,onDelete:d,onTagSelect:f,onNotice:p}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-border/70 bg-card/65 px-4 py-3 backdrop-blur-xl`,children:[(0,W.jsx)(M,{variant:`ghost`,size:`icon`,className:`md:hidden`,onClick:c,"aria-label":`Back to memory list`,children:(0,W.jsx)(m,{className:`size-4`})}),(0,W.jsx)(`span`,{className:j(`text-[10px] font-bold uppercase tracking-[0.14em]`,I(e.kind)),children:V[e.kind]??e.kind}),(0,W.jsx)(R,{status:e.status}),(0,W.jsx)(`span`,{className:`border border-border/70 px-2 py-0.5 font-mono text-[9px] uppercase text-muted-foreground`,children:e.scope}),e.audience&&(0,W.jsxs)(`span`,{className:`flex items-center gap-1 border border-primary/30 bg-primary/10 px-2 py-0.5 font-mono text-[9px] text-primary`,title:Fe(e.audience),children:[(0,W.jsx)(t,{className:`size-3`}),Fe(e.audience)]}),(0,W.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,W.jsx)(M,{variant:`ghost`,size:`icon`,"aria-label":`Copy memory ID`,title:`Copy memory ID`,onClick:()=>{navigator.clipboard?.writeText(e.id),p(`Memory ID copied.`)},children:(0,W.jsx)(ae,{className:`size-4`})}),(0,W.jsxs)(M,{variant:`outline`,size:`sm`,onClick:u,disabled:e.status===`deleted`,children:[(0,W.jsx)(T,{className:`size-3.5`}),` Edit`]}),(0,W.jsxs)(M,{variant:`destructive`,size:`sm`,onClick:d,disabled:e.status===`deleted`,children:[(0,W.jsx)(a,{className:`size-3.5`}),` Delete`]})]})]}),(0,W.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-4 md:p-5`,children:(0,W.jsxs)(`div`,{className:`mx-auto max-w-5xl space-y-5`,children:[(0,W.jsx)(Xe,{memory:e}),(0,W.jsx)(Ze,{memory:e}),e.tags.length>0&&(0,W.jsx)(Qe,{tags:e.tags,onTagSelect:f}),e.anchors.length>0&&(0,W.jsx)($e,{anchors:e.anchors}),r.length>0&&(0,W.jsx)(et,{relatedMemories:r,allMemories:n,onOpenMemory:l}),(0,W.jsx)(Je,{centerMemory:e,allMemories:n,graphEdges:i,loading:o,error:s}),(0,W.jsx)(tt,{memory:e}),e.status===`deleted`&&(0,W.jsx)(nt,{contextPolicy:e.contextPolicy})]})})]})}function Xe({memory:e}){return(0,W.jsxs)(`div`,{className:`relative overflow-hidden border border-border/75 bg-card/55 p-5 shadow-[inset_0_1px_0_hsl(var(--foreground)/0.04)]`,children:[(0,W.jsx)(`div`,{className:`pointer-events-none absolute -right-10 -top-10 size-36 bg-[radial-gradient(circle,hsl(var(--info)/0.13),transparent_68%)]`}),(0,W.jsx)(`p`,{className:`relative whitespace-pre-wrap text-sm leading-7 text-foreground md:text-[15px]`,children:e.text}),e.summary&&(0,W.jsx)(`p`,{className:`relative mt-4 border-l-2 border-info/50 pl-3 text-xs italic leading-5 text-muted-foreground`,children:e.summary}),(0,W.jsxs)(`div`,{className:`relative mt-5 flex flex-wrap items-center gap-2 border-t border-border/60 pt-3`,children:[(0,W.jsx)(`code`,{className:`min-w-0 break-all font-mono text-[10px] text-muted-foreground`,children:e.id}),(0,W.jsxs)(`span`,{className:`ml-auto font-mono text-[10px] text-muted-foreground`,children:[`revision `,e.revision]})]})]})}function Ze({memory:e}){return(0,W.jsx)(`div`,{className:`grid gap-px bg-border/60 sm:grid-cols-3`,children:[[`Importance`,e.importance,r],[`Confidence`,e.confidence,E],[`Freshness`,e.freshness,de]].map(([e,t,n])=>(0,W.jsxs)(`div`,{className:`bg-card/60 p-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(n,{className:`size-3.5 text-info`}),(0,W.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.13em] text-muted-foreground`,children:e}),(0,W.jsxs)(`span`,{className:`ml-auto font-mono text-xs font-bold tabular-nums`,children:[Math.round(t*100),`%`]})]}),(0,W.jsx)(`div`,{className:`mt-2 h-1 bg-muted`,children:(0,W.jsx)(`div`,{className:`h-full bg-info shadow-[0_0_8px_hsl(var(--info)/0.45)]`,style:{width:`${Math.round(t*100)}%`}})})]},e))})}function Qe({tags:e,onTagSelect:t}){return(0,W.jsxs)(`section`,{children:[(0,W.jsxs)(`h3`,{className:`mb-2 flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:[(0,W.jsx)(o,{className:`size-3.5 text-info`}),` Tags`]}),(0,W.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map(e=>(0,W.jsxs)(`button`,{type:`button`,onClick:()=>t(e),className:`border border-info/25 bg-info/5 px-2 py-1 font-mono text-[10px] text-info hover:border-info/55 hover:bg-info/10`,children:[`#`,e]},e))})]})}function $e({anchors:e}){return(0,W.jsxs)(`section`,{className:`border border-border/75 bg-card/40`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/65 px-3 py-2.5`,children:[(0,W.jsxs)(`h3`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:[(0,W.jsx)(f,{className:`size-3.5 text-info`}),` Anchors`]}),(0,W.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.length})]}),(0,W.jsx)(`ul`,{className:`divide-y divide-border/55`,children:e.map((e,t)=>(0,W.jsxs)(`li`,{className:`flex min-w-0 items-start gap-3 px-3 py-2.5`,children:[(0,W.jsx)(`span`,{className:`mt-0.5 flex size-7 shrink-0 items-center justify-center border border-info/25 bg-info/5 text-info`,children:e.type===`command`?(0,W.jsx)(u,{className:`size-3.5`}):(0,W.jsx)(f,{className:`size-3.5`})}),(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`p`,{className:`text-[9px] font-bold uppercase text-muted-foreground`,children:e.type}),(0,W.jsxs)(`p`,{className:`mt-0.5 break-all font-mono text-[10px] leading-4 text-foreground/85`,children:[e.path??e.command??`—`,e.symbol?`#${e.symbol}`:``]})]}),(e.lineStart||e.lineEnd)&&(0,W.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono text-[9px] text-muted-foreground`,children:[`L`,e.lineStart??`?`,`–`,e.lineEnd??`?`]})]},`${e.type}:${e.path??e.command??e.symbol}:${t}`))})]})}function et({relatedMemories:e,allMemories:t,onOpenMemory:n}){return(0,W.jsxs)(`section`,{className:`border border-border/75 bg-card/40`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/65 px-3 py-2.5`,children:[(0,W.jsxs)(`h3`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:[(0,W.jsx)(se,{className:`size-3.5 text-info`}),` Memory relationships`]}),(0,W.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.length})]}),(0,W.jsx)(`ul`,{className:`divide-y divide-border/55`,children:e.map(e=>{let r=t.find(t=>t.id===e.id);return(0,W.jsx)(`li`,{children:(0,W.jsxs)(`button`,{type:`button`,disabled:!r,onClick:()=>r&&n(r.id),className:`group flex w-full min-w-0 items-center gap-3 px-3 py-2.5 text-left hover:bg-info/5 disabled:cursor-not-allowed disabled:opacity-55`,children:[(0,W.jsx)(`span`,{className:j(`w-24 shrink-0 text-[9px] font-bold uppercase`,e.relation===`Contradicts`?`text-destructive`:`text-info`),children:e.relation}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs`,children:r?Ne(r.text,95):`Referenced memory is unavailable`}),(0,W.jsx)(`code`,{className:`hidden max-w-32 truncate font-mono text-[9px] text-muted-foreground sm:block`,children:e.id}),r&&(0,W.jsx)(he,{className:`size-3.5 shrink-0 text-muted-foreground group-hover:text-info`})]})},`${e.relation}:${e.id}`)})})]})}function tt({memory:e}){return(0,W.jsx)(`section`,{className:`grid gap-px bg-border/60 sm:grid-cols-2 lg:grid-cols-4`,children:[[`Created`,z(e.createdAt),s],[`Updated`,z(e.updatedAt),de],[`Last accessed`,z(e.lastAccessedAt),i],[`Last verified`,z(e.lastVerifiedAt),r]].map(([e,t,n])=>(0,W.jsxs)(`div`,{className:`bg-card/50 p-3`,children:[(0,W.jsx)(n,{className:`size-3.5 text-muted-foreground`}),(0,W.jsx)(`p`,{className:`mt-2 text-[9px] font-bold uppercase tracking-[0.12em] text-muted-foreground`,children:e}),(0,W.jsx)(`p`,{className:`mt-1 text-[10px] leading-4 text-foreground/85`,children:t})]},e))})}function nt({contextPolicy:e}){return(0,W.jsxs)(`div`,{className:`flex items-start gap-3 border border-border bg-muted/50 p-4 text-xs text-muted-foreground`,children:[(0,W.jsx)(h,{className:`mt-0.5 size-4 shrink-0`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`font-bold text-foreground`,children:`Deleted memory`}),(0,W.jsx)(`p`,{className:`mt-1 leading-5`,children:e===`never`?`This record is audit-only and carries an absolute ban: it can never enter LLM context.`:`The record is inactive and cannot be edited, but remains eligible as historical evidence when retrieval finds it relevant.`})]})]})}var rt={filePath:``,primaryMatches:[],symbolMatches:[],relatedMatches:[],totalCount:0,activeCount:0,supersededCount:0,reviewPendingCount:0};function it(e){let{filePath:t,lineStart:n,lineEnd:r,limit:i=50,showSuperseded:a=!0,showDeleted:o=!1,autoFetch:s=!0,sendOptions:c}=e,l=c?JSON.stringify(c):``,[u,d]=(0,U.useState)(null),[f,p]=(0,U.useState)(!1),[m,h]=(0,U.useState)(null),g=(0,U.useRef)(0),_=(0,U.useRef)(null),v=(0,U.useRef)(c);v.current=c;let y=(0,U.useCallback)(()=>{if(!t){d(null),h(null),p(!1);return}let e=++g.current;p(!0),h(null);let s=ve();if(!s){h(`WebSocket client unavailable`),p(!1);return}_.current?.(),_.current=null;let c=t,l=s.on(`memory.super.forFile`,t=>{if(e!==g.current)return;let n=t.payload.response;n&&n.filePath!==c||(t.payload.error?(h(t.payload.error),d(null)):(d(n??rt),h(null)),p(!1))});_.current=l;let u={filePath:t,limit:i,showSuperseded:a,showDeleted:o,...n===void 0?{}:{lineStart:n},...r===void 0?{}:{lineEnd:r}};try{s.findMemoriesForFile(u,v.current??void 0)}catch(t){l(),_.current===l&&(_.current=null),e===g.current&&(h(t instanceof Error?t.message:String(t)),p(!1))}},[t,n,r,i,a,o]);(0,U.useEffect)(()=>{if(s)return y(),()=>{g.current++,_.current?.(),_.current=null}},[s,y,l]);let ee=(0,U.useCallback)(()=>{y()},[y]);return(0,U.useEffect)(()=>()=>{_.current?.(),_.current=null},[]),{data:u,loading:f,error:m,refetch:ee}}function at(e){return e>=.9?`bg-success/15 border-success/40`:e>=.7?`bg-info/15 border-info/40`:e>=.4?`bg-warning/10 border-warning/30`:`bg-muted/30 border-border/40`}function q(e){switch(e){case`scope_file`:return`scope: file`;case`scope_symbol`:return`scope: symbol`;case`anchor_file`:return`anchor: file`;case`anchor_symbol`:return`anchor: symbol`;case`anchor_directory`:return`anchor: directory`;case`mention`:return`text mention`}}function ot({match:e,cursorBoosted:t,onShowMemory:r,onAcceptDeletion:i,onKeep:a,onUpdate:o,onMarkPermanent:s,onRecover:l,pendingAction:u}){let d=e.memory.status===`deleted`,f=e.memory.status===`superseded`,m=e.pendingReview,h=u!==void 0,g=t===!0;return(0,W.jsxs)(`article`,{className:j(`group relative rounded-md border px-3 py-2 text-sm transition-colors`,at(e.matchStrength),g&&`ring-1 ring-primary/40 ring-offset-0`,d&&`opacity-70`),"data-match-via":e.matchedVia,"data-memory-id":e.memory.id,children:[(0,W.jsx)(`header`,{className:`flex items-start justify-between gap-2`,children:(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] uppercase tracking-wide`,children:[(0,W.jsx)(`span`,{className:j(`font-mono`,I(e.memory.kind)),children:V[e.memory.kind]??e.memory.kind}),(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`·`}),(0,W.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:q(e.matchedVia)}),g&&(0,W.jsxs)(`span`,{className:`flex items-center gap-0.5 rounded-sm bg-primary/15 px-1 py-0.5 font-mono text-primary`,title:`Cursor line range matches this memory's anchor`,children:[(0,W.jsx)(S,{className:`size-2.5`}),` cursor`]}),m&&(0,W.jsxs)(`span`,{className:`flex items-center gap-0.5 rounded-sm bg-warning/15 px-1 py-0.5 font-mono text-warning`,title:`Hygiene review: ${m.reason} (${m.ageDays}d old)`,children:[(0,W.jsx)(re,{className:`size-2.5`}),` review`]}),d&&(0,W.jsx)(`span`,{className:`font-mono text-destructive`,children:`deleted`}),f&&!d&&(0,W.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:`superseded`})]}),(0,W.jsx)(`p`,{className:`mt-1 text-foreground/90`,children:Ne(e.memory.text,200)}),(0,W.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,W.jsx)(R,{status:e.memory.status}),(0,W.jsxs)(`span`,{children:[`updated `,ze(e.memory.updatedAt)]})]})]})}),(0,W.jsxs)(`footer`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,children:[d&&l&&(0,W.jsxs)(M,{type:`button`,size:`sm`,variant:`outline`,disabled:h,onClick:()=>l(e.memory.id),className:`h-7 gap-1 border-primary/40 px-2 text-[11px] text-primary hover:bg-primary/10`,title:`Restore this memory to active status (PR #1: memory_recover)`,children:[(0,W.jsx)(de,{className:`size-3`}),` Recover`]}),f&&e.supersededByActiveId&&r&&(0,W.jsxs)(M,{type:`button`,size:`sm`,variant:`outline`,disabled:h,onClick:()=>r(e.supersededByActiveId),className:`h-7 gap-1 px-2 text-[11px]`,title:`This version is superseded — jump to the active version`,children:[(0,W.jsx)(C,{className:`size-3`}),` Go to active`]}),m&&(0,W.jsxs)(W.Fragment,{children:[m.suggestedAction===`delete`&&(0,W.jsxs)(M,{type:`button`,size:`sm`,variant:`destructive`,disabled:h,onClick:()=>i?.(m.candidateId,e.memory.id),className:`h-7 gap-1 px-2 text-[11px]`,title:`Accept hygiene's deletion suggestion — memory will be forgotten`,children:[(0,W.jsx)(me,{className:`size-3`}),` Accept Deletion`]}),(0,W.jsxs)(M,{type:`button`,size:`sm`,variant:`outline`,disabled:h,onClick:()=>a?.(m.candidateId,e.memory.id),className:`h-7 gap-1 px-2 text-[11px]`,title:`Reject the suggestion — memory stays as-is and may be re-suggested later`,children:[(0,W.jsx)(oe,{className:`size-3`}),` Keep`]}),(0,W.jsxs)(M,{type:`button`,size:`sm`,variant:`outline`,disabled:h,onClick:()=>o?.(e.memory.id),className:`h-7 gap-1 px-2 text-[11px]`,title:`Update the memory's content — versioning creates a new active record`,children:[(0,W.jsx)(c,{className:`size-3`}),` Update`]}),s&&(0,W.jsxs)(M,{type:`button`,size:`sm`,variant:`outline`,disabled:h,onClick:()=>s(e.memory.id),className:`h-7 gap-1 border-warning/40 px-2 text-[11px] text-warning hover:bg-warning/10`,title:"Promote to `permanent` — hygiene will never surface this again",children:[(0,W.jsx)(S,{className:`size-3`}),` Mark as Permanent`]})]}),r&&!d&&(0,W.jsxs)(M,{type:`button`,size:`sm`,variant:`ghost`,disabled:h,onClick:()=>r(e.memory.id),className:`h-7 gap-1 px-2 text-[11px] text-muted-foreground hover:text-foreground`,title:`Open the full record in MemoryManager`,children:[(0,W.jsx)(p,{className:`size-3`}),` Show full`]}),u&&(0,W.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 text-[10px] text-muted-foreground`,children:[(0,W.jsx)(n,{className:`size-3 animate-spin`}),` `,u]})]})]})}function J({icon:e,title:t,count:n,matches:r,cursorBoosted:i=!1,...a}){let o=Ee(r,10);return r.length===0?null:(0,W.jsxs)(`section`,{className:`flex flex-col gap-1.5`,children:[(0,W.jsxs)(`h3`,{className:`flex items-center gap-1.5 px-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[(0,W.jsx)(e,{className:`size-3`}),(0,W.jsx)(`span`,{children:t}),(0,W.jsxs)(`span`,{className:`font-mono`,children:[`(`,n,`)`]}),i&&(0,W.jsxs)(`span`,{className:`ml-auto flex items-center gap-0.5 font-mono text-[9px] text-primary`,children:[(0,W.jsx)(S,{className:`size-2.5`}),` cursor boost`]})]}),(0,W.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:o.pageItems.map(e=>(0,W.jsx)(ot,{match:e,cursorBoosted:i&&(e.matchedVia===`anchor_symbol`||e.matchedVia===`scope_symbol`),pendingAction:a.pendingActionById.get(e.memory.id),...a},e.memory.id))}),(0,W.jsx)(N,{page:o.page,pageSize:o.pageSize,totalItems:o.totalItems,onPageChange:o.setPage,compact:!0,itemLabel:`memories`})]})}function st({filePath:e,lineStart:t,lineEnd:n,open:r,onClose:i,onShowMemory:a,onAcceptDeletion:o,onKeep:s,onUpdate:c,onMarkPermanent:u,onRecover:f}){let[m,h]=(0,U.useState)(!1),[g,_]=(0,U.useState)(new Map),{data:v,loading:y,error:ee,refetch:te}=it({filePath:e,lineStart:t,lineEnd:n,showDeleted:m,autoFetch:r}),ne=t!==void 0&&n!==void 0,b=(0,U.useCallback)(async(e,t,n)=>{if(n){_(n=>new Map(n).set(e,t));try{await n(e)}finally{_(t=>{let n=new Map(t);return n.delete(e),n})}}},[]);if((0,U.useEffect)(()=>{h(!1)},[e]),!r)return null;let x=v,C=x?.totalCount??0;return(0,W.jsxs)(`aside`,{className:`flex h-full min-h-0 w-full flex-col border-l border-border/70 bg-card/15`,"aria-label":`File memory drawer`,"data-file-path":e??``,children:[(0,W.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-border/60 px-3 py-2`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] uppercase tracking-wide text-muted-foreground`,children:[(0,W.jsx)(d,{className:`size-3`}),(0,W.jsx)(`span`,{className:`truncate font-mono`,title:e??``,children:e??`(no file)`})]}),(0,W.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,W.jsxs)(`span`,{className:`font-mono`,children:[C,` memories`]}),x&&x.reviewPendingCount>0&&(0,W.jsxs)(`span`,{className:`flex items-center gap-0.5 font-mono text-warning`,children:[(0,W.jsx)(re,{className:`size-3`}),x.reviewPendingCount,` pending review`]}),x&&x.supersededCount>0&&(0,W.jsxs)(`span`,{className:`font-mono`,children:[x.supersededCount,` superseded`]})]})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,W.jsx)(M,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>te(),disabled:y||!e,className:`h-7 w-7 p-0`,"aria-label":`Refresh`,title:`Re-query for this file`,children:(0,W.jsx)(de,{className:j(`size-3.5`,y&&`animate-spin`)})}),(0,W.jsx)(M,{type:`button`,size:`sm`,variant:`ghost`,onClick:i,className:`h-7 w-7 p-0`,"aria-label":`Close drawer`,title:`Close memory drawer`,children:(0,W.jsx)(O,{className:`size-3.5`})})]})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-border/40 bg-background/40 px-3 py-1.5 text-[10px] text-muted-foreground`,children:[(0,W.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:m,onChange:e=>h(e.target.checked),className:`size-3 accent-primary`,disabled:!e,"data-testid":`memory-drawer-show-deleted`}),m?(0,W.jsx)(p,{className:`size-3`}):(0,W.jsx)(l,{className:`size-3`}),(0,W.jsx)(`span`,{children:`Show recoverable (deleted)`})]}),ne&&(0,W.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 font-mono text-[10px] text-primary`,children:[(0,W.jsx)(S,{className:`size-3`}),` lines `,t,`–`,n]})]}),(0,W.jsx)(`div`,{className:`flex-1 overflow-y-auto px-3 py-3`,children:e?y&&!x?(0,W.jsx)(Y,{loading:!0,message:`Loading memories…`}):ee?(0,W.jsx)(Y,{tone:`error`,message:`Error: ${ee}`}):!x||C===0?(0,W.jsx)(Y,{message:`No memories attached to ${e} yet.`}):(0,W.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,W.jsx)(J,{icon:S,title:`Cursor boost`,count:x.symbolMatches.length,cursorBoosted:ne,matches:x.symbolMatches,pendingActionById:g,onShowMemory:a,onAcceptDeletion:(e,t)=>b(t,`accepting…`,()=>o?.(e,t)),onKeep:(e,t)=>b(t,`keeping…`,()=>s?.(e,t)),onUpdate:e=>b(e,`updating…`,()=>c?.(e)),onMarkPermanent:e=>b(e,`marking…`,()=>u?.(e)),onRecover:e=>b(e,`recovering…`,()=>f?.(e))}),(0,W.jsx)(J,{icon:d,title:`File-scoped`,count:x.primaryMatches.length,matches:x.primaryMatches,pendingActionById:g,onShowMemory:a,onAcceptDeletion:(e,t)=>b(t,`accepting…`,()=>o?.(e,t)),onKeep:(e,t)=>b(t,`keeping…`,()=>s?.(e,t)),onUpdate:e=>b(e,`updating…`,()=>c?.(e)),onMarkPermanent:e=>b(e,`marking…`,()=>u?.(e)),onRecover:e=>b(e,`recovering…`,()=>f?.(e))}),(0,W.jsx)(J,{icon:p,title:`Mentioned in`,count:x.relatedMatches.length,matches:x.relatedMatches,pendingActionById:g,onShowMemory:a,onAcceptDeletion:(e,t)=>b(t,`accepting…`,()=>o?.(e,t)),onKeep:(e,t)=>b(t,`keeping…`,()=>s?.(e,t)),onUpdate:e=>b(e,`updating…`,()=>c?.(e)),onMarkPermanent:e=>b(e,`marking…`,()=>u?.(e)),onRecover:e=>b(e,`recovering…`,()=>f?.(e))})]}):(0,W.jsx)(Y,{message:`Open a file to see its memories.`})})]})}function Y({message:e,loading:t=!1,tone:r=`default`}){return(0,W.jsxs)(`div`,{className:j(`flex min-h-[120px] flex-col items-center justify-center gap-2 rounded-md border border-dashed border-border/60 px-4 py-6 text-center text-[11px]`,r===`error`?`text-destructive`:`text-muted-foreground`),children:[t&&(0,W.jsx)(n,{className:`size-4 animate-spin`}),(0,W.jsx)(`p`,{children:e})]})}function ct({mode:e,draft:t,busy:r,error:i,onChange:o,onCancel:s,onSubmit:l}){let u=(0,U.useRef)(null);(0,U.useEffect)(()=>{u.current?.focus()},[]);let d=(e,n)=>{o({...t,[e]:n})},f=()=>{d(`anchors`,[...t.anchors,{type:`file`,path:``}])};return(0,W.jsxs)(`form`,{className:`flex min-h-0 flex-1 flex-col`,onSubmit:e=>{e.preventDefault(),l()},"aria-busy":r,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-border/70 bg-card/70 px-4 py-3 backdrop-blur-xl`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`flex size-8 items-center justify-center border border-info/35 bg-info/10 text-info`,children:e===`create`?(0,W.jsx)(c,{className:`size-4`}):(0,W.jsx)(T,{className:`size-4`})}),(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`p`,{className:`truncate text-sm font-bold`,children:e===`create`?`Capture a memory`:`Edit memory`}),(0,W.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:e===`create`?`Add durable knowledge with retrieval metadata.`:`Update content without losing provenance.`})]})]}),(0,W.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,W.jsxs)(M,{type:`button`,variant:`ghost`,size:`sm`,onClick:s,disabled:r,children:[(0,W.jsx)(oe,{className:`size-3.5`}),` Cancel`]}),(0,W.jsxs)(M,{type:`submit`,size:`sm`,disabled:r||!t.text.trim(),children:[r?(0,W.jsx)(n,{className:`size-3.5 animate-spin`}):e===`create`?(0,W.jsx)(x,{className:`size-3.5`}):(0,W.jsx)(_,{className:`size-3.5`}),r?`Saving…`:e===`create`?`Create memory`:`Save changes`]})]})]}),(0,W.jsx)(`div`,{className:`flex-1 overflow-y-auto overscroll-contain p-4 md:p-5`,children:(0,W.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-5`,children:[i&&(0,W.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-2 border border-destructive/40 bg-destructive/10 px-3 py-2.5 text-sm text-destructive`,children:[(0,W.jsx)(re,{className:`mt-0.5 size-4 shrink-0`}),(0,W.jsx)(`span`,{children:i})]}),(0,W.jsxs)(`section`,{className:`border border-border/75 bg-card/45 p-4`,children:[(0,W.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{className:`text-xs font-bold uppercase tracking-[0.14em]`,children:`Knowledge`}),(0,W.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:`Write the durable fact or decision in complete, searchable language.`})]}),(0,W.jsxs)(`span`,{className:`font-mono text-[10px] text-muted-foreground tabular-nums`,children:[t.text.length,` chars`]})]}),(0,W.jsx)(`label`,{htmlFor:`memory-text`,className:`sr-only`,children:`Memory content`}),(0,W.jsx)(`textarea`,{ref:u,id:`memory-text`,value:t.text,onChange:e=>d(`text`,e.target.value),rows:7,required:!0,placeholder:`Example: WebUI state is owned by Zustand stores; server messages update those stores through singleton WebSocket handlers.`,className:`min-h-36 w-full resize-y border border-input bg-background/75 px-3 py-3 text-sm leading-6 text-foreground shadow-inner placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`})]}),(0,W.jsxs)(`section`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`label`,{htmlFor:`memory-kind`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Kind`}),(0,W.jsx)(`select`,{id:`memory-kind`,value:t.kind,onChange:e=>d(`kind`,e.target.value),className:`h-10 w-full border border-input bg-background px-3 text-sm`,children:L.map(e=>(0,W.jsx)(`option`,{value:e,children:V[e]},e))})]}),e===`create`?(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`label`,{htmlFor:`memory-scope`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Scope`}),(0,W.jsx)(`select`,{id:`memory-scope`,value:t.scope,onChange:e=>d(`scope`,e.target.value),className:`h-10 w-full border border-input bg-background px-3 text-sm`,children:ke.map(e=>(0,W.jsx)(`option`,{value:e,children:e},e))})]}):(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`label`,{htmlFor:`memory-status`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Lifecycle status`}),(0,W.jsx)(`select`,{id:`memory-status`,value:t.status,onChange:e=>d(`status`,e.target.value),className:`h-10 w-full border border-input bg-background px-3 text-sm`,children:Pe.map(e=>(0,W.jsx)(`option`,{value:e,children:e},e))})]}),(0,W.jsxs)(`div`,{className:j(`min-w-0`,e===`create`?`sm:col-span-2 lg:col-span-1`:``),children:[(0,W.jsx)(`label`,{htmlFor:`memory-tags`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Tags`}),(0,W.jsx)(P,{id:`memory-tags`,value:t.tags,onChange:e=>d(`tags`,e.target.value),placeholder:`architecture, webui, workflow`,className:`h-10 bg-background`})]})]}),(0,W.jsxs)(`section`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,W.jsx)(F,{id:`memory-importance`,label:`Importance`,value:t.importance,onChange:e=>d(`importance`,e)}),(0,W.jsx)(F,{id:`memory-confidence`,label:`Confidence`,value:t.confidence,onChange:e=>d(`confidence`,e)}),(0,W.jsx)(F,{id:`memory-freshness`,label:`Freshness`,value:t.freshness,onChange:e=>d(`freshness`,e)})]}),(0,W.jsxs)(`section`,{className:`border border-border/75 bg-card/45 p-4`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{className:`text-xs font-bold uppercase tracking-[0.14em]`,children:`Anchors`}),(0,W.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:`Bind knowledge to files, symbols, packages, tests, Git paths, or commands.`})]}),(0,W.jsxs)(M,{type:`button`,variant:`outline`,size:`sm`,onClick:f,children:[(0,W.jsx)(x,{className:`size-3.5`}),` Add anchor`]})]}),t.anchors.length===0?(0,W.jsxs)(`button`,{type:`button`,onClick:f,className:`mt-4 flex w-full items-center justify-center gap-2 border border-dashed border-border px-4 py-7 text-xs text-muted-foreground transition-colors hover:border-info/50 hover:bg-info/5 hover:text-info`,children:[(0,W.jsx)(ce,{className:`size-4`}),` No anchors yet — add one to improve retrieval precision`]}):(0,W.jsx)(`div`,{className:`mt-4 space-y-2`,children:t.anchors.map((e,n)=>(0,W.jsxs)(`div`,{className:`grid gap-2 border border-border/65 bg-background/40 p-2 sm:grid-cols-[9rem_minmax(0,1fr)_auto]`,children:[(0,W.jsxs)(`label`,{className:`sr-only`,htmlFor:`anchor-type-${n}`,children:[`Anchor `,n+1,` type`]}),(0,W.jsx)(`select`,{id:`anchor-type-${n}`,value:e.type,onChange:e=>{let r=e.target.value,i=r===`command`?{type:r,command:``}:{type:r,path:``},a=t.anchors.map((e,t)=>t===n?i:e);d(`anchors`,a)},className:`h-10 border border-input bg-background px-2 text-xs`,children:Le.map(e=>(0,W.jsx)(`option`,{value:e,children:e},e))}),(0,W.jsxs)(`div`,{className:j(`grid min-w-0 gap-2`,e.type===`symbol`&&`sm:grid-cols-[minmax(0,1fr)_11rem]`),children:[(0,W.jsxs)(`label`,{className:`sr-only`,htmlFor:`anchor-value-${n}`,children:[`Anchor `,n+1,` value`]}),(0,W.jsx)(P,{id:`anchor-value-${n}`,value:Re(e),onChange:e=>{let r=t.anchors.map((t,r)=>r===n?Ae(t,e.target.value):t);d(`anchors`,r)},placeholder:e.type===`command`?`pnpm test --filter webui`:`packages/webui/src/App.tsx`,className:`h-10 min-w-0 bg-background font-mono text-xs`}),e.type===`symbol`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`label`,{className:`sr-only`,htmlFor:`anchor-symbol-${n}`,children:[`Anchor `,n+1,` symbol`]}),(0,W.jsx)(P,{id:`anchor-symbol-${n}`,value:e.symbol??``,onChange:e=>{let r=t.anchors.map((t,r)=>r===n?{...t,symbol:e.target.value}:t);d(`anchors`,r)},placeholder:`Symbol name`,className:`h-10 bg-background font-mono text-xs`})]})]}),(0,W.jsx)(M,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Remove anchor ${n+1}`,onClick:()=>d(`anchors`,t.anchors.filter((e,t)=>t!==n)),children:(0,W.jsx)(a,{className:`size-4 text-destructive`})})]},`${e.type}:${n}`))})]}),(0,W.jsxs)(`section`,{className:`grid gap-3 border border-border/75 bg-card/45 p-4 sm:grid-cols-2`,children:[(0,W.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,W.jsx)(`h3`,{className:`text-xs font-bold uppercase tracking-[0.14em]`,children:`Relationships`}),(0,W.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:`Reference exact memory IDs. Relationships are validated and graph edges are rebuilt by Super Memory.`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{htmlFor:`memory-supersedes`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Supersedes`}),(0,W.jsx)(P,{id:`memory-supersedes`,value:t.supersedes,onChange:e=>d(`supersedes`,e.target.value),placeholder:`mem_id, mem_id`,className:`h-10 bg-background font-mono text-xs`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{htmlFor:`memory-contradicts`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Contradicts`}),(0,W.jsx)(P,{id:`memory-contradicts`,value:t.contradicts,onChange:e=>d(`contradicts`,e.target.value),placeholder:`mem_id, mem_id`,className:`h-10 bg-background font-mono text-xs`})]})]}),(0,W.jsxs)(`section`,{className:`space-y-2`,children:[(0,W.jsx)(`h3`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Audience (Optional)`}),(0,W.jsx)(`p`,{className:`text-[10px] text-muted-foreground/70`,children:`Target this memory to specific agent types. Leave empty for general project memory.`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{htmlFor:`memory-audience-roles`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Roles`}),(0,W.jsx)(P,{id:`memory-audience-roles`,value:t.audienceRoles,onChange:e=>d(`audienceRoles`,e.target.value),placeholder:`reviewer, refactor-planner`,className:`h-9 bg-background font-mono text-xs`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{htmlFor:`memory-audience-task-types`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Task types`}),(0,W.jsx)(P,{id:`memory-audience-task-types`,value:t.audienceTaskTypes,onChange:e=>d(`audienceTaskTypes`,e.target.value),placeholder:`review, refactor, bugfix`,className:`h-9 bg-background font-mono text-xs`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{htmlFor:`memory-audience-modes`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Modes`}),(0,W.jsx)(P,{id:`memory-audience-modes`,value:t.audienceModes,onChange:e=>d(`audienceModes`,e.target.value),placeholder:`teach, code-review`,className:`h-9 bg-background font-mono text-xs`})]})]})]})})]})}function lt({searchQuery:e,statusFilter:n,kindFilter:r,audienceOnly:i,tagFilter:a,hasFilters:s,allTags:c,stats:l,onSearchChange:u,onStatusFilterChange:d,onKindFilterChange:f,onToggleAudienceOnly:p,onTagFilterChange:m,onClearFilters:h}){return(0,W.jsxs)(`div`,{className:`shrink-0 space-y-2 overflow-hidden border-b border-border/70 bg-card/45 p-3`,children:[(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,W.jsx)(le,{className:`pointer-events-none absolute left-3 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,W.jsx)(P,{"aria-label":`Search memories`,value:e,onChange:e=>u(e.target.value),placeholder:`Search content, IDs, tags, anchors…`,className:`h-10 min-w-0 bg-background pl-9 pr-8 text-xs`}),e&&(0,W.jsx)(`button`,{type:`button`,"aria-label":`Clear search`,onClick:()=>u(``),className:`absolute right-2 top-1/2 -translate-y-1/2 p-1 text-muted-foreground hover:text-foreground`,children:(0,W.jsx)(oe,{className:`size-3.5`})})]}),(0,W.jsx)(M,{variant:i?`default`:`ghost`,size:`icon`,onClick:p,"aria-label":`Filter audience-scoped only`,title:`Show only audience-scoped memories`,className:`shrink-0`,children:(0,W.jsx)(t,{className:`size-4`})}),s&&(0,W.jsx)(M,{variant:`ghost`,size:`icon`,onClick:h,"aria-label":`Clear all filters`,title:`Clear all filters`,children:(0,W.jsx)(te,{className:`size-4`})})]}),(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsx)(`label`,{className:`sr-only`,htmlFor:`memory-status-filter`,children:`Filter by status`}),(0,W.jsxs)(`select`,{id:`memory-status-filter`,value:n,onChange:e=>d(e.target.value),className:`h-9 min-w-0 border border-input bg-background px-2 text-xs`,children:[(0,W.jsx)(`option`,{value:`all`,children:`All statuses`}),B.map(e=>(0,W.jsxs)(`option`,{value:e,children:[e,` · `,l?.byStatus[e]??0]},e))]}),(0,W.jsx)(`label`,{className:`sr-only`,htmlFor:`memory-kind-filter`,children:`Filter by kind`}),(0,W.jsxs)(`select`,{id:`memory-kind-filter`,value:r,onChange:e=>f(e.target.value),className:`h-9 min-w-0 border border-input bg-background px-2 text-xs`,children:[(0,W.jsx)(`option`,{value:`all`,children:`All kinds`}),L.map(e=>(0,W.jsxs)(`option`,{value:e,children:[V[e],` · `,l?.byKind[e]??0]},e))]})]}),c.length>0&&(0,W.jsxs)(`fieldset`,{className:`min-w-0 border-0 p-0`,children:[(0,W.jsx)(`legend`,{className:`sr-only`,children:`Popular tags`}),(0,W.jsx)(`div`,{className:`no-scrollbar flex gap-1.5 overflow-x-auto pb-0.5`,children:c.slice(0,18).map(([e,t])=>(0,W.jsxs)(`button`,{type:`button`,"aria-pressed":a===e,onClick:()=>m(a===e?null:e),className:j(`flex shrink-0 items-center gap-1 border px-2 py-1 text-[10px] transition-colors`,a===e?`border-info/55 bg-info/10 text-info`:`border-border/70 bg-background/45 text-muted-foreground hover:border-info/35 hover:text-foreground`),children:[(0,W.jsx)(o,{className:`size-2.5`}),` `,e,(0,W.jsx)(`span`,{className:`font-mono opacity-60`,children:t})]},e))})]})]})}function ut(){let e=A(e=>e.traces[0]),t=A(e=>e.contextMemories),n=A(e=>e.clear),r=Object.values(t),i=r.filter(e=>e.state!==`exited`).length,o=r.filter(e=>e.state===`exited`).length,s=e?Object.values(e.rejected).reduce((e,t)=>e+t,0):0;return(0,W.jsx)(`section`,{className:`shrink-0 border-b border-border/70 bg-violet-500/[0.035]`,"aria-label":`Memory Injector summary`,children:(0,W.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-4 text-[10px]`,children:[(0,W.jsx)(v,{className:`size-3.5 text-violet-400`}),(0,W.jsx)(`span`,{className:`font-bold uppercase tracking-wide text-violet-300`,children:`Memory context`}),e?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`span`,{className:`font-mono text-foreground`,children:[e.candidates,` matched`]}),(0,W.jsxs)(`span`,{className:`font-mono text-success`,children:[e.injected.length,` injected`]}),(0,W.jsxs)(`span`,{className:`font-mono text-warning`,children:[s,` filtered`]}),(0,W.jsxs)(`span`,{className:`font-mono text-sky-300`,children:[i,` active`]}),o>0&&(0,W.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[o,` left`]}),(0,W.jsxs)(`span`,{className:`ml-auto text-muted-foreground`,children:[e.trigger,` · ctx `,Math.round(e.contextPressure*100),`% · details in Context`]}),(0,W.jsxs)(M,{type:`button`,variant:`ghost`,size:`sm`,className:`h-6 px-2 text-[10px]`,onClick:n,children:[(0,W.jsx)(a,{className:`size-3`}),` Clear`]})]}):(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`waiting · details in Context`})]})})}var X=100;function dt({memoryListRef:e,memories:t,filteredMemories:n,selectedId:r,onSelectMemory:i,onOpenCreate:a,onClearFilters:o}){let s=n.length>X,c=k({count:n.length,getScrollElement:()=>e.current,estimateSize:()=>100,overscan:8,enabled:s});return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-border/60 px-3 py-2 text-[10px] text-muted-foreground`,children:[(0,W.jsxs)(`span`,{children:[n.length,` of `,t.length,` memories`]}),(0,W.jsx)(`span`,{className:`font-mono uppercase`,children:`updated ↓`})]}),(0,W.jsx)(`section`,{ref:e,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,"aria-label":`Memories`,children:n.length===0?(0,W.jsx)(ft,{hasMemories:t.length>0,onOpenCreate:a,onClearFilters:o}):s?(0,W.jsx)(`div`,{style:{height:`${c.getTotalSize()}px`,width:`100%`,position:`relative`},children:c.getVirtualItems().map(e=>{let t=n[e.index];return t?(0,W.jsx)(`div`,{"data-index":e.index,ref:c.measureElement,style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${e.start}px)`},children:(0,W.jsx)(Z,{memory:t,isSelected:r===t.id,onClick:()=>i(t.id)})},t.id):null})}):n.map(e=>(0,W.jsx)(Z,{memory:e,isSelected:r===e.id,onClick:()=>i(e.id)},e.id))})]})}function ft({hasMemories:e,onOpenCreate:t,onClearFilters:n}){return(0,W.jsxs)(`div`,{className:`flex min-h-64 flex-col items-center justify-center px-6 text-center`,children:[(0,W.jsx)(`span`,{className:`flex size-12 items-center justify-center border border-dashed border-border text-muted-foreground`,children:(0,W.jsx)(g,{className:`size-5`})}),(0,W.jsx)(`h2`,{className:`mt-4 text-sm font-bold`,children:e?`No matching memories`:`Build your memory graph`}),(0,W.jsx)(`p`,{className:`mt-1 max-w-xs text-xs leading-5 text-muted-foreground`,children:e?`Change the filters or clear the search query.`:`Capture durable facts, decisions, conventions, and file-bound notes for every agent.`}),(0,W.jsxs)(M,{className:`mt-4`,variant:`outline`,size:`sm`,onClick:e?n:t,children:[e?(0,W.jsx)(te,{className:`size-3.5`}):(0,W.jsx)(x,{className:`size-3.5`}),e?`Clear filters`:`Create first memory`]})]})}function Z({memory:e,isSelected:n,onClick:r}){return(0,W.jsxs)(`button`,{type:`button`,"aria-current":n?`true`:void 0,onClick:r,className:j(`group relative block w-full border-b border-border/55 px-3 py-3 text-left transition-[background-color,border-color] hover:bg-info/5`,n&&`bg-info/8`),children:[n&&(0,W.jsx)(`span`,{className:`absolute inset-y-0 left-0 w-0.5 bg-info shadow-[0_0_10px_hsl(var(--info)/0.7)]`}),(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.jsx)(`span`,{className:j(`truncate text-[10px] font-bold uppercase tracking-[0.1em]`,I(e.kind)),children:V[e.kind]??e.kind}),(0,W.jsx)(R,{status:e.status}),(0,W.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono text-[9px] text-muted-foreground`,children:[`r`,e.revision]})]}),(0,W.jsx)(`p`,{className:j(`mt-2 line-clamp-2 text-xs leading-5 text-foreground/90`,e.status===`deleted`&&`line-through opacity-60`),children:Ne(e.text)}),(0,W.jsxs)(`div`,{className:`mt-2 flex min-w-0 items-center gap-1.5`,children:[(0,W.jsx)(`span`,{className:`border border-border/60 bg-background/50 px-1.5 py-0.5 font-mono text-[9px] uppercase text-muted-foreground`,children:e.scope}),e.audience&&(0,W.jsxs)(`span`,{className:`flex items-center gap-0.5 border border-primary/30 bg-primary/10 px-1.5 py-0.5 font-mono text-[9px] text-primary`,children:[(0,W.jsx)(t,{className:`size-2.5`}),(e.audience.roles??e.audience.taskTypes??e.audience.modes??[]).slice(0,1)[0]??`scoped`]}),e.tags.slice(0,2).map(e=>(0,W.jsxs)(`span`,{className:`max-w-24 truncate border border-border/60 px-1.5 py-0.5 font-mono text-[9px] text-muted-foreground`,children:[`#`,e]},e)),e.tags.length>2&&(0,W.jsxs)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:[`+`,e.tags.length-2]}),(0,W.jsx)(`span`,{className:`ml-auto shrink-0 text-[9px] text-muted-foreground`,children:ze(e.updatedAt)}),(0,W.jsx)(he,{className:`size-3 shrink-0 text-muted-foreground transition-transform group-hover:translate-x-0.5 group-hover:text-info`})]})]})}function pt(){let{client:e,listSuperMemoriesPage:r,rememberSuperMemory:i,updateSuperMemory:o,deleteSuperMemory:s,getSuperMemoryGraph:c,recoverSuperMemory:l,resolveMemoryCandidate:u}=_e(),d=ye(e=>e.wsConnected),f=ge(e=>e.setCurrentView),p=De(`memory`),[h,g]=(0,U.useState)([]),[_,v]=(0,U.useState)(null),[y,te]=(0,U.useState)(!0),[ne,b]=(0,U.useState)(!1),[S,C]=(0,U.useState)(null),[w,T]=(0,U.useState)(null),[E,D]=(0,U.useState)(null),[O,k]=(0,U.useState)(null),[ae,oe]=(0,U.useState)([]),[se,ce]=(0,U.useState)([]),[le,ue]=(0,U.useState)(null),[fe,pe]=(0,U.useState)(!1),[he,A]=(0,U.useState)(!1),[ve,N]=(0,U.useState)(!1),[P,Ee]=(0,U.useState)(Me),[ke,Ae]=(0,U.useState)(Me),[F,I]=(0,U.useState)(null),[L,R]=(0,U.useState)(null),[z,Pe]=(0,U.useState)(``),[B,Fe]=(0,U.useState)(`all`),[V,Le]=(0,U.useState)(`all`),[Re,ze]=(0,U.useState)(!1),[G,Be]=(0,U.useState)(null),[K,Ve]=(0,U.useState)(!1),[He,Ue]=(0,U.useState)(null),[We,Ge]=(0,U.useState)(!1),[Ke,qe]=(0,U.useState)(!1),[Je,Xe]=(0,U.useState)({}),[Ze,Qe]=(0,U.useState)(!1),[$e,et]=(0,U.useState)(null),[tt,nt]=(0,U.useState)(void 0),[rt,it]=(0,U.useState)(void 0),at=(0,U.useRef)(!1),q=(0,U.useRef)(!0),ot=(0,U.useRef)(0),J=(0,U.useRef)(0),Y=(0,U.useRef)(null),X=(0,U.useRef)(null),ft=(0,U.useMemo)(()=>JSON.stringify(P)!==JSON.stringify(ke),[ke,P]),Z=(0,U.useMemo)(()=>h.find(e=>e.id===O)??null,[h,O]),pt=(0,U.useCallback)(t=>{let n=t!==null,i=++ot.current;Y.current?.(),C(null),n?qe(!0):(b(!0),at.current||te(!0));let a=()=>{},o=null,s=!1,c=()=>{s||(s=!0,o!==null&&clearTimeout(o),a(),Y.current===c&&(Y.current=null))};a=e.on(`memory.super.listPage`,e=>{if(i!==ot.current||!q.current){c();return}if(c(),e.payload.error)C(e.payload.error);else{let t=e.payload.memories??[];g(e=>n?[...e,...t]:t),Ue(e.payload.nextCursor??null),Ge(!!e.payload.nextCursor);let r=e.payload.statusCounts??{};Xe(r);let i=Object.values(r).reduce((e,t)=>e+t,0);e.payload.stats?v(e.payload.stats):v(e=>({total:i,byStatus:r,byKind:e?.byKind??{},edges:e?.edges??0})),at.current=!0,n||k(e=>e&&t.some(t=>t.id===e)?e:null)}te(!1),b(!1),qe(!1)}),o=setTimeout(()=>{i!==ot.current||!q.current||(c(),C(`The memory store did not respond. Check the WebSocket connection and try again.`),te(!1),b(!1),qe(!1))},2e4),Y.current=c,r({limit:100,...K?{statuses:[`deleted`]}:{},...t?{cursor:t}:{}},{echoToChat:!1})},[e,r,K]),Q=(0,U.useCallback)(()=>{Ue(null),Ge(!1),pt(null)},[pt]),ht=(0,U.useCallback)(()=>{Ke||!He||pt(He)},[pt,Ke,He]);(0,U.useEffect)(()=>(q.current=!0,Q(),()=>{q.current=!1,ot.current+=1,J.current+=1,Y.current?.(),X.current?.()}),[Q]),(0,U.useEffect)(()=>{if(oe([]),ce([]),ue(null),!O){pe(!1);return}let t=O;pe(!0);let n=null,r=e.on(`memory.super.graph`,e=>{e.payload.query===t&&(n!==null&&clearTimeout(n),oe(e.payload.edges??[]),ce(e.payload.memories??[]),ue(e.payload.error??null),pe(!1))});return n=setTimeout(()=>{ue(`Relationship graph did not respond in time.`),pe(!1)},15e3),c(t,{maxDepth:1,limit:120},{echoToChat:!1}),()=>{n!==null&&clearTimeout(n),r()}},[e,c,O]);let gt=(0,U.useRef)(d);(0,U.useEffect)(()=>{d&&!gt.current&&at.current&&Q(),gt.current=d},[Q,d]),(0,U.useEffect)(()=>{if(!E)return;let e=setTimeout(()=>D(null),4e3);return()=>clearTimeout(e)},[E]);let _t=(0,U.useCallback)(()=>!ft||!he&&!ve||window.confirm(`Discard the unsaved memory changes?`),[ve,ft,he]),vt=(0,U.useCallback)(()=>{if(!_t())return;let e=Me();Ee(e),Ae(e),N(!0),A(!1),k(null),T(null)},[_t]),yt=(0,U.useCallback)(e=>{_t()&&(k(e),N(!1),A(!1),T(null))},[_t]),bt=(0,U.useCallback)(()=>{if(!Z||Z.status===`deleted`)return;let e=je(Z);Ee(e),Ae(e),A(!0),N(!1),T(null)},[Z]),xt=(0,U.useCallback)(()=>{_t()&&(A(!1),N(!1),T(null))},[_t]),St=(0,U.useCallback)((t,n,r)=>{if(!P.text.trim()){T(`Memory content is required.`);return}let i=++J.current;X.current?.(),I(r),T(null),D(null);let a=()=>{},o=null,s=!1,c=()=>{s||(s=!0,o!==null&&clearTimeout(o),a(),X.current===c&&(X.current=null))},l=e=>{if(i!==J.current||!q.current){c();return}if(c(),I(null),e.payload.error||!e.payload.memory){T(e.payload.error??`The server returned no memory record.`);return}let t=e.payload.memory;g(e=>{let n=e.filter(e=>e.id!==t.id);return[t,...n]}),k(t.id),N(!1),A(!1),D(r===`create`?`Memory captured.`:`Memory updated.`),Q()};a=t===`memory.super.remember`?e.on(`memory.super.remember`,l):e.on(`memory.super.update`,l),o=setTimeout(()=>{i!==J.current||!q.current||(c(),I(null),T(`${r===`create`?`Create`:`Save`} timed out. Your draft is still here.`))},2e4),X.current=c,n()},[e,P.text,Q]),Ct=(0,U.useCallback)(()=>{St(`memory.super.remember`,()=>i({text:P.text.trim(),kind:P.kind,scope:P.scope,tags:H(P.tags),importance:P.importance,confidence:P.confidence,freshness:P.freshness,anchors:Oe(P.anchors),...H(P.audienceRoles).length||H(P.audienceTaskTypes).length||H(P.audienceModes).length?{audience:{roles:H(P.audienceRoles),taskTypes:H(P.audienceTaskTypes),modes:H(P.audienceModes)}}:{},supersedes:H(P.supersedes),contradicts:H(P.contradicts)},{echoToChat:!1}),`create`)},[P,i,St]),wt=(0,U.useCallback)(()=>{Z&&St(`memory.super.update`,()=>o(Z.id,{text:P.text.trim(),kind:P.kind,status:P.status,tags:H(P.tags),importance:P.importance,confidence:P.confidence,freshness:P.freshness,anchors:Oe(P.anchors),...H(P.audienceRoles).length||H(P.audienceTaskTypes).length||H(P.audienceModes).length?{audience:{roles:H(P.audienceRoles),taskTypes:H(P.audienceTaskTypes),modes:H(P.audienceModes)}}:{},supersedes:H(P.supersedes),contradicts:H(P.contradicts)},{echoToChat:!1}),`update`)},[P,St,Z,o]),Tt=(0,U.useCallback)(()=>{if(!L)return;let t=++J.current;X.current?.(),I(`delete`),T(null);let n=()=>{},r=null,i=!1,a=()=>{i||(i=!0,r!==null&&clearTimeout(r),n(),X.current===a&&(X.current=null))};n=e.on(`memory.super.delete`,e=>{if(t!==J.current||!q.current){a();return}if(a(),I(null),!e.payload.success){T(e.payload.message||`Delete failed.`);return}R(null),k(null),A(!1),D(`Memory deleted and relationship edges cleaned up.`),Q()}),r=setTimeout(()=>{t!==J.current||!q.current||(a(),I(null),T(`Delete timed out. The memory may still exist; refresh to confirm.`))},2e4),X.current=a,s(L,`Deleted from the WebUI Memory Manager.`)},[e,s,L,Q]),Et=(0,U.useMemo)(()=>{let e=z.trim().toLowerCase();return h.filter(t=>{if(B!==`all`&&t.status!==B||V!==`all`&&t.kind!==V||G&&!t.tags.includes(G)||Re&&!t.audience)return!1;if(!e)return!0;let n=t.anchors.map(e=>[e.path,e.symbol,e.command].filter(Boolean).join(` `)).join(` `),r=t.audience?[t.audience.roles?.join(` `)??``,t.audience.taskTypes?.join(` `)??``,t.audience.modes?.join(` `)??``].join(` `):``;return[t.id,t.text,t.summary??``,t.kind,t.scope,t.tags.join(` `),n,r].join(` `).toLowerCase().includes(e)})},[Re,V,h,z,B,G]),Dt=(0,U.useMemo)(()=>{let e=new Map;for(let t of h)for(let n of t.tags)e.set(n,(e.get(n)??0)+1);return[...e.entries()].sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0]))},[h]),Ot=(0,U.useMemo)(()=>{if(!Z)return[];let e=[];Z.supersededBy&&e.push({relation:`Superseded by`,id:Z.supersededBy});for(let t of Z.supersedes??[])e.push({relation:`Supersedes`,id:t});for(let t of Z.contradicts??[])e.push({relation:`Contradicts`,id:t});return e},[Z]),kt=(0,U.useCallback)(()=>{Pe(``),Fe(`all`),Le(`all`),ze(!1),Be(null)},[]),At=!!(z||B!==`all`||V!==`all`||G||Re),jt=ve||!!Z,$=Ze&&!!$e;return y&&h.length===0?(0,W.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-background`,"aria-busy":`true`,children:[(0,W.jsxs)(`div`,{className:`border-b border-border/70 bg-card/70 px-5 py-4`,children:[(0,W.jsx)(`div`,{className:`h-3 w-28 animate-pulse bg-muted`}),(0,W.jsx)(`div`,{className:`mt-3 h-7 w-56 animate-pulse bg-muted`})]}),(0,W.jsxs)(`div`,{className:`grid flex-1 gap-px bg-border/60 md:grid-cols-[minmax(300px,0.82fr)_minmax(0,1.35fr)]`,children:[(0,W.jsx)(`div`,{className:`space-y-px bg-background p-4`,children:Array.from({length:7},(e,t)=>(0,W.jsx)(`div`,{className:`h-24 animate-pulse border border-border/60 bg-card/45`},t))}),(0,W.jsx)(`div`,{className:`hidden bg-background p-6 md:block`,children:(0,W.jsx)(`div`,{className:`h-full animate-pulse border border-border/60 bg-card/35`})})]}),(0,W.jsx)(`span`,{className:`sr-only`,role:`status`,children:`Loading Super Memory content`})]}):S&&h.length===0?(0,W.jsx)(`div`,{className:`flex h-full min-h-0 items-center justify-center bg-background p-6`,children:(0,W.jsxs)(`div`,{className:`max-w-md border border-destructive/35 bg-card p-6 shadow-2xl`,children:[(0,W.jsx)(`span`,{className:`flex size-11 items-center justify-center border border-destructive/35 bg-destructive/10 text-destructive`,children:(0,W.jsx)(re,{className:`size-5`})}),(0,W.jsx)(`h2`,{className:`mt-4 text-lg font-bold`,children:`Memory store unavailable`}),(0,W.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-muted-foreground`,children:S}),(0,W.jsxs)(`div`,{className:`mt-5 flex gap-2`,children:[(0,W.jsxs)(M,{onClick:Q,children:[(0,W.jsx)(de,{className:`size-4`}),` Retry`]}),(0,W.jsxs)(M,{variant:`outline`,onClick:()=>f(`chat`),children:[(0,W.jsx)(m,{className:`size-4`}),` Back to chat`]})]})]})}):(0,W.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-background`,children:[(0,W.jsxs)(`header`,{className:`relative shrink-0 overflow-hidden border-b border-border/70 bg-card/72 px-4 py-3 backdrop-blur-xl sm:px-5`,children:[(0,W.jsx)(`div`,{className:`pointer-events-none absolute inset-y-0 right-0 w-1/2 bg-[radial-gradient(circle_at_right,hsl(var(--info)/0.11),transparent_68%)]`}),(0,W.jsxs)(`div`,{className:`relative flex flex-wrap items-center gap-3`,children:[(0,W.jsx)(M,{variant:`ghost`,size:`icon`,onClick:()=>f(`chat`),"aria-label":`Back to chat`,title:`Back to chat`,children:(0,W.jsx)(m,{className:`size-4`})}),(0,W.jsx)(`span`,{className:`flex size-10 items-center justify-center border border-info/40 bg-info/10 text-info shadow-[0_0_20px_hsl(var(--info)/0.12)]`,children:(0,W.jsx)(t,{className:`size-5`})}),(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`h1`,{className:`text-base font-bold sm:text-lg`,children:`Super Memory`}),(0,W.jsx)(`span`,{className:`border border-success/35 bg-success/10 px-2 py-0.5 font-mono text-[9px] font-bold uppercase text-success`,children:`project knowledge`})]}),(0,W.jsx)(`p`,{className:`mt-0.5 max-w-2xl text-[10px] text-muted-foreground sm:text-xs`,children:`Inspect, connect, curate, and retire durable context used across agent sessions.`})]}),(0,W.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,W.jsxs)(`span`,{className:j(`hidden items-center gap-1.5 border px-2 py-1 font-mono text-[9px] uppercase sm:flex`,d?`border-success/30 text-success`:`border-warning/30 text-warning`),children:[(0,W.jsx)(`span`,{className:`size-1.5 bg-current`}),` `,d?`live store`:`reconnecting`]}),(0,W.jsxs)(M,{variant:`outline`,size:`sm`,onClick:Q,disabled:ne,"aria-label":`Refresh memories`,children:[(0,W.jsx)(de,{className:j(`size-3.5`,ne&&`animate-spin`)}),(0,W.jsx)(`span`,{className:`hidden sm:inline`,children:`Refresh`})]}),(0,W.jsxs)(M,{size:`sm`,onClick:vt,children:[(0,W.jsx)(x,{className:`size-3.5`}),` New memory`]})]})]})]}),(0,W.jsxs)(`div`,{className:`grid shrink-0 grid-cols-2 gap-px border-b border-border/70 bg-border/60 sm:grid-cols-4`,children:[(0,W.jsx)(Ie,{label:`Memories`,value:_?.total??h.length,hint:`${Et.length} visible`}),(0,W.jsx)(Ie,{label:`Active`,value:_?.byStatus.active??h.filter(e=>e.status===`active`).length,hint:`retrievable`,tone:`success`}),(0,W.jsx)(Ie,{label:`Needs review`,value:(_?.byStatus.stale??0)+(_?.byStatus.contradicted??0),hint:`stale + conflicts`,tone:`warning`}),(0,W.jsx)(`div`,{className:`hidden sm:block`,children:(0,W.jsx)(Ie,{label:`Graph edges`,value:_?.edges??0,hint:`${Dt.length} tags`,tone:`info`})})]}),(0,W.jsx)(ut,{}),(()=>{let e=h.filter(e=>e.audience).length;if(e===0)return null;let n=new Set;for(let e of h)if(e.audience){for(let t of e.audience.roles??[])n.add(t);for(let t of e.audience.taskTypes??[])n.add(t);for(let t of e.audience.modes??[])n.add(t)}return(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-border/70 bg-primary/5 px-4 py-1.5`,children:[(0,W.jsx)(t,{className:`size-3.5 text-primary`}),(0,W.jsxs)(`span`,{className:`text-[11px] font-medium text-primary`,children:[e,` audience-scoped memory`,e===1?``:`ies`]}),n.size>0&&(0,W.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`(`,[...n].sort().join(`, `),`)`]})]})})(),(E||S||w)&&(0,W.jsxs)(`div`,{className:`shrink-0 border-b border-border/70 px-4 py-2`,"aria-live":`polite`,children:[E&&(0,W.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2 text-xs text-success`,children:[(0,W.jsx)(me,{className:`size-3.5`}),` `,E]}),S&&(0,W.jsxs)(`div`,{role:`alert`,className:`flex items-center gap-2 text-xs text-warning`,children:[(0,W.jsx)(re,{className:`size-3.5`}),` `,S,` Existing content remains available.`]}),w&&!he&&!ve&&(0,W.jsxs)(`div`,{role:`alert`,className:`flex items-center gap-2 text-xs text-destructive`,children:[(0,W.jsx)(re,{className:`size-3.5`}),` `,w]})]}),(0,W.jsxs)(`div`,{className:`grid min-h-0 flex-1 md:grid-cols-[minmax(320px,0.82fr)_minmax(0,1.35fr)]`,children:[(0,W.jsxs)(`section`,{className:j(`min-h-0 border-r border-border/70 bg-card/25`,jt?`hidden md:flex md:flex-col`:`flex flex-col`),"aria-label":`Memory library`,children:[(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-border/60 px-3 py-1.5`,children:[(0,W.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:`File drawer`}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsxs)(`select`,{value:$e??``,onChange:e=>{let t=e.target.value||null;et(t),t&&Qe(!0)},className:`max-w-[180px] truncate rounded-sm border border-border/60 bg-background px-1.5 py-0.5 text-[10px] font-mono`,"aria-label":`File for memory drawer`,"data-testid":`memory-drawer-file-select`,children:[(0,W.jsx)(`option`,{value:``,children:`— select a file —`}),h.flatMap(e=>e.anchors??[]).filter(e=>e.type===`file`&&e.path).map((e,t)=>(0,W.jsx)(`option`,{value:e.path,children:e.path},`${e.path}-${t}`))]}),(0,W.jsxs)(M,{type:`button`,size:`sm`,variant:$?`default`:`outline`,onClick:()=>{$e&&Qe(e=>!e)},disabled:!$e,className:`h-7 gap-1 px-2 text-[11px]`,"aria-pressed":$,title:$?`Hide file memory drawer`:`Show file memory drawer`,children:[$?(0,W.jsx)(ie,{className:`size-3`}):(0,W.jsx)(ee,{className:`size-3`}),$?`Hide`:`Show`,` drawer`]})]})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 border-b border-border/60 px-3 pt-1`,role:`tablist`,"aria-label":`Memory view`,children:[(0,W.jsx)(M,{type:`button`,variant:`ghost`,size:`sm`,role:`tab`,"aria-selected":!K,onClick:()=>{K&&Ve(!1)},className:j(`h-7 rounded-b-none border-b-2 px-3 text-[11px]`,K?`border-transparent text-muted-foreground`:`border-primary text-foreground`),children:`Active`}),(0,W.jsxs)(M,{type:`button`,variant:`ghost`,size:`sm`,role:`tab`,"aria-selected":K,onClick:()=>{K||Ve(!0)},className:j(`h-7 rounded-b-none border-b-2 px-3 text-[11px]`,K?`border-primary text-foreground`:`border-transparent text-muted-foreground`),children:[`Deleted`,typeof Je.deleted==`number`?` (${Je.deleted})`:``]})]}),(0,W.jsx)(lt,{searchQuery:z,statusFilter:B,kindFilter:V,audienceOnly:Re,tagFilter:G,hasFilters:At,allTags:Dt,stats:_,onSearchChange:Pe,onStatusFilterChange:Fe,onKindFilterChange:Le,onToggleAudienceOnly:()=>ze(e=>!e),onTagFilterChange:Be,onClearFilters:kt}),(0,W.jsx)(dt,{memoryListRef:p,memories:h,filteredMemories:Et,selectedId:O,onSelectMemory:yt,onOpenCreate:vt,onClearFilters:kt}),We?(0,W.jsx)(`div`,{className:`shrink-0 border-t border-border/60 p-2`,children:(0,W.jsx)(M,{type:`button`,variant:`outline`,size:`sm`,onClick:ht,disabled:Ke,className:`h-7 w-full text-[11px]`,children:Ke?`Loading…`:`Load more (${h.length} loaded)`})}):null]}),(0,W.jsx)(`section`,{className:j(`min-h-0 bg-background`,jt?`flex flex-col`:`hidden md:flex md:flex-col`),"aria-label":`Memory detail`,children:ve?(0,W.jsx)(ct,{mode:`create`,draft:P,busy:F===`create`,error:w,onChange:Ee,onCancel:xt,onSubmit:Ct}):Z?he?(0,W.jsx)(ct,{mode:`edit`,draft:P,busy:F===`update`,error:w,onChange:Ee,onCancel:xt,onSubmit:wt}):$?(0,W.jsx)(st,{filePath:$e,lineStart:tt,lineEnd:rt,open:$,onClose:()=>Qe(!1),onShowMemory:e=>k(e),onAcceptDeletion:async(e,t)=>{u({candidateId:e,action:`accept`}),D(`Accepted hygiene review for ${t.slice(0,12)}… (candidate ${e.slice(0,12)}…).`),setTimeout(()=>{Q()},500)},onKeep:async(e,t)=>{u({candidateId:e,action:`reject`}),D(`Kept ${t.slice(0,12)}… (candidate ${e.slice(0,12)}… rejected).`)},onUpdate:e=>{k(e),bt()},onMarkPermanent:async e=>{I(`update`);try{await o(e,{persistence:`permanent`}),D(`Memory ${e.slice(0,12)}… promoted to permanent.`),await Q()}catch(e){T(e instanceof Error?e.message:String(e))}finally{I(null)}},onRecover:async e=>{l({id:e,reason:`recovered via file drawer`}),D(`Recovered ${e.slice(0,12)}…`),setTimeout(()=>{Q()},500)}}):(0,W.jsx)(Ye,{memory:Z,allMemories:[...h,...se],relatedMemories:Ot,graphEdges:ae,graphLoading:fe,graphError:le,onClose:()=>k(null),onOpenMemory:yt,onEdit:bt,onDelete:()=>R(Z.id),onTagSelect:e=>{Be(e),k(null)},onNotice:D}):(0,W.jsx)(mt,{onCapture:vt})})]}),(0,W.jsx)(Te,{open:!!L,onOpenChange:e=>{!e&&F!==`delete`&&R(null)},children:(0,W.jsxs)(Se,{className:`max-w-md`,children:[(0,W.jsxs)(be,{children:[(0,W.jsx)(`span`,{className:`mb-2 flex size-10 items-center justify-center border border-destructive/35 bg-destructive/10 text-destructive`,children:(0,W.jsx)(a,{className:`size-4`})}),(0,W.jsx)(Ce,{children:`Delete this memory?`}),(0,W.jsx)(we,{className:`leading-6`,children:`Super Memory will mark the record deleted, remove graph edges, and clean references from related memories. The record remains in the audit trail but cannot be restored from this page.`})]}),(0,W.jsx)(`div`,{className:`border border-border/70 bg-background/45 p-3 text-xs text-muted-foreground`,children:Ne(h.find(e=>e.id===L)?.text??``,180)}),(0,W.jsxs)(xe,{children:[(0,W.jsx)(M,{variant:`outline`,onClick:()=>R(null),disabled:F===`delete`,children:`Cancel`}),(0,W.jsxs)(M,{variant:`destructive`,onClick:Tt,disabled:F===`delete`,children:[F===`delete`?(0,W.jsx)(n,{className:`size-4 animate-spin`}):(0,W.jsx)(a,{className:`size-4`}),F===`delete`?`Deleting…`:`Delete memory`]})]})]})})]})}function mt({onCapture:e}){return(0,W.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center p-8 text-center`,children:[(0,W.jsxs)(`div`,{className:`relative flex size-20 items-center justify-center border border-info/25 bg-info/5 text-info`,children:[(0,W.jsx)(t,{className:`size-8`}),(0,W.jsx)(`span`,{className:`absolute inset-2 border border-info/10`})]}),(0,W.jsx)(`h2`,{className:`mt-5 text-lg font-bold`,children:`Your project’s long-term context`}),(0,W.jsx)(`p`,{className:`mt-2 max-w-md text-sm leading-6 text-muted-foreground`,children:`Select a memory to inspect its metadata and relationship graph, or capture knowledge that future agents should retrieve automatically.`}),(0,W.jsxs)(`div`,{className:`mt-6 grid w-full max-w-lg gap-2 sm:grid-cols-3`,children:[(0,W.jsxs)(`div`,{className:`border border-border/70 bg-card/45 p-3`,children:[(0,W.jsx)(me,{className:`mx-auto size-4 text-success`}),(0,W.jsx)(`p`,{className:`mt-2 text-[10px] font-bold uppercase`,children:`Verified anchors`})]}),(0,W.jsxs)(`div`,{className:`border border-border/70 bg-card/45 p-3`,children:[(0,W.jsx)(t,{className:`mx-auto size-4 text-info`}),(0,W.jsx)(`p`,{className:`mt-2 text-[10px] font-bold uppercase`,children:`Typed relations`})]}),(0,W.jsxs)(`div`,{className:`border border-border/70 bg-card/45 p-3`,children:[(0,W.jsx)(x,{className:`mx-auto size-4 text-warning`}),(0,W.jsx)(`p`,{className:`mt-2 text-[10px] font-bold uppercase`,children:`Agent recall`})]})]}),(0,W.jsxs)(M,{onClick:e,children:[(0,W.jsx)(x,{className:`size-4`}),` Capture memory`]})]})}export{pt as MemoryManager};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Ai as t,Bn as n,Bt as r,Cn as i,Ct as a,Dt as o,Fi as s,Ft as c,Hr as l,Nt as u,Or as d,Rr as f,Vr as p,Wi as m,Yi as h,Yr as g,Yt as _,Zi as v,_ as y,_n as ee,_r as te,a as ne,aa as b,bt as re,cn as x,dn as S,dr as C,f as w,fn as T,gn as ie,hi as E,i as D,li as O,n as k,oi as ae,ot as oe,pr as se,qn as ce,qt as le,r as ue,rn as de,s as fe,tt as pe,wi as me,xi as he}from"./vendor-Di1mdAi5.js";import{n as ge}from"./ui-store-BepZz9CZ.js";import{i as A,t as _e}from"./useWebSocket-CRYUFxmO.js";import{t as ve}from"./ws-client-BWO_PH_X.js";import{t as j}from"./utils-C4qVQ63O.js";import{j as ye}from"./stores-JSLvWOQY.js";import{a as be,i as xe,n as Se,o as Ce,r as we,t as Te}from"./dialog-CNwwBFw3.js";import{t as M}from"./button-99L74zdE.js";import{t as N}from"./pagination-Ktuov5iD.js";import{t as P}from"./input-DXjUO_X9.js";import{S as Ee,g as De}from"./index-Du90vd1u.js";import{_ as Oe,a as ke,b as Ae,c as F,d as je,f as Me,g as Ne,h as I,i as L,l as R,m as z,n as Pe,o as B,p as Fe,r as V,s as Ie,t as Le,u as Re,v as ze,y as H}from"./shared-aSCYBzAV.js";var U=e(b(),1),W=pe(),G=212,Be=188;function K(e){return e.length>14?`${e.slice(0,11)}…`:e}function Ve(e,t=58){let n=e.replace(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t-1)}…`:n}function He(e){return e.type===`symbol`?[e.path,e.symbol?`#${e.symbol}`:``].filter(Boolean).join(``):e.path??e.command??e.symbol??e.type}function Ue(e){return e===`active`?`border-success/45 bg-success/10 text-success`:e===`stale`?`border-warning/45 bg-warning/10 text-warning`:e===`contradicted`?`border-destructive/45 bg-destructive/10 text-destructive`:e===`superseded`?`border-warning/35 bg-warning/5 text-warning`:`border-border bg-muted/55 text-muted-foreground`}function We({data:e}){let{entry:t,center:n}=e;return(0,W.jsxs)(`div`,{className:n?`border border-primary/70 bg-card px-3 py-2.5 text-card-foreground shadow-[0_0_0_1px_hsl(var(--primary)/0.2),0_0_24px_hsl(var(--primary)/0.12)]`:`border border-border/80 bg-card/95 px-3 py-2.5 text-card-foreground shadow-lg`,style:{width:G},title:t.text,children:[(0,W.jsx)(fe,{type:`target`,position:y.Top,className:`!border-background !bg-muted-foreground`}),(0,W.jsx)(fe,{type:`source`,position:y.Bottom,className:`!border-background !bg-primary`}),(0,W.jsx)(fe,{type:`source`,position:y.Right,className:`!border-background !bg-primary`}),(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`border px-1.5 py-0.5 text-[9px] font-bold uppercase ${Ue(t.status)}`,children:t.status}),(0,W.jsx)(`span`,{className:`ml-auto truncate font-mono text-[9px] text-muted-foreground`,children:K(t.id)})]}),(0,W.jsx)(`p`,{className:`mt-2 line-clamp-2 text-[11px] leading-4 text-foreground/90`,children:Ve(t.text)}),(0,W.jsx)(`p`,{className:`mt-1 font-mono text-[9px] uppercase text-muted-foreground`,children:t.kind})]})}function Ge({data:e}){return(0,W.jsxs)(`div`,{className:`border border-info/40 bg-info/8 px-2.5 py-2 text-card-foreground shadow-lg`,style:{width:Be},title:e.label,children:[(0,W.jsx)(fe,{type:`target`,position:y.Left,className:`!border-background !bg-info`}),(0,W.jsx)(`p`,{className:`font-mono text-[9px] font-bold uppercase text-info`,children:e.anchor.type}),(0,W.jsx)(`p`,{className:`mt-1 truncate font-mono text-[10px] text-foreground/85`,children:e.label})]})}var Ke={memoryNode:We,anchorNode:Ge};function qe(e){return{id:e,revision:0,scope:`project`,kind:`fact`,status:`deleted`,text:`Memory is unavailable or has been removed.`,importance:0,confidence:0,freshness:0,tags:[],anchors:[],createdAt:``,updatedAt:``}}function Je({centerMemory:e,allMemories:t,graphEdges:n,loading:r=!1,error:i=null}){let a=`mem:${e.id}`,o=(0,U.useMemo)(()=>n.filter(e=>e.from===a&&e.to.startsWith(`mem:`)||e.to===a&&e.from.startsWith(`mem:`)).slice(0,24),[a,n]),{nodes:s,edges:c}=(0,U.useMemo)(()=>{let n=[],r=[],i=new Map(t.map(e=>[e.id,e]));n.push({id:e.id,type:`memoryNode`,position:{x:320-G/2,y:120},data:{entry:e,center:!0}});let s=[...e.supersededBy?[{id:e.supersededBy,relation:`superseded by`}]:[],...(e.supersedes??[]).map(e=>({id:e,relation:`supersedes`})),...(e.contradicts??[]).map(e=>({id:e,relation:`contradicts`}))];for(let e of o){let t=(e.from===a?e.to:e.from).slice(4);s.some(n=>n.id===t&&n.relation===e.relation)||s.push({id:t,relation:e.relation,weight:e.weight,evidence:e.evidence})}let c=320-(s.length-1)*220/2;return s.forEach((t,a)=>{let o=i.get(t.id)??qe(t.id),s=t.relation===`superseded by`,l=s?0:280+Math.floor(a/3)*130,u=s?320-G/2:c+a*220-G/2;n.push({id:`memory:${t.id}:${a}`,type:`memoryNode`,position:{x:u,y:l},data:{entry:o,center:!1}});let d=t.relation===`contradicts`,f=s?`memory:${t.id}:${a}`:e.id,p=s?e.id:`memory:${t.id}:${a}`;r.push({id:`relation:${t.relation}:${t.id}:${a}`,source:f,target:p,type:`smoothstep`,animated:!d,label:t.weight===void 0?t.relation:`${t.relation} ${t.weight.toFixed(2)}`,data:{evidence:t.evidence??[]},style:{stroke:d?`hsl(var(--destructive))`:`hsl(var(--primary))`,strokeWidth:1.7,...d?{strokeDasharray:`5 4`}:{}},labelStyle:{fill:d?`hsl(var(--destructive))`:`hsl(var(--muted-foreground))`,fontSize:9,fontWeight:700},labelBgStyle:{fill:`hsl(var(--card))`,fillOpacity:.9}})}),e.anchors.forEach((t,i)=>{let a=`anchor:${i}`;n.push({id:a,type:`anchorNode`,position:{x:540,y:120+(i-(e.anchors.length-1)/2)*66},data:{anchor:t,label:He(t)}}),r.push({id:`anchor-edge:${i}`,source:e.id,target:a,type:`smoothstep`,style:{stroke:`hsl(var(--info))`,strokeWidth:1.3}})}),{nodes:n,edges:r}},[t,e,a,o]);return s.length<=1&&!r&&!i?null:(0,W.jsxs)(`section`,{className:`overflow-hidden border border-border/75 bg-background/35`,"aria-label":`Memory relationship graph`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/70 bg-card/55 px-3 py-2`,children:[(0,W.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-muted-foreground`,children:`Relationship map`}),(0,W.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:r?`loading real graph…`:`${s.length} nodes · ${c.length} edges`})]}),i&&(0,W.jsx)(`p`,{className:`border-b border-destructive/25 bg-destructive/5 px-3 py-2 text-[10px] text-destructive`,children:i}),s.length>1&&(0,W.jsx)(`div`,{className:`h-[320px] w-full`,"aria-hidden":`true`,children:(0,W.jsxs)(w,{nodes:s,edges:c,nodeTypes:Ke,fitView:!0,fitViewOptions:{padding:.24,maxZoom:1.05},minZoom:.4,maxZoom:1.5,nodesConnectable:!1,elementsSelectable:!1,panOnScroll:!1,zoomOnScroll:!1,proOptions:{hideAttribution:!0},children:[(0,W.jsx)(ue,{variant:D.Dots,gap:18,size:1,color:`hsl(var(--muted-foreground) / 0.18)`}),(0,W.jsx)(ne,{showInteractive:!1,className:`!border-border !bg-card !shadow-lg`})]})}),o.some(e=>e.evidence?.length)&&(0,W.jsx)(`div`,{className:`grid gap-1 border-t border-border/70 bg-card/35 px-3 py-2`,children:o.filter(e=>e.evidence?.length).slice(0,12).map(e=>{let t=(e.from===a?e.to:e.from).slice(4);return(0,W.jsxs)(`p`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:[(0,W.jsx)(`span`,{className:`text-info`,children:e.relation}),` `,K(t),` · why:`,` `,e.evidence?.join(`, `)]},e.id)})})]})}function Ye({memory:e,allMemories:n,relatedMemories:r,graphEdges:i,graphLoading:o,graphError:s,onClose:c,onOpenMemory:l,onEdit:u,onDelete:d,onTagSelect:f,onNotice:p}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-border/70 bg-card/65 px-4 py-3 backdrop-blur-xl`,children:[(0,W.jsx)(M,{variant:`ghost`,size:`icon`,className:`md:hidden`,onClick:c,"aria-label":`Back to memory list`,children:(0,W.jsx)(m,{className:`size-4`})}),(0,W.jsx)(`span`,{className:j(`text-[10px] font-bold uppercase tracking-[0.14em]`,I(e.kind)),children:V[e.kind]??e.kind}),(0,W.jsx)(R,{status:e.status}),(0,W.jsx)(`span`,{className:`border border-border/70 px-2 py-0.5 font-mono text-[9px] uppercase text-muted-foreground`,children:e.scope}),e.audience&&(0,W.jsxs)(`span`,{className:`flex items-center gap-1 border border-primary/30 bg-primary/10 px-2 py-0.5 font-mono text-[9px] text-primary`,title:Fe(e.audience),children:[(0,W.jsx)(t,{className:`size-3`}),Fe(e.audience)]}),(0,W.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,W.jsx)(M,{variant:`ghost`,size:`icon`,"aria-label":`Copy memory ID`,title:`Copy memory ID`,onClick:()=>{navigator.clipboard?.writeText(e.id),p(`Memory ID copied.`)},children:(0,W.jsx)(ae,{className:`size-4`})}),(0,W.jsxs)(M,{variant:`outline`,size:`sm`,onClick:u,disabled:e.status===`deleted`,children:[(0,W.jsx)(T,{className:`size-3.5`}),` Edit`]}),(0,W.jsxs)(M,{variant:`destructive`,size:`sm`,onClick:d,disabled:e.status===`deleted`,children:[(0,W.jsx)(a,{className:`size-3.5`}),` Delete`]})]})]}),(0,W.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-4 md:p-5`,children:(0,W.jsxs)(`div`,{className:`mx-auto max-w-5xl space-y-5`,children:[(0,W.jsx)(Xe,{memory:e}),(0,W.jsx)(Ze,{memory:e}),e.tags.length>0&&(0,W.jsx)(Qe,{tags:e.tags,onTagSelect:f}),e.anchors.length>0&&(0,W.jsx)($e,{anchors:e.anchors}),r.length>0&&(0,W.jsx)(et,{relatedMemories:r,allMemories:n,onOpenMemory:l}),(0,W.jsx)(Je,{centerMemory:e,allMemories:n,graphEdges:i,loading:o,error:s}),(0,W.jsx)(tt,{memory:e}),e.status===`deleted`&&(0,W.jsx)(nt,{contextPolicy:e.contextPolicy})]})})]})}function Xe({memory:e}){return(0,W.jsxs)(`div`,{className:`relative overflow-hidden border border-border/75 bg-card/55 p-5 shadow-[inset_0_1px_0_hsl(var(--foreground)/0.04)]`,children:[(0,W.jsx)(`div`,{className:`pointer-events-none absolute -right-10 -top-10 size-36 bg-[radial-gradient(circle,hsl(var(--info)/0.13),transparent_68%)]`}),(0,W.jsx)(`p`,{className:`relative whitespace-pre-wrap text-sm leading-7 text-foreground md:text-[15px]`,children:e.text}),e.summary&&(0,W.jsx)(`p`,{className:`relative mt-4 border-l-2 border-info/50 pl-3 text-xs italic leading-5 text-muted-foreground`,children:e.summary}),(0,W.jsxs)(`div`,{className:`relative mt-5 flex flex-wrap items-center gap-2 border-t border-border/60 pt-3`,children:[(0,W.jsx)(`code`,{className:`min-w-0 break-all font-mono text-[10px] text-muted-foreground`,children:e.id}),(0,W.jsxs)(`span`,{className:`ml-auto font-mono text-[10px] text-muted-foreground`,children:[`revision `,e.revision]})]})]})}function Ze({memory:e}){return(0,W.jsx)(`div`,{className:`grid gap-px bg-border/60 sm:grid-cols-3`,children:[[`Importance`,e.importance,r],[`Confidence`,e.confidence,E],[`Freshness`,e.freshness,de]].map(([e,t,n])=>(0,W.jsxs)(`div`,{className:`bg-card/60 p-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(n,{className:`size-3.5 text-info`}),(0,W.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.13em] text-muted-foreground`,children:e}),(0,W.jsxs)(`span`,{className:`ml-auto font-mono text-xs font-bold tabular-nums`,children:[Math.round(t*100),`%`]})]}),(0,W.jsx)(`div`,{className:`mt-2 h-1 bg-muted`,children:(0,W.jsx)(`div`,{className:`h-full bg-info shadow-[0_0_8px_hsl(var(--info)/0.45)]`,style:{width:`${Math.round(t*100)}%`}})})]},e))})}function Qe({tags:e,onTagSelect:t}){return(0,W.jsxs)(`section`,{children:[(0,W.jsxs)(`h3`,{className:`mb-2 flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:[(0,W.jsx)(o,{className:`size-3.5 text-info`}),` Tags`]}),(0,W.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map(e=>(0,W.jsxs)(`button`,{type:`button`,onClick:()=>t(e),className:`border border-info/25 bg-info/5 px-2 py-1 font-mono text-[10px] text-info hover:border-info/55 hover:bg-info/10`,children:[`#`,e]},e))})]})}function $e({anchors:e}){return(0,W.jsxs)(`section`,{className:`border border-border/75 bg-card/40`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/65 px-3 py-2.5`,children:[(0,W.jsxs)(`h3`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:[(0,W.jsx)(f,{className:`size-3.5 text-info`}),` Anchors`]}),(0,W.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.length})]}),(0,W.jsx)(`ul`,{className:`divide-y divide-border/55`,children:e.map((e,t)=>(0,W.jsxs)(`li`,{className:`flex min-w-0 items-start gap-3 px-3 py-2.5`,children:[(0,W.jsx)(`span`,{className:`mt-0.5 flex size-7 shrink-0 items-center justify-center border border-info/25 bg-info/5 text-info`,children:e.type===`command`?(0,W.jsx)(u,{className:`size-3.5`}):(0,W.jsx)(f,{className:`size-3.5`})}),(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`p`,{className:`text-[9px] font-bold uppercase text-muted-foreground`,children:e.type}),(0,W.jsxs)(`p`,{className:`mt-0.5 break-all font-mono text-[10px] leading-4 text-foreground/85`,children:[e.path??e.command??`—`,e.symbol?`#${e.symbol}`:``]})]}),(e.lineStart||e.lineEnd)&&(0,W.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono text-[9px] text-muted-foreground`,children:[`L`,e.lineStart??`?`,`–`,e.lineEnd??`?`]})]},`${e.type}:${e.path??e.command??e.symbol}:${t}`))})]})}function et({relatedMemories:e,allMemories:t,onOpenMemory:n}){return(0,W.jsxs)(`section`,{className:`border border-border/75 bg-card/40`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/65 px-3 py-2.5`,children:[(0,W.jsxs)(`h3`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:[(0,W.jsx)(se,{className:`size-3.5 text-info`}),` Memory relationships`]}),(0,W.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.length})]}),(0,W.jsx)(`ul`,{className:`divide-y divide-border/55`,children:e.map(e=>{let r=t.find(t=>t.id===e.id);return(0,W.jsx)(`li`,{children:(0,W.jsxs)(`button`,{type:`button`,disabled:!r,onClick:()=>r&&n(r.id),className:`group flex w-full min-w-0 items-center gap-3 px-3 py-2.5 text-left hover:bg-info/5 disabled:cursor-not-allowed disabled:opacity-55`,children:[(0,W.jsx)(`span`,{className:j(`w-24 shrink-0 text-[9px] font-bold uppercase`,e.relation===`Contradicts`?`text-destructive`:`text-info`),children:e.relation}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs`,children:r?Ne(r.text,95):`Referenced memory is unavailable`}),(0,W.jsx)(`code`,{className:`hidden max-w-32 truncate font-mono text-[9px] text-muted-foreground sm:block`,children:e.id}),r&&(0,W.jsx)(he,{className:`size-3.5 shrink-0 text-muted-foreground group-hover:text-info`})]})},`${e.relation}:${e.id}`)})})]})}function tt({memory:e}){return(0,W.jsx)(`section`,{className:`grid gap-px bg-border/60 sm:grid-cols-2 lg:grid-cols-4`,children:[[`Created`,z(e.createdAt),s],[`Updated`,z(e.updatedAt),de],[`Last accessed`,z(e.lastAccessedAt),i],[`Last verified`,z(e.lastVerifiedAt),r]].map(([e,t,n])=>(0,W.jsxs)(`div`,{className:`bg-card/50 p-3`,children:[(0,W.jsx)(n,{className:`size-3.5 text-muted-foreground`}),(0,W.jsx)(`p`,{className:`mt-2 text-[9px] font-bold uppercase tracking-[0.12em] text-muted-foreground`,children:e}),(0,W.jsx)(`p`,{className:`mt-1 text-[10px] leading-4 text-foreground/85`,children:t})]},e))})}function nt({contextPolicy:e}){return(0,W.jsxs)(`div`,{className:`flex items-start gap-3 border border-border bg-muted/50 p-4 text-xs text-muted-foreground`,children:[(0,W.jsx)(h,{className:`mt-0.5 size-4 shrink-0`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`font-bold text-foreground`,children:`Deleted memory`}),(0,W.jsx)(`p`,{className:`mt-1 leading-5`,children:e===`never`?`This record is audit-only and carries an absolute ban: it can never enter LLM context.`:`The record is inactive and cannot be edited, but remains eligible as historical evidence when retrieval finds it relevant.`})]})]})}var rt={filePath:``,primaryMatches:[],symbolMatches:[],relatedMatches:[],totalCount:0,activeCount:0,supersededCount:0,reviewPendingCount:0};function it(e){let{filePath:t,lineStart:n,lineEnd:r,limit:i=50,showSuperseded:a=!0,showDeleted:o=!1,autoFetch:s=!0,sendOptions:c}=e,l=c?JSON.stringify(c):``,[u,d]=(0,U.useState)(null),[f,p]=(0,U.useState)(!1),[m,h]=(0,U.useState)(null),g=(0,U.useRef)(0),_=(0,U.useRef)(null),v=(0,U.useRef)(c);v.current=c;let y=(0,U.useCallback)(()=>{if(!t){d(null),h(null),p(!1);return}let e=++g.current;p(!0),h(null);let s=ve();if(!s){h(`WebSocket client unavailable`),p(!1);return}_.current?.(),_.current=null;let c=t,l=s.on(`memory.super.forFile`,t=>{if(e!==g.current)return;let n=t.payload.response;n&&n.filePath!==c||(t.payload.error?(h(t.payload.error),d(null)):(d(n??rt),h(null)),p(!1))});_.current=l;let u={filePath:t,limit:i,showSuperseded:a,showDeleted:o,...n===void 0?{}:{lineStart:n},...r===void 0?{}:{lineEnd:r}};try{s.findMemoriesForFile(u,v.current??void 0)}catch(t){l(),_.current===l&&(_.current=null),e===g.current&&(h(t instanceof Error?t.message:String(t)),p(!1))}},[t,n,r,i,a,o]);(0,U.useEffect)(()=>{if(s)return y(),()=>{g.current++,_.current?.(),_.current=null}},[s,y,l]);let ee=(0,U.useCallback)(()=>{y()},[y]);return(0,U.useEffect)(()=>()=>{_.current?.(),_.current=null},[]),{data:u,loading:f,error:m,refetch:ee}}function at(e){return e>=.9?`bg-success/15 border-success/40`:e>=.7?`bg-info/15 border-info/40`:e>=.4?`bg-warning/10 border-warning/30`:`bg-muted/30 border-border/40`}function q(e){switch(e){case`scope_file`:return`scope: file`;case`scope_symbol`:return`scope: symbol`;case`anchor_file`:return`anchor: file`;case`anchor_symbol`:return`anchor: symbol`;case`anchor_directory`:return`anchor: directory`;case`mention`:return`text mention`}}function ot({match:e,cursorBoosted:t,onShowMemory:r,onAcceptDeletion:i,onKeep:a,onUpdate:o,onMarkPermanent:s,onRecover:l,pendingAction:u}){let d=e.memory.status===`deleted`,f=e.memory.status===`superseded`,m=e.pendingReview,h=u!==void 0,g=t===!0;return(0,W.jsxs)(`article`,{className:j(`group relative rounded-md border px-3 py-2 text-sm transition-colors`,at(e.matchStrength),g&&`ring-1 ring-primary/40 ring-offset-0`,d&&`opacity-70`),"data-match-via":e.matchedVia,"data-memory-id":e.memory.id,children:[(0,W.jsx)(`header`,{className:`flex items-start justify-between gap-2`,children:(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] uppercase tracking-wide`,children:[(0,W.jsx)(`span`,{className:j(`font-mono`,I(e.memory.kind)),children:V[e.memory.kind]??e.memory.kind}),(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`·`}),(0,W.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:q(e.matchedVia)}),g&&(0,W.jsxs)(`span`,{className:`flex items-center gap-0.5 rounded-sm bg-primary/15 px-1 py-0.5 font-mono text-primary`,title:`Cursor line range matches this memory's anchor`,children:[(0,W.jsx)(S,{className:`size-2.5`}),` cursor`]}),m&&(0,W.jsxs)(`span`,{className:`flex items-center gap-0.5 rounded-sm bg-warning/15 px-1 py-0.5 font-mono text-warning`,title:`Hygiene review: ${m.reason} (${m.ageDays}d old)`,children:[(0,W.jsx)(re,{className:`size-2.5`}),` review`]}),d&&(0,W.jsx)(`span`,{className:`font-mono text-destructive`,children:`deleted`}),f&&!d&&(0,W.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:`superseded`})]}),(0,W.jsx)(`p`,{className:`mt-1 text-foreground/90`,children:Ne(e.memory.text,200)}),(0,W.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,W.jsx)(R,{status:e.memory.status}),(0,W.jsxs)(`span`,{children:[`updated `,ze(e.memory.updatedAt)]})]})]})}),(0,W.jsxs)(`footer`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,children:[d&&l&&(0,W.jsxs)(M,{type:`button`,size:`sm`,variant:`outline`,disabled:h,onClick:()=>l(e.memory.id),className:`h-7 gap-1 border-primary/40 px-2 text-[11px] text-primary hover:bg-primary/10`,title:`Restore this memory to active status (PR #1: memory_recover)`,children:[(0,W.jsx)(de,{className:`size-3`}),` Recover`]}),f&&e.supersededByActiveId&&r&&(0,W.jsxs)(M,{type:`button`,size:`sm`,variant:`outline`,disabled:h,onClick:()=>r(e.supersededByActiveId),className:`h-7 gap-1 px-2 text-[11px]`,title:`This version is superseded — jump to the active version`,children:[(0,W.jsx)(C,{className:`size-3`}),` Go to active`]}),m&&(0,W.jsxs)(W.Fragment,{children:[m.suggestedAction===`delete`&&(0,W.jsxs)(M,{type:`button`,size:`sm`,variant:`destructive`,disabled:h,onClick:()=>i?.(m.candidateId,e.memory.id),className:`h-7 gap-1 px-2 text-[11px]`,title:`Accept hygiene's deletion suggestion — memory will be forgotten`,children:[(0,W.jsx)(me,{className:`size-3`}),` Accept Deletion`]}),(0,W.jsxs)(M,{type:`button`,size:`sm`,variant:`outline`,disabled:h,onClick:()=>a?.(m.candidateId,e.memory.id),className:`h-7 gap-1 px-2 text-[11px]`,title:`Reject the suggestion — memory stays as-is and may be re-suggested later`,children:[(0,W.jsx)(oe,{className:`size-3`}),` Keep`]}),(0,W.jsxs)(M,{type:`button`,size:`sm`,variant:`outline`,disabled:h,onClick:()=>o?.(e.memory.id),className:`h-7 gap-1 px-2 text-[11px]`,title:`Update the memory's content — versioning creates a new active record`,children:[(0,W.jsx)(c,{className:`size-3`}),` Update`]}),s&&(0,W.jsxs)(M,{type:`button`,size:`sm`,variant:`outline`,disabled:h,onClick:()=>s(e.memory.id),className:`h-7 gap-1 border-warning/40 px-2 text-[11px] text-warning hover:bg-warning/10`,title:"Promote to `permanent` — hygiene will never surface this again",children:[(0,W.jsx)(S,{className:`size-3`}),` Mark as Permanent`]})]}),r&&!d&&(0,W.jsxs)(M,{type:`button`,size:`sm`,variant:`ghost`,disabled:h,onClick:()=>r(e.memory.id),className:`h-7 gap-1 px-2 text-[11px] text-muted-foreground hover:text-foreground`,title:`Open the full record in MemoryManager`,children:[(0,W.jsx)(p,{className:`size-3`}),` Show full`]}),u&&(0,W.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 text-[10px] text-muted-foreground`,children:[(0,W.jsx)(n,{className:`size-3 animate-spin`}),` `,u]})]})]})}function J({icon:e,title:t,count:n,matches:r,cursorBoosted:i=!1,...a}){let o=Ee(r,10);return r.length===0?null:(0,W.jsxs)(`section`,{className:`flex flex-col gap-1.5`,children:[(0,W.jsxs)(`h3`,{className:`flex items-center gap-1.5 px-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[(0,W.jsx)(e,{className:`size-3`}),(0,W.jsx)(`span`,{children:t}),(0,W.jsxs)(`span`,{className:`font-mono`,children:[`(`,n,`)`]}),i&&(0,W.jsxs)(`span`,{className:`ml-auto flex items-center gap-0.5 font-mono text-[9px] text-primary`,children:[(0,W.jsx)(S,{className:`size-2.5`}),` cursor boost`]})]}),(0,W.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:o.pageItems.map(e=>(0,W.jsx)(ot,{match:e,cursorBoosted:i&&(e.matchedVia===`anchor_symbol`||e.matchedVia===`scope_symbol`),pendingAction:a.pendingActionById.get(e.memory.id),...a},e.memory.id))}),(0,W.jsx)(N,{page:o.page,pageSize:o.pageSize,totalItems:o.totalItems,onPageChange:o.setPage,compact:!0,itemLabel:`memories`})]})}function st({filePath:e,lineStart:t,lineEnd:n,open:r,onClose:i,onShowMemory:a,onAcceptDeletion:o,onKeep:s,onUpdate:c,onMarkPermanent:u,onRecover:f}){let[m,h]=(0,U.useState)(!1),[g,_]=(0,U.useState)(new Map),{data:v,loading:y,error:ee,refetch:te}=it({filePath:e,lineStart:t,lineEnd:n,showDeleted:m,autoFetch:r}),ne=t!==void 0&&n!==void 0,b=(0,U.useCallback)(async(e,t,n)=>{if(n){_(n=>new Map(n).set(e,t));try{await n(e)}finally{_(t=>{let n=new Map(t);return n.delete(e),n})}}},[]);if((0,U.useEffect)(()=>{h(!1)},[e]),!r)return null;let x=v,C=x?.totalCount??0;return(0,W.jsxs)(`aside`,{className:`flex h-full min-h-0 w-full flex-col border-l border-border/70 bg-card/15`,"aria-label":`File memory drawer`,"data-file-path":e??``,children:[(0,W.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-border/60 px-3 py-2`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] uppercase tracking-wide text-muted-foreground`,children:[(0,W.jsx)(d,{className:`size-3`}),(0,W.jsx)(`span`,{className:`truncate font-mono`,title:e??``,children:e??`(no file)`})]}),(0,W.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,W.jsxs)(`span`,{className:`font-mono`,children:[C,` memories`]}),x&&x.reviewPendingCount>0&&(0,W.jsxs)(`span`,{className:`flex items-center gap-0.5 font-mono text-warning`,children:[(0,W.jsx)(re,{className:`size-3`}),x.reviewPendingCount,` pending review`]}),x&&x.supersededCount>0&&(0,W.jsxs)(`span`,{className:`font-mono`,children:[x.supersededCount,` superseded`]})]})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,W.jsx)(M,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>te(),disabled:y||!e,className:`h-7 w-7 p-0`,"aria-label":`Refresh`,title:`Re-query for this file`,children:(0,W.jsx)(de,{className:j(`size-3.5`,y&&`animate-spin`)})}),(0,W.jsx)(M,{type:`button`,size:`sm`,variant:`ghost`,onClick:i,className:`h-7 w-7 p-0`,"aria-label":`Close drawer`,title:`Close memory drawer`,children:(0,W.jsx)(O,{className:`size-3.5`})})]})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-border/40 bg-background/40 px-3 py-1.5 text-[10px] text-muted-foreground`,children:[(0,W.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:m,onChange:e=>h(e.target.checked),className:`size-3 accent-primary`,disabled:!e,"data-testid":`memory-drawer-show-deleted`}),m?(0,W.jsx)(p,{className:`size-3`}):(0,W.jsx)(l,{className:`size-3`}),(0,W.jsx)(`span`,{children:`Show recoverable (deleted)`})]}),ne&&(0,W.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 font-mono text-[10px] text-primary`,children:[(0,W.jsx)(S,{className:`size-3`}),` lines `,t,`–`,n]})]}),(0,W.jsx)(`div`,{className:`flex-1 overflow-y-auto px-3 py-3`,children:e?y&&!x?(0,W.jsx)(Y,{loading:!0,message:`Loading memories…`}):ee?(0,W.jsx)(Y,{tone:`error`,message:`Error: ${ee}`}):!x||C===0?(0,W.jsx)(Y,{message:`No memories attached to ${e} yet.`}):(0,W.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,W.jsx)(J,{icon:S,title:`Cursor boost`,count:x.symbolMatches.length,cursorBoosted:ne,matches:x.symbolMatches,pendingActionById:g,onShowMemory:a,onAcceptDeletion:(e,t)=>b(t,`accepting…`,()=>o?.(e,t)),onKeep:(e,t)=>b(t,`keeping…`,()=>s?.(e,t)),onUpdate:e=>b(e,`updating…`,()=>c?.(e)),onMarkPermanent:e=>b(e,`marking…`,()=>u?.(e)),onRecover:e=>b(e,`recovering…`,()=>f?.(e))}),(0,W.jsx)(J,{icon:d,title:`File-scoped`,count:x.primaryMatches.length,matches:x.primaryMatches,pendingActionById:g,onShowMemory:a,onAcceptDeletion:(e,t)=>b(t,`accepting…`,()=>o?.(e,t)),onKeep:(e,t)=>b(t,`keeping…`,()=>s?.(e,t)),onUpdate:e=>b(e,`updating…`,()=>c?.(e)),onMarkPermanent:e=>b(e,`marking…`,()=>u?.(e)),onRecover:e=>b(e,`recovering…`,()=>f?.(e))}),(0,W.jsx)(J,{icon:p,title:`Mentioned in`,count:x.relatedMatches.length,matches:x.relatedMatches,pendingActionById:g,onShowMemory:a,onAcceptDeletion:(e,t)=>b(t,`accepting…`,()=>o?.(e,t)),onKeep:(e,t)=>b(t,`keeping…`,()=>s?.(e,t)),onUpdate:e=>b(e,`updating…`,()=>c?.(e)),onMarkPermanent:e=>b(e,`marking…`,()=>u?.(e)),onRecover:e=>b(e,`recovering…`,()=>f?.(e))})]}):(0,W.jsx)(Y,{message:`Open a file to see its memories.`})})]})}function Y({message:e,loading:t=!1,tone:r=`default`}){return(0,W.jsxs)(`div`,{className:j(`flex min-h-[120px] flex-col items-center justify-center gap-2 rounded-md border border-dashed border-border/60 px-4 py-6 text-center text-[11px]`,r===`error`?`text-destructive`:`text-muted-foreground`),children:[t&&(0,W.jsx)(n,{className:`size-4 animate-spin`}),(0,W.jsx)(`p`,{children:e})]})}function ct({mode:e,draft:t,busy:r,error:i,onChange:o,onCancel:s,onSubmit:l}){let u=(0,U.useRef)(null);(0,U.useEffect)(()=>{u.current?.focus()},[]);let d=(e,n)=>{o({...t,[e]:n})},f=()=>{d(`anchors`,[...t.anchors,{type:`file`,path:``}])};return(0,W.jsxs)(`form`,{className:`flex min-h-0 flex-1 flex-col`,onSubmit:e=>{e.preventDefault(),l()},"aria-busy":r,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-border/70 bg-card/70 px-4 py-3 backdrop-blur-xl`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`flex size-8 items-center justify-center border border-info/35 bg-info/10 text-info`,children:e===`create`?(0,W.jsx)(c,{className:`size-4`}):(0,W.jsx)(T,{className:`size-4`})}),(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`p`,{className:`truncate text-sm font-bold`,children:e===`create`?`Capture a memory`:`Edit memory`}),(0,W.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:e===`create`?`Add durable knowledge with retrieval metadata.`:`Update content without losing provenance.`})]})]}),(0,W.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,W.jsxs)(M,{type:`button`,variant:`ghost`,size:`sm`,onClick:s,disabled:r,children:[(0,W.jsx)(oe,{className:`size-3.5`}),` Cancel`]}),(0,W.jsxs)(M,{type:`submit`,size:`sm`,disabled:r||!t.text.trim(),children:[r?(0,W.jsx)(n,{className:`size-3.5 animate-spin`}):e===`create`?(0,W.jsx)(x,{className:`size-3.5`}):(0,W.jsx)(_,{className:`size-3.5`}),r?`Saving…`:e===`create`?`Create memory`:`Save changes`]})]})]}),(0,W.jsx)(`div`,{className:`flex-1 overflow-y-auto overscroll-contain p-4 md:p-5`,children:(0,W.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-5`,children:[i&&(0,W.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-2 border border-destructive/40 bg-destructive/10 px-3 py-2.5 text-sm text-destructive`,children:[(0,W.jsx)(re,{className:`mt-0.5 size-4 shrink-0`}),(0,W.jsx)(`span`,{children:i})]}),(0,W.jsxs)(`section`,{className:`border border-border/75 bg-card/45 p-4`,children:[(0,W.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{className:`text-xs font-bold uppercase tracking-[0.14em]`,children:`Knowledge`}),(0,W.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:`Write the durable fact or decision in complete, searchable language.`})]}),(0,W.jsxs)(`span`,{className:`font-mono text-[10px] text-muted-foreground tabular-nums`,children:[t.text.length,` chars`]})]}),(0,W.jsx)(`label`,{htmlFor:`memory-text`,className:`sr-only`,children:`Memory content`}),(0,W.jsx)(`textarea`,{ref:u,id:`memory-text`,value:t.text,onChange:e=>d(`text`,e.target.value),rows:7,required:!0,placeholder:`Example: WebUI state is owned by Zustand stores; server messages update those stores through singleton WebSocket handlers.`,className:`min-h-36 w-full resize-y border border-input bg-background/75 px-3 py-3 text-sm leading-6 text-foreground shadow-inner placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`})]}),(0,W.jsxs)(`section`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`label`,{htmlFor:`memory-kind`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Kind`}),(0,W.jsx)(`select`,{id:`memory-kind`,value:t.kind,onChange:e=>d(`kind`,e.target.value),className:`h-10 w-full border border-input bg-background px-3 text-sm`,children:L.map(e=>(0,W.jsx)(`option`,{value:e,children:V[e]},e))})]}),e===`create`?(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`label`,{htmlFor:`memory-scope`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Scope`}),(0,W.jsx)(`select`,{id:`memory-scope`,value:t.scope,onChange:e=>d(`scope`,e.target.value),className:`h-10 w-full border border-input bg-background px-3 text-sm`,children:ke.map(e=>(0,W.jsx)(`option`,{value:e,children:e},e))})]}):(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`label`,{htmlFor:`memory-status`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Lifecycle status`}),(0,W.jsx)(`select`,{id:`memory-status`,value:t.status,onChange:e=>d(`status`,e.target.value),className:`h-10 w-full border border-input bg-background px-3 text-sm`,children:Pe.map(e=>(0,W.jsx)(`option`,{value:e,children:e},e))})]}),(0,W.jsxs)(`div`,{className:j(`min-w-0`,e===`create`?`sm:col-span-2 lg:col-span-1`:``),children:[(0,W.jsx)(`label`,{htmlFor:`memory-tags`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Tags`}),(0,W.jsx)(P,{id:`memory-tags`,value:t.tags,onChange:e=>d(`tags`,e.target.value),placeholder:`architecture, webui, workflow`,className:`h-10 bg-background`})]})]}),(0,W.jsxs)(`section`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,W.jsx)(F,{id:`memory-importance`,label:`Importance`,value:t.importance,onChange:e=>d(`importance`,e)}),(0,W.jsx)(F,{id:`memory-confidence`,label:`Confidence`,value:t.confidence,onChange:e=>d(`confidence`,e)}),(0,W.jsx)(F,{id:`memory-freshness`,label:`Freshness`,value:t.freshness,onChange:e=>d(`freshness`,e)})]}),(0,W.jsxs)(`section`,{className:`border border-border/75 bg-card/45 p-4`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{className:`text-xs font-bold uppercase tracking-[0.14em]`,children:`Anchors`}),(0,W.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:`Bind knowledge to files, symbols, packages, tests, Git paths, or commands.`})]}),(0,W.jsxs)(M,{type:`button`,variant:`outline`,size:`sm`,onClick:f,children:[(0,W.jsx)(x,{className:`size-3.5`}),` Add anchor`]})]}),t.anchors.length===0?(0,W.jsxs)(`button`,{type:`button`,onClick:f,className:`mt-4 flex w-full items-center justify-center gap-2 border border-dashed border-border px-4 py-7 text-xs text-muted-foreground transition-colors hover:border-info/50 hover:bg-info/5 hover:text-info`,children:[(0,W.jsx)(ce,{className:`size-4`}),` No anchors yet — add one to improve retrieval precision`]}):(0,W.jsx)(`div`,{className:`mt-4 space-y-2`,children:t.anchors.map((e,n)=>(0,W.jsxs)(`div`,{className:`grid gap-2 border border-border/65 bg-background/40 p-2 sm:grid-cols-[9rem_minmax(0,1fr)_auto]`,children:[(0,W.jsxs)(`label`,{className:`sr-only`,htmlFor:`anchor-type-${n}`,children:[`Anchor `,n+1,` type`]}),(0,W.jsx)(`select`,{id:`anchor-type-${n}`,value:e.type,onChange:e=>{let r=e.target.value,i=r===`command`?{type:r,command:``}:{type:r,path:``},a=t.anchors.map((e,t)=>t===n?i:e);d(`anchors`,a)},className:`h-10 border border-input bg-background px-2 text-xs`,children:Le.map(e=>(0,W.jsx)(`option`,{value:e,children:e},e))}),(0,W.jsxs)(`div`,{className:j(`grid min-w-0 gap-2`,e.type===`symbol`&&`sm:grid-cols-[minmax(0,1fr)_11rem]`),children:[(0,W.jsxs)(`label`,{className:`sr-only`,htmlFor:`anchor-value-${n}`,children:[`Anchor `,n+1,` value`]}),(0,W.jsx)(P,{id:`anchor-value-${n}`,value:Re(e),onChange:e=>{let r=t.anchors.map((t,r)=>r===n?Ae(t,e.target.value):t);d(`anchors`,r)},placeholder:e.type===`command`?`pnpm test --filter webui`:`packages/webui/src/App.tsx`,className:`h-10 min-w-0 bg-background font-mono text-xs`}),e.type===`symbol`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`label`,{className:`sr-only`,htmlFor:`anchor-symbol-${n}`,children:[`Anchor `,n+1,` symbol`]}),(0,W.jsx)(P,{id:`anchor-symbol-${n}`,value:e.symbol??``,onChange:e=>{let r=t.anchors.map((t,r)=>r===n?{...t,symbol:e.target.value}:t);d(`anchors`,r)},placeholder:`Symbol name`,className:`h-10 bg-background font-mono text-xs`})]})]}),(0,W.jsx)(M,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Remove anchor ${n+1}`,onClick:()=>d(`anchors`,t.anchors.filter((e,t)=>t!==n)),children:(0,W.jsx)(a,{className:`size-4 text-destructive`})})]},`${e.type}:${n}`))})]}),(0,W.jsxs)(`section`,{className:`grid gap-3 border border-border/75 bg-card/45 p-4 sm:grid-cols-2`,children:[(0,W.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,W.jsx)(`h3`,{className:`text-xs font-bold uppercase tracking-[0.14em]`,children:`Relationships`}),(0,W.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:`Reference exact memory IDs. Relationships are validated and graph edges are rebuilt by Super Memory.`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{htmlFor:`memory-supersedes`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Supersedes`}),(0,W.jsx)(P,{id:`memory-supersedes`,value:t.supersedes,onChange:e=>d(`supersedes`,e.target.value),placeholder:`mem_id, mem_id`,className:`h-10 bg-background font-mono text-xs`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{htmlFor:`memory-contradicts`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Contradicts`}),(0,W.jsx)(P,{id:`memory-contradicts`,value:t.contradicts,onChange:e=>d(`contradicts`,e.target.value),placeholder:`mem_id, mem_id`,className:`h-10 bg-background font-mono text-xs`})]})]}),(0,W.jsxs)(`section`,{className:`space-y-2`,children:[(0,W.jsx)(`h3`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Audience (Optional)`}),(0,W.jsx)(`p`,{className:`text-[10px] text-muted-foreground/70`,children:`Target this memory to specific agent types. Leave empty for general project memory.`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{htmlFor:`memory-audience-roles`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Roles`}),(0,W.jsx)(P,{id:`memory-audience-roles`,value:t.audienceRoles,onChange:e=>d(`audienceRoles`,e.target.value),placeholder:`reviewer, refactor-planner`,className:`h-9 bg-background font-mono text-xs`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{htmlFor:`memory-audience-task-types`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Task types`}),(0,W.jsx)(P,{id:`memory-audience-task-types`,value:t.audienceTaskTypes,onChange:e=>d(`audienceTaskTypes`,e.target.value),placeholder:`review, refactor, bugfix`,className:`h-9 bg-background font-mono text-xs`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{htmlFor:`memory-audience-modes`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Modes`}),(0,W.jsx)(P,{id:`memory-audience-modes`,value:t.audienceModes,onChange:e=>d(`audienceModes`,e.target.value),placeholder:`teach, code-review`,className:`h-9 bg-background font-mono text-xs`})]})]})]})})]})}function lt({searchQuery:e,statusFilter:n,kindFilter:r,audienceOnly:i,tagFilter:a,hasFilters:s,allTags:c,stats:l,onSearchChange:u,onStatusFilterChange:d,onKindFilterChange:f,onToggleAudienceOnly:p,onTagFilterChange:m,onClearFilters:h}){return(0,W.jsxs)(`div`,{className:`shrink-0 space-y-2 overflow-hidden border-b border-border/70 bg-card/45 p-3`,children:[(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,W.jsx)(le,{className:`pointer-events-none absolute left-3 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,W.jsx)(P,{"aria-label":`Search memories`,value:e,onChange:e=>u(e.target.value),placeholder:`Search content, IDs, tags, anchors…`,className:`h-10 min-w-0 bg-background pl-9 pr-8 text-xs`}),e&&(0,W.jsx)(`button`,{type:`button`,"aria-label":`Clear search`,onClick:()=>u(``),className:`absolute right-2 top-1/2 -translate-y-1/2 p-1 text-muted-foreground hover:text-foreground`,children:(0,W.jsx)(oe,{className:`size-3.5`})})]}),(0,W.jsx)(M,{variant:i?`default`:`ghost`,size:`icon`,onClick:p,"aria-label":`Filter audience-scoped only`,title:`Show only audience-scoped memories`,className:`shrink-0`,children:(0,W.jsx)(t,{className:`size-4`})}),s&&(0,W.jsx)(M,{variant:`ghost`,size:`icon`,onClick:h,"aria-label":`Clear all filters`,title:`Clear all filters`,children:(0,W.jsx)(te,{className:`size-4`})})]}),(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsx)(`label`,{className:`sr-only`,htmlFor:`memory-status-filter`,children:`Filter by status`}),(0,W.jsxs)(`select`,{id:`memory-status-filter`,value:n,onChange:e=>d(e.target.value),className:`h-9 min-w-0 border border-input bg-background px-2 text-xs`,children:[(0,W.jsx)(`option`,{value:`all`,children:`All statuses`}),B.map(e=>(0,W.jsxs)(`option`,{value:e,children:[e,` · `,l?.byStatus[e]??0]},e))]}),(0,W.jsx)(`label`,{className:`sr-only`,htmlFor:`memory-kind-filter`,children:`Filter by kind`}),(0,W.jsxs)(`select`,{id:`memory-kind-filter`,value:r,onChange:e=>f(e.target.value),className:`h-9 min-w-0 border border-input bg-background px-2 text-xs`,children:[(0,W.jsx)(`option`,{value:`all`,children:`All kinds`}),L.map(e=>(0,W.jsxs)(`option`,{value:e,children:[V[e],` · `,l?.byKind[e]??0]},e))]})]}),c.length>0&&(0,W.jsxs)(`fieldset`,{className:`min-w-0 border-0 p-0`,children:[(0,W.jsx)(`legend`,{className:`sr-only`,children:`Popular tags`}),(0,W.jsx)(`div`,{className:`no-scrollbar flex gap-1.5 overflow-x-auto pb-0.5`,children:c.slice(0,18).map(([e,t])=>(0,W.jsxs)(`button`,{type:`button`,"aria-pressed":a===e,onClick:()=>m(a===e?null:e),className:j(`flex shrink-0 items-center gap-1 border px-2 py-1 text-[10px] transition-colors`,a===e?`border-info/55 bg-info/10 text-info`:`border-border/70 bg-background/45 text-muted-foreground hover:border-info/35 hover:text-foreground`),children:[(0,W.jsx)(o,{className:`size-2.5`}),` `,e,(0,W.jsx)(`span`,{className:`font-mono opacity-60`,children:t})]},e))})]})]})}function ut(){let e=A(e=>e.traces[0]),t=A(e=>e.contextMemories),n=A(e=>e.clear),r=Object.values(t),i=r.filter(e=>e.state!==`exited`).length,o=r.filter(e=>e.state===`exited`).length,s=e?Object.values(e.rejected).reduce((e,t)=>e+t,0):0;return(0,W.jsx)(`section`,{className:`shrink-0 border-b border-border/70 bg-violet-500/[0.035]`,"aria-label":`Memory Injector summary`,children:(0,W.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-4 text-[10px]`,children:[(0,W.jsx)(v,{className:`size-3.5 text-violet-400`}),(0,W.jsx)(`span`,{className:`font-bold uppercase tracking-wide text-violet-300`,children:`Memory context`}),e?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`span`,{className:`font-mono text-foreground`,children:[e.candidates,` matched`]}),(0,W.jsxs)(`span`,{className:`font-mono text-success`,children:[e.injected.length,` injected`]}),(0,W.jsxs)(`span`,{className:`font-mono text-warning`,children:[s,` filtered`]}),(0,W.jsxs)(`span`,{className:`font-mono text-sky-300`,children:[i,` active`]}),o>0&&(0,W.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[o,` left`]}),(0,W.jsxs)(`span`,{className:`ml-auto text-muted-foreground`,children:[e.trigger,` · ctx `,Math.round(e.contextPressure*100),`% · details in Context`]}),(0,W.jsxs)(M,{type:`button`,variant:`ghost`,size:`sm`,className:`h-6 px-2 text-[10px]`,onClick:n,children:[(0,W.jsx)(a,{className:`size-3`}),` Clear`]})]}):(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`waiting · details in Context`})]})})}var X=100;function dt({memoryListRef:e,memories:t,filteredMemories:n,selectedId:r,onSelectMemory:i,onOpenCreate:a,onClearFilters:o}){let s=n.length>X,c=k({count:n.length,getScrollElement:()=>e.current,estimateSize:()=>100,overscan:8,enabled:s});return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-border/60 px-3 py-2 text-[10px] text-muted-foreground`,children:[(0,W.jsxs)(`span`,{children:[n.length,` of `,t.length,` memories`]}),(0,W.jsx)(`span`,{className:`font-mono uppercase`,children:`updated ↓`})]}),(0,W.jsx)(`section`,{ref:e,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,"aria-label":`Memories`,children:n.length===0?(0,W.jsx)(ft,{hasMemories:t.length>0,onOpenCreate:a,onClearFilters:o}):s?(0,W.jsx)(`div`,{style:{height:`${c.getTotalSize()}px`,width:`100%`,position:`relative`},children:c.getVirtualItems().map(e=>{let t=n[e.index];return t?(0,W.jsx)(`div`,{"data-index":e.index,ref:c.measureElement,style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${e.start}px)`},children:(0,W.jsx)(Z,{memory:t,isSelected:r===t.id,onClick:()=>i(t.id)})},t.id):null})}):n.map(e=>(0,W.jsx)(Z,{memory:e,isSelected:r===e.id,onClick:()=>i(e.id)},e.id))})]})}function ft({hasMemories:e,onOpenCreate:t,onClearFilters:n}){return(0,W.jsxs)(`div`,{className:`flex min-h-64 flex-col items-center justify-center px-6 text-center`,children:[(0,W.jsx)(`span`,{className:`flex size-12 items-center justify-center border border-dashed border-border text-muted-foreground`,children:(0,W.jsx)(g,{className:`size-5`})}),(0,W.jsx)(`h2`,{className:`mt-4 text-sm font-bold`,children:e?`No matching memories`:`Build your memory graph`}),(0,W.jsx)(`p`,{className:`mt-1 max-w-xs text-xs leading-5 text-muted-foreground`,children:e?`Change the filters or clear the search query.`:`Capture durable facts, decisions, conventions, and file-bound notes for every agent.`}),(0,W.jsxs)(M,{className:`mt-4`,variant:`outline`,size:`sm`,onClick:e?n:t,children:[e?(0,W.jsx)(te,{className:`size-3.5`}):(0,W.jsx)(x,{className:`size-3.5`}),e?`Clear filters`:`Create first memory`]})]})}function Z({memory:e,isSelected:n,onClick:r}){return(0,W.jsxs)(`button`,{type:`button`,"aria-current":n?`true`:void 0,onClick:r,className:j(`group relative block w-full border-b border-border/55 px-3 py-3 text-left transition-[background-color,border-color] hover:bg-info/5`,n&&`bg-info/8`),children:[n&&(0,W.jsx)(`span`,{className:`absolute inset-y-0 left-0 w-0.5 bg-info shadow-[0_0_10px_hsl(var(--info)/0.7)]`}),(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.jsx)(`span`,{className:j(`truncate text-[10px] font-bold uppercase tracking-[0.1em]`,I(e.kind)),children:V[e.kind]??e.kind}),(0,W.jsx)(R,{status:e.status}),(0,W.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono text-[9px] text-muted-foreground`,children:[`r`,e.revision]})]}),(0,W.jsx)(`p`,{className:j(`mt-2 line-clamp-2 text-xs leading-5 text-foreground/90`,e.status===`deleted`&&`line-through opacity-60`),children:Ne(e.text)}),(0,W.jsxs)(`div`,{className:`mt-2 flex min-w-0 items-center gap-1.5`,children:[(0,W.jsx)(`span`,{className:`border border-border/60 bg-background/50 px-1.5 py-0.5 font-mono text-[9px] uppercase text-muted-foreground`,children:e.scope}),e.audience&&(0,W.jsxs)(`span`,{className:`flex items-center gap-0.5 border border-primary/30 bg-primary/10 px-1.5 py-0.5 font-mono text-[9px] text-primary`,children:[(0,W.jsx)(t,{className:`size-2.5`}),(e.audience.roles??e.audience.taskTypes??e.audience.modes??[]).slice(0,1)[0]??`scoped`]}),e.tags.slice(0,2).map(e=>(0,W.jsxs)(`span`,{className:`max-w-24 truncate border border-border/60 px-1.5 py-0.5 font-mono text-[9px] text-muted-foreground`,children:[`#`,e]},e)),e.tags.length>2&&(0,W.jsxs)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:[`+`,e.tags.length-2]}),(0,W.jsx)(`span`,{className:`ml-auto shrink-0 text-[9px] text-muted-foreground`,children:ze(e.updatedAt)}),(0,W.jsx)(he,{className:`size-3 shrink-0 text-muted-foreground transition-transform group-hover:translate-x-0.5 group-hover:text-info`})]})]})}function pt(){let{client:e,listSuperMemoriesPage:r,rememberSuperMemory:i,updateSuperMemory:o,deleteSuperMemory:s,getSuperMemoryGraph:c,recoverSuperMemory:l,resolveMemoryCandidate:u}=_e(),d=ye(e=>e.wsConnected),f=ge(e=>e.setCurrentView),p=De(`memory`),[h,g]=(0,U.useState)([]),[_,v]=(0,U.useState)(null),[y,te]=(0,U.useState)(!0),[ne,b]=(0,U.useState)(!1),[S,C]=(0,U.useState)(null),[w,T]=(0,U.useState)(null),[E,D]=(0,U.useState)(null),[O,k]=(0,U.useState)(null),[ae,oe]=(0,U.useState)([]),[se,ce]=(0,U.useState)([]),[le,ue]=(0,U.useState)(null),[fe,pe]=(0,U.useState)(!1),[he,A]=(0,U.useState)(!1),[ve,N]=(0,U.useState)(!1),[P,Ee]=(0,U.useState)(Me),[ke,Ae]=(0,U.useState)(Me),[F,I]=(0,U.useState)(null),[L,R]=(0,U.useState)(null),[z,Pe]=(0,U.useState)(``),[B,Fe]=(0,U.useState)(`all`),[V,Le]=(0,U.useState)(`all`),[Re,ze]=(0,U.useState)(!1),[G,Be]=(0,U.useState)(null),[K,Ve]=(0,U.useState)(!1),[He,Ue]=(0,U.useState)(null),[We,Ge]=(0,U.useState)(!1),[Ke,qe]=(0,U.useState)(!1),[Je,Xe]=(0,U.useState)({}),[Ze,Qe]=(0,U.useState)(!1),[$e,et]=(0,U.useState)(null),[tt,nt]=(0,U.useState)(void 0),[rt,it]=(0,U.useState)(void 0),at=(0,U.useRef)(!1),q=(0,U.useRef)(!0),ot=(0,U.useRef)(0),J=(0,U.useRef)(0),Y=(0,U.useRef)(null),X=(0,U.useRef)(null),ft=(0,U.useMemo)(()=>JSON.stringify(P)!==JSON.stringify(ke),[ke,P]),Z=(0,U.useMemo)(()=>h.find(e=>e.id===O)??null,[h,O]),pt=(0,U.useCallback)(t=>{let n=t!==null,i=++ot.current;Y.current?.(),C(null),n?qe(!0):(b(!0),at.current||te(!0));let a=()=>{},o=null,s=!1,c=()=>{s||(s=!0,o!==null&&clearTimeout(o),a(),Y.current===c&&(Y.current=null))};a=e.on(`memory.super.listPage`,e=>{if(i!==ot.current||!q.current){c();return}if(c(),e.payload.error)C(e.payload.error);else{let t=e.payload.memories??[];g(e=>n?[...e,...t]:t),Ue(e.payload.nextCursor??null),Ge(!!e.payload.nextCursor);let r=e.payload.statusCounts??{};Xe(r);let i=Object.values(r).reduce((e,t)=>e+t,0);e.payload.stats?v(e.payload.stats):v(e=>({total:i,byStatus:r,byKind:e?.byKind??{},edges:e?.edges??0})),at.current=!0,n||k(e=>e&&t.some(t=>t.id===e)?e:null)}te(!1),b(!1),qe(!1)}),o=setTimeout(()=>{i!==ot.current||!q.current||(c(),C(`The memory store did not respond. Check the WebSocket connection and try again.`),te(!1),b(!1),qe(!1))},2e4),Y.current=c,r({limit:100,...K?{statuses:[`deleted`]}:{},...t?{cursor:t}:{}},{echoToChat:!1})},[e,r,K]),Q=(0,U.useCallback)(()=>{Ue(null),Ge(!1),pt(null)},[pt]),ht=(0,U.useCallback)(()=>{Ke||!He||pt(He)},[pt,Ke,He]);(0,U.useEffect)(()=>(q.current=!0,Q(),()=>{q.current=!1,ot.current+=1,J.current+=1,Y.current?.(),X.current?.()}),[Q]),(0,U.useEffect)(()=>{if(oe([]),ce([]),ue(null),!O){pe(!1);return}let t=O;pe(!0);let n=null,r=e.on(`memory.super.graph`,e=>{e.payload.query===t&&(n!==null&&clearTimeout(n),oe(e.payload.edges??[]),ce(e.payload.memories??[]),ue(e.payload.error??null),pe(!1))});return n=setTimeout(()=>{ue(`Relationship graph did not respond in time.`),pe(!1)},15e3),c(t,{maxDepth:1,limit:120},{echoToChat:!1}),()=>{n!==null&&clearTimeout(n),r()}},[e,c,O]);let gt=(0,U.useRef)(d);(0,U.useEffect)(()=>{d&&!gt.current&&at.current&&Q(),gt.current=d},[Q,d]),(0,U.useEffect)(()=>{if(!E)return;let e=setTimeout(()=>D(null),4e3);return()=>clearTimeout(e)},[E]);let _t=(0,U.useCallback)(()=>!ft||!he&&!ve||window.confirm(`Discard the unsaved memory changes?`),[ve,ft,he]),vt=(0,U.useCallback)(()=>{if(!_t())return;let e=Me();Ee(e),Ae(e),N(!0),A(!1),k(null),T(null)},[_t]),yt=(0,U.useCallback)(e=>{_t()&&(k(e),N(!1),A(!1),T(null))},[_t]),bt=(0,U.useCallback)(()=>{if(!Z||Z.status===`deleted`)return;let e=je(Z);Ee(e),Ae(e),A(!0),N(!1),T(null)},[Z]),xt=(0,U.useCallback)(()=>{_t()&&(A(!1),N(!1),T(null))},[_t]),St=(0,U.useCallback)((t,n,r)=>{if(!P.text.trim()){T(`Memory content is required.`);return}let i=++J.current;X.current?.(),I(r),T(null),D(null);let a=()=>{},o=null,s=!1,c=()=>{s||(s=!0,o!==null&&clearTimeout(o),a(),X.current===c&&(X.current=null))},l=e=>{if(i!==J.current||!q.current){c();return}if(c(),I(null),e.payload.error||!e.payload.memory){T(e.payload.error??`The server returned no memory record.`);return}let t=e.payload.memory;g(e=>{let n=e.filter(e=>e.id!==t.id);return[t,...n]}),k(t.id),N(!1),A(!1),D(r===`create`?`Memory captured.`:`Memory updated.`),Q()};a=t===`memory.super.remember`?e.on(`memory.super.remember`,l):e.on(`memory.super.update`,l),o=setTimeout(()=>{i!==J.current||!q.current||(c(),I(null),T(`${r===`create`?`Create`:`Save`} timed out. Your draft is still here.`))},2e4),X.current=c,n()},[e,P.text,Q]),Ct=(0,U.useCallback)(()=>{St(`memory.super.remember`,()=>i({text:P.text.trim(),kind:P.kind,scope:P.scope,tags:H(P.tags),importance:P.importance,confidence:P.confidence,freshness:P.freshness,anchors:Oe(P.anchors),...H(P.audienceRoles).length||H(P.audienceTaskTypes).length||H(P.audienceModes).length?{audience:{roles:H(P.audienceRoles),taskTypes:H(P.audienceTaskTypes),modes:H(P.audienceModes)}}:{},supersedes:H(P.supersedes),contradicts:H(P.contradicts)},{echoToChat:!1}),`create`)},[P,i,St]),wt=(0,U.useCallback)(()=>{Z&&St(`memory.super.update`,()=>o(Z.id,{text:P.text.trim(),kind:P.kind,status:P.status,tags:H(P.tags),importance:P.importance,confidence:P.confidence,freshness:P.freshness,anchors:Oe(P.anchors),...H(P.audienceRoles).length||H(P.audienceTaskTypes).length||H(P.audienceModes).length?{audience:{roles:H(P.audienceRoles),taskTypes:H(P.audienceTaskTypes),modes:H(P.audienceModes)}}:{},supersedes:H(P.supersedes),contradicts:H(P.contradicts)},{echoToChat:!1}),`update`)},[P,St,Z,o]),Tt=(0,U.useCallback)(()=>{if(!L)return;let t=++J.current;X.current?.(),I(`delete`),T(null);let n=()=>{},r=null,i=!1,a=()=>{i||(i=!0,r!==null&&clearTimeout(r),n(),X.current===a&&(X.current=null))};n=e.on(`memory.super.delete`,e=>{if(t!==J.current||!q.current){a();return}if(a(),I(null),!e.payload.success){T(e.payload.message||`Delete failed.`);return}R(null),k(null),A(!1),D(`Memory deleted and relationship edges cleaned up.`),Q()}),r=setTimeout(()=>{t!==J.current||!q.current||(a(),I(null),T(`Delete timed out. The memory may still exist; refresh to confirm.`))},2e4),X.current=a,s(L,`Deleted from the WebUI Memory Manager.`)},[e,s,L,Q]),Et=(0,U.useMemo)(()=>{let e=z.trim().toLowerCase();return h.filter(t=>{if(B!==`all`&&t.status!==B||V!==`all`&&t.kind!==V||G&&!t.tags.includes(G)||Re&&!t.audience)return!1;if(!e)return!0;let n=t.anchors.map(e=>[e.path,e.symbol,e.command].filter(Boolean).join(` `)).join(` `),r=t.audience?[t.audience.roles?.join(` `)??``,t.audience.taskTypes?.join(` `)??``,t.audience.modes?.join(` `)??``].join(` `):``;return[t.id,t.text,t.summary??``,t.kind,t.scope,t.tags.join(` `),n,r].join(` `).toLowerCase().includes(e)})},[Re,V,h,z,B,G]),Dt=(0,U.useMemo)(()=>{let e=new Map;for(let t of h)for(let n of t.tags)e.set(n,(e.get(n)??0)+1);return[...e.entries()].sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0]))},[h]),Ot=(0,U.useMemo)(()=>{if(!Z)return[];let e=[];Z.supersededBy&&e.push({relation:`Superseded by`,id:Z.supersededBy});for(let t of Z.supersedes??[])e.push({relation:`Supersedes`,id:t});for(let t of Z.contradicts??[])e.push({relation:`Contradicts`,id:t});return e},[Z]),kt=(0,U.useCallback)(()=>{Pe(``),Fe(`all`),Le(`all`),ze(!1),Be(null)},[]),At=!!(z||B!==`all`||V!==`all`||G||Re),jt=ve||!!Z,$=Ze&&!!$e;return y&&h.length===0?(0,W.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-background`,"aria-busy":`true`,children:[(0,W.jsxs)(`div`,{className:`border-b border-border/70 bg-card/70 px-5 py-4`,children:[(0,W.jsx)(`div`,{className:`h-3 w-28 animate-pulse bg-muted`}),(0,W.jsx)(`div`,{className:`mt-3 h-7 w-56 animate-pulse bg-muted`})]}),(0,W.jsxs)(`div`,{className:`grid flex-1 gap-px bg-border/60 md:grid-cols-[minmax(300px,0.82fr)_minmax(0,1.35fr)]`,children:[(0,W.jsx)(`div`,{className:`space-y-px bg-background p-4`,children:Array.from({length:7},(e,t)=>(0,W.jsx)(`div`,{className:`h-24 animate-pulse border border-border/60 bg-card/45`},t))}),(0,W.jsx)(`div`,{className:`hidden bg-background p-6 md:block`,children:(0,W.jsx)(`div`,{className:`h-full animate-pulse border border-border/60 bg-card/35`})})]}),(0,W.jsx)(`span`,{className:`sr-only`,role:`status`,children:`Loading Super Memory content`})]}):S&&h.length===0?(0,W.jsx)(`div`,{className:`flex h-full min-h-0 items-center justify-center bg-background p-6`,children:(0,W.jsxs)(`div`,{className:`max-w-md border border-destructive/35 bg-card p-6 shadow-2xl`,children:[(0,W.jsx)(`span`,{className:`flex size-11 items-center justify-center border border-destructive/35 bg-destructive/10 text-destructive`,children:(0,W.jsx)(re,{className:`size-5`})}),(0,W.jsx)(`h2`,{className:`mt-4 text-lg font-bold`,children:`Memory store unavailable`}),(0,W.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-muted-foreground`,children:S}),(0,W.jsxs)(`div`,{className:`mt-5 flex gap-2`,children:[(0,W.jsxs)(M,{onClick:Q,children:[(0,W.jsx)(de,{className:`size-4`}),` Retry`]}),(0,W.jsxs)(M,{variant:`outline`,onClick:()=>f(`chat`),children:[(0,W.jsx)(m,{className:`size-4`}),` Back to chat`]})]})]})}):(0,W.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-background`,children:[(0,W.jsxs)(`header`,{className:`relative shrink-0 overflow-hidden border-b border-border/70 bg-card/72 px-4 py-3 backdrop-blur-xl sm:px-5`,children:[(0,W.jsx)(`div`,{className:`pointer-events-none absolute inset-y-0 right-0 w-1/2 bg-[radial-gradient(circle_at_right,hsl(var(--info)/0.11),transparent_68%)]`}),(0,W.jsxs)(`div`,{className:`relative flex flex-wrap items-center gap-3`,children:[(0,W.jsx)(M,{variant:`ghost`,size:`icon`,onClick:()=>f(`chat`),"aria-label":`Back to chat`,title:`Back to chat`,children:(0,W.jsx)(m,{className:`size-4`})}),(0,W.jsx)(`span`,{className:`flex size-10 items-center justify-center border border-info/40 bg-info/10 text-info shadow-[0_0_20px_hsl(var(--info)/0.12)]`,children:(0,W.jsx)(t,{className:`size-5`})}),(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`h1`,{className:`text-base font-bold sm:text-lg`,children:`Super Memory`}),(0,W.jsx)(`span`,{className:`border border-success/35 bg-success/10 px-2 py-0.5 font-mono text-[9px] font-bold uppercase text-success`,children:`project knowledge`})]}),(0,W.jsx)(`p`,{className:`mt-0.5 max-w-2xl text-[10px] text-muted-foreground sm:text-xs`,children:`Inspect, connect, curate, and retire durable context used across agent sessions.`})]}),(0,W.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,W.jsxs)(`span`,{className:j(`hidden items-center gap-1.5 border px-2 py-1 font-mono text-[9px] uppercase sm:flex`,d?`border-success/30 text-success`:`border-warning/30 text-warning`),children:[(0,W.jsx)(`span`,{className:`size-1.5 bg-current`}),` `,d?`live store`:`reconnecting`]}),(0,W.jsxs)(M,{variant:`outline`,size:`sm`,onClick:Q,disabled:ne,"aria-label":`Refresh memories`,children:[(0,W.jsx)(de,{className:j(`size-3.5`,ne&&`animate-spin`)}),(0,W.jsx)(`span`,{className:`hidden sm:inline`,children:`Refresh`})]}),(0,W.jsxs)(M,{size:`sm`,onClick:vt,children:[(0,W.jsx)(x,{className:`size-3.5`}),` New memory`]})]})]})]}),(0,W.jsxs)(`div`,{className:`grid shrink-0 grid-cols-2 gap-px border-b border-border/70 bg-border/60 sm:grid-cols-4`,children:[(0,W.jsx)(Ie,{label:`Memories`,value:_?.total??h.length,hint:`${Et.length} visible`}),(0,W.jsx)(Ie,{label:`Active`,value:_?.byStatus.active??h.filter(e=>e.status===`active`).length,hint:`retrievable`,tone:`success`}),(0,W.jsx)(Ie,{label:`Needs review`,value:(_?.byStatus.stale??0)+(_?.byStatus.contradicted??0),hint:`stale + conflicts`,tone:`warning`}),(0,W.jsx)(`div`,{className:`hidden sm:block`,children:(0,W.jsx)(Ie,{label:`Graph edges`,value:_?.edges??0,hint:`${Dt.length} tags`,tone:`info`})})]}),(0,W.jsx)(ut,{}),(()=>{let e=h.filter(e=>e.audience).length;if(e===0)return null;let n=new Set;for(let e of h)if(e.audience){for(let t of e.audience.roles??[])n.add(t);for(let t of e.audience.taskTypes??[])n.add(t);for(let t of e.audience.modes??[])n.add(t)}return(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-border/70 bg-primary/5 px-4 py-1.5`,children:[(0,W.jsx)(t,{className:`size-3.5 text-primary`}),(0,W.jsxs)(`span`,{className:`text-[11px] font-medium text-primary`,children:[e,` audience-scoped memory`,e===1?``:`ies`]}),n.size>0&&(0,W.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`(`,[...n].sort().join(`, `),`)`]})]})})(),(E||S||w)&&(0,W.jsxs)(`div`,{className:`shrink-0 border-b border-border/70 px-4 py-2`,"aria-live":`polite`,children:[E&&(0,W.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2 text-xs text-success`,children:[(0,W.jsx)(me,{className:`size-3.5`}),` `,E]}),S&&(0,W.jsxs)(`div`,{role:`alert`,className:`flex items-center gap-2 text-xs text-warning`,children:[(0,W.jsx)(re,{className:`size-3.5`}),` `,S,` Existing content remains available.`]}),w&&!he&&!ve&&(0,W.jsxs)(`div`,{role:`alert`,className:`flex items-center gap-2 text-xs text-destructive`,children:[(0,W.jsx)(re,{className:`size-3.5`}),` `,w]})]}),(0,W.jsxs)(`div`,{className:`grid min-h-0 flex-1 md:grid-cols-[minmax(320px,0.82fr)_minmax(0,1.35fr)]`,children:[(0,W.jsxs)(`section`,{className:j(`min-h-0 border-r border-border/70 bg-card/25`,jt?`hidden md:flex md:flex-col`:`flex flex-col`),"aria-label":`Memory library`,children:[(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-border/60 px-3 py-1.5`,children:[(0,W.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:`File drawer`}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsxs)(`select`,{value:$e??``,onChange:e=>{let t=e.target.value||null;et(t),t&&Qe(!0)},className:`max-w-[180px] truncate rounded-sm border border-border/60 bg-background px-1.5 py-0.5 text-[10px] font-mono`,"aria-label":`File for memory drawer`,"data-testid":`memory-drawer-file-select`,children:[(0,W.jsx)(`option`,{value:``,children:`— select a file —`}),h.flatMap(e=>e.anchors??[]).filter(e=>e.type===`file`&&e.path).map((e,t)=>(0,W.jsx)(`option`,{value:e.path,children:e.path},`${e.path}-${t}`))]}),(0,W.jsxs)(M,{type:`button`,size:`sm`,variant:$?`default`:`outline`,onClick:()=>{$e&&Qe(e=>!e)},disabled:!$e,className:`h-7 gap-1 px-2 text-[11px]`,"aria-pressed":$,title:$?`Hide file memory drawer`:`Show file memory drawer`,children:[$?(0,W.jsx)(ie,{className:`size-3`}):(0,W.jsx)(ee,{className:`size-3`}),$?`Hide`:`Show`,` drawer`]})]})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 border-b border-border/60 px-3 pt-1`,role:`tablist`,"aria-label":`Memory view`,children:[(0,W.jsx)(M,{type:`button`,variant:`ghost`,size:`sm`,role:`tab`,"aria-selected":!K,onClick:()=>{K&&Ve(!1)},className:j(`h-7 rounded-b-none border-b-2 px-3 text-[11px]`,K?`border-transparent text-muted-foreground`:`border-primary text-foreground`),children:`Active`}),(0,W.jsxs)(M,{type:`button`,variant:`ghost`,size:`sm`,role:`tab`,"aria-selected":K,onClick:()=>{K||Ve(!0)},className:j(`h-7 rounded-b-none border-b-2 px-3 text-[11px]`,K?`border-primary text-foreground`:`border-transparent text-muted-foreground`),children:[`Deleted`,typeof Je.deleted==`number`?` (${Je.deleted})`:``]})]}),(0,W.jsx)(lt,{searchQuery:z,statusFilter:B,kindFilter:V,audienceOnly:Re,tagFilter:G,hasFilters:At,allTags:Dt,stats:_,onSearchChange:Pe,onStatusFilterChange:Fe,onKindFilterChange:Le,onToggleAudienceOnly:()=>ze(e=>!e),onTagFilterChange:Be,onClearFilters:kt}),(0,W.jsx)(dt,{memoryListRef:p,memories:h,filteredMemories:Et,selectedId:O,onSelectMemory:yt,onOpenCreate:vt,onClearFilters:kt}),We?(0,W.jsx)(`div`,{className:`shrink-0 border-t border-border/60 p-2`,children:(0,W.jsx)(M,{type:`button`,variant:`outline`,size:`sm`,onClick:ht,disabled:Ke,className:`h-7 w-full text-[11px]`,children:Ke?`Loading…`:`Load more (${h.length} loaded)`})}):null]}),(0,W.jsx)(`section`,{className:j(`min-h-0 bg-background`,jt?`flex flex-col`:`hidden md:flex md:flex-col`),"aria-label":`Memory detail`,children:ve?(0,W.jsx)(ct,{mode:`create`,draft:P,busy:F===`create`,error:w,onChange:Ee,onCancel:xt,onSubmit:Ct}):Z?he?(0,W.jsx)(ct,{mode:`edit`,draft:P,busy:F===`update`,error:w,onChange:Ee,onCancel:xt,onSubmit:wt}):$?(0,W.jsx)(st,{filePath:$e,lineStart:tt,lineEnd:rt,open:$,onClose:()=>Qe(!1),onShowMemory:e=>k(e),onAcceptDeletion:async(e,t)=>{u({candidateId:e,action:`accept`}),D(`Accepted hygiene review for ${t.slice(0,12)}… (candidate ${e.slice(0,12)}…).`),setTimeout(()=>{Q()},500)},onKeep:async(e,t)=>{u({candidateId:e,action:`reject`}),D(`Kept ${t.slice(0,12)}… (candidate ${e.slice(0,12)}… rejected).`)},onUpdate:e=>{k(e),bt()},onMarkPermanent:async e=>{I(`update`);try{await o(e,{persistence:`permanent`}),D(`Memory ${e.slice(0,12)}… promoted to permanent.`),await Q()}catch(e){T(e instanceof Error?e.message:String(e))}finally{I(null)}},onRecover:async e=>{l({id:e,reason:`recovered via file drawer`}),D(`Recovered ${e.slice(0,12)}…`),setTimeout(()=>{Q()},500)}}):(0,W.jsx)(Ye,{memory:Z,allMemories:[...h,...se],relatedMemories:Ot,graphEdges:ae,graphLoading:fe,graphError:le,onClose:()=>k(null),onOpenMemory:yt,onEdit:bt,onDelete:()=>R(Z.id),onTagSelect:e=>{Be(e),k(null)},onNotice:D}):(0,W.jsx)(mt,{onCapture:vt})})]}),(0,W.jsx)(Te,{open:!!L,onOpenChange:e=>{!e&&F!==`delete`&&R(null)},children:(0,W.jsxs)(Se,{className:`max-w-md`,children:[(0,W.jsxs)(be,{children:[(0,W.jsx)(`span`,{className:`mb-2 flex size-10 items-center justify-center border border-destructive/35 bg-destructive/10 text-destructive`,children:(0,W.jsx)(a,{className:`size-4`})}),(0,W.jsx)(Ce,{children:`Delete this memory?`}),(0,W.jsx)(we,{className:`leading-6`,children:`Super Memory will mark the record deleted, remove graph edges, and clean references from related memories. The record remains in the audit trail but cannot be restored from this page.`})]}),(0,W.jsx)(`div`,{className:`border border-border/70 bg-background/45 p-3 text-xs text-muted-foreground`,children:Ne(h.find(e=>e.id===L)?.text??``,180)}),(0,W.jsxs)(xe,{children:[(0,W.jsx)(M,{variant:`outline`,onClick:()=>R(null),disabled:F===`delete`,children:`Cancel`}),(0,W.jsxs)(M,{variant:`destructive`,onClick:Tt,disabled:F===`delete`,children:[F===`delete`?(0,W.jsx)(n,{className:`size-4 animate-spin`}):(0,W.jsx)(a,{className:`size-4`}),F===`delete`?`Deleting…`:`Delete memory`]})]})]})})]})}function mt({onCapture:e}){return(0,W.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center p-8 text-center`,children:[(0,W.jsxs)(`div`,{className:`relative flex size-20 items-center justify-center border border-info/25 bg-info/5 text-info`,children:[(0,W.jsx)(t,{className:`size-8`}),(0,W.jsx)(`span`,{className:`absolute inset-2 border border-info/10`})]}),(0,W.jsx)(`h2`,{className:`mt-5 text-lg font-bold`,children:`Your project’s long-term context`}),(0,W.jsx)(`p`,{className:`mt-2 max-w-md text-sm leading-6 text-muted-foreground`,children:`Select a memory to inspect its metadata and relationship graph, or capture knowledge that future agents should retrieve automatically.`}),(0,W.jsxs)(`div`,{className:`mt-6 grid w-full max-w-lg gap-2 sm:grid-cols-3`,children:[(0,W.jsxs)(`div`,{className:`border border-border/70 bg-card/45 p-3`,children:[(0,W.jsx)(me,{className:`mx-auto size-4 text-success`}),(0,W.jsx)(`p`,{className:`mt-2 text-[10px] font-bold uppercase`,children:`Verified anchors`})]}),(0,W.jsxs)(`div`,{className:`border border-border/70 bg-card/45 p-3`,children:[(0,W.jsx)(t,{className:`mx-auto size-4 text-info`}),(0,W.jsx)(`p`,{className:`mt-2 text-[10px] font-bold uppercase`,children:`Typed relations`})]}),(0,W.jsxs)(`div`,{className:`border border-border/70 bg-card/45 p-3`,children:[(0,W.jsx)(x,{className:`mx-auto size-4 text-warning`}),(0,W.jsx)(`p`,{className:`mt-2 text-[10px] font-bold uppercase`,children:`Agent recall`})]})]}),(0,W.jsxs)(M,{onClick:e,children:[(0,W.jsx)(x,{className:`size-4`}),` Capture memory`]})]})}export{pt as MemoryManager};