@wrongstack/webui 1.0.19 → 1.0.24

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 (132) hide show
  1. package/dist/assets/{AgentRosterView-D4TuVXe8.js → AgentRosterView-Dq8Xa0WK.js} +4 -4
  2. package/dist/assets/{AnalyticsDashboard-DmQd0E0V.js → AnalyticsDashboard-DgqJODVI.js} +1 -1
  3. package/dist/assets/{AudienceMemoryPanel-DHJM4rf1.js → AudienceMemoryPanel-BVGdDVTT.js} +1 -1
  4. package/dist/assets/{ChangesView-CZ-nCe26.js → ChangesView-BVyLENBb.js} +1 -1
  5. package/dist/assets/ChimeraReviewsView-CTuxzgTC.js +1 -0
  6. package/dist/assets/ChronicleDashboard-BRP7D6RZ.js +1 -0
  7. package/dist/assets/{CodeEditor-CLscjkIR.js → CodeEditor-k3z3M0NG.js} +1 -1
  8. package/dist/assets/{CodeMap-CdVy9Q7V.js → CodeMap-CvHNQZEF.js} +1 -1
  9. package/dist/assets/{CronJobsPanel-TcZy_W2t.js → CronJobsPanel-GTK038V9.js} +1 -1
  10. package/dist/assets/{DeadCodeScanPanel-BOD2JEyf.js → DeadCodeScanPanel-DX4OEuyp.js} +1 -1
  11. package/dist/assets/{DebugDashboard-DFPNPzQ_.js → DebugDashboard-CKp3sa_k.js} +1 -1
  12. package/dist/assets/{DesignGalleryView-BXABwAji.js → DesignGalleryView-DVUTYaP6.js} +1 -1
  13. package/dist/assets/{GoalView-Cepqrg9l.js → GoalView-D8G8e8YG.js} +1 -1
  14. package/dist/assets/{KanbanView-FSePkLch.js → KanbanView-BMXGDqGo.js} +2 -2
  15. package/dist/assets/{MailboxDetailView-QyNmt1Gv.js → MailboxDetailView-CylnzTVc.js} +1 -1
  16. package/dist/assets/{MemoryDrawer-BZsyD1dh.js → MemoryDrawer-DJ0Y98Z8.js} +1 -1
  17. package/dist/assets/{MemoryManager-IHmhWn4P.js → MemoryManager-DfcsYPUB.js} +1 -1
  18. package/dist/assets/{ProcessMonitor-Bz0jZvHJ.js → ProcessMonitor-BnQ3vJtn.js} +1 -1
  19. package/dist/assets/{PromptJournalView-Ct8cLcGU.js → PromptJournalView-D7k8Yh5a.js} +1 -1
  20. package/dist/assets/{ProviderTestView-Dy3k2bVu.js → ProviderTestView-DSd6kkWT.js} +1 -1
  21. package/dist/assets/{QueuePanel-oVkTB68Q.js → QueuePanel-79KiyZWD.js} +1 -1
  22. package/dist/assets/{RefreshDebugView-_XPrBDq3.js → RefreshDebugView-s6MyGpPq.js} +1 -1
  23. package/dist/assets/{RepositoryHistoryView-Wlnvi5r1.js → RepositoryHistoryView-CWi_Zo3F.js} +1 -1
  24. package/dist/assets/{RequirementIntakeView-Cj5arGFF.js → RequirementIntakeView-D_Ea20fx.js} +1 -1
  25. package/dist/assets/{SageTabs-qrBn3VQr.js → SageTabs-D6eTg3ix.js} +2 -2
  26. package/dist/assets/SddFlowGraph-B-ptkFX6.js +1 -0
  27. package/dist/assets/SddHub-CSVfLGpr.js +2 -0
  28. package/dist/assets/{SessionInspectView-CuRk2DS0.js → SessionInspectView-NSpj5WEN.js} +1 -1
  29. package/dist/assets/{SessionList-BgRb1Mp4.js → SessionList-BYRCs1AK.js} +1 -1
  30. package/dist/assets/{SessionsDashboard-CSkm28Bx.js → SessionsDashboard-mF4PzdKY.js} +1 -1
  31. package/dist/assets/{SetupScreen-CNcJ_9O9.js → SetupScreen-BUZeJSZi.js} +1 -1
  32. package/dist/assets/SkillDetailView-B9BFyB1i.js +3 -0
  33. package/dist/assets/{TechStackView-BHiGCRBT.js → TechStackView-CXJilX0M.js} +2 -2
  34. package/dist/assets/{TerminalPanel-7VeXK8LB.js → TerminalPanel-CAXevSAa.js} +1 -1
  35. package/dist/assets/{activity-BVbAv0x7.js → activity-B3wutYIE.js} +4 -4
  36. package/dist/assets/activity-Be03cc7g.js +10 -0
  37. package/dist/assets/activity-CiYZ3y4e.js +10 -0
  38. package/dist/assets/activity-CmIA2MhR.js +10 -0
  39. package/dist/assets/activity-Cp5GhldB.js +10 -0
  40. package/dist/assets/activity-DFCf7l5d.js +10 -0
  41. package/dist/assets/{activity-Du_fOnvF.js → activity-EbNUY7Ci.js} +4 -4
  42. package/dist/assets/{chat-store-C-PKlsCR.js → chat-store-C7InoWAO.js} +1 -1
  43. package/dist/assets/common-Bjl7V12m.js +1 -0
  44. package/dist/assets/common-BtyQBZBN.js +1 -0
  45. package/dist/assets/common-D0QL7rwb.js +1 -0
  46. package/dist/assets/common-DJRPtYAt.js +1 -0
  47. package/dist/assets/common-DPPTV3yw.js +1 -0
  48. package/dist/assets/common-DvjdaRhB.js +1 -0
  49. package/dist/assets/common-opV6EoLd.js +1 -0
  50. package/dist/assets/config-store-BbL0WxLE.js +21 -0
  51. package/dist/assets/{i18n--QdD6NCn.js → i18n-Dv97urcO.js} +3 -3
  52. package/dist/assets/index-CON0Nbm4.css +1 -0
  53. package/dist/assets/index-DX6tHUzs.js +177 -0
  54. package/dist/assets/roster-ws-Cv_PHlEV.js +1 -0
  55. package/dist/assets/settings-BCvuzOJ6.js +1 -0
  56. package/dist/assets/settings-DMPKd-4K.js +1 -0
  57. package/dist/assets/settings-DxQ2452f.js +1 -0
  58. package/dist/assets/settings-Dz3StaVx.js +1 -0
  59. package/dist/assets/settings-EBW1mlXc.js +1 -0
  60. package/dist/assets/settings-Er2LHp9d.js +1 -0
  61. package/dist/assets/settings-EzznCDaX.js +1 -0
  62. package/dist/assets/stores-DXn5tdr7.js +7 -0
  63. package/dist/assets/ui-store-DxDwFHNK.js +1 -0
  64. package/dist/assets/{view-navigation-DTs4cSQ6.js → view-navigation-CpIPxhZp.js} +1 -1
  65. package/dist/components/ChatInput/skill-mention-picker.d.ts +10 -0
  66. package/dist/components/CustomRosterPanel.d.ts +0 -1
  67. package/dist/components/OfficeMapCanvas.d.ts +0 -7
  68. package/dist/components/SettingsPanel/BrainSection.d.ts +1 -1
  69. package/dist/components/SettingsPanel/JevSection.d.ts +4 -0
  70. package/dist/components/SettingsPanel/OAuthLoginSection.d.ts +2 -0
  71. package/dist/components/SettingsPanel/ProviderSection.d.ts +5 -5
  72. package/dist/components/SettingsPanel/brain-section-options.d.ts +1 -1
  73. package/dist/components/SettingsPanel/contracts.d.ts +1 -0
  74. package/dist/components/SettingsPanel/official-servers.d.ts +1 -0
  75. package/dist/components/SettingsPanel/use-brain-section.d.ts +28 -0
  76. package/dist/components/SkillDetailView.d.ts +1 -1
  77. package/dist/components/chronicle-event-detail.d.ts +51 -0
  78. package/dist/components/context-dashboard-sections.d.ts +79 -0
  79. package/dist/components/use-office-map-canvas.d.ts +42 -0
  80. package/dist/components/use-skill-detail.d.ts +177 -0
  81. package/dist/components/vector-memory-panel/model.d.ts +9 -0
  82. package/dist/hooks/useProviderModels.d.ts +2 -0
  83. package/dist/hooks/useWebSocket.d.ts +3 -3
  84. package/dist/hooks/ws-handlers/brain-handlers.d.ts +18 -0
  85. package/dist/hooks/ws-handlers/goal-handlers.d.ts +7 -0
  86. package/dist/hooks/ws-handlers/misc-handlers.d.ts +2 -21
  87. package/dist/index.html +9 -9
  88. package/dist/index.js +15497 -12864
  89. package/dist/lib/auth-operation.d.ts +5 -0
  90. package/dist/lib/sdd-theme.d.ts +2 -2
  91. package/dist/lib/ws-client-actions.d.ts +2 -0
  92. package/dist/lib/ws-client-domain-methods.d.ts +1 -1
  93. package/dist/lib/ws-client-session-methods.d.ts +1 -1
  94. package/dist/lib/ws-client.d.ts +0 -3
  95. package/dist/stores/council-log-store.d.ts +4 -0
  96. package/dist/stores/ui-store-types.d.ts +1 -1
  97. package/dist/types/client-message.d.ts +13 -0
  98. package/dist/types/jev.d.ts +62 -0
  99. package/dist/types/runtime.d.ts +5 -3
  100. package/dist/types/server-message-system.d.ts +4 -0
  101. package/dist/types/system.d.ts +2 -0
  102. package/package.json +10 -10
  103. package/dist/assets/ChimeraReviewsView-CNeRLesP.js +0 -1
  104. package/dist/assets/ChronicleDashboard-CYELq7EO.js +0 -1
  105. package/dist/assets/SddFlowGraph-DS8R2zEj.js +0 -1
  106. package/dist/assets/SddHub-C8pHQYSM.js +0 -2
  107. package/dist/assets/SkillDetailView-Bc9owpaX.js +0 -3
  108. package/dist/assets/activity-1wlPY6yi.js +0 -10
  109. package/dist/assets/activity-BmJTU8kX.js +0 -10
  110. package/dist/assets/activity-By_aWEsY.js +0 -10
  111. package/dist/assets/activity-Cps_29WN.js +0 -10
  112. package/dist/assets/activity-p_2o4eC6.js +0 -10
  113. package/dist/assets/common-BXosnbIt.js +0 -1
  114. package/dist/assets/common-CzfPgMjC.js +0 -1
  115. package/dist/assets/common-DDDPz7Dv.js +0 -1
  116. package/dist/assets/common-DYx9oSoC.js +0 -1
  117. package/dist/assets/common-DZ-05t4z.js +0 -1
  118. package/dist/assets/common-MjX8fcng.js +0 -1
  119. package/dist/assets/common-ipsuLC3n.js +0 -1
  120. package/dist/assets/config-store-xSv1mChc.js +0 -21
  121. package/dist/assets/index-DiX5j910.css +0 -1
  122. package/dist/assets/index-FWwLmwjx.js +0 -177
  123. package/dist/assets/roster-ws-CxKDc-ET.js +0 -1
  124. package/dist/assets/settings-B5Jy-ObI.js +0 -1
  125. package/dist/assets/settings-BXTJJ4n-.js +0 -1
  126. package/dist/assets/settings-BcXAVecM.js +0 -1
  127. package/dist/assets/settings-ByPfZHGm.js +0 -1
  128. package/dist/assets/settings-CCe4iHcn.js +0 -1
  129. package/dist/assets/settings-D2GLiaDO.js +0 -1
  130. package/dist/assets/settings-gB9nKL3f.js +0 -1
  131. package/dist/assets/stores-2kakt8j9.js +0 -7
  132. package/dist/assets/ui-store-DC3mkswy.js +0 -1
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-core-wiHys0m2.js";import{Bn as r,Dn as i,En as a,Er as o,Fn as s,Ht as c,Mt as l,Ta as u,Ti as d,Xa as f,ba as p,ha as m,jr as h,ri as g,rn as _,so as v,ua as y,wo as b,xo as x,yr as S}from"./vendor-V3ydTHqN.js";import"./i18n--QdD6NCn.js";import{t as C}from"./utils-CKsqCaP8.js";import{o as w}from"./view-navigation-DTs4cSQ6.js";import{t as T}from"./mailbox-store-ZQO_Rv6E.js";import{n as E}from"./ui-store-DC3mkswy.js";import{o as D,x as O}from"./index-FWwLmwjx.js";import{t as k}from"./empty-state-pfuS5znr.js";var A=e(t(),1),j=n(),M={note:d,ask:p,assign:a,steer:s,btw:f,broadcast:a,status:m,result:u,review:i},N={high:`border-destructive/25 bg-destructive/10 text-destructive`,normal:`border-border bg-muted text-muted-foreground`,low:`border-primary/20 bg-primary/10 text-primary`};function P(e){return new Date(e).toLocaleString()}function F(e){let t=new Date(e),n=Date.now()-t.getTime();return n<6e4?b.t(`common:time.justNow`):n<36e5?b.t(`common:time.minutesAgo`,{count:Math.round(n/6e4)}):n<864e5?b.t(`common:time.hoursAgo`,{count:Math.round(n/36e5)}):n<6048e5?b.t(`common:time.daysAgo`,{count:Math.round(n/864e5)}):t.toLocaleDateString()}function I({readBy:e}){let{t}=x(),n=Object.entries(e);return n.length===0?null:(0,j.jsxs)(`div`,{className:`space-y-1`,children:[(0,j.jsx)(`div`,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wide`,children:t(`activity:mailbox.readBy`)}),(0,j.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:n.map(([e,t])=>(0,j.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] bg-success/10 text-success`,title:P(t),children:[(0,j.jsx)(u,{className:`h-2.5 w-2.5`}),e]},e))})]})}function L({className:e}){let{t}=x(),n=E(e=>e.selectedMailMessage),i=E(e=>e.setSelectedMailMessage);(0,A.useEffect)(()=>()=>{i(null)},[i]);function a(){i(null),w(`chat`)}if(!n)return(0,j.jsx)(k,{icon:(0,j.jsx)(o,{className:`h-6 w-6`}),title:t(`activity:mailbox.emptyDetail`),description:t(`activity:mailbox.emptyDetailHint`)});let s=M[n.type]??S,d=t(`activity:mailbox.type.${n.type}`,{defaultValue:n.type}),f=N[n.priority]??N.normal,p=n.scope?{scope:n.scope,recipientSessionId:n.recipientSessionId}:T(n.to),m=n.to===`*`||n.to===`all`?t(`activity:mailbox.everyone`):n.to,b=p.scope===`session`?t(`activity:mailbox.sessionScope`,{sid:p.recipientSessionId??``}):p.scope===`project`?t(`activity:mailbox.projectScope`):t(`activity:mailbox.directScope`);return(0,j.jsx)(`div`,{className:C(`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-[hsl(var(--surface-2)/0.45)] p-3`,e),children:(0,j.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-border/70 bg-card/75 shadow-sm`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-border/70 px-3 py-3 sm:px-4 shrink-0`,children:[(0,j.jsx)(`button`,{type:`button`,onClick:a,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md border border-border/70 bg-background/60 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,title:t(`activity:mailbox.backToChat`),children:(0,j.jsx)(v,{className:`h-4 w-4`})}),(0,j.jsx)(`div`,{className:C(`hidden h-9 w-9 shrink-0 items-center justify-center sm:flex`,n.completed?`bg-success/10`:`bg-primary/10`),children:(0,j.jsx)(s,{className:C(`h-4 w-4`,n.completed?`text-success`:`text-primary`)})}),(0,j.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,j.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,j.jsx)(`h2`,{className:`text-sm font-semibold text-foreground truncate`,title:n.subject,children:n.subject}),n.completed&&(0,j.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 rounded-md border border-success/25 bg-success/8 px-1.5 py-0.5 text-[10px] font-semibold text-success`,children:[(0,j.jsx)(u,{className:`h-3 w-3`}),t(`activity:mailbox.completed`)]}),(0,j.jsx)(`span`,{className:C(`rounded-md border px-1.5 py-0.5 text-[10px] font-semibold uppercase`,f),children:n.priority||`normal`}),n.audience===`leaders`&&(0,j.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-primary/25 bg-primary/10 px-1.5 py-0.5 text-[10px] font-semibold text-primary`,children:[(0,j.jsx)(h,{className:`h-2.5 w-2.5`}),` `,t(`activity:mailbox.audienceLeaders`)]})]}),(0,j.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-2 text-[11px] text-muted-foreground`,children:[(0,j.jsx)(`span`,{className:`min-w-0 truncate font-medium text-foreground/80`,children:n.from}),(0,j.jsx)(`span`,{children:`→`}),(0,j.jsx)(`span`,{className:`min-w-0 truncate`,children:m}),p.scope===`session`&&(0,j.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-semibold bg-warning/12 text-warning`,title:t(`activity:mailbox.sessionScopeTitle`,{sid:p.recipientSessionId??``}),children:[(0,j.jsx)(h,{className:`h-2.5 w-2.5`}),t(`activity:mailbox.sessionLabel`)]}),p.scope===`project`&&(0,j.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-semibold bg-primary/12 text-primary`,children:[(0,j.jsx)(g,{className:`h-2.5 w-2.5`}),t(`activity:mailbox.projectLabel`)]}),(0,j.jsx)(`span`,{className:`opacity-40`,children:`•`}),(0,j.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,j.jsx)(y,{className:`h-3 w-3`}),F(n.timestamp)]})]})]}),(0,j.jsx)(`button`,{type:`button`,onClick:a,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,title:t(`activity:mailbox.closeTitle`),children:(0,j.jsx)(l,{className:`h-4 w-4`})})]}),(0,j.jsxs)(`article`,{"aria-label":n.subject,className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:[(0,j.jsx)(`div`,{className:`mx-auto w-full max-w-4xl px-4 py-5`,children:(0,j.jsx)(`div`,{className:`markdown-content prose prose-sm dark:prose-invert max-w-none text-sm leading-relaxed`,children:(0,j.jsx)(D,{components:O,children:n.body})})}),(0,j.jsxs)(`div`,{className:`border-t border-border/70 bg-muted/20 px-4 py-3 shrink-0`,children:[(0,j.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-x-6 gap-y-2 text-xs [&>div]:min-w-0`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,j.jsx)(_,{className:`h-3 w-3 shrink-0`}),(0,j.jsx)(`span`,{children:d})]}),(0,j.jsx)(`div`,{className:`flex items-center gap-1.5`,children:(0,j.jsx)(`span`,{className:C(`rounded border px-1.5 py-0.5 text-[10px] font-semibold uppercase`,f),children:n.priority||`normal`})}),(0,j.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,j.jsx)(c,{className:`h-3 w-3 shrink-0`}),(0,j.jsx)(`span`,{className:`truncate`,title:n.from,children:n.from})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[p.scope===`session`?(0,j.jsx)(h,{className:`h-3 w-3 shrink-0 text-warning`}):(0,j.jsx)(g,{className:`h-3 w-3 shrink-0 text-primary`}),(0,j.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide shrink-0`,children:t(`activity:mailbox.scopeLabel`)}),(0,j.jsx)(`span`,{className:`truncate`,children:b})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,j.jsx)(y,{className:`h-3 w-3 shrink-0`}),(0,j.jsx)(`span`,{children:P(n.timestamp)})]}),n.replyTo&&(0,j.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground col-span-2`,children:[(0,j.jsx)(r,{className:`h-3 w-3 shrink-0`}),(0,j.jsx)(`span`,{className:`truncate`,children:t(`activity:mailbox.replyTo`,{id:n.replyTo})})]}),n.completed&&n.completedBy&&(0,j.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground col-span-2`,children:[(0,j.jsx)(u,{className:`h-3 w-3 shrink-0 text-success`}),(0,j.jsx)(`span`,{children:n.completedAt?t(`activity:mailbox.completedByAt`,{name:n.completedBy,time:P(n.completedAt)}):t(`activity:mailbox.completedBy`,{name:n.completedBy})})]}),n.outcome&&(0,j.jsxs)(`div`,{className:`flex items-start gap-1.5 text-muted-foreground col-span-2 sm:col-span-4`,children:[(0,j.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide shrink-0 mt-0.5`,children:t(`activity:mailbox.outcome`)}),(0,j.jsx)(`span`,{children:n.outcome})]}),n.taskContext&&(0,j.jsxs)(`div`,{className:`flex items-start gap-1.5 text-muted-foreground col-span-2 sm:col-span-4`,children:[(0,j.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide shrink-0 mt-0.5`,children:t(`activity:mailbox.task`)}),(0,j.jsx)(`span`,{children:n.taskContext})]})]}),Object.keys(n.readBy??{}).length>0&&(0,j.jsx)(`div`,{className:`mt-3 pt-3 border-t border-border/50`,children:(0,j.jsx)(I,{readBy:n.readBy})})]})]})]})})}export{L as MailboxDetailView};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-core-wiHys0m2.js";import{Bn as r,Dn as i,En as a,Er as o,Fn as s,Ht as c,Mt as l,Ta as u,Ti as d,Xa as f,ba as p,ha as m,jr as h,ri as g,rn as _,so as v,ua as y,wo as b,xo as x,yr as S}from"./vendor-V3ydTHqN.js";import"./i18n-Dv97urcO.js";import{t as C}from"./utils-CKsqCaP8.js";import{o as w}from"./view-navigation-CpIPxhZp.js";import{t as T}from"./mailbox-store-ZQO_Rv6E.js";import{n as E}from"./ui-store-DxDwFHNK.js";import{o as D,x as O}from"./index-DX6tHUzs.js";import{t as k}from"./empty-state-pfuS5znr.js";var A=e(t(),1),j=n(),M={note:d,ask:p,assign:a,steer:s,btw:f,broadcast:a,status:m,result:u,review:i},N={high:`border-destructive/25 bg-destructive/10 text-destructive`,normal:`border-border bg-muted text-muted-foreground`,low:`border-primary/20 bg-primary/10 text-primary`};function P(e){return new Date(e).toLocaleString()}function F(e){let t=new Date(e),n=Date.now()-t.getTime();return n<6e4?b.t(`common:time.justNow`):n<36e5?b.t(`common:time.minutesAgo`,{count:Math.round(n/6e4)}):n<864e5?b.t(`common:time.hoursAgo`,{count:Math.round(n/36e5)}):n<6048e5?b.t(`common:time.daysAgo`,{count:Math.round(n/864e5)}):t.toLocaleDateString()}function I({readBy:e}){let{t}=x(),n=Object.entries(e);return n.length===0?null:(0,j.jsxs)(`div`,{className:`space-y-1`,children:[(0,j.jsx)(`div`,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wide`,children:t(`activity:mailbox.readBy`)}),(0,j.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:n.map(([e,t])=>(0,j.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] bg-success/10 text-success`,title:P(t),children:[(0,j.jsx)(u,{className:`h-2.5 w-2.5`}),e]},e))})]})}function L({className:e}){let{t}=x(),n=E(e=>e.selectedMailMessage),i=E(e=>e.setSelectedMailMessage);(0,A.useEffect)(()=>()=>{i(null)},[i]);function a(){i(null),w(`chat`)}if(!n)return(0,j.jsx)(k,{icon:(0,j.jsx)(o,{className:`h-6 w-6`}),title:t(`activity:mailbox.emptyDetail`),description:t(`activity:mailbox.emptyDetailHint`)});let s=M[n.type]??S,d=t(`activity:mailbox.type.${n.type}`,{defaultValue:n.type}),f=N[n.priority]??N.normal,p=n.scope?{scope:n.scope,recipientSessionId:n.recipientSessionId}:T(n.to),m=n.to===`*`||n.to===`all`?t(`activity:mailbox.everyone`):n.to,b=p.scope===`session`?t(`activity:mailbox.sessionScope`,{sid:p.recipientSessionId??``}):p.scope===`project`?t(`activity:mailbox.projectScope`):t(`activity:mailbox.directScope`);return(0,j.jsx)(`div`,{className:C(`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-[hsl(var(--surface-2)/0.45)] p-3`,e),children:(0,j.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-border/70 bg-card/75 shadow-sm`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-border/70 px-3 py-3 sm:px-4 shrink-0`,children:[(0,j.jsx)(`button`,{type:`button`,onClick:a,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md border border-border/70 bg-background/60 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,title:t(`activity:mailbox.backToChat`),children:(0,j.jsx)(v,{className:`h-4 w-4`})}),(0,j.jsx)(`div`,{className:C(`hidden h-9 w-9 shrink-0 items-center justify-center sm:flex`,n.completed?`bg-success/10`:`bg-primary/10`),children:(0,j.jsx)(s,{className:C(`h-4 w-4`,n.completed?`text-success`:`text-primary`)})}),(0,j.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,j.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,j.jsx)(`h2`,{className:`text-sm font-semibold text-foreground truncate`,title:n.subject,children:n.subject}),n.completed&&(0,j.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 rounded-md border border-success/25 bg-success/8 px-1.5 py-0.5 text-[10px] font-semibold text-success`,children:[(0,j.jsx)(u,{className:`h-3 w-3`}),t(`activity:mailbox.completed`)]}),(0,j.jsx)(`span`,{className:C(`rounded-md border px-1.5 py-0.5 text-[10px] font-semibold uppercase`,f),children:n.priority||`normal`}),n.audience===`leaders`&&(0,j.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-primary/25 bg-primary/10 px-1.5 py-0.5 text-[10px] font-semibold text-primary`,children:[(0,j.jsx)(h,{className:`h-2.5 w-2.5`}),` `,t(`activity:mailbox.audienceLeaders`)]})]}),(0,j.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-2 text-[11px] text-muted-foreground`,children:[(0,j.jsx)(`span`,{className:`min-w-0 truncate font-medium text-foreground/80`,children:n.from}),(0,j.jsx)(`span`,{children:`→`}),(0,j.jsx)(`span`,{className:`min-w-0 truncate`,children:m}),p.scope===`session`&&(0,j.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-semibold bg-warning/12 text-warning`,title:t(`activity:mailbox.sessionScopeTitle`,{sid:p.recipientSessionId??``}),children:[(0,j.jsx)(h,{className:`h-2.5 w-2.5`}),t(`activity:mailbox.sessionLabel`)]}),p.scope===`project`&&(0,j.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-semibold bg-primary/12 text-primary`,children:[(0,j.jsx)(g,{className:`h-2.5 w-2.5`}),t(`activity:mailbox.projectLabel`)]}),(0,j.jsx)(`span`,{className:`opacity-40`,children:`•`}),(0,j.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,j.jsx)(y,{className:`h-3 w-3`}),F(n.timestamp)]})]})]}),(0,j.jsx)(`button`,{type:`button`,onClick:a,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,title:t(`activity:mailbox.closeTitle`),children:(0,j.jsx)(l,{className:`h-4 w-4`})})]}),(0,j.jsxs)(`article`,{"aria-label":n.subject,className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:[(0,j.jsx)(`div`,{className:`mx-auto w-full max-w-4xl px-4 py-5`,children:(0,j.jsx)(`div`,{className:`markdown-content prose prose-sm dark:prose-invert max-w-none text-sm leading-relaxed`,children:(0,j.jsx)(D,{components:O,children:n.body})})}),(0,j.jsxs)(`div`,{className:`border-t border-border/70 bg-muted/20 px-4 py-3 shrink-0`,children:[(0,j.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-x-6 gap-y-2 text-xs [&>div]:min-w-0`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,j.jsx)(_,{className:`h-3 w-3 shrink-0`}),(0,j.jsx)(`span`,{children:d})]}),(0,j.jsx)(`div`,{className:`flex items-center gap-1.5`,children:(0,j.jsx)(`span`,{className:C(`rounded border px-1.5 py-0.5 text-[10px] font-semibold uppercase`,f),children:n.priority||`normal`})}),(0,j.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,j.jsx)(c,{className:`h-3 w-3 shrink-0`}),(0,j.jsx)(`span`,{className:`truncate`,title:n.from,children:n.from})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[p.scope===`session`?(0,j.jsx)(h,{className:`h-3 w-3 shrink-0 text-warning`}):(0,j.jsx)(g,{className:`h-3 w-3 shrink-0 text-primary`}),(0,j.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide shrink-0`,children:t(`activity:mailbox.scopeLabel`)}),(0,j.jsx)(`span`,{className:`truncate`,children:b})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,j.jsx)(y,{className:`h-3 w-3 shrink-0`}),(0,j.jsx)(`span`,{children:P(n.timestamp)})]}),n.replyTo&&(0,j.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground col-span-2`,children:[(0,j.jsx)(r,{className:`h-3 w-3 shrink-0`}),(0,j.jsx)(`span`,{className:`truncate`,children:t(`activity:mailbox.replyTo`,{id:n.replyTo})})]}),n.completed&&n.completedBy&&(0,j.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground col-span-2`,children:[(0,j.jsx)(u,{className:`h-3 w-3 shrink-0 text-success`}),(0,j.jsx)(`span`,{children:n.completedAt?t(`activity:mailbox.completedByAt`,{name:n.completedBy,time:P(n.completedAt)}):t(`activity:mailbox.completedBy`,{name:n.completedBy})})]}),n.outcome&&(0,j.jsxs)(`div`,{className:`flex items-start gap-1.5 text-muted-foreground col-span-2 sm:col-span-4`,children:[(0,j.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide shrink-0 mt-0.5`,children:t(`activity:mailbox.outcome`)}),(0,j.jsx)(`span`,{children:n.outcome})]}),n.taskContext&&(0,j.jsxs)(`div`,{className:`flex items-start gap-1.5 text-muted-foreground col-span-2 sm:col-span-4`,children:[(0,j.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide shrink-0 mt-0.5`,children:t(`activity:mailbox.task`)}),(0,j.jsx)(`span`,{children:n.taskContext})]})]}),Object.keys(n.readBy??{}).length>0&&(0,j.jsx)(`div`,{className:`mt-3 pt-3 border-t border-border/50`,children:(0,j.jsx)(I,{readBy:n.readBy})})]})]})]})})}export{L as MailboxDetailView};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{K as t}from"./config-store-xSv1mChc.js";import{i as n,t as r}from"./react-core-wiHys0m2.js";import{Bi as i,Mr as a,Mt as o,Pa as s,Ti as c,Vn as l,Xn as u,Yt as d,fn as f,ga as p,ii as m,xo as h,zi as g}from"./vendor-V3ydTHqN.js";import"./i18n--QdD6NCn.js";import{t as _}from"./utils-CKsqCaP8.js";import{t as v}from"./button-BbeB5Qm8.js";import{E as y,T as b}from"./index-FWwLmwjx.js";import{g as x,h as S,l as C,r as w,v as T}from"./shared-BFJvAYzX.js";var E=e(n(),1);function D(e){return e.replace(/\\/g,`/`).replace(/^\.\//,``).replace(/\/{2,}/g,`/`).toLowerCase()}var O={filePath:``,primaryMatches:[],symbolMatches:[],relatedMatches:[],totalCount:0,activeCount:0,supersededCount:0,reviewPendingCount:0};function k(e){let{filePath:n,lineStart:r,lineEnd:i,limit:a=50,showSuperseded:o=!0,showDeleted:s=!1,autoFetch:c=!0,sendOptions:l}=e,u=l?JSON.stringify(l):``,[d,f]=(0,E.useState)(null),[p,m]=(0,E.useState)(!1),[h,g]=(0,E.useState)(null),_=(0,E.useRef)(0),v=(0,E.useRef)(null),y=(0,E.useRef)(l);y.current=l;let b=(0,E.useCallback)(()=>{if(!n){f(null),g(null),m(!1);return}let e=++_.current;m(!0),g(null);let c=t();if(!c){g(`WebSocket client unavailable`),m(!1);return}v.current?.(),v.current=null;let l=n,u=c.on(`memory.sage.forFile`,t=>{if(e!==_.current)return;let n=t.payload.response;n&&D(n.filePath)!==D(l)||(t.payload.error?(g(t.payload.error),f(null)):(f(n??O),g(null)),m(!1))});v.current=u;let d={filePath:n,limit:a,showSuperseded:o,showDeleted:s,...r===void 0?{}:{lineStart:r},...i===void 0?{}:{lineEnd:i}};try{c.findMemoriesForFile(d,y.current??void 0)}catch(t){u(),v.current===u&&(v.current=null),e===_.current&&(g(t instanceof Error?t.message:String(t)),m(!1))}},[n,r,i,a,o,s]);(0,E.useEffect)(()=>{if(c)return b(),()=>{_.current++,v.current?.(),v.current=null}},[c,b,u]);let x=(0,E.useCallback)(()=>{b()},[b]);return(0,E.useEffect)(()=>()=>{v.current?.(),v.current=null},[]),{data:d,loading:p,error:h,refetch:x}}var A=r();function j(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 M(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 N({match:e,cursorBoosted:t,onShowMemory:n,onAcceptDeletion:r,onKeep:i,onUpdate:c,onMarkPermanent:p,onRecover:y,pendingAction:b}){let{t:E}=h(),D=e.memory.status===`deleted`,O=e.memory.status===`superseded`,k=e.pendingReview,N=b!==void 0,P=t===!0;return(0,A.jsxs)(`article`,{className:_(`group relative rounded-md border px-3 py-2 text-sm transition-colors`,j(e.matchStrength),P&&`ring-1 ring-primary/40 ring-offset-0`,D&&`opacity-70`),"data-match-via":e.matchedVia,"data-memory-id":e.memory.id,children:[(0,A.jsx)(`header`,{className:`flex items-start justify-between gap-2`,children:(0,A.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] uppercase tracking-wide`,children:[(0,A.jsx)(`span`,{className:_(`font-mono`,S(e.memory.kind)),children:w[e.memory.kind]??e.memory.kind}),(0,A.jsx)(`span`,{className:`text-muted-foreground`,children:`·`}),(0,A.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:M(e.matchedVia)}),P&&(0,A.jsxs)(`span`,{className:`flex items-center gap-0.5 rounded-sm bg-primary/15 px-1 py-0.5 font-mono text-primary`,title:E(`activity:memoryManager.anchorCursorHint`),children:[(0,A.jsx)(u,{className:`size-2.5`}),` `,E(`activity:memoryManager.cursorLabel`)]}),k&&(0,A.jsxs)(`span`,{className:`flex items-center gap-0.5 rounded-sm bg-warning/15 px-1 py-0.5 font-mono text-warning`,title:E(`activity:memoryManager.hygieneReviewTitle`,{reason:k.reason,days:k.ageDays}),children:[(0,A.jsx)(d,{className:`size-2.5`}),` `,E(`activity:memoryManager.reviewLabel`)]}),D&&(0,A.jsx)(`span`,{className:`font-mono text-destructive`,children:E(`activity:memoryManager.statusDeleted`)}),O&&!D&&(0,A.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:E(`activity:memoryManager.statusSuperseded`)})]}),(0,A.jsx)(`p`,{className:`mt-1 text-foreground/90`,children:x(e.memory.text,200)}),(0,A.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,A.jsx)(C,{status:e.memory.status}),(0,A.jsx)(`span`,{children:E(`activity:memoryManager.updatedSuffix`,{date:T(e.memory.updatedAt)})})]})]})}),(0,A.jsxs)(`footer`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,children:[D&&y&&(0,A.jsxs)(v,{type:`button`,size:`sm`,variant:`outline`,disabled:N,onClick:()=>y(e.memory.id),className:`h-7 gap-1 border-primary/40 px-2 text-[11px] text-primary hover:bg-primary/10`,title:E(`activity:memoryManager.restoreTitle`),children:[(0,A.jsx)(l,{className:`size-3`}),` `,E(`activity:memoryManager.actionRecover`)]}),O&&e.supersededByActiveId&&n&&(0,A.jsxs)(v,{type:`button`,size:`sm`,variant:`outline`,disabled:N,onClick:()=>n(e.supersededByActiveId),className:`h-7 gap-1 px-2 text-[11px]`,title:E(`activity:memoryManager.supersededJumpTitle`),children:[(0,A.jsx)(m,{className:`size-3`}),` `,E(`activity:memoryManager.actionGoToActive`)]}),k&&(r||i||c||p)&&(0,A.jsxs)(A.Fragment,{children:[k.suggestedAction===`delete`&&(0,A.jsxs)(v,{type:`button`,size:`sm`,variant:`destructive`,disabled:N,onClick:()=>r?.(k.candidateId,e.memory.id),className:`h-7 gap-1 px-2 text-[11px]`,title:E(`activity:memoryManager.acceptSuggestionTitle`),children:[(0,A.jsx)(s,{className:`size-3`}),` `,E(`activity:memoryManager.actionAcceptDeletion`)]}),(0,A.jsxs)(v,{type:`button`,size:`sm`,variant:`outline`,disabled:N,onClick:()=>i?.(k.candidateId,e.memory.id),className:`h-7 gap-1 px-2 text-[11px]`,title:E(`activity:memoryManager.rejectSuggestionTitle`),children:[(0,A.jsx)(o,{className:`size-3`}),` `,E(`activity:memoryManager.actionKeep`)]}),(0,A.jsxs)(v,{type:`button`,size:`sm`,variant:`outline`,disabled:N,onClick:()=>c?.(e.memory.id),className:`h-7 gap-1 px-2 text-[11px]`,title:E(`activity:memoryManager.updateTitle`),children:[(0,A.jsx)(f,{className:`size-3`}),` `,E(`activity:memoryManager.actionUpdate`)]}),p&&(0,A.jsxs)(v,{type:`button`,size:`sm`,variant:`outline`,disabled:N,onClick:()=>p(e.memory.id),className:`h-7 gap-1 border-warning/40 px-2 text-[11px] text-warning hover:bg-warning/10`,title:E(`activity:memoryManager.promoteTitle`),children:[(0,A.jsx)(u,{className:`size-3`}),` `,E(`activity:memoryManager.actionMarkPermanent`)]})]}),n&&!D&&(0,A.jsxs)(v,{type:`button`,size:`sm`,variant:`ghost`,disabled:N,onClick:()=>n(e.memory.id),className:`h-7 gap-1 px-2 text-[11px] text-muted-foreground hover:text-foreground`,title:E(`activity:memoryManager.openRecordTitle`),children:[(0,A.jsx)(g,{className:`size-3`}),` `,E(`activity:memoryManager.actionShowFull`)]}),b&&(0,A.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 text-[10px] text-muted-foreground`,children:[(0,A.jsx)(a,{className:`size-3 animate-spin`}),` `,b]})]})]})}function P({icon:e,title:t,count:n,matches:r,cursorBoosted:i=!1,...a}){let{t:o}=h(),s=y(r,10);return r.length===0?null:(0,A.jsxs)(`section`,{className:`flex flex-col gap-1.5`,children:[(0,A.jsxs)(`h3`,{className:`flex items-center gap-1.5 px-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[(0,A.jsx)(e,{className:`size-3`}),(0,A.jsx)(`span`,{children:t}),(0,A.jsxs)(`span`,{className:`font-mono`,children:[`(`,n,`)`]}),i&&(0,A.jsxs)(`span`,{className:`ml-auto flex items-center gap-0.5 font-mono text-[9px] text-primary`,children:[(0,A.jsx)(u,{className:`size-2.5`}),` `,o(`activity:memoryManager.cursorBoostTitle`)]})]}),(0,A.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:s.pageItems.map(e=>(0,A.jsx)(N,{match:e,cursorBoosted:i&&(e.matchedVia===`anchor_symbol`||e.matchedVia===`scope_symbol`),pendingAction:a.pendingActionById.get(e.memory.id),...a},e.memory.id))}),(0,A.jsx)(b,{page:s.page,pageSize:s.pageSize,totalItems:s.totalItems,onPageChange:s.setPage,compact:!0,itemLabel:o(`activity:memoryManager.itemLabel`)})]})}function F({filePath:e,lineStart:t,lineEnd:n,open:r,onClose:a,onShowMemory:o,onAcceptDeletion:s,onKeep:f,onUpdate:m,onMarkPermanent:y,onRecover:b}){let{t:x}=h(),[S,C]=(0,E.useState)(!1),[w,T]=(0,E.useState)(new Map),D={accepting:x(`activity:memoryManager.pendingAccepting`),keeping:x(`activity:memoryManager.pendingKeeping`),updating:x(`activity:memoryManager.pendingUpdating`),marking:x(`activity:memoryManager.pendingMarking`),recovering:x(`activity:memoryManager.pendingRecovering`)},{data:O,loading:j,error:M,refetch:N}=k({filePath:e,lineStart:t,lineEnd:n,showDeleted:S,autoFetch:r}),F=t!==void 0&&n!==void 0,L=(0,E.useCallback)(async(e,t,n)=>{if(n){T(n=>new Map(n).set(e,t));try{await n(e)}finally{T(t=>{let n=new Map(t);return n.delete(e),n})}}},[]);if((0,E.useEffect)(()=>{C(!1)},[e]),!r)return null;let R=O,z=R?.totalCount??0;return(0,A.jsxs)(`aside`,{className:`flex h-full min-h-0 w-full flex-col border-l border-border/70 bg-card/15`,"aria-label":x(`activity:memoryManager.fileDrawerAria`),"data-file-path":e??``,children:[(0,A.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-border/60 px-3 py-2`,children:[(0,A.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] uppercase tracking-wide text-muted-foreground`,children:[(0,A.jsx)(c,{className:`size-3`}),(0,A.jsx)(`span`,{className:`truncate font-mono`,title:e??``,children:e??x(`activity:memoryManager.noFile`)})]}),(0,A.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,A.jsx)(`span`,{className:`font-mono`,children:x(`activity:memoryManager.memoriesCount`,{count:z})}),R&&R.reviewPendingCount>0&&(0,A.jsxs)(`span`,{className:`flex items-center gap-0.5 font-mono text-warning`,children:[(0,A.jsx)(d,{className:`size-3`}),x(`activity:memoryManager.pendingReviewCount`,{count:R.reviewPendingCount})]}),R&&R.supersededCount>0&&(0,A.jsx)(`span`,{className:`font-mono`,children:x(`activity:memoryManager.supersededCount`,{count:R.supersededCount})})]})]}),(0,A.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,A.jsx)(v,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>N(),disabled:j||!e,className:`h-7 w-7 p-0`,"aria-label":x(`common:action.refresh`),title:x(`activity:memoryManager.requeryTitle`),children:(0,A.jsx)(l,{className:_(`size-3.5`,j&&`animate-spin`)})}),(0,A.jsx)(v,{type:`button`,size:`sm`,variant:`ghost`,onClick:a,className:`h-7 w-7 p-0`,"aria-label":x(`activity:memoryManager.closeDrawerAria`),title:x(`activity:memoryManager.closeDrawerTitle`),children:(0,A.jsx)(p,{className:`size-3.5`})})]})]}),(0,A.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,A.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:S,onChange:e=>C(e.target.checked),className:`size-3 accent-primary`,disabled:!e,"data-testid":`memory-drawer-show-deleted`}),S?(0,A.jsx)(g,{className:`size-3`}):(0,A.jsx)(i,{className:`size-3`}),(0,A.jsx)(`span`,{children:x(`activity:memoryManager.showRecoverable`)})]}),F&&(0,A.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 font-mono text-[10px] text-primary`,children:[(0,A.jsx)(u,{className:`size-3`}),` `,x(`activity:memoryManager.linesRange`,{start:t,end:n})]})]}),(0,A.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-3 py-3`,children:e?j&&!R?(0,A.jsx)(I,{loading:!0,message:x(`activity:memoryManager.loadingMemories`)}):M?(0,A.jsx)(I,{tone:`error`,message:x(`activity:memoryManager.errorPrefix`,{message:M})}):!R||z===0?(0,A.jsx)(I,{message:x(`activity:memoryManager.emptyNoMemories`,{file:e})}):(0,A.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,A.jsx)(P,{icon:u,title:x(`activity:memoryManager.cursorBoostTitle`),count:R.symbolMatches.length,cursorBoosted:F,matches:R.symbolMatches,pendingActionById:w,onShowMemory:o,onAcceptDeletion:(e,t)=>L(t,D.accepting,()=>s?.(e,t)),onKeep:(e,t)=>L(t,D.keeping,()=>f?.(e,t)),onUpdate:e=>L(e,D.updating,()=>m?.(e)),onMarkPermanent:e=>L(e,D.marking,()=>y?.(e)),onRecover:e=>L(e,D.recovering,()=>b?.(e))}),(0,A.jsx)(P,{icon:c,title:x(`activity:memoryManager.fileScopedTitle`),count:R.primaryMatches.length,matches:R.primaryMatches,pendingActionById:w,onShowMemory:o,onAcceptDeletion:(e,t)=>L(t,D.accepting,()=>s?.(e,t)),onKeep:(e,t)=>L(t,D.keeping,()=>f?.(e,t)),onUpdate:e=>L(e,D.updating,()=>m?.(e)),onMarkPermanent:e=>L(e,D.marking,()=>y?.(e)),onRecover:e=>L(e,D.recovering,()=>b?.(e))}),(0,A.jsx)(P,{icon:g,title:x(`activity:memoryManager.mentionedInTitle`),count:R.relatedMatches.length,matches:R.relatedMatches,pendingActionById:w,onShowMemory:o,onAcceptDeletion:(e,t)=>L(t,D.accepting,()=>s?.(e,t)),onKeep:(e,t)=>L(t,D.keeping,()=>f?.(e,t)),onUpdate:e=>L(e,D.updating,()=>m?.(e)),onMarkPermanent:e=>L(e,D.marking,()=>y?.(e)),onRecover:e=>L(e,D.recovering,()=>b?.(e))})]}):(0,A.jsx)(I,{message:x(`activity:memoryManager.emptyOpenFile`)})})]})}function I({message:e,loading:t=!1,tone:n=`default`}){return(0,A.jsxs)(`div`,{className:_(`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]`,n===`error`?`text-destructive`:`text-muted-foreground`),children:[t&&(0,A.jsx)(a,{className:`size-4 animate-spin`}),(0,A.jsx)(`p`,{children:e})]})}export{F as t};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{K as t}from"./config-store-BbL0WxLE.js";import{i as n,t as r}from"./react-core-wiHys0m2.js";import{Bi as i,Mr as a,Mt as o,Pa as s,Ti as c,Vn as l,Xn as u,Yt as d,fn as f,ga as p,ii as m,xo as h,zi as g}from"./vendor-V3ydTHqN.js";import"./i18n-Dv97urcO.js";import{t as _}from"./utils-CKsqCaP8.js";import{t as v}from"./button-BbeB5Qm8.js";import{E as y,T as b}from"./index-DX6tHUzs.js";import{g as x,h as S,l as C,r as w,v as T}from"./shared-BFJvAYzX.js";var E=e(n(),1);function D(e){return e.replace(/\\/g,`/`).replace(/^\.\//,``).replace(/\/{2,}/g,`/`).toLowerCase()}var O={filePath:``,primaryMatches:[],symbolMatches:[],relatedMatches:[],totalCount:0,activeCount:0,supersededCount:0,reviewPendingCount:0};function k(e){let{filePath:n,lineStart:r,lineEnd:i,limit:a=50,showSuperseded:o=!0,showDeleted:s=!1,autoFetch:c=!0,sendOptions:l}=e,u=l?JSON.stringify(l):``,[d,f]=(0,E.useState)(null),[p,m]=(0,E.useState)(!1),[h,g]=(0,E.useState)(null),_=(0,E.useRef)(0),v=(0,E.useRef)(null),y=(0,E.useRef)(l);y.current=l;let b=(0,E.useCallback)(()=>{if(!n){f(null),g(null),m(!1);return}let e=++_.current;m(!0),g(null);let c=t();if(!c){g(`WebSocket client unavailable`),m(!1);return}v.current?.(),v.current=null;let l=n,u=c.on(`memory.sage.forFile`,t=>{if(e!==_.current)return;let n=t.payload.response;n&&D(n.filePath)!==D(l)||(t.payload.error?(g(t.payload.error),f(null)):(f(n??O),g(null)),m(!1))});v.current=u;let d={filePath:n,limit:a,showSuperseded:o,showDeleted:s,...r===void 0?{}:{lineStart:r},...i===void 0?{}:{lineEnd:i}};try{c.findMemoriesForFile(d,y.current??void 0)}catch(t){u(),v.current===u&&(v.current=null),e===_.current&&(g(t instanceof Error?t.message:String(t)),m(!1))}},[n,r,i,a,o,s]);(0,E.useEffect)(()=>{if(c)return b(),()=>{_.current++,v.current?.(),v.current=null}},[c,b,u]);let x=(0,E.useCallback)(()=>{b()},[b]);return(0,E.useEffect)(()=>()=>{v.current?.(),v.current=null},[]),{data:d,loading:p,error:h,refetch:x}}var A=r();function j(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 M(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 N({match:e,cursorBoosted:t,onShowMemory:n,onAcceptDeletion:r,onKeep:i,onUpdate:c,onMarkPermanent:p,onRecover:y,pendingAction:b}){let{t:E}=h(),D=e.memory.status===`deleted`,O=e.memory.status===`superseded`,k=e.pendingReview,N=b!==void 0,P=t===!0;return(0,A.jsxs)(`article`,{className:_(`group relative rounded-md border px-3 py-2 text-sm transition-colors`,j(e.matchStrength),P&&`ring-1 ring-primary/40 ring-offset-0`,D&&`opacity-70`),"data-match-via":e.matchedVia,"data-memory-id":e.memory.id,children:[(0,A.jsx)(`header`,{className:`flex items-start justify-between gap-2`,children:(0,A.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] uppercase tracking-wide`,children:[(0,A.jsx)(`span`,{className:_(`font-mono`,S(e.memory.kind)),children:w[e.memory.kind]??e.memory.kind}),(0,A.jsx)(`span`,{className:`text-muted-foreground`,children:`·`}),(0,A.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:M(e.matchedVia)}),P&&(0,A.jsxs)(`span`,{className:`flex items-center gap-0.5 rounded-sm bg-primary/15 px-1 py-0.5 font-mono text-primary`,title:E(`activity:memoryManager.anchorCursorHint`),children:[(0,A.jsx)(u,{className:`size-2.5`}),` `,E(`activity:memoryManager.cursorLabel`)]}),k&&(0,A.jsxs)(`span`,{className:`flex items-center gap-0.5 rounded-sm bg-warning/15 px-1 py-0.5 font-mono text-warning`,title:E(`activity:memoryManager.hygieneReviewTitle`,{reason:k.reason,days:k.ageDays}),children:[(0,A.jsx)(d,{className:`size-2.5`}),` `,E(`activity:memoryManager.reviewLabel`)]}),D&&(0,A.jsx)(`span`,{className:`font-mono text-destructive`,children:E(`activity:memoryManager.statusDeleted`)}),O&&!D&&(0,A.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:E(`activity:memoryManager.statusSuperseded`)})]}),(0,A.jsx)(`p`,{className:`mt-1 text-foreground/90`,children:x(e.memory.text,200)}),(0,A.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,A.jsx)(C,{status:e.memory.status}),(0,A.jsx)(`span`,{children:E(`activity:memoryManager.updatedSuffix`,{date:T(e.memory.updatedAt)})})]})]})}),(0,A.jsxs)(`footer`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,children:[D&&y&&(0,A.jsxs)(v,{type:`button`,size:`sm`,variant:`outline`,disabled:N,onClick:()=>y(e.memory.id),className:`h-7 gap-1 border-primary/40 px-2 text-[11px] text-primary hover:bg-primary/10`,title:E(`activity:memoryManager.restoreTitle`),children:[(0,A.jsx)(l,{className:`size-3`}),` `,E(`activity:memoryManager.actionRecover`)]}),O&&e.supersededByActiveId&&n&&(0,A.jsxs)(v,{type:`button`,size:`sm`,variant:`outline`,disabled:N,onClick:()=>n(e.supersededByActiveId),className:`h-7 gap-1 px-2 text-[11px]`,title:E(`activity:memoryManager.supersededJumpTitle`),children:[(0,A.jsx)(m,{className:`size-3`}),` `,E(`activity:memoryManager.actionGoToActive`)]}),k&&(r||i||c||p)&&(0,A.jsxs)(A.Fragment,{children:[k.suggestedAction===`delete`&&(0,A.jsxs)(v,{type:`button`,size:`sm`,variant:`destructive`,disabled:N,onClick:()=>r?.(k.candidateId,e.memory.id),className:`h-7 gap-1 px-2 text-[11px]`,title:E(`activity:memoryManager.acceptSuggestionTitle`),children:[(0,A.jsx)(s,{className:`size-3`}),` `,E(`activity:memoryManager.actionAcceptDeletion`)]}),(0,A.jsxs)(v,{type:`button`,size:`sm`,variant:`outline`,disabled:N,onClick:()=>i?.(k.candidateId,e.memory.id),className:`h-7 gap-1 px-2 text-[11px]`,title:E(`activity:memoryManager.rejectSuggestionTitle`),children:[(0,A.jsx)(o,{className:`size-3`}),` `,E(`activity:memoryManager.actionKeep`)]}),(0,A.jsxs)(v,{type:`button`,size:`sm`,variant:`outline`,disabled:N,onClick:()=>c?.(e.memory.id),className:`h-7 gap-1 px-2 text-[11px]`,title:E(`activity:memoryManager.updateTitle`),children:[(0,A.jsx)(f,{className:`size-3`}),` `,E(`activity:memoryManager.actionUpdate`)]}),p&&(0,A.jsxs)(v,{type:`button`,size:`sm`,variant:`outline`,disabled:N,onClick:()=>p(e.memory.id),className:`h-7 gap-1 border-warning/40 px-2 text-[11px] text-warning hover:bg-warning/10`,title:E(`activity:memoryManager.promoteTitle`),children:[(0,A.jsx)(u,{className:`size-3`}),` `,E(`activity:memoryManager.actionMarkPermanent`)]})]}),n&&!D&&(0,A.jsxs)(v,{type:`button`,size:`sm`,variant:`ghost`,disabled:N,onClick:()=>n(e.memory.id),className:`h-7 gap-1 px-2 text-[11px] text-muted-foreground hover:text-foreground`,title:E(`activity:memoryManager.openRecordTitle`),children:[(0,A.jsx)(g,{className:`size-3`}),` `,E(`activity:memoryManager.actionShowFull`)]}),b&&(0,A.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 text-[10px] text-muted-foreground`,children:[(0,A.jsx)(a,{className:`size-3 animate-spin`}),` `,b]})]})]})}function P({icon:e,title:t,count:n,matches:r,cursorBoosted:i=!1,...a}){let{t:o}=h(),s=y(r,10);return r.length===0?null:(0,A.jsxs)(`section`,{className:`flex flex-col gap-1.5`,children:[(0,A.jsxs)(`h3`,{className:`flex items-center gap-1.5 px-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[(0,A.jsx)(e,{className:`size-3`}),(0,A.jsx)(`span`,{children:t}),(0,A.jsxs)(`span`,{className:`font-mono`,children:[`(`,n,`)`]}),i&&(0,A.jsxs)(`span`,{className:`ml-auto flex items-center gap-0.5 font-mono text-[9px] text-primary`,children:[(0,A.jsx)(u,{className:`size-2.5`}),` `,o(`activity:memoryManager.cursorBoostTitle`)]})]}),(0,A.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:s.pageItems.map(e=>(0,A.jsx)(N,{match:e,cursorBoosted:i&&(e.matchedVia===`anchor_symbol`||e.matchedVia===`scope_symbol`),pendingAction:a.pendingActionById.get(e.memory.id),...a},e.memory.id))}),(0,A.jsx)(b,{page:s.page,pageSize:s.pageSize,totalItems:s.totalItems,onPageChange:s.setPage,compact:!0,itemLabel:o(`activity:memoryManager.itemLabel`)})]})}function F({filePath:e,lineStart:t,lineEnd:n,open:r,onClose:a,onShowMemory:o,onAcceptDeletion:s,onKeep:f,onUpdate:m,onMarkPermanent:y,onRecover:b}){let{t:x}=h(),[S,C]=(0,E.useState)(!1),[w,T]=(0,E.useState)(new Map),D={accepting:x(`activity:memoryManager.pendingAccepting`),keeping:x(`activity:memoryManager.pendingKeeping`),updating:x(`activity:memoryManager.pendingUpdating`),marking:x(`activity:memoryManager.pendingMarking`),recovering:x(`activity:memoryManager.pendingRecovering`)},{data:O,loading:j,error:M,refetch:N}=k({filePath:e,lineStart:t,lineEnd:n,showDeleted:S,autoFetch:r}),F=t!==void 0&&n!==void 0,L=(0,E.useCallback)(async(e,t,n)=>{if(n){T(n=>new Map(n).set(e,t));try{await n(e)}finally{T(t=>{let n=new Map(t);return n.delete(e),n})}}},[]);if((0,E.useEffect)(()=>{C(!1)},[e]),!r)return null;let R=O,z=R?.totalCount??0;return(0,A.jsxs)(`aside`,{className:`flex h-full min-h-0 w-full flex-col border-l border-border/70 bg-card/15`,"aria-label":x(`activity:memoryManager.fileDrawerAria`),"data-file-path":e??``,children:[(0,A.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-border/60 px-3 py-2`,children:[(0,A.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] uppercase tracking-wide text-muted-foreground`,children:[(0,A.jsx)(c,{className:`size-3`}),(0,A.jsx)(`span`,{className:`truncate font-mono`,title:e??``,children:e??x(`activity:memoryManager.noFile`)})]}),(0,A.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,A.jsx)(`span`,{className:`font-mono`,children:x(`activity:memoryManager.memoriesCount`,{count:z})}),R&&R.reviewPendingCount>0&&(0,A.jsxs)(`span`,{className:`flex items-center gap-0.5 font-mono text-warning`,children:[(0,A.jsx)(d,{className:`size-3`}),x(`activity:memoryManager.pendingReviewCount`,{count:R.reviewPendingCount})]}),R&&R.supersededCount>0&&(0,A.jsx)(`span`,{className:`font-mono`,children:x(`activity:memoryManager.supersededCount`,{count:R.supersededCount})})]})]}),(0,A.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,A.jsx)(v,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>N(),disabled:j||!e,className:`h-7 w-7 p-0`,"aria-label":x(`common:action.refresh`),title:x(`activity:memoryManager.requeryTitle`),children:(0,A.jsx)(l,{className:_(`size-3.5`,j&&`animate-spin`)})}),(0,A.jsx)(v,{type:`button`,size:`sm`,variant:`ghost`,onClick:a,className:`h-7 w-7 p-0`,"aria-label":x(`activity:memoryManager.closeDrawerAria`),title:x(`activity:memoryManager.closeDrawerTitle`),children:(0,A.jsx)(p,{className:`size-3.5`})})]})]}),(0,A.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,A.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:S,onChange:e=>C(e.target.checked),className:`size-3 accent-primary`,disabled:!e,"data-testid":`memory-drawer-show-deleted`}),S?(0,A.jsx)(g,{className:`size-3`}):(0,A.jsx)(i,{className:`size-3`}),(0,A.jsx)(`span`,{children:x(`activity:memoryManager.showRecoverable`)})]}),F&&(0,A.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 font-mono text-[10px] text-primary`,children:[(0,A.jsx)(u,{className:`size-3`}),` `,x(`activity:memoryManager.linesRange`,{start:t,end:n})]})]}),(0,A.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-3 py-3`,children:e?j&&!R?(0,A.jsx)(I,{loading:!0,message:x(`activity:memoryManager.loadingMemories`)}):M?(0,A.jsx)(I,{tone:`error`,message:x(`activity:memoryManager.errorPrefix`,{message:M})}):!R||z===0?(0,A.jsx)(I,{message:x(`activity:memoryManager.emptyNoMemories`,{file:e})}):(0,A.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,A.jsx)(P,{icon:u,title:x(`activity:memoryManager.cursorBoostTitle`),count:R.symbolMatches.length,cursorBoosted:F,matches:R.symbolMatches,pendingActionById:w,onShowMemory:o,onAcceptDeletion:(e,t)=>L(t,D.accepting,()=>s?.(e,t)),onKeep:(e,t)=>L(t,D.keeping,()=>f?.(e,t)),onUpdate:e=>L(e,D.updating,()=>m?.(e)),onMarkPermanent:e=>L(e,D.marking,()=>y?.(e)),onRecover:e=>L(e,D.recovering,()=>b?.(e))}),(0,A.jsx)(P,{icon:c,title:x(`activity:memoryManager.fileScopedTitle`),count:R.primaryMatches.length,matches:R.primaryMatches,pendingActionById:w,onShowMemory:o,onAcceptDeletion:(e,t)=>L(t,D.accepting,()=>s?.(e,t)),onKeep:(e,t)=>L(t,D.keeping,()=>f?.(e,t)),onUpdate:e=>L(e,D.updating,()=>m?.(e)),onMarkPermanent:e=>L(e,D.marking,()=>y?.(e)),onRecover:e=>L(e,D.recovering,()=>b?.(e))}),(0,A.jsx)(P,{icon:g,title:x(`activity:memoryManager.mentionedInTitle`),count:R.relatedMatches.length,matches:R.relatedMatches,pendingActionById:w,onShowMemory:o,onAcceptDeletion:(e,t)=>L(t,D.accepting,()=>s?.(e,t)),onKeep:(e,t)=>L(t,D.keeping,()=>f?.(e,t)),onUpdate:e=>L(e,D.updating,()=>m?.(e)),onMarkPermanent:e=>L(e,D.marking,()=>y?.(e)),onRecover:e=>L(e,D.recovering,()=>b?.(e))})]}):(0,A.jsx)(I,{message:x(`activity:memoryManager.emptyOpenFile`)})})]})}function I({message:e,loading:t=!1,tone:n=`default`}){return(0,A.jsxs)(`div`,{className:_(`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]`,n===`error`?`text-destructive`:`text-muted-foreground`),children:[t&&(0,A.jsx)(a,{className:`size-4 animate-spin`}),(0,A.jsx)(`p`,{children:e})]})}export{F as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./config-store-xSv1mChc.js";import{i as n,t as r}from"./react-core-wiHys0m2.js";import{Dn as i,Ha as a,Ii as o,Mn as s,Mr as c,Mt as l,Na as u,Pa as d,Qt as f,Va as p,Vi as m,Vn as h,Ya as g,Yi as ee,Yt as _,Zn as v,ci as y,ei as b,fa as x,fn as S,ja as C,ln as w,mi as T,n as E,nr as D,po as te,qn as O,rn as k,so as A,tr as ne,ur as re,wa as ie,xo as j,yn as ae,zr as oe}from"./vendor-V3ydTHqN.js";import"./i18n--QdD6NCn.js";import{a as M,h as N,n as se,r as P,t as ce,u as le}from"./xyflow-BqDBClm9.js";import{t as F}from"./utils-CKsqCaP8.js";import{n as ue}from"./ui-store-DC3mkswy.js";import"./stores-2kakt8j9.js";import{S as I}from"./fonts-DRGbd-AM.js";import{a as de,i as fe,n as L,o as pe,r as R,t as me}from"./dialog-b-Ai37sa.js";import{t as z}from"./button-BbeB5Qm8.js";import{t as B}from"./input-BA6D2L3K.js";import{L as he,N as ge,y as V}from"./index-FWwLmwjx.js";import{t as _e}from"./roster-ws-CxKDc-ET.js";import{_ as ve,a as ye,b as be,c as H,d as xe,f as Se,g as Ce,h as we,i as Te,l as Ee,m as De,n as Oe,o as ke,p as Ae,r as je,s as U,t as Me,u as Ne,v as Pe,y as W}from"./shared-BFJvAYzX.js";import{t as Fe}from"./MemoryDrawer-BZsyD1dh.js";var G=r();function Ie({busyAction:e,deletingId:t,memory:n,onCancel:r,onConfirm:i,onOpenChange:a}){let{t:o}=j();return(0,G.jsx)(me,{open:!!t,onOpenChange:a,children:(0,G.jsxs)(L,{className:`max-w-md`,children:[(0,G.jsxs)(de,{children:[(0,G.jsx)(`span`,{className:`mb-2 flex size-10 items-center justify-center border border-destructive/35 bg-destructive/10 text-destructive`,children:(0,G.jsx)(f,{className:`size-4`})}),(0,G.jsx)(pe,{children:o(`activity:memoryManager.deleteTitle`)}),(0,G.jsx)(R,{className:`leading-6`,children:o(`activity:deleteMemoryDialog.sageWillMarkTheRecordDeleted`)})]}),(0,G.jsx)(`div`,{className:`border border-border/70 bg-background/45 p-3 text-xs text-muted-foreground`,children:Ce(n?.text??``,180)}),(0,G.jsxs)(fe,{children:[(0,G.jsx)(z,{variant:`outline`,onClick:r,disabled:e===`delete`,children:o(`common:action.cancel`)}),(0,G.jsxs)(z,{variant:`destructive`,onClick:i,disabled:e===`delete`,children:[e===`delete`?(0,G.jsx)(c,{className:`size-4 animate-spin`}):(0,G.jsx)(f,{className:`size-4`}),o(e===`delete`?`activity:memoryManager.deletingLabel`:`activity:memoryManager.actionDeleteMemory`)]})]})]})})}var K=e(n(),1),Le=212,Re=188;function ze(e){return e.length>14?`${e.slice(0,11)}…`:e}function Be(e,t=58){let n=e.replace(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t-1)}…`:n}function q(e){return e.type===`symbol`?[e.path,e.symbol?`#${e.symbol}`:``].filter(Boolean).join(``):e.path??e.command??e.symbol??e.role??e.type}function J(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 Ve({data:e}){let{entry:t,center:n}=e;return(0,G.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:Le},title:t.text,children:[(0,G.jsx)(M,{type:`target`,position:N.Top,className:`!border-background !bg-muted-foreground`}),(0,G.jsx)(M,{type:`source`,position:N.Bottom,className:`!border-background !bg-primary`}),(0,G.jsx)(M,{type:`source`,position:N.Right,className:`!border-background !bg-primary`}),(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`border px-1.5 py-0.5 text-[9px] font-bold uppercase ${J(t.status)}`,children:t.status}),(0,G.jsx)(`span`,{className:`ml-auto truncate font-mono text-[9px] text-muted-foreground`,children:ze(t.id)})]}),(0,G.jsx)(`p`,{className:`mt-2 line-clamp-2 text-[11px] leading-4 text-foreground/90`,children:Be(t.text)}),(0,G.jsx)(`p`,{className:`mt-1 font-mono text-[9px] uppercase text-muted-foreground`,children:t.kind})]})}function Y({data:e}){return(0,G.jsxs)(`div`,{className:`border border-info/40 bg-info/8 px-2.5 py-2 text-card-foreground shadow-lg`,style:{width:Re},title:e.label,children:[(0,G.jsx)(M,{type:`target`,position:N.Left,className:`!border-background !bg-info`}),(0,G.jsx)(`p`,{className:`font-mono text-[9px] font-bold uppercase text-info`,children:e.anchor.type}),(0,G.jsx)(`p`,{className:`mt-1 truncate font-mono text-[10px] text-foreground/85`,children:e.label})]})}var He={memoryNode:Ve,anchorNode:Y};function X(e,t){return{id:e,revision:0,scope:`project`,kind:`fact`,status:`deleted`,text:t(`activity:memoryManager.memoryUnavailable`),importance:0,confidence:0,freshness:0,tags:[],anchors:[],createdAt:``,updatedAt:``}}function Ue({nodes:e,edges:t,className:n}){return(0,G.jsx)(`div`,{className:F(`w-full`,n),children:(0,G.jsxs)(le,{nodes:e,edges:t,nodeTypes:He,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,G.jsx)(ce,{variant:se.Dots,gap:18,size:1,color:`hsl(var(--muted-foreground) / 0.18)`}),(0,G.jsx)(P,{showInteractive:!1,className:`!border-border !bg-card !shadow-lg`})]})})}function We({centerMemory:e,allMemories:t,graphEdges:n,loading:r=!1,error:i=null}){let{t:a}=j(),[o,s]=(0,K.useState)(!1),c=`mem:${e.id}`,l=(0,K.useMemo)(()=>n.filter(e=>e.from===c&&e.to.startsWith(`mem:`)||e.to===c&&e.from.startsWith(`mem:`)).slice(0,24),[c,n]),{nodes:u,edges:d}=(0,K.useMemo)(()=>{let n=[],r=[],i=new Map(t.map(e=>[e.id,e]));n.push({id:e.id,type:`memoryNode`,position:{x:320-Le/2,y:120},data:{entry:e,center:!0}});let o=[...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 l){let t=(e.from===c?e.to:e.from).slice(4);o.some(n=>n.id===t&&n.relation===e.relation)||o.push({id:t,relation:e.relation,weight:e.weight,evidence:e.evidence})}let s=320-(o.length-1)*220/2;return o.forEach((t,o)=>{let c=i.get(t.id)??X(t.id,a),l=t.relation===`superseded by`,u=l?0:280+Math.floor(o/3)*130,d=l?320-Le/2:s+o*220-Le/2;n.push({id:`memory:${t.id}:${o}`,type:`memoryNode`,position:{x:d,y:u},data:{entry:c,center:!1}});let f=t.relation===`contradicts`,p=l?`memory:${t.id}:${o}`:e.id,m=l?e.id:`memory:${t.id}:${o}`;r.push({id:`relation:${t.relation}:${t.id}:${o}`,source:p,target:m,type:`smoothstep`,animated:!f,label:t.weight===void 0?t.relation:`${t.relation} ${t.weight.toFixed(2)}`,data:{evidence:t.evidence??[]},style:{stroke:f?`hsl(var(--destructive))`:`hsl(var(--primary))`,strokeWidth:1.7,...f?{strokeDasharray:`5 4`}:{}},labelStyle:{fill:f?`hsl(var(--destructive))`:`hsl(var(--muted-foreground))`,fontSize:I(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:q(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,c,l]);return u.length<=1&&!r&&!i?null:(0,G.jsxs)(`section`,{className:`overflow-hidden border border-border/75 bg-background/35`,"aria-label":a(`activity:memoryManager.graphAria`),children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/70 bg-card/55 px-3 py-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-muted-foreground`,children:a(`activity:memoryManager.graphHeading`)}),u.length>1&&(0,G.jsxs)(z,{variant:`ghost`,size:`sm`,onClick:()=>s(!0),className:`h-6 gap-1 px-2 text-[9px] font-bold uppercase tracking-[0.12em]`,"aria-label":a(`activity:memoryManager.graphFullscreenAria`),children:[(0,G.jsx)(m,{className:`size-3`}),a(`activity:memoryManager.graphOpenFullscreen`)]})]}),(0,G.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:r?a(`activity:memoryManager.loadingGraph`):a(`activity:memoryManager.graphStats`,{nodes:u.length,edges:d.length})})]}),i&&(0,G.jsx)(`p`,{className:`border-b border-destructive/25 bg-destructive/5 px-3 py-2 text-[10px] text-destructive`,children:i}),u.length>1&&(0,G.jsx)(Ue,{nodes:u,edges:d,className:`h-[320px]`}),l.some(e=>e.evidence?.length)&&(0,G.jsx)(`div`,{className:`grid gap-1 border-t border-border/70 bg-card/35 px-3 py-2`,children:l.filter(e=>e.evidence?.length).slice(0,12).map(e=>{let t=(e.from===c?e.to:e.from).slice(4);return(0,G.jsxs)(`p`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:[(0,G.jsx)(`span`,{className:`text-info`,children:e.relation}),` `,ze(t),` · why:`,` `,e.evidence?.join(`, `)]},e.id)})}),o&&(0,G.jsx)(me,{open:o,onOpenChange:s,children:(0,G.jsxs)(L,{className:`flex max-h-[90dvh] max-w-[90vw] flex-col p-0`,showCloseButton:!1,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/70 bg-card/55 px-4 py-3`,children:[(0,G.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-muted-foreground`,children:a(`activity:memoryManager.graphHeadingFull`,{id:e.id})}),(0,G.jsx)(z,{variant:`ghost`,size:`sm`,onClick:()=>s(!1),className:`h-7 gap-1 px-2 text-[10px]`,children:a(`common:action.close`)})]}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1 px-4 pb-4`,children:(0,G.jsx)(Ue,{nodes:u,edges:d,className:`h-[65vh]`})})]})})]})}function Ge({memory:e,allMemories:t,relatedMemories:n,graphEdges:r,graphLoading:i,graphError:o,onClose:s,onOpenMemory:c,onEdit:l,onDelete:u,onTagSelect:d,onNotice:p}){let{t:m}=j();return(0,G.jsxs)(G.Fragment,{children:[(0,G.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,G.jsx)(z,{variant:`ghost`,size:`icon`,className:`md:hidden`,onClick:s,"aria-label":m(`activity:memoryManager.backToList`),children:(0,G.jsx)(A,{className:`size-4`})}),(0,G.jsx)(`span`,{className:F(`text-[10px] font-bold uppercase tracking-[0.14em]`,we(e.kind)),children:je[e.kind]??e.kind}),(0,G.jsx)(Ee,{status:e.status}),(0,G.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,G.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:Ae(e.audience),children:[(0,G.jsx)(a,{className:`size-3`}),Ae(e.audience)]}),(0,G.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,G.jsx)(z,{variant:`ghost`,size:`icon`,"aria-label":m(`activity:memoryManager.copyId`),title:m(`activity:memoryManager.copyId`),onClick:()=>{navigator.clipboard?.writeText(e.id),p(m(`activity:memoryManager.copiedNotice`))},children:(0,G.jsx)(x,{className:`size-4`})}),(0,G.jsxs)(z,{variant:`outline`,size:`sm`,onClick:()=>l(e.id),disabled:e.status===`deleted`,children:[(0,G.jsx)(v,{className:`size-3.5`}),` `,m(`common:action.edit`)]}),(0,G.jsxs)(z,{variant:`destructive`,size:`sm`,onClick:u,disabled:e.status===`deleted`,children:[(0,G.jsx)(f,{className:`size-3.5`}),` `,m(`common:action.delete`)]})]})]}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-4 md:p-5`,children:(0,G.jsxs)(`div`,{className:`mx-auto max-w-5xl space-y-5`,children:[(0,G.jsx)(Z,{memory:e}),(0,G.jsx)(Ke,{memory:e}),e.tags.length>0&&(0,G.jsx)(Q,{tags:e.tags,onTagSelect:d}),e.anchors.length>0&&(0,G.jsx)(qe,{anchors:e.anchors}),n.length>0&&(0,G.jsx)(Je,{relatedMemories:n,allMemories:t,onOpenMemory:c}),(0,G.jsx)(We,{centerMemory:e,allMemories:t,graphEdges:r,loading:i,error:o}),(0,G.jsx)($,{memory:e}),e.status===`deleted`&&(0,G.jsx)(Ye,{contextPolicy:e.contextPolicy})]})})]})}function Z({memory:e}){let{t}=j();return(0,G.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,G.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,G.jsx)(`p`,{className:`relative whitespace-pre-wrap text-sm leading-7 text-foreground md:text-[15px]`,children:e.text}),e.summary&&(0,G.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,G.jsxs)(`div`,{className:`relative mt-5 flex flex-wrap items-center gap-2 border-t border-border/60 pt-3`,children:[(0,G.jsx)(`code`,{className:`min-w-0 break-all font-mono text-[10px] text-muted-foreground`,children:e.id}),(0,G.jsx)(`span`,{className:`ml-auto font-mono text-[10px] text-muted-foreground`,children:t(`activity:memoryManager.revisionSuffix`,{n:e.revision})})]})]})}function Ke({memory:e}){let{t}=j(),n=[[t(`activity:memoryManager.editorImportance`),e.importance,ae],[t(`activity:memoryManager.editorConfidence`),e.confidence,ie],[t(`activity:memoryManager.editorFreshness`),e.freshness,h]];return(0,G.jsx)(`div`,{className:`grid gap-px bg-border/60 sm:grid-cols-3`,children:n.map(([e,t,n])=>(0,G.jsxs)(`div`,{className:`bg-card/60 p-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(n,{className:`size-3.5 text-info`}),(0,G.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.13em] text-muted-foreground`,children:e}),(0,G.jsxs)(`span`,{className:`ml-auto font-mono text-xs font-bold tabular-nums`,children:[Math.round(t*100),`%`]})]}),(0,G.jsx)(`div`,{className:`mt-2 h-1 bg-muted`,children:(0,G.jsx)(`div`,{className:`h-full bg-info shadow-[0_0_8px_hsl(var(--info)/0.45)]`,style:{width:`${Math.round(t*100)}%`}})})]},e))})}function Q({tags:e,onTagSelect:t}){let{t:n}=j();return(0,G.jsxs)(`section`,{children:[(0,G.jsxs)(`h3`,{className:`mb-2 flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:[(0,G.jsx)(k,{className:`size-3.5 text-info`}),` `,n(`activity:memoryManager.tagsLabel`)]}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map(e=>(0,G.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 qe({anchors:e}){let{t}=j();return(0,G.jsxs)(`section`,{className:`border border-border/75 bg-card/40`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/65 px-3 py-2.5`,children:[(0,G.jsxs)(`h3`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:[(0,G.jsx)(o,{className:`size-3.5 text-info`}),` `,t(`activity:memoryManager.editorAnchors`)]}),(0,G.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.length})]}),(0,G.jsx)(`ul`,{className:`divide-y divide-border/55`,children:e.map((e,t)=>(0,G.jsxs)(`li`,{className:`flex min-w-0 items-start gap-3 px-3 py-2.5`,children:[(0,G.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,G.jsx)(w,{className:`size-3.5`}):(0,G.jsx)(o,{className:`size-3.5`})}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`p`,{className:`text-[9px] font-bold uppercase text-muted-foreground`,children:e.type}),(0,G.jsxs)(`p`,{className:`mt-0.5 break-all font-mono text-[10px] leading-4 text-foreground/85`,children:[e.path??e.command??e.role??`—`,e.symbol?`#${e.symbol}`:``]})]}),(e.lineStart||e.lineEnd)&&(0,G.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??e.role}:${t}`))})]})}function Je({relatedMemories:e,allMemories:t,onOpenMemory:n}){let{t:r}=j();return(0,G.jsxs)(`section`,{className:`border border-border/75 bg-card/40`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/65 px-3 py-2.5`,children:[(0,G.jsxs)(`h3`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:[(0,G.jsx)(y,{className:`size-3.5 text-info`}),` `,r(`activity:memoryManager.memoryRelationships`)]}),(0,G.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.length})]}),(0,G.jsx)(`ul`,{className:`divide-y divide-border/55`,children:e.map(e=>{let i=t.find(t=>t.id===e.id);return(0,G.jsx)(`li`,{children:(0,G.jsxs)(`button`,{type:`button`,disabled:!i,onClick:()=>i&&n(i.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,G.jsx)(`span`,{className:F(`w-24 shrink-0 text-[9px] font-bold uppercase`,e.relation===`Contradicts`?`text-destructive`:`text-info`),children:e.relation}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs`,children:i?Ce(i.text,95):r(`activity:memoryManager.referencedUnavailable`)}),(0,G.jsx)(`code`,{className:`hidden max-w-32 truncate font-mono text-[9px] text-muted-foreground sm:block`,children:e.id}),i&&(0,G.jsx)(C,{className:`size-3.5 shrink-0 text-muted-foreground group-hover:text-info`})]})},`${e.relation}:${e.id}`)})})]})}function $({memory:e}){let{t}=j(),n=[[t(`activity:memoryManager.metaCreated`),De(e.createdAt),g],[t(`activity:memoryManager.metaUpdated`),De(e.updatedAt),h],[t(`activity:memoryManager.metaLastAccessed`),De(e.lastAccessedAt),re],[t(`activity:memoryManager.metaLastVerified`),De(e.lastVerifiedAt),ae]];return(0,G.jsx)(`section`,{className:`grid gap-px bg-border/60 sm:grid-cols-2 lg:grid-cols-4`,children:n.map(([e,t,n])=>(0,G.jsxs)(`div`,{className:`bg-card/50 p-3`,children:[(0,G.jsx)(n,{className:`size-3.5 text-muted-foreground`}),(0,G.jsx)(`p`,{className:`mt-2 text-[9px] font-bold uppercase tracking-[0.12em] text-muted-foreground`,children:e}),(0,G.jsx)(`p`,{className:`mt-1 text-[10px] leading-4 text-foreground/85`,children:t})]},e))})}function Ye({contextPolicy:e}){let{t}=j();return(0,G.jsxs)(`div`,{className:`flex items-start gap-3 border border-border bg-muted/50 p-4 text-xs text-muted-foreground`,children:[(0,G.jsx)(te,{className:`mt-0.5 size-4 shrink-0`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-bold text-foreground`,children:t(`activity:memoryManager.deletedMemory`)}),(0,G.jsx)(`p`,{className:`mt-1 leading-5`,children:t(e===`never`?`activity:memoryManager.deletedNeverPolicy`:`activity:memoryManager.deletedEligiblePolicy`)})]})]})}function Xe({currentFilePath:e,knownFilePaths:t,drawerActive:n,onFilePathChange:r,onToggleDrawer:i}){let{t:a}=j();return(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-border/60 bg-card/30 px-3 py-1.5`,children:[(0,G.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:a(`activity:memoryManager.fileDrawerLabel`)}),(0,G.jsx)(`input`,{type:`text`,list:`memory-drawer-file-list`,value:e??``,onChange:e=>{r(e.target.value.trim()||null)},placeholder:a(`activity:memoryManager.selectFilePlaceholder`),className:`min-w-0 max-w-[260px] flex-1 truncate rounded-sm border border-border/60 bg-background px-1.5 py-0.5 text-[10px] font-mono`,"aria-label":a(`activity:memoryManager.fileForDrawerAria`),"data-testid":`memory-drawer-file-select`}),(0,G.jsx)(`datalist`,{id:`memory-drawer-file-list`,children:[...t].sort().map(e=>(0,G.jsx)(`option`,{value:e},e))}),(0,G.jsxs)(z,{type:`button`,size:`sm`,variant:n?`default`:`outline`,onClick:i,disabled:!e,className:`h-7 shrink-0 gap-1 px-2 text-[11px]`,"aria-pressed":n,title:a(n?`activity:memoryManager.hideFileDrawer`:`activity:memoryManager.showFileDrawer`),children:[n?(0,G.jsx)(D,{className:`size-3`}):(0,G.jsx)(ne,{className:`size-3`}),a(n?`activity:memoryManager.hideDrawer`:`activity:memoryManager.showDrawer`)]})]})}function Ze({mode:e,draft:t,busy:n,error:r,onChange:i,onCancel:a,onSubmit:o}){let{t:u}=j(),d=(0,K.useRef)(null),[p,m]=(0,K.useState)([]);(0,K.useEffect)(()=>{d.current?.focus();let e=new AbortController;return _e(`agent-roster.list`,{},e.signal).then(e=>{let t=e.roles;Array.isArray(t)&&m(t.filter(e=>typeof e==`string`))}).catch(()=>void 0),()=>e.abort()},[]);let h=(e,n)=>{i({...t,[e]:n})},g=()=>{h(`anchors`,[...t.anchors,{type:`file`,path:``}])};return(0,G.jsxs)(`form`,{className:`flex min-h-0 flex-1 flex-col`,onSubmit:e=>{e.preventDefault(),o()},"aria-busy":n,children:[(0,G.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,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`flex size-8 items-center justify-center border border-info/35 bg-info/10 text-info`,children:e===`create`?(0,G.jsx)(S,{className:`size-4`}):(0,G.jsx)(v,{className:`size-4`})}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`p`,{className:`truncate text-sm font-bold`,children:u(e===`create`?`activity:memoryManager.captureMemory`:`activity:memoryManager.editMemory`)}),(0,G.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:u(e===`create`?`activity:memoryManager.editorCreateHint`:`activity:memoryManager.editorEditHint`)})]})]}),(0,G.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,G.jsxs)(z,{type:`button`,variant:`ghost`,size:`sm`,onClick:a,disabled:n,children:[(0,G.jsx)(l,{className:`size-3.5`}),` `,u(`common:action.cancel`)]}),(0,G.jsxs)(z,{type:`submit`,size:`sm`,disabled:n||!t.text.trim(),children:[n?(0,G.jsx)(c,{className:`size-3.5 animate-spin`}):e===`create`?(0,G.jsx)(O,{className:`size-3.5`}):(0,G.jsx)(s,{className:`size-3.5`}),u(n?`common:action.saving`:e===`create`?`activity:memoryManager.createMemory`:`activity:memoryManager.saveChanges`)]})]})]}),(0,G.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto overscroll-contain p-4 md:p-5`,children:(0,G.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-5`,children:[r&&(0,G.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,G.jsx)(_,{className:`mt-0.5 size-4 shrink-0`}),(0,G.jsx)(`span`,{children:r})]}),(0,G.jsxs)(`section`,{className:`border border-border/75 bg-card/45 p-4`,children:[(0,G.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-xs font-bold uppercase tracking-[0.14em]`,children:u(`activity:memoryManager.editorKnowledge`)}),(0,G.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:u(`activity:memEditor.writeTheDurableFactOrDecision`)})]}),(0,G.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground tabular-nums`,children:u(`activity:memoryManager.editorCharCount`,{count:t.text.length})})]}),(0,G.jsx)(`label`,{htmlFor:`memory-text`,className:`sr-only`,children:u(`activity:memoryManager.editorContentLabel`)}),(0,G.jsx)(`textarea`,{ref:d,id:`memory-text`,value:t.text,onChange:e=>h(`text`,e.target.value),rows:7,required:!0,placeholder:u(`activity:memoryManager.editorContentPlaceholder`),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,G.jsxs)(`section`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`label`,{htmlFor:`memory-kind`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:u(`activity:memoryManager.editorKind`)}),(0,G.jsx)(`select`,{id:`memory-kind`,value:t.kind,onChange:e=>h(`kind`,e.target.value),className:`h-10 w-full border border-input bg-background px-3 text-sm`,children:Te.map(e=>(0,G.jsx)(`option`,{value:e,children:je[e]},e))})]}),e===`create`?(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`label`,{htmlFor:`memory-scope`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:u(`activity:memoryManager.editorScope`)}),(0,G.jsx)(`select`,{id:`memory-scope`,value:t.scope,onChange:e=>h(`scope`,e.target.value),className:`h-10 w-full border border-input bg-background px-3 text-sm`,children:ye.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))})]}):(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`label`,{htmlFor:`memory-status`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:u(`activity:memoryManager.editorLifecycleStatus`)}),(0,G.jsx)(`select`,{id:`memory-status`,value:t.status,onChange:e=>h(`status`,e.target.value),className:`h-10 w-full border border-input bg-background px-3 text-sm`,children:Oe.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))})]}),(0,G.jsxs)(`div`,{className:F(`min-w-0`,e===`create`?`sm:col-span-2 lg:col-span-1`:``),children:[(0,G.jsx)(`label`,{htmlFor:`memory-tags`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:u(`activity:memoryManager.tagsLabel`)}),(0,G.jsx)(B,{id:`memory-tags`,value:t.tags,onChange:e=>h(`tags`,e.target.value),placeholder:u(`activity:memEditor.architectureWebuiWorkflow`),className:`h-10 bg-background`})]})]}),(0,G.jsxs)(`section`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,G.jsx)(H,{id:`memory-importance`,label:u(`activity:memoryManager.editorImportance`),value:t.importance,onChange:e=>h(`importance`,e)}),(0,G.jsx)(H,{id:`memory-confidence`,label:u(`activity:memoryManager.editorConfidence`),value:t.confidence,onChange:e=>h(`confidence`,e)}),(0,G.jsx)(H,{id:`memory-freshness`,label:u(`activity:memoryManager.editorFreshness`),value:t.freshness,onChange:e=>h(`freshness`,e)})]}),(0,G.jsxs)(`section`,{className:`border border-border/75 bg-card/45 p-4`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-xs font-bold uppercase tracking-[0.14em]`,children:u(`activity:memoryManager.editorAnchors`)}),(0,G.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:u(`activity:memEditor.bindKnowledgeToFilesSymbolsPackages`)})]}),(0,G.jsxs)(z,{type:`button`,variant:`outline`,size:`sm`,onClick:g,children:[(0,G.jsx)(O,{className:`size-3.5`}),` `,u(`activity:memoryManager.addAnchor`)]})]}),t.anchors.length===0?(0,G.jsxs)(`button`,{type:`button`,onClick:g,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,G.jsx)(oe,{className:`size-4`}),` `,u(`activity:memoryManager.noAnchors`)]}):(0,G.jsx)(`div`,{className:`mt-4 space-y-2`,children:t.anchors.map((e,n)=>(0,G.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,G.jsxs)(`label`,{className:`sr-only`,htmlFor:`anchor-type-${n}`,children:[`Anchor `,n+1,` type`]}),(0,G.jsx)(`select`,{id:`anchor-type-${n}`,value:e.type,onChange:e=>{let r=e.target.value,i=r===`command`?{type:r,command:``}:r===`agent`?{type:r,role:``}:{type:r,path:``},a=t.anchors.map((e,t)=>t===n?i:e);h(`anchors`,a)},className:`h-10 border border-input bg-background px-2 text-xs`,children:Me.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))}),(0,G.jsxs)(`div`,{className:F(`grid min-w-0 gap-2`,e.type===`symbol`&&`sm:grid-cols-[minmax(0,1fr)_11rem]`),children:[(0,G.jsxs)(`label`,{className:`sr-only`,htmlFor:`anchor-value-${n}`,children:[`Anchor `,n+1,` value`]}),(0,G.jsx)(B,{id:`anchor-value-${n}`,list:e.type===`agent`?`memory-agent-role-options`:void 0,value:Ne(e),onChange:e=>{let r=t.anchors.map((t,r)=>r===n?be(t,e.target.value):t);h(`anchors`,r)},placeholder:e.type===`command`?`pnpm test --filter webui`:e.type===`agent`?`reviewer`:`packages/webui/src/App.tsx`,className:`h-10 min-w-0 bg-background font-mono text-xs`}),e.type===`symbol`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`label`,{className:`sr-only`,htmlFor:`anchor-symbol-${n}`,children:[`Anchor `,n+1,` symbol`]}),(0,G.jsx)(B,{id:`anchor-symbol-${n}`,value:e.symbol??``,onChange:e=>{let r=t.anchors.map((t,r)=>r===n?{...t,symbol:e.target.value}:t);h(`anchors`,r)},placeholder:u(`activity:memoryManager.editorSymbolPlaceholder`),className:`h-10 bg-background font-mono text-xs`})]})]}),(0,G.jsx)(z,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Remove anchor ${n+1}`,onClick:()=>h(`anchors`,t.anchors.filter((e,t)=>t!==n)),children:(0,G.jsx)(f,{className:`size-4 text-destructive`})})]},`${e.type}:${n}`))}),(0,G.jsx)(`datalist`,{id:`memory-agent-role-options`,children:p.map(e=>(0,G.jsx)(`option`,{value:e},e))})]}),(0,G.jsxs)(`section`,{className:`grid gap-3 border border-border/75 bg-card/45 p-4 sm:grid-cols-2`,children:[(0,G.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,G.jsx)(`h3`,{className:`text-xs font-bold uppercase tracking-[0.14em]`,children:u(`activity:memoryManager.editorRelationships`)}),(0,G.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:u(`activity:memoryManager.editorRelationshipsHint`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{htmlFor:`memory-supersedes`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:u(`activity:memoryManager.editorSupersedes`)}),(0,G.jsx)(B,{id:`memory-supersedes`,value:t.supersedes,onChange:e=>h(`supersedes`,e.target.value),placeholder:u(`activity:memEditor.memIdMemId`),className:`h-10 bg-background font-mono text-xs`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{htmlFor:`memory-contradicts`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:u(`activity:memoryManager.editorContradicts`)}),(0,G.jsx)(B,{id:`memory-contradicts`,value:t.contradicts,onChange:e=>h(`contradicts`,e.target.value),placeholder:u(`activity:memEditor.memIdMemId`),className:`h-10 bg-background font-mono text-xs`})]})]}),(0,G.jsxs)(`section`,{className:`space-y-2`,children:[(0,G.jsx)(`h3`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:u(`activity:memEditor.audienceOptional`)}),(0,G.jsx)(`p`,{className:`text-[10px] text-muted-foreground/70`,children:u(`activity:memEditor.targetThisMemoryToSpecificAgent`)}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{htmlFor:`memory-audience-roles`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:u(`activity:memEditor.roles`)}),(0,G.jsx)(B,{id:`memory-audience-roles`,value:t.audienceRoles,onChange:e=>h(`audienceRoles`,e.target.value),placeholder:u(`activity:memEditor.reviewerRefactorPlanner`),className:`h-9 bg-background font-mono text-xs`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{htmlFor:`memory-audience-task-types`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:u(`activity:memoryManager.editorTaskTypes`)}),(0,G.jsx)(B,{id:`memory-audience-task-types`,value:t.audienceTaskTypes,onChange:e=>h(`audienceTaskTypes`,e.target.value),placeholder:u(`activity:memEditor.reviewRefactorBugfix`),className:`h-9 bg-background font-mono text-xs`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{htmlFor:`memory-audience-modes`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:u(`activity:memEditor.modes`)}),(0,G.jsx)(B,{id:`memory-audience-modes`,value:t.audienceModes,onChange:e=>h(`audienceModes`,e.target.value),placeholder:u(`activity:memEditor.teachCodeReview`),className:`h-9 bg-background font-mono text-xs`})]})]})]})})]})}function Qe({searchQuery:e,statusFilter:t,kindFilter:n,audienceOnly:r,tagFilter:o,hasFilters:s,allTags:c,stats:d,onSearchChange:f,onStatusFilterChange:p,onKindFilterChange:m,onToggleAudienceOnly:h,onTagFilterChange:g,onClearFilters:ee}){let{t:_}=j(),[v,y]=(0,K.useState)(!!o),b=v||!!o,x=c.length>0;return(0,G.jsxs)(`div`,{className:`shrink-0 space-y-2 overflow-hidden border-b border-border/70 bg-card/45 p-3`,children:[(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,G.jsx)(i,{className:`pointer-events-none absolute left-3 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,G.jsx)(B,{"aria-label":_(`activity:memoryManager.searchAria`),value:e,onChange:e=>f(e.target.value),placeholder:_(`activity:memoryManager.searchPlaceholder`),className:`h-10 min-w-0 bg-background pl-9 pr-8 text-xs`}),e&&(0,G.jsx)(`button`,{type:`button`,"aria-label":_(`activity:memoryManager.clearSearchAria`),onClick:()=>f(``),className:`absolute right-2 top-1/2 -translate-y-1/2 p-1 text-muted-foreground hover:text-foreground`,children:(0,G.jsx)(l,{className:`size-3.5`})})]}),(0,G.jsx)(z,{variant:r?`default`:`ghost`,size:`icon`,onClick:h,"aria-label":_(`activity:memoryManager.audienceFilterAria`),title:_(`activity:memoryManager.audienceFilterTitle`),className:`shrink-0`,children:(0,G.jsx)(a,{className:`size-4`})}),s&&(0,G.jsx)(z,{variant:`ghost`,size:`icon`,onClick:ee,"aria-label":_(`activity:memoryManager.clearFiltersAria`),title:_(`activity:memoryManager.clearFiltersTitle`),children:(0,G.jsx)(T,{className:`size-4`})})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,G.jsx)(`label`,{className:`sr-only`,htmlFor:`memory-status-filter`,children:_(`activity:memoryManager.filterByStatus`)}),(0,G.jsxs)(`select`,{id:`memory-status-filter`,value:t,onChange:e=>p(e.target.value),className:`h-9 min-w-0 border border-input bg-background px-2 text-xs`,children:[(0,G.jsx)(`option`,{value:`all`,children:_(`activity:memoryManager.allStatuses`)}),ke.map(e=>(0,G.jsxs)(`option`,{value:e,children:[e,` · `,d?.byStatus[e]??0]},e))]}),(0,G.jsx)(`label`,{className:`sr-only`,htmlFor:`memory-kind-filter`,children:_(`activity:memoryManager.filterByKind`)}),(0,G.jsxs)(`select`,{id:`memory-kind-filter`,value:n,onChange:e=>m(e.target.value),className:`h-9 min-w-0 border border-input bg-background px-2 text-xs`,children:[(0,G.jsx)(`option`,{value:`all`,children:_(`activity:memoryManager.allKinds`)}),Te.map(e=>(0,G.jsxs)(`option`,{value:e,children:[je[e],` · `,d?.byKind[e]??0]},e))]})]}),x&&(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{o||y(e=>!e)},"aria-expanded":b,"aria-controls":`memory-tags-panel`,disabled:!!o,className:F(`flex items-center gap-1.5 px-1 py-0.5 text-[10px] uppercase tracking-wide transition-colors`,b?`text-foreground`:`text-muted-foreground hover:text-foreground`,!!o&&`cursor-default`),title:o?`Active filter: ${o} (click the chip to clear)`:b?`Hide tag filters`:`Show tag filters (${c.length})`,children:[(0,G.jsx)(u,{className:F(`size-3 transition-transform`,!b&&`-rotate-90`)}),(0,G.jsx)(k,{className:`size-3`}),(0,G.jsx)(`span`,{className:`font-semibold`,children:_(`activity:memoryManager.tagsLabel`)}),(0,G.jsx)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:c.length})]}),o&&(0,G.jsx)(`span`,{role:`status`,"aria-label":`Active tag filter: ${o}`,className:`border border-info/55 bg-info/10 px-1 font-mono text-[9px] uppercase text-info`,children:o})]}),x&&b&&(0,G.jsxs)(`fieldset`,{id:`memory-tags-panel`,className:`min-w-0 border-0 p-0`,children:[(0,G.jsx)(`legend`,{className:`sr-only`,children:_(`activity:memoryManager.popularTags`)}),(0,G.jsx)(`div`,{className:`no-scrollbar flex gap-1.5 overflow-x-auto pb-0.5`,children:c.slice(0,18).map(([e,t])=>(0,G.jsxs)(`button`,{type:`button`,"aria-pressed":o===e,onClick:()=>g(o===e?null:e),className:F(`flex shrink-0 items-center gap-1 border px-2 py-1 text-[10px] transition-colors`,o===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,G.jsx)(k,{className:`size-2.5`}),` `,e,(0,G.jsx)(`span`,{className:`font-mono opacity-60`,children:t})]},e))})]})]})}var $e=100;function et({memoryListRef:e,memories:t,filteredMemories:n,selectedId:r,onSelectMemory:i,onOpenCreate:a,onClearFilters:o}){let{t:s}=j(),c=n.length>$e,l=E({count:n.length,getScrollElement:()=>e.current,estimateSize:()=>100,overscan:8,enabled:c});return(0,G.jsxs)(G.Fragment,{children:[(0,G.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,G.jsx)(`span`,{children:s(`activity:memoryManager.memoryCountSummary`,{shown:n.length,total:t.length})}),(0,G.jsx)(`span`,{className:`font-mono uppercase`,children:s(`activity:memoryManager.updatedSortLabel`)})]}),(0,G.jsx)(`section`,{ref:e,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,"aria-label":s(`activity:memoryManager.listAria`),children:n.length===0?(0,G.jsx)(tt,{hasMemories:t.length>0,onOpenCreate:a,onClearFilters:o}):c?(0,G.jsx)(`div`,{style:{height:`${l.getTotalSize()}px`,width:`100%`,position:`relative`},children:l.getVirtualItems().map(e=>{let t=n[e.index];return t?(0,G.jsx)(`div`,{"data-index":e.index,ref:l.measureElement,style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${e.start}px)`},children:(0,G.jsx)(nt,{memory:t,isSelected:r===t.id,onClick:()=>i(t.id)})},t.id):null})}):n.map(e=>(0,G.jsx)(nt,{memory:e,isSelected:r===e.id,onClick:()=>i(e.id)},e.id))})]})}function tt({hasMemories:e,onOpenCreate:t,onClearFilters:n}){let{t:r}=j();return(0,G.jsxs)(`div`,{className:`flex min-h-64 flex-col items-center justify-center px-6 text-center`,children:[(0,G.jsx)(`span`,{className:`flex size-12 items-center justify-center border border-dashed border-border text-muted-foreground`,children:(0,G.jsx)(ee,{className:`size-5`})}),(0,G.jsx)(`h2`,{className:`mt-4 text-sm font-bold`,children:r(e?`activity:memoryManager.noMatching`:`activity:memoryManager.buildGraph`)}),(0,G.jsx)(`p`,{className:`mt-1 max-w-xs text-xs leading-5 text-muted-foreground`,children:r(e?`activity:memoryManager.emptyFiltered`:`activity:memoryManager.emptyCapture`)}),(0,G.jsxs)(z,{className:`mt-4`,variant:`outline`,size:`sm`,onClick:e?n:t,children:[e?(0,G.jsx)(T,{className:`size-3.5`}):(0,G.jsx)(O,{className:`size-3.5`}),r(e?`activity:memoryManager.clearFilters`:`activity:memoryManager.createFirst`)]})]})}function nt({memory:e,isSelected:t,onClick:n}){return(0,G.jsxs)(`button`,{type:`button`,"aria-current":t?`true`:void 0,onClick:n,className:F(`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`,t&&`bg-info/8`),children:[t&&(0,G.jsx)(`span`,{className:`absolute inset-y-0 left-0 w-0.5 bg-info shadow-[0_0_10px_hsl(var(--info)/0.7)]`}),(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:F(`truncate text-[10px] font-bold uppercase tracking-[0.1em]`,we(e.kind)),children:je[e.kind]??e.kind}),(0,G.jsx)(Ee,{status:e.status}),(0,G.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono text-[9px] text-muted-foreground`,children:[`r`,e.revision]})]}),(0,G.jsx)(`p`,{className:F(`mt-2 line-clamp-2 text-xs leading-5 text-foreground/90`,e.status===`deleted`&&`line-through opacity-60`),children:Ce(e.text)}),(0,G.jsxs)(`div`,{className:`mt-2 flex min-w-0 items-center gap-1.5`,children:[(0,G.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,G.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,G.jsx)(a,{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,G.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,G.jsxs)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:[`+`,e.tags.length-2]}),(0,G.jsx)(`span`,{className:`ml-auto shrink-0 text-[9px] text-muted-foreground`,children:Pe(e.updatedAt)}),(0,G.jsx)(C,{className:`size-3 shrink-0 text-muted-foreground transition-transform group-hover:translate-x-0.5 group-hover:text-info`})]})]})}function rt({onCapture:e}){let{t}=j();return(0,G.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center p-8 text-center`,children:[(0,G.jsxs)(`div`,{className:`relative flex size-20 items-center justify-center border border-info/25 bg-info/5 text-info`,children:[(0,G.jsx)(a,{className:`size-8`}),(0,G.jsx)(`span`,{className:`absolute inset-2 border border-info/10`})]}),(0,G.jsx)(`h2`,{className:`mt-5 text-lg font-bold`,children:t(`activity:memoryManager.emptyTitle`)}),(0,G.jsx)(`p`,{className:`mt-2 max-w-md text-sm leading-6 text-muted-foreground`,children:t(`activity:memoryManager.emptyBody`)}),(0,G.jsxs)(`div`,{className:`mt-6 grid w-full max-w-lg gap-2 sm:grid-cols-3`,children:[(0,G.jsxs)(`div`,{className:`border border-border/70 bg-card/45 p-3`,children:[(0,G.jsx)(d,{className:`mx-auto size-4 text-success`}),(0,G.jsx)(`p`,{className:`mt-2 text-[10px] font-bold uppercase`,children:t(`activity:memoryManager.emptyVerifiedAnchors`)})]}),(0,G.jsxs)(`div`,{className:`border border-border/70 bg-card/45 p-3`,children:[(0,G.jsx)(a,{className:`mx-auto size-4 text-info`}),(0,G.jsx)(`p`,{className:`mt-2 text-[10px] font-bold uppercase`,children:t(`activity:memoryManager.emptyTypedRelations`)})]}),(0,G.jsxs)(`div`,{className:`border border-border/70 bg-card/45 p-3`,children:[(0,G.jsx)(O,{className:`mx-auto size-4 text-warning`}),(0,G.jsx)(`p`,{className:`mt-2 text-[10px] font-bold uppercase`,children:t(`activity:memoryManager.emptyAgentRecall`)})]})]}),(0,G.jsxs)(z,{onClick:e,children:[(0,G.jsx)(O,{className:`size-4`}),` `,t(`activity:memoryManager.captureButton`)]})]})}function it({wsConnected:e,refreshing:t,onRefresh:n,onCreate:r}){let{t:i}=j(),o=ue(e=>e.setCurrentView);return(0,G.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,G.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,G.jsxs)(`div`,{className:`relative flex flex-wrap items-center gap-3`,children:[(0,G.jsx)(z,{variant:`ghost`,size:`icon`,onClick:()=>o(`chat`),"aria-label":i(`activity:memoryManager.backToChat`),title:i(`activity:memoryManager.backToChat`),children:(0,G.jsx)(A,{className:`size-4`})}),(0,G.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,G.jsx)(a,{className:`size-5`})}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`h1`,{className:`text-base font-bold sm:text-lg`,children:i(`activity:memoryManager.sageHeading`)}),(0,G.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:i(`activity:memoryManager.projectKnowledge`)})]}),(0,G.jsx)(`p`,{className:`mt-0.5 max-w-2xl text-[10px] text-muted-foreground sm:text-xs`,children:i(`activity:memoryManager.sageSubtitle`)})]}),(0,G.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,G.jsxs)(`span`,{className:F(`hidden items-center gap-1.5 border px-2 py-1 font-mono text-[9px] uppercase sm:flex`,e?`border-success/30 text-success`:`border-warning/30 text-warning`),children:[(0,G.jsx)(`span`,{className:`size-1.5 bg-current`}),` `,i(e?`activity:memoryManager.liveStore`:`activity:memoryManager.reconnecting`)]}),(0,G.jsxs)(z,{variant:`outline`,size:`sm`,onClick:n,disabled:t,"aria-label":i(`activity:memoryManager.refreshAria`),children:[(0,G.jsx)(h,{className:F(`size-3.5`,t&&`animate-spin`)}),(0,G.jsx)(`span`,{className:`hidden sm:inline`,children:i(`common:action.refresh`)})]}),(0,G.jsxs)(z,{size:`sm`,onClick:r,children:[(0,G.jsx)(O,{className:`size-3.5`}),` `,i(`activity:memoryManager.newMemory`)]})]})]})]})}function at({stats:e,memories:t,filteredCount:n,allTagsCount:r}){let{t:i}=j(),o=t.filter(e=>e.audience).length,s=new Set;if(o>0){for(let e of t)if(e.audience){for(let t of e.audience.roles??[])s.add(t);for(let t of e.audience.taskTypes??[])s.add(t);for(let t of e.audience.modes??[])s.add(t)}}return(0,G.jsxs)(G.Fragment,{children:[(0,G.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,G.jsx)(U,{label:i(`activity:memoryManager.tabMemories`),value:e?.total??t.length,hint:`${n} visible`}),(0,G.jsx)(U,{label:i(`activity:memoryManager.tabActive`),value:e?.byStatus.active??t.filter(e=>e.status===`active`).length,hint:`retrievable`,tone:`success`}),(0,G.jsx)(U,{label:i(`activity:memoryManager.tabNeedsReview`),value:(e?.byStatus.stale??0)+(e?.byStatus.contradicted??0),hint:i(`activity:memoryManager.staleConflicts`),tone:`warning`}),(0,G.jsx)(`div`,{className:`hidden sm:block`,children:(0,G.jsx)(U,{label:i(`activity:memoryManager.tabGraphEdges`),value:e?.edges??0,hint:`${r} tags`,tone:`info`})})]}),o>0&&(0,G.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,G.jsx)(a,{className:`size-3.5 text-primary`}),(0,G.jsxs)(`span`,{className:`text-[11px] font-medium text-primary`,children:[o,` audience-scoped memory`,o===1?``:`ies`]}),s.size>0&&(0,G.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`(`,[...s].sort().join(`, `),`)`]})]})]})}function ot({query:e,channel:t,hits:n,loading:r,error:i,onOpenMemory:a,onClear:o}){let{t:s}=j();return e?(0,G.jsxs)(`section`,{"aria-label":s(`activity:memoryManager.searchBreakdownAria`),className:`border-b border-border/60 bg-card/35`,children:[(0,G.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between border-b border-border/55 px-3 py-2 text-[10px] text-muted-foreground`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(S,{className:`size-3 text-info`}),(0,G.jsx)(`span`,{className:`font-mono uppercase tracking-[0.1em]`,children:s(`activity:memoryManager.searchBreakdownTitle`,{query:e})}),t===`breakdown`&&(0,G.jsx)(`span`,{className:`border border-info/40 bg-info/8 px-1.5 py-0.5 font-mono text-[9px] uppercase text-info`,children:s(`activity:memoryManager.searchBreakdownDual`)}),t===`lexical`&&(0,G.jsx)(`span`,{className:`border border-border/60 px-1.5 py-0.5 font-mono text-[9px] uppercase text-muted-foreground`,children:s(`activity:memoryManager.searchBreakdownLexicalOnly`)})]}),(0,G.jsx)(`button`,{type:`button`,onClick:o,className:`font-mono text-[10px] uppercase text-muted-foreground hover:text-foreground`,children:s(`common:action.close`)})]}),r&&(0,G.jsx)(`p`,{className:`px-3 py-3 text-[10px] text-muted-foreground`,children:s(`activity:memoryManager.searchBreakdownLoading`)}),i&&(0,G.jsx)(`p`,{className:`border-t border-border/55 px-3 py-2 text-[10px] text-destructive`,role:`alert`,children:i}),!r&&!i&&n.length===0&&(0,G.jsx)(`p`,{className:`px-3 py-3 text-[10px] text-muted-foreground`,children:s(`activity:memoryManager.searchBreakdownEmpty`)}),(0,G.jsx)(`ul`,{className:`divide-y divide-border/55`,children:n.map(e=>(0,G.jsx)(st,{hit:e,onOpenMemory:a},e.memory.id))})]}):null}function st({hit:e,onOpenMemory:t}){let{t:n}=j(),r=ct(e.lexicalScore),i=ct(e.vectorScore),a=ct(e.finalScore),{accent:o,label:s}=lt(e.source);return(0,G.jsx)(`li`,{children:(0,G.jsxs)(`button`,{type:`button`,onClick:()=>t(e.memory.id),className:`group flex w-full min-w-0 items-start gap-3 px-3 py-2.5 text-left hover:bg-info/5`,children:[(0,G.jsx)(`span`,{className:F(`flex size-7 shrink-0 items-center justify-center border font-mono text-[9px] uppercase`,o),title:n(`activity:memoryManager.searchBreakdownSourceLabel`,{source:s}),children:e.source===`vector`?(0,G.jsx)(S,{className:`size-3.5`}):e.source===`both`?(0,G.jsx)(p,{className:`size-3.5`}):(0,G.jsx)(b,{className:`size-3.5`})}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`p`,{className:`line-clamp-2 text-[11px] leading-5 text-foreground/90`,children:e.memory.text}),(0,G.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1 font-mono text-[9px] text-muted-foreground`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`span`,{className:`uppercase text-[9px] text-muted-foreground/80`,children:`L`}),(0,G.jsx)(`span`,{className:`tabular-nums text-foreground/80`,children:r})]}),(0,G.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`span`,{className:`uppercase text-[9px] text-muted-foreground/80`,children:`V`}),(0,G.jsx)(`span`,{className:F(`tabular-nums`,e.vectorScore===null?`text-muted-foreground/50`:`text-foreground/80`),children:i})]}),(0,G.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`span`,{className:`uppercase text-[9px] text-muted-foreground/80`,children:`RRF`}),(0,G.jsx)(`span`,{className:`tabular-nums font-bold text-foreground`,children:a})]}),(0,G.jsx)(`span`,{className:`ml-auto uppercase text-[9px]`,children:s})]})]})]})})}function ct(e){return e===null?`—`:`${Math.round(e*100)}%`}function lt(e){switch(e){case`vector`:return{accent:`border-accent/40 bg-accent/10 text-accent`,label:`vector`};case`both`:return{accent:`border-info/40 bg-info/10 text-info`,label:`both`};default:return{accent:`border-border/60 bg-background text-muted-foreground`,label:`lexical`}}}function ut({listCandidates:e,resolveCandidate:t,onOpenMemory:n,client:r,active:i}){let{t:a}=j(),[o,s]=(0,K.useState)([]),[u,f]=(0,K.useState)(!1),[p,m]=(0,K.useState)(null),[g,ee]=(0,K.useState)(null),[v,y]=(0,K.useState)(!1),[b,x]=(0,K.useState)(()=>new Set),S=(0,K.useRef)(0),C=(0,K.useCallback)(()=>{let t=++S.current;f(!0),m(null);let n=r.on(`memory.sage.listCandidates`,e=>{if(t===S.current){if(n(),e.payload.error)m(String(e.payload.error)),s([]);else{let t=(Array.isArray(e.payload.candidates)?e.payload.candidates:[]).filter(e=>e.status===`pending`);s(t),x(e=>{let n=new Set;for(let r of e)t.some(e=>e.id===r)&&n.add(r);return n})}f(!1)}}),i=setTimeout(()=>{t===S.current&&(n(),f(!1),m(a(`activity:memoryManager.reviewLoadTimeout`)))},15e3);return e({includeResolved:!1},{echoToChat:!1}),()=>{clearTimeout(i),n()}},[r,e,a]);(0,K.useEffect)(()=>{if(i)return C()},[i,C]);let w=(0,K.useCallback)((e,n)=>new Promise(i=>{let a=r.on(`memory.sage.candidateResolve`,e=>{a();let t=e.payload.error;i(!t)});t({candidateId:e,action:n,reason:n===`reject`?`Rejected via Memory Review tab`:void 0},{echoToChat:!1}),setTimeout(()=>{a(),i(!1)},15e3)}),[r,t]),T=(0,K.useCallback)(async(e,t)=>{ee(e),await w(e,t),ee(null),C()},[C,w]),E=(0,K.useCallback)(async e=>{let t=[...b];if(t.length!==0){y(!0);for(let n of t)await w(n,e);y(!1),x(new Set),C()}},[C,w,b]),D=e=>{x(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},te=()=>{x(new Set(o.map(e=>e.id)))},O=()=>x(new Set);if(u&&o.length===0)return(0,G.jsxs)(`div`,{className:`flex flex-1 items-center justify-center gap-2 p-6 text-sm text-muted-foreground`,children:[(0,G.jsx)(c,{className:`size-4 animate-spin`}),a(`activity:memoryManager.reviewLoading`)]});if(p&&o.length===0)return(0,G.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center`,children:[(0,G.jsx)(_,{className:`size-5 text-warning`}),(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:p}),(0,G.jsxs)(z,{size:`sm`,variant:`outline`,onClick:()=>C(),children:[(0,G.jsx)(h,{className:`size-3.5`}),` `,a(`common:action.retry`)]})]});if(o.length===0)return(0,G.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-2 p-8 text-center`,children:[(0,G.jsx)(d,{className:`size-6 text-success`}),(0,G.jsx)(`p`,{className:`text-sm font-medium`,children:a(`activity:memoryManager.reviewEmptyTitle`)}),(0,G.jsx)(`p`,{className:`max-w-sm text-xs text-muted-foreground`,children:a(`activity:memoryManager.reviewEmptyHint`)}),(0,G.jsxs)(z,{size:`sm`,variant:`ghost`,onClick:()=>C(),children:[(0,G.jsx)(h,{className:`size-3.5`}),` `,a(`common:action.refresh`)]})]});let k=b.size,A=k===o.length&&o.length>0;return(0,G.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,G.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2 border-b border-border/60 px-3 py-2`,children:[(0,G.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-wide text-muted-foreground`,children:a(`activity:memoryManager.reviewPendingCount`,{count:o.length})}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,G.jsx)(z,{size:`sm`,variant:`ghost`,className:`h-7 text-[11px]`,onClick:A?O:te,children:a(A?`activity:memoryManager.reviewClearSelection`:`activity:memoryManager.reviewSelectAll`)}),(0,G.jsxs)(z,{size:`sm`,className:`h-7`,disabled:k===0||v,onClick:()=>void E(`accept`),children:[v?(0,G.jsx)(c,{className:`size-3 animate-spin`}):(0,G.jsx)(d,{className:`size-3`}),a(`activity:memoryManager.reviewBulkAccept`),k>0?` (${k})`:``]}),(0,G.jsxs)(z,{size:`sm`,variant:`outline`,className:`h-7`,disabled:k===0||v,onClick:()=>void E(`reject`),children:[(0,G.jsx)(l,{className:`size-3`}),a(`activity:memoryManager.reviewBulkKeep`),k>0?` (${k})`:``]}),(0,G.jsx)(z,{size:`sm`,variant:`ghost`,className:`h-7`,onClick:()=>C(),disabled:u,children:(0,G.jsx)(h,{className:F(`size-3.5`,u&&`animate-spin`)})})]})]}),(0,G.jsx)(`ul`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto p-3`,children:o.map(e=>{let t=e.targetMemoryId??e.memoryId,r=e.reviewReason??e.reason??``,i=g===e.id||v,o=b.has(e.id);return(0,G.jsx)(`li`,{className:F(`rounded-md border bg-card/60 p-3 text-sm shadow-sm`,o?`border-primary/50 ring-1 ring-primary/20`:`border-border/70`),children:(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`input`,{type:`checkbox`,className:`mt-1 size-3.5 accent-primary`,checked:o,disabled:v,onChange:()=>D(e.id),"aria-label":a(`activity:memoryManager.reviewSelectOne`)}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 text-[10px] uppercase tracking-wide text-muted-foreground`,children:[(0,G.jsx)(`span`,{className:`font-mono text-warning`,children:e.suggestedAction??`review`}),(0,G.jsx)(`span`,{children:`·`}),(0,G.jsx)(`span`,{children:Pe(e.createdAt)}),e.tags?.includes(`triage`)&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{children:`·`}),(0,G.jsx)(`span`,{className:`text-info`,children:`triage`})]})]}),(0,G.jsx)(`p`,{className:`mt-1.5 text-[13px] leading-snug text-foreground`,children:Ce(e.text,220)}),r?(0,G.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:r}):null,t?(0,G.jsxs)(`button`,{type:`button`,className:`mt-1 font-mono text-[10px] text-primary hover:underline`,onClick:()=>n?.(t),children:[t.slice(0,16),`…`]}):null,(0,G.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:[(0,G.jsxs)(z,{size:`sm`,className:`h-7`,disabled:i,onClick:()=>void T(e.id,`accept`),children:[g===e.id?(0,G.jsx)(c,{className:`size-3 animate-spin`}):(0,G.jsx)(d,{className:`size-3`}),a(`activity:memoryManager.actionAcceptDeletion`)]}),(0,G.jsxs)(z,{size:`sm`,variant:`outline`,className:`h-7`,disabled:i,onClick:()=>void T(e.id,`reject`),children:[(0,G.jsx)(l,{className:`size-3`}),a(`activity:memoryManager.actionKeep`)]})]})]})]})},e.id)})})]})}function dt(e,t){let n=t.searchQuery.trim().toLowerCase();return e.filter(e=>{if(t.statusFilter!==`all`&&e.status!==t.statusFilter||t.kindFilter!==`all`&&e.kind!==t.kindFilter||t.tagFilter&&!e.tags.includes(t.tagFilter)||t.audienceOnly&&!e.audience)return!1;if(!n)return!0;let r=e.anchors.map(e=>[e.path,e.symbol,e.command,e.role].filter(Boolean).join(` `)).join(` `),i=e.audience?[e.audience.roles?.join(` `)??``,e.audience.taskTypes?.join(` `)??``,e.audience.modes?.join(` `)??``].join(` `):``;return[e.id,e.text,e.summary??``,e.kind,e.scope,e.tags.join(` `),r,i].join(` `).toLowerCase().includes(n)})}function ft(e){let t=new Map;for(let n of e)for(let e of n.tags)t.set(e,(t.get(e)??0)+1);return[...t.entries()].sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0]))}function pt(e){if(!e)return[];let t=[];e.supersededBy&&t.push({relation:`Superseded by`,id:e.supersededBy});for(let n of e.supersedes??[])t.push({relation:`Supersedes`,id:n});for(let n of e.contradicts??[])t.push({relation:`Contradicts`,id:n});return t}var mt=100;function ht(){let{t:e}=j(),{client:n,listSageMemoriesPage:r,listMemoryCandidates:i,rememberSage:a,updateSage:o,deleteSage:s,getSageGraph:c,recoverSage:l,resolveMemoryCandidate:u,searchSageBreakdown:d}=he(),f=t(e=>e.wsConnected),[p,m]=(0,K.useState)([]),[h,g]=(0,K.useState)(null),[ee,_]=(0,K.useState)(!0),[v,y]=(0,K.useState)(!1),[b,x]=(0,K.useState)(null),[S,C]=(0,K.useState)(null),[w,T]=(0,K.useState)(null),[E,D]=(0,K.useState)(null),[te,O]=(0,K.useState)([]),[k,A]=(0,K.useState)([]),[ne,re]=(0,K.useState)(null),[ie,ae]=(0,K.useState)(!1),[oe,M]=(0,K.useState)(!1),[N,se]=(0,K.useState)(!1),[P,ce]=(0,K.useState)(Se),[le,F]=(0,K.useState)(Se),[ue,I]=(0,K.useState)(null),[de,fe]=(0,K.useState)(null),[L,pe]=(0,K.useState)({hits:[],channel:void 0,loading:!1,error:null}),[R,me]=(0,K.useState)(``),[z,B]=(0,K.useState)(`all`),[V,_e]=(0,K.useState)(`all`),[ye,be]=(0,K.useState)(!1),[H,Ce]=(0,K.useState)(null),[we,Te]=(0,K.useState)(`active`),Ee=we===`deleted`,De=we===`review`,[Oe,ke]=(0,K.useState)(null),[Ae,je]=(0,K.useState)(!1),[U,Me]=(0,K.useState)(!1),[Ne,Pe]=(0,K.useState)({}),[Fe,G]=(0,K.useState)(!1),[Ie,Le]=(0,K.useState)(null),Re=(0,K.useRef)(!1),ze=(0,K.useRef)([]),Be=(0,K.useRef)(0),q=(0,K.useRef)(null),J=(0,K.useRef)(!0),Ve=(0,K.useRef)(0),Y=(0,K.useRef)(0),He=(0,K.useRef)(null),X=(0,K.useRef)(null),Ue=(0,K.useMemo)(()=>{let e=new Set;for(let t of p)for(let n of t.anchors??[])n.type===`file`&&n.path&&e.add(n.path);return e},[p]),We=(0,K.useMemo)(()=>JSON.stringify(P)!==JSON.stringify(le),[le,P]),Ge=(0,K.useCallback)(e=>p.find(t=>t.id===e)??L.hits.find(t=>t.memory.id===e)?.memory??k.find(t=>t.id===e)??null,[k,p,L.hits]),Z=(0,K.useMemo)(()=>E===null?null:Ge(E),[Ge,E]),Ke=(0,K.useCallback)(e=>{let t=e!==null,i=++Ve.current;He.current?.(),x(null),t?Me(!0):(y(!0),Re.current||_(!0));let a=()=>{},o=null,s=!1,c=()=>{s||(s=!0,o!==null&&clearTimeout(o),a(),He.current===c&&(He.current=null))};a=n.on(`memory.sage.listPage`,e=>{if(i!==Ve.current||!J.current){c();return}if(c(),e.payload.error)x(e.payload.error);else{let n=e.payload.memories??[];m(e=>t?[...e,...n]:n),ke(e.payload.nextCursor??null),je(!!e.payload.nextCursor);let r=e.payload.statusCounts??{};Pe(r);let i=Object.values(r).reduce((e,t)=>e+t,0);e.payload.stats?g(e.payload.stats):g(e=>({total:i,byStatus:r,byKind:e?.byKind??{},edges:e?.edges??0})),Re.current=!0,t||D(e=>e&&(n.some(t=>t.id===e)||ze.current.some(t=>t.memory.id===e))?e:null)}_(!1),y(!1),Me(!1)}),o=setTimeout(()=>{i===Ve.current&&J.current&&(c(),x(`The memory store did not respond. Check the WebSocket connection and try again.`),_(!1),y(!1),Me(!1))},2e4),He.current=c,r({limit:mt,...Ee?{statuses:[`deleted`]}:{},...e?{cursor:e}:{},...R.trim()?{query:R.trim()}:{},...V===`all`?{}:{kind:V}},{echoToChat:!1})},[n,V,r,R,Ee]),Q=(0,K.useCallback)(()=>{ke(null),je(!1),Ke(null)},[Ke]),qe=(0,K.useCallback)(()=>{!U&&Oe&&Ke(Oe)},[Ke,U,Oe]);(0,K.useEffect)(()=>(J.current=!0,Q(),()=>{J.current=!1,Ve.current+=1,Y.current+=1,He.current?.(),X.current?.(),q.current?.()}),[Q]),(0,K.useEffect)(()=>{let e=R.trim();if(q.current?.(),e.length===0){pe({hits:[],channel:void 0,loading:!1,error:null});return}let t=++Be.current;pe(e=>({...e,loading:!0,error:null}));let r=()=>{},i=()=>{q.current===i&&(q.current=null),r()};q.current=i,r=n.on(`memory.sage.searchBreakdown`,e=>{if(t!==Be.current||!J.current){i();return}if(i(),e.payload.error){pe({hits:[],channel:void 0,loading:!1,error:e.payload.error});return}pe({hits:e.payload.hits??[],channel:e.payload.source,loading:!1,error:null})}),d({query:e,limit:20})},[R,n,d]),(0,K.useEffect)(()=>{ze.current=L.hits},[L.hits]),(0,K.useEffect)(()=>{if(O([]),A([]),re(null),!E){ae(!1);return}let e=E;ae(!0);let t=null,r=n.on(`memory.sage.graph`,n=>{n.payload.query===e&&(t!==null&&clearTimeout(t),O(n.payload.edges??[]),A(n.payload.memories??[]),re(n.payload.error??null),ae(!1))});return t=setTimeout(()=>{re(`Relationship graph did not respond in time.`),ae(!1)},15e3),c(e,{maxDepth:1,limit:120},{echoToChat:!1}),()=>{t!==null&&clearTimeout(t),r()}},[n,c,E]);let Je=(0,K.useRef)(f);(0,K.useEffect)(()=>{f&&!Je.current&&Re.current&&Q(),Je.current=f},[Q,f]),(0,K.useEffect)(()=>{if(!w)return;let e=setTimeout(()=>T(null),4e3);return()=>clearTimeout(e)},[w]);let $=(0,K.useCallback)(async()=>!We||!oe&&!N||ge({title:e(`activity:memoryManager.discardTitle`,{defaultValue:`Discard Unsaved Changes?`}),message:e(`activity:memoryManager.discardConfirm`,{defaultValue:`Discard the unsaved memory changes? This cannot be undone.`}),confirmLabel:e(`common:action.discard`,{defaultValue:`Discard`}),danger:!0}),[N,We,oe,e]),Ye=(0,K.useCallback)(async()=>{if(!await $())return;let e=Se();ce(e),F(e),se(!0),M(!1),D(null),C(null)},[$]),Xe=(0,K.useCallback)(e=>{let t=()=>{D(e),se(!1),M(!1),C(null)};if(!We||!oe&&!N){t();return}$().then(e=>{e&&t()})},[$,N,We,oe]),Ze=(0,K.useCallback)(e=>{let t=e===void 0?Z:Ge(e);if(!t||t.status===`deleted`)return;e!==void 0&&D(e);let n=xe(t);ce(n),F(n),M(!0),se(!1),C(null)},[Ge,Z]),Qe=(0,K.useCallback)(async()=>{await $()&&(M(!1),se(!1),C(null))},[$]),$e=(0,K.useCallback)((t,r,i)=>{if(!P.text.trim()){C(`Memory content is required.`);return}let a=++Y.current;X.current?.(),I(i),C(null),T(null);let o=()=>{},s=null,c=!1,l=()=>{c||(c=!0,s!==null&&clearTimeout(s),o(),X.current===l&&(X.current=null))},u=t=>{if(a!==Y.current||!J.current){l();return}if(l(),I(null),t.payload.error||!t.payload.memory){C(t.payload.error??`The server returned no memory record.`);return}let n=t.payload.memory;m(e=>{let t=e.filter(e=>e.id!==n.id);return[n,...t]}),D(n.id),se(!1),M(!1),T(e(i===`create`?`activity:memoryManager.memoryCaptured`:`activity:memoryManager.memoryUpdated`)),Q()};o=t===`memory.sage.remember`?n.on(`memory.sage.remember`,u):n.on(`memory.sage.update`,u),s=setTimeout(()=>{a===Y.current&&J.current&&(l(),I(null),C(e(`activity:memoryManager.mutationTimeout`,{verb:e(i===`create`?`activity:memoryManager.createAction`:`common:action.save`)})))},2e4),X.current=l,r()},[n,P.text,Q,e]),et=(0,K.useCallback)(()=>{$e(`memory.sage.remember`,()=>a({text:P.text.trim(),kind:P.kind,scope:P.scope,tags:W(P.tags),importance:P.importance,confidence:P.confidence,freshness:P.freshness,anchors:ve(P.anchors),...W(P.audienceRoles).length||W(P.audienceTaskTypes).length||W(P.audienceModes).length?{audience:{roles:W(P.audienceRoles),taskTypes:W(P.audienceTaskTypes),modes:W(P.audienceModes)}}:{},supersedes:W(P.supersedes),contradicts:W(P.contradicts)},{echoToChat:!1}),`create`)},[P,a,$e]),tt=(0,K.useCallback)(()=>{Z&&$e(`memory.sage.update`,()=>o(Z.id,{text:P.text.trim(),kind:P.kind,status:P.status,tags:W(P.tags),importance:P.importance,confidence:P.confidence,freshness:P.freshness,anchors:ve(P.anchors),...W(P.audienceRoles).length||W(P.audienceTaskTypes).length||W(P.audienceModes).length?{audience:{roles:W(P.audienceRoles),taskTypes:W(P.audienceTaskTypes),modes:W(P.audienceModes)}}:{},supersedes:W(P.supersedes),contradicts:W(P.contradicts)},{echoToChat:!1}),`update`)},[P,$e,Z,o]),nt=(0,K.useCallback)(()=>{if(!de)return;let e=++Y.current;X.current?.(),I(`delete`),C(null);let t=()=>{},r=null,i=!1,a=()=>{i||(i=!0,r!==null&&clearTimeout(r),t(),X.current===a&&(X.current=null))};t=n.on(`memory.sage.delete`,t=>{if(e!==Y.current||!J.current){a();return}if(a(),I(null),!t.payload.success){C(t.payload.message||`Delete failed.`);return}fe(null),D(null),M(!1),T(`Memory deleted and relationship edges cleaned up.`),Q()}),r=setTimeout(()=>{e===Y.current&&J.current&&(a(),I(null),C(`Delete timed out. The memory may still exist; refresh to confirm.`))},2e4),X.current=a,s(de,`Deleted from the WebUI Memory Manager.`)},[n,s,de,Q]),rt=(0,K.useCallback)((e,t,r)=>{let i=++Y.current;X.current?.(),C(null);let a=()=>{},o=null,s=!1,c=()=>{s||(s=!0,o!==null&&clearTimeout(o),a(),X.current===c&&(X.current=null))};a=n.on(e,e=>{if(i!==Y.current||!J.current){c();return}c(),r(e.payload)}),o=setTimeout(()=>{i===Y.current&&J.current&&(c(),C(`The memory store did not respond. Check the WebSocket connection and try again.`))},2e4),X.current=c,t()},[n]),it=(0,K.useMemo)(()=>dt(p,{searchQuery:R,statusFilter:z,kindFilter:V,tagFilter:H,audienceOnly:ye}),[ye,V,p,R,z,H]),at=(0,K.useMemo)(()=>ft(p),[p]),ot=(0,K.useMemo)(()=>pt(Z),[Z]),st=(0,K.useCallback)(()=>{me(``),B(`all`),_e(`all`),be(!1),Ce(null)},[]);return{client:n,wsConnected:f,memories:p,stats:h,initialLoading:ee,refreshing:v,loadError:b,mutationError:S,setMutationError:C,notice:w,setNotice:T,selectedId:E,setSelectedId:D,selectedMemory:Z,graphEdges:te,graphMemories:k,graphError:ne,graphLoading:ie,editing:oe,creating:N,draft:P,setDraft:ce,busyAction:ue,deletingId:de,setDeletingId:fe,searchQuery:R,setSearchQuery:me,searchBreakdown:L,clearSearchBreakdown:()=>{Be.current+=1,q.current?.(),pe({hits:[],channel:void 0,loading:!1,error:null})},statusFilter:z,setStatusFilter:B,kindFilter:V,setKindFilter:_e,audienceOnly:ye,setAudienceOnly:be,tagFilter:H,setTagFilter:Ce,libraryView:we,setLibraryView:Te,showDeleted:Ee,showReview:De,hasMore:Ae,loadingMore:U,statusCounts:Ne,drawerOpen:Fe,setDrawerOpen:G,currentFilePath:Ie,setCurrentFilePath:Le,knownFilePaths:Ue,filteredMemories:it,allTags:at,relatedMemories:ot,hasFilters:!!(R||z!==`all`||V!==`all`||H||ye),detailOpen:N||!!Z,drawerActive:Fe&&!!Ie,loadMemories:Q,loadMore:qe,openCreate:Ye,openMemory:Xe,openEdit:Ze,cancelEditor:Qe,submitCreate:et,submitUpdate:tt,confirmDelete:nt,sendWithAck:rt,clearFilters:st,resolveMemoryCandidate:u,updateSage:o,recoverSage:l,listMemoryCandidates:i}}function gt(){let{t:e}=j(),t=ue(e=>e.setCurrentView),n=V(`memory`),r=ht();return r.initialLoading&&r.memories.length===0?(0,G.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-background`,"aria-busy":`true`,children:[(0,G.jsxs)(`div`,{className:`border-b border-border/70 bg-card/70 px-5 py-4`,children:[(0,G.jsx)(`div`,{className:`h-3 w-28 animate-pulse bg-muted`}),(0,G.jsx)(`div`,{className:`mt-3 h-7 w-56 animate-pulse bg-muted`})]}),(0,G.jsxs)(`div`,{className:`grid flex-1 gap-px bg-border/60 md:grid-cols-[minmax(300px,0.82fr)_minmax(0,1.35fr)]`,children:[(0,G.jsx)(`div`,{className:`space-y-px bg-background p-4`,children:Array.from({length:7},(e,t)=>(0,G.jsx)(`div`,{className:`h-24 animate-pulse border border-border/60 bg-card/45`},t))}),(0,G.jsx)(`div`,{className:`hidden bg-background p-6 md:block`,children:(0,G.jsx)(`div`,{className:`h-full animate-pulse border border-border/60 bg-card/35`})})]}),(0,G.jsx)(`span`,{className:`sr-only`,role:`status`,children:e(`activity:memoryManager.loadingSageContent`)})]}):r.loadError&&r.memories.length===0?(0,G.jsx)(`div`,{className:`flex h-full min-h-0 items-center justify-center bg-background p-6`,children:(0,G.jsxs)(`div`,{className:`max-w-md border border-destructive/35 bg-card p-6 shadow-2xl`,children:[(0,G.jsx)(`span`,{className:`flex size-11 items-center justify-center border border-destructive/35 bg-destructive/10 text-destructive`,children:(0,G.jsx)(_,{className:`size-5`})}),(0,G.jsx)(`h2`,{className:`mt-4 text-lg font-bold`,children:e(`activity:memoryManager.storeUnavailable`)}),(0,G.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-muted-foreground`,children:r.loadError}),(0,G.jsxs)(`div`,{className:`mt-5 flex gap-2`,children:[(0,G.jsxs)(z,{onClick:r.loadMemories,children:[(0,G.jsx)(h,{className:`size-4`}),` `,e(`common:action.retry`)]}),(0,G.jsxs)(z,{variant:`outline`,onClick:()=>t(`chat`),children:[(0,G.jsx)(A,{className:`size-4`}),` `,e(`activity:memoryManager.backToChat`)]})]})]})}):(0,G.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-background`,children:[(0,G.jsx)(it,{wsConnected:r.wsConnected,refreshing:r.refreshing,onRefresh:r.loadMemories,onCreate:r.openCreate}),(0,G.jsx)(at,{stats:r.stats,memories:r.memories,filteredCount:r.filteredMemories.length,allTagsCount:r.allTags.length}),(r.notice||r.loadError||r.mutationError)&&(0,G.jsxs)(`div`,{className:`shrink-0 border-b border-border/70 px-4 py-2`,"aria-live":`polite`,children:[r.notice&&(0,G.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2 text-xs text-success`,children:[(0,G.jsx)(d,{className:`size-3.5`}),` `,r.notice]}),r.loadError&&(0,G.jsxs)(`div`,{role:`alert`,className:`flex items-center gap-2 text-xs text-warning`,children:[(0,G.jsx)(_,{className:`size-3.5`}),` `,r.loadError,` Existing content remains available.`]}),r.mutationError&&!r.editing&&!r.creating&&(0,G.jsxs)(`div`,{role:`alert`,className:`flex items-center gap-2 text-xs text-destructive`,children:[(0,G.jsx)(_,{className:`size-3.5`}),` `,r.mutationError]})]}),(0,G.jsxs)(`div`,{className:`grid min-h-0 flex-1 md:grid-cols-[minmax(320px,0.82fr)_minmax(0,1.35fr)]`,children:[(0,G.jsxs)(`section`,{className:F(`min-h-0 border-r border-border/70 bg-card/25`,r.detailOpen?`hidden md:flex md:flex-col`:`flex flex-col`),"aria-label":e(`activity:memoryManager.libraryAria`),children:[(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 border-b border-border/60 px-3 pt-1`,role:`tablist`,"aria-label":e(`activity:memoryManager.viewAria`),children:[(0,G.jsx)(z,{type:`button`,variant:`ghost`,size:`sm`,role:`tab`,"aria-selected":r.libraryView===`active`,onClick:()=>r.setLibraryView(`active`),className:F(`h-7 rounded-b-none border-b-2 px-3 text-[11px]`,r.libraryView===`active`?`border-primary text-foreground`:`border-transparent text-muted-foreground`),children:e(`activity:memoryManager.tabActive`)}),(0,G.jsx)(z,{type:`button`,variant:`ghost`,size:`sm`,role:`tab`,"aria-selected":r.showReview,onClick:()=>r.setLibraryView(`review`),className:F(`h-7 rounded-b-none border-b-2 px-3 text-[11px]`,r.showReview?`border-primary text-foreground`:`border-transparent text-muted-foreground`),children:e(`activity:memoryManager.tabReview`)}),(0,G.jsxs)(z,{type:`button`,variant:`ghost`,size:`sm`,role:`tab`,"aria-selected":r.showDeleted,onClick:()=>r.setLibraryView(`deleted`),className:F(`h-7 rounded-b-none border-b-2 px-3 text-[11px]`,r.showDeleted?`border-primary text-foreground`:`border-transparent text-muted-foreground`),children:[e(`activity:memoryManager.tabDeleted`),typeof r.statusCounts.deleted==`number`?` (${r.statusCounts.deleted})`:``]})]}),r.showReview?(0,G.jsx)(ut,{active:r.showReview,client:r.client,listCandidates:r.listMemoryCandidates,resolveCandidate:r.resolveMemoryCandidate,onOpenMemory:r.openMemory}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Qe,{searchQuery:r.searchQuery,statusFilter:r.statusFilter,kindFilter:r.kindFilter,audienceOnly:r.audienceOnly,tagFilter:r.tagFilter,hasFilters:r.hasFilters,allTags:r.allTags,stats:r.stats,onSearchChange:r.setSearchQuery,onStatusFilterChange:r.setStatusFilter,onKindFilterChange:r.setKindFilter,onToggleAudienceOnly:()=>r.setAudienceOnly(e=>!e),onTagFilterChange:r.setTagFilter,onClearFilters:r.clearFilters}),(0,G.jsx)(et,{memoryListRef:n,memories:r.memories,filteredMemories:r.filteredMemories,selectedId:r.selectedId,onSelectMemory:r.openMemory,onOpenCreate:r.openCreate,onClearFilters:r.clearFilters}),r.searchQuery.trim().length>0&&(0,G.jsx)(ot,{query:r.searchQuery.trim(),channel:r.searchBreakdown.channel,hits:r.searchBreakdown.hits,loading:r.searchBreakdown.loading,error:r.searchBreakdown.error,onOpenMemory:r.openMemory,onClear:r.clearSearchBreakdown}),r.hasMore?(0,G.jsx)(`div`,{className:`shrink-0 border-t border-border/60 p-2`,children:(0,G.jsx)(z,{type:`button`,variant:`outline`,size:`sm`,onClick:r.loadMore,disabled:r.loadingMore,className:`h-7 w-full text-[11px]`,children:r.loadingMore?e(`common:action.loading`):`Load more (${r.memories.length} loaded)`})}):null]})]}),(0,G.jsxs)(`section`,{className:F(`min-h-0 bg-background`,r.detailOpen?`flex flex-col`:`hidden md:flex md:flex-col`),"aria-label":e(`activity:memoryManager.detailAria`),children:[r.memories.some(e=>(e.anchors??[]).some(e=>e.type===`file`&&e.path))&&(0,G.jsx)(Xe,{currentFilePath:r.currentFilePath,knownFilePaths:r.knownFilePaths,drawerActive:r.drawerActive,onFilePathChange:e=>{e&&r.knownFilePaths.has(e)?(r.setCurrentFilePath(e),r.setDrawerOpen(!0)):e?r.setCurrentFilePath(e):r.setCurrentFilePath(null)},onToggleDrawer:()=>{r.currentFilePath&&r.setDrawerOpen(e=>!e)}}),r.creating?(0,G.jsx)(Ze,{mode:`create`,draft:r.draft,busy:r.busyAction===`create`,error:r.mutationError,onChange:r.setDraft,onCancel:r.cancelEditor,onSubmit:r.submitCreate}):r.selectedMemory?r.editing?(0,G.jsx)(Ze,{mode:`edit`,draft:r.draft,busy:r.busyAction===`update`,error:r.mutationError,onChange:r.setDraft,onCancel:r.cancelEditor,onSubmit:r.submitUpdate}):r.drawerActive?(0,G.jsx)(Fe,{filePath:r.currentFilePath,open:r.drawerActive,onClose:()=>r.setDrawerOpen(!1),onShowMemory:e=>r.setSelectedId(e),onAcceptDeletion:(e,t)=>{r.sendWithAck(`memory.sage.candidateResolve`,()=>r.resolveMemoryCandidate({candidateId:e,action:`accept`}),n=>{if(n.error){r.setMutationError(n.error);return}r.setNotice(`Accepted hygiene review for ${t.slice(0,12)}… (candidate ${e.slice(0,12)}…).`),r.loadMemories()})},onKeep:(e,t)=>{r.sendWithAck(`memory.sage.candidateResolve`,()=>r.resolveMemoryCandidate({candidateId:e,action:`reject`}),n=>{if(n.error){r.setMutationError(n.error);return}r.setNotice(`Kept ${t.slice(0,12)}… (candidate ${e.slice(0,12)}… rejected).`),r.loadMemories()})},onUpdate:e=>{r.openEdit(e)},onMarkPermanent:e=>{r.sendWithAck(`memory.sage.update`,()=>r.updateSage(e,{persistence:`permanent`}),t=>{if(t.error||!t.memory){r.setMutationError(t.error??`The server returned no memory record.`);return}r.setNotice(`Memory ${e.slice(0,12)}… promoted to permanent.`),r.loadMemories()})},onRecover:e=>{r.sendWithAck(`memory.sage.recover`,()=>r.recoverSage({id:e,reason:`recovered via file drawer`}),t=>{if(t.error){r.setMutationError(t.error);return}r.setNotice(`Recovered ${e.slice(0,12)}…`),r.loadMemories()})}}):(0,G.jsx)(Ge,{memory:r.selectedMemory,allMemories:[...r.memories,...r.graphMemories],relatedMemories:r.relatedMemories,graphEdges:r.graphEdges,graphLoading:r.graphLoading,graphError:r.graphError,onClose:()=>r.setSelectedId(null),onOpenMemory:r.openMemory,onEdit:r.openEdit,onDelete:()=>r.setDeletingId(r.selectedMemory.id),onTagSelect:e=>{r.setTagFilter(e),r.setSelectedId(null)},onNotice:r.setNotice}):(0,G.jsx)(rt,{onCapture:r.openCreate})]})]}),(0,G.jsx)(Ie,{busyAction:r.busyAction,deletingId:r.deletingId,memory:r.selectedMemory,onCancel:()=>r.setDeletingId(null),onConfirm:r.confirmDelete,onOpenChange:e=>{!e&&r.busyAction!==`delete`&&r.setDeletingId(null)}})]})}export{gt as MemoryManager};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./config-store-BbL0WxLE.js";import{i as n,t as r}from"./react-core-wiHys0m2.js";import{Dn as i,Ha as a,Ii as o,Mn as s,Mr as c,Mt as l,Na as u,Pa as d,Qt as f,Va as p,Vi as m,Vn as h,Ya as g,Yi as ee,Yt as _,Zn as v,ci as y,ei as b,fa as x,fn as S,ja as C,ln as w,mi as T,n as E,nr as D,po as te,qn as O,rn as k,so as A,tr as ne,ur as re,wa as ie,xo as j,yn as ae,zr as oe}from"./vendor-V3ydTHqN.js";import"./i18n-Dv97urcO.js";import{a as M,h as N,n as se,r as P,t as ce,u as le}from"./xyflow-BqDBClm9.js";import{t as F}from"./utils-CKsqCaP8.js";import{n as ue}from"./ui-store-DxDwFHNK.js";import"./stores-DXn5tdr7.js";import{S as I}from"./fonts-DRGbd-AM.js";import{a as de,i as fe,n as L,o as pe,r as R,t as me}from"./dialog-b-Ai37sa.js";import{t as z}from"./button-BbeB5Qm8.js";import{t as B}from"./input-BA6D2L3K.js";import{L as he,N as ge,y as V}from"./index-DX6tHUzs.js";import{t as _e}from"./roster-ws-Cv_PHlEV.js";import{_ as ve,a as ye,b as be,c as H,d as xe,f as Se,g as Ce,h as we,i as Te,l as Ee,m as De,n as Oe,o as ke,p as Ae,r as je,s as U,t as Me,u as Ne,v as Pe,y as W}from"./shared-BFJvAYzX.js";import{t as Fe}from"./MemoryDrawer-DJ0Y98Z8.js";var G=r();function Ie({busyAction:e,deletingId:t,memory:n,onCancel:r,onConfirm:i,onOpenChange:a}){let{t:o}=j();return(0,G.jsx)(me,{open:!!t,onOpenChange:a,children:(0,G.jsxs)(L,{className:`max-w-md`,children:[(0,G.jsxs)(de,{children:[(0,G.jsx)(`span`,{className:`mb-2 flex size-10 items-center justify-center border border-destructive/35 bg-destructive/10 text-destructive`,children:(0,G.jsx)(f,{className:`size-4`})}),(0,G.jsx)(pe,{children:o(`activity:memoryManager.deleteTitle`)}),(0,G.jsx)(R,{className:`leading-6`,children:o(`activity:deleteMemoryDialog.sageWillMarkTheRecordDeleted`)})]}),(0,G.jsx)(`div`,{className:`border border-border/70 bg-background/45 p-3 text-xs text-muted-foreground`,children:Ce(n?.text??``,180)}),(0,G.jsxs)(fe,{children:[(0,G.jsx)(z,{variant:`outline`,onClick:r,disabled:e===`delete`,children:o(`common:action.cancel`)}),(0,G.jsxs)(z,{variant:`destructive`,onClick:i,disabled:e===`delete`,children:[e===`delete`?(0,G.jsx)(c,{className:`size-4 animate-spin`}):(0,G.jsx)(f,{className:`size-4`}),o(e===`delete`?`activity:memoryManager.deletingLabel`:`activity:memoryManager.actionDeleteMemory`)]})]})]})})}var K=e(n(),1),Le=212,Re=188;function ze(e){return e.length>14?`${e.slice(0,11)}…`:e}function Be(e,t=58){let n=e.replace(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t-1)}…`:n}function q(e){return e.type===`symbol`?[e.path,e.symbol?`#${e.symbol}`:``].filter(Boolean).join(``):e.path??e.command??e.symbol??e.role??e.type}function J(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 Ve({data:e}){let{entry:t,center:n}=e;return(0,G.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:Le},title:t.text,children:[(0,G.jsx)(M,{type:`target`,position:N.Top,className:`!border-background !bg-muted-foreground`}),(0,G.jsx)(M,{type:`source`,position:N.Bottom,className:`!border-background !bg-primary`}),(0,G.jsx)(M,{type:`source`,position:N.Right,className:`!border-background !bg-primary`}),(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`border px-1.5 py-0.5 text-[9px] font-bold uppercase ${J(t.status)}`,children:t.status}),(0,G.jsx)(`span`,{className:`ml-auto truncate font-mono text-[9px] text-muted-foreground`,children:ze(t.id)})]}),(0,G.jsx)(`p`,{className:`mt-2 line-clamp-2 text-[11px] leading-4 text-foreground/90`,children:Be(t.text)}),(0,G.jsx)(`p`,{className:`mt-1 font-mono text-[9px] uppercase text-muted-foreground`,children:t.kind})]})}function Y({data:e}){return(0,G.jsxs)(`div`,{className:`border border-info/40 bg-info/8 px-2.5 py-2 text-card-foreground shadow-lg`,style:{width:Re},title:e.label,children:[(0,G.jsx)(M,{type:`target`,position:N.Left,className:`!border-background !bg-info`}),(0,G.jsx)(`p`,{className:`font-mono text-[9px] font-bold uppercase text-info`,children:e.anchor.type}),(0,G.jsx)(`p`,{className:`mt-1 truncate font-mono text-[10px] text-foreground/85`,children:e.label})]})}var He={memoryNode:Ve,anchorNode:Y};function X(e,t){return{id:e,revision:0,scope:`project`,kind:`fact`,status:`deleted`,text:t(`activity:memoryManager.memoryUnavailable`),importance:0,confidence:0,freshness:0,tags:[],anchors:[],createdAt:``,updatedAt:``}}function Ue({nodes:e,edges:t,className:n}){return(0,G.jsx)(`div`,{className:F(`w-full`,n),children:(0,G.jsxs)(le,{nodes:e,edges:t,nodeTypes:He,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,G.jsx)(ce,{variant:se.Dots,gap:18,size:1,color:`hsl(var(--muted-foreground) / 0.18)`}),(0,G.jsx)(P,{showInteractive:!1,className:`!border-border !bg-card !shadow-lg`})]})})}function We({centerMemory:e,allMemories:t,graphEdges:n,loading:r=!1,error:i=null}){let{t:a}=j(),[o,s]=(0,K.useState)(!1),c=`mem:${e.id}`,l=(0,K.useMemo)(()=>n.filter(e=>e.from===c&&e.to.startsWith(`mem:`)||e.to===c&&e.from.startsWith(`mem:`)).slice(0,24),[c,n]),{nodes:u,edges:d}=(0,K.useMemo)(()=>{let n=[],r=[],i=new Map(t.map(e=>[e.id,e]));n.push({id:e.id,type:`memoryNode`,position:{x:320-Le/2,y:120},data:{entry:e,center:!0}});let o=[...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 l){let t=(e.from===c?e.to:e.from).slice(4);o.some(n=>n.id===t&&n.relation===e.relation)||o.push({id:t,relation:e.relation,weight:e.weight,evidence:e.evidence})}let s=320-(o.length-1)*220/2;return o.forEach((t,o)=>{let c=i.get(t.id)??X(t.id,a),l=t.relation===`superseded by`,u=l?0:280+Math.floor(o/3)*130,d=l?320-Le/2:s+o*220-Le/2;n.push({id:`memory:${t.id}:${o}`,type:`memoryNode`,position:{x:d,y:u},data:{entry:c,center:!1}});let f=t.relation===`contradicts`,p=l?`memory:${t.id}:${o}`:e.id,m=l?e.id:`memory:${t.id}:${o}`;r.push({id:`relation:${t.relation}:${t.id}:${o}`,source:p,target:m,type:`smoothstep`,animated:!f,label:t.weight===void 0?t.relation:`${t.relation} ${t.weight.toFixed(2)}`,data:{evidence:t.evidence??[]},style:{stroke:f?`hsl(var(--destructive))`:`hsl(var(--primary))`,strokeWidth:1.7,...f?{strokeDasharray:`5 4`}:{}},labelStyle:{fill:f?`hsl(var(--destructive))`:`hsl(var(--muted-foreground))`,fontSize:I(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:q(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,c,l]);return u.length<=1&&!r&&!i?null:(0,G.jsxs)(`section`,{className:`overflow-hidden border border-border/75 bg-background/35`,"aria-label":a(`activity:memoryManager.graphAria`),children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/70 bg-card/55 px-3 py-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-muted-foreground`,children:a(`activity:memoryManager.graphHeading`)}),u.length>1&&(0,G.jsxs)(z,{variant:`ghost`,size:`sm`,onClick:()=>s(!0),className:`h-6 gap-1 px-2 text-[9px] font-bold uppercase tracking-[0.12em]`,"aria-label":a(`activity:memoryManager.graphFullscreenAria`),children:[(0,G.jsx)(m,{className:`size-3`}),a(`activity:memoryManager.graphOpenFullscreen`)]})]}),(0,G.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:r?a(`activity:memoryManager.loadingGraph`):a(`activity:memoryManager.graphStats`,{nodes:u.length,edges:d.length})})]}),i&&(0,G.jsx)(`p`,{className:`border-b border-destructive/25 bg-destructive/5 px-3 py-2 text-[10px] text-destructive`,children:i}),u.length>1&&(0,G.jsx)(Ue,{nodes:u,edges:d,className:`h-[320px]`}),l.some(e=>e.evidence?.length)&&(0,G.jsx)(`div`,{className:`grid gap-1 border-t border-border/70 bg-card/35 px-3 py-2`,children:l.filter(e=>e.evidence?.length).slice(0,12).map(e=>{let t=(e.from===c?e.to:e.from).slice(4);return(0,G.jsxs)(`p`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:[(0,G.jsx)(`span`,{className:`text-info`,children:e.relation}),` `,ze(t),` · why:`,` `,e.evidence?.join(`, `)]},e.id)})}),o&&(0,G.jsx)(me,{open:o,onOpenChange:s,children:(0,G.jsxs)(L,{className:`flex max-h-[90dvh] max-w-[90vw] flex-col p-0`,showCloseButton:!1,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/70 bg-card/55 px-4 py-3`,children:[(0,G.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-muted-foreground`,children:a(`activity:memoryManager.graphHeadingFull`,{id:e.id})}),(0,G.jsx)(z,{variant:`ghost`,size:`sm`,onClick:()=>s(!1),className:`h-7 gap-1 px-2 text-[10px]`,children:a(`common:action.close`)})]}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1 px-4 pb-4`,children:(0,G.jsx)(Ue,{nodes:u,edges:d,className:`h-[65vh]`})})]})})]})}function Ge({memory:e,allMemories:t,relatedMemories:n,graphEdges:r,graphLoading:i,graphError:o,onClose:s,onOpenMemory:c,onEdit:l,onDelete:u,onTagSelect:d,onNotice:p}){let{t:m}=j();return(0,G.jsxs)(G.Fragment,{children:[(0,G.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,G.jsx)(z,{variant:`ghost`,size:`icon`,className:`md:hidden`,onClick:s,"aria-label":m(`activity:memoryManager.backToList`),children:(0,G.jsx)(A,{className:`size-4`})}),(0,G.jsx)(`span`,{className:F(`text-[10px] font-bold uppercase tracking-[0.14em]`,we(e.kind)),children:je[e.kind]??e.kind}),(0,G.jsx)(Ee,{status:e.status}),(0,G.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,G.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:Ae(e.audience),children:[(0,G.jsx)(a,{className:`size-3`}),Ae(e.audience)]}),(0,G.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,G.jsx)(z,{variant:`ghost`,size:`icon`,"aria-label":m(`activity:memoryManager.copyId`),title:m(`activity:memoryManager.copyId`),onClick:()=>{navigator.clipboard?.writeText(e.id),p(m(`activity:memoryManager.copiedNotice`))},children:(0,G.jsx)(x,{className:`size-4`})}),(0,G.jsxs)(z,{variant:`outline`,size:`sm`,onClick:()=>l(e.id),disabled:e.status===`deleted`,children:[(0,G.jsx)(v,{className:`size-3.5`}),` `,m(`common:action.edit`)]}),(0,G.jsxs)(z,{variant:`destructive`,size:`sm`,onClick:u,disabled:e.status===`deleted`,children:[(0,G.jsx)(f,{className:`size-3.5`}),` `,m(`common:action.delete`)]})]})]}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-4 md:p-5`,children:(0,G.jsxs)(`div`,{className:`mx-auto max-w-5xl space-y-5`,children:[(0,G.jsx)(Z,{memory:e}),(0,G.jsx)(Ke,{memory:e}),e.tags.length>0&&(0,G.jsx)(Q,{tags:e.tags,onTagSelect:d}),e.anchors.length>0&&(0,G.jsx)(qe,{anchors:e.anchors}),n.length>0&&(0,G.jsx)(Je,{relatedMemories:n,allMemories:t,onOpenMemory:c}),(0,G.jsx)(We,{centerMemory:e,allMemories:t,graphEdges:r,loading:i,error:o}),(0,G.jsx)($,{memory:e}),e.status===`deleted`&&(0,G.jsx)(Ye,{contextPolicy:e.contextPolicy})]})})]})}function Z({memory:e}){let{t}=j();return(0,G.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,G.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,G.jsx)(`p`,{className:`relative whitespace-pre-wrap text-sm leading-7 text-foreground md:text-[15px]`,children:e.text}),e.summary&&(0,G.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,G.jsxs)(`div`,{className:`relative mt-5 flex flex-wrap items-center gap-2 border-t border-border/60 pt-3`,children:[(0,G.jsx)(`code`,{className:`min-w-0 break-all font-mono text-[10px] text-muted-foreground`,children:e.id}),(0,G.jsx)(`span`,{className:`ml-auto font-mono text-[10px] text-muted-foreground`,children:t(`activity:memoryManager.revisionSuffix`,{n:e.revision})})]})]})}function Ke({memory:e}){let{t}=j(),n=[[t(`activity:memoryManager.editorImportance`),e.importance,ae],[t(`activity:memoryManager.editorConfidence`),e.confidence,ie],[t(`activity:memoryManager.editorFreshness`),e.freshness,h]];return(0,G.jsx)(`div`,{className:`grid gap-px bg-border/60 sm:grid-cols-3`,children:n.map(([e,t,n])=>(0,G.jsxs)(`div`,{className:`bg-card/60 p-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(n,{className:`size-3.5 text-info`}),(0,G.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.13em] text-muted-foreground`,children:e}),(0,G.jsxs)(`span`,{className:`ml-auto font-mono text-xs font-bold tabular-nums`,children:[Math.round(t*100),`%`]})]}),(0,G.jsx)(`div`,{className:`mt-2 h-1 bg-muted`,children:(0,G.jsx)(`div`,{className:`h-full bg-info shadow-[0_0_8px_hsl(var(--info)/0.45)]`,style:{width:`${Math.round(t*100)}%`}})})]},e))})}function Q({tags:e,onTagSelect:t}){let{t:n}=j();return(0,G.jsxs)(`section`,{children:[(0,G.jsxs)(`h3`,{className:`mb-2 flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:[(0,G.jsx)(k,{className:`size-3.5 text-info`}),` `,n(`activity:memoryManager.tagsLabel`)]}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map(e=>(0,G.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 qe({anchors:e}){let{t}=j();return(0,G.jsxs)(`section`,{className:`border border-border/75 bg-card/40`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/65 px-3 py-2.5`,children:[(0,G.jsxs)(`h3`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:[(0,G.jsx)(o,{className:`size-3.5 text-info`}),` `,t(`activity:memoryManager.editorAnchors`)]}),(0,G.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.length})]}),(0,G.jsx)(`ul`,{className:`divide-y divide-border/55`,children:e.map((e,t)=>(0,G.jsxs)(`li`,{className:`flex min-w-0 items-start gap-3 px-3 py-2.5`,children:[(0,G.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,G.jsx)(w,{className:`size-3.5`}):(0,G.jsx)(o,{className:`size-3.5`})}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`p`,{className:`text-[9px] font-bold uppercase text-muted-foreground`,children:e.type}),(0,G.jsxs)(`p`,{className:`mt-0.5 break-all font-mono text-[10px] leading-4 text-foreground/85`,children:[e.path??e.command??e.role??`—`,e.symbol?`#${e.symbol}`:``]})]}),(e.lineStart||e.lineEnd)&&(0,G.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??e.role}:${t}`))})]})}function Je({relatedMemories:e,allMemories:t,onOpenMemory:n}){let{t:r}=j();return(0,G.jsxs)(`section`,{className:`border border-border/75 bg-card/40`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/65 px-3 py-2.5`,children:[(0,G.jsxs)(`h3`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:[(0,G.jsx)(y,{className:`size-3.5 text-info`}),` `,r(`activity:memoryManager.memoryRelationships`)]}),(0,G.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.length})]}),(0,G.jsx)(`ul`,{className:`divide-y divide-border/55`,children:e.map(e=>{let i=t.find(t=>t.id===e.id);return(0,G.jsx)(`li`,{children:(0,G.jsxs)(`button`,{type:`button`,disabled:!i,onClick:()=>i&&n(i.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,G.jsx)(`span`,{className:F(`w-24 shrink-0 text-[9px] font-bold uppercase`,e.relation===`Contradicts`?`text-destructive`:`text-info`),children:e.relation}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs`,children:i?Ce(i.text,95):r(`activity:memoryManager.referencedUnavailable`)}),(0,G.jsx)(`code`,{className:`hidden max-w-32 truncate font-mono text-[9px] text-muted-foreground sm:block`,children:e.id}),i&&(0,G.jsx)(C,{className:`size-3.5 shrink-0 text-muted-foreground group-hover:text-info`})]})},`${e.relation}:${e.id}`)})})]})}function $({memory:e}){let{t}=j(),n=[[t(`activity:memoryManager.metaCreated`),De(e.createdAt),g],[t(`activity:memoryManager.metaUpdated`),De(e.updatedAt),h],[t(`activity:memoryManager.metaLastAccessed`),De(e.lastAccessedAt),re],[t(`activity:memoryManager.metaLastVerified`),De(e.lastVerifiedAt),ae]];return(0,G.jsx)(`section`,{className:`grid gap-px bg-border/60 sm:grid-cols-2 lg:grid-cols-4`,children:n.map(([e,t,n])=>(0,G.jsxs)(`div`,{className:`bg-card/50 p-3`,children:[(0,G.jsx)(n,{className:`size-3.5 text-muted-foreground`}),(0,G.jsx)(`p`,{className:`mt-2 text-[9px] font-bold uppercase tracking-[0.12em] text-muted-foreground`,children:e}),(0,G.jsx)(`p`,{className:`mt-1 text-[10px] leading-4 text-foreground/85`,children:t})]},e))})}function Ye({contextPolicy:e}){let{t}=j();return(0,G.jsxs)(`div`,{className:`flex items-start gap-3 border border-border bg-muted/50 p-4 text-xs text-muted-foreground`,children:[(0,G.jsx)(te,{className:`mt-0.5 size-4 shrink-0`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-bold text-foreground`,children:t(`activity:memoryManager.deletedMemory`)}),(0,G.jsx)(`p`,{className:`mt-1 leading-5`,children:t(e===`never`?`activity:memoryManager.deletedNeverPolicy`:`activity:memoryManager.deletedEligiblePolicy`)})]})]})}function Xe({currentFilePath:e,knownFilePaths:t,drawerActive:n,onFilePathChange:r,onToggleDrawer:i}){let{t:a}=j();return(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-border/60 bg-card/30 px-3 py-1.5`,children:[(0,G.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:a(`activity:memoryManager.fileDrawerLabel`)}),(0,G.jsx)(`input`,{type:`text`,list:`memory-drawer-file-list`,value:e??``,onChange:e=>{r(e.target.value.trim()||null)},placeholder:a(`activity:memoryManager.selectFilePlaceholder`),className:`min-w-0 max-w-[260px] flex-1 truncate rounded-sm border border-border/60 bg-background px-1.5 py-0.5 text-[10px] font-mono`,"aria-label":a(`activity:memoryManager.fileForDrawerAria`),"data-testid":`memory-drawer-file-select`}),(0,G.jsx)(`datalist`,{id:`memory-drawer-file-list`,children:[...t].sort().map(e=>(0,G.jsx)(`option`,{value:e},e))}),(0,G.jsxs)(z,{type:`button`,size:`sm`,variant:n?`default`:`outline`,onClick:i,disabled:!e,className:`h-7 shrink-0 gap-1 px-2 text-[11px]`,"aria-pressed":n,title:a(n?`activity:memoryManager.hideFileDrawer`:`activity:memoryManager.showFileDrawer`),children:[n?(0,G.jsx)(D,{className:`size-3`}):(0,G.jsx)(ne,{className:`size-3`}),a(n?`activity:memoryManager.hideDrawer`:`activity:memoryManager.showDrawer`)]})]})}function Ze({mode:e,draft:t,busy:n,error:r,onChange:i,onCancel:a,onSubmit:o}){let{t:u}=j(),d=(0,K.useRef)(null),[p,m]=(0,K.useState)([]);(0,K.useEffect)(()=>{d.current?.focus();let e=new AbortController;return _e(`agent-roster.list`,{},e.signal).then(e=>{let t=e.roles;Array.isArray(t)&&m(t.filter(e=>typeof e==`string`))}).catch(()=>void 0),()=>e.abort()},[]);let h=(e,n)=>{i({...t,[e]:n})},g=()=>{h(`anchors`,[...t.anchors,{type:`file`,path:``}])};return(0,G.jsxs)(`form`,{className:`flex min-h-0 flex-1 flex-col`,onSubmit:e=>{e.preventDefault(),o()},"aria-busy":n,children:[(0,G.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,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`flex size-8 items-center justify-center border border-info/35 bg-info/10 text-info`,children:e===`create`?(0,G.jsx)(S,{className:`size-4`}):(0,G.jsx)(v,{className:`size-4`})}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`p`,{className:`truncate text-sm font-bold`,children:u(e===`create`?`activity:memoryManager.captureMemory`:`activity:memoryManager.editMemory`)}),(0,G.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:u(e===`create`?`activity:memoryManager.editorCreateHint`:`activity:memoryManager.editorEditHint`)})]})]}),(0,G.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,G.jsxs)(z,{type:`button`,variant:`ghost`,size:`sm`,onClick:a,disabled:n,children:[(0,G.jsx)(l,{className:`size-3.5`}),` `,u(`common:action.cancel`)]}),(0,G.jsxs)(z,{type:`submit`,size:`sm`,disabled:n||!t.text.trim(),children:[n?(0,G.jsx)(c,{className:`size-3.5 animate-spin`}):e===`create`?(0,G.jsx)(O,{className:`size-3.5`}):(0,G.jsx)(s,{className:`size-3.5`}),u(n?`common:action.saving`:e===`create`?`activity:memoryManager.createMemory`:`activity:memoryManager.saveChanges`)]})]})]}),(0,G.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto overscroll-contain p-4 md:p-5`,children:(0,G.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-5`,children:[r&&(0,G.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,G.jsx)(_,{className:`mt-0.5 size-4 shrink-0`}),(0,G.jsx)(`span`,{children:r})]}),(0,G.jsxs)(`section`,{className:`border border-border/75 bg-card/45 p-4`,children:[(0,G.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-xs font-bold uppercase tracking-[0.14em]`,children:u(`activity:memoryManager.editorKnowledge`)}),(0,G.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:u(`activity:memEditor.writeTheDurableFactOrDecision`)})]}),(0,G.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground tabular-nums`,children:u(`activity:memoryManager.editorCharCount`,{count:t.text.length})})]}),(0,G.jsx)(`label`,{htmlFor:`memory-text`,className:`sr-only`,children:u(`activity:memoryManager.editorContentLabel`)}),(0,G.jsx)(`textarea`,{ref:d,id:`memory-text`,value:t.text,onChange:e=>h(`text`,e.target.value),rows:7,required:!0,placeholder:u(`activity:memoryManager.editorContentPlaceholder`),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,G.jsxs)(`section`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`label`,{htmlFor:`memory-kind`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:u(`activity:memoryManager.editorKind`)}),(0,G.jsx)(`select`,{id:`memory-kind`,value:t.kind,onChange:e=>h(`kind`,e.target.value),className:`h-10 w-full border border-input bg-background px-3 text-sm`,children:Te.map(e=>(0,G.jsx)(`option`,{value:e,children:je[e]},e))})]}),e===`create`?(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`label`,{htmlFor:`memory-scope`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:u(`activity:memoryManager.editorScope`)}),(0,G.jsx)(`select`,{id:`memory-scope`,value:t.scope,onChange:e=>h(`scope`,e.target.value),className:`h-10 w-full border border-input bg-background px-3 text-sm`,children:ye.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))})]}):(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`label`,{htmlFor:`memory-status`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:u(`activity:memoryManager.editorLifecycleStatus`)}),(0,G.jsx)(`select`,{id:`memory-status`,value:t.status,onChange:e=>h(`status`,e.target.value),className:`h-10 w-full border border-input bg-background px-3 text-sm`,children:Oe.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))})]}),(0,G.jsxs)(`div`,{className:F(`min-w-0`,e===`create`?`sm:col-span-2 lg:col-span-1`:``),children:[(0,G.jsx)(`label`,{htmlFor:`memory-tags`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:u(`activity:memoryManager.tagsLabel`)}),(0,G.jsx)(B,{id:`memory-tags`,value:t.tags,onChange:e=>h(`tags`,e.target.value),placeholder:u(`activity:memEditor.architectureWebuiWorkflow`),className:`h-10 bg-background`})]})]}),(0,G.jsxs)(`section`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,G.jsx)(H,{id:`memory-importance`,label:u(`activity:memoryManager.editorImportance`),value:t.importance,onChange:e=>h(`importance`,e)}),(0,G.jsx)(H,{id:`memory-confidence`,label:u(`activity:memoryManager.editorConfidence`),value:t.confidence,onChange:e=>h(`confidence`,e)}),(0,G.jsx)(H,{id:`memory-freshness`,label:u(`activity:memoryManager.editorFreshness`),value:t.freshness,onChange:e=>h(`freshness`,e)})]}),(0,G.jsxs)(`section`,{className:`border border-border/75 bg-card/45 p-4`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-xs font-bold uppercase tracking-[0.14em]`,children:u(`activity:memoryManager.editorAnchors`)}),(0,G.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:u(`activity:memEditor.bindKnowledgeToFilesSymbolsPackages`)})]}),(0,G.jsxs)(z,{type:`button`,variant:`outline`,size:`sm`,onClick:g,children:[(0,G.jsx)(O,{className:`size-3.5`}),` `,u(`activity:memoryManager.addAnchor`)]})]}),t.anchors.length===0?(0,G.jsxs)(`button`,{type:`button`,onClick:g,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,G.jsx)(oe,{className:`size-4`}),` `,u(`activity:memoryManager.noAnchors`)]}):(0,G.jsx)(`div`,{className:`mt-4 space-y-2`,children:t.anchors.map((e,n)=>(0,G.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,G.jsxs)(`label`,{className:`sr-only`,htmlFor:`anchor-type-${n}`,children:[`Anchor `,n+1,` type`]}),(0,G.jsx)(`select`,{id:`anchor-type-${n}`,value:e.type,onChange:e=>{let r=e.target.value,i=r===`command`?{type:r,command:``}:r===`agent`?{type:r,role:``}:{type:r,path:``},a=t.anchors.map((e,t)=>t===n?i:e);h(`anchors`,a)},className:`h-10 border border-input bg-background px-2 text-xs`,children:Me.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))}),(0,G.jsxs)(`div`,{className:F(`grid min-w-0 gap-2`,e.type===`symbol`&&`sm:grid-cols-[minmax(0,1fr)_11rem]`),children:[(0,G.jsxs)(`label`,{className:`sr-only`,htmlFor:`anchor-value-${n}`,children:[`Anchor `,n+1,` value`]}),(0,G.jsx)(B,{id:`anchor-value-${n}`,list:e.type===`agent`?`memory-agent-role-options`:void 0,value:Ne(e),onChange:e=>{let r=t.anchors.map((t,r)=>r===n?be(t,e.target.value):t);h(`anchors`,r)},placeholder:e.type===`command`?`pnpm test --filter webui`:e.type===`agent`?`reviewer`:`packages/webui/src/App.tsx`,className:`h-10 min-w-0 bg-background font-mono text-xs`}),e.type===`symbol`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`label`,{className:`sr-only`,htmlFor:`anchor-symbol-${n}`,children:[`Anchor `,n+1,` symbol`]}),(0,G.jsx)(B,{id:`anchor-symbol-${n}`,value:e.symbol??``,onChange:e=>{let r=t.anchors.map((t,r)=>r===n?{...t,symbol:e.target.value}:t);h(`anchors`,r)},placeholder:u(`activity:memoryManager.editorSymbolPlaceholder`),className:`h-10 bg-background font-mono text-xs`})]})]}),(0,G.jsx)(z,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Remove anchor ${n+1}`,onClick:()=>h(`anchors`,t.anchors.filter((e,t)=>t!==n)),children:(0,G.jsx)(f,{className:`size-4 text-destructive`})})]},`${e.type}:${n}`))}),(0,G.jsx)(`datalist`,{id:`memory-agent-role-options`,children:p.map(e=>(0,G.jsx)(`option`,{value:e},e))})]}),(0,G.jsxs)(`section`,{className:`grid gap-3 border border-border/75 bg-card/45 p-4 sm:grid-cols-2`,children:[(0,G.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,G.jsx)(`h3`,{className:`text-xs font-bold uppercase tracking-[0.14em]`,children:u(`activity:memoryManager.editorRelationships`)}),(0,G.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:u(`activity:memoryManager.editorRelationshipsHint`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{htmlFor:`memory-supersedes`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:u(`activity:memoryManager.editorSupersedes`)}),(0,G.jsx)(B,{id:`memory-supersedes`,value:t.supersedes,onChange:e=>h(`supersedes`,e.target.value),placeholder:u(`activity:memEditor.memIdMemId`),className:`h-10 bg-background font-mono text-xs`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{htmlFor:`memory-contradicts`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:u(`activity:memoryManager.editorContradicts`)}),(0,G.jsx)(B,{id:`memory-contradicts`,value:t.contradicts,onChange:e=>h(`contradicts`,e.target.value),placeholder:u(`activity:memEditor.memIdMemId`),className:`h-10 bg-background font-mono text-xs`})]})]}),(0,G.jsxs)(`section`,{className:`space-y-2`,children:[(0,G.jsx)(`h3`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:u(`activity:memEditor.audienceOptional`)}),(0,G.jsx)(`p`,{className:`text-[10px] text-muted-foreground/70`,children:u(`activity:memEditor.targetThisMemoryToSpecificAgent`)}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{htmlFor:`memory-audience-roles`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:u(`activity:memEditor.roles`)}),(0,G.jsx)(B,{id:`memory-audience-roles`,value:t.audienceRoles,onChange:e=>h(`audienceRoles`,e.target.value),placeholder:u(`activity:memEditor.reviewerRefactorPlanner`),className:`h-9 bg-background font-mono text-xs`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{htmlFor:`memory-audience-task-types`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:u(`activity:memoryManager.editorTaskTypes`)}),(0,G.jsx)(B,{id:`memory-audience-task-types`,value:t.audienceTaskTypes,onChange:e=>h(`audienceTaskTypes`,e.target.value),placeholder:u(`activity:memEditor.reviewRefactorBugfix`),className:`h-9 bg-background font-mono text-xs`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{htmlFor:`memory-audience-modes`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:u(`activity:memEditor.modes`)}),(0,G.jsx)(B,{id:`memory-audience-modes`,value:t.audienceModes,onChange:e=>h(`audienceModes`,e.target.value),placeholder:u(`activity:memEditor.teachCodeReview`),className:`h-9 bg-background font-mono text-xs`})]})]})]})})]})}function Qe({searchQuery:e,statusFilter:t,kindFilter:n,audienceOnly:r,tagFilter:o,hasFilters:s,allTags:c,stats:d,onSearchChange:f,onStatusFilterChange:p,onKindFilterChange:m,onToggleAudienceOnly:h,onTagFilterChange:g,onClearFilters:ee}){let{t:_}=j(),[v,y]=(0,K.useState)(!!o),b=v||!!o,x=c.length>0;return(0,G.jsxs)(`div`,{className:`shrink-0 space-y-2 overflow-hidden border-b border-border/70 bg-card/45 p-3`,children:[(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,G.jsx)(i,{className:`pointer-events-none absolute left-3 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,G.jsx)(B,{"aria-label":_(`activity:memoryManager.searchAria`),value:e,onChange:e=>f(e.target.value),placeholder:_(`activity:memoryManager.searchPlaceholder`),className:`h-10 min-w-0 bg-background pl-9 pr-8 text-xs`}),e&&(0,G.jsx)(`button`,{type:`button`,"aria-label":_(`activity:memoryManager.clearSearchAria`),onClick:()=>f(``),className:`absolute right-2 top-1/2 -translate-y-1/2 p-1 text-muted-foreground hover:text-foreground`,children:(0,G.jsx)(l,{className:`size-3.5`})})]}),(0,G.jsx)(z,{variant:r?`default`:`ghost`,size:`icon`,onClick:h,"aria-label":_(`activity:memoryManager.audienceFilterAria`),title:_(`activity:memoryManager.audienceFilterTitle`),className:`shrink-0`,children:(0,G.jsx)(a,{className:`size-4`})}),s&&(0,G.jsx)(z,{variant:`ghost`,size:`icon`,onClick:ee,"aria-label":_(`activity:memoryManager.clearFiltersAria`),title:_(`activity:memoryManager.clearFiltersTitle`),children:(0,G.jsx)(T,{className:`size-4`})})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,G.jsx)(`label`,{className:`sr-only`,htmlFor:`memory-status-filter`,children:_(`activity:memoryManager.filterByStatus`)}),(0,G.jsxs)(`select`,{id:`memory-status-filter`,value:t,onChange:e=>p(e.target.value),className:`h-9 min-w-0 border border-input bg-background px-2 text-xs`,children:[(0,G.jsx)(`option`,{value:`all`,children:_(`activity:memoryManager.allStatuses`)}),ke.map(e=>(0,G.jsxs)(`option`,{value:e,children:[e,` · `,d?.byStatus[e]??0]},e))]}),(0,G.jsx)(`label`,{className:`sr-only`,htmlFor:`memory-kind-filter`,children:_(`activity:memoryManager.filterByKind`)}),(0,G.jsxs)(`select`,{id:`memory-kind-filter`,value:n,onChange:e=>m(e.target.value),className:`h-9 min-w-0 border border-input bg-background px-2 text-xs`,children:[(0,G.jsx)(`option`,{value:`all`,children:_(`activity:memoryManager.allKinds`)}),Te.map(e=>(0,G.jsxs)(`option`,{value:e,children:[je[e],` · `,d?.byKind[e]??0]},e))]})]}),x&&(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{o||y(e=>!e)},"aria-expanded":b,"aria-controls":`memory-tags-panel`,disabled:!!o,className:F(`flex items-center gap-1.5 px-1 py-0.5 text-[10px] uppercase tracking-wide transition-colors`,b?`text-foreground`:`text-muted-foreground hover:text-foreground`,!!o&&`cursor-default`),title:o?`Active filter: ${o} (click the chip to clear)`:b?`Hide tag filters`:`Show tag filters (${c.length})`,children:[(0,G.jsx)(u,{className:F(`size-3 transition-transform`,!b&&`-rotate-90`)}),(0,G.jsx)(k,{className:`size-3`}),(0,G.jsx)(`span`,{className:`font-semibold`,children:_(`activity:memoryManager.tagsLabel`)}),(0,G.jsx)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:c.length})]}),o&&(0,G.jsx)(`span`,{role:`status`,"aria-label":`Active tag filter: ${o}`,className:`border border-info/55 bg-info/10 px-1 font-mono text-[9px] uppercase text-info`,children:o})]}),x&&b&&(0,G.jsxs)(`fieldset`,{id:`memory-tags-panel`,className:`min-w-0 border-0 p-0`,children:[(0,G.jsx)(`legend`,{className:`sr-only`,children:_(`activity:memoryManager.popularTags`)}),(0,G.jsx)(`div`,{className:`no-scrollbar flex gap-1.5 overflow-x-auto pb-0.5`,children:c.slice(0,18).map(([e,t])=>(0,G.jsxs)(`button`,{type:`button`,"aria-pressed":o===e,onClick:()=>g(o===e?null:e),className:F(`flex shrink-0 items-center gap-1 border px-2 py-1 text-[10px] transition-colors`,o===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,G.jsx)(k,{className:`size-2.5`}),` `,e,(0,G.jsx)(`span`,{className:`font-mono opacity-60`,children:t})]},e))})]})]})}var $e=100;function et({memoryListRef:e,memories:t,filteredMemories:n,selectedId:r,onSelectMemory:i,onOpenCreate:a,onClearFilters:o}){let{t:s}=j(),c=n.length>$e,l=E({count:n.length,getScrollElement:()=>e.current,estimateSize:()=>100,overscan:8,enabled:c});return(0,G.jsxs)(G.Fragment,{children:[(0,G.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,G.jsx)(`span`,{children:s(`activity:memoryManager.memoryCountSummary`,{shown:n.length,total:t.length})}),(0,G.jsx)(`span`,{className:`font-mono uppercase`,children:s(`activity:memoryManager.updatedSortLabel`)})]}),(0,G.jsx)(`section`,{ref:e,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,"aria-label":s(`activity:memoryManager.listAria`),children:n.length===0?(0,G.jsx)(tt,{hasMemories:t.length>0,onOpenCreate:a,onClearFilters:o}):c?(0,G.jsx)(`div`,{style:{height:`${l.getTotalSize()}px`,width:`100%`,position:`relative`},children:l.getVirtualItems().map(e=>{let t=n[e.index];return t?(0,G.jsx)(`div`,{"data-index":e.index,ref:l.measureElement,style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${e.start}px)`},children:(0,G.jsx)(nt,{memory:t,isSelected:r===t.id,onClick:()=>i(t.id)})},t.id):null})}):n.map(e=>(0,G.jsx)(nt,{memory:e,isSelected:r===e.id,onClick:()=>i(e.id)},e.id))})]})}function tt({hasMemories:e,onOpenCreate:t,onClearFilters:n}){let{t:r}=j();return(0,G.jsxs)(`div`,{className:`flex min-h-64 flex-col items-center justify-center px-6 text-center`,children:[(0,G.jsx)(`span`,{className:`flex size-12 items-center justify-center border border-dashed border-border text-muted-foreground`,children:(0,G.jsx)(ee,{className:`size-5`})}),(0,G.jsx)(`h2`,{className:`mt-4 text-sm font-bold`,children:r(e?`activity:memoryManager.noMatching`:`activity:memoryManager.buildGraph`)}),(0,G.jsx)(`p`,{className:`mt-1 max-w-xs text-xs leading-5 text-muted-foreground`,children:r(e?`activity:memoryManager.emptyFiltered`:`activity:memoryManager.emptyCapture`)}),(0,G.jsxs)(z,{className:`mt-4`,variant:`outline`,size:`sm`,onClick:e?n:t,children:[e?(0,G.jsx)(T,{className:`size-3.5`}):(0,G.jsx)(O,{className:`size-3.5`}),r(e?`activity:memoryManager.clearFilters`:`activity:memoryManager.createFirst`)]})]})}function nt({memory:e,isSelected:t,onClick:n}){return(0,G.jsxs)(`button`,{type:`button`,"aria-current":t?`true`:void 0,onClick:n,className:F(`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`,t&&`bg-info/8`),children:[t&&(0,G.jsx)(`span`,{className:`absolute inset-y-0 left-0 w-0.5 bg-info shadow-[0_0_10px_hsl(var(--info)/0.7)]`}),(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:F(`truncate text-[10px] font-bold uppercase tracking-[0.1em]`,we(e.kind)),children:je[e.kind]??e.kind}),(0,G.jsx)(Ee,{status:e.status}),(0,G.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono text-[9px] text-muted-foreground`,children:[`r`,e.revision]})]}),(0,G.jsx)(`p`,{className:F(`mt-2 line-clamp-2 text-xs leading-5 text-foreground/90`,e.status===`deleted`&&`line-through opacity-60`),children:Ce(e.text)}),(0,G.jsxs)(`div`,{className:`mt-2 flex min-w-0 items-center gap-1.5`,children:[(0,G.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,G.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,G.jsx)(a,{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,G.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,G.jsxs)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:[`+`,e.tags.length-2]}),(0,G.jsx)(`span`,{className:`ml-auto shrink-0 text-[9px] text-muted-foreground`,children:Pe(e.updatedAt)}),(0,G.jsx)(C,{className:`size-3 shrink-0 text-muted-foreground transition-transform group-hover:translate-x-0.5 group-hover:text-info`})]})]})}function rt({onCapture:e}){let{t}=j();return(0,G.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center p-8 text-center`,children:[(0,G.jsxs)(`div`,{className:`relative flex size-20 items-center justify-center border border-info/25 bg-info/5 text-info`,children:[(0,G.jsx)(a,{className:`size-8`}),(0,G.jsx)(`span`,{className:`absolute inset-2 border border-info/10`})]}),(0,G.jsx)(`h2`,{className:`mt-5 text-lg font-bold`,children:t(`activity:memoryManager.emptyTitle`)}),(0,G.jsx)(`p`,{className:`mt-2 max-w-md text-sm leading-6 text-muted-foreground`,children:t(`activity:memoryManager.emptyBody`)}),(0,G.jsxs)(`div`,{className:`mt-6 grid w-full max-w-lg gap-2 sm:grid-cols-3`,children:[(0,G.jsxs)(`div`,{className:`border border-border/70 bg-card/45 p-3`,children:[(0,G.jsx)(d,{className:`mx-auto size-4 text-success`}),(0,G.jsx)(`p`,{className:`mt-2 text-[10px] font-bold uppercase`,children:t(`activity:memoryManager.emptyVerifiedAnchors`)})]}),(0,G.jsxs)(`div`,{className:`border border-border/70 bg-card/45 p-3`,children:[(0,G.jsx)(a,{className:`mx-auto size-4 text-info`}),(0,G.jsx)(`p`,{className:`mt-2 text-[10px] font-bold uppercase`,children:t(`activity:memoryManager.emptyTypedRelations`)})]}),(0,G.jsxs)(`div`,{className:`border border-border/70 bg-card/45 p-3`,children:[(0,G.jsx)(O,{className:`mx-auto size-4 text-warning`}),(0,G.jsx)(`p`,{className:`mt-2 text-[10px] font-bold uppercase`,children:t(`activity:memoryManager.emptyAgentRecall`)})]})]}),(0,G.jsxs)(z,{onClick:e,children:[(0,G.jsx)(O,{className:`size-4`}),` `,t(`activity:memoryManager.captureButton`)]})]})}function it({wsConnected:e,refreshing:t,onRefresh:n,onCreate:r}){let{t:i}=j(),o=ue(e=>e.setCurrentView);return(0,G.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,G.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,G.jsxs)(`div`,{className:`relative flex flex-wrap items-center gap-3`,children:[(0,G.jsx)(z,{variant:`ghost`,size:`icon`,onClick:()=>o(`chat`),"aria-label":i(`activity:memoryManager.backToChat`),title:i(`activity:memoryManager.backToChat`),children:(0,G.jsx)(A,{className:`size-4`})}),(0,G.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,G.jsx)(a,{className:`size-5`})}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`h1`,{className:`text-base font-bold sm:text-lg`,children:i(`activity:memoryManager.sageHeading`)}),(0,G.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:i(`activity:memoryManager.projectKnowledge`)})]}),(0,G.jsx)(`p`,{className:`mt-0.5 max-w-2xl text-[10px] text-muted-foreground sm:text-xs`,children:i(`activity:memoryManager.sageSubtitle`)})]}),(0,G.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,G.jsxs)(`span`,{className:F(`hidden items-center gap-1.5 border px-2 py-1 font-mono text-[9px] uppercase sm:flex`,e?`border-success/30 text-success`:`border-warning/30 text-warning`),children:[(0,G.jsx)(`span`,{className:`size-1.5 bg-current`}),` `,i(e?`activity:memoryManager.liveStore`:`activity:memoryManager.reconnecting`)]}),(0,G.jsxs)(z,{variant:`outline`,size:`sm`,onClick:n,disabled:t,"aria-label":i(`activity:memoryManager.refreshAria`),children:[(0,G.jsx)(h,{className:F(`size-3.5`,t&&`animate-spin`)}),(0,G.jsx)(`span`,{className:`hidden sm:inline`,children:i(`common:action.refresh`)})]}),(0,G.jsxs)(z,{size:`sm`,onClick:r,children:[(0,G.jsx)(O,{className:`size-3.5`}),` `,i(`activity:memoryManager.newMemory`)]})]})]})]})}function at({stats:e,memories:t,filteredCount:n,allTagsCount:r}){let{t:i}=j(),o=t.filter(e=>e.audience).length,s=new Set;if(o>0){for(let e of t)if(e.audience){for(let t of e.audience.roles??[])s.add(t);for(let t of e.audience.taskTypes??[])s.add(t);for(let t of e.audience.modes??[])s.add(t)}}return(0,G.jsxs)(G.Fragment,{children:[(0,G.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,G.jsx)(U,{label:i(`activity:memoryManager.tabMemories`),value:e?.total??t.length,hint:`${n} visible`}),(0,G.jsx)(U,{label:i(`activity:memoryManager.tabActive`),value:e?.byStatus.active??t.filter(e=>e.status===`active`).length,hint:`retrievable`,tone:`success`}),(0,G.jsx)(U,{label:i(`activity:memoryManager.tabNeedsReview`),value:(e?.byStatus.stale??0)+(e?.byStatus.contradicted??0),hint:i(`activity:memoryManager.staleConflicts`),tone:`warning`}),(0,G.jsx)(`div`,{className:`hidden sm:block`,children:(0,G.jsx)(U,{label:i(`activity:memoryManager.tabGraphEdges`),value:e?.edges??0,hint:`${r} tags`,tone:`info`})})]}),o>0&&(0,G.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,G.jsx)(a,{className:`size-3.5 text-primary`}),(0,G.jsxs)(`span`,{className:`text-[11px] font-medium text-primary`,children:[o,` audience-scoped memory`,o===1?``:`ies`]}),s.size>0&&(0,G.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`(`,[...s].sort().join(`, `),`)`]})]})]})}function ot({query:e,channel:t,hits:n,loading:r,error:i,onOpenMemory:a,onClear:o}){let{t:s}=j();return e?(0,G.jsxs)(`section`,{"aria-label":s(`activity:memoryManager.searchBreakdownAria`),className:`border-b border-border/60 bg-card/35`,children:[(0,G.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between border-b border-border/55 px-3 py-2 text-[10px] text-muted-foreground`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(S,{className:`size-3 text-info`}),(0,G.jsx)(`span`,{className:`font-mono uppercase tracking-[0.1em]`,children:s(`activity:memoryManager.searchBreakdownTitle`,{query:e})}),t===`breakdown`&&(0,G.jsx)(`span`,{className:`border border-info/40 bg-info/8 px-1.5 py-0.5 font-mono text-[9px] uppercase text-info`,children:s(`activity:memoryManager.searchBreakdownDual`)}),t===`lexical`&&(0,G.jsx)(`span`,{className:`border border-border/60 px-1.5 py-0.5 font-mono text-[9px] uppercase text-muted-foreground`,children:s(`activity:memoryManager.searchBreakdownLexicalOnly`)})]}),(0,G.jsx)(`button`,{type:`button`,onClick:o,className:`font-mono text-[10px] uppercase text-muted-foreground hover:text-foreground`,children:s(`common:action.close`)})]}),r&&(0,G.jsx)(`p`,{className:`px-3 py-3 text-[10px] text-muted-foreground`,children:s(`activity:memoryManager.searchBreakdownLoading`)}),i&&(0,G.jsx)(`p`,{className:`border-t border-border/55 px-3 py-2 text-[10px] text-destructive`,role:`alert`,children:i}),!r&&!i&&n.length===0&&(0,G.jsx)(`p`,{className:`px-3 py-3 text-[10px] text-muted-foreground`,children:s(`activity:memoryManager.searchBreakdownEmpty`)}),(0,G.jsx)(`ul`,{className:`divide-y divide-border/55`,children:n.map(e=>(0,G.jsx)(st,{hit:e,onOpenMemory:a},e.memory.id))})]}):null}function st({hit:e,onOpenMemory:t}){let{t:n}=j(),r=ct(e.lexicalScore),i=ct(e.vectorScore),a=ct(e.finalScore),{accent:o,label:s}=lt(e.source);return(0,G.jsx)(`li`,{children:(0,G.jsxs)(`button`,{type:`button`,onClick:()=>t(e.memory.id),className:`group flex w-full min-w-0 items-start gap-3 px-3 py-2.5 text-left hover:bg-info/5`,children:[(0,G.jsx)(`span`,{className:F(`flex size-7 shrink-0 items-center justify-center border font-mono text-[9px] uppercase`,o),title:n(`activity:memoryManager.searchBreakdownSourceLabel`,{source:s}),children:e.source===`vector`?(0,G.jsx)(S,{className:`size-3.5`}):e.source===`both`?(0,G.jsx)(p,{className:`size-3.5`}):(0,G.jsx)(b,{className:`size-3.5`})}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`p`,{className:`line-clamp-2 text-[11px] leading-5 text-foreground/90`,children:e.memory.text}),(0,G.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1 font-mono text-[9px] text-muted-foreground`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`span`,{className:`uppercase text-[9px] text-muted-foreground/80`,children:`L`}),(0,G.jsx)(`span`,{className:`tabular-nums text-foreground/80`,children:r})]}),(0,G.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`span`,{className:`uppercase text-[9px] text-muted-foreground/80`,children:`V`}),(0,G.jsx)(`span`,{className:F(`tabular-nums`,e.vectorScore===null?`text-muted-foreground/50`:`text-foreground/80`),children:i})]}),(0,G.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`span`,{className:`uppercase text-[9px] text-muted-foreground/80`,children:`RRF`}),(0,G.jsx)(`span`,{className:`tabular-nums font-bold text-foreground`,children:a})]}),(0,G.jsx)(`span`,{className:`ml-auto uppercase text-[9px]`,children:s})]})]})]})})}function ct(e){return e===null?`—`:`${Math.round(e*100)}%`}function lt(e){switch(e){case`vector`:return{accent:`border-accent/40 bg-accent/10 text-accent`,label:`vector`};case`both`:return{accent:`border-info/40 bg-info/10 text-info`,label:`both`};default:return{accent:`border-border/60 bg-background text-muted-foreground`,label:`lexical`}}}function ut({listCandidates:e,resolveCandidate:t,onOpenMemory:n,client:r,active:i}){let{t:a}=j(),[o,s]=(0,K.useState)([]),[u,f]=(0,K.useState)(!1),[p,m]=(0,K.useState)(null),[g,ee]=(0,K.useState)(null),[v,y]=(0,K.useState)(!1),[b,x]=(0,K.useState)(()=>new Set),S=(0,K.useRef)(0),C=(0,K.useCallback)(()=>{let t=++S.current;f(!0),m(null);let n=r.on(`memory.sage.listCandidates`,e=>{if(t===S.current){if(n(),e.payload.error)m(String(e.payload.error)),s([]);else{let t=(Array.isArray(e.payload.candidates)?e.payload.candidates:[]).filter(e=>e.status===`pending`);s(t),x(e=>{let n=new Set;for(let r of e)t.some(e=>e.id===r)&&n.add(r);return n})}f(!1)}}),i=setTimeout(()=>{t===S.current&&(n(),f(!1),m(a(`activity:memoryManager.reviewLoadTimeout`)))},15e3);return e({includeResolved:!1},{echoToChat:!1}),()=>{clearTimeout(i),n()}},[r,e,a]);(0,K.useEffect)(()=>{if(i)return C()},[i,C]);let w=(0,K.useCallback)((e,n)=>new Promise(i=>{let a=r.on(`memory.sage.candidateResolve`,e=>{a();let t=e.payload.error;i(!t)});t({candidateId:e,action:n,reason:n===`reject`?`Rejected via Memory Review tab`:void 0},{echoToChat:!1}),setTimeout(()=>{a(),i(!1)},15e3)}),[r,t]),T=(0,K.useCallback)(async(e,t)=>{ee(e),await w(e,t),ee(null),C()},[C,w]),E=(0,K.useCallback)(async e=>{let t=[...b];if(t.length!==0){y(!0);for(let n of t)await w(n,e);y(!1),x(new Set),C()}},[C,w,b]),D=e=>{x(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},te=()=>{x(new Set(o.map(e=>e.id)))},O=()=>x(new Set);if(u&&o.length===0)return(0,G.jsxs)(`div`,{className:`flex flex-1 items-center justify-center gap-2 p-6 text-sm text-muted-foreground`,children:[(0,G.jsx)(c,{className:`size-4 animate-spin`}),a(`activity:memoryManager.reviewLoading`)]});if(p&&o.length===0)return(0,G.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center`,children:[(0,G.jsx)(_,{className:`size-5 text-warning`}),(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:p}),(0,G.jsxs)(z,{size:`sm`,variant:`outline`,onClick:()=>C(),children:[(0,G.jsx)(h,{className:`size-3.5`}),` `,a(`common:action.retry`)]})]});if(o.length===0)return(0,G.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-2 p-8 text-center`,children:[(0,G.jsx)(d,{className:`size-6 text-success`}),(0,G.jsx)(`p`,{className:`text-sm font-medium`,children:a(`activity:memoryManager.reviewEmptyTitle`)}),(0,G.jsx)(`p`,{className:`max-w-sm text-xs text-muted-foreground`,children:a(`activity:memoryManager.reviewEmptyHint`)}),(0,G.jsxs)(z,{size:`sm`,variant:`ghost`,onClick:()=>C(),children:[(0,G.jsx)(h,{className:`size-3.5`}),` `,a(`common:action.refresh`)]})]});let k=b.size,A=k===o.length&&o.length>0;return(0,G.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,G.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2 border-b border-border/60 px-3 py-2`,children:[(0,G.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-wide text-muted-foreground`,children:a(`activity:memoryManager.reviewPendingCount`,{count:o.length})}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,G.jsx)(z,{size:`sm`,variant:`ghost`,className:`h-7 text-[11px]`,onClick:A?O:te,children:a(A?`activity:memoryManager.reviewClearSelection`:`activity:memoryManager.reviewSelectAll`)}),(0,G.jsxs)(z,{size:`sm`,className:`h-7`,disabled:k===0||v,onClick:()=>void E(`accept`),children:[v?(0,G.jsx)(c,{className:`size-3 animate-spin`}):(0,G.jsx)(d,{className:`size-3`}),a(`activity:memoryManager.reviewBulkAccept`),k>0?` (${k})`:``]}),(0,G.jsxs)(z,{size:`sm`,variant:`outline`,className:`h-7`,disabled:k===0||v,onClick:()=>void E(`reject`),children:[(0,G.jsx)(l,{className:`size-3`}),a(`activity:memoryManager.reviewBulkKeep`),k>0?` (${k})`:``]}),(0,G.jsx)(z,{size:`sm`,variant:`ghost`,className:`h-7`,onClick:()=>C(),disabled:u,children:(0,G.jsx)(h,{className:F(`size-3.5`,u&&`animate-spin`)})})]})]}),(0,G.jsx)(`ul`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto p-3`,children:o.map(e=>{let t=e.targetMemoryId??e.memoryId,r=e.reviewReason??e.reason??``,i=g===e.id||v,o=b.has(e.id);return(0,G.jsx)(`li`,{className:F(`rounded-md border bg-card/60 p-3 text-sm shadow-sm`,o?`border-primary/50 ring-1 ring-primary/20`:`border-border/70`),children:(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`input`,{type:`checkbox`,className:`mt-1 size-3.5 accent-primary`,checked:o,disabled:v,onChange:()=>D(e.id),"aria-label":a(`activity:memoryManager.reviewSelectOne`)}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 text-[10px] uppercase tracking-wide text-muted-foreground`,children:[(0,G.jsx)(`span`,{className:`font-mono text-warning`,children:e.suggestedAction??`review`}),(0,G.jsx)(`span`,{children:`·`}),(0,G.jsx)(`span`,{children:Pe(e.createdAt)}),e.tags?.includes(`triage`)&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{children:`·`}),(0,G.jsx)(`span`,{className:`text-info`,children:`triage`})]})]}),(0,G.jsx)(`p`,{className:`mt-1.5 text-[13px] leading-snug text-foreground`,children:Ce(e.text,220)}),r?(0,G.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:r}):null,t?(0,G.jsxs)(`button`,{type:`button`,className:`mt-1 font-mono text-[10px] text-primary hover:underline`,onClick:()=>n?.(t),children:[t.slice(0,16),`…`]}):null,(0,G.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:[(0,G.jsxs)(z,{size:`sm`,className:`h-7`,disabled:i,onClick:()=>void T(e.id,`accept`),children:[g===e.id?(0,G.jsx)(c,{className:`size-3 animate-spin`}):(0,G.jsx)(d,{className:`size-3`}),a(`activity:memoryManager.actionAcceptDeletion`)]}),(0,G.jsxs)(z,{size:`sm`,variant:`outline`,className:`h-7`,disabled:i,onClick:()=>void T(e.id,`reject`),children:[(0,G.jsx)(l,{className:`size-3`}),a(`activity:memoryManager.actionKeep`)]})]})]})]})},e.id)})})]})}function dt(e,t){let n=t.searchQuery.trim().toLowerCase();return e.filter(e=>{if(t.statusFilter!==`all`&&e.status!==t.statusFilter||t.kindFilter!==`all`&&e.kind!==t.kindFilter||t.tagFilter&&!e.tags.includes(t.tagFilter)||t.audienceOnly&&!e.audience)return!1;if(!n)return!0;let r=e.anchors.map(e=>[e.path,e.symbol,e.command,e.role].filter(Boolean).join(` `)).join(` `),i=e.audience?[e.audience.roles?.join(` `)??``,e.audience.taskTypes?.join(` `)??``,e.audience.modes?.join(` `)??``].join(` `):``;return[e.id,e.text,e.summary??``,e.kind,e.scope,e.tags.join(` `),r,i].join(` `).toLowerCase().includes(n)})}function ft(e){let t=new Map;for(let n of e)for(let e of n.tags)t.set(e,(t.get(e)??0)+1);return[...t.entries()].sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0]))}function pt(e){if(!e)return[];let t=[];e.supersededBy&&t.push({relation:`Superseded by`,id:e.supersededBy});for(let n of e.supersedes??[])t.push({relation:`Supersedes`,id:n});for(let n of e.contradicts??[])t.push({relation:`Contradicts`,id:n});return t}var mt=100;function ht(){let{t:e}=j(),{client:n,listSageMemoriesPage:r,listMemoryCandidates:i,rememberSage:a,updateSage:o,deleteSage:s,getSageGraph:c,recoverSage:l,resolveMemoryCandidate:u,searchSageBreakdown:d}=he(),f=t(e=>e.wsConnected),[p,m]=(0,K.useState)([]),[h,g]=(0,K.useState)(null),[ee,_]=(0,K.useState)(!0),[v,y]=(0,K.useState)(!1),[b,x]=(0,K.useState)(null),[S,C]=(0,K.useState)(null),[w,T]=(0,K.useState)(null),[E,D]=(0,K.useState)(null),[te,O]=(0,K.useState)([]),[k,A]=(0,K.useState)([]),[ne,re]=(0,K.useState)(null),[ie,ae]=(0,K.useState)(!1),[oe,M]=(0,K.useState)(!1),[N,se]=(0,K.useState)(!1),[P,ce]=(0,K.useState)(Se),[le,F]=(0,K.useState)(Se),[ue,I]=(0,K.useState)(null),[de,fe]=(0,K.useState)(null),[L,pe]=(0,K.useState)({hits:[],channel:void 0,loading:!1,error:null}),[R,me]=(0,K.useState)(``),[z,B]=(0,K.useState)(`all`),[V,_e]=(0,K.useState)(`all`),[ye,be]=(0,K.useState)(!1),[H,Ce]=(0,K.useState)(null),[we,Te]=(0,K.useState)(`active`),Ee=we===`deleted`,De=we===`review`,[Oe,ke]=(0,K.useState)(null),[Ae,je]=(0,K.useState)(!1),[U,Me]=(0,K.useState)(!1),[Ne,Pe]=(0,K.useState)({}),[Fe,G]=(0,K.useState)(!1),[Ie,Le]=(0,K.useState)(null),Re=(0,K.useRef)(!1),ze=(0,K.useRef)([]),Be=(0,K.useRef)(0),q=(0,K.useRef)(null),J=(0,K.useRef)(!0),Ve=(0,K.useRef)(0),Y=(0,K.useRef)(0),He=(0,K.useRef)(null),X=(0,K.useRef)(null),Ue=(0,K.useMemo)(()=>{let e=new Set;for(let t of p)for(let n of t.anchors??[])n.type===`file`&&n.path&&e.add(n.path);return e},[p]),We=(0,K.useMemo)(()=>JSON.stringify(P)!==JSON.stringify(le),[le,P]),Ge=(0,K.useCallback)(e=>p.find(t=>t.id===e)??L.hits.find(t=>t.memory.id===e)?.memory??k.find(t=>t.id===e)??null,[k,p,L.hits]),Z=(0,K.useMemo)(()=>E===null?null:Ge(E),[Ge,E]),Ke=(0,K.useCallback)(e=>{let t=e!==null,i=++Ve.current;He.current?.(),x(null),t?Me(!0):(y(!0),Re.current||_(!0));let a=()=>{},o=null,s=!1,c=()=>{s||(s=!0,o!==null&&clearTimeout(o),a(),He.current===c&&(He.current=null))};a=n.on(`memory.sage.listPage`,e=>{if(i!==Ve.current||!J.current){c();return}if(c(),e.payload.error)x(e.payload.error);else{let n=e.payload.memories??[];m(e=>t?[...e,...n]:n),ke(e.payload.nextCursor??null),je(!!e.payload.nextCursor);let r=e.payload.statusCounts??{};Pe(r);let i=Object.values(r).reduce((e,t)=>e+t,0);e.payload.stats?g(e.payload.stats):g(e=>({total:i,byStatus:r,byKind:e?.byKind??{},edges:e?.edges??0})),Re.current=!0,t||D(e=>e&&(n.some(t=>t.id===e)||ze.current.some(t=>t.memory.id===e))?e:null)}_(!1),y(!1),Me(!1)}),o=setTimeout(()=>{i===Ve.current&&J.current&&(c(),x(`The memory store did not respond. Check the WebSocket connection and try again.`),_(!1),y(!1),Me(!1))},2e4),He.current=c,r({limit:mt,...Ee?{statuses:[`deleted`]}:{},...e?{cursor:e}:{},...R.trim()?{query:R.trim()}:{},...V===`all`?{}:{kind:V}},{echoToChat:!1})},[n,V,r,R,Ee]),Q=(0,K.useCallback)(()=>{ke(null),je(!1),Ke(null)},[Ke]),qe=(0,K.useCallback)(()=>{!U&&Oe&&Ke(Oe)},[Ke,U,Oe]);(0,K.useEffect)(()=>(J.current=!0,Q(),()=>{J.current=!1,Ve.current+=1,Y.current+=1,He.current?.(),X.current?.(),q.current?.()}),[Q]),(0,K.useEffect)(()=>{let e=R.trim();if(q.current?.(),e.length===0){pe({hits:[],channel:void 0,loading:!1,error:null});return}let t=++Be.current;pe(e=>({...e,loading:!0,error:null}));let r=()=>{},i=()=>{q.current===i&&(q.current=null),r()};q.current=i,r=n.on(`memory.sage.searchBreakdown`,e=>{if(t!==Be.current||!J.current){i();return}if(i(),e.payload.error){pe({hits:[],channel:void 0,loading:!1,error:e.payload.error});return}pe({hits:e.payload.hits??[],channel:e.payload.source,loading:!1,error:null})}),d({query:e,limit:20})},[R,n,d]),(0,K.useEffect)(()=>{ze.current=L.hits},[L.hits]),(0,K.useEffect)(()=>{if(O([]),A([]),re(null),!E){ae(!1);return}let e=E;ae(!0);let t=null,r=n.on(`memory.sage.graph`,n=>{n.payload.query===e&&(t!==null&&clearTimeout(t),O(n.payload.edges??[]),A(n.payload.memories??[]),re(n.payload.error??null),ae(!1))});return t=setTimeout(()=>{re(`Relationship graph did not respond in time.`),ae(!1)},15e3),c(e,{maxDepth:1,limit:120},{echoToChat:!1}),()=>{t!==null&&clearTimeout(t),r()}},[n,c,E]);let Je=(0,K.useRef)(f);(0,K.useEffect)(()=>{f&&!Je.current&&Re.current&&Q(),Je.current=f},[Q,f]),(0,K.useEffect)(()=>{if(!w)return;let e=setTimeout(()=>T(null),4e3);return()=>clearTimeout(e)},[w]);let $=(0,K.useCallback)(async()=>!We||!oe&&!N||ge({title:e(`activity:memoryManager.discardTitle`,{defaultValue:`Discard Unsaved Changes?`}),message:e(`activity:memoryManager.discardConfirm`,{defaultValue:`Discard the unsaved memory changes? This cannot be undone.`}),confirmLabel:e(`common:action.discard`,{defaultValue:`Discard`}),danger:!0}),[N,We,oe,e]),Ye=(0,K.useCallback)(async()=>{if(!await $())return;let e=Se();ce(e),F(e),se(!0),M(!1),D(null),C(null)},[$]),Xe=(0,K.useCallback)(e=>{let t=()=>{D(e),se(!1),M(!1),C(null)};if(!We||!oe&&!N){t();return}$().then(e=>{e&&t()})},[$,N,We,oe]),Ze=(0,K.useCallback)(e=>{let t=e===void 0?Z:Ge(e);if(!t||t.status===`deleted`)return;e!==void 0&&D(e);let n=xe(t);ce(n),F(n),M(!0),se(!1),C(null)},[Ge,Z]),Qe=(0,K.useCallback)(async()=>{await $()&&(M(!1),se(!1),C(null))},[$]),$e=(0,K.useCallback)((t,r,i)=>{if(!P.text.trim()){C(`Memory content is required.`);return}let a=++Y.current;X.current?.(),I(i),C(null),T(null);let o=()=>{},s=null,c=!1,l=()=>{c||(c=!0,s!==null&&clearTimeout(s),o(),X.current===l&&(X.current=null))},u=t=>{if(a!==Y.current||!J.current){l();return}if(l(),I(null),t.payload.error||!t.payload.memory){C(t.payload.error??`The server returned no memory record.`);return}let n=t.payload.memory;m(e=>{let t=e.filter(e=>e.id!==n.id);return[n,...t]}),D(n.id),se(!1),M(!1),T(e(i===`create`?`activity:memoryManager.memoryCaptured`:`activity:memoryManager.memoryUpdated`)),Q()};o=t===`memory.sage.remember`?n.on(`memory.sage.remember`,u):n.on(`memory.sage.update`,u),s=setTimeout(()=>{a===Y.current&&J.current&&(l(),I(null),C(e(`activity:memoryManager.mutationTimeout`,{verb:e(i===`create`?`activity:memoryManager.createAction`:`common:action.save`)})))},2e4),X.current=l,r()},[n,P.text,Q,e]),et=(0,K.useCallback)(()=>{$e(`memory.sage.remember`,()=>a({text:P.text.trim(),kind:P.kind,scope:P.scope,tags:W(P.tags),importance:P.importance,confidence:P.confidence,freshness:P.freshness,anchors:ve(P.anchors),...W(P.audienceRoles).length||W(P.audienceTaskTypes).length||W(P.audienceModes).length?{audience:{roles:W(P.audienceRoles),taskTypes:W(P.audienceTaskTypes),modes:W(P.audienceModes)}}:{},supersedes:W(P.supersedes),contradicts:W(P.contradicts)},{echoToChat:!1}),`create`)},[P,a,$e]),tt=(0,K.useCallback)(()=>{Z&&$e(`memory.sage.update`,()=>o(Z.id,{text:P.text.trim(),kind:P.kind,status:P.status,tags:W(P.tags),importance:P.importance,confidence:P.confidence,freshness:P.freshness,anchors:ve(P.anchors),...W(P.audienceRoles).length||W(P.audienceTaskTypes).length||W(P.audienceModes).length?{audience:{roles:W(P.audienceRoles),taskTypes:W(P.audienceTaskTypes),modes:W(P.audienceModes)}}:{},supersedes:W(P.supersedes),contradicts:W(P.contradicts)},{echoToChat:!1}),`update`)},[P,$e,Z,o]),nt=(0,K.useCallback)(()=>{if(!de)return;let e=++Y.current;X.current?.(),I(`delete`),C(null);let t=()=>{},r=null,i=!1,a=()=>{i||(i=!0,r!==null&&clearTimeout(r),t(),X.current===a&&(X.current=null))};t=n.on(`memory.sage.delete`,t=>{if(e!==Y.current||!J.current){a();return}if(a(),I(null),!t.payload.success){C(t.payload.message||`Delete failed.`);return}fe(null),D(null),M(!1),T(`Memory deleted and relationship edges cleaned up.`),Q()}),r=setTimeout(()=>{e===Y.current&&J.current&&(a(),I(null),C(`Delete timed out. The memory may still exist; refresh to confirm.`))},2e4),X.current=a,s(de,`Deleted from the WebUI Memory Manager.`)},[n,s,de,Q]),rt=(0,K.useCallback)((e,t,r)=>{let i=++Y.current;X.current?.(),C(null);let a=()=>{},o=null,s=!1,c=()=>{s||(s=!0,o!==null&&clearTimeout(o),a(),X.current===c&&(X.current=null))};a=n.on(e,e=>{if(i!==Y.current||!J.current){c();return}c(),r(e.payload)}),o=setTimeout(()=>{i===Y.current&&J.current&&(c(),C(`The memory store did not respond. Check the WebSocket connection and try again.`))},2e4),X.current=c,t()},[n]),it=(0,K.useMemo)(()=>dt(p,{searchQuery:R,statusFilter:z,kindFilter:V,tagFilter:H,audienceOnly:ye}),[ye,V,p,R,z,H]),at=(0,K.useMemo)(()=>ft(p),[p]),ot=(0,K.useMemo)(()=>pt(Z),[Z]),st=(0,K.useCallback)(()=>{me(``),B(`all`),_e(`all`),be(!1),Ce(null)},[]);return{client:n,wsConnected:f,memories:p,stats:h,initialLoading:ee,refreshing:v,loadError:b,mutationError:S,setMutationError:C,notice:w,setNotice:T,selectedId:E,setSelectedId:D,selectedMemory:Z,graphEdges:te,graphMemories:k,graphError:ne,graphLoading:ie,editing:oe,creating:N,draft:P,setDraft:ce,busyAction:ue,deletingId:de,setDeletingId:fe,searchQuery:R,setSearchQuery:me,searchBreakdown:L,clearSearchBreakdown:()=>{Be.current+=1,q.current?.(),pe({hits:[],channel:void 0,loading:!1,error:null})},statusFilter:z,setStatusFilter:B,kindFilter:V,setKindFilter:_e,audienceOnly:ye,setAudienceOnly:be,tagFilter:H,setTagFilter:Ce,libraryView:we,setLibraryView:Te,showDeleted:Ee,showReview:De,hasMore:Ae,loadingMore:U,statusCounts:Ne,drawerOpen:Fe,setDrawerOpen:G,currentFilePath:Ie,setCurrentFilePath:Le,knownFilePaths:Ue,filteredMemories:it,allTags:at,relatedMemories:ot,hasFilters:!!(R||z!==`all`||V!==`all`||H||ye),detailOpen:N||!!Z,drawerActive:Fe&&!!Ie,loadMemories:Q,loadMore:qe,openCreate:Ye,openMemory:Xe,openEdit:Ze,cancelEditor:Qe,submitCreate:et,submitUpdate:tt,confirmDelete:nt,sendWithAck:rt,clearFilters:st,resolveMemoryCandidate:u,updateSage:o,recoverSage:l,listMemoryCandidates:i}}function gt(){let{t:e}=j(),t=ue(e=>e.setCurrentView),n=V(`memory`),r=ht();return r.initialLoading&&r.memories.length===0?(0,G.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-background`,"aria-busy":`true`,children:[(0,G.jsxs)(`div`,{className:`border-b border-border/70 bg-card/70 px-5 py-4`,children:[(0,G.jsx)(`div`,{className:`h-3 w-28 animate-pulse bg-muted`}),(0,G.jsx)(`div`,{className:`mt-3 h-7 w-56 animate-pulse bg-muted`})]}),(0,G.jsxs)(`div`,{className:`grid flex-1 gap-px bg-border/60 md:grid-cols-[minmax(300px,0.82fr)_minmax(0,1.35fr)]`,children:[(0,G.jsx)(`div`,{className:`space-y-px bg-background p-4`,children:Array.from({length:7},(e,t)=>(0,G.jsx)(`div`,{className:`h-24 animate-pulse border border-border/60 bg-card/45`},t))}),(0,G.jsx)(`div`,{className:`hidden bg-background p-6 md:block`,children:(0,G.jsx)(`div`,{className:`h-full animate-pulse border border-border/60 bg-card/35`})})]}),(0,G.jsx)(`span`,{className:`sr-only`,role:`status`,children:e(`activity:memoryManager.loadingSageContent`)})]}):r.loadError&&r.memories.length===0?(0,G.jsx)(`div`,{className:`flex h-full min-h-0 items-center justify-center bg-background p-6`,children:(0,G.jsxs)(`div`,{className:`max-w-md border border-destructive/35 bg-card p-6 shadow-2xl`,children:[(0,G.jsx)(`span`,{className:`flex size-11 items-center justify-center border border-destructive/35 bg-destructive/10 text-destructive`,children:(0,G.jsx)(_,{className:`size-5`})}),(0,G.jsx)(`h2`,{className:`mt-4 text-lg font-bold`,children:e(`activity:memoryManager.storeUnavailable`)}),(0,G.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-muted-foreground`,children:r.loadError}),(0,G.jsxs)(`div`,{className:`mt-5 flex gap-2`,children:[(0,G.jsxs)(z,{onClick:r.loadMemories,children:[(0,G.jsx)(h,{className:`size-4`}),` `,e(`common:action.retry`)]}),(0,G.jsxs)(z,{variant:`outline`,onClick:()=>t(`chat`),children:[(0,G.jsx)(A,{className:`size-4`}),` `,e(`activity:memoryManager.backToChat`)]})]})]})}):(0,G.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-background`,children:[(0,G.jsx)(it,{wsConnected:r.wsConnected,refreshing:r.refreshing,onRefresh:r.loadMemories,onCreate:r.openCreate}),(0,G.jsx)(at,{stats:r.stats,memories:r.memories,filteredCount:r.filteredMemories.length,allTagsCount:r.allTags.length}),(r.notice||r.loadError||r.mutationError)&&(0,G.jsxs)(`div`,{className:`shrink-0 border-b border-border/70 px-4 py-2`,"aria-live":`polite`,children:[r.notice&&(0,G.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2 text-xs text-success`,children:[(0,G.jsx)(d,{className:`size-3.5`}),` `,r.notice]}),r.loadError&&(0,G.jsxs)(`div`,{role:`alert`,className:`flex items-center gap-2 text-xs text-warning`,children:[(0,G.jsx)(_,{className:`size-3.5`}),` `,r.loadError,` Existing content remains available.`]}),r.mutationError&&!r.editing&&!r.creating&&(0,G.jsxs)(`div`,{role:`alert`,className:`flex items-center gap-2 text-xs text-destructive`,children:[(0,G.jsx)(_,{className:`size-3.5`}),` `,r.mutationError]})]}),(0,G.jsxs)(`div`,{className:`grid min-h-0 flex-1 md:grid-cols-[minmax(320px,0.82fr)_minmax(0,1.35fr)]`,children:[(0,G.jsxs)(`section`,{className:F(`min-h-0 border-r border-border/70 bg-card/25`,r.detailOpen?`hidden md:flex md:flex-col`:`flex flex-col`),"aria-label":e(`activity:memoryManager.libraryAria`),children:[(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 border-b border-border/60 px-3 pt-1`,role:`tablist`,"aria-label":e(`activity:memoryManager.viewAria`),children:[(0,G.jsx)(z,{type:`button`,variant:`ghost`,size:`sm`,role:`tab`,"aria-selected":r.libraryView===`active`,onClick:()=>r.setLibraryView(`active`),className:F(`h-7 rounded-b-none border-b-2 px-3 text-[11px]`,r.libraryView===`active`?`border-primary text-foreground`:`border-transparent text-muted-foreground`),children:e(`activity:memoryManager.tabActive`)}),(0,G.jsx)(z,{type:`button`,variant:`ghost`,size:`sm`,role:`tab`,"aria-selected":r.showReview,onClick:()=>r.setLibraryView(`review`),className:F(`h-7 rounded-b-none border-b-2 px-3 text-[11px]`,r.showReview?`border-primary text-foreground`:`border-transparent text-muted-foreground`),children:e(`activity:memoryManager.tabReview`)}),(0,G.jsxs)(z,{type:`button`,variant:`ghost`,size:`sm`,role:`tab`,"aria-selected":r.showDeleted,onClick:()=>r.setLibraryView(`deleted`),className:F(`h-7 rounded-b-none border-b-2 px-3 text-[11px]`,r.showDeleted?`border-primary text-foreground`:`border-transparent text-muted-foreground`),children:[e(`activity:memoryManager.tabDeleted`),typeof r.statusCounts.deleted==`number`?` (${r.statusCounts.deleted})`:``]})]}),r.showReview?(0,G.jsx)(ut,{active:r.showReview,client:r.client,listCandidates:r.listMemoryCandidates,resolveCandidate:r.resolveMemoryCandidate,onOpenMemory:r.openMemory}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Qe,{searchQuery:r.searchQuery,statusFilter:r.statusFilter,kindFilter:r.kindFilter,audienceOnly:r.audienceOnly,tagFilter:r.tagFilter,hasFilters:r.hasFilters,allTags:r.allTags,stats:r.stats,onSearchChange:r.setSearchQuery,onStatusFilterChange:r.setStatusFilter,onKindFilterChange:r.setKindFilter,onToggleAudienceOnly:()=>r.setAudienceOnly(e=>!e),onTagFilterChange:r.setTagFilter,onClearFilters:r.clearFilters}),(0,G.jsx)(et,{memoryListRef:n,memories:r.memories,filteredMemories:r.filteredMemories,selectedId:r.selectedId,onSelectMemory:r.openMemory,onOpenCreate:r.openCreate,onClearFilters:r.clearFilters}),r.searchQuery.trim().length>0&&(0,G.jsx)(ot,{query:r.searchQuery.trim(),channel:r.searchBreakdown.channel,hits:r.searchBreakdown.hits,loading:r.searchBreakdown.loading,error:r.searchBreakdown.error,onOpenMemory:r.openMemory,onClear:r.clearSearchBreakdown}),r.hasMore?(0,G.jsx)(`div`,{className:`shrink-0 border-t border-border/60 p-2`,children:(0,G.jsx)(z,{type:`button`,variant:`outline`,size:`sm`,onClick:r.loadMore,disabled:r.loadingMore,className:`h-7 w-full text-[11px]`,children:r.loadingMore?e(`common:action.loading`):`Load more (${r.memories.length} loaded)`})}):null]})]}),(0,G.jsxs)(`section`,{className:F(`min-h-0 bg-background`,r.detailOpen?`flex flex-col`:`hidden md:flex md:flex-col`),"aria-label":e(`activity:memoryManager.detailAria`),children:[r.memories.some(e=>(e.anchors??[]).some(e=>e.type===`file`&&e.path))&&(0,G.jsx)(Xe,{currentFilePath:r.currentFilePath,knownFilePaths:r.knownFilePaths,drawerActive:r.drawerActive,onFilePathChange:e=>{e&&r.knownFilePaths.has(e)?(r.setCurrentFilePath(e),r.setDrawerOpen(!0)):e?r.setCurrentFilePath(e):r.setCurrentFilePath(null)},onToggleDrawer:()=>{r.currentFilePath&&r.setDrawerOpen(e=>!e)}}),r.creating?(0,G.jsx)(Ze,{mode:`create`,draft:r.draft,busy:r.busyAction===`create`,error:r.mutationError,onChange:r.setDraft,onCancel:r.cancelEditor,onSubmit:r.submitCreate}):r.selectedMemory?r.editing?(0,G.jsx)(Ze,{mode:`edit`,draft:r.draft,busy:r.busyAction===`update`,error:r.mutationError,onChange:r.setDraft,onCancel:r.cancelEditor,onSubmit:r.submitUpdate}):r.drawerActive?(0,G.jsx)(Fe,{filePath:r.currentFilePath,open:r.drawerActive,onClose:()=>r.setDrawerOpen(!1),onShowMemory:e=>r.setSelectedId(e),onAcceptDeletion:(e,t)=>{r.sendWithAck(`memory.sage.candidateResolve`,()=>r.resolveMemoryCandidate({candidateId:e,action:`accept`}),n=>{if(n.error){r.setMutationError(n.error);return}r.setNotice(`Accepted hygiene review for ${t.slice(0,12)}… (candidate ${e.slice(0,12)}…).`),r.loadMemories()})},onKeep:(e,t)=>{r.sendWithAck(`memory.sage.candidateResolve`,()=>r.resolveMemoryCandidate({candidateId:e,action:`reject`}),n=>{if(n.error){r.setMutationError(n.error);return}r.setNotice(`Kept ${t.slice(0,12)}… (candidate ${e.slice(0,12)}… rejected).`),r.loadMemories()})},onUpdate:e=>{r.openEdit(e)},onMarkPermanent:e=>{r.sendWithAck(`memory.sage.update`,()=>r.updateSage(e,{persistence:`permanent`}),t=>{if(t.error||!t.memory){r.setMutationError(t.error??`The server returned no memory record.`);return}r.setNotice(`Memory ${e.slice(0,12)}… promoted to permanent.`),r.loadMemories()})},onRecover:e=>{r.sendWithAck(`memory.sage.recover`,()=>r.recoverSage({id:e,reason:`recovered via file drawer`}),t=>{if(t.error){r.setMutationError(t.error);return}r.setNotice(`Recovered ${e.slice(0,12)}…`),r.loadMemories()})}}):(0,G.jsx)(Ge,{memory:r.selectedMemory,allMemories:[...r.memories,...r.graphMemories],relatedMemories:r.relatedMemories,graphEdges:r.graphEdges,graphLoading:r.graphLoading,graphError:r.graphError,onClose:()=>r.setSelectedId(null),onOpenMemory:r.openMemory,onEdit:r.openEdit,onDelete:()=>r.setDeletingId(r.selectedMemory.id),onTagSelect:e=>{r.setTagFilter(e),r.setSelectedId(null)},onNotice:r.setNotice}):(0,G.jsx)(rt,{onCapture:r.openCreate})]})]}),(0,G.jsx)(Ie,{busyAction:r.busyAction,deletingId:r.deletingId,memory:r.selectedMemory,onCancel:()=>r.setDeletingId(null),onConfirm:r.confirmDelete,onOpenChange:e=>{!e&&r.busyAction!==`delete`&&r.setDeletingId(null)}})]})}export{gt as MemoryManager};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{U as t,mt as n,t as r}from"./config-store-xSv1mChc.js";import{i,t as a}from"./react-core-wiHys0m2.js";import{cn as o,hn as s,tn as c,xo as l}from"./vendor-V3ydTHqN.js";import"./i18n--QdD6NCn.js";import{t as u}from"./utils-CKsqCaP8.js";import"./stores-2kakt8j9.js";import{n as d,o as f,r as p,t as m}from"./dialog-b-Ai37sa.js";import{L as h,N as g}from"./index-FWwLmwjx.js";var _=e(i(),1),v=a();function y({open:e,onClose:i,className:a}){let{t:y}=l(),[b,x]=(0,_.useState)([]),S=n(),C=h(),w=r(e=>e.wsConnected),T=(0,_.useRef)(null),E=(0,_.useRef)(null);(0,_.useEffect)(()=>{if(!e||!w||!C.client?.isConnected)return;x([]);let n=()=>{let e=C.client.withSession?.({})??(S?{sessionId:S}:{});C.client.send?.({type:`process.list`,payload:e})};return n(),T.current=C.client.on?.(`process.list`,e=>{let n=e?.payload;n?.processes&&t(n.sessionId,S)&&x(n.processes)})??null,E.current=setInterval(n,3e3),()=>{T.current?.(),E.current&&clearInterval(E.current)}},[e,w,C.client,S]);let D=b.filter(e=>e.status===`running`),O=(0,_.useCallback)(async e=>{if(e.background&&!await g({title:y(`activity:process.killTitle`,{defaultValue:`Terminate Process`}),message:y(`activity:process.confirmKillBackground`,{pid:e.pid,defaultValue:`Terminate detached background process ${e.pid}?`}),confirmLabel:y(`common:action.stop`,{defaultValue:`Terminate`}),danger:!0}))return;let t=C.client.withSession?.({pid:e.pid})??{pid:e.pid};C.client.send?.({type:`process.kill`,payload:t})},[y,C.client]),k=(0,_.useCallback)(async()=>{if(!await g({title:y(`activity:process.killAllTitle`,{defaultValue:`Terminate All Processes`}),message:y(`activity:process.confirmKillAll`,{count:D.length,defaultValue:`Terminate all ${D.length} running processes?`}),confirmLabel:y(`common:action.stop`,{defaultValue:`Terminate All`}),danger:!0}))return;let e=C.client.withSession?.({})??(S?{sessionId:S}:{});C.client.send?.({type:`process.killAll`,payload:e})},[D.length,y,C.client,S]);return(0,v.jsx)(m,{open:e,onOpenChange:e=>{e||i()},children:(0,v.jsxs)(d,{className:u(`max-w-lg gap-0 p-0 overflow-hidden flex flex-col max-h-[75dvh] pt-[10dvh]`,a),showCloseButton:!1,children:[(0,v.jsx)(f,{className:`sr-only`,children:y(`activity:process.heading`)}),(0,v.jsx)(p,{className:`sr-only`,children:y(`activity:process.subtitle`,{active:D.length,total:b.length})}),(0,v.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b shrink-0`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,v.jsx)(`span`,{className:`flex items-center justify-center w-8 h-8 rounded-lg bg-warning/10 text-warning`,children:(0,v.jsx)(c,{className:`h-4 w-4`})}),(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`h2`,{className:`text-sm font-semibold`,children:y(`activity:process.heading`)}),(0,v.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:y(`activity:process.subtitle`,{active:D.length,total:b.length})})]})]}),(0,v.jsx)(`div`,{className:`flex items-center gap-1`,children:D.length>0&&(0,v.jsxs)(`button`,{type:`button`,onClick:k,className:`flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-xs text-destructive hover:bg-destructive/10 transition-colors font-medium`,children:[(0,v.jsx)(o,{className:`h-3 w-3 fill-current`}),y(`activity:process.killAll`)]})})]}),(0,v.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:b.length===0?(0,v.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16 gap-3 text-muted-foreground`,children:[(0,v.jsx)(c,{className:`h-10 w-10 opacity-15`}),(0,v.jsx)(`p`,{className:`text-sm font-medium`,children:y(`activity:process.emptyTitle`)}),(0,v.jsx)(`p`,{className:`text-xs text-center max-w-xs`,children:y(`activity:process.emptyBody`)})]}):(0,v.jsx)(`div`,{className:`divide-y`,children:b.map(e=>{let t=e.status===`running`?Math.floor((Date.now()-e.startedAt)/1e3):null,n=t?t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`:null,r=e.protected===!0,i=e.background===!0;return(0,v.jsxs)(`div`,{className:u(`flex items-center justify-between px-4 py-3 text-xs transition-colors`,e.status===`running`?`bg-background hover:bg-muted/30`:`bg-muted/20 text-muted-foreground`),children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:[(0,v.jsx)(`span`,{className:u(`led shrink-0`,e.status===`running`?r?`text-info`:`text-success led-pulse`:`text-muted-foreground`)}),(0,v.jsxs)(`div`,{className:`min-w-0`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,v.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground shrink-0`,children:y(`activity:process.pidLabel`,{pid:e.pid})}),(0,v.jsx)(`span`,{className:`font-medium truncate`,children:e.tool}),r&&(0,v.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 px-1 py-0.5 rounded text-[9px] bg-info/10 text-info font-medium shrink-0`,title:y(`activity:process.protectedTitle`),children:[(0,v.jsx)(s,{className:`h-2.5 w-2.5`}),y(`activity:process.protected`)]}),i&&(0,v.jsx)(`span`,{className:`inline-flex items-center px-1 py-0.5 rounded text-[9px] bg-success/10 text-success font-medium shrink-0`,title:y(`activity:process.backgroundTitle`),children:y(`activity:process.background`)})]}),(0,v.jsx)(`code`,{className:`text-[10px] text-muted-foreground/70 truncate block mt-0.5 font-mono`,children:e.command})]})]}),(0,v.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0 ml-3`,children:[n&&(0,v.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:n}),e.status===`running`&&!r&&(0,v.jsx)(`button`,{type:`button`,onClick:()=>O(e),className:`p-1.5 rounded-md hover:bg-destructive/10 hover:text-destructive transition-colors`,title:y(`activity:process.killTitle`,{pid:e.pid}),children:(0,v.jsx)(o,{className:`h-3.5 w-3.5 fill-current`})})]})]},e.pid)})})})]})})}export{y as ProcessMonitor};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{U as t,mt as n,t as r}from"./config-store-BbL0WxLE.js";import{i,t as a}from"./react-core-wiHys0m2.js";import{cn as o,hn as s,tn as c,xo as l}from"./vendor-V3ydTHqN.js";import"./i18n-Dv97urcO.js";import{t as u}from"./utils-CKsqCaP8.js";import"./stores-DXn5tdr7.js";import{n as d,o as f,r as p,t as m}from"./dialog-b-Ai37sa.js";import{L as h,N as g}from"./index-DX6tHUzs.js";var _=e(i(),1),v=a();function y({open:e,onClose:i,className:a}){let{t:y}=l(),[b,x]=(0,_.useState)([]),S=n(),C=h(),w=r(e=>e.wsConnected),T=(0,_.useRef)(null),E=(0,_.useRef)(null);(0,_.useEffect)(()=>{if(!e||!w||!C.client?.isConnected)return;x([]);let n=()=>{let e=C.client.withSession?.({})??(S?{sessionId:S}:{});C.client.send?.({type:`process.list`,payload:e})};return n(),T.current=C.client.on?.(`process.list`,e=>{let n=e?.payload;n?.processes&&t(n.sessionId,S)&&x(n.processes)})??null,E.current=setInterval(n,3e3),()=>{T.current?.(),E.current&&clearInterval(E.current)}},[e,w,C.client,S]);let D=b.filter(e=>e.status===`running`),O=(0,_.useCallback)(async e=>{if(e.background&&!await g({title:y(`activity:process.killTitle`,{defaultValue:`Terminate Process`}),message:y(`activity:process.confirmKillBackground`,{pid:e.pid,defaultValue:`Terminate detached background process ${e.pid}?`}),confirmLabel:y(`common:action.stop`,{defaultValue:`Terminate`}),danger:!0}))return;let t=C.client.withSession?.({pid:e.pid})??{pid:e.pid};C.client.send?.({type:`process.kill`,payload:t})},[y,C.client]),k=(0,_.useCallback)(async()=>{if(!await g({title:y(`activity:process.killAllTitle`,{defaultValue:`Terminate All Processes`}),message:y(`activity:process.confirmKillAll`,{count:D.length,defaultValue:`Terminate all ${D.length} running processes?`}),confirmLabel:y(`common:action.stop`,{defaultValue:`Terminate All`}),danger:!0}))return;let e=C.client.withSession?.({})??(S?{sessionId:S}:{});C.client.send?.({type:`process.killAll`,payload:e})},[D.length,y,C.client,S]);return(0,v.jsx)(m,{open:e,onOpenChange:e=>{e||i()},children:(0,v.jsxs)(d,{className:u(`max-w-lg gap-0 p-0 overflow-hidden flex flex-col max-h-[75dvh] pt-[10dvh]`,a),showCloseButton:!1,children:[(0,v.jsx)(f,{className:`sr-only`,children:y(`activity:process.heading`)}),(0,v.jsx)(p,{className:`sr-only`,children:y(`activity:process.subtitle`,{active:D.length,total:b.length})}),(0,v.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b shrink-0`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,v.jsx)(`span`,{className:`flex items-center justify-center w-8 h-8 rounded-lg bg-warning/10 text-warning`,children:(0,v.jsx)(c,{className:`h-4 w-4`})}),(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`h2`,{className:`text-sm font-semibold`,children:y(`activity:process.heading`)}),(0,v.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:y(`activity:process.subtitle`,{active:D.length,total:b.length})})]})]}),(0,v.jsx)(`div`,{className:`flex items-center gap-1`,children:D.length>0&&(0,v.jsxs)(`button`,{type:`button`,onClick:k,className:`flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-xs text-destructive hover:bg-destructive/10 transition-colors font-medium`,children:[(0,v.jsx)(o,{className:`h-3 w-3 fill-current`}),y(`activity:process.killAll`)]})})]}),(0,v.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:b.length===0?(0,v.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16 gap-3 text-muted-foreground`,children:[(0,v.jsx)(c,{className:`h-10 w-10 opacity-15`}),(0,v.jsx)(`p`,{className:`text-sm font-medium`,children:y(`activity:process.emptyTitle`)}),(0,v.jsx)(`p`,{className:`text-xs text-center max-w-xs`,children:y(`activity:process.emptyBody`)})]}):(0,v.jsx)(`div`,{className:`divide-y`,children:b.map(e=>{let t=e.status===`running`?Math.floor((Date.now()-e.startedAt)/1e3):null,n=t?t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`:null,r=e.protected===!0,i=e.background===!0;return(0,v.jsxs)(`div`,{className:u(`flex items-center justify-between px-4 py-3 text-xs transition-colors`,e.status===`running`?`bg-background hover:bg-muted/30`:`bg-muted/20 text-muted-foreground`),children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:[(0,v.jsx)(`span`,{className:u(`led shrink-0`,e.status===`running`?r?`text-info`:`text-success led-pulse`:`text-muted-foreground`)}),(0,v.jsxs)(`div`,{className:`min-w-0`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,v.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground shrink-0`,children:y(`activity:process.pidLabel`,{pid:e.pid})}),(0,v.jsx)(`span`,{className:`font-medium truncate`,children:e.tool}),r&&(0,v.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 px-1 py-0.5 rounded text-[9px] bg-info/10 text-info font-medium shrink-0`,title:y(`activity:process.protectedTitle`),children:[(0,v.jsx)(s,{className:`h-2.5 w-2.5`}),y(`activity:process.protected`)]}),i&&(0,v.jsx)(`span`,{className:`inline-flex items-center px-1 py-0.5 rounded text-[9px] bg-success/10 text-success font-medium shrink-0`,title:y(`activity:process.backgroundTitle`),children:y(`activity:process.background`)})]}),(0,v.jsx)(`code`,{className:`text-[10px] text-muted-foreground/70 truncate block mt-0.5 font-mono`,children:e.command})]})]}),(0,v.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0 ml-3`,children:[n&&(0,v.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:n}),e.status===`running`&&!r&&(0,v.jsx)(`button`,{type:`button`,onClick:()=>O(e),className:`p-1.5 rounded-md hover:bg-destructive/10 hover:text-destructive transition-colors`,title:y(`activity:process.killTitle`,{pid:e.pid}),children:(0,v.jsx)(o,{className:`h-3.5 w-3.5 fill-current`})})]})]},e.pid)})})})]})})}export{y as ProcessMonitor};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{K as t}from"./config-store-xSv1mChc.js";import{i as n,t as r}from"./react-core-wiHys0m2.js";import{Na as i,Ti as a,Vn as o,Yt as s,ja as c,kn as l,xo as u}from"./vendor-V3ydTHqN.js";import"./i18n--QdD6NCn.js";import{t as d}from"./utils-CKsqCaP8.js";var f=e(n(),1),p=r(),m=200,h=new Set([`raw_user`,`refined_user`]),g=[`raw_user`,`refined_user`];function _(e,t){return e(`activity:promptJournal.cat.${t}`,t)}function v(){let{t:e}=u(),n=t(),[r,i]=(0,f.useState)([]),[c,v]=(0,f.useState)(!0),[b,x]=(0,f.useState)(null),[S,C]=(0,f.useState)(!0),[w,T]=(0,f.useState)({category:``,session:``,limit:m}),[E,D]=(0,f.useState)(new Set),O=(0,f.useCallback)(()=>{if(!n.isConnected){C(!1);return}C(!0),x(null),n.send({type:`prompts.journal`,payload:{filter:{...w.category?{category:w.category}:{},limit:w.limit}}})},[n,w.category,w.limit]);(0,f.useEffect)(()=>{let e=e=>{let t=e.payload;v(t.enabled);let n=(t.entries??[]).filter(e=>h.has(e.category));i(n),x(t.error??null),C(!1)};return n.on(`prompts.journal`,e),O(),()=>n.off(`prompts.journal`,e)},[n,O]);let k=(0,f.useMemo)(()=>{let e=w.session.trim().toLowerCase(),t=r.filter(t=>!e||t.sessionId.toLowerCase().includes(e)),n=new Map;for(let e of[...t].reverse()){let t=e.timestamp.slice(0,10),r=n.get(t)??[];r.push(e),n.set(t,r)}return[...n.entries()]},[r,w.session]),A=(0,f.useMemo)(()=>{let e=0;for(let t of r)e+=t.metadata.tokenEstimate??0;return{count:r.length,tokens:e}},[r]),j=e=>{D(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},M=(0,f.useMemo)(()=>g.filter(e=>r.some(t=>t.category===e)),[r]);return(0,p.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-y-auto`,children:[(0,p.jsxs)(`div`,{className:`border-b border-border/70 px-4 py-3 sm:px-6`,children:[(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(l,{className:`h-5 w-5 text-primary`}),(0,p.jsx)(`h1`,{className:`text-base font-semibold`,children:e(`activity:promptJournal.title`)})]}),(0,p.jsxs)(`button`,{type:`button`,onClick:O,disabled:S,className:`inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-xs text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:opacity-50`,children:[(0,p.jsx)(o,{className:d(`h-3.5 w-3.5`,S&&`animate-spin`)}),e(`activity:promptJournal.refresh`)]})]}),(0,p.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:e(`activity:promptJournal.subtitle`)}),c&&A.count>0&&(0,p.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-x-4 gap-y-1 text-xs text-muted-foreground`,children:[(0,p.jsx)(`span`,{children:e(`activity:promptJournal.statEntries`,{count:A.count})}),(0,p.jsx)(`span`,{children:e(`activity:promptJournal.statTokens`,{count:A.tokens.toLocaleString()})})]})]}),(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-border/70 px-4 py-2 sm:px-6`,children:[(0,p.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,p.jsx)(`span`,{children:e(`activity:promptJournal.filterCategory`)}),(0,p.jsxs)(`select`,{value:w.category,onChange:e=>T(t=>({...t,category:e.target.value})),className:`rounded border border-border bg-background px-2 py-1 text-xs outline-none focus:ring-1 focus:ring-primary`,children:[(0,p.jsx)(`option`,{value:``,children:e(`activity:promptJournal.filterAll`)}),M.map(t=>(0,p.jsx)(`option`,{value:t,children:_(e,t)},t))]})]}),(0,p.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,p.jsx)(`span`,{children:e(`activity:promptJournal.filterSession`)}),(0,p.jsx)(`input`,{type:`text`,value:w.session,onChange:e=>T(t=>({...t,session:e.target.value})),placeholder:`sess_…`,className:`w-40 rounded border border-border bg-background px-2 py-1 text-xs outline-none focus:ring-1 focus:ring-primary`})]}),(0,p.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,p.jsx)(`span`,{children:e(`activity:promptJournal.filterLimit`)}),(0,p.jsxs)(`select`,{value:w.limit,onChange:e=>T(t=>({...t,limit:Number(e.target.value)})),className:`rounded border border-border bg-background px-2 py-1 text-xs outline-none focus:ring-1 focus:ring-primary`,children:[(0,p.jsx)(`option`,{value:50,children:`50`}),(0,p.jsx)(`option`,{value:200,children:`200`}),(0,p.jsx)(`option`,{value:1e3,children:`1000`})]})]})]}),(0,p.jsxs)(`div`,{className:`min-h-0 flex-1 px-4 py-3 sm:px-6`,children:[S&&(0,p.jsx)(`div`,{className:`py-10 text-center text-sm text-muted-foreground`,children:e(`activity:promptJournal.loading`)}),!S&&b&&(0,p.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-10 text-sm text-destructive`,children:[(0,p.jsx)(s,{className:`h-4 w-4`}),b]}),!S&&!b&&!c&&(0,p.jsx)(`div`,{className:`py-10 text-center text-sm text-muted-foreground`,children:e(`activity:promptJournal.disabled`)}),!S&&!b&&c&&k.length===0&&(0,p.jsxs)(`div`,{className:`py-10 text-center`,children:[(0,p.jsx)(a,{className:`mx-auto h-8 w-8 text-muted-foreground/50`}),(0,p.jsx)(`div`,{className:`mt-2 text-sm font-medium text-foreground`,children:e(`activity:promptJournal.emptyTitle`)}),(0,p.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:e(`activity:promptJournal.emptyHint`)})]}),!S&&!b&&c&&k.length>0&&(0,p.jsx)(`div`,{className:`space-y-5`,children:k.map(([e,t])=>(0,p.jsxs)(`section`,{children:[(0,p.jsxs)(`h2`,{className:`sticky top-0 z-10 border-b border-border/60 bg-background/90 py-1 text-xs font-semibold uppercase tracking-wide text-muted-foreground backdrop-blur`,children:[e,(0,p.jsx)(`span`,{className:`ml-2 font-normal normal-case text-muted-foreground/60`,children:t.length})]}),(0,p.jsx)(`ul`,{className:`mt-2 space-y-2`,children:t.map(e=>(0,p.jsx)(y,{entry:e,expanded:E.has(e.id),onToggle:()=>j(e.id)},e.id))})]},e))})]})]})}function y({entry:e,expanded:t,onToggle:n}){let{t:r}=u(),a=e.timestamp.slice(11,19),o=e.metadata,s=e.content.trim().slice(0,240),l=e.rawContent!==void 0&&e.rawContent!==e.content;return(0,p.jsxs)(`li`,{className:`rounded-lg border border-border/70 bg-card/60`,children:[(0,p.jsxs)(`button`,{type:`button`,onClick:n,className:`flex w-full items-start gap-2 rounded-lg px-3 py-2 text-left hover:bg-accent/40`,children:[t?(0,p.jsx)(i,{className:`mt-0.5 h-4 w-4 shrink-0 text-muted-foreground`}):(0,p.jsx)(c,{className:`mt-0.5 h-4 w-4 shrink-0 text-muted-foreground`}),(0,p.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-xs`,children:[(0,p.jsx)(`span`,{className:`tabular text-muted-foreground`,children:a}),(0,p.jsx)(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 font-medium text-primary`,children:_(r,e.category)}),(0,p.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-muted-foreground`,children:e.role}),(0,p.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:e.sessionId})]}),!t&&s&&(0,p.jsx)(`div`,{className:`mt-1 line-clamp-2 whitespace-pre-wrap break-words text-xs text-foreground/80`,children:s})]}),(0,p.jsxs)(`span`,{className:`shrink-0 text-[11px] tabular text-muted-foreground`,children:[`~`,o.tokenEstimate,` `,r(`activity:promptJournal.tokens`)]})]}),t&&(0,p.jsxs)(`div`,{className:`border-t border-border/60 px-3 py-2 pl-9`,children:[(0,p.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-wide text-muted-foreground`,children:r(`activity:promptJournal.refinedBody`)}),(0,p.jsx)(`pre`,{className:`mt-1 max-h-72 overflow-auto whitespace-pre-wrap break-words rounded bg-muted/50 p-2 text-xs text-foreground`,children:e.content}),l&&(0,p.jsxs)(`div`,{className:`mt-2`,children:[(0,p.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-wide text-muted-foreground`,children:r(`activity:promptJournal.rawInput`)}),(0,p.jsx)(`pre`,{className:`mt-1 max-h-40 overflow-auto whitespace-pre-wrap break-words rounded bg-muted/30 p-2 text-xs text-muted-foreground`,children:e.rawContent})]})]})]})}export{v as PromptJournalView};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{K as t}from"./config-store-BbL0WxLE.js";import{i as n,t as r}from"./react-core-wiHys0m2.js";import{Na as i,Ti as a,Vn as o,Yt as s,ja as c,kn as l,xo as u}from"./vendor-V3ydTHqN.js";import"./i18n-Dv97urcO.js";import{t as d}from"./utils-CKsqCaP8.js";var f=e(n(),1),p=r(),m=200,h=new Set([`raw_user`,`refined_user`]),g=[`raw_user`,`refined_user`];function _(e,t){return e(`activity:promptJournal.cat.${t}`,t)}function v(){let{t:e}=u(),n=t(),[r,i]=(0,f.useState)([]),[c,v]=(0,f.useState)(!0),[b,x]=(0,f.useState)(null),[S,C]=(0,f.useState)(!0),[w,T]=(0,f.useState)({category:``,session:``,limit:m}),[E,D]=(0,f.useState)(new Set),O=(0,f.useCallback)(()=>{if(!n.isConnected){C(!1);return}C(!0),x(null),n.send({type:`prompts.journal`,payload:{filter:{...w.category?{category:w.category}:{},limit:w.limit}}})},[n,w.category,w.limit]);(0,f.useEffect)(()=>{let e=e=>{let t=e.payload;v(t.enabled);let n=(t.entries??[]).filter(e=>h.has(e.category));i(n),x(t.error??null),C(!1)};return n.on(`prompts.journal`,e),O(),()=>n.off(`prompts.journal`,e)},[n,O]);let k=(0,f.useMemo)(()=>{let e=w.session.trim().toLowerCase(),t=r.filter(t=>!e||t.sessionId.toLowerCase().includes(e)),n=new Map;for(let e of[...t].reverse()){let t=e.timestamp.slice(0,10),r=n.get(t)??[];r.push(e),n.set(t,r)}return[...n.entries()]},[r,w.session]),A=(0,f.useMemo)(()=>{let e=0;for(let t of r)e+=t.metadata.tokenEstimate??0;return{count:r.length,tokens:e}},[r]),j=e=>{D(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},M=(0,f.useMemo)(()=>g.filter(e=>r.some(t=>t.category===e)),[r]);return(0,p.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-y-auto`,children:[(0,p.jsxs)(`div`,{className:`border-b border-border/70 px-4 py-3 sm:px-6`,children:[(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(l,{className:`h-5 w-5 text-primary`}),(0,p.jsx)(`h1`,{className:`text-base font-semibold`,children:e(`activity:promptJournal.title`)})]}),(0,p.jsxs)(`button`,{type:`button`,onClick:O,disabled:S,className:`inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-xs text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:opacity-50`,children:[(0,p.jsx)(o,{className:d(`h-3.5 w-3.5`,S&&`animate-spin`)}),e(`activity:promptJournal.refresh`)]})]}),(0,p.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:e(`activity:promptJournal.subtitle`)}),c&&A.count>0&&(0,p.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-x-4 gap-y-1 text-xs text-muted-foreground`,children:[(0,p.jsx)(`span`,{children:e(`activity:promptJournal.statEntries`,{count:A.count})}),(0,p.jsx)(`span`,{children:e(`activity:promptJournal.statTokens`,{count:A.tokens.toLocaleString()})})]})]}),(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-border/70 px-4 py-2 sm:px-6`,children:[(0,p.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,p.jsx)(`span`,{children:e(`activity:promptJournal.filterCategory`)}),(0,p.jsxs)(`select`,{value:w.category,onChange:e=>T(t=>({...t,category:e.target.value})),className:`rounded border border-border bg-background px-2 py-1 text-xs outline-none focus:ring-1 focus:ring-primary`,children:[(0,p.jsx)(`option`,{value:``,children:e(`activity:promptJournal.filterAll`)}),M.map(t=>(0,p.jsx)(`option`,{value:t,children:_(e,t)},t))]})]}),(0,p.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,p.jsx)(`span`,{children:e(`activity:promptJournal.filterSession`)}),(0,p.jsx)(`input`,{type:`text`,value:w.session,onChange:e=>T(t=>({...t,session:e.target.value})),placeholder:`sess_…`,className:`w-40 rounded border border-border bg-background px-2 py-1 text-xs outline-none focus:ring-1 focus:ring-primary`})]}),(0,p.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,p.jsx)(`span`,{children:e(`activity:promptJournal.filterLimit`)}),(0,p.jsxs)(`select`,{value:w.limit,onChange:e=>T(t=>({...t,limit:Number(e.target.value)})),className:`rounded border border-border bg-background px-2 py-1 text-xs outline-none focus:ring-1 focus:ring-primary`,children:[(0,p.jsx)(`option`,{value:50,children:`50`}),(0,p.jsx)(`option`,{value:200,children:`200`}),(0,p.jsx)(`option`,{value:1e3,children:`1000`})]})]})]}),(0,p.jsxs)(`div`,{className:`min-h-0 flex-1 px-4 py-3 sm:px-6`,children:[S&&(0,p.jsx)(`div`,{className:`py-10 text-center text-sm text-muted-foreground`,children:e(`activity:promptJournal.loading`)}),!S&&b&&(0,p.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-10 text-sm text-destructive`,children:[(0,p.jsx)(s,{className:`h-4 w-4`}),b]}),!S&&!b&&!c&&(0,p.jsx)(`div`,{className:`py-10 text-center text-sm text-muted-foreground`,children:e(`activity:promptJournal.disabled`)}),!S&&!b&&c&&k.length===0&&(0,p.jsxs)(`div`,{className:`py-10 text-center`,children:[(0,p.jsx)(a,{className:`mx-auto h-8 w-8 text-muted-foreground/50`}),(0,p.jsx)(`div`,{className:`mt-2 text-sm font-medium text-foreground`,children:e(`activity:promptJournal.emptyTitle`)}),(0,p.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:e(`activity:promptJournal.emptyHint`)})]}),!S&&!b&&c&&k.length>0&&(0,p.jsx)(`div`,{className:`space-y-5`,children:k.map(([e,t])=>(0,p.jsxs)(`section`,{children:[(0,p.jsxs)(`h2`,{className:`sticky top-0 z-10 border-b border-border/60 bg-background/90 py-1 text-xs font-semibold uppercase tracking-wide text-muted-foreground backdrop-blur`,children:[e,(0,p.jsx)(`span`,{className:`ml-2 font-normal normal-case text-muted-foreground/60`,children:t.length})]}),(0,p.jsx)(`ul`,{className:`mt-2 space-y-2`,children:t.map(e=>(0,p.jsx)(y,{entry:e,expanded:E.has(e.id),onToggle:()=>j(e.id)},e.id))})]},e))})]})]})}function y({entry:e,expanded:t,onToggle:n}){let{t:r}=u(),a=e.timestamp.slice(11,19),o=e.metadata,s=e.content.trim().slice(0,240),l=e.rawContent!==void 0&&e.rawContent!==e.content;return(0,p.jsxs)(`li`,{className:`rounded-lg border border-border/70 bg-card/60`,children:[(0,p.jsxs)(`button`,{type:`button`,onClick:n,className:`flex w-full items-start gap-2 rounded-lg px-3 py-2 text-left hover:bg-accent/40`,children:[t?(0,p.jsx)(i,{className:`mt-0.5 h-4 w-4 shrink-0 text-muted-foreground`}):(0,p.jsx)(c,{className:`mt-0.5 h-4 w-4 shrink-0 text-muted-foreground`}),(0,p.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-xs`,children:[(0,p.jsx)(`span`,{className:`tabular text-muted-foreground`,children:a}),(0,p.jsx)(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 font-medium text-primary`,children:_(r,e.category)}),(0,p.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-muted-foreground`,children:e.role}),(0,p.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:e.sessionId})]}),!t&&s&&(0,p.jsx)(`div`,{className:`mt-1 line-clamp-2 whitespace-pre-wrap break-words text-xs text-foreground/80`,children:s})]}),(0,p.jsxs)(`span`,{className:`shrink-0 text-[11px] tabular text-muted-foreground`,children:[`~`,o.tokenEstimate,` `,r(`activity:promptJournal.tokens`)]})]}),t&&(0,p.jsxs)(`div`,{className:`border-t border-border/60 px-3 py-2 pl-9`,children:[(0,p.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-wide text-muted-foreground`,children:r(`activity:promptJournal.refinedBody`)}),(0,p.jsx)(`pre`,{className:`mt-1 max-h-72 overflow-auto whitespace-pre-wrap break-words rounded bg-muted/50 p-2 text-xs text-foreground`,children:e.content}),l&&(0,p.jsxs)(`div`,{className:`mt-2`,children:[(0,p.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-wide text-muted-foreground`,children:r(`activity:promptJournal.rawInput`)}),(0,p.jsx)(`pre`,{className:`mt-1 max-h-40 overflow-auto whitespace-pre-wrap break-words rounded bg-muted/30 p-2 text-xs text-muted-foreground`,children:e.rawContent})]})]})]})}export{v as PromptJournalView};