@wrongstack/webui 0.299.0 → 0.301.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (180) hide show
  1. package/dist/assets/AgentRosterView-BV6ysoGs.js +9 -0
  2. package/dist/assets/{AnalyticsDashboard-D58kSekC.js → AnalyticsDashboard-UWNP8zjE.js} +1 -1
  3. package/dist/assets/AudienceMemoryPanel-DwDKbvSA.js +3 -0
  4. package/dist/assets/ChangesView-DuVlGWkD.js +1 -0
  5. package/dist/assets/ChronicleDashboard-cs16n708.js +1 -0
  6. package/dist/assets/CodeEditor-sr50ljZN.js +1 -0
  7. package/dist/assets/CodeMap-CtK-C8gK.js +1 -0
  8. package/dist/assets/ConfirmModal-ndS17YwF.js +1 -0
  9. package/dist/assets/CronJobsPanel-Dovomns5.js +1 -0
  10. package/dist/assets/DeadCodeScanPanel-DjR4LLMs.js +2 -0
  11. package/dist/assets/DebugDashboard-jK1yp3qS.js +1 -0
  12. package/dist/assets/DesignGalleryView-CqXlEUzE.js +1 -0
  13. package/dist/assets/GoalView-CGNLrnA4.js +1 -0
  14. package/dist/assets/KanbanView--tAf_K7N.js +3 -0
  15. package/dist/assets/{MailboxDetailView-ZcKcOEAe.js → MailboxDetailView-0TBzZTdN.js} +1 -1
  16. package/dist/assets/MemoryManager-CDK_MO8A.js +1 -0
  17. package/dist/assets/{ModelPicker-DvNLZzkm.js → ModelPicker-BbBZuQwR.js} +1 -1
  18. package/dist/assets/OfficeMapPanel-68sVzHRD.js +4 -0
  19. package/dist/assets/OfficeMapPanel-D6yTfGIT.css +1 -0
  20. package/dist/assets/{ProcessMonitor-2nSk6sXA.js → ProcessMonitor-gFwiF8gX.js} +1 -1
  21. package/dist/assets/{QueuePanel-4KBBWFxj.js → QueuePanel-Cx-isRGl.js} +1 -1
  22. package/dist/assets/{RefreshDebugView-D3XnE53y.js → RefreshDebugView-C9tdu6Ld.js} +1 -1
  23. package/dist/assets/RequirementIntakeView-cPEw-RpV.js +1 -0
  24. package/dist/assets/SageTabs-BbK6VFO0.js +2 -0
  25. package/dist/assets/SddHub-NKvDRECi.js +2 -0
  26. package/dist/assets/SessionInspectView-DPG5qWhj.js +1 -0
  27. package/dist/assets/SessionList-ncl-20X_.js +1 -0
  28. package/dist/assets/SessionsDashboard-D23UVLr4.js +1 -0
  29. package/dist/assets/SetupScreen-D3XQ8MGk.js +1 -0
  30. package/dist/assets/{SkillDetailView-D7EQ2XtV.js → SkillDetailView-DDPhVFet.js} +1 -1
  31. package/dist/assets/SpecsView-afIS0QpX.js +1 -0
  32. package/dist/assets/TechStackView-kQ2OGxxw.js +1 -0
  33. package/dist/assets/{TerminalPanel-BL9ZPGJt.js → TerminalPanel-GcJWeldW.js} +1 -1
  34. package/dist/assets/{Toaster-CJI70aa-.js → Toaster-CgQA9256.js} +1 -1
  35. package/dist/assets/activity-B-cvKIfT.js +9 -0
  36. package/dist/assets/activity-Ba3aMzvo.js +9 -0
  37. package/dist/assets/activity-CRTVZ5A4.js +9 -0
  38. package/dist/assets/activity-DsSuflRW.js +9 -0
  39. package/dist/assets/activity-DxDRJ8kN.js +9 -0
  40. package/dist/assets/activity-VI776bUZ.js +9 -0
  41. package/dist/assets/activity-nVmsmqAI.js +9 -0
  42. package/dist/assets/chat-BPuAsrkF.js +1 -0
  43. package/dist/assets/chat-BfQBSiII.js +1 -0
  44. package/dist/assets/chat-BnkVCZ3Q.js +1 -0
  45. package/dist/assets/chat-CR2B97dj.js +1 -0
  46. package/dist/assets/chat-CdiY7G6Z.js +1 -0
  47. package/dist/assets/chat-DResBrkV.js +1 -0
  48. package/dist/assets/chat-Di8o0wDz.js +1 -0
  49. package/dist/assets/chat-store-DbxFVDwi.js +17 -0
  50. package/dist/assets/{common-DMM-xyW3.js → common-BXJbu5Y-.js} +1 -1
  51. package/dist/assets/{common-C9ikgX7d.js → common-BiNu_WzQ.js} +1 -1
  52. package/dist/assets/common-COVxQ0FV.js +1 -0
  53. package/dist/assets/{common-D29Zdkxb.js → common-Ch7JihXD.js} +1 -1
  54. package/dist/assets/{common-DoUBSHRY.js → common-DPaTeTls.js} +1 -1
  55. package/dist/assets/{common-vdwxzODB.js → common-DdGpRh8j.js} +1 -1
  56. package/dist/assets/{common-C5hY-d_0.js → common-pI6fYZW3.js} +1 -1
  57. package/dist/assets/i18n-COgumVF5.js +2 -0
  58. package/dist/assets/index-CtpViiZy.js +132 -0
  59. package/dist/assets/index-fIsq43fR.css +1 -0
  60. package/dist/assets/mailbox-store-C1mzoSqJ.js +1 -0
  61. package/dist/assets/{progress-ring-61A-xUEl.js → progress-ring-D_48qsBl.js} +1 -1
  62. package/dist/assets/{roster-ws-Dfg_187V.js → roster-ws-Da57e_sI.js} +1 -1
  63. package/dist/assets/session-store-Df7_hhe9.js +1 -0
  64. package/dist/assets/settings-Bb7_utQE.js +1 -0
  65. package/dist/assets/settings-Bd8zMwvC.js +1 -0
  66. package/dist/assets/settings-DdFgBMAw.js +1 -0
  67. package/dist/assets/settings-De6sXIFO.js +1 -0
  68. package/dist/assets/settings-E8SKMLxq.js +1 -0
  69. package/dist/assets/settings-zIY9-ivF.js +1 -0
  70. package/dist/assets/settings-zKBcRjqE.js +1 -0
  71. package/dist/assets/stores-ChEnUmic.js +7 -0
  72. package/dist/assets/ui-store-CE4-TlwB.js +1 -0
  73. package/dist/assets/useWebSocket-_gk4MRJz.js +29 -0
  74. package/dist/assets/{view-navigation-DxfiZrXS.js → view-navigation-DIDEcp4V.js} +1 -1
  75. package/dist/assets/ws-client-TTMa0XaT.js +1 -0
  76. package/dist/components/AgentCard.d.ts +21 -0
  77. package/dist/components/AgentsPage.d.ts +0 -3
  78. package/dist/components/AutonomyPicker.d.ts +1 -1
  79. package/dist/components/ChatInput/refine-panel-host.d.ts +2 -2
  80. package/dist/components/ChatView/auto-collapse.d.ts +42 -0
  81. package/dist/components/ConfirmModal.d.ts +7 -2
  82. package/dist/components/FallbackModal.d.ts +2 -0
  83. package/dist/components/KanbanBoardState.d.ts +1 -1
  84. package/dist/components/KanbanVerificationDashboard.d.ts +0 -6
  85. package/dist/components/SettingsPanel/PluginToggleList.d.ts +11 -3
  86. package/dist/components/SettingsPanel/ShadowSection.d.ts +18 -1
  87. package/dist/components/SettingsPanel/brain-section-options.d.ts +27 -55
  88. package/dist/components/TaskCard.d.ts +0 -1
  89. package/dist/components/TaskRiskPanel.d.ts +10 -3
  90. package/dist/components/TechStackView/shared.d.ts +11 -6
  91. package/dist/components/ThemeProvider.d.ts +6 -1
  92. package/dist/components/agent-roster-data.d.ts +2 -1
  93. package/dist/components/index.d.ts +0 -1
  94. package/dist/hooks/useWebSocket.d.ts +10 -2
  95. package/dist/hooks/ws-handlers/files-mailbox-handlers.d.ts +1 -0
  96. package/dist/hooks/ws-handlers/misc-handlers.d.ts +13 -0
  97. package/dist/hooks/ws-handlers/session-handlers.d.ts +1 -0
  98. package/dist/index.css +62 -0
  99. package/dist/index.html +18 -17
  100. package/dist/index.js +26640 -12728
  101. package/dist/lib/file-icons.d.ts +3 -3
  102. package/dist/lib/kanban-board-active.d.ts +19 -0
  103. package/dist/lib/palettes.d.ts +37 -0
  104. package/dist/lib/plugin-enablement.d.ts +1 -1
  105. package/dist/lib/ws-client.d.ts +24 -4
  106. package/dist/providers.json +7 -7
  107. package/dist/stores/config-store.d.ts +9 -1
  108. package/dist/stores/context-editor-store.d.ts +9 -1
  109. package/dist/stores/fallback-store.d.ts +30 -0
  110. package/dist/stores/fleet-store.d.ts +14 -1
  111. package/dist/stores/index.d.ts +2 -0
  112. package/dist/stores/local-prefs.d.ts +13 -0
  113. package/dist/stores/mailbox-store.d.ts +2 -0
  114. package/dist/stores/session-store.d.ts +9 -1
  115. package/dist/stores/ui-store.d.ts +2 -0
  116. package/dist/types/brain.d.ts +2 -0
  117. package/dist/types/client-message.d.ts +19 -2
  118. package/dist/types/protocol-core.d.ts +21 -0
  119. package/dist/types/runtime.d.ts +22 -0
  120. package/dist/types/server-message.d.ts +15 -4
  121. package/package.json +9 -9
  122. package/dist/assets/AgentRosterView-BqojERFR.js +0 -11
  123. package/dist/assets/AudienceMemoryPanel-Cc1UkbDl.js +0 -3
  124. package/dist/assets/ChangesView-BKU80ANq.js +0 -1
  125. package/dist/assets/ChronicleDashboard-CvCS1Dj1.js +0 -1
  126. package/dist/assets/CodeEditor-BHZQhx_8.js +0 -1
  127. package/dist/assets/CodeMap-qllGEFLB.js +0 -1
  128. package/dist/assets/CronJobsPanel-DD5mhZ4Q.js +0 -1
  129. package/dist/assets/DeadCodeScanPanel-PB-c8et_.js +0 -2
  130. package/dist/assets/DebugDashboard-Q8QiVflQ.js +0 -1
  131. package/dist/assets/DesignGalleryView-CGOtWO7s.js +0 -1
  132. package/dist/assets/GoalView-Dlk42vW7.js +0 -1
  133. package/dist/assets/KanbanView-DIP6kKmU.js +0 -3
  134. package/dist/assets/MemoryManager-B7620q_K.js +0 -1
  135. package/dist/assets/OfficeMapPanel-BFIF-EMt.css +0 -1
  136. package/dist/assets/OfficeMapPanel-DKJNTtOZ.js +0 -4
  137. package/dist/assets/RequirementIntakeView-BMxlf8bt.js +0 -1
  138. package/dist/assets/SageTabs-g1hO2hJ0.js +0 -2
  139. package/dist/assets/SddHub-Kv_TbTgT.js +0 -2
  140. package/dist/assets/SessionInspectView-PnKTvyvP.js +0 -1
  141. package/dist/assets/SessionList-BeinIC-h.js +0 -1
  142. package/dist/assets/SessionsDashboard-DEG_BylE.js +0 -1
  143. package/dist/assets/SetupScreen-DxJwZ1OZ.js +0 -1
  144. package/dist/assets/SpecsView-Fm7pYYcj.js +0 -1
  145. package/dist/assets/TechStackView-Bo_UenRF.js +0 -1
  146. package/dist/assets/activity-BCgOEWgR.js +0 -5
  147. package/dist/assets/activity-BQ0zqkw2.js +0 -5
  148. package/dist/assets/activity-CAovbq3e.js +0 -5
  149. package/dist/assets/activity-CFQyCvgu.js +0 -5
  150. package/dist/assets/activity-CdQf7zRK.js +0 -5
  151. package/dist/assets/activity-DACvyn2-.js +0 -5
  152. package/dist/assets/activity-DOwYydU-.js +0 -5
  153. package/dist/assets/chat-CRmMDzCb.js +0 -1
  154. package/dist/assets/chat-CwnuX7tG.js +0 -1
  155. package/dist/assets/chat-DLn1hY01.js +0 -1
  156. package/dist/assets/chat-DSEq1Bdz.js +0 -1
  157. package/dist/assets/chat-DxLD17ER.js +0 -1
  158. package/dist/assets/chat-DzPxYALH.js +0 -1
  159. package/dist/assets/chat-OunddzYy.js +0 -1
  160. package/dist/assets/chat-store-CtOyUCdF.js +0 -17
  161. package/dist/assets/common-BfVFjVhf.js +0 -1
  162. package/dist/assets/i18n-B0hsnanh.js +0 -2
  163. package/dist/assets/index-DHdO0CRE.js +0 -132
  164. package/dist/assets/index-DKrFQ76m.css +0 -1
  165. package/dist/assets/mailbox-store-D8TvJsuk.js +0 -1
  166. package/dist/assets/session-store-b2KGFwkX.js +0 -1
  167. package/dist/assets/settings-B5xal2R3.js +0 -1
  168. package/dist/assets/settings-BHtFy8EG.js +0 -1
  169. package/dist/assets/settings-Bss5hBla.js +0 -1
  170. package/dist/assets/settings-BzrLCVRP.js +0 -1
  171. package/dist/assets/settings-C7RdvmLZ.js +0 -1
  172. package/dist/assets/settings-Dd94HoV6.js +0 -1
  173. package/dist/assets/settings-Dm9THFe8.js +0 -1
  174. package/dist/assets/stores-BptlyD_v.js +0 -7
  175. package/dist/assets/ui-store-BsBnjO3w.js +0 -1
  176. package/dist/assets/useWebSocket-Bc4S0N4r.js +0 -29
  177. package/dist/assets/ws-client-DqFoX4jJ.js +0 -1
  178. package/dist/components/AgentsMonitor.d.ts +0 -26
  179. package/dist/components/FleetMonitor.d.ts +0 -21
  180. package/dist/lib/accent-colors.d.ts +0 -136
@@ -0,0 +1,9 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./chat-store-DbxFVDwi.js";import{Ai as n,Ii as r,Oa as i,Ot as a,Pa as o,Qi as s,Wi as c,Wt as l,Xr as u,Zt as d,an as f,da as p,dt as m,ft as h,hr as g,ir as _,jt as v,la as y,lt as b,pr as x,tn as S,ua as C,ut as w,vi as T,vn as E,yi as D,za as O}from"./vendor-BuarzSSb.js";import"./i18n-COgumVF5.js";import{t as k}from"./ws-client-TTMa0XaT.js";import{t as A}from"./utils-B-9lSDIn.js";import{T as j}from"./stores-ChEnUmic.js";import{n as M}from"./ui-store-CE4-TlwB.js";import{i as N}from"./view-navigation-DIDEcp4V.js";import{n as P}from"./Toaster-CgQA9256.js";import{n as F,t as I}from"./ModelPicker-BbBZuQwR.js";import{s as L}from"./index-CtpViiZy.js";import{t as R}from"./roster-ws-Da57e_sI.js";var z=e(O(),1),B=b(),V=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],H=[[`timeoutMs`,`Total timeout (ms)`],[`idleTimeoutMs`,`Idle timeout (ms)`],[`maxIterations`,`Max iterations`],[`maxToolCalls`,`Max tool calls`],[`maxTokens`,`Max tokens`],[`maxCostUsd`,`Max cost (USD)`]];function U(e){return`${e.provider}/${e.model}`}function W(e){let t=e.indexOf(`/`);return t<0?{provider:``,model:e}:{provider:e.slice(0,t),model:e.slice(t+1)}}function G(e){return Array.isArray(e)?e.join(`, `):``}function K(e){return[...new Set(e.split(/[\n,]+/).map(e=>e.trim()).filter(Boolean))]}function q({initialConfig:e,systemProtected:t,saving:n,onSave:r,onCancel:i}){let{t:a}=o(),[s,c]=(0,z.useState)(()=>structuredClone(e)),l=F(!0),u=s.modelPolicy,f=(0,z.useMemo)(()=>(u?.allowed??[]).map(U),[u?.allowed]),p=(0,z.useMemo)(()=>(u?.fallbacks??[]).map(U),[u?.fallbacks]),m=e=>c(t=>({...t,...e})),h=(e,t)=>{let n=K(t);c(t=>{let r={...t};return n.length?r[e]=n:delete r[e],r})},g=(e,t)=>{c(n=>{let r={...n.budget??{}};t===``?delete r[e]:r[e]=Number(t);let i={...n};return Object.keys(r).length?i.budget=r:delete i.budget,i})},_=e=>{let t=e.map(W),n=new Set(e);c(e=>({...e,modelPolicy:{allowed:t,fallbacks:(e.modelPolicy?.fallbacks??[]).filter(e=>n.has(U(e))),strict:e.modelPolicy?.strict??!0}}))};return(0,B.jsxs)(`div`,{className:`space-y-4 rounded-lg border border-border bg-card/40 p-4`,children:[t&&(0,B.jsxs)(`div`,{className:`flex gap-2 rounded-md border border-warning/30 bg-warning/5 p-2 text-[11px] text-muted-foreground`,children:[(0,B.jsx)(d,{className:`mt-0.5 h-4 w-4 shrink-0 text-warning`}),(0,B.jsx)(`span`,{children:a(`activity:runtimePolicy.protectedSystemAgentRequiredToolsAnd`)})]}),(0,B.jsxs)(`section`,{className:`space-y-2`,children:[(0,B.jsx)(`h4`,{className:`text-xs font-semibold`,children:a(`activity:runtimePolicy.providerAndModelPolicy`)}),(0,B.jsx)(I,{candidates:l,provider:s.provider,value:s.model,placeholder:a(`activity:runtimePolicy.useProjectDefaultModel`),resetLabel:`Use project default`,onReset:()=>{c(e=>{let t={...e};return delete t.provider,delete t.model,t})},onPick:(e,t)=>{let n=`${t}/${e}`;m({provider:t,model:e}),u&&!f.includes(n)&&_([...f,n])}}),(0,B.jsxs)(`label`,{className:`flex items-center gap-2 text-[11px]`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:!!u,onChange:e=>{if(e.target.checked){let e=s.provider&&s.model?[{provider:s.provider,model:s.model}]:l[0]?[{provider:l[0].provider,model:l[0].model}]:[];e.length&&m({modelPolicy:{allowed:e,strict:!0}})}else c(e=>{let t={...e};return delete t.modelPolicy,t})}}),a(`activity:runtimePolicy.restrictThisAgentToAnExplicit`)]}),u&&(0,B.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,B.jsxs)(`div`,{className:`space-y-1`,children:[(0,B.jsx)(`span`,{className:`text-[10px] font-medium`,children:a(`activity:runtimePolicy.allowedModels`)}),(0,B.jsx)(L,{value:f,candidates:l,onChange:_,placeholder:a(`activity:runtimePolicy.addAllowedModel`),emptyHint:`At least one model is required`})]}),(0,B.jsxs)(`div`,{className:`space-y-1`,children:[(0,B.jsx)(`span`,{className:`text-[10px] font-medium`,children:a(`activity:runtimePolicy.orderedFallbackChain`)}),(0,B.jsx)(L,{value:p,candidates:l,onChange:e=>{let t=[...new Set([...f,...e])];c(n=>({...n,modelPolicy:{allowed:t.map(W),fallbacks:e.map(W),strict:n.modelPolicy?.strict??!0}}))},placeholder:a(`activity:runtimePolicy.addFallbackModel`),emptyHint:`No fallback; primary failure stops the task`})]})]})]}),(0,B.jsx)(`section`,{className:`grid gap-3 sm:grid-cols-3`,children:[[`tools`,`Tools`,`read_file, search, bash`],[`skillNames`,`Skills`,`security-check, browser`],[`allowedCapabilities`,`Capabilities`,`fs.read, fs.write`]].map(([e,t,n])=>(0,B.jsxs)(`label`,{className:`space-y-1 text-[10px]`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:t}),(0,B.jsx)(`textarea`,{value:G(s[e]),onChange:t=>h(e,t.target.value),placeholder:n,className:`h-20 w-full resize-y rounded border border-border bg-background p-2 font-mono`})]},e))}),(0,B.jsxs)(`section`,{className:`space-y-2`,children:[(0,B.jsx)(`h4`,{className:`text-xs font-semibold`,children:a(`activity:runtimePolicy.workspaceAndIsolation`)}),(0,B.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,B.jsxs)(`label`,{className:`space-y-1 text-[10px]`,children:[(0,B.jsx)(`span`,{children:a(`activity:runtimePolicy.projectRelativeWorkingDirectory`)}),(0,B.jsx)(`input`,{value:s.cwd??``,onChange:e=>m({cwd:e.target.value||void 0}),placeholder:a(`activity:runtimePolicy.packagesWebui`),className:`h-8 w-full rounded border border-border bg-background px-2 font-mono`})]}),(0,B.jsxs)(`label`,{className:`space-y-1 text-[10px]`,children:[(0,B.jsx)(`span`,{children:a(`activity:runtimePolicy.gitWorktreeIsolation`)}),(0,B.jsxs)(`select`,{value:String(s.worktree??`auto`),onChange:e=>m({worktree:e.target.value}),className:`h-8 w-full rounded border border-border bg-background px-2`,children:[(0,B.jsx)(`option`,{value:`auto`,children:a(`activity:runtimePolicy.automatic`)}),(0,B.jsx)(`option`,{value:`required`,children:a(`activity:runtimePolicy.required`)}),(0,B.jsx)(`option`,{value:`off`,children:a(`activity:runtimePolicy.off`)})]})]})]})]}),(0,B.jsxs)(`section`,{className:`space-y-2`,children:[(0,B.jsx)(`h4`,{className:`text-xs font-semibold`,children:a(`activity:runtimePolicy.limits`)}),(0,B.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:H.map(([e,t])=>(0,B.jsxs)(`label`,{className:`space-y-1 text-[10px]`,children:[(0,B.jsx)(`span`,{children:t}),(0,B.jsx)(`input`,{type:`number`,min:`0`,step:e===`maxCostUsd`?`0.01`:`1`,value:s.budget?.[e]??``,onChange:t=>g(e,t.target.value),className:`h-8 w-full rounded border border-border bg-background px-2`})]},e))})]}),(0,B.jsxs)(`section`,{className:`space-y-2`,children:[(0,B.jsxs)(`label`,{className:`flex items-center gap-2 text-xs font-semibold`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:!!s.availability,onChange:e=>{e.target.checked?m({availability:{timezone:Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`,days:[1,2,3,4,5],start:`09:00`,end:`18:00`,mode:t?`advisory`:`enforce`}}):c(e=>{let t={...e};return delete t.availability,t})}}),a(`activity:runtimePolicy.workingHours`)]}),s.availability&&(0,B.jsxs)(`div`,{className:`space-y-2 rounded border border-border p-2`,children:[(0,B.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:V.map((e,t)=>(0,B.jsxs)(`label`,{className:`flex items-center gap-1 text-[10px]`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:s.availability?.days.includes(t)??!1,onChange:e=>{let n=s.availability;if(!n)return;let r=e.target.checked?[...new Set([...n.days,t])].sort():n.days.filter(e=>e!==t);m({availability:{...n,days:r}})}}),e]},e))}),(0,B.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-4`,children:[(0,B.jsx)(`input`,{value:s.availability.timezone,onChange:e=>m({availability:{...s.availability,timezone:e.target.value}}),placeholder:a(`activity:runtimePolicy.europeKiev`),className:`h-8 rounded border border-border bg-background px-2 text-[10px]`}),(0,B.jsx)(`input`,{type:`time`,value:s.availability.start,onChange:e=>m({availability:{...s.availability,start:e.target.value}}),className:`h-8 rounded border border-border bg-background px-2 text-[10px]`}),(0,B.jsx)(`input`,{type:`time`,value:s.availability.end,onChange:e=>m({availability:{...s.availability,end:e.target.value}}),className:`h-8 rounded border border-border bg-background px-2 text-[10px]`}),(0,B.jsxs)(`select`,{value:t?`advisory`:s.availability.mode??`enforce`,disabled:t,onChange:e=>m({availability:{...s.availability,mode:e.target.value}}),className:`h-8 rounded border border-border bg-background px-2 text-[10px]`,children:[(0,B.jsx)(`option`,{value:`enforce`,children:a(`activity:runtimePolicy.enforce`)}),(0,B.jsx)(`option`,{value:`advisory`,children:a(`activity:runtimePolicy.advisory`)})]})]})]})]}),(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(`button`,{type:`button`,disabled:n||!!(u&&u.allowed.length===0),onClick:()=>r(s),className:`rounded bg-primary px-3 py-1.5 text-xs text-primary-foreground disabled:opacity-50`,children:n?`Saving…`:`Save runtime policy`}),(0,B.jsx)(`button`,{type:`button`,onClick:i,className:`rounded border border-border px-3 py-1.5 text-xs hover:bg-accent`,children:a(`activity:runtimePolicy.cancel`)})]})]})}var J=[{id:`live`,icon:(0,B.jsx)(i,{className:`h-4 w-4`}),labelKey:`activity:agentRoster.tabLive`},{id:`catalog`,icon:(0,B.jsx)(C,{className:`h-4 w-4`}),labelKey:`activity:agentRoster.tabCatalog`},{id:`learning`,icon:(0,B.jsx)(p,{className:`h-4 w-4`}),labelKey:`activity:agentRoster.tabLearning`},{id:`customize`,icon:(0,B.jsx)(S,{className:`h-4 w-4`}),labelKey:`activity:agentRoster.tabCustomize`}],Y=[{role:`generic`,name:`Generic Project Agent`,summary:`Flexible template that can be cloned into independently learning project roles.`,tools:0,budget:{maxIterations:2500,maxToolCalls:7500}},{role:`audit-log`,name:`Audit Log`,summary:`Analyzes session logs, event streams, and system traces.`,tools:12,budget:{timeoutMs:108e5,maxIterations:2500,maxToolCalls:7500}},{role:`bug-hunter`,name:`Bug Hunter`,summary:`Scans code for bugs, code smells, and anti-patterns.`,tools:15,budget:{timeoutMs:18e6,maxIterations:4e3,maxToolCalls:1e4}},{role:`refactor-planner`,name:`Refactor Planner`,summary:`Analyzes code structure and produces phased refactoring plans.`,tools:14,budget:{timeoutMs:144e5,maxIterations:3e3,maxToolCalls:9e3}},{role:`security-scanner`,name:`Security Scanner`,summary:`Scans code, configs, and dependencies for security issues.`,tools:18,budget:{timeoutMs:18e6,maxIterations:4e3,maxToolCalls:1e4}},{role:`critic`,name:`Critic`,summary:`Evaluates decisions, plans, and implementations.`,tools:10,budget:{timeoutMs:108e5,maxIterations:2e3,maxToolCalls:5e3}},{role:`shadow-agent`,name:`Shadow Agent`,summary:`Background monitoring agent that watches fleet health.`,tools:8,budget:{timeoutMs:36e6,maxIterations:500,maxToolCalls:2e3}},{role:`executor`,name:`Executor`,summary:`General-purpose task executor for delegated work.`,tools:20,budget:{timeoutMs:72e5,maxIterations:1500,maxToolCalls:4e3}},{role:`chimera`,name:`Chimera`,summary:`Post-session code quality review of changed files.`,tools:10,budget:{timeoutMs:72e5,maxIterations:1e3,maxToolCalls:3e3}},{role:`researcher`,name:`Researcher`,summary:`Web research and data gathering specialist.`,tools:8,budget:{timeoutMs:72e5,maxIterations:1e3,maxToolCalls:3e3}},{role:`tech-stack`,name:`Tech Stack Validator`,summary:`Validates package/library/framework choices.`,tools:9,budget:{timeoutMs:72e5,maxIterations:1e3,maxToolCalls:3e3}},{role:`orchestrator`,name:`Orchestrator`,summary:`Coordinates multi-agent task execution.`,tools:12,budget:{timeoutMs:144e5,maxIterations:3e3,maxToolCalls:8e3}},{role:`supervisor`,name:`Supervisor`,summary:`Oversees subagent execution and handles escalations.`,tools:10,budget:{timeoutMs:144e5,maxIterations:2e3,maxToolCalls:6e3}},{role:`quality-gate`,name:`Quality Gate`,summary:`Enforces quality gates on implementations.`,tools:8,budget:{timeoutMs:72e5,maxIterations:1e3,maxToolCalls:3e3}},{role:`architect`,name:`Architect`,summary:`Makes design and architecture decisions.`,tools:14,budget:{timeoutMs:144e5,maxIterations:3e3,maxToolCalls:8e3}},{role:`prompt-engineer`,name:`Prompt Engineer`,summary:`Designs and optimizes system prompts.`,tools:8,budget:{timeoutMs:72e5,maxIterations:1e3,maxToolCalls:3e3}},{role:`mnemosyne`,name:`Mnemosyne`,summary:`Memory curator — reviews and maintains SAGE integrity.`,tools:6,budget:{timeoutMs:72e5,maxIterations:500,maxToolCalls:2e3}},{role:`autophase`,name:`AutoPhase`,summary:`Manages multi-phase autonomous task execution.`,tools:10,budget:{timeoutMs:144e5,maxIterations:2e3,maxToolCalls:6e3}}];function X({customStats:e,rosterLoading:t,onRefresh:n}){let{t:r}=o();return(0,B.jsx)(`div`,{className:`shrink-0 border-b border-border/70 bg-card/80 px-4 py-2.5`,children:(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2 flex-nowrap min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 overflow-hidden`,children:[(0,B.jsx)(`div`,{className:`flex items-center justify-center w-8 h-8 shrink-0 rounded-lg bg-primary/10`,children:(0,B.jsx)(x,{className:`h-4 w-4 text-primary`})}),(0,B.jsxs)(`div`,{className:`min-w-0 overflow-hidden`,children:[(0,B.jsx)(`h1`,{className:`text-sm font-semibold truncate`,children:r(`activity:agentRoster.heading`)}),(0,B.jsx)(`p`,{className:`text-[10px] text-muted-foreground truncate`,children:r(`activity:agentRoster.headerSummary`,{customized:e.filter(e=>e.exists||e.hasIdentity||e.hasConfig||e.hasKnowledge).length,entries:e.reduce((e,t)=>e+t.entryCount,0)})})]})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[t&&(0,B.jsx)(_,{className:`h-4 w-4 animate-spin text-muted-foreground shrink-0`}),(0,B.jsxs)(`button`,{type:`button`,onClick:n,className:`inline-flex items-center gap-1 rounded border border-border/50 px-2 py-1 text-[10px] hover:bg-accent transition-colors shrink-0 whitespace-nowrap`,title:r(`activity:agentRoster.refreshRosterData`),children:[(0,B.jsx)(E,{className:`h-3 w-3`}),` `,r(`common:action.refresh`)]})]})]})})}function ee({activeTab:e,onTabChange:t}){let{t:n}=o();return(0,B.jsx)(`div`,{className:`shrink-0 border-b border-border/50 bg-muted/20 px-3 flex gap-0`,children:J.map(r=>(0,B.jsxs)(`button`,{type:`button`,onClick:()=>t(r.id),className:A(`flex items-center gap-1.5 px-3 py-2 text-[10px] font-medium border-b-2 transition-colors`,e===r.id?`border-primary text-primary`:`border-transparent text-muted-foreground hover:text-foreground hover:border-muted-foreground/30`),children:[r.icon,n(r.labelKey)]},r.id))})}function te({customStats:e,onRefresh:n}){let{t:r}=o(),[i,s]=(0,z.useState)(null),[u,d]=(0,z.useState)(null),[f,m]=(0,z.useState)({}),[h,g]=(0,z.useState)(``),[v,y]=(0,z.useState)(null),[b,x]=(0,z.useState)(!1),[S,E]=(0,z.useState)(!1),[D,O]=(0,z.useState)(null),[j,N]=(0,z.useState)(!1),[F,I]=(0,z.useState)(!1),L=(0,z.useMemo)(()=>[...e].sort((e,t)=>e.role.localeCompare(t.role)),[e]),V=(0,z.useMemo)(()=>i?L.find(e=>e.role===i):null,[i,L]),H=(0,z.useCallback)(async e=>{E(!0),d(null);try{let t=await R(`agent-roster.read-learned`,{role:e});d(t.entries??[]),m({})}catch{}E(!1)},[]),U=(0,z.useCallback)(async()=>{if(!i||!u)return;x(!0);let e=u.filter((e,t)=>f[t]!==`drop`).join(`
2
+
3
+ ---
4
+
5
+ `);try{await R(`agent-roster.update-learned`,{role:i,content:e}),d(null),m({})}catch{}x(!1)},[i,u,f]),W=(0,z.useCallback)(async()=>{if(!(!i||!h.trim())){y(null),x(!0);try{let e=`> Taught ${new Date().toISOString().slice(0,10)}\n\n${h.trim()}`;(await R(`agent-roster.append-learned`,{role:i,content:e})).success?(y({ok:!0,msg:r(`activity:customRoster.behaviorSaved`)}),g(``),n()):y({ok:!1,msg:r(`activity:agentRoster.saveFailed`)})}catch(e){y({ok:!1,msg:e instanceof Error?e.message:r(`activity:agentRoster.failed`)})}x(!1)}},[n,i,h]),G=(0,z.useCallback)(async(e,t)=>{x(!0),y(null);try{let i=await R(`agent-roster.update-learning`,{role:e,enabled:t});if(i.error)throw Error(i.error);y({ok:!0,msg:r(t?`activity:agentRoster.learningResumed`:`activity:agentRoster.autoLearningPaused`)}),n()}catch(e){y({ok:!1,msg:e instanceof Error?e.message:r(`activity:agentRoster.policyUpdateFailed`)})}finally{x(!1)}},[n]),K=(0,z.useCallback)(async e=>{try{let t=await R(`agent-roster.read-consolidated`,{role:e});O(t.isConsolidated?t.content:null)}catch{O(null)}},[]),q=(0,z.useCallback)(async e=>{N(!0),y(null);try{let i=await R(`agent-roster.consolidate`,{role:e});if(i.error)throw Error(i.error);if(i.rawEntryCount===0){y({ok:!1,msg:r(`activity:agentRoster.noRawEntries`)});return}if(i.consolidated){await n(),await K(e),y({ok:!0,msg:r(`activity:agentRoster.optimizedOk`)}),P.success(i.model?r(`activity:agentRoster.consolidatedWithModel`,{model:i.model}):r(`activity:agentRoster.consolidatedPlain`));return}if(i.emptySynthesis){y({ok:!1,msg:r(`activity:agentRoster.emptySynthesis`)}),P.error(r(`activity:agentRoster.optimizationEmptyToast`));return}let a=i.instruction;if(!a)throw Error(`No consolidation instruction generated`);let o=t.getState();o.addMessage({role:`user`,content:a}),o.setLoading(!0),k().sendMessage(a);let s=M.getState();s.setSidebarOpen(!1),s.setCurrentView(`chat`),y({ok:!0,msg:r(`activity:agentRoster.noActiveModelMsg`)}),P.info(r(`activity:agentRoster.noActiveModelToast`))}catch(e){y({ok:!1,msg:e instanceof Error?e.message:r(`activity:agentRoster.optimizationFailed`)}),P.error(e instanceof Error?e.message:r(`activity:agentRoster.optimizationFailed`))}finally{N(!1)}},[n,K]),J=(0,z.useCallback)(async e=>{if(e.length!==0){I(!0),y(null);try{let n=[],r=0,a=0,o=``,s=[];for(let t of e)try{let e=await R(`agent-roster.consolidate`,{role:t});e.error?(a++,o=e.error):e.consolidated?n.push(t):e.rawEntryCount===0?r++:e.emptySynthesis?(a++,o=`Model returned an empty result`):e.instruction?s.push({role:t,instruction:e.instruction}):(a++,o=`No consolidation produced`)}catch(e){a++,o=e instanceof Error?e.message:String(e)}if(i&&n.includes(i)&&await K(i),s.length>0){let e=`Optimize the learned data for ${s.length} agent${s.length>1?`s`:``}. For each agent below, read its raw learned entries, synthesize them into a single narrowly-scoped document preserving every fact, and save the result to its consolidated.md file.\n\n`+s.map(e=>`## Agent: ${e.role}\n\n${e.instruction}`).join(`
6
+
7
+ ---
8
+
9
+ `),n=t.getState();n.addMessage({role:`user`,content:e}),n.setLoading(!0),k().sendMessage(e);let r=M.getState();r.setSidebarOpen(!1),r.setCurrentView(`chat`)}if(n.length===0&&s.length===0){if(a>0){let t=r>0?` ${r} skipped.`:``,n=`Bulk consolidate failed for ${a} of ${e.length} agent${e.length>1?`s`:``}.${o?` Last error: ${o}`:``}${t}`;y({ok:!1,msg:n});return}let t=r>0?`Bulk optimize: ${r} skipped (no entries to optimize).`:`No agents had optimizable entries.`;y({ok:!0,msg:t}),P.info(t,6e3);return}let c=[];n.length>0&&c.push(`${n.length} consolidated`),s.length>0&&c.push(`${s.length} sent to chat`),r>0&&c.push(`${r} skipped`),a>0&&c.push(`${a} failed`);let l=`Bulk optimize: ${c.join(`, `)}.`;y({ok:a===0,msg:l}),n.length>0&&s.length===0?P.success(l,6e3):P.info(l,6e3)}catch(e){y({ok:!1,msg:e instanceof Error?e.message:r(`activity:agentRoster.bulkOptimizationFailed`)}),P.error(e instanceof Error?e.message:r(`activity:agentRoster.bulkOptimizationFailed`))}finally{I(!1)}}},[i,K]);return L.length===0?(0,B.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-muted-foreground`,children:(0,B.jsxs)(`div`,{className:`text-center space-y-3`,children:[(0,B.jsx)(T,{className:`h-10 w-10 mx-auto opacity-30`}),(0,B.jsx)(`p`,{className:`text-sm`,children:r(`activity:agentRoster.noSelfLearningDataYet`)}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground/70`,children:r(`activity:agentRoster.learningsEmpty`)})]})}):(0,B.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(0,B.jsxs)(`div`,{className:A(`flex flex-col min-h-0 min-w-0 overflow-hidden border-r border-border/50`,i?`w-80 shrink-0`:`flex-1`),children:[(0,B.jsxs)(`div`,{className:`shrink-0 px-3 py-2 border-b border-border/50`,children:[(0,B.jsxs)(`h3`,{className:`text-xs font-semibold flex items-center gap-1.5`,children:[(0,B.jsx)(T,{className:`h-3.5 w-3.5 text-brand-2`}),r(`activity:agentRoster.allRosterAgents`)]}),(()=>{let e=L.filter(e=>e.needsSummarization);return e.length===0?null:(0,B.jsxs)(`div`,{className:`mt-2 flex flex-col gap-1.5 rounded border border-warning/40 bg-warning/10 px-2 py-1.5`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(w,{className:`h-3 w-3 text-warning shrink-0`}),(0,B.jsxs)(`span`,{className:`text-[10px] text-warning leading-tight`,children:[e.length,` agent`,e.length>1?`s`:``,` need`,e.length===1?`s`:``,` optimization`]}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>{let t=e[0];t&&(s(t.role),d(null),O(null))},className:`ml-auto text-[9px] text-warning underline hover:text-warning/80 shrink-0`,children:r(`activity:agentRoster.review`)})]}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>J(e.map(e=>e.role)),disabled:F,className:`flex items-center justify-center gap-1 rounded bg-warning/20 border border-warning/40 px-2 py-1 text-[10px] font-medium text-warning hover:bg-warning/30 transition-colors disabled:opacity-50`,children:[F?(0,B.jsx)(_,{className:`h-3 w-3 animate-spin`}):(0,B.jsx)(w,{className:`h-3 w-3`}),F?r(`activity:agentRoster.optimizing`):r(`activity:agentRoster.optimizeAll`,{count:e.length})]})]})})()]}),(0,B.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-2 space-y-1`,children:L.map(e=>(0,B.jsxs)(`button`,{type:`button`,onClick:()=>{s(e.role),d(null),O(null)},className:A(`w-full text-left rounded-lg border px-3 py-2 transition-colors`,i===e.role?`border-primary/50 bg-primary/[0.06]`:`border-border/60 hover:border-primary/30`,e.needsSummarization&&i!==e.role&&`border-warning/40`),children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsx)(`span`,{className:`text-xs font-semibold`,children:e.role}),(0,B.jsx)(`span`,{className:A(`text-[9px] tabular-nums`,e.learningEnabled?`text-success`:`text-muted-foreground`),children:e.learningEnabled?r(`activity:agentRoster.learning`):r(`activity:agentRoster.paused`)})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2 mt-1 text-[9px] text-muted-foreground`,children:[(0,B.jsxs)(`span`,{className:`tabular-nums`,children:[e.entryCount,` entries`]}),e.sessionCaptureCount>0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,B.jsxs)(`span`,{className:`text-success tabular-nums`,children:[`+`,e.sessionCaptureCount]})]}),e.lastCapture&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,B.jsx)(`span`,{children:new Date(e.lastCapture).toLocaleDateString()})]}),e.needsSummarization&&(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-warning font-medium`,children:[(0,B.jsx)(w,{className:`h-2.5 w-2.5`}),`optimize`]})]})]},e.role))})]}),(0,B.jsxs)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-y-auto p-4`,children:[!i&&(0,B.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground`,children:r(`activity:agentRoster.selectAnAgentToViewLearning`)}),i&&V&&(0,B.jsxs)(`div`,{className:`space-y-4`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsx)(`h3`,{className:`text-base font-semibold`,children:i}),(0,B.jsx)(`div`,{className:`flex gap-1`,children:(0,B.jsxs)(`button`,{type:`button`,onClick:()=>G(i,!V.learningEnabled),disabled:b,className:A(`inline-flex items-center gap-1 rounded border px-2 py-1 text-[10px] transition-colors disabled:opacity-50`,V.learningEnabled?`border-success/40 text-success hover:bg-success/10`:`border-border/50 text-muted-foreground hover:bg-accent`),children:[(0,B.jsx)(T,{className:`h-3 w-3`}),` `,V.learningEnabled?r(`activity:agentRoster.learningOn`):r(`activity:agentRoster.learningPaused`)]})})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-4 gap-2`,children:[(0,B.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,B.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:r(`activity:agentRoster.entries`)}),(0,B.jsx)(`div`,{className:`text-lg font-mono font-semibold mt-0.5`,children:V.entryCount})]}),(0,B.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,B.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:r(`activity:agentRoster.size`)}),(0,B.jsxs)(`div`,{className:`text-lg font-mono font-semibold mt-0.5`,children:[V.totalBytes,`B`]})]}),(0,B.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,B.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:r(`activity:agentRoster.lastCapture`)}),(0,B.jsx)(`div`,{className:`text-lg font-mono font-semibold mt-0.5`,children:V.lastCapture?new Date(V.lastCapture).toLocaleDateString():`—`})]}),(0,B.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,B.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:r(`activity:agentRoster.lifetimeCaptures`)}),(0,B.jsx)(`div`,{className:`text-lg font-mono font-semibold mt-0.5`,children:V.lifetimeCaptureCount})]})]}),V.needsSummarization&&(0,B.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-warning bg-warning/10 rounded-lg px-3 py-2.5`,children:[(0,B.jsx)(a,{className:`h-4 w-4 shrink-0`}),(0,B.jsx)(`span`,{className:`flex-1`,children:r(`activity:agentRoster.learningsLimitExceeded`,{bytes:V.totalBytes.toLocaleString()})}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>q(i),disabled:j,className:`inline-flex items-center gap-1 rounded bg-warning/20 text-warning border border-warning/40 px-2.5 py-1 text-[10px] font-medium hover:bg-warning/30 transition-colors disabled:opacity-50 shrink-0`,children:[j?(0,B.jsx)(_,{className:`h-3 w-3 animate-spin`}):(0,B.jsx)(w,{className:`h-3 w-3`}),j?r(`activity:agentRoster.optimizing`):`Optimize Now`]})]}),(0,B.jsxs)(`div`,{className:`space-y-2 border border-border rounded-lg p-3 bg-card`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsx)(l,{className:`h-4 w-4 text-primary`}),(0,B.jsx)(`span`,{className:`text-xs font-semibold`,children:r(`activity:agentRoster.optimizeLearnings`)})]}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>q(i),disabled:j||V.entryCount===0,className:`inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs text-primary-foreground hover:bg-primary/90 transition-colors disabled:opacity-50`,title:V.entryCount===0?`No raw entries to optimize`:`Synthesize raw entries into a consolidated, narrowly-scoped document`,children:[j?(0,B.jsx)(_,{className:`h-3.5 w-3.5 animate-spin`}):(0,B.jsx)(w,{className:`h-3.5 w-3.5`}),j?r(`activity:agentRoster.optimizing`):`Optimize`]})]}),(0,B.jsxs)(`p`,{className:`text-[10px] text-muted-foreground leading-relaxed`,children:[`Synthesizes all `,V.entryCount,` raw entries into a single reviewed document — narrowly scoped to this agent's skills, preserving every fact but reducing context volume. The result replaces raw entries in the agent's prompt.`]}),V.isConsolidated&&V.consolidation&&(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-muted-foreground pt-1 border-t border-border/50`,children:[(0,B.jsx)(c,{className:`h-3 w-3 text-success`}),(0,B.jsxs)(`span`,{children:[`Consolidated`,` `,new Date(V.consolidation.consolidatedAt).toLocaleDateString(),` ·`,` `,V.consolidation.sourceBytes,`B →`,` `,V.consolidation.consolidatedBytes,`B`,V.consolidation.sourceEntryCount<V.entryCount&&(0,B.jsxs)(`span`,{className:`text-warning ml-1`,children:[`· `,V.entryCount-V.consolidation.sourceEntryCount,` `,r(`activity:agentRoster.newPending`)]})]}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>{D===null?K(i):O(null)},className:`ml-auto underline text-primary hover:text-primary/80`,children:D===null?r(`activity:agentRoster.viewAction`):`Hide`})]}),D!==null&&(0,B.jsxs)(`div`,{className:`mt-2 max-h-72 overflow-y-auto rounded border border-border/50 bg-background/50 p-2`,children:[(0,B.jsxs)(`div`,{className:`text-[10px] text-muted-foreground mb-1 font-medium`,children:[`Consolidated knowledge for `,i]}),(0,B.jsx)(`pre`,{className:`text-[10px] whitespace-pre-wrap font-sans leading-relaxed`,children:D||`(empty)`})]})]}),V.entryCount>0&&(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,B.jsxs)(`button`,{type:`button`,onClick:()=>H(i),disabled:S,className:`inline-flex items-center gap-1 rounded border border-border/50 px-3 py-1.5 text-xs hover:bg-accent transition-colors`,children:[S?(0,B.jsx)(_,{className:`h-3 w-3 animate-spin`}):(0,B.jsx)(C,{className:`h-3 w-3`}),`Review Learned Entries (`,V.entryCount,`)`]})}),u&&(0,B.jsxs)(`div`,{className:`space-y-2 border border-border rounded-lg p-3 bg-card`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsxs)(`span`,{className:`text-xs font-medium`,children:[u.filter((e,t)=>f[t]!==`drop`).length,`/`,u.length,` kept`]}),(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:U,disabled:b,className:`inline-flex items-center gap-1 rounded bg-primary px-2 py-1 text-[10px] text-primary-foreground hover:bg-primary/90 transition-colors`,children:b?r(`activity:agentRoster.applying`):`Apply Selection`}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>{d(null),m({})},className:`inline-flex items-center gap-1 rounded border border-border/50 px-2 py-1 text-[10px] hover:bg-accent transition-colors`,children:r(`activity:agentRoster.cancel`)})]})]}),(0,B.jsx)(`div`,{className:`max-h-72 overflow-y-auto space-y-2`,children:u.map((e,t)=>{let n=f[t]??`keep`,i=e.length>200?e.slice(0,200)+`…`:e;return(0,B.jsx)(`div`,{className:A(`rounded-lg border p-2 transition-colors`,n===`drop`?`border-destructive/40 bg-destructive/5 opacity-60`:`border-border`),children:(0,B.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,B.jsx)(`pre`,{className:`text-[10px] whitespace-pre-wrap flex-1 leading-relaxed font-sans`,children:i}),(0,B.jsxs)(`div`,{className:`flex gap-1 shrink-0`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:()=>m(e=>({...e,[t]:`keep`})),className:A(`px-2 py-1 text-[9px] rounded`,n===`keep`?`bg-success/20 text-success`:`bg-muted text-muted-foreground`),children:r(`activity:agentRoster.keep`)}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>m(e=>({...e,[t]:`drop`})),className:A(`px-2 py-1 text-[9px] rounded`,n===`drop`?`bg-destructive/20 text-destructive`:`bg-muted text-muted-foreground`),children:r(`activity:agentRoster.drop`)})]})]})},t)})})]})]}),(0,B.jsxs)(`div`,{className:`space-y-2 pt-4 border-t border-border`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1 text-sm font-medium`,children:[(0,B.jsx)(p,{className:`h-4 w-4 text-brand-2`}),` `,r(`activity:agentRoster.teachThisAgent`)]}),(0,B.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:r(`activity:agentRoster.describeACommandPatternOrBehavior`)}),(0,B.jsx)(`textarea`,{className:`w-full h-20 text-xs p-2 bg-card border border-border rounded resize-y`,value:h,onChange:e=>g(e.target.value),placeholder:r(`activity:agentRoster.eGAlwaysUsePnpmForThisProject`)}),(0,B.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,B.jsxs)(`button`,{type:`button`,onClick:W,disabled:!h.trim()||b,className:`inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs text-primary-foreground hover:bg-primary/90 transition-colors disabled:opacity-50`,children:[(0,B.jsx)(p,{className:`h-3.5 w-3.5`}),` `,r(`activity:agentRoster.teach`)]}),v&&(0,B.jsx)(`span`,{className:A(`text-xs`,v.ok?`text-success`:`text-destructive`),children:v.msg})]})]})]})]})]})}function ne({customStats:e,catalog:t}){let{t:n}=o(),r=(0,z.useCallback)(e=>n(`activity:rosterRoles.${e.role}.name`,{defaultValue:e.name}),[n]),a=(0,z.useCallback)(e=>n(`activity:rosterRoles.${e.role}.summary`,{defaultValue:e.summary}),[n]),[c,l]=(0,z.useState)(``),[d,p]=(0,z.useState)(null),h=(0,z.useMemo)(()=>new Set(e.filter(e=>e.exists||e.hasIdentity||e.hasConfig||e.hasKnowledge).map(e=>e.role)),[e]),g=(0,z.useMemo)(()=>{if(!c.trim())return t;let e=c.toLowerCase();return t.filter(t=>t.role.includes(e)||r(t).toLowerCase().includes(e)||a(t).toLowerCase().includes(e))},[t,c,r,a]),_=(0,z.useCallback)(t=>e.find(e=>e.role===t),[e]),v=g;return(0,B.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,B.jsx)(`div`,{className:`shrink-0 px-3 py-2 border-b border-border/50`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-border/60 bg-background px-3 py-1.5`,children:[(0,B.jsx)(f,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,B.jsx)(`input`,{type:`text`,value:c,onChange:e=>l(e.target.value),placeholder:n(`activity:agentRoster.searchPlaceholder`),className:`flex-1 bg-transparent text-xs outline-none placeholder:text-muted-foreground/50`}),c&&(0,B.jsx)(`button`,{type:`button`,onClick:()=>l(``),className:`text-muted-foreground hover:text-foreground`,children:(0,B.jsx)(m,{className:`h-3 w-3`})})]})}),(0,B.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-3`,children:[(0,B.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-2`,children:v.map(e=>{let t=_(e.role),o=h.has(e.role),c=d===e.role;return(0,B.jsxs)(`div`,{className:A(`rounded-lg border bg-card transition-colors`,c?`border-primary/40 ring-1 ring-primary/20`:`border-border/60 hover:border-primary/30`),children:[(0,B.jsxs)(`button`,{type:`button`,onClick:()=>p(c?null:e.role),className:`w-full text-left p-3`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,B.jsx)(y,{className:`h-4 w-4 shrink-0 text-primary`}),(0,B.jsx)(`span`,{className:`text-sm font-semibold truncate`,children:r(e)}),(0,B.jsxs)(`code`,{className:`text-[9px] text-muted-foreground font-mono shrink-0`,children:[`@`,e.role]})]}),(0,B.jsx)(s,{className:A(`h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform`,c&&`rotate-180`)})]}),(0,B.jsx)(`p`,{className:`text-[10px] text-muted-foreground mt-1 leading-relaxed line-clamp-2`,children:a(e)}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2 mt-1.5`,children:[(0,B.jsx)(`span`,{className:`text-[9px] text-muted-foreground tabular-nums`,children:n(`activity:agentRoster.toolsCount`,{count:e.tools})}),e.budget.maxIterations&&(0,B.jsx)(`span`,{className:`text-[9px] text-muted-foreground tabular-nums`,children:n(`activity:agentRoster.maxItShort`,{count:e.budget.maxIterations,value:e.budget.maxIterations.toLocaleString()})}),o&&(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 rounded bg-brand-2/10 px-1 py-0.5 text-[8px] text-brand-2 font-medium`,children:[(0,B.jsx)(u,{className:`h-2.5 w-2.5`}),` `,n(`activity:agentRoster.customizedBadge`)]}),t?.needsSummarization&&(0,B.jsx)(`span`,{className:`text-[9px] text-warning`,children:n(`activity:agentRoster.needsSummary`)})]})]}),c&&(0,B.jsxs)(`div`,{className:`border-t border-border/50 px-3 py-2 space-y-2`,children:[(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,B.jsxs)(`div`,{className:`rounded bg-muted/30 p-1.5`,children:[(0,B.jsx)(`span`,{className:`text-[8px] text-muted-foreground uppercase tracking-wider`,children:n(`activity:agentRoster.maxIterations`)}),(0,B.jsx)(`div`,{className:`text-xs font-mono mt-0.5`,children:e.budget.maxIterations?.toLocaleString()??`—`})]}),(0,B.jsxs)(`div`,{className:`rounded bg-muted/30 p-1.5`,children:[(0,B.jsx)(`span`,{className:`text-[8px] text-muted-foreground uppercase tracking-wider`,children:n(`activity:agentRoster.timeout`)}),(0,B.jsx)(`div`,{className:`text-xs font-mono mt-0.5`,children:e.budget.timeoutMs?`${Math.round(e.budget.timeoutMs/6e4)}m`:`—`})]}),(0,B.jsxs)(`div`,{className:`rounded bg-muted/30 p-1.5`,children:[(0,B.jsx)(`span`,{className:`text-[8px] text-muted-foreground uppercase tracking-wider`,children:n(`activity:agentRoster.maxToolCalls`)}),(0,B.jsx)(`div`,{className:`text-xs font-mono mt-0.5`,children:e.budget.maxToolCalls?.toLocaleString()??`—`})]}),(0,B.jsxs)(`div`,{className:`rounded bg-muted/30 p-1.5`,children:[(0,B.jsx)(`span`,{className:`text-[8px] text-muted-foreground uppercase tracking-wider`,children:n(`activity:agentRoster.customizedBadge`)}),(0,B.jsx)(`div`,{className:`text-xs font-mono mt-0.5`,children:n(o?`common:action.yes`:`common:action.no`)})]})]}),o&&t&&(0,B.jsxs)(`div`,{className:`rounded bg-accent/30 p-2 space-y-1`,children:[(0,B.jsx)(`span`,{className:`text-[9px] font-medium text-muted-foreground`,children:n(`activity:agentRoster.projectCustomizations`)}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-[9px]`,children:[t.hasIdentity&&(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[(0,B.jsx)(u,{className:`h-2.5 w-2.5 text-primary`}),` identity.md`]}),t.entryCount>0&&(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[(0,B.jsx)(T,{className:`h-2.5 w-2.5 text-brand-2`}),` `,n(`activity:agentRoster.learnedEntriesCount`,{count:t.entryCount})]}),t.hasConfig&&(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[(0,B.jsx)(S,{className:`h-2.5 w-2.5 text-muted-foreground`}),` config.json`]}),t.sessionCaptureCount>0&&(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[(0,B.jsx)(i,{className:`h-2.5 w-2.5 text-success`}),` `,n(`activity:agentRoster.sessionCapturesCount`,{count:t.sessionCaptureCount})]})]})]})]})]},e.role)})}),v.length===0&&(0,B.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-40 text-muted-foreground`,children:[(0,B.jsx)(f,{className:`h-8 w-8 mb-2 opacity-30`}),(0,B.jsx)(`p`,{className:`text-sm`,children:n(`activity:agentRoster.noAgentsMatch`,{query:c})})]})]}),(0,B.jsxs)(`div`,{className:`shrink-0 border-t border-border/50 px-3 py-2 text-[10px] text-muted-foreground flex items-center gap-2`,children:[(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`strong`,{children:t.length}),` `,n(`activity:agentRoster.footerRosterRoles`,{count:t.length})]}),(0,B.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,B.jsxs)(`span`,{className:`text-brand-2`,children:[(0,B.jsx)(`strong`,{children:h.size}),` `,n(`activity:agentRoster.footerCustomized`,{count:h.size})]}),(0,B.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`strong`,{children:e.reduce((e,t)=>e+t.entryCount,0)}),` `,n(`activity:agentRoster.footerTotalLearned`,{count:e.reduce((e,t)=>e+t.entryCount,0)})]})]})]})}var Z={running:{led:`bg-success`,badge:`bg-success/12 text-success`,icon:(0,B.jsx)(`span`,{className:`led text-success led-pulse`}),color:`text-success`},completed:{led:`bg-success`,badge:`bg-success/12 text-success`,icon:(0,B.jsx)(c,{className:`h-3.5 w-3.5`}),color:`text-success`},failed:{led:`bg-destructive`,badge:`bg-destructive/15 text-destructive`,icon:(0,B.jsx)(r,{className:`h-3.5 w-3.5`}),color:`text-destructive`},timeout:{led:`bg-warning`,badge:`bg-muted text-muted-foreground`,icon:(0,B.jsx)(n,{className:`h-3.5 w-3.5`}),color:`text-warning`},stopped:{led:`bg-muted-foreground`,badge:`bg-muted text-muted-foreground`,icon:(0,B.jsx)(`span`,{className:`led text-muted-foreground`}),color:`text-muted-foreground`},idle:{led:`bg-muted-foreground`,badge:`bg-muted text-muted-foreground`,icon:(0,B.jsx)(`span`,{className:`led text-muted-foreground`}),color:`text-muted-foreground`}};function Q(e){let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m ${t%60}s`;let r=Math.floor(n/60);return r<24?`${r}h ${n%60}m`:`${Math.floor(r/24)}d`}function $(e){if(e==null||!Number.isFinite(e)||e<=0)return`$0`;if(e<.01){let t=e.toFixed(5);return t===`0.00000`?`$0`:`$`+t.replace(/(\d)0+$/,`$1`).replace(/\.$/,``)}return`$`+e.toFixed(3)}function re({nowTick:e}){let{t}=o(),n=j(e=>e.agents),r=j(e=>e.leaderId),[i,a]=(0,z.useState)(null),[s,c]=(0,z.useState)(`all`),l=(0,z.useMemo)(()=>{let e=Array.from(n.values());return e.sort((e,t)=>{let n=e.status===`running`?0:1,r=t.status===`running`?0:1;return n===r?t.startedAt-e.startedAt:n-r}),s===`all`?e:s===`running`?e.filter(e=>e.status===`running`):s===`done`?e.filter(e=>e.status===`completed`):s===`failed`?e.filter(e=>e.status===`failed`||e.status===`timeout`):e},[n,s]),u=(0,z.useMemo)(()=>{let e=0,t=0,r=0;for(let i of n.values())i.status===`running`?e++:i.status===`completed`?t++:(i.status===`failed`||i.status===`timeout`)&&r++;return{running:e,completed:t,failed:r,total:n.size}},[n]),d=j(e=>e.clearFinishedAgents),f=i?l.find(e=>e.id===i):null,p=(0,z.useCallback)(e=>{let t=M.getState();e?(t.setInspectorFocusedAgentId(e),t.setInspectorTab(`agents`)):t.setInspectorTab(`fleet`),t.setInspectorOpen(!0)},[]);return l.length===0?(0,B.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-muted-foreground`,children:(0,B.jsxs)(`div`,{className:`text-center space-y-3`,children:[(0,B.jsx)(y,{className:`h-10 w-10 mx-auto opacity-30`}),(0,B.jsx)(`p`,{className:`text-sm`,children:t(`activity:agentRoster.noActiveFleetAgents`)}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground/70`,children:t(`activity:agentRoster.liveEmpty`)})]})}):(0,B.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(0,B.jsxs)(`div`,{className:A(`flex flex-col min-h-0 min-w-0 overflow-hidden`,f?`w-80 shrink-0 border-r border-border/50`:`flex-1`),children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0 px-3 py-2 border-b border-border/50`,children:[[`all`,`running`,`done`,`failed`].map(e=>(0,B.jsxs)(`button`,{type:`button`,onClick:()=>c(e),className:A(`rounded px-2 py-0.5 text-[10px] font-medium transition-colors`,s===e?`bg-primary/10 text-primary`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),children:[e===`all`&&t(`activity:agentRoster.filterAll`,{count:u.total}),e===`running`&&t(`activity:agentRoster.filterRunning`,{count:u.running}),e===`done`&&t(`activity:agentRoster.filterDone`,{count:u.completed}),e===`failed`&&t(`activity:agentRoster.filterFailed`,{count:u.failed})]},e)),(0,B.jsx)(`span`,{className:`flex-1`}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>N(`agents`),className:`inline-flex items-center gap-0.5 rounded px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-colors`,title:t(`activity:agentRoster.openAgentsPanel`),children:[(0,B.jsx)(y,{className:`h-3 w-3`}),t(`activity:agentRoster.openAgentsPanel`)]}),u.completed+u.failed>0&&(0,B.jsxs)(`button`,{type:`button`,onClick:d,className:`inline-flex items-center gap-0.5 rounded px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors`,children:[(0,B.jsx)(v,{className:`h-2.5 w-2.5`}),` `,t(`activity:agentRoster.clear`)]})]}),(0,B.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-2 space-y-1`,children:l.map(e=>(0,B.jsxs)(`button`,{type:`button`,onClick:()=>a(i===e.id?null:e.id),className:A(`w-full text-left rounded-lg border px-3 py-2 transition-colors flex items-center gap-2`,i===e.id?`border-primary/50 bg-primary/[0.06]`:`border-border/60 hover:border-primary/30 hover:bg-primary/[0.03]`),children:[(0,B.jsx)(`span`,{className:A(`led shrink-0`,Z[e.status]?.led??`bg-muted-foreground`,e.status===`running`&&`led-pulse`)}),(0,B.jsx)(`span`,{className:`text-xs font-semibold min-w-0 truncate max-w-[7rem]`,children:e.name}),e.id===r&&(0,B.jsx)(D,{className:`h-3 w-3 shrink-0 text-warning`}),e.model&&(0,B.jsx)(`span`,{className:`text-[9px] text-muted-foreground font-mono truncate max-w-[6rem] shrink-0`,children:e.model}),(0,B.jsxs)(`span`,{className:`text-[9px] text-muted-foreground tabular-nums shrink-0`,children:[e.iteration,`it · `,e.toolCalls,`t`]}),e.status===`running`&&(0,B.jsx)(`span`,{className:`text-[9px] text-primary tabular-nums shrink-0 ml-auto`,children:Q(Date.now()-e.startedAt)}),e.status!==`running`&&(0,B.jsx)(`span`,{className:A(`text-[9px] tabular-nums shrink-0 ml-auto`,Z[e.status]?.color??`text-muted-foreground`),children:e.status}),e.costUsd>0&&(0,B.jsx)(`span`,{className:`text-[9px] text-success tabular-nums font-medium shrink-0`,children:$(e.costUsd)}),e.status===`running`&&e.currentTool&&(0,B.jsxs)(`span`,{className:`text-[9px] text-primary font-mono truncate max-w-[6rem] shrink-0`,children:[`→ `,e.currentTool]})]},e.id))}),(0,B.jsxs)(`div`,{className:`shrink-0 border-t border-border/50 px-3 py-2 flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,B.jsx)(`span`,{className:`font-medium tabular-nums`,children:u.total}),` `,t(`activity:agentRoster.agentsTotal`),(0,B.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,B.jsx)(`span`,{className:`text-success tabular-nums`,children:u.running}),` running`,(0,B.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,B.jsx)(`span`,{className:`tabular-nums`,children:u.completed}),` done`,u.failed>0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,B.jsx)(`span`,{className:`text-destructive tabular-nums`,children:u.failed}),` failed`]}),(0,B.jsx)(`span`,{className:`flex-1`}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>p(),className:`inline-flex items-center gap-1 rounded border border-border/50 px-2 py-1 hover:bg-accent transition-colors`,children:[(0,B.jsx)(g,{className:`h-3 w-3`}),t(`activity:agentRoster.fleetInspector`)]})]})]}),f&&(0,B.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-y-auto p-4`,children:(0,B.jsx)(ie,{agent:f,nowTick:e})})]})}function ie({agent:e,nowTick:t}){let{t:n}=o(),r=e.status===`running`?Q(t-e.startedAt):e.completedAt?Q(e.completedAt-e.startedAt):`-`,i=Math.min(100,Math.max(0,e.ctxPct)),a=e.currentTool||e.lastTool,s=j(e=>e.leaderId);return(0,B.jsxs)(`div`,{className:`space-y-4`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,B.jsx)(`div`,{className:`flex items-center justify-center w-10 h-10 rounded-lg bg-primary/10`,children:(0,B.jsx)(y,{className:`h-5 w-5 text-primary`})}),(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`text-base font-semibold`,children:e.name}),e.id===s&&(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded border border-warning/30 bg-warning/10 px-1.5 py-0.5 text-[9px] font-medium text-warning`,children:[(0,B.jsx)(D,{className:`h-2.5 w-2.5`}),` `,n(`activity:agentRoster.leader`)]})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,B.jsx)(`span`,{className:A(`led`,Z[e.status]?.led,e.status===`running`&&`led-pulse`)}),(0,B.jsx)(`span`,{children:e.status}),e.model&&(0,B.jsxs)(`span`,{children:[`· `,e.provider,`/`,e.model]}),(0,B.jsxs)(`span`,{children:[`· `,r]})]})]})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-4 gap-2`,children:[(0,B.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,B.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:n(`activity:agentRoster.iterations`)}),(0,B.jsx)(`div`,{className:`text-lg font-mono font-semibold mt-0.5`,children:e.iteration})]}),(0,B.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,B.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:n(`activity:agentRoster.toolCalls`)}),(0,B.jsx)(`div`,{className:`text-lg font-mono font-semibold mt-0.5`,children:e.toolCalls})]}),(0,B.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,B.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:n(`activity:agentRoster.cost`)}),(0,B.jsx)(`div`,{className:`text-lg font-mono font-semibold mt-0.5 text-success`,children:$(e.costUsd)})]}),(0,B.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,B.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:n(`activity:agentRoster.context`)}),(0,B.jsxs)(`div`,{className:`text-lg font-mono font-semibold mt-0.5`,children:[i,`%`]})]})]}),e.maxContext>0&&(0,B.jsxs)(`div`,{className:`space-y-1`,children:[(0,B.jsxs)(`div`,{className:`flex justify-between text-[10px]`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:n(`activity:agentRoster.contextWindow`)}),(0,B.jsxs)(`span`,{className:A(`tabular font-medium`,i>=85?`text-destructive`:i>=70?`text-warning`:`text-success`),children:[e.ctxTokens.toLocaleString(),` / `,e.maxContext.toLocaleString(),` tokens`]})]}),(0,B.jsx)(`div`,{className:`h-2 w-full overflow-hidden rounded-full bg-muted`,children:(0,B.jsx)(`div`,{className:A(`h-full rounded-full transition-all`,i>=85?`bg-destructive`:i>=70?`bg-warning`:`bg-primary`),style:{width:`${Math.max(2,i)}%`}})})]}),a&&(0,B.jsxs)(`div`,{className:A(`flex items-center gap-2 rounded-lg border px-3 py-2`,e.status===`running`?`border-primary/30 bg-primary/[0.04]`:`border-border bg-muted/30`),children:[(0,B.jsx)(h,{className:A(`h-4 w-4`,e.status===`running`?`text-primary animate-pulse`:`text-muted-foreground`)}),(0,B.jsx)(`span`,{className:`text-sm font-mono`,children:e.currentTool??e.lastTool}),(0,B.jsx)(`span`,{className:`text-[10px] text-muted-foreground ml-auto`,children:e.currentTool?n(`activity:agentRoster.running`):`Last tool`})]}),e.error&&(0,B.jsxs)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/5 p-3`,children:[(0,B.jsx)(`span`,{className:`text-[10px] font-semibold text-destructive uppercase tracking-wider`,children:n(`activity:agentRoster.error`)}),(0,B.jsx)(`p`,{className:`text-xs text-destructive/90 mt-1`,children:e.error.message})]}),e.toolLog.length>0&&(0,B.jsxs)(`div`,{className:`space-y-1`,children:[(0,B.jsxs)(`span`,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wider`,children:[`Tool Log (`,e.toolLog.length,`)`]}),(0,B.jsx)(`div`,{className:`space-y-0.5`,children:e.toolLog.slice(0,10).map((e,t)=>(0,B.jsxs)(`div`,{className:A(`flex items-center gap-2 rounded px-2 py-1 text-[10px] font-mono`,e.ok?`bg-muted/30`:`bg-destructive/5 border border-destructive/20`),children:[(0,B.jsx)(`span`,{className:A(`led shrink-0`,e.ok?`text-success`:`text-destructive`)}),(0,B.jsx)(`span`,{className:`truncate flex-1`,children:e.name}),(0,B.jsxs)(`span`,{className:`tabular text-muted-foreground`,children:[e.durationMs,`ms`]}),!e.ok&&(0,B.jsx)(`span`,{className:`text-destructive`,children:`✗`})]},`${e.name}-${t}`))})]}),e.budgetWarning&&(0,B.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg bg-warning/10 border border-warning/25 text-xs`,children:[(0,B.jsx)(w,{className:`h-3.5 w-3.5 text-warning shrink-0`}),(0,B.jsxs)(`span`,{className:`text-warning`,children:[`Budget: `,e.budgetWarning.kind,` limit (`,e.budgetWarning.used,`/`,e.budgetWarning.limit,`)`]})]})]})}function ae(){let[e,t]=(0,z.useState)([]),[n,r]=(0,z.useState)(Y),[i,a]=(0,z.useState)(!1),[o,s]=(0,z.useState)(null),c=(0,z.useCallback)(async()=>{a(!0),s(null);try{let e=await R(`agent-roster.list`,{});e.stats&&t(e.stats),e.catalog?.length&&r(e.catalog)}catch(e){s(e instanceof Error?e.message:`Failed to load roster`)}a(!1)},[]);return(0,z.useEffect)(()=>{c()},[c]),(0,z.useEffect)(()=>{let e=null,t=k().on(`agent-roster.updated`,()=>{e&&clearTimeout(e),e=setTimeout(()=>{e=null,c()},300)});return()=>{e&&clearTimeout(e),t()}},[c]),{customStats:e,catalog:n,rosterLoading:i,rosterError:o,loadRoster:c}}function oe({customStats:e,catalog:n,onRefresh:r}){let{t:i}=o(),[a,s]=(0,z.useState)(null),[c,f]=(0,z.useState)(null),[p,m]=(0,z.useState)(``),[h,g]=(0,z.useState)(null),[_,y]=(0,z.useState)(!1),[b,x]=(0,z.useState)(null),[w,E]=(0,z.useState)(!1),[D,O]=(0,z.useState)({name:``,role:``,baseRole:`generic`,purpose:``,taskTypes:``}),j=(0,z.useMemo)(()=>a?e.find(e=>e.role===a):null,[a,e]),N=(0,z.useMemo)(()=>{let e=n.find(e=>e.role===a);return e?.systemProtected??!e?.custom},[n,a]),P=(0,z.useCallback)(async(e,t)=>{y(!0),x(null),s(e);try{let n=await R(`agent-roster.read-customization`,{role:e});m(t===`config`?`${JSON.stringify(n.config??{},null,2)}\n`:n[t]??``),f(t),g(null)}catch(e){x(e instanceof Error?e.message:i(`activity:agentRoster.loadCustomizationFailed`))}finally{y(!1)}},[]),F=(0,z.useCallback)(async e=>{y(!0),x(null),s(e);try{let t=await R(`agent-roster.read-customization`,{role:e});g(t.config??{}),f(null)}catch(e){x(e instanceof Error?e.message:i(`activity:agentRoster.loadRuntimePolicyFailed`))}finally{y(!1)}},[]),I=(0,z.useCallback)(async e=>{if(a){y(!0),x(null);try{await R(`agent-roster.update-config`,{role:a,config:e}),g(null),r()}catch(e){x(e instanceof Error?e.message:i(`activity:agentRoster.runtimePolicySaveFailed`))}finally{y(!1)}}},[r,a]),L=(0,z.useCallback)(async()=>{if(!(!a||!c)){y(!0);try{let e={identity:`agent-roster.update-identity`,learned:`agent-roster.update-learned`,config:`agent-roster.update-config`},t={role:a};if(c===`config`)try{t.config=JSON.parse(p)}catch{x(`config.json must contain valid JSON`),y(!1);return}else t.content=p;await R(e[c],t),f(null),x(null),r()}catch(e){x(e instanceof Error?e.message:i(`activity:agentRoster.saveFailed`))}y(!1)}},[a,c,p,r]),V=(0,z.useCallback)(async()=>{if(a)try{let e=await R(`agent-roster.llm-improve`,{role:a,prompt:`Improve this agent for optimal project performance`});if(!e.instruction)throw Error(`No improvement instruction generated`);let n=t.getState();n.addMessage({role:`user`,content:e.instruction}),n.setLoading(!0),k().sendMessage(e.instruction);let r=M.getState();r.setSidebarOpen(!1),r.setCurrentView(`chat`)}catch(e){x(e instanceof Error?e.message:i(`activity:agentRoster.llmImprovementFailed`))}},[a]),H=(0,z.useCallback)(async e=>{if(window.confirm(i(`activity:agentRoster.resetConfirm`,{role:e})))try{await R(`agent-roster.reset`,{role:e}),s(null),r()}catch{}},[r]),U=(0,z.useCallback)(async()=>{let e=D.taskTypes.split(/[\n,]+/).map(e=>e.trim()).filter(Boolean);y(!0),x(null);try{let t=await R(`agent-roster.create`,{name:D.name,role:D.role,baseRole:D.baseRole,purpose:D.purpose,taskTypes:e});E(!1),O({name:``,role:``,baseRole:`generic`,purpose:``,taskTypes:``}),s(t.role),r()}catch(e){x(e instanceof Error?e.message:i(`activity:agentRoster.agentCreationFailed`))}finally{y(!1)}},[D,r]),W=(0,z.useMemo)(()=>[...e].sort((e,t)=>{let n=+!!e.hasIdentity+ +(e.entryCount>0)+ +!!e.hasConfig;return+!!t.hasIdentity+ +(t.entryCount>0)+ +!!t.hasConfig-n}),[e]);return(0,B.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(0,B.jsxs)(`div`,{className:`w-80 shrink-0 border-r border-border/50 flex flex-col overflow-hidden`,children:[(0,B.jsx)(`div`,{className:`shrink-0 border-b border-border/50 px-3 py-2`,children:(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,B.jsxs)(`h3`,{className:`flex items-center gap-1.5 text-xs font-semibold`,children:[(0,B.jsx)(S,{className:`h-3.5 w-3.5`}),i(`activity:agentRoster.projectAgents`)]}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>{E(!0),s(null),g(null),x(null)},className:`rounded border border-primary/40 px-1.5 py-1 text-[9px] text-primary hover:bg-primary/10`,children:i(`activity:agentRoster.clone`)})]})}),(0,B.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-2 space-y-1`,children:[W.map(e=>(0,B.jsxs)(`button`,{type:`button`,onClick:()=>{s(e.role),g(null),f(null)},className:A(`w-full text-left rounded-lg border px-3 py-2 transition-colors`,a===e.role?`border-primary/50 bg-primary/[0.06]`:`border-border/60 hover:border-primary/30`),children:[(0,B.jsx)(`div`,{className:`text-xs font-semibold`,children:e.role}),(0,B.jsxs)(`div`,{className:`flex gap-2 mt-0.5 text-[9px] text-muted-foreground`,children:[e.hasIdentity&&(0,B.jsx)(`span`,{className:`text-primary`,children:`id`}),e.entryCount>0&&(0,B.jsxs)(`span`,{className:`text-brand-2`,children:[e.entryCount,`e`]}),e.hasConfig&&(0,B.jsx)(`span`,{children:`cfg`})]})]},e.role)),W.length===0&&(0,B.jsx)(`div`,{className:`text-[10px] text-muted-foreground text-center py-4`,children:i(`activity:agentRoster.noCustomizations`)})]})]}),(0,B.jsxs)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-y-auto p-4`,children:[w&&(0,B.jsxs)(`div`,{className:`max-w-2xl space-y-4`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{className:`text-base font-semibold`,children:i(`activity:agentRoster.createOrCloneTitle`)}),(0,B.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:i(`activity:agentRoster.createOrCloneHint`)})]}),(0,B.jsxs)(`label`,{className:`block space-y-1 text-xs`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:i(`activity:agentRoster.cloneFromRole`)}),(0,B.jsx)(`select`,{value:D.baseRole,onChange:e=>O(t=>({...t,baseRole:e.target.value})),className:`h-9 w-full rounded border border-border bg-card px-2`,children:[...n].sort((e,t)=>e.name.localeCompare(t.name)).map(e=>(0,B.jsxs)(`option`,{value:e.role,children:[e.name,` (`,e.role,`)`]},e.role))}),(0,B.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:i(`activity:agentRoster.cloneHint`)})]}),(0,B.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,B.jsxs)(`label`,{className:`space-y-1 text-xs`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:i(`activity:agentRoster.displayName`)}),(0,B.jsx)(`input`,{value:D.name,onChange:e=>O(t=>({...t,name:e.target.value})),placeholder:i(`activity:agentRoster.abc`),className:`h-9 w-full rounded border border-border bg-card px-2`})]}),(0,B.jsxs)(`label`,{className:`space-y-1 text-xs`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:i(`activity:agentRoster.roleIdOptional`)}),(0,B.jsx)(`input`,{value:D.role,onChange:e=>O(t=>({...t,role:e.target.value})),placeholder:i(`activity:agentRoster.abcGeneratedFromName`),className:`h-9 w-full rounded border border-border bg-card px-2 font-mono`})]})]}),(0,B.jsxs)(`label`,{className:`block space-y-1 text-xs`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:i(`activity:agentRoster.purpose`)}),(0,B.jsx)(`textarea`,{value:D.purpose,onChange:e=>O(t=>({...t,purpose:e.target.value})),placeholder:i(`activity:agentRoster.descriptionPlaceholder`),className:`h-24 w-full resize-y rounded border border-border bg-card p-2`})]}),(0,B.jsxs)(`label`,{className:`block space-y-1 text-xs`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:i(`activity:agentRoster.taskTypesCommaOrOnePer`)}),(0,B.jsx)(`textarea`,{value:D.taskTypes,onChange:e=>O(t=>({...t,taskTypes:e.target.value})),placeholder:i(`activity:agentRoster.taskTypesPlaceholder`),className:`h-24 w-full resize-y rounded border border-border bg-card p-2`})]}),b&&(0,B.jsx)(`p`,{className:`text-xs text-destructive`,children:b}),(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:U,disabled:_||!D.name.trim()||D.purpose.trim().length<10||!D.taskTypes.trim(),className:`rounded bg-primary px-3 py-1.5 text-xs text-primary-foreground disabled:opacity-50`,children:_?i(`activity:agentRoster.creating`):`Clone Agent`}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>E(!1),className:`rounded border border-border px-3 py-1.5 text-xs hover:bg-accent`,children:i(`activity:agentRoster.cancel`)})]})]}),!w&&!a&&(0,B.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground`,children:i(`activity:agentRoster.selectAnAgentToEditCustomizations`)}),!w&&a&&j&&(0,B.jsxs)(`div`,{className:`space-y-4 max-w-2xl`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsx)(`h3`,{className:`text-base font-semibold`,children:a}),(0,B.jsxs)(`div`,{className:`flex gap-1`,children:[(0,B.jsxs)(`button`,{type:`button`,onClick:V,className:`inline-flex items-center gap-1 rounded border border-border/50 px-2 py-1 text-[10px] hover:bg-accent transition-colors`,children:[(0,B.jsx)(l,{className:`h-3 w-3 text-brand-2`}),` `,i(`activity:agentRoster.llmImprove`)]}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>H(a),className:`inline-flex items-center gap-1 rounded border border-destructive/30 px-2 py-1 text-[10px] text-destructive hover:bg-destructive/10 transition-colors`,children:[(0,B.jsx)(v,{className:`h-3 w-3`}),` `,i(`activity:agentRoster.reset`)]})]})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[j.hasIdentity&&(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-primary/10 px-2 py-1 text-[10px] text-primary`,children:[(0,B.jsx)(u,{className:`h-3 w-3`}),` identity.md`]}),j.hasConfig&&(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-muted px-2 py-1 text-[10px] text-muted-foreground`,children:[(0,B.jsx)(S,{className:`h-3 w-3`}),` config.json`]}),j.hasKnowledge&&(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-muted px-2 py-1 text-[10px] text-muted-foreground`,children:[(0,B.jsx)(T,{className:`h-3 w-3`}),` knowledge.json`]}),j.entryCount>0&&(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-brand-2/10 px-2 py-1 text-[10px] text-brand-2`,children:[(0,B.jsx)(C,{className:`h-3 w-3`}),` `,j.entryCount,` learned entries`]})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,B.jsxs)(`button`,{type:`button`,onClick:()=>P(a,`identity`),className:`inline-flex items-center gap-1 rounded border border-border/50 px-3 py-1.5 text-xs hover:bg-accent transition-colors`,children:[(0,B.jsx)(u,{className:`h-3.5 w-3.5`}),` `,i(`activity:agentRoster.editIdentityMd`)]}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>P(a,`learned`),className:`inline-flex items-center gap-1 rounded border border-border/50 px-3 py-1.5 text-xs hover:bg-accent transition-colors`,children:[(0,B.jsx)(C,{className:`h-3.5 w-3.5`}),` `,i(`activity:agentRoster.editLearnedMd`)]}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>F(a),className:`inline-flex items-center gap-1 rounded border border-primary/40 bg-primary/5 px-3 py-1.5 text-xs text-primary hover:bg-primary/10 transition-colors`,children:[(0,B.jsx)(d,{className:`h-3.5 w-3.5`}),` `,i(`activity:agentRoster.runtimePolicy`)]}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>P(a,`config`),className:`inline-flex items-center gap-1 rounded border border-border/50 px-3 py-1.5 text-xs hover:bg-accent transition-colors`,children:[(0,B.jsx)(S,{className:`h-3.5 w-3.5`}),` `,i(`activity:agentRoster.editConfigJson`)]})]}),b&&(0,B.jsx)(`p`,{className:`text-xs text-destructive`,children:b}),h&&(0,B.jsx)(q,{initialConfig:h,systemProtected:N,saving:_,onSave:I,onCancel:()=>g(null)},a),c&&(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsxs)(`span`,{className:`text-xs font-medium`,children:[c,`.md / `,c,`.json`]}),(0,B.jsxs)(`div`,{className:`flex gap-1`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:L,disabled:_,className:`inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs text-primary-foreground hover:bg-primary/90 transition-colors disabled:opacity-50`,children:i(_?`activity:agentRoster.saving`:`common:action.save`)}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>f(null),className:`inline-flex items-center gap-1 rounded border border-border/50 px-3 py-1.5 text-xs hover:bg-accent transition-colors`,children:i(`activity:agentRoster.cancel`)})]})]}),(0,B.jsx)(`textarea`,{className:`w-full h-48 font-mono text-xs p-2 bg-card border border-border rounded resize-y`,value:p,onChange:e=>m(e.target.value),placeholder:c===`config`?`{ "tools": [...], "budget": {...} }`:`# Project identity for ${a}\n\nDescribe this agent's role…`})]})]})]})]})}function se({className:e}){let{t}=o(),[n,r]=(0,z.useState)(`live`),[i,s]=(0,z.useState)(Date.now()),{customStats:c,catalog:l,rosterLoading:u,rosterError:d,loadRoster:f}=ae();return(0,z.useEffect)(()=>{let e=setInterval(()=>{document.hidden||s(Date.now())},2e3);return()=>clearInterval(e)},[]),(0,B.jsxs)(`div`,{className:A(`flex h-full min-h-0 min-w-0 w-full flex-col overflow-hidden`,e),children:[(0,B.jsx)(X,{customStats:c,rosterLoading:u,onRefresh:f}),(0,B.jsx)(ee,{activeTab:n,onTabChange:r}),(0,B.jsxs)(`div`,{className:`flex min-h-0 min-w-0 w-full flex-1 overflow-hidden bg-background/50`,children:[d&&(0,B.jsxs)(`div`,{className:`flex items-center justify-center w-full text-destructive text-xs gap-2`,children:[(0,B.jsx)(a,{className:`h-4 w-4`}),d,(0,B.jsx)(`button`,{type:`button`,onClick:f,className:`underline`,children:t(`activity:agentRoster.retry`)})]}),n===`live`&&(0,B.jsx)(re,{nowTick:i}),n===`catalog`&&(0,B.jsx)(ne,{customStats:c,catalog:l}),n===`learning`&&(0,B.jsx)(te,{customStats:c,onRefresh:f}),n===`customize`&&(0,B.jsx)(oe,{customStats:c,catalog:l,onRefresh:f})]})]})}export{se as AgentRosterView};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Nt as t,Oa as n,Ot as r,Pa as i,_i as a,bi as o,ir as s,kt as c,lt as l,qn as u,ta as d,yt as f,za as p}from"./vendor-BuarzSSb.js";import"./i18n-B0hsnanh.js";import{t as m}from"./ws-client-DqFoX4jJ.js";import{P as h}from"./stores-BptlyD_v.js";import{C as g,S as _,c as v}from"./index-DHdO0CRE.js";var y=e(p(),1),b=l();function x(e){let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m ${t%60}s`;let r=Math.floor(n/60);return r<24?`${r}h ${n%60}m`:`${Math.floor(r/24)}d`}function S(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function C(e){return e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function w(e){return new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function T(e){return e.includes(`error`)||e.includes(`fail`)?`text-destructive`:e.includes(`warn`)?`text-warning`:e.includes(`success`)||e.includes(`complete`)?`text-success`:`text-muted-foreground`}function E({icon:e,label:t,value:n,sub:r,color:i=`text-muted-foreground`}){return(0,b.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsx)(`div`,{className:`mt-0.5 ${i}`,children:e}),(0,b.jsxs)(`div`,{className:`min-w-0`,children:[(0,b.jsx)(`div`,{className:`text-2xl font-semibold tabular-nums text-foreground`,children:n}),(0,b.jsx)(`div`,{className:`mt-0.5 text-xs text-muted-foreground`,children:t}),r?(0,b.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground/70`,children:r}):null]})]})}function D(){let{t:e}=i(),[l,p]=(0,y.useState)(null),[D,O]=(0,y.useState)([]),[k,A]=(0,y.useState)([]),[j,M]=(0,y.useState)(null),[N,P]=(0,y.useState)(!0),[F,I]=(0,y.useState)(!1),L=(0,y.useRef)(null),R=(0,y.useCallback)(async()=>{try{let e=await fetch(`/api/analytics/summary`);if(e.ok){let t=await e.json();p(t)}}catch{}},[]),z=(0,y.useCallback)(async()=>{try{let e=await fetch(`/api/analytics?limit=50`);if(e.ok){let t=await e.json();O(t.events)}}catch{}},[]),B=(0,y.useCallback)(async()=>{try{let e=await fetch(`/api/sessions`);if(e.ok){let t=await e.json();A(t)}}catch{}},[]),V=(0,y.useCallback)(async()=>{if(F)return;I(!0);let e=null,t=null;try{let n=m(h.getState().wsUrl);L.current=n,t=n.on(`stats.get`,n=>{let r=n.payload;M(r),I(!1),t?.(),e!==null&&clearTimeout(e)}),n.getStats({echoToChat:!1}),e=setTimeout(()=>{t?.(),I(!1)},8e3)}catch{t?.(),e!==null&&clearTimeout(e),I(!1)}},[F]);(0,y.useEffect)(()=>{let e=()=>{Promise.all([R(),z(),B(),V()]).finally(()=>P(!1))};e();let t=setInterval(e,1e4);return()=>clearInterval(t)},[R,z,B,V]);let{totalAgents:H,activeAgents:U,totalToolCalls:W,totalIterations:G}=(0,y.useMemo)(()=>{let e=0,t=0,n=0,r=0;for(let i of k)for(let a of i.agents)e++,a.status===`running`&&t++,n+=a.toolCalls,r+=a.iterations;return{totalAgents:e,activeAgents:t,totalToolCalls:n,totalIterations:r}},[k]),K=(0,y.useMemo)(()=>l?Object.entries(l.categoryBreakdown).sort((e,t)=>t[1]-e[1]).slice(0,8):[],[l]),q=(0,y.useMemo)(()=>l?Object.entries(l.eventBreakdown).sort((e,t)=>t[1]-e[1]).slice(0,10):[],[l]),J=(0,y.useMemo)(()=>{if(!l)return 0;let e=0;for(let[t,n]of Object.entries(l.eventBreakdown))t.toLowerCase().includes(`error`)&&(e+=n);return e},[l]),Y=(0,y.useMemo)(()=>{if(!l)return 0;let e=0;for(let[t,n]of Object.entries(l.eventBreakdown))t.toLowerCase().includes(`warn`)&&(e+=n);return e},[l]),X=g((0,y.useMemo)(()=>[...D].reverse(),[D]),20);return N?(0,b.jsx)(`div`,{className:`flex h-full min-h-0 items-center justify-center bg-[hsl(var(--surface-2)/0.45)] p-4`,children:(0,b.jsxs)(`div`,{className:`ws-surface flex items-center gap-2 rounded-xl px-4 py-3 text-sm text-muted-foreground`,children:[(0,b.jsx)(s,{className:`h-4 w-4 animate-spin text-primary`}),e(`activity:analytics.loading`)]})}):(0,b.jsx)(`div`,{ref:v(`analytics`),className:`h-full min-h-0 min-w-0 overflow-y-auto overscroll-contain bg-[hsl(var(--surface-2)/0.45)] p-4 sm:p-6`,children:(0,b.jsxs)(`div`,{className:`mx-auto flex w-full max-w-7xl flex-col gap-5`,children:[(0,b.jsx)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:(0,b.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,b.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,b.jsx)(d,{className:`h-4 w-4 text-primary`}),(0,b.jsx)(`h1`,{className:`truncate text-base font-semibold`,children:e(`activity:analytics.heading`)})]}),(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`activity:analytics.autoRefresh`)})]})}),(0,b.jsxs)(`div`,{className:`min-w-0 space-y-5`,children:[(0,b.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3`,children:[(0,b.jsx)(E,{icon:(0,b.jsx)(n,{className:`h-4 w-4`}),label:e(`activity:analytics.liveSessions`),value:k.length,color:`text-primary`}),(0,b.jsx)(E,{icon:(0,b.jsx)(f,{className:`h-4 w-4`}),label:e(`activity:analytics.agents`),value:`${U}/${H}`,sub:U>0?e(`activity:analytics.agentsActive`,{count:U}):void 0,color:`text-success`}),(0,b.jsx)(E,{icon:(0,b.jsx)(u,{className:`h-4 w-4`}),label:e(`activity:analytics.totalEvents`),value:l?.totalEvents??0,sub:e(`activity:analytics.categoriesSub`,{count:l?.uniqueCategories??0}),color:`text-warning`}),(0,b.jsx)(E,{icon:(0,b.jsx)(t,{className:`h-4 w-4`}),label:e(`activity:analytics.toolCalls`),value:W,sub:e(`activity:analytics.iterationsSub`,{count:G}),color:`text-success`}),(0,b.jsx)(E,{icon:(0,b.jsx)(a,{className:`h-4 w-4`}),label:e(`activity:analytics.sessionCost`),value:j?C(j.cost):`—`,sub:j?e(`activity:analytics.tokensSub`,{input:S(j.usage.input),output:S(j.usage.output)}):void 0,color:`text-primary`}),(0,b.jsx)(E,{icon:(0,b.jsx)(o,{className:`h-4 w-4`}),label:e(`activity:analytics.sessionDuration`),value:j?x(j.elapsedMs):`—`,sub:j?e(`activity:analytics.messagesSub`,{count:j.messages}):void 0,color:`text-muted-foreground`})]}),(0,b.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4`,children:[(0,b.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-xs font-semibold uppercase text-muted-foreground`,children:[(0,b.jsx)(c,{className:`h-3.5 w-3.5 text-primary`}),e(`activity:analytics.eventsByCategory`)]}),K.length===0?(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`activity:analytics.noEvents`)}):(0,b.jsx)(`div`,{className:`space-y-1.5`,children:K.map(([e,t])=>{let n=K[0]?.[1]??1,r=Math.round(t/n*100);return(0,b.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,7rem)_minmax(0,1fr)_2.5rem] items-center gap-2 text-xs`,children:[(0,b.jsx)(`span`,{className:`min-w-0 truncate text-foreground`,children:e}),(0,b.jsx)(`div`,{className:`h-4 overflow-hidden rounded-full bg-muted`,children:(0,b.jsx)(`div`,{className:`h-full rounded-full bg-primary/70 transition-all`,style:{width:`${Math.max(r,4)}%`}})}),(0,b.jsx)(`span`,{className:`text-right tabular-nums text-muted-foreground`,children:t})]},e)})})]}),(0,b.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-xs font-semibold uppercase text-muted-foreground`,children:[(0,b.jsx)(d,{className:`h-3.5 w-3.5 text-warning`}),e(`activity:analytics.topEvents`)]}),q.length===0?(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`activity:analytics.noEvents`)}):(0,b.jsx)(`div`,{className:`space-y-1.5`,children:q.map(([e,t])=>{let n=q[0]?.[1]??1,r=Math.round(t/n*100);return(0,b.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,9rem)_minmax(0,1fr)_2.5rem] items-center gap-2 text-xs`,children:[(0,b.jsx)(`span`,{className:`min-w-0 truncate ${T(e)}`,children:e}),(0,b.jsx)(`div`,{className:`h-4 overflow-hidden rounded-full bg-muted`,children:(0,b.jsx)(`div`,{className:`h-full rounded-full bg-warning/70 transition-all`,style:{width:`${Math.max(r,4)}%`}})}),(0,b.jsx)(`span`,{className:`text-right tabular-nums text-muted-foreground`,children:t})]},e)})})]})]}),(0,b.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4`,children:[(0,b.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-xs font-semibold uppercase text-muted-foreground`,children:[(0,b.jsx)(a,{className:`h-3.5 w-3.5 text-primary`}),e(`activity:analytics.activeSessionUsage`)]}),j?(0,b.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 text-xs`,children:[(0,b.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.provider`)}),(0,b.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-foreground`,children:j.provider})]}),(0,b.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.model`)}),(0,b.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-foreground`,children:j.model})]}),(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.inputTokens`)}),(0,b.jsx)(`p`,{className:`mt-0.5 tabular-nums text-foreground`,children:S(j.usage.input)})]}),(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.outputTokens`)}),(0,b.jsx)(`p`,{className:`mt-0.5 tabular-nums text-foreground`,children:S(j.usage.output)})]}),(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.cacheRatio`)}),(0,b.jsxs)(`p`,{className:`mt-0.5 tabular-nums text-foreground`,children:[(j.cache.ratio*100).toFixed(1),`%`]})]}),(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.filesRead`)}),(0,b.jsx)(`p`,{className:`mt-0.5 tabular-nums text-foreground`,children:j.readFiles})]})]}):(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`activity:analytics.noSession`)})]}),(0,b.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-xs font-semibold uppercase text-muted-foreground`,children:[(0,b.jsx)(r,{className:`h-3.5 w-3.5 text-warning`}),e(`activity:analytics.healthErrors`)]}),(0,b.jsx)(`div`,{className:`space-y-2 text-xs`,children:l?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`flex justify-between`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.errorEvents`)}),(0,b.jsx)(`span`,{className:`tabular-nums text-destructive`,children:J})]}),(0,b.jsxs)(`div`,{className:`flex justify-between`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.warningEvents`)}),(0,b.jsx)(`span`,{className:`tabular-nums text-warning`,children:Y})]}),(0,b.jsxs)(`div`,{className:`flex justify-between`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.cacheHitRate`)}),(0,b.jsx)(`span`,{className:`tabular-nums text-success`,children:j?`${(j.cache.ratio*100).toFixed(1)}%`:`—`})]}),(0,b.jsxs)(`div`,{className:`flex justify-between`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.totalCategories`)}),(0,b.jsx)(`span`,{className:`tabular-nums text-foreground`,children:l.uniqueCategories})]})]}):(0,b.jsx)(`p`,{className:`text-muted-foreground`,children:e(`activity:analytics.waitingData`)})})]})]}),(0,b.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-xs font-semibold uppercase text-muted-foreground`,children:[(0,b.jsx)(n,{className:`h-3.5 w-3.5 text-primary`}),e(`activity:analytics.recentEvents`)]}),D.length===0?(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`activity:analytics.noRecentEvents`)}):(0,b.jsx)(`div`,{className:`max-h-64 space-y-1 overflow-y-auto`,children:X.pageItems.map((e,t)=>(0,b.jsxs)(`div`,{className:`grid grid-cols-[4rem_minmax(0,7rem)_minmax(0,6rem)_minmax(0,1fr)] items-start gap-2 rounded px-2 py-1 text-xs hover:bg-muted/60`,children:[(0,b.jsx)(`span`,{className:`tabular-nums text-muted-foreground/70`,children:w(e.timestamp)}),(0,b.jsx)(`span`,{className:`min-w-0 truncate ${T(e.event)}`,children:e.event}),(0,b.jsx)(`span`,{className:`min-w-0 truncate text-muted-foreground`,children:e.category}),(0,b.jsx)(`span`,{className:`min-w-0 truncate text-foreground/80`,children:e.label??e.sessionId??``})]},`${e.timestamp}-${t}`))}),(0,b.jsx)(_,{page:X.page,pageSize:X.pageSize,totalItems:X.totalItems,onPageChange:X.setPage,compact:!0,itemLabel:`events`,className:`mt-3 rounded-lg border`})]})]})]})})}export{D as AnalyticsDashboard};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Nt as t,Oa as n,Ot as r,Pa as i,_i as a,bi as o,ir as s,kt as c,lt as l,qn as u,ta as d,yt as f,za as p}from"./vendor-BuarzSSb.js";import"./i18n-COgumVF5.js";import{t as m}from"./ws-client-TTMa0XaT.js";import{I as h}from"./stores-ChEnUmic.js";import{b as g,c as _,x as v}from"./index-CtpViiZy.js";var y=e(p(),1),b=l();function x(e){let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m ${t%60}s`;let r=Math.floor(n/60);return r<24?`${r}h ${n%60}m`:`${Math.floor(r/24)}d`}function S(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function C(e){return e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function w(e){return new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function T(e){return e.includes(`error`)||e.includes(`fail`)?`text-destructive`:e.includes(`warn`)?`text-warning`:e.includes(`success`)||e.includes(`complete`)?`text-success`:`text-muted-foreground`}function E({icon:e,label:t,value:n,sub:r,color:i=`text-muted-foreground`}){return(0,b.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsx)(`div`,{className:`mt-0.5 ${i}`,children:e}),(0,b.jsxs)(`div`,{className:`min-w-0`,children:[(0,b.jsx)(`div`,{className:`text-2xl font-semibold tabular-nums text-foreground`,children:n}),(0,b.jsx)(`div`,{className:`mt-0.5 text-xs text-muted-foreground`,children:t}),r?(0,b.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground/70`,children:r}):null]})]})}function D(){let{t:e}=i(),[l,p]=(0,y.useState)(null),[D,O]=(0,y.useState)([]),[k,A]=(0,y.useState)([]),[j,M]=(0,y.useState)(null),[N,P]=(0,y.useState)(!0),[F,I]=(0,y.useState)(!1),L=(0,y.useRef)(null),R=(0,y.useCallback)(async()=>{try{let e=await fetch(`/api/analytics/summary`);if(e.ok){let t=await e.json();p(t)}}catch{}},[]),z=(0,y.useCallback)(async()=>{try{let e=await fetch(`/api/analytics?limit=50`);if(e.ok){let t=await e.json();O(t.events)}}catch{}},[]),B=(0,y.useCallback)(async()=>{try{let e=await fetch(`/api/sessions`);if(e.ok){let t=await e.json();A(t)}}catch{}},[]),V=(0,y.useCallback)(async()=>{if(F)return;I(!0);let e=null,t=null;try{let n=m(h.getState().wsUrl);L.current=n,t=n.on(`stats.get`,n=>{let r=n.payload;M(r),I(!1),t?.(),e!==null&&clearTimeout(e)}),n.getStats({echoToChat:!1}),e=setTimeout(()=>{t?.(),I(!1)},8e3)}catch{t?.(),e!==null&&clearTimeout(e),I(!1)}},[F]);(0,y.useEffect)(()=>{let e=()=>{Promise.all([R(),z(),B(),V()]).finally(()=>P(!1))};e();let t=setInterval(e,1e4);return()=>clearInterval(t)},[R,z,B,V]);let{totalAgents:H,activeAgents:U,totalToolCalls:W,totalIterations:G}=(0,y.useMemo)(()=>{let e=0,t=0,n=0,r=0;for(let i of k)for(let a of i.agents)e++,a.status===`running`&&t++,n+=a.toolCalls,r+=a.iterations;return{totalAgents:e,activeAgents:t,totalToolCalls:n,totalIterations:r}},[k]),K=(0,y.useMemo)(()=>l?Object.entries(l.categoryBreakdown).sort((e,t)=>t[1]-e[1]).slice(0,8):[],[l]),q=(0,y.useMemo)(()=>l?Object.entries(l.eventBreakdown).sort((e,t)=>t[1]-e[1]).slice(0,10):[],[l]),J=(0,y.useMemo)(()=>{if(!l)return 0;let e=0;for(let[t,n]of Object.entries(l.eventBreakdown))t.toLowerCase().includes(`error`)&&(e+=n);return e},[l]),Y=(0,y.useMemo)(()=>{if(!l)return 0;let e=0;for(let[t,n]of Object.entries(l.eventBreakdown))t.toLowerCase().includes(`warn`)&&(e+=n);return e},[l]),X=v((0,y.useMemo)(()=>[...D].reverse(),[D]),20);return N?(0,b.jsx)(`div`,{className:`flex h-full min-h-0 items-center justify-center bg-[hsl(var(--surface-2)/0.45)] p-4`,children:(0,b.jsxs)(`div`,{className:`ws-surface flex items-center gap-2 rounded-xl px-4 py-3 text-sm text-muted-foreground`,children:[(0,b.jsx)(s,{className:`h-4 w-4 animate-spin text-primary`}),e(`activity:analytics.loading`)]})}):(0,b.jsx)(`div`,{ref:_(`analytics`),className:`h-full min-h-0 min-w-0 overflow-y-auto overscroll-contain bg-[hsl(var(--surface-2)/0.45)] p-4 sm:p-6`,children:(0,b.jsxs)(`div`,{className:`mx-auto flex w-full max-w-7xl flex-col gap-5`,children:[(0,b.jsx)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:(0,b.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,b.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,b.jsx)(d,{className:`h-4 w-4 text-primary`}),(0,b.jsx)(`h1`,{className:`truncate text-base font-semibold`,children:e(`activity:analytics.heading`)})]}),(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`activity:analytics.autoRefresh`)})]})}),(0,b.jsxs)(`div`,{className:`min-w-0 space-y-5`,children:[(0,b.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3`,children:[(0,b.jsx)(E,{icon:(0,b.jsx)(n,{className:`h-4 w-4`}),label:e(`activity:analytics.liveSessions`),value:k.length,color:`text-primary`}),(0,b.jsx)(E,{icon:(0,b.jsx)(f,{className:`h-4 w-4`}),label:e(`activity:analytics.agents`),value:`${U}/${H}`,sub:U>0?e(`activity:analytics.agentsActive`,{count:U}):void 0,color:`text-success`}),(0,b.jsx)(E,{icon:(0,b.jsx)(u,{className:`h-4 w-4`}),label:e(`activity:analytics.totalEvents`),value:l?.totalEvents??0,sub:e(`activity:analytics.categoriesSub`,{count:l?.uniqueCategories??0}),color:`text-warning`}),(0,b.jsx)(E,{icon:(0,b.jsx)(t,{className:`h-4 w-4`}),label:e(`activity:analytics.toolCalls`),value:W,sub:e(`activity:analytics.iterationsSub`,{count:G}),color:`text-success`}),(0,b.jsx)(E,{icon:(0,b.jsx)(a,{className:`h-4 w-4`}),label:e(`activity:analytics.sessionCost`),value:j?C(j.cost):`—`,sub:j?e(`activity:analytics.tokensSub`,{input:S(j.usage.input),output:S(j.usage.output)}):void 0,color:`text-primary`}),(0,b.jsx)(E,{icon:(0,b.jsx)(o,{className:`h-4 w-4`}),label:e(`activity:analytics.sessionDuration`),value:j?x(j.elapsedMs):`—`,sub:j?e(`activity:analytics.messagesSub`,{count:j.messages}):void 0,color:`text-muted-foreground`})]}),(0,b.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4`,children:[(0,b.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-xs font-semibold uppercase text-muted-foreground`,children:[(0,b.jsx)(c,{className:`h-3.5 w-3.5 text-primary`}),e(`activity:analytics.eventsByCategory`)]}),K.length===0?(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`activity:analytics.noEvents`)}):(0,b.jsx)(`div`,{className:`space-y-1.5`,children:K.map(([e,t])=>{let n=K[0]?.[1]??1,r=Math.round(t/n*100);return(0,b.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,7rem)_minmax(0,1fr)_2.5rem] items-center gap-2 text-xs`,children:[(0,b.jsx)(`span`,{className:`min-w-0 truncate text-foreground`,children:e}),(0,b.jsx)(`div`,{className:`h-4 overflow-hidden rounded-full bg-muted`,children:(0,b.jsx)(`div`,{className:`h-full rounded-full bg-primary/70 transition-all`,style:{width:`${Math.max(r,4)}%`}})}),(0,b.jsx)(`span`,{className:`text-right tabular-nums text-muted-foreground`,children:t})]},e)})})]}),(0,b.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-xs font-semibold uppercase text-muted-foreground`,children:[(0,b.jsx)(d,{className:`h-3.5 w-3.5 text-warning`}),e(`activity:analytics.topEvents`)]}),q.length===0?(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`activity:analytics.noEvents`)}):(0,b.jsx)(`div`,{className:`space-y-1.5`,children:q.map(([e,t])=>{let n=q[0]?.[1]??1,r=Math.round(t/n*100);return(0,b.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,9rem)_minmax(0,1fr)_2.5rem] items-center gap-2 text-xs`,children:[(0,b.jsx)(`span`,{className:`min-w-0 truncate ${T(e)}`,children:e}),(0,b.jsx)(`div`,{className:`h-4 overflow-hidden rounded-full bg-muted`,children:(0,b.jsx)(`div`,{className:`h-full rounded-full bg-warning/70 transition-all`,style:{width:`${Math.max(r,4)}%`}})}),(0,b.jsx)(`span`,{className:`text-right tabular-nums text-muted-foreground`,children:t})]},e)})})]})]}),(0,b.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4`,children:[(0,b.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-xs font-semibold uppercase text-muted-foreground`,children:[(0,b.jsx)(a,{className:`h-3.5 w-3.5 text-primary`}),e(`activity:analytics.activeSessionUsage`)]}),j?(0,b.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 text-xs`,children:[(0,b.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.provider`)}),(0,b.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-foreground`,children:j.provider})]}),(0,b.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.model`)}),(0,b.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-foreground`,children:j.model})]}),(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.inputTokens`)}),(0,b.jsx)(`p`,{className:`mt-0.5 tabular-nums text-foreground`,children:S(j.usage.input)})]}),(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.outputTokens`)}),(0,b.jsx)(`p`,{className:`mt-0.5 tabular-nums text-foreground`,children:S(j.usage.output)})]}),(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.cacheRatio`)}),(0,b.jsxs)(`p`,{className:`mt-0.5 tabular-nums text-foreground`,children:[(j.cache.ratio*100).toFixed(1),`%`]})]}),(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.filesRead`)}),(0,b.jsx)(`p`,{className:`mt-0.5 tabular-nums text-foreground`,children:j.readFiles})]})]}):(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`activity:analytics.noSession`)})]}),(0,b.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-xs font-semibold uppercase text-muted-foreground`,children:[(0,b.jsx)(r,{className:`h-3.5 w-3.5 text-warning`}),e(`activity:analytics.healthErrors`)]}),(0,b.jsx)(`div`,{className:`space-y-2 text-xs`,children:l?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`flex justify-between`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.errorEvents`)}),(0,b.jsx)(`span`,{className:`tabular-nums text-destructive`,children:J})]}),(0,b.jsxs)(`div`,{className:`flex justify-between`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.warningEvents`)}),(0,b.jsx)(`span`,{className:`tabular-nums text-warning`,children:Y})]}),(0,b.jsxs)(`div`,{className:`flex justify-between`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.cacheHitRate`)}),(0,b.jsx)(`span`,{className:`tabular-nums text-success`,children:j?`${(j.cache.ratio*100).toFixed(1)}%`:`—`})]}),(0,b.jsxs)(`div`,{className:`flex justify-between`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.totalCategories`)}),(0,b.jsx)(`span`,{className:`tabular-nums text-foreground`,children:l.uniqueCategories})]})]}):(0,b.jsx)(`p`,{className:`text-muted-foreground`,children:e(`activity:analytics.waitingData`)})})]})]}),(0,b.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-xs font-semibold uppercase text-muted-foreground`,children:[(0,b.jsx)(n,{className:`h-3.5 w-3.5 text-primary`}),e(`activity:analytics.recentEvents`)]}),D.length===0?(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`activity:analytics.noRecentEvents`)}):(0,b.jsx)(`div`,{className:`max-h-64 space-y-1 overflow-y-auto`,children:X.pageItems.map((e,t)=>(0,b.jsxs)(`div`,{className:`grid grid-cols-[4rem_minmax(0,7rem)_minmax(0,6rem)_minmax(0,1fr)] items-start gap-2 rounded px-2 py-1 text-xs hover:bg-muted/60`,children:[(0,b.jsx)(`span`,{className:`tabular-nums text-muted-foreground/70`,children:w(e.timestamp)}),(0,b.jsx)(`span`,{className:`min-w-0 truncate ${T(e.event)}`,children:e.event}),(0,b.jsx)(`span`,{className:`min-w-0 truncate text-muted-foreground`,children:e.category}),(0,b.jsx)(`span`,{className:`min-w-0 truncate text-foreground/80`,children:e.label??e.sessionId??``})]},`${e.timestamp}-${t}`))}),(0,b.jsx)(g,{page:X.page,pageSize:X.pageSize,totalItems:X.totalItems,onPageChange:X.setPage,compact:!0,itemLabel:`events`,className:`mt-3 rounded-lg border`})]})]})]})})}export{D as AnalyticsDashboard};
@@ -0,0 +1,3 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Cn as t,Ft as n,Pa as r,Rr as i,Tt as a,Xt as o,an as s,dt as c,gi as l,jt as u,lt as d,vn as f,za as p}from"./vendor-BuarzSSb.js";import"./i18n-COgumVF5.js";import{t as m}from"./useWebSocket-_gk4MRJz.js";import{t as h}from"./utils-B-9lSDIn.js";import{a as g,i as _,n as v,o as y,r as b,t as x}from"./dialog-ftgTihmF.js";import{t as S}from"./button-Dcy288Mc.js";import{t as C}from"./input-fo9-BPBC.js";import{b as w,x as T}from"./index-CtpViiZy.js";import{g as E,i as D,r as O,y as k}from"./shared-KAzksK0C.js";var A=e(p(),1),j=d();function M(e){if(!Array.isArray(e))return;let t=[...new Set(e.filter(e=>typeof e==`string`).map(e=>e.trim()).filter(Boolean))];return t.length>0?t:void 0}function N(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e,n={roles:M(t.roles),taskTypes:M(t.taskTypes),modes:M(t.modes)};return n.roles||n.taskTypes||n.modes?n:void 0}function ee(e){let t=e.trim().replace(/^```(?:json)?\s*/i,``).replace(/\s*```$/,``),n=JSON.parse(t);if(!Array.isArray(n))throw Error(`Input must be a JSON array.`);let r=[],i=0;for(let e of n){if(!e||typeof e!=`object`||Array.isArray(e)){i++;continue}let t=e,n=typeof t.text==`string`?t.text.trim():``,a=N(t.audience);if(!n||!a){i++;continue}let o=typeof t.kind==`string`&&D.some(e=>e===t.kind)?t.kind:void 0,s=M(t.tags);r.push({text:n,audience:a,kind:o,tags:s,importance:typeof t.importance==`number`?t.importance:void 0,confidence:typeof t.confidence==`number`?t.confidence:void 0})}return{entries:r,skipped:i}}function P(e,t){if(!t)return!0;let n=e.audience;return[e.text,e.kind,e.status,...n?.roles??[],...n?.taskTypes??[],...n?.modes??[]].join(` `).toLocaleLowerCase().includes(t.toLocaleLowerCase())}function F(e,t){return[...new Set(e.flatMap(e=>e.audience?.[t]??[]).filter(e=>e.length>0))].sort((e,t)=>e.localeCompare(t))}function I(){let{t:e}=r(),o=m(),[d,p]=(0,A.useState)([]),[D,O]=(0,A.useState)(!0),[k,M]=(0,A.useState)(null),[N,I]=(0,A.useState)(``),[z,B]=(0,A.useState)(!1),[ae,V]=(0,A.useState)(!1),[H,U]=(0,A.useState)(null),[W,G]=(0,A.useState)(!1),[K,q]=(0,A.useState)(!1),J=(0,A.useRef)(null),Y=(0,A.useCallback)(()=>{O(!0),M(null),o.listSageMemories({echoToChat:!1})},[o.listSageMemories]);(0,A.useEffect)(()=>{let t=o.client,n=t.on(`memory.sage.list`,e=>{let t=e.payload;t.error?M({tone:`error`,text:t.error}):p(t.memories??[]),O(!1)}),r=t.on(`memory.sage.remember`,e=>{let t=e.payload;if(G(!1),t.error){M({tone:`error`,text:t.error});return}t.memory&&(p(e=>[t.memory,...e.filter(e=>e.id!==t.memory.id)]),B(!1))}),i=t.on(`memory.sage.update`,t=>{let n=t.payload;n.error?M({tone:`error`,text:n.error}):n.memory&&(p(e=>e.map(e=>e.id===n.memory.id?n.memory:e)),n.memory.audience||M({tone:`success`,text:e(`activity:audienceMem.scopeRemoved`)}))}),a=t.on(`memory.sage.delete`,t=>{let n=t.payload,r=J.current;n.success&&r?(p(e=>e.filter(e=>e.id!==r)),M({tone:`success`,text:e(`activity:audienceMem.deleted`)}),U(null),q(!1),J.current=null):n.success?Y():(M({tone:`error`,text:n.message??`Could not delete the memory.`}),q(!1),J.current=null)});return Y(),()=>{n(),r(),i(),a()}},[Y,o.client]);let X=(0,A.useMemo)(()=>d.filter(e=>{let t=e.audience;return!!(t&&(t.roles?.length||t.taskTypes?.length||t.modes?.length))}),[d]),Z=N.trim(),Q=(0,A.useMemo)(()=>X.filter(e=>P(e,Z)),[Z,X]),$=T(Q,16,Z),oe=(0,A.useMemo)(()=>F(X,`roles`),[X]),se=(0,A.useMemo)(()=>F(X,`taskTypes`),[X]),ce=(0,A.useMemo)(()=>F(X,`modes`),[X]),le=e=>{M(null),o.updateSage(e,{audience:void 0},{echoToChat:!1})},ue=()=>{H&&(J.current=H,q(!0),M(null),o.deleteSage(H,`Removed from the audience memory panel.`))},de=async()=>{let t=X.map(e=>({id:e.id,text:e.text,kind:e.kind,status:e.status,audience:e.audience,tags:e.tags,importance:e.importance,confidence:e.confidence}));try{if(!navigator.clipboard)throw Error(`Clipboard access is unavailable.`);await navigator.clipboard.writeText(JSON.stringify(t,null,2)),M({tone:`success`,text:e(`activity:audienceMem.copiedAsJson`,{count:t.length})})}catch(t){M({tone:`error`,text:t instanceof Error?t.message:e(`activity:audienceMem.copyFailed`)})}};return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col bg-card/20`,"aria-labelledby":`audience-memory-title`,children:[(0,j.jsxs)(`div`,{className:`shrink-0 border-b border-border/60 p-3`,children:[(0,j.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,j.jsx)(`div`,{className:`min-w-0`,children:(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-md border border-primary/20 bg-primary/10 text-primary`,children:(0,j.jsx)(n,{className:`size-3.5`})}),(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsx)(`h2`,{id:`audience-memory-title`,className:`truncate text-sm font-semibold`,children:e(`activity:audienceMem.heading`)}),(0,j.jsx)(`p`,{className:`truncate text-[10px] text-muted-foreground`,children:e(`activity:audienceMem.subheading`)})]})]})}),(0,j.jsxs)(S,{variant:`default`,size:`sm`,className:`h-7 shrink-0 gap-1 px-2 text-xs`,onClick:()=>B(!0),children:[(0,j.jsx)(t,{className:`size-3`}),e(`common:action.add`)]})]}),(0,j.jsxs)(`div`,{className:`mt-3 grid grid-cols-4 gap-px overflow-hidden rounded-md border border-border/60 bg-border/60`,children:[(0,j.jsx)(L,{value:X.length,label:e(`activity:audienceMem.statMemories`)}),(0,j.jsx)(L,{value:oe.length,label:e(`activity:audienceMem.statRoles`)}),(0,j.jsx)(L,{value:se.length,label:e(`activity:audienceMem.statTasks`)}),(0,j.jsx)(L,{value:ce.length,label:e(`activity:audienceMem.statModes`)})]}),(0,j.jsxs)(`div`,{className:`mt-3 flex items-center gap-1.5`,children:[(0,j.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,j.jsx)(s,{className:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,j.jsx)(C,{value:N,onChange:e=>I(e.target.value),placeholder:e(`activity:audienceMem.searchTextRoleTaskOrMode`),"aria-label":e(`activity:audienceMem.searchAudienceMemories`),className:`h-8 pl-8 pr-8 text-xs`}),N&&(0,j.jsx)(`button`,{type:`button`,className:`absolute right-2 top-1/2 -translate-y-1/2 rounded-sm p-0.5 text-muted-foreground hover:text-foreground`,onClick:()=>I(``),"aria-label":e(`activity:audienceMem.clearAudienceMemorySearch`),children:(0,j.jsx)(c,{className:`size-3`})})]}),(0,j.jsx)(S,{variant:`ghost`,size:`icon`,className:`size-8 shrink-0`,onClick:Y,"aria-label":e(`activity:audienceMem.refreshAudienceMemories`),title:e(`activity:audienceMem.refresh`),children:(0,j.jsx)(f,{className:h(`size-3.5`,D&&`animate-spin`)})}),(0,j.jsx)(S,{variant:`ghost`,size:`icon`,className:`size-8 shrink-0`,onClick:()=>V(!0),"aria-label":e(`activity:audienceMem.importAudienceMemories`),title:e(`activity:audienceMem.importJson`),children:(0,j.jsx)(a,{className:`size-3.5`})}),(0,j.jsx)(S,{variant:`ghost`,size:`icon`,className:`size-8 shrink-0`,onClick:()=>void de(),"aria-label":e(`activity:audienceMem.copyAudienceMemoriesAsJson`),title:e(`activity:audienceMem.copyJson`),disabled:X.length===0,children:(0,j.jsx)(l,{className:`size-3.5`})})]})]}),k&&(0,j.jsxs)(`div`,{role:k.tone===`error`?`alert`:`status`,className:h(`mx-3 mt-3 flex shrink-0 items-start justify-between gap-2 rounded-md border px-2.5 py-2 text-[11px]`,k.tone===`error`?`border-destructive/30 bg-destructive/5 text-destructive`:`border-success/30 bg-success/5 text-success`),children:[(0,j.jsx)(`span`,{children:k.text}),(0,j.jsx)(`button`,{type:`button`,onClick:()=>M(null),className:`shrink-0 rounded-sm opacity-70 hover:opacity-100`,"aria-label":e(`activity:audienceMem.dismissMessage`),children:(0,j.jsx)(c,{className:`size-3`})})]}),(0,j.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[!D&&X.length>0&&(0,j.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between px-3 pb-1.5 pt-3 text-[10px] text-muted-foreground`,children:[(0,j.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,j.jsx)(i,{className:`size-3`}),Z?`${Q.length} of ${X.length}`:`${X.length} scoped`]}),Z&&(0,j.jsx)(`button`,{type:`button`,className:`hover:text-foreground`,onClick:()=>I(``),children:e(`activity:audienceMem.clearFilter`)})]}),(0,j.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3`,children:[D?(0,j.jsx)(te,{}):X.length===0?(0,j.jsx)(ne,{onAdd:()=>B(!0)}):Q.length===0?(0,j.jsxs)(`div`,{className:`flex h-full min-h-32 flex-col items-center justify-center px-4 text-center`,children:[(0,j.jsx)(s,{className:`mb-2 size-5 text-muted-foreground/60`}),(0,j.jsx)(`p`,{className:`text-xs font-medium`,children:e(`activity:audienceMem.noMatching`)}),(0,j.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:e(`activity:audienceMem.noMatchingHint`)}),(0,j.jsx)(S,{variant:`ghost`,size:`sm`,className:`mt-2 h-7 text-xs`,onClick:()=>I(``),children:e(`activity:audienceMemoryPanel.clearSearch`)})]}):(0,j.jsx)(`ul`,{className:`space-y-2`,children:$.pageItems.map(e=>(0,j.jsx)(R,{memory:e,onFilter:I,onClearScope:()=>le(e.id),onDelete:()=>U(e.id)},e.id))}),(0,j.jsx)(w,{page:$.page,pageSize:$.pageSize,totalItems:$.totalItems,onPageChange:$.setPage,compact:!0,itemLabel:`memories`})]})]})]}),(0,j.jsx)(re,{open:z,busy:W,onOpenChange:e=>{W||B(e)},onCreate:e=>{M(null),G(!0),o.rememberSage({text:e.text,kind:e.kind,audience:{roles:e.roles.length>0?e.roles:void 0,taskTypes:e.taskTypes.length>0?e.taskTypes:void 0,modes:e.modes.length>0?e.modes:void 0}},{echoToChat:!1})}}),(0,j.jsx)(ie,{open:ae,onOpenChange:V,onImport:t=>{try{let{entries:n,skipped:r}=ee(t);if(n.length===0)return M({tone:`error`,text:e(`activity:audienceMem.noValidInJson`)}),!1;for(let e of n)o.rememberSage(e,{echoToChat:!1});return M({tone:`success`,text:e(`activity:audienceMem.queuedForImport`,{count:n.length})+(r?e(`activity:audienceMem.skippedSuffix`,{count:r}):`.`)}),V(!1),!0}catch(t){return M({tone:`error`,text:t instanceof Error?t.message:e(`activity:customRoster.invalidJson`)}),!1}}}),(0,j.jsx)(x,{open:!!H,onOpenChange:e=>{!e&&!K&&U(null)},children:(0,j.jsxs)(v,{className:`max-w-md`,children:[(0,j.jsxs)(g,{children:[(0,j.jsx)(y,{children:e(`activity:audienceMem.deleteTitle`)}),(0,j.jsx)(b,{children:e(`activity:audienceMem.deleteBody`)})]}),(0,j.jsx)(`div`,{className:`rounded-md border border-border/70 bg-background/45 p-3 text-xs text-muted-foreground`,children:E(d.find(e=>e.id===H)?.text??``,180)}),(0,j.jsxs)(_,{children:[(0,j.jsx)(S,{variant:`outline`,onClick:()=>U(null),disabled:K,children:`Cancel`}),(0,j.jsxs)(S,{variant:`destructive`,onClick:ue,disabled:K,children:[(0,j.jsx)(u,{className:`size-4`}),K?`Deleting…`:`Delete memory`]})]})]})})]})}function L({value:e,label:t}){return(0,j.jsxs)(`div`,{className:`bg-card/95 px-1.5 py-2 text-center`,children:[(0,j.jsx)(`p`,{className:`text-sm font-semibold tabular-nums`,children:e}),(0,j.jsx)(`p`,{className:`truncate text-[9px] uppercase tracking-wide text-muted-foreground`,children:t})]})}function R({memory:e,onFilter:t,onClearScope:n,onDelete:i}){let{t:a}=r();return(0,j.jsxs)(`li`,{className:`group rounded-md border border-border/65 bg-card/55 p-2.5 transition-colors hover:border-border hover:bg-card/85`,children:[(0,j.jsx)(`p`,{className:`break-words text-xs leading-5`,children:e.text}),e.audience&&(0,j.jsx)(z,{audience:e.audience,onFilter:t}),(0,j.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-2 border-t border-border/45 pt-2`,children:[(0,j.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-[9px] uppercase tracking-wide text-muted-foreground`,children:[(0,j.jsx)(`span`,{className:`truncate`,children:O[e.kind]??e.kind}),(0,j.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,j.jsx)(`span`,{children:e.status})]}),(0,j.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[(0,j.jsx)(S,{variant:`ghost`,size:`icon`,className:`size-6`,onClick:n,"aria-label":`Remove audience scope from ${E(e.text,42)}`,title:a(`activity:audienceMem.makeGeneralMemory`),children:(0,j.jsx)(o,{className:`size-3`})}),(0,j.jsx)(S,{variant:`ghost`,size:`icon`,className:`size-6 text-destructive hover:text-destructive`,onClick:i,"aria-label":`Delete ${E(e.text,42)}`,title:a(`activity:audienceMem.delete`),children:(0,j.jsx)(u,{className:`size-3`})})]})]})]})}function z({audience:e,onFilter:t}){return(0,j.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[...(e.roles??[]).map(e=>({label:`role`,value:e})),...(e.taskTypes??[]).map(e=>({label:`task`,value:e})),...(e.modes??[]).map(e=>({label:`mode`,value:e}))].map(({label:e,value:n})=>(0,j.jsxs)(`button`,{type:`button`,className:`max-w-full truncate rounded border border-primary/15 bg-primary/7 px-1.5 py-0.5 font-mono text-[9px] text-primary/90 transition-colors hover:border-primary/35 hover:bg-primary/12`,onClick:()=>t(n),title:`Filter by ${e}: ${n}`,children:[e,`:`,n]},`${e}:${n}`))})}function te(){let{t:e}=r();return(0,j.jsx)(`div`,{className:`space-y-2 pt-3`,role:`status`,"aria-label":e(`activity:audienceMem.loadingAudienceMemories`),children:[0,1,2].map(e=>(0,j.jsxs)(`div`,{className:`animate-pulse rounded-md border border-border/50 p-3`,children:[(0,j.jsx)(`div`,{className:`h-2.5 w-full rounded bg-muted`}),(0,j.jsx)(`div`,{className:`mt-2 h-2.5 w-2/3 rounded bg-muted`}),(0,j.jsx)(`div`,{className:`mt-3 h-4 w-24 rounded bg-muted`})]},e))})}function ne({onAdd:e}){let{t:i}=r();return(0,j.jsxs)(`div`,{className:`flex h-full min-h-44 flex-col items-center justify-center px-5 text-center`,children:[(0,j.jsx)(`span`,{className:`mb-3 flex size-10 items-center justify-center rounded-full border border-dashed border-primary/35 bg-primary/5 text-primary`,children:(0,j.jsx)(n,{className:`size-4`})}),(0,j.jsx)(`p`,{className:`text-xs font-medium`,children:i(`activity:audienceMem.emptyTitle`)}),(0,j.jsx)(`p`,{className:`mt-1 max-w-52 text-[10px] leading-4 text-muted-foreground`,children:i(`activity:audienceMem.emptyBody`)}),(0,j.jsxs)(S,{variant:`outline`,size:`sm`,className:`mt-3 h-7 gap-1 text-xs`,onClick:e,children:[(0,j.jsx)(t,{className:`size-3`}),i(`activity:audienceMem.addScoped`)]})]})}function re({open:e,busy:t,onOpenChange:n,onCreate:i}){let{t:a}=r(),[o,s]=(0,A.useState)(``),[c,l]=(0,A.useState)(`workflow`),[u,d]=(0,A.useState)(``),[f,p]=(0,A.useState)(``),[m,h]=(0,A.useState)(``);(0,A.useEffect)(()=>{e||(s(``),l(`workflow`),d(``),p(``),h(``))},[e]);let C=k(u),w=k(f),T=k(m),E=o.trim().length>0&&(C.length>0||w.length>0||T.length>0);return(0,j.jsx)(x,{open:e,onOpenChange:n,children:(0,j.jsxs)(v,{className:`max-w-xl`,children:[(0,j.jsxs)(g,{children:[(0,j.jsx)(y,{children:a(`activity:audienceMem.createTitle`)}),(0,j.jsx)(b,{children:a(`activity:audienceMem.createBody`)})]}),(0,j.jsxs)(`div`,{className:`space-y-4`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`label`,{htmlFor:`audience-memory-text`,className:`mb-1.5 block text-xs font-medium`,children:a(`activity:audienceMem.fieldMemory`)}),(0,j.jsx)(`textarea`,{id:`audience-memory-text`,value:o,onChange:e=>s(e.target.value),placeholder:a(`activity:audienceMem.whatShouldMatchingAgentsRemember`),rows:4,autoFocus:!0,className:`w-full resize-y rounded-md border border-input bg-background px-3 py-2 text-sm outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring`})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`label`,{htmlFor:`audience-memory-kind`,className:`mb-1.5 block text-xs font-medium`,children:a(`activity:audienceMem.fieldKind`)}),(0,j.jsx)(`select`,{id:`audience-memory-kind`,value:c,onChange:e=>l(e.target.value),className:`h-9 w-full rounded-md border border-input bg-background px-3 text-xs outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:D.map(e=>(0,j.jsx)(`option`,{value:e,children:O[e]??e},e))})]}),(0,j.jsxs)(`fieldset`,{className:`space-y-3 rounded-md border border-border/70 bg-background/35 p-3`,children:[(0,j.jsx)(`legend`,{className:`px-1 text-xs font-medium`,children:a(`activity:audienceMem.selectors`)}),(0,j.jsx)(B,{id:`audience-memory-roles`,label:a(`activity:audienceMem.statRoles`),value:u,onChange:d,placeholder:a(`activity:audienceMem.reviewerRefactorPlanner`)}),(0,j.jsx)(B,{id:`audience-memory-task-types`,label:a(`activity:audienceMem.fieldTaskTypes`),value:f,onChange:p,placeholder:a(`activity:audienceMem.reviewRefactorBugfix`)}),(0,j.jsx)(B,{id:`audience-memory-modes`,label:a(`activity:audienceMem.statModes`),value:m,onChange:h,placeholder:a(`activity:audienceMem.teachCodeReview`)}),(0,j.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:a(`activity:audienceMem.selectorsHint`)})]})]}),(0,j.jsxs)(_,{children:[(0,j.jsx)(S,{variant:`outline`,onClick:()=>n(!1),disabled:t,children:a(`common:action.cancel`)}),(0,j.jsx)(S,{onClick:()=>i({text:o.trim(),kind:c,roles:C,taskTypes:w,modes:T}),disabled:!E||t,children:t?`Remembering…`:`Remember`})]})]})})}function B({id:e,label:t,value:n,placeholder:r,onChange:i}){return(0,j.jsxs)(`div`,{className:`grid gap-1.5 sm:grid-cols-[6rem_1fr] sm:items-center`,children:[(0,j.jsx)(`label`,{htmlFor:e,className:`text-[11px] font-medium text-muted-foreground`,children:t}),(0,j.jsx)(C,{id:e,value:n,onChange:e=>i(e.target.value),placeholder:r,className:`h-8 font-mono text-xs`})]})}function ie({open:e,onOpenChange:t,onImport:n}){let{t:i}=r(),[o,s]=(0,A.useState)(``);return(0,A.useEffect)(()=>{e||s(``)},[e]),(0,j.jsx)(x,{open:e,onOpenChange:t,children:(0,j.jsxs)(v,{className:`max-w-xl`,children:[(0,j.jsxs)(g,{children:[(0,j.jsx)(y,{children:i(`activity:audienceMem.importTitle`)}),(0,j.jsxs)(b,{children:[i(`activity:audienceMem.importBodyBefore`),` `,(0,j.jsx)(`code`,{children:i(`activity:audienceMemoryPanel.memoryAudienceExport`)}),`.`,` `,i(`activity:audienceMem.importBodyAfter`)]})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`label`,{htmlFor:`audience-memory-import`,className:`mb-1.5 block text-xs font-medium`,children:i(`activity:audienceMem.jsonArray`)}),(0,j.jsx)(`textarea`,{id:`audience-memory-import`,value:o,onChange:e=>s(e.target.value),placeholder:`[
2
+ { "text": "…", "audience": { "roles": ["reviewer"] } }
3
+ ]`,rows:10,autoFocus:!0,spellCheck:!1,className:`w-full resize-y rounded-md border border-input bg-background p-3 font-mono text-xs outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring`})]}),(0,j.jsxs)(_,{children:[(0,j.jsx)(S,{variant:`outline`,onClick:()=>t(!1),children:i(`common:action.cancel`)}),(0,j.jsxs)(S,{onClick:()=>n(o),disabled:!o.trim(),children:[(0,j.jsx)(a,{className:`size-4`}),i(`activity:audienceMem.importAction`)]})]})]})})}export{I as AudienceMemoryPanel};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{$i as t,Ei as n,Pa as r,b as i,dn as a,ir as o,lt as s,ri as c,un as l,vn as u,za as d}from"./vendor-BuarzSSb.js";import"./i18n-COgumVF5.js";import{a as f,n as p,t as m}from"./monaco-BLUV5g0U.js";import{t as h}from"./ws-client-TTMa0XaT.js";import{t as g}from"./utils-B-9lSDIn.js";import{I as _,b as v}from"./stores-ChEnUmic.js";import{v as y}from"./index-CtpViiZy.js";import{t as b}from"./empty-state-RRSqQaCk.js";import{t as x}from"./monaco-theme-DSeCDzQy.js";var S=e(d(),1),C=s();p.config({monaco:m});var w={ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,mjs:`javascript`,json:`json`,css:`css`,scss:`scss`,html:`html`,md:`markdown`,py:`python`,go:`go`,rs:`rust`,java:`java`,c:`c`,cpp:`cpp`,cs:`csharp`,rb:`ruby`,php:`php`,sh:`shell`,bash:`shell`,yml:`yaml`,yaml:`yaml`,toml:`toml`,sql:`sql`};function T(e){return w[e.split(`.`).pop()?.toLowerCase()??``]??`plaintext`}function E({path:e,oldText:n,newText:a}){let{t:s}=r(),c=(0,S.useRef)(null),[u,d]=(0,S.useState)(!1),[p,m]=(0,S.useState)(!1),[g,v]=(0,S.useState)(null);(0,S.useEffect)(()=>{d(!1),m(!1),v(null)},[]);let y=(0,S.useCallback)(e=>{c.current=e,f.setTheme(x()),e.getModifiedEditor().onDidChangeModelContent(()=>d(!0))},[]),b=(0,S.useCallback)(()=>{let t=c.current?.getModifiedEditor().getValue();if(t==null)return;m(!0);let n=h(_.getState().wsUrl),r=n.on(`files.written`,t=>{t.type===`files.written`&&t.payload.filePath===e&&(r(),clearTimeout(i),m(!1),t.payload.success&&(d(!1),v(Date.now())))}),i=setTimeout(()=>{r(),m(!1)},5e3);n.send({type:`files.write`,payload:{filePath:e,content:t}})},[e]),w=T(e);return(0,C.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,C.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2 px-2 py-1.5 border-b border-border/40`,children:[(0,C.jsx)(`span`,{className:`text-xs font-mono text-muted-foreground truncate`,children:e}),(0,C.jsxs)(`button`,{type:`button`,onClick:b,disabled:!u||p,className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-md border border-border text-xs font-medium disabled:opacity-40 enabled:hover:bg-muted transition-colors`,title:s(`activity:monacoDiff.applyTitle`),children:[p?(0,C.jsx)(o,{className:`h-3.5 w-3.5 animate-spin`}):g&&!u?(0,C.jsx)(t,{className:`h-3.5 w-3.5 text-success`}):(0,C.jsx)(l,{className:`h-3.5 w-3.5`}),s(p?`activity:monacoDiff.applying`:g&&!u?`activity:monacoDiff.applied`:`activity:monacoDiff.apply`)]})]}),(0,C.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-hidden`,children:(0,C.jsx)(i,{original:n,modified:a,language:w,theme:x(),onMount:y,options:{renderSideBySide:!0,readOnly:!1,originalEditable:!1,minimap:{enabled:!1},fontSize:13,scrollBeyondLastLine:!1,automaticLayout:!0}})})]})}var D=1e4;function O({className:e}){let{t}=r(),i=v(e=>e.selectedPath),s=v(e=>e.diff),l=v(e=>e.loadingDiff),[d,f]=(0,S.useState)(`unified`),[p,m]=(0,S.useState)(!1),x=!!i&&(l||!s);(0,S.useEffect)(()=>{if(m(!1),!x)return;let e=setTimeout(()=>m(!0),D);return()=>clearTimeout(e)},[x,i]);let w=()=>{i&&(m(!1),v.getState().setDiffLoading(!0),h(_.getState().wsUrl).getGitDiff?.(i))};if(!i)return(0,C.jsx)(b,{icon:(0,C.jsx)(c,{className:`h-6 w-6`}),title:t(`activity:changesView.sourceChanges`),description:t(`activity:changes.selectPrompt`),className:e});let T=s&&!s.error&&!s.binary&&!s.tooLarge;return(0,C.jsx)(`div`,{className:g(`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,C.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,C.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2 border-b border-border/70 px-3 py-2`,children:[(0,C.jsxs)(`div`,{className:`min-w-0`,children:[(0,C.jsx)(`div`,{className:`text-[10px] font-semibold uppercase text-muted-foreground`,children:t(`activity:changesView.sourceControl`)}),(0,C.jsx)(`div`,{className:`truncate font-mono text-xs text-foreground`,title:i,children:i})]}),T&&(0,C.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,C.jsxs)(`button`,{type:`button`,onClick:()=>f(`unified`),title:t(`activity:changes.unifiedTitle`),className:g(`inline-flex h-8 items-center gap-1 rounded-md border px-2 text-xs transition-colors`,d===`unified`?`border-primary/40 bg-primary/10 text-primary`:`border-border text-muted-foreground hover:bg-muted`),children:[(0,C.jsx)(a,{className:`h-3.5 w-3.5`}),` `,t(`activity:changes.unified`)]}),(0,C.jsxs)(`button`,{type:`button`,onClick:()=>f(`edit`),title:t(`activity:changes.editTitle`),className:g(`inline-flex h-8 items-center gap-1 rounded-md border px-2 text-xs transition-colors`,d===`edit`?`border-primary/40 bg-primary/10 text-primary`:`border-border text-muted-foreground hover:bg-muted`),children:[(0,C.jsx)(n,{className:`h-3.5 w-3.5`}),` `,t(`activity:changes.edit`)]})]})]}),(0,C.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:l||!s?p?(0,C.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center gap-3 p-4 text-center`,children:[(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`activity:changes.diffTimeout`)}),(0,C.jsxs)(`button`,{type:`button`,onClick:w,className:`inline-flex h-8 items-center gap-1.5 rounded-md border border-border px-3 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:[(0,C.jsx)(u,{className:`h-3.5 w-3.5`}),` `,t(`common:action.retry`)]})]}):(0,C.jsxs)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,C.jsx)(o,{className:`h-4 w-4 animate-spin`}),` `,t(`activity:changes.loadingDiff`)]}):s.error?(0,C.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-sm text-destructive`,children:s.error}):s.binary?(0,C.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-sm text-muted-foreground`,children:t(`activity:changes.binary`)}):s.tooLarge?(0,C.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-sm text-muted-foreground`,children:t(`activity:changes.tooLarge`)}):d===`edit`?(0,C.jsx)(E,{path:s.path,oldText:s.oldText??``,newText:s.newText??``},s.path):(0,C.jsx)(y,{oldText:s.oldText,newText:s.newText,caption:s.path,fill:!0})})]})})}export{O as ChangesView};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Nr as t,Oa as n,Ot as r,Pa as i,Rr as a,Vt as o,Xi as s,Zt as c,an as l,dt as ee,ji as u,la as d,lt as f,mn as te,oa as p,oi as m,ur as ne,vi as h,vn as re,za as g}from"./vendor-BuarzSSb.js";import"./i18n-COgumVF5.js";import{t as ie}from"./ws-client-TTMa0XaT.js";import{t as _}from"./utils-B-9lSDIn.js";import{b as ae,x as oe}from"./index-CtpViiZy.js";var v=e(g(),1),y=f();function b({status:e}){let{t}=i();return(0,y.jsxs)(`section`,{className:`flex flex-wrap gap-x-5 gap-y-1 border-b border-border/60 bg-primary/[0.025] px-4 py-1.5 font-mono text-[9px] text-muted-foreground`,title:e.chronicleDirectory,children:[(0,y.jsx)(`span`,{className:`font-sans font-semibold uppercase tracking-wider text-primary`,children:t(`activity:chroniclePipelineStrip.chronicleOwnership`)}),(0,y.jsxs)(`span`,{children:[`collect `,(0,y.jsx)(`b`,{className:`text-foreground`,children:e.pipeline.collection})]}),(0,y.jsxs)(`span`,{children:[`process `,(0,y.jsx)(`b`,{className:`text-foreground`,children:e.pipeline.processing})]}),(0,y.jsxs)(`span`,{children:[`serve `,(0,y.jsx)(`b`,{className:`text-foreground`,children:e.pipeline.serving})]}),(0,y.jsxs)(`span`,{children:[`PID `,(0,y.jsx)(`b`,{className:`text-foreground`,children:e.pid}),` · `,e.clients,` clients`]}),(0,y.jsxs)(`span`,{children:[`watcher`,` `,(0,y.jsx)(`b`,{className:_(e.watcher.active?`text-success`:`text-warning`),children:e.watcher.active?`active`:`inactive`}),` `,`· `,e.watcher.watchedFiles,` files`]}),(0,y.jsxs)(`span`,{children:[`store `,(0,y.jsx)(`b`,{className:`text-foreground`,children:x(e.pipeline.storage)})]}),e.mode===`inline`&&(0,y.jsx)(`span`,{className:`font-sans font-semibold text-warning`,children:t(`activity:chroniclePipelineStrip.inlineFallback`)})]})}function x(e){return e.replaceAll(`\\`,`/`).split(`/`).filter(Boolean).slice(-3).join(`/`)}var S=[`eventType`,`providerId`,`modelId`,`outcome`,`resourceKind`],C=1440*60*1e3;function w(){return{limit:300,order:`desc`,from:new Date(Date.now()-C).toISOString()}}var se=[{id:`all`,labelKey:`activity:chronicle.signalAllSignals`,icon:(0,y.jsx)(n,{})},{id:`llm`,labelKey:`activity:chronicle.signalLlm`,icon:(0,y.jsx)(p,{})},{id:`agents`,labelKey:`activity:chronicle.signalAgents`,icon:(0,y.jsx)(d,{})},{id:`tools`,labelKey:`activity:chronicle.signalTools`,icon:(0,y.jsx)(o,{})},{id:`files`,labelKey:`activity:chronicle.signalFiles`,icon:(0,y.jsx)(m,{})},{id:`failures`,labelKey:`activity:chronicle.signalFailures`,icon:(0,y.jsx)(r,{})}];function T(){let{t:e}=i(),t=ie(),[n,r]=(0,v.useState)([]),[s,c]=(0,v.useState)(null),[f,h]=(0,v.useState)({}),[g,x]=(0,v.useState)(w()),[C,T]=(0,v.useState)({text:``,path:``,providerId:``,modelId:``,sessionId:``}),[E,O]=(0,v.useState)(`all`),[N,F]=(0,v.useState)({total:0,scannedEvents:0,sourceFiles:0,invalidLines:0}),[I,pe]=(0,v.useState)(D),[L,R]=(0,v.useState)(!0),[z,B]=(0,v.useState)(null),[me,V]=(0,v.useState)(null),[H,he]=(0,v.useState)([]),[U,ge]=(0,v.useState)([]),[W,_e]=(0,v.useState)(null),G=(0,v.useRef)(g);G.current=g;let K=(0,v.useCallback)(e=>{if(!t.supportsCapability(`chronicle.query`)){R(!1),B(`Restart the backend once to activate Chronicle protocol support.`);return}if(R(!0),B(null),x(e),h({}),t.send({type:`chronicle.query`,payload:{query:e}}),t.supportsCapability(`chronicle.facets`))t.send({type:`chronicle.facets`,payload:{fields:[...S],query:e,limit:12}});else for(let n of S)t.send({type:`chronicle.facet`,payload:{field:n,query:e,limit:12}})},[t]),q=(0,v.useCallback)(()=>{t.supportsCapability(`chronicle.metrics`)&&(t.send({type:`chronicle.metrics`,payload:{view:`providers`}}),t.send({type:`chronicle.metrics`,payload:{view:`tasks`,limit:200}}))},[t]),J=(0,v.useCallback)(()=>{t.supportsCapability(`chronicle.status`)&&t.send({type:`chronicle.status`})},[t]);(0,v.useEffect)(()=>{let e=t.on(`chronicle.query_result`,e=>{e.type===`chronicle.query_result`&&(r(e.payload.events),F(e.payload),pe(e.payload.summary??D),R(!1))}),n=t.on(`chronicle.facet_result`,e=>{e.type===`chronicle.facet_result`&&h(t=>({...t,[e.payload.field]:e.payload.values}))}),i=t.on(`chronicle.facets_result`,e=>{e.type===`chronicle.facets_result`&&h(e.payload.values)}),a=t.on(`chronicle.error`,e=>{e.type===`chronicle.error`&&(B(e.payload.message),R(!1))}),o=t.on(`chronicle.graph_result`,e=>{e.type===`chronicle.graph_result`&&V(e.payload)}),s=t.on(`chronicle.metrics_result`,e=>{e.type===`chronicle.metrics_result`&&(e.payload.view===`providers`?he(e.payload.data):e.payload.view===`tasks`&&ge(e.payload.data))}),c=t.on(`chronicle.status_result`,e=>{e.type===`chronicle.status_result`&&_e(e.payload)});return K(G.current),q(),J(),()=>{e(),n(),i(),a(),o(),s(),c()}},[t,K,q,J]);let Y=(0,v.useMemo)(()=>n.filter(e=>ue(e,E)),[n,E]),X=oe(Y,25,E),Z=(0,v.useMemo)(()=>{let e=n.find(e=>e.eventType===`metrics.rollup`&&e.attributes?.signal===`runtime.health`)?.attributes?.stats;if(!e)return;let t=t=>e[t]?.last;return{eventLoop:{utilization:t(`eventLoop.utilization`),delayP95Ms:t(`eventLoop.delayP95Ms`)},memory:{heapUsedBytes:t(`memory.heapUsedBytes`)},chronicle:{pendingEvents:t(`chronicle.pendingEvents`),rejectedEvents:t(`chronicle.rejectedEvents`)}}},[n]),Q=(0,v.useMemo)(()=>{let e={};for(let t of U)e[t.status]=(e[t.status]??0)+1;let t=(e.completed??0)+(e.merged??0)+(e.failed??0)+(e.conflict??0),n=(e.completed??0)+(e.merged??0),r=[...U].sort((e,t)=>(t.endedAt??t.startedAt??``).localeCompare(e.endedAt??e.startedAt??``)).slice(0,8);return{counts:e,total:U.length,terminal:t,successRate:t>0?n/t*100:100,recent:r}},[U]),$=()=>K({...w(),...C.text?{text:C.text}:{},...C.path?{path:C.path}:{},...C.providerId?{providerId:C.providerId}:{},...C.modelId?{modelId:C.modelId}:{},...C.sessionId?{sessionId:C.sessionId}:{}}),ve=()=>{T({text:``,path:``,providerId:``,modelId:``,sessionId:``}),O(`all`),K(w())},ye=e=>{c(e),V(null),t.supportsCapability(`chronicle.graph`)&&t.send({type:`chronicle.graph`,payload:{seed:{eventId:e.eventId},hops:2,maxNodes:250}})};return(0,y.jsxs)(`div`,{className:`flex h-full min-h-0 bg-background`,"data-testid":`chronicle-dashboard`,children:[(0,y.jsxs)(`main`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,y.jsx)(`header`,{className:`border-b border-border/70 bg-gradient-to-r from-primary/[0.045] via-background to-background px-5 py-4`,children:(0,y.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,y.jsxs)(`div`,{children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(p,{className:`h-5 w-5 text-primary`}),(0,y.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight`,children:e(`activity:chronicle.codingIntelligence`)}),(0,y.jsx)(`span`,{className:`rounded-full border border-primary/20 bg-primary/10 px-2 py-0.5 text-[9px] font-semibold tracking-wider text-primary`,children:e(`activity:chronicle.chronicle`)})]}),(0,y.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:e(`activity:chronicle.llmAgentToolAndFileEvidence`)})]}),(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(`span`,{className:_(`h-2 w-2 rounded-full`,z?`bg-destructive`:L?`animate-pulse bg-warning`:`bg-success`)}),(0,y.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:L?`Reading journal`:z?`Unavailable`:`Live evidence`}),(0,y.jsx)(`button`,{type:`button`,onClick:()=>{K(g),q(),J()},className:`ml-2 rounded-md border border-border bg-card p-2 hover:bg-muted`,title:e(`activity:chronicle.refreshEvidence`),children:(0,y.jsx)(re,{className:_(`h-4 w-4`,L&&`animate-spin`)})})]})]})}),(0,y.jsxs)(`section`,{className:`grid grid-cols-2 border-b border-border/70 xl:grid-cols-6`,children:[(0,y.jsx)(j,{icon:(0,y.jsx)(p,{}),label:e(`activity:chronicle.llmRequests`),value:I.logicalRequests,detail:`${I.modelAttempts} attempts · ${I.providers} providers · ${I.models} models`}),(0,y.jsx)(j,{icon:(0,y.jsx)(d,{}),label:e(`activity:chronicle.agentWork`),value:I.agentEvents,detail:`${I.uniqueAgents} correlated agents · ${I.decisions} decisions`}),(0,y.jsx)(j,{icon:(0,y.jsx)(o,{}),label:e(`activity:chronicle.toolCalls`),value:I.toolCalls,detail:`${I.failedTools} failed · ${I.processes} processes`}),(0,y.jsx)(j,{icon:(0,y.jsx)(m,{}),label:e(`activity:chronicle.fileEvidence`),value:I.fileEvents,detail:`${I.uniqueFiles} unique paths`}),(0,y.jsx)(j,{icon:(0,y.jsx)(te,{}),label:e(`activity:chronicle.retries`),value:I.scheduledRetries,detail:`${I.failures} failures · ${I.fallbacks} fallbacks`,tone:I.failures?`danger`:`normal`}),(0,y.jsx)(j,{icon:(0,y.jsx)(u,{}),label:e(`activity:chronicle.providerP95`),value:k(I.providerP95DurationMs),detail:`${k(I.providerAvgDurationMs)} average · all matches`})]}),(0,y.jsxs)(`section`,{className:`flex flex-wrap gap-x-6 gap-y-1 border-b border-border/60 bg-primary/[0.018] px-4 py-1.5 font-mono text-[9px] text-muted-foreground`,children:[(0,y.jsx)(`span`,{className:`font-sans font-semibold uppercase tracking-wider text-primary`,children:e(`activity:chronicle.tokenEconomics`)}),(0,y.jsxs)(`span`,{children:[e(`activity:chronicle.freshInput`),` `,(0,y.jsx)(`b`,{className:`text-foreground`,children:I.inputTokens.toLocaleString()})]}),(0,y.jsxs)(`span`,{children:[`output `,(0,y.jsx)(`b`,{className:`text-foreground`,children:I.outputTokens.toLocaleString()})]}),(0,y.jsxs)(`span`,{children:[e(`activity:chronicle.cacheRead`),` `,(0,y.jsx)(`b`,{className:`text-foreground`,children:I.cacheReadTokens.toLocaleString()})]}),(0,y.jsxs)(`span`,{children:[`cache write`,` `,(0,y.jsx)(`b`,{className:`text-foreground`,children:I.cacheWriteTokens.toLocaleString()})]}),(0,y.jsxs)(`span`,{children:[e(`activity:chronicle.cacheHit`),` `,(0,y.jsxs)(`b`,{className:`text-foreground`,children:[le(I).toFixed(1),`%`]})]}),(0,y.jsxs)(`span`,{children:[e(`activity:chronicle.estimatedCost`),` `,(0,y.jsxs)(`b`,{className:`text-foreground`,children:[`$`,I.estimatedCostUsd.toFixed(4)]})]})]}),H.length>0&&(0,y.jsxs)(`section`,{className:`flex items-center gap-3 overflow-x-auto border-b border-border/60 bg-muted/[0.14] px-4 py-1.5`,children:[(0,y.jsx)(`span`,{className:`shrink-0 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e(`activity:chronicle.modelReliability`)}),H.slice(0,6).map(e=>{let t=e.completed+e.failed,n=t>0?e.completed/t*100:100;return(0,y.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 rounded-full border border-border bg-card px-2.5 py-0.5 font-mono text-[9px]`,title:`${e.day} · ${e.attempts} attempts · avg ${k(e.avgDurationMs)} · ${e.inputTokens.toLocaleString()} in / ${e.outputTokens.toLocaleString()} out`,children:[(0,y.jsx)(`span`,{className:_(`h-1.5 w-1.5 rounded-full`,n>=99?`bg-success`:n>=90?`bg-warning`:`bg-destructive`)}),(0,y.jsxs)(`span`,{className:`max-w-[180px] truncate`,children:[e.providerId,`/`,e.modelId]}),(0,y.jsxs)(`b`,{className:`text-foreground`,children:[n.toFixed(0),`%`]}),(0,y.jsx)(`span`,{className:`text-muted-foreground`,children:e.day.slice(5)})]},`${e.day}-${e.providerId}-${e.modelId}`)})]}),Q.total>0&&(0,y.jsxs)(`section`,{className:`flex items-center gap-3 overflow-x-auto border-b border-border/60 bg-muted/[0.10] px-4 py-1.5`,children:[(0,y.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,y.jsx)(ne,{className:`h-3 w-3`}),e(`activity:chronicle.taskOutcomes`)]}),(0,y.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 rounded-full border border-border bg-card px-2.5 py-0.5 font-mono text-[9px]`,title:`${Q.total} tasks tracked · ${Q.terminal} finished`,children:[(0,y.jsx)(`span`,{className:_(`h-1.5 w-1.5 rounded-full`,Q.successRate>=90?`bg-success`:Q.successRate>=60?`bg-warning`:`bg-destructive`)}),(0,y.jsxs)(`b`,{className:`text-foreground`,children:[Q.successRate.toFixed(0),`%`]}),(0,y.jsxs)(`span`,{className:`text-muted-foreground`,children:[`success · `,Q.total,` tasks`]})]}),[`completed`,`merged`,`failed`,`conflict`,`started`].filter(e=>Q.counts[e]).map(e=>(0,y.jsxs)(`span`,{className:`shrink-0 font-mono text-[9px] text-muted-foreground`,children:[e,` `,(0,y.jsx)(`b`,{className:_(e===`failed`||e===`conflict`?`text-destructive`:`text-foreground`),children:Q.counts[e]})]},e)),(0,y.jsx)(`span`,{className:`mx-1 h-3 w-px shrink-0 bg-border`}),Q.recent.map(e=>(0,y.jsxs)(`button`,{type:`button`,onClick:()=>K({limit:300,order:`desc`,taskId:e.taskId}),className:`flex shrink-0 items-center gap-1.5 rounded-full border border-border bg-card px-2 py-0.5 font-mono text-[9px] hover:border-primary/50`,title:`${e.taskId}${e.boardId?` · board ${e.boardId}`:``}${e.sessionId?` · ${e.sessionId}`:``} · ${e.filesTouched} files${e.retries?` · ${e.retries} retries`:``}${e.verificationFailures?` · ${e.verificationFailures} verify-fails`:``}`,children:[(0,y.jsx)(`span`,{className:_(`h-1.5 w-1.5 rounded-full`,e.status===`completed`||e.status===`merged`?`bg-success`:e.status===`failed`||e.status===`conflict`?`bg-destructive`:`bg-primary`)}),(0,y.jsx)(`span`,{className:`max-w-[84px] truncate`,children:e.taskId}),e.durationMs!==null&&(0,y.jsx)(`span`,{className:`text-muted-foreground`,children:k(e.durationMs)}),e.filesTouched>0&&(0,y.jsxs)(`span`,{className:`flex items-center gap-0.5 text-muted-foreground`,children:[(0,y.jsx)(m,{className:`h-2.5 w-2.5`}),e.filesTouched]})]},e.taskId))]}),(0,y.jsx)(`section`,{className:`border-b border-border/70 px-4 py-3`,children:(0,y.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 xl:grid-cols-[1.35fr_1fr_1fr_1fr_1fr_auto]`,children:[(0,y.jsx)(A,{icon:(0,y.jsx)(l,{}),placeholder:e(`activity:chronicle.searchEventEvidence`),value:C.text,onChange:e=>T(t=>({...t,text:e})),onEnter:$}),(0,y.jsx)(A,{placeholder:e(`activity:chronicle.fileOrDirectory`),value:C.path,onChange:e=>T(t=>({...t,path:e})),onEnter:$}),(0,y.jsx)(A,{placeholder:e(`activity:chronicle.provider`),value:C.providerId,onChange:e=>T(t=>({...t,providerId:e})),onEnter:$}),(0,y.jsx)(A,{placeholder:e(`activity:chronicle.model`),value:C.modelId,onChange:e=>T(t=>({...t,modelId:e})),onEnter:$}),(0,y.jsx)(A,{placeholder:e(`activity:chronicle.session`),value:C.sessionId,onChange:e=>T(t=>({...t,sessionId:e})),onEnter:$}),(0,y.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,y.jsxs)(`button`,{type:`button`,onClick:$,className:`rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground`,children:[(0,y.jsx)(a,{className:`mr-1 inline h-3 w-3`}),e(`activity:chronicle.apply`)]}),(0,y.jsx)(`button`,{type:`button`,onClick:ve,className:`rounded-md border border-border px-2.5 text-xs hover:bg-muted`,children:e(`activity:chronicle.clear`)})]})]})}),(0,y.jsxs)(`section`,{className:`flex items-center gap-1 overflow-x-auto border-b border-border/70 px-4 py-2`,children:[se.map(t=>(0,y.jsxs)(`button`,{type:`button`,onClick:()=>O(t.id),className:_(`flex shrink-0 items-center gap-1.5 rounded-md px-2.5 py-1.5 text-[11px] transition-colors [&>svg]:h-3.5 [&>svg]:w-3.5`,E===t.id?`bg-primary/10 font-medium text-primary`:`text-muted-foreground hover:bg-muted hover:text-foreground`),children:[t.icon,e(t.labelKey),(0,y.jsx)(`span`,{className:`ml-1 rounded bg-background/70 px-1 font-mono text-[9px]`,children:ce(I,t.id,N.total)})]},t.id)),(0,y.jsxs)(`div`,{className:`ml-auto hidden items-center gap-3 pl-4 text-[9px] text-muted-foreground lg:flex`,children:[(0,y.jsxs)(`span`,{children:[N.total.toLocaleString(),` matched`]}),(0,y.jsxs)(`span`,{children:[N.sourceFiles,` journal files`]}),N.invalidLines>0&&(0,y.jsxs)(`span`,{className:`text-warning`,children:[N.invalidLines,` invalid lines`]})]})]}),W&&(0,y.jsx)(b,{status:W}),Z&&(0,y.jsx)(M,{health:Z}),(0,y.jsx)(`section`,{className:`flex gap-4 overflow-x-auto border-b border-border/60 bg-muted/[0.18] px-4 py-2`,children:[`providerId`,`modelId`,`outcome`].map(e=>(0,y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,y.jsx)(`span`,{className:`mr-1 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e.replace(`Id`,``)}),(f[e]??[]).slice(0,4).map(t=>(0,y.jsxs)(`button`,{type:`button`,onClick:()=>K({...g,[e]:t.value}),className:`rounded-full border border-border bg-card px-2 py-0.5 text-[9px] hover:border-primary/50`,children:[t.value,` `,(0,y.jsx)(`b`,{children:t.count})]},t.value))]},e))}),(0,y.jsxs)(`div`,{className:`grid grid-cols-[92px_minmax(190px,1.25fr)_110px_minmax(180px,1fr)_minmax(140px,.8fr)_24px] gap-3 border-b border-border/60 bg-muted/20 px-4 py-1.5 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,y.jsx)(`span`,{children:e(`activity:chronicle.time`)}),(0,y.jsx)(`span`,{children:e(`activity:chronicle.signal`)}),(0,y.jsx)(`span`,{children:e(`activity:chronicle.outcome`)}),(0,y.jsx)(`span`,{children:e(`activity:chronicle.modelAgent`)}),(0,y.jsx)(`span`,{children:e(`activity:chronicle.resource`)}),(0,y.jsx)(`span`,{})]}),(0,y.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:z?(0,y.jsx)(P,{text:z}):!L&&Y.length===0?(0,y.jsx)(P,{text:`No coding evidence matches these filters.`}):(0,y.jsx)(`div`,{className:`divide-y divide-border/40`,children:X.pageItems.map(e=>(0,y.jsx)(de,{event:e,active:s?.eventId===e.eventId,onClick:()=>ye(e)},e.eventId))})}),(0,y.jsx)(ae,{page:X.page,pageSize:X.pageSize,totalItems:X.totalItems,onPageChange:X.setPage,itemLabel:`events`})]}),s&&(0,y.jsxs)(`aside`,{className:`w-[440px] max-w-[48vw] shrink-0 overflow-auto border-l border-border bg-card/60 shadow-[-12px_0_32px_hsl(var(--background)/.35)]`,children:[(0,y.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center justify-between border-b border-border bg-card/95 px-4 py-3 backdrop-blur`,children:[(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`text-xs font-semibold`,children:e(`activity:chronicle.evidenceLineage`)}),(0,y.jsxs)(`div`,{className:`mt-0.5 font-mono text-[9px] text-muted-foreground`,children:[`#`,s.sequence,` · `,s.eventId]})]}),(0,y.jsx)(`button`,{type:`button`,onClick:()=>c(null),className:`rounded p-1 hover:bg-muted`,children:(0,y.jsx)(ee,{className:`h-4 w-4`})})]}),(0,y.jsx)(fe,{event:s,graph:me})]})]})}var E={llm:0,agent:0,tool:0,file:0,memory:0,task:0,decision:0,runtime:0},D={logicalRequests:0,modelAttempts:0,completedAttempts:0,failedAttempts:0,scheduledRetries:0,fallbacks:0,providers:0,models:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheWriteTokens:0,estimatedCostUsd:0,providerAvgDurationMs:0,providerP95DurationMs:0,toolCalls:0,completedTools:0,failedTools:0,toolAvgDurationMs:0,processes:0,failedProcesses:0,fileEvents:0,uniqueFiles:0,agentEvents:0,uniqueAgents:0,decisions:0,escalations:0,failures:0,cancellations:0,families:{...E},failuresByFamily:{...E}};function ce(e,t,n){return t===`all`?n:t===`llm`?e.families.llm:t===`agents`?e.families.agent:t===`tools`?e.families.tool:t===`files`?e.families.file:e.failures}function le(e){let t=e.inputTokens+e.cacheReadTokens;return t?e.cacheReadTokens/t*100:0}function ue(e,t){return t===`all`?!0:t===`llm`?/^(provider|token|context|compaction)\./.test(e.eventType):t===`agents`?/^(agent|subagent|delegate|fleet|sdd)\./.test(e.eventType):t===`tools`?/^(tool|process|mcp|network)\./.test(e.eventType):t===`files`?e.resource?.kind===`file`||/^(file|worktree|storage)\./.test(e.eventType):e.outcome===`failure`||/(?:failed|error|retry|fallback|blocked|conflict)/i.test(e.eventType)}function O(e){if(!e)return`—`;let t=e/1e6;return t<1?`${(e/1e3).toFixed(0)}µs`:t<1e3?`${t.toFixed(1)}ms`:`${(t/1e3).toFixed(1)}s`}function k(e){return e?e<1?`${(e*1e3).toFixed(0)}µs`:e<1e3?`${e.toFixed(1)}ms`:`${(e/1e3).toFixed(1)}s`:`—`}function A({placeholder:e,value:t,onChange:n,onEnter:r,icon:i}){return(0,y.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md border border-border bg-card px-2.5 py-2 focus-within:border-primary/60`,children:[i&&(0,y.jsx)(`span`,{className:`text-muted-foreground [&>svg]:h-3.5 [&>svg]:w-3.5`,children:i}),(0,y.jsx)(`input`,{className:`w-full bg-transparent text-xs outline-none placeholder:text-muted-foreground/70`,placeholder:e,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{e.key===`Enter`&&r()}})]})}function j({icon:e,label:t,value:n,detail:r,tone:i=`normal`}){return(0,y.jsxs)(`div`,{className:`min-w-0 border-r border-border/60 px-4 py-3`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:[(0,y.jsx)(`span`,{className:`text-primary [&>svg]:h-3.5 [&>svg]:w-3.5`,children:e}),t]}),(0,y.jsx)(`div`,{className:_(`mt-1 text-xl font-semibold tabular-nums`,i===`danger`&&`text-destructive`),children:typeof n==`number`?n.toLocaleString():n}),(0,y.jsx)(`div`,{className:`mt-0.5 truncate text-[9px] text-muted-foreground`,children:r})]})}function M({health:e}){let{t}=i();return(0,y.jsxs)(`section`,{className:`flex flex-wrap gap-x-5 gap-y-1 border-b border-border/60 bg-success/[0.025] px-4 py-1.5 font-mono text-[9px] text-muted-foreground`,children:[(0,y.jsx)(`span`,{className:`font-sans font-semibold uppercase tracking-wider text-success`,children:t(`activity:chronicle.collectorHealthy`)}),(0,y.jsxs)(`span`,{children:[`ELU`,` `,(0,y.jsxs)(`b`,{className:`text-foreground`,children:[((e.eventLoop?.utilization??0)*100).toFixed(1),`%`]})]}),(0,y.jsxs)(`span`,{children:[`p95 `,(0,y.jsxs)(`b`,{className:`text-foreground`,children:[(e.eventLoop?.delayP95Ms??0).toFixed(1),`ms`]})]}),(0,y.jsxs)(`span`,{children:[`heap`,` `,(0,y.jsxs)(`b`,{className:`text-foreground`,children:[((e.memory?.heapUsedBytes??0)/1048576).toFixed(0),`MB`]})]}),(0,y.jsxs)(`span`,{children:[`queue `,(0,y.jsx)(`b`,{className:`text-foreground`,children:e.chronicle?.pendingEvents??0})]}),(0,y.jsxs)(`span`,{children:[`dropped`,` `,(0,y.jsx)(`b`,{className:_((e.chronicle?.rejectedEvents??0)>0&&`text-destructive`),children:e.chronicle?.rejectedEvents??0})]})]})}function de({event:e,active:t,onClick:n}){let r=e.occurredAt??e.observedAt,i=e.runtime?.modelId??e.scope.agentId??e.runtime?.providerId??`—`,a=e.resource?.path??e.resource?.id??e.correlation.toolCallId??`—`;return(0,y.jsxs)(`button`,{type:`button`,onClick:n,className:_(`grid w-full grid-cols-[92px_minmax(190px,1.25fr)_110px_minmax(180px,1fr)_minmax(140px,.8fr)_24px] items-center gap-3 px-4 py-2.5 text-left hover:bg-muted/45`,t&&`bg-primary/[0.07]`),children:[(0,y.jsx)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:new Date(r).toLocaleTimeString()}),(0,y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,y.jsx)(`span`,{className:_(`h-1.5 w-1.5 shrink-0 rounded-full`,e.outcome===`failure`?`bg-destructive`:e.outcome===`success`?`bg-success`:`bg-primary`)}),(0,y.jsx)(`span`,{className:`truncate font-mono text-[11px] font-medium`,children:e.eventType})]}),(0,y.jsx)(`span`,{className:_(`w-fit rounded px-1.5 py-0.5 text-[9px]`,F(e.outcome)),children:e.outcome??`unknown`}),(0,y.jsx)(`span`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:i}),(0,y.jsx)(`span`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:a}),(0,y.jsx)(s,{className:`h-3.5 w-3.5 text-muted-foreground`})]})}function fe({event:e,graph:n}){let{t:r}=i(),a=(0,v.useMemo)(()=>[[`Scope`,e.scope],[`Correlation`,e.correlation],[`Runtime`,e.runtime],[`Resource`,e.resource],[`Attributes`,e.attributes],[`Tags`,e.tags]],[e]);return(0,y.jsxs)(`div`,{className:`p-4`,children:[(0,y.jsxs)(`div`,{className:`mb-4 rounded-lg border border-border bg-background/60 p-3`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(`span`,{className:_(`h-2 w-2 rounded-full`,e.outcome===`failure`?`bg-destructive`:e.outcome===`success`?`bg-success`:`bg-primary`)}),(0,y.jsx)(`span`,{className:`font-mono text-xs font-semibold`,children:e.eventType})]}),(0,y.jsxs)(`div`,{className:`mt-2 flex gap-4 text-[9px] text-muted-foreground`,children:[(0,y.jsx)(`span`,{children:new Date(e.occurredAt??e.observedAt).toLocaleString()}),(0,y.jsx)(`span`,{children:O(Number(e.durationNs??0))})]})]}),(0,y.jsxs)(`div`,{className:`mb-4 grid grid-cols-2 gap-2`,children:[(0,y.jsx)(N,{icon:(0,y.jsx)(c,{}),label:r(`activity:chronicle.evidenceHash`),value:e.hash.slice(0,16)}),(0,y.jsx)(N,{icon:(0,y.jsx)(h,{}),label:r(`activity:chronicle.sequence`),value:String(e.sequence)})]}),n&&(0,y.jsxs)(`section`,{className:`mb-4`,children:[(0,y.jsxs)(`h3`,{className:`mb-1.5 flex items-center gap-1 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,y.jsx)(t,{className:`h-3 w-3`}),`Lineage · `,n.nodes.length,` nodes · `,n.edges.length,` edges`]}),(0,y.jsx)(`div`,{className:`space-y-1 rounded-md border border-border bg-background/70 p-2`,children:n.edges.slice(0,40).map((e,t)=>(0,y.jsxs)(`div`,{className:`flex items-center gap-2 font-mono text-[9px]`,children:[(0,y.jsx)(`span`,{className:_(`rounded px-1`,e.confidence===`explicit`?`bg-success/10 text-success`:e.confidence===`inferred`?`bg-warning/10 text-warning`:`bg-primary/10 text-primary`),children:e.confidence}),(0,y.jsx)(`span`,{className:`text-muted-foreground`,children:e.kind}),(0,y.jsxs)(`span`,{className:`truncate`,children:[n.nodes.find(t=>t.eventId===e.from)?.eventType,` →`,` `,n.nodes.find(t=>t.eventId===e.to)?.eventType]})]},`${e.from}-${e.to}-${e.kind}-${t}`))}),n.truncated&&(0,y.jsx)(`p`,{className:`mt-1 text-[9px] text-warning`,children:r(`activity:chronicle.lineageTruncatedAtSafetyLimit`)})]}),a.map(([e,t])=>t&&(0,y.jsxs)(`section`,{className:`mb-4`,children:[(0,y.jsx)(`h3`,{className:`mb-1.5 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e}),(0,y.jsx)(`pre`,{className:`overflow-auto rounded-md border border-border bg-background/70 p-3 font-mono text-[9px] leading-relaxed`,children:JSON.stringify(t,null,2)})]},e))]})}function N({icon:e,label:t,value:n}){return(0,y.jsxs)(`div`,{className:`rounded-md border border-border p-2`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-1 text-[8px] uppercase text-muted-foreground`,children:[(0,y.jsx)(`span`,{className:`[&>svg]:h-3 [&>svg]:w-3`,children:e}),t]}),(0,y.jsx)(`div`,{className:`mt-1 truncate font-mono text-[9px]`,children:n})]})}function P({text:e}){return(0,y.jsx)(`div`,{className:`flex h-48 items-center justify-center text-sm text-muted-foreground`,children:e})}function F(e){return e===`failure`?`bg-destructive/10 text-destructive`:e===`success`?`bg-success/10 text-success`:e===`started`?`bg-primary/10 text-primary`:`bg-muted text-muted-foreground`}export{T as ChronicleDashboard};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Fi as t,Nr as n,Oa as r,Pa as i,Qi as a,Qt as o,Ui as s,Vt as c,Xr as l,Yi as u,ar as d,dt as f,in as p,ir as m,la as h,lt as g,ri as _,si as v,vn as y,y as b,yt as x,za as S}from"./vendor-BuarzSSb.js";import"./i18n-COgumVF5.js";import{a as C,i as w,n as ee,o as T,r as E,t as D}from"./monaco-BLUV5g0U.js";import{t as te}from"./ws-client-TTMa0XaT.js";import{t as O}from"./utils-B-9lSDIn.js";import{i as ne}from"./codemap-activity-store-DQfjo7-j.js";import{I as re,N as k,c as ie,j as A,p as ae}from"./stores-ChEnUmic.js";import{o as j}from"./view-navigation-DIDEcp4V.js";import{O as M,v as oe,y as N}from"./index-CtpViiZy.js";import{t as P}from"./empty-state-RRSqQaCk.js";import{t as F}from"./monaco-theme-DSeCDzQy.js";var I={ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,json:`json`,css:`css`,html:`html`,svg:`xml`,md:`markdown`,yml:`yaml`,yaml:`yaml`,toml:`toml`,sh:`shell`,bash:`shell`,ps1:`powershell`,py:`python`,rs:`rust`,go:`go`,rb:`ruby`,java:`java`,c:`c`,cpp:`cpp`,h:`c`,hpp:`cpp`,sql:`sql`,xml:`xml`},L=Array.from(new Set(Object.values(I))).filter(e=>e!==`plaintext`),R=12e3,z=4e3,se=5e3,B=1e4;function V(e){return I[e.split(`.`).pop()?.toLowerCase()??``]??`plaintext`}function H(e){return e.match(/([A-Za-z_$][\w$]*)$/)?.[1]??``}function U(e,t){return e.triggerCharacter?!0:t.length>=3}function W(e,t){return e.triggerCharacter===`.`||!e.triggerCharacter&&/^(findBy|findAllBy|create|update|delete|remove|get[A-Z_]|set[A-Z_]|use[A-Z_])/.test(t)}function G(e){return[e.filePath,e.language,e.lineNumber,e.column,e.versionId??``,e.triggerCharacter??``,e.linePrefix.slice(-160),e.suffix.slice(0,160)].join(`\0`)}var K=e(S(),1),q=g();function ce(e){let t=new Set,n=new Set,r=new Set,i=new Set,a=new Set,o,s;for(let c of e)c.sessionId&&t.add(c.sessionId),c.taskId&&n.add(c.taskId),c.boardId&&r.add(c.boardId),c.toolName&&i.add(c.toolName),c.modelId&&a.add(c.modelId),(!o||c.occurredAt<o)&&(o=c.occurredAt),(!s||c.occurredAt>s)&&(s=c.occurredAt);return{mutations:e.length,sessions:t.size,tasks:n.size,boards:r.size,tools:[...i],models:[...a],firstAt:o,lastAt:s}}var J=150,le=224,ue=38,Y=/(write|edit|update|create|delete|rename|modified|changed)/i;function X(e){return e.replace(/\\/g,`/`).replace(/^\.\//,``).replace(/\/{2,}/g,`/`).toLowerCase()}function Z(e,t){let n=X(e),r=X(t);return n===r||n.endsWith(`/${r}`)||r.endsWith(`/${n}`)}function de(e,t=Date.now()){let n=e.filter(e=>t-e.at<=30*6e4),r=n.filter(e=>Y.test(e.action)),i=new Set(n.map(e=>e.sessionId).filter(Boolean)).size,a=new Set(n.map(e=>e.actor).filter(Boolean)).size,o=new Set(n.map(e=>e.taskId).filter(Boolean)).size;return{level:r.length>=8||r.length>=4&&a>=3?`churn`:r.length>0?`active`:`quiet`,mutationCount:r.length,sessionCount:i,actorCount:a,taskCount:o}}function Q(e){return typeof e==`string`&&e.length>0?e:void 0}function fe(e){let t=Date.parse(e.occurredAt??e.observedAt);return Number.isFinite(t)?t:Date.now()}function pe(e){let t=e.attributes??{},n=Q(t.operation)??e.eventType,r=e.scope.agentId,i=e.runtime?.providerId,a=e.runtime?.modelId;return{id:e.eventId,at:fe(e),action:n,actor:r??i??Q(t.actor)??`external`,source:Q(t.source)??e.tags?.collector??`chronicle`,summary:[e.eventType,i&&a?`${i}/${a}`:i,e.outcome].filter(Boolean).join(` · `),sessionId:e.scope.sessionId,agentId:r,taskId:e.scope.taskId??Q(t.taskId),boardId:Q(t.boardId)??e.scope.boardId,tool:Q(t.toolName),status:e.outcome,raw:e}}function me(e){return{id:e.id??`${e.filePath}:${e.timestamp}:${e.type}`,at:e.timestamp,action:e.type,actor:e.agentName??e.agent??e.agentId??`external`,source:e.source??`live`,summary:e.summary,sessionId:e.sessionId,agentId:e.agentId,tool:e.toolName,status:e.status,raw:e}}function he(e){let t=new Set;return e.sort((e,t)=>t.at-e.at).filter(e=>{let n=`${e.id}:${e.at}`;return t.has(n)?!1:(t.add(n),!0)})}function ge(e){return e?e.split(/\r?\n/).length:0}function _e(e){return new TextEncoder().encode(e).length}function ve(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function ye(e){return e.length>18?`${e.slice(0,8)}…${e.slice(-6)}`:e}function be(e,t){let n=N(e,t);return n?{added:n.filter(e=>e.kind===`add`).length,removed:n.filter(e=>e.kind===`del`).length,large:!1}:{added:0,removed:0,large:!0}}function xe({file:e}){let{t}=i(),[o,l]=(0,K.useState)(!0),[f,p]=(0,K.useState)(le),[m,h]=(0,K.useState)(`overview`),[g,b]=(0,K.useState)([]),[x,S]=(0,K.useState)([]),[C,w]=(0,K.useState)(!1),[ee,T]=(0,K.useState)(null),[E,D]=(0,K.useState)(null),k=(0,K.useRef)(null),A=re(e=>e.wsUrl),j=ne(e=>e.history),M=ne(e=>e.activeOperations),N=ae(e=>e.activeBoard),P=ie(e=>e.snapshot),F=(0,K.useMemo)(()=>te(A),[A]),I=(0,K.useCallback)(()=>{T(null),w(!0),typeof F.getGitDiff==`function`&&F.getGitDiff(e.path);let t=typeof F.supportsCapability==`function`?F.supportsCapability.bind(F):null;t?.(`chronicle.query`)?F.send({type:`chronicle.query`,payload:{query:{path:e.path,resourceKind:`file`,order:`desc`,limit:150}}}):w(!1),t?.(`chronicle.metrics`)&&F.send({type:`chronicle.metrics`,payload:{view:`files`,path:e.path,limit:1e3}})},[F,e.path]);(0,K.useEffect)(()=>{b([]),S([]),D(null);let t=F.on(`chronicle.query_result`,t=>{if(t.type!==`chronicle.query_result`)return;let n=t.payload.events.filter(t=>t.resource?.path&&Z(t.resource.path,e.path));t.payload.events.length>0&&n.length===0||(b(n),w(!1))}),n=F.on(`chronicle.metrics_result`,t=>{t.type!==`chronicle.metrics_result`||t.payload.view!==`files`||S(t.payload.data.filter(t=>Z(t.path,e.path)))}),r=F.on(`chronicle.error`,e=>{e.type===`chronicle.error`&&(T(e.payload.message),w(!1))}),i=F.on(`git.diff`,t=>{if(t.type!==`git.diff`||!Z(t.payload.path,e.path))return;let n=t.payload;if(n.error||n.binary||n.tooLarge){D({text:e.savedContent,available:!1,error:n.error});return}D({text:n.oldText??``,available:!0})});return I(),()=>{t(),n(),r(),i()}},[F,e.path,e.savedContent,I]),(0,K.useEffect)(()=>{let e=e=>{if(!k.current)return;let t=k.current.startY-e.clientY,n=Math.max(J,Math.floor(window.innerHeight*.62));p(Math.min(n,Math.max(J,k.current.startHeight+t)))},t=()=>{k.current=null,document.body.style.cursor=``,document.body.style.userSelect=``};return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t)}},[]);let L=(0,K.useMemo)(()=>{let t=[];for(let[n,r]of j)Z(n,e.path)&&t.push(...r);for(let n of M.values())t.push(...n.filter(t=>Z(t.filePath,e.path)));return t},[M,e.path,j]),R=(0,K.useMemo)(()=>he([...L.map(me),...g.map(pe)]),[g,L]),z=(0,K.useMemo)(()=>de(R),[R]),se=(0,K.useMemo)(()=>ce(x),[x]),B=E?.text??e.savedContent,V=(0,K.useMemo)(()=>be(B,e.content),[B,e.content]),H=(0,K.useMemo)(()=>[...new Set(R.map(e=>e.sessionId).filter(e=>!!e))],[R]),U=(0,K.useMemo)(()=>[...new Set(R.map(e=>e.actor).filter(Boolean))],[R]),W=(0,K.useMemo)(()=>[...new Set(R.map(e=>e.taskId).filter(e=>!!e))],[R]),G=(0,K.useCallback)(e=>{let t=N?.tasks.find(t=>t.id===e),n=P?.tasks.find(t=>t.id===e||t.shortId===e);return t?.title??n?.title??e},[N,P]),Y=e=>{o||l(!0),k.current={startY:e.clientY,startHeight:o?f:J},document.body.style.cursor=`ns-resize`,document.body.style.userSelect=`none`},X=[{id:`overview`,label:t(`activity:fileActivity.overview`),icon:(0,q.jsx)(r,{})},{id:`changes`,label:t(`activity:fileActivity.changes`),icon:(0,q.jsx)(_,{})},{id:`context`,label:t(`activity:fileActivity.context`),icon:(0,q.jsx)(d,{})},{id:`logs`,label:t(`activity:fileActivity.logs`),icon:(0,q.jsx)(c,{})}];return(0,q.jsxs)(`section`,{className:`flex shrink-0 flex-col overflow-hidden border-t border-border bg-card/95 shadow-[0_-10px_30px_hsl(var(--background)/0.24)] backdrop-blur`,style:{height:o?f:ue},"data-testid":`file-activity-drawer`,children:[(0,q.jsx)(`button`,{type:`button`,"aria-label":t(`activity:fileActivity.resizeHint`),className:`group relative block h-2 w-full cursor-ns-resize touch-none`,onPointerDown:Y,onDoubleClick:()=>{l(!0),p(le)},title:t(`activity:fileActivity.resizeHint`),children:(0,q.jsx)(`span`,{className:`absolute left-1/2 top-0.5 h-1 w-10 -translate-x-1/2 rounded-full bg-border transition-colors group-hover:bg-primary/60`})}),(0,q.jsxs)(`header`,{className:`flex h-[30px] min-w-0 items-center gap-2 border-b border-border/70 px-2.5`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:()=>l(e=>!e),className:`inline-flex min-w-0 items-center gap-1.5 rounded px-1.5 py-1 text-[11px] font-semibold hover:bg-muted`,"aria-expanded":o,children:[(0,q.jsx)(v,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,q.jsx)(`span`,{className:`truncate`,children:t(`activity:fileActivity.title`)}),o?(0,q.jsx)(a,{className:`h-3 w-3`}):(0,q.jsx)(u,{className:`h-3 w-3`})]}),(0,q.jsx)(`span`,{className:`hidden h-3 w-px bg-border sm:block`}),(0,q.jsx)(Se,{label:`${ge(e.content)} ${t(`activity:fileActivity.lines`)}`}),(0,q.jsx)(Se,{label:ve(_e(e.content))}),!V.large&&(V.added>0||V.removed>0)&&(0,q.jsxs)(`span`,{className:`hidden items-center gap-1 font-mono text-[10px] md:flex`,children:[(0,q.jsxs)(`span`,{className:`text-success`,children:[`+`,V.added]}),(0,q.jsxs)(`span`,{className:`text-destructive`,children:[`−`,V.removed]})]}),(0,q.jsxs)(`span`,{className:O(`ml-auto inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[9px] font-semibold uppercase tracking-wide`,z.level===`churn`&&`bg-destructive/10 text-destructive`,z.level===`active`&&`bg-warning/10 text-warning`,z.level===`quiet`&&`bg-success/10 text-success`),children:[(0,q.jsx)(s,{className:`h-2.5 w-2.5`}),t(`activity:fileActivity.level.${z.level}`)]}),(0,q.jsx)(`span`,{className:`hidden text-[9px] text-muted-foreground lg:inline`,children:t(`activity:fileActivity.evidenceCount`,{count:R.length})}),o&&(0,q.jsx)(`button`,{type:`button`,onClick:I,className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,title:t(`activity:fileActivity.refresh`),children:(0,q.jsx)(y,{className:O(`h-3.5 w-3.5`,C&&`animate-spin`)})})]}),o&&(0,q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,q.jsxs)(`nav`,{className:`flex shrink-0 items-center gap-0.5 border-b border-border/60 bg-muted/20 px-2`,children:[X.map(e=>(0,q.jsxs)(`button`,{type:`button`,onClick:()=>h(e.id),className:O(`inline-flex h-7 items-center gap-1.5 border-b-2 px-2 text-[10px] transition-colors [&>svg]:h-3 [&>svg]:w-3`,m===e.id?`border-primary font-medium text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`),children:[e.icon,e.label]},e.id)),ee&&(0,q.jsx)(`span`,{className:`ml-auto truncate px-2 text-[9px] text-warning`,children:ee})]}),(0,q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[m===`overview`&&(0,q.jsx)(Ce,{analysis:z,lifetime:se,records:R,sessions:H,agents:U,tasks:W,taskLabel:G}),m===`changes`&&(0,q.jsxs)(`div`,{className:`h-full min-h-[120px] p-2`,children:[(0,q.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2 text-[9px] text-muted-foreground`,children:[(0,q.jsx)(n,{className:`h-3 w-3`}),(0,q.jsx)(`span`,{children:E?.available?t(`activity:fileActivity.gitToBuffer`):t(`activity:fileActivity.savedToBuffer`)}),e.dirty&&(0,q.jsx)(`span`,{className:`rounded bg-warning/10 px-1.5 py-0.5 text-warning`,children:t(`activity:fileActivity.unsaved`)}),E?.error&&(0,q.jsx)(`span`,{className:`truncate text-warning`,children:E.error})]}),(0,q.jsx)(`div`,{className:`h-[calc(100%-24px)] min-h-[90px]`,children:(0,q.jsx)(oe,{oldText:B,newText:e.content,caption:e.path,fill:!0})})]}),m===`context`&&(0,q.jsx)(Te,{sessions:H,agents:U,tasks:W,records:R,taskLabel:G,boardTitle:N?.title??P?.title}),m===`logs`&&(0,q.jsx)(Oe,{records:R,loading:C})]})]})]})}function Se({label:e}){return(0,q.jsx)(`span`,{className:`hidden whitespace-nowrap font-mono text-[9px] text-muted-foreground sm:inline`,children:e})}function Ce({analysis:e,lifetime:t,records:n,sessions:r,agents:a,tasks:s,taskLabel:c}){let{t:l}=i();return(0,q.jsxs)(`div`,{className:`grid min-h-full grid-cols-1 gap-2 p-2 lg:grid-cols-[minmax(360px,.9fr)_minmax(420px,1.35fr)]`,children:[(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsx)(`div`,{className:`grid grid-cols-4 gap-1.5`,children:[{label:l(`activity:fileActivity.mutations30m`),value:e.mutationCount,icon:(0,q.jsx)(_,{})},{label:l(`activity:fileActivity.sessions`),value:r.length,icon:(0,q.jsx)(x,{})},{label:l(`activity:fileActivity.actors`),value:a.length,icon:(0,q.jsx)(h,{})},{label:l(`activity:fileActivity.linkedWork`),value:s.length,icon:(0,q.jsx)(d,{})}].map(e=>(0,q.jsxs)(`div`,{className:`rounded-md border border-border/70 bg-background/45 px-2 py-1.5`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1 text-[9px] text-muted-foreground [&>svg]:h-3 [&>svg]:w-3`,children:[e.icon,(0,q.jsx)(`span`,{className:`truncate`,children:e.label})]}),(0,q.jsx)(`div`,{className:`mt-0.5 font-mono text-sm font-semibold`,children:e.value})]},e.label))}),t.mutations>0&&(0,q.jsx)(we,{lifetime:t}),(0,q.jsxs)(`div`,{className:O(`flex items-start gap-2 rounded-md border px-2.5 py-2 text-[10px]`,e.level===`churn`?`border-destructive/25 bg-destructive/[0.055]`:`border-border/70 bg-background/45`),children:[(0,q.jsx)(o,{className:O(`mt-0.5 h-3.5 w-3.5 shrink-0`,e.level===`churn`?`text-destructive`:`text-primary`)}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`font-semibold`,children:l(`activity:fileActivity.analysisTitle.${e.level}`)}),(0,q.jsx)(`p`,{className:`mt-0.5 text-muted-foreground`,children:l(`activity:fileActivity.analysisBody.${e.level}`,{mutations:e.mutationCount,actors:e.actorCount,sessions:e.sessionCount})})]})]}),s.length>0&&(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 text-[9px]`,children:[(0,q.jsxs)(`span`,{className:`text-muted-foreground`,children:[l(`activity:fileActivity.workLinks`),`:`]}),s.slice(0,4).map(e=>(0,q.jsx)(`span`,{className:`max-w-[180px] truncate rounded border border-primary/20 bg-primary/5 px-1.5 py-0.5 text-primary`,title:e,children:c(e)},e))]})]}),(0,q.jsxs)(`div`,{className:`min-w-0 rounded-md border border-border/70 bg-background/35`,children:[(0,q.jsx)(`div`,{className:`border-b border-border/60 px-2.5 py-1.5 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:l(`activity:fileActivity.recentActivity`)}),(0,q.jsx)(`div`,{className:`divide-y divide-border/40`,children:n.length===0?(0,q.jsx)($,{text:l(`activity:fileActivity.noEvidence`)}):n.slice(0,5).map(e=>(0,q.jsx)(ke,{record:e},`${e.id}:${e.at}`))})]})]})}function we({lifetime:e}){let{t}=i(),n=[{value:e.mutations,label:t(`activity:fileActivity.lifetimeChanges`)},{value:e.sessions,label:t(`activity:fileActivity.lifetimeSessions`)},{value:e.tasks,label:t(`activity:fileActivity.lifetimeTasks`)},{value:e.boards,label:t(`activity:fileActivity.lifetimeBoards`)}],r=e.firstAt?new Date(e.firstAt).toLocaleDateString():void 0;return(0,q.jsxs)(`div`,{className:`rounded-md border border-primary/15 bg-primary/[0.03] px-2.5 py-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[9px] font-semibold uppercase tracking-wider text-primary [&>svg]:h-3 [&>svg]:w-3`,children:[(0,q.jsx)(v,{}),t(`activity:fileActivity.lifetimeTitle`)]}),(0,q.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:[n.map(e=>(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`b`,{className:`text-foreground`,children:e.value.toLocaleString()}),` `,e.label]},e.label)),r&&(0,q.jsx)(`span`,{children:t(`activity:fileActivity.lifetimeSince`,{date:r})})]}),e.tools.length>0&&(0,q.jsx)(`div`,{className:`mt-1 truncate font-mono text-[8px] text-muted-foreground`,title:e.tools.join(`, `),children:t(`activity:fileActivity.lifetimeTools`,{tools:e.tools.slice(0,6).join(`, `)})})]})}function Te({sessions:e,agents:t,tasks:n,records:r,taskLabel:a,boardTitle:o}){let{t:s}=i();return(0,q.jsxs)(`div`,{className:`grid min-h-full grid-cols-1 divide-y divide-border/50 md:grid-cols-3 md:divide-x md:divide-y-0`,children:[(0,q.jsx)(Ee,{icon:(0,q.jsx)(x,{}),title:s(`activity:fileActivity.sessions`),empty:s(`activity:fileActivity.noSessions`),children:e.map(e=>(0,q.jsx)(De,{title:ye(e),subtitle:`${r.filter(t=>t.sessionId===e).length} ${s(`activity:fileActivity.events`)}`,raw:e},e))}),(0,q.jsx)(Ee,{icon:(0,q.jsx)(h,{}),title:s(`activity:fileActivity.actors`),empty:s(`activity:fileActivity.noActors`),children:t.map(e=>(0,q.jsx)(De,{title:e,subtitle:`${r.filter(t=>t.actor===e).length} ${s(`activity:fileActivity.events`)}`},e))}),(0,q.jsx)(Ee,{icon:(0,q.jsx)(d,{}),title:s(`activity:fileActivity.workLinks`),empty:s(`activity:fileActivity.noWorkLinks`),children:n.map(e=>(0,q.jsx)(De,{title:a(e),subtitle:o??s(`activity:fileActivity.taskOrTodo`),raw:e},e))})]})}function Ee({icon:e,title:t,empty:n,children:r}){let i=Array.isArray(r)?r.length>0:!!r;return(0,q.jsxs)(`section`,{className:`min-w-0 p-2`,children:[(0,q.jsxs)(`h3`,{className:`mb-1.5 flex items-center gap-1.5 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground [&>svg]:h-3 [&>svg]:w-3`,children:[e,t]}),(0,q.jsx)(`div`,{className:`space-y-1`,children:i?r:(0,q.jsx)($,{text:n})})]})}function De({title:e,subtitle:t,raw:n}){return(0,q.jsxs)(`div`,{className:`rounded-md border border-border/60 bg-background/45 px-2 py-1.5`,title:n,children:[(0,q.jsx)(`div`,{className:`truncate text-[10px] font-medium`,children:e}),(0,q.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-[8px] text-muted-foreground`,children:t})]})}function Oe({records:e,loading:t}){let{t:n}=i();return t&&e.length===0?(0,q.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-[10px] text-muted-foreground`,children:[(0,q.jsx)(m,{className:`h-3.5 w-3.5 animate-spin`}),n(`activity:fileActivity.loadingEvidence`)]}):e.length===0?(0,q.jsx)($,{text:n(`activity:fileActivity.noEvidence`)}):(0,q.jsx)(`div`,{className:`divide-y divide-border/40`,children:e.map(e=>(0,q.jsx)(ke,{record:e,raw:!0},`${e.id}:${e.at}`))})}function ke({record:e,raw:t=!1}){let n=(0,q.jsxs)(`div`,{className:`grid grid-cols-[62px_74px_minmax(90px,.7fr)_minmax(160px,1.5fr)] items-center gap-2 text-[9px]`,children:[(0,q.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:new Date(e.at).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}),(0,q.jsx)(`span`,{className:O(`w-fit rounded px-1.5 py-0.5 font-mono`,Y.test(e.action)?`bg-warning/10 text-warning`:`bg-primary/10 text-primary`),children:e.action}),(0,q.jsx)(`span`,{className:`truncate`,title:e.agentId,children:e.actor}),(0,q.jsx)(`span`,{className:`truncate text-muted-foreground`,title:e.summary,children:e.summary})]});return t?(0,q.jsxs)(`details`,{className:`group cursor-pointer px-2.5 py-1.5`,children:[(0,q.jsx)(`summary`,{className:`list-none [&::-webkit-details-marker]:hidden`,children:n}),(0,q.jsx)(`pre`,{className:`mt-1.5 max-h-48 overflow-auto rounded border border-border/60 bg-background/60 p-2 font-mono text-[8px] leading-relaxed text-muted-foreground`,children:JSON.stringify(e.raw,null,2)})]}):(0,q.jsx)(`div`,{className:`px-2.5 py-1.5`,children:n})}function $({text:e}){return(0,q.jsx)(`div`,{className:`px-3 py-3 text-center text-[10px] text-muted-foreground`,children:e})}ee.config({monaco:D});function Ae(e){switch(e){case`method`:return T.CompletionItemKind.Method;case`function`:return T.CompletionItemKind.Function;case`constructor`:return T.CompletionItemKind.Constructor;case`field`:return T.CompletionItemKind.Field;case`variable`:return T.CompletionItemKind.Variable;case`class`:return T.CompletionItemKind.Class;case`interface`:return T.CompletionItemKind.Interface;case`module`:return T.CompletionItemKind.Module;case`property`:return T.CompletionItemKind.Property;case`unit`:return T.CompletionItemKind.Unit;case`value`:return T.CompletionItemKind.Value;case`enum`:return T.CompletionItemKind.Enum;case`keyword`:return T.CompletionItemKind.Keyword;case`snippet`:return T.CompletionItemKind.Snippet;case`file`:return T.CompletionItemKind.File;case`reference`:return T.CompletionItemKind.Reference;default:return T.CompletionItemKind.Text}}function je(){let e=A(e=>e.openFiles),n=A(e=>e.activeFilePath),r=A(e=>e.setActiveFile),i=A(e=>e.closeFile);return e.length===0?null:(0,q.jsx)(`div`,{className:`flex items-center border-b bg-muted/40 overflow-x-auto shrink-0`,children:e.map(e=>{let a=e.path===n,o=e.path.split(`/`).pop()??e.path;return(0,q.jsxs)(`button`,{type:`button`,onClick:()=>r(e.path),onMouseDown:t=>{t.button===1&&(t.preventDefault(),i(e.path))},className:O(`group flex items-center gap-1.5 px-3 py-1.5 text-[11px] border-r whitespace-nowrap min-w-0 max-w-[180px] transition-colors`,a?`bg-background border-t-2 border-t-primary text-foreground -mb-px`:`text-muted-foreground hover:bg-muted/60 hover:text-foreground`),title:e.path,children:[e.dirty&&(0,q.jsx)(t,{className:`h-2 w-2 fill-current text-primary shrink-0`}),(0,q.jsx)(`span`,{className:`truncate`,children:o}),(0,q.jsx)(f,{className:O(`h-3 w-3 shrink-0 rounded-sm hover:bg-muted-foreground/20 opacity-0 group-hover:opacity-100 transition-opacity`,a&&`opacity-100`),onClick:t=>{t.stopPropagation(),i(e.path)}})]},e.path)})})}function Me(){let{t:e}=i(),t=A(e=>e.openFiles),n=A(e=>e.activeFilePath),r=A(e=>e.updateContent),{theme:a}=M(),o=(0,K.useRef)(null),s=(0,K.useRef)(n),c=(0,K.useRef)(new Map),u=(0,K.useMemo)(()=>t.find(e=>e.path===n)??null,[t,n]),d=n?V(n):`plaintext`,f=F(),[m,h]=(0,K.useState)(!1);(0,K.useEffect)(()=>{s.current=n},[n]),(0,K.useEffect)(()=>{let e=F();C.setTheme(e)},[a]),(0,K.useEffect)(()=>{let e=L.map(e=>T.registerCompletionItemProvider(e,{triggerCharacters:[`.`,`_`],provideCompletionItems:async(e,t,n,r)=>{let i=s.current;if(!i)return{suggestions:[]};let a=e.getOffsetAt(t),o=e.getValue(),l=o.slice(Math.max(0,a-R),a),u=o.slice(a,a+z),d=e.getLineContent(t.lineNumber).slice(0,Math.max(0,t.column-1)),f=H(d),p={triggerCharacter:n.triggerCharacter,triggerKind:n.triggerKind};if(!U(p,f))return{suggestions:[]};let m=`cmp_${Date.now()}_${Math.random().toString(36).slice(2)}`,h=e.getWordUntilPosition(t),g={startLineNumber:t.lineNumber,endLineNumber:t.lineNumber,startColumn:h.startColumn,endColumn:t.column},_=te(re.getState().wsUrl),v=e=>e.map((e,t)=>({label:e.label,kind:Ae(e.kind),insertText:e.insertText,detail:e.detail??(e.source?`WrongStack ${e.source}`:void 0),documentation:e.documentation,sortText:e.sortText??`${String(t).padStart(3,`0`)}-${e.label}`,range:g,insertTextRules:e.kind===`snippet`?T.CompletionItemInsertTextRule.InsertAsSnippet:void 0})),y=G({filePath:i,language:e.getLanguageId(),lineNumber:t.lineNumber,column:t.column,versionId:e.getVersionId(),triggerCharacter:n.triggerCharacter,linePrefix:d,suffix:u}),b=c.current.get(y);return b&&b.expiresAt>Date.now()?{suggestions:v(b.items)}:await new Promise(a=>{let s=!1,d=()=>{},h=null,g,b=e=>{s||(s=!0,d(),g!==void 0&&window.clearTimeout(g),h?.dispose(),a({suggestions:e}))};d=_.on(`completion.result`,e=>{let t=e;t.payload.requestId===m&&(c.current.set(y,{expiresAt:Date.now()+B,items:t.payload.items}),b(v(t.payload.items)))}),g=window.setTimeout(()=>b([]),se),h=r.onCancellationRequested(()=>b([])),_.requestCompletion({requestId:m,filePath:i,language:e.getLanguageId(),lineNumber:t.lineNumber,column:t.column,content:o.length<=5e5?o:void 0,prefix:l,suffix:u,triggerCharacter:n.triggerCharacter,triggerKind:n.triggerKind,allowLlm:W(p,f)})})}}));return()=>{e.forEach(e=>{e.dispose()})}},[]);let g=(0,K.useCallback)(()=>{let e=o.current;if(!e)return null;let t=e.getSelection();if(!t||t.isEmpty())return null;let n=e.getModel();if(!n)return null;let r=n.getValueInRange(t);return r.trim()?{content:r,startLine:t.startLineNumber,endLine:t.endLineNumber}:null},[]),_=(0,K.useCallback)(()=>{j(`chat`),requestAnimationFrame(()=>{document.querySelector(`[data-chat-textarea]`)?.focus()})},[]),v=(0,K.useCallback)(()=>{let e=s.current;if(!e)return;let t=g();t&&(k.getState().addRef({kind:`snippet`,path:e,startLine:t.startLine,endLine:t.endLine,content:t.content}),_())},[g,_]),y=(0,K.useCallback)(()=>{let e=s.current;e&&(k.getState().addRef({kind:`file`,path:e}),_())},[_]),x=(0,K.useCallback)(t=>{o.current=t,C.setTheme(F()),t.onDidChangeCursorSelection(()=>{let e=t.getSelection();h(!!e&&!e.isEmpty())}),t.addAction({id:`wrongstack-send-to-chat`,label:e(`activity:codeEditor.sendSelectionAction`),contextMenuGroupId:`wrongstack`,contextMenuOrder:0,precondition:void 0,keybindings:[w.CtrlCmd|w.Shift|E.KeyL],run:e=>{let t=e.getSelection();t&&!t.isEmpty()?v():y()}})},[v,y]),S=(0,K.useCallback)(e=>{n&&e!==void 0&&r(n,e)},[n,r]);return(0,K.useEffect)(()=>{let e=e=>{let t=e.ctrlKey||e.metaKey,r=e.target?.tagName?.toLowerCase()===`textarea`||e.target?.closest(`.monaco-editor`)!==null;!t||!r||(e.key.toLowerCase()===`s`&&(e.preventDefault(),window.dispatchEvent(new CustomEvent(`wrongstack:save-file`,{detail:{filePath:n}}))),e.key.toLowerCase()===`w`&&(e.preventDefault(),n&&A.getState().closeFile(n)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),t.length===0?(0,q.jsx)(P,{title:e(`activity:codeEditor.noFilesOpen`),description:e(`activity:codeEditor.selectToEdit`)}):(0,q.jsxs)(`div`,{className:`flex h-full min-w-0 flex-col overflow-hidden`,children:[(0,q.jsx)(je,{}),(0,q.jsxs)(`div`,{className:`relative min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(m||u)&&(0,q.jsx)(`div`,{className:`absolute top-2 right-2 z-10 flex items-center gap-1 rounded-lg border border-border bg-popover/95 backdrop-blur shadow-md p-1`,children:(0,q.jsxs)(`button`,{type:`button`,onClick:m?v:y,className:`inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-[11px] text-foreground hover:bg-accent transition-colors`,title:e(m?`activity:codeEditor.sendSelectedTitle`:`activity:codeEditor.mentionFileTitle`),children:[m?(0,q.jsx)(p,{className:`h-3 w-3`}):(0,q.jsx)(l,{className:`h-3 w-3`}),(0,q.jsx)(`span`,{children:e(m?`activity:codeEditor.sendToChat`:`activity:codeEditor.mentionFile`)})]})}),u?(0,q.jsx)(b,{language:d,value:u.content,onChange:S,theme:f,onMount:x,loading:(0,q.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,q.jsx)(`span`,{className:`text-[11px] text-muted-foreground animate-pulse`,children:e(`activity:codeEditor.loadingEditor`)})}),options:{minimap:{enabled:!1},fontSize:13,fontFamily:`'IBM Plex Mono', 'Cascadia Code', 'Fira Code', 'JetBrains Mono', monospace`,lineNumbers:`on`,renderWhitespace:`selection`,scrollBeyondLastLine:!1,wordWrap:`off`,tabSize:2,smoothScrolling:!0,cursorBlinking:`smooth`,cursorSmoothCaretAnimation:`on`,bracketPairColorization:{enabled:!0},"semanticHighlighting.enabled":!0,automaticLayout:!0,padding:{top:8}}},u.path):(0,q.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,q.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e(`activity:codeEditor.selectTab`)})})]}),u&&(0,q.jsx)(xe,{file:u})]})}export{Me as CodeEditor};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Ln as t,Nr as n,Oa as r,Pa as i,Pt as a,Qi as o,Rn as s,Tr as c,Vr as l,Wr as u,Xi as d,Zt as f,_ as p,a as m,ai as h,an as g,c as _,ca as ee,di as v,dt as y,f as b,g as te,gr as x,h as ne,i as re,ir as S,ja as ie,kn as C,lt as w,m as ae,n as oe,p as se,r as ce,s as T,u as le,wn as E,xa as ue,yn as D,za as de,zn as O}from"./vendor-BuarzSSb.js";import"./i18n-COgumVF5.js";import{t as k}from"./utils-B-9lSDIn.js";import{i as fe,r as pe,t as me}from"./codemap-activity-store-DQfjo7-j.js";import{t as he}from"./codemap-index-store-COStDU-8.js";var A=e(de(),1),ge=4096,j=new Map;function M(e){let t=j.get(e);if(t!==void 0)return t;let n=e.replace(/\\/g,`/`).replace(/^\.\//,``).toLocaleLowerCase();for(;j.size>=ge;){let e=j.keys().next().value;if(e===void 0)break;j.delete(e)}return j.set(e,n),n}function N(e){return e.level===`packages`?`packages`:e.level===`files`?`files:${e.package}`:`symbols:${e.file}`}function _e(e){return e.level===`packages`?`/api/codemap/packages`:e.level===`files`?`/api/codemap/files?package=${encodeURIComponent(e.package)}`:`/api/codemap/symbols?file=${encodeURIComponent(e.file)}`}function ve(e,t,n){let r=new Map(e.nodes.map(e=>[e.id,e])),i=[];for(let a of e.edges){let e=n===`incoming`?a.target===t?a.source:void 0:a.source===t?a.target:void 0;if(!e)continue;let o=r.get(e);o&&i.push({node:o,edge:a})}return i.sort((e,t)=>t.edge.weight-e.edge.weight||e.node.label.localeCompare(t.node.label))}function ye(e,t){let n=new Set([t]);for(let r of e.edges)r.source===t&&n.add(r.target),r.target===t&&n.add(r.source);return n}function be(e,t){let n=new Map(e.nodes.map(e=>[e.id,0]));for(let r of e.edges)!t.has(r.source)||!t.has(r.target)||(n.set(r.source,(n.get(r.source)??0)+r.weight),r.target!==r.source&&n.set(r.target,(n.get(r.target)??0)+r.weight));return n}function P(e){let t=new Set(e.nodes.map(e=>e.id)),n=be(e,t),r=new Map(e.nodes.map(e=>[e.id,0])),i=new Map;for(let n of e.edges){if(!t.has(n.source)||!t.has(n.target)||n.source===n.target)continue;r.set(n.target,(r.get(n.target)??0)+1);let e=i.get(n.source)??[];e.push(n.target),i.set(n.source,e)}let a=new Map,o=e.nodes.filter(e=>(r.get(e.id)??0)===0).sort((e,t)=>(n.get(t.id)??0)-(n.get(e.id)??0)).map(e=>e.id);o.length===0&&e.nodes[0]&&o.push(e.nodes[0].id);for(let e of o)a.set(e,0);let s=new Set,c=0;for(;c<o.length;){let e=o[c++];if(!s.has(e)){s.add(e);for(let t of i.get(e)??[])a.set(t,Math.max(a.get(t)??0,Math.min((a.get(e)??0)+1,7))),r.set(t,(r.get(t)??1)-1),(r.get(t)??0)<=0&&o.push(t)}}let l=e.nodes.filter(e=>!a.has(e.id)).sort((e,t)=>(n.get(t.id)??0)-(n.get(e.id)??0));l.forEach((e,t)=>{a.set(e.id,t%Math.min(4,Math.max(1,l.length)))});let u=new Map;for(let t of e.nodes){let e=a.get(t.id)??0,n=u.get(e)??[];n.push(t),u.set(e,n)}for(let e of u.values())e.sort((e,t)=>Number(e.external)-Number(t.external)||(n.get(t.id)??0)-(n.get(e.id)??0)||e.label.localeCompare(t.label));let d=Math.max(1,...[...u.values()].map(e=>e.length))*160,f=[];for(let[e,t]of[...u.entries()].sort(([e],[t])=>e-t)){let n=(d-t.length*160)/2;t.forEach((t,r)=>{f.push({node:t,position:{x:e*386,y:n+r*160}})})}return f}function xe(e,t){if(e.nodes.length===0)return[];let n=be(e,new Set(e.nodes.map(e=>e.id))),r=e.nodes.find(e=>e.id===t)??[...e.nodes].sort((e,t)=>(n.get(t.id)??0)-(n.get(e.id)??0))[0],i=ye(e,r.id);i.delete(r.id);let a=e.nodes.filter(e=>i.has(e.id)),o=e.nodes.filter(e=>e.id!==r.id&&!i.has(e.id)),s=[{node:r,position:{x:0,y:0}}],c=(e,t,n)=>{e.forEach((r,i)=>{let a=n+Math.PI*2*i/Math.max(1,e.length);s.push({node:r,position:{x:Math.cos(a)*t,y:Math.sin(a)*t}})})};c(a,Math.max(330,a.length*34),-Math.PI/2);for(let e=0;e<o.length;e+=18)c(o.slice(e,e+18),620+Math.floor(e/18)*280,-Math.PI/2+.12);return s}function Se(e,t,n){return t===`orbit`?xe(e,n):P(e)}function F(e,t,n){if(e.length<=n)return e;let r=t?e.filter(e=>e.source===t||e.target===t):[],i=e.filter(e=>!t||e.source!==t&&e.target!==t).sort((e,t)=>t.weight-e.weight||e.source.localeCompare(t.source)||e.target.localeCompare(t.target)),a=Math.max(0,n-r.length);return[...r,...i.slice(0,a)]}function Ce(e,t,n){if(n===`all`)return e;let r=e.nodes;if(e.nodes.length>96){let n=new Map(e.nodes.map(e=>[e.id,e])),i=new Map;for(let t of e.edges)i.set(t.source,(i.get(t.source)??0)+t.weight),i.set(t.target,(i.get(t.target)??0)+t.weight);let a=[...e.nodes].sort((e,t)=>(i.get(t.id)??0)-(i.get(e.id)??0)||e.label.localeCompare(t.label)),o=new Set,s=e=>{n.has(e)&&o.size<96&&o.add(e)};if(t&&n.has(t)){s(t);let n=e.edges.filter(e=>e.source===t||e.target===t).sort((e,t)=>t.weight-e.weight);for(let e of n)s(e.source),s(e.target);let r=new Set(o),i=e.edges.filter(e=>r.has(e.source)||r.has(e.target)).sort((e,t)=>t.weight-e.weight);for(let e of i)s(e.source),s(e.target)}else{let e=a.filter(e=>!e.external).slice(0,72),t=a.filter(e=>e.external).slice(0,24);for(let n of[...e,...t])s(n.id)}for(let e of a)s(e.id);r=e.nodes.filter(e=>o.has(e.id))}let i=new Set(r.map(e=>e.id)),a=e.edges.filter(e=>i.has(e.source)&&i.has(e.target));return{nodes:r,edges:F(a,t,180)}}var we=[`/src/main/java/`,`/src/main/kotlin/`,`/src/`,`/lib/`,`/internal/`,`/cmd/`,`/pkg/`,`/app/`];function Te(e){let t=(e.file??e.label).replace(/\\/g,`/`),n=e.package??``,r=n.startsWith(`@wrongstack/`)?`/packages/${n.slice(12)}/`:n.startsWith(`app:`)?`/apps/${n.slice(4)}/`:void 0;if(!r)return;let i=t.indexOf(r);return i>=0?t.slice(i+r.length):void 0}function I(e){let t=(e.file??e.label).replace(/\\/g,`/`),n=Te(e);if(n!==void 0)return n;let r=-1,i=0;for(let e of we){let n=t.lastIndexOf(e);n>r&&(r=n,i=n+e.length)}return r>=0?t.slice(i):t.split(`/`).slice(-3).join(`/`)}function Ee(e){if(e.length===0)return``;let t=e.map(e=>e.split(`/`)),n=t[0]??[],r=0;for(;r<n.length-1;){let e=n[r];if(!t.every(t=>t.length-1>r&&t[r]===e))break;r++}return r===0?``:`${n.slice(0,r).join(`/`)}/`}var De=new WeakMap;function Oe(e){let t=De.get(e);if(t)return t;let n={name:``,path:``,directories:[],files:[]},r=e.filter(e=>e.kind===`file`&&!e.external),i=r.map(Te),a=i.every(e=>e!==void 0),o=a?``:Ee(r.map(e=>(e.file??e.label).replace(/\\/g,`/`)));for(let[e,t]of r.entries()){let r=(t.file??t.label).replace(/\\/g,`/`),s=i[e],c=(a?s??I(t):o&&r.startsWith(o)?r.slice(o.length):I(t)).split(`/`).filter(Boolean),l=c.pop()??t.label,u=n;for(let e of c){let t=u.path?`${u.path}/${e}`:e,n=u.directories.find(t=>t.name===e);n||(n={name:e,path:t,directories:[],files:[]},u.directories.push(n)),u=n}u.files.push({...t,label:l})}let s=e=>{e.directories.sort((e,t)=>e.name.localeCompare(t.name)),e.files.sort((e,t)=>e.label.localeCompare(t.label)),e.directories.forEach(s)};return s(n),De.set(e,n),n}function ke(e){let t=2166136261,n=e=>{for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619)};for(let t of e.nodes)n(t.id);for(let r of e.edges)n(r.source),n(r.target),n(r.refType),t^=r.weight|0,t=Math.imul(t,16777619);return`${e.nodes.length}:${e.edges.length}:${t>>>0}`}function Ae(e,t,n,r){for(e.has(t)&&e.delete(t),e.set(t,n);e.size>r;){let t=e.keys().next().value;if(t===void 0)break;e.delete(t)}}function je(e,t){if(!e||!t)return!1;let n=M(e),r=M(t);return n===r||n.endsWith(`/${r}`)||r.endsWith(`/${n}`)}function Me(e){let t=M(e),n=t.match(/\/packages\/([^/]+)\//);if(n?.[1])return`@wrongstack/${n[1]}`;let r=t.match(/\/apps\/([^/]+)\//);return r?.[1]?`app:${r[1]}`:`(root)`}function Ne(e,t){return t.kind===`package`?Me(e.filePath)===(t.package??t.label):je(e.filePath,t.file)?t.kind!==`symbol`||e.symbol?.id===t.id:!1}function L(e){let t=new Map;for(let n of e){let e=M(n.filePath),r=t.get(e);r?r.push(n):t.set(e,[n])}return t}function Pe(e,t){let n=new Map;if(t.length===0||e.length===0)return n;let r=L(t),i=new Map;for(let a of e){let e;if(a.kind===`package`){let n=a.package??a.label,r=i.get(n);r||(r=t.filter(e=>Me(e.filePath)===n),i.set(n,r)),e=r}else if(a.file){let t=M(a.file),n=r.get(t);if(!n){n=[];for(let[e,i]of r)(e.endsWith(`/${t}`)||t.endsWith(`/${e}`))&&n.push(...i)}e=a.kind===`symbol`?n.filter(e=>e.symbol?.id===a.id):n}else e=[];e.length>0&&n.set(a.id,e)}return n}function Fe(e){if(e.length===0)return``;let t=`${e.length}`;for(let n=0;n<e.length;n++){let r=e[n];t+=`|${r.id??``}:${r.toolUseId??``}:${r.filePath}:${r.type}:${r.status??``}:${r.symbol?.id??``}:${r.timestamp}`}return t}function Ie(e,t){let n=t.filter(t=>t.kind===`symbol`&&!t.external&&je(t.file,e.filePath));if(n.length===0)return;if(e.line)return[...n].sort((e,t)=>(t.line??0)-(e.line??0)).find(t=>(t.line??0)<=e.line)??n[0];let r=e.summary.toLocaleLowerCase();return n.find(e=>e.label.length>2&&(r.includes(e.label.toLocaleLowerCase())||!!(e.signature&&r.includes(e.signature.toLocaleLowerCase()))))}var R=w();function Le({historyFile:e,fileHistory:t,onClose:n}){let{t:a}=i();return(0,R.jsxs)(`div`,{className:`absolute right-0 top-0 z-50 flex h-full w-[390px] max-w-[90%] flex-col border-l bg-card shadow-2xl`,children:[(0,R.jsxs)(`div`,{className:`flex h-12 items-center justify-between border-b px-4`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsx)(r,{className:`h-4 w-4 shrink-0 text-warning`}),(0,R.jsx)(`span`,{className:`truncate font-mono text-[11px] font-semibold`,title:e,children:e})]}),(0,R.jsx)(`button`,{type:`button`,onClick:n,className:`flex h-7 w-7 items-center justify-center border text-muted-foreground hover:bg-muted`,"aria-label":a(`activity:codeMap.closeActivity`),children:(0,R.jsx)(y,{className:`h-3.5 w-3.5`})})]}),(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-3`,children:t.length===0?(0,R.jsx)(`p`,{className:`py-12 text-center text-[10px] text-muted-foreground`,children:a(`activity:codeMap.noActivityRecordedForThisFile`)}):t.map((e,t)=>(0,R.jsxs)(`div`,{className:`mb-1 flex items-start gap-2 border p-2 text-[10px]`,children:[(0,R.jsx)(`span`,{className:k(`border px-1.5 py-0.5 font-mono text-[8px] font-bold uppercase`,e.type===`delete`?`border-destructive/40 text-destructive`:e.type===`read`?`border-info/40 text-info`:`border-warning/40 text-warning`),children:e.type}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`div`,{className:`font-mono text-[9px] text-muted-foreground`,children:new Date(e.timestamp).toLocaleTimeString()}),e.toolName&&(0,R.jsxs)(`div`,{className:`mt-1`,children:[`via `,e.toolName]}),e.agent&&(0,R.jsx)(`div`,{className:`text-muted-foreground`,children:e.agent}),e.summary&&(0,R.jsx)(`div`,{className:`mt-1 text-muted-foreground`,children:e.summary}),e.change&&(0,R.jsxs)(`div`,{className:`mt-1 flex items-center gap-1 font-mono text-[8px]`,children:[(0,R.jsxs)(`span`,{className:`border border-success/40 bg-success/10 px-1 text-success`,children:[`+`,e.change.added]}),(0,R.jsxs)(`span`,{className:`border border-destructive/40 bg-destructive/10 px-1 text-destructive`,children:[`−`,e.change.removed]}),e.change.before&&(0,R.jsx)(`span`,{className:`ml-1 truncate text-destructive/80`,title:e.change.before,children:e.change.before}),e.change.after&&(0,R.jsxs)(`span`,{className:`truncate text-success/80`,title:e.change.after,children:[`→ `,e.change.after]})]}),(0,R.jsxs)(`div`,{className:`mt-1 flex gap-2 font-mono text-[8px] uppercase text-muted-foreground`,children:[(0,R.jsx)(`span`,{children:e.status??`observed`}),(0,R.jsx)(`span`,{children:e.source??`legacy`}),e.durationMs!==void 0&&(0,R.jsxs)(`span`,{children:[e.durationMs,`ms`]}),e.watcherConfirmed&&(0,R.jsx)(`span`,{className:`text-success`,children:a(`activity:codeMap.fsVerified`)})]})]})]},`${e.timestamp}-${t}`))}),(0,R.jsxs)(`div`,{className:`border-t px-4 py-2 font-mono text-[9px] text-muted-foreground`,children:[t.length,` events · newest first`]})]})}var z={package:{icon:t,accent:`border-l-primary`,iconStyle:`bg-primary/12 text-primary`},file:{icon:h,accent:`border-l-info`,iconStyle:`bg-info/12 text-info`},symbol:{icon:ee,accent:`border-l-success`,iconStyle:`bg-success/12 text-success`}},Re={call:`hsl(var(--primary))`,import:`hsl(var(--info))`,type_ref:`hsl(var(--success))`,inherit:`hsl(var(--warning))`,implement:`hsl(var(--destructive))`},B={read:`ring-2 ring-info/60 shadow-info/20`,write:`ring-2 ring-warning/70 shadow-warning/30`,edit:`ring-2 ring-warning/80 shadow-warning/40`,delete:`ring-2 ring-destructive/70 shadow-destructive/30`,search:`ring-2 ring-primary/55 shadow-primary/20`,memory:`ring-2 ring-success/60 shadow-success/30`,index:`ring-2 ring-info/50 shadow-info/20`,execute:`ring-2 ring-primary/55 shadow-primary/25`},V=[`bg-primary text-primary-foreground`,`bg-info text-info-foreground`,`bg-success text-success-foreground`,`bg-warning text-warning-foreground`,`bg-destructive text-destructive-foreground`];function ze(e){let t=e.trim().split(/[\s:_-]+/).filter(Boolean);return(t.length>1?`${t[0]?.[0]??``}${t[1]?.[0]??``}`:e.slice(0,2)).toLocaleUpperCase()}function H(e){let t=0;for(let n of e)t=t*31+n.charCodeAt(0)|0;return V[Math.abs(t)%V.length]??V[0]}function Be(e){let t=0;for(let n of e)t=t*31+n.charCodeAt(0)|0;return`hsl(${Math.abs(t)%360} 82% 58%)`}var U=[`/packages/`,`/apps/`,`/crates/`,`/cmd/`,`/internal/`,`/pkg/`,`/src/`];function Ve(e){let t=e.replace(/\\/g,`/`),n=U.reduce((e,n)=>Math.max(e,t.lastIndexOf(n)),-1);return n>=0?t.slice(n+1):t.split(`/`).slice(-3).join(`/`)}function He(e){return[e.symbol?.name,e.line?`L${e.line}`:void 0].filter(Boolean).join(` · `)}function Ue({data:e}){let{t}=i(),{graphNode:n,selected:r,dimmed:a,incoming:o,outgoing:s,isActive:c,activityType:l,activeOperations:u}=e,d=z[n.kind],f=d.icon,m=n.kind!==`symbol`,h=n.kind===`symbol`?`${n.symbolKind??`symbol`}${n.line?` · L${n.line}`:``}`:n.kind===`file`?I(n):`${n.fileCount??0} files · ${n.symbolCount??0} symbols`;return(0,R.jsxs)(`div`,{className:k(`group relative w-[236px] border border-l-[3px] bg-card text-card-foreground shadow-[0_8px_24px_hsl(var(--shadow-color)/0.08)] transition-[opacity,box-shadow,border-color,background-color]`,d.accent,r&&`border-primary bg-primary/5 shadow-[0_0_0_2px_hsl(var(--primary)/0.18),0_16px_36px_hsl(var(--shadow-color)/0.18)]`,n.external&&`border-dashed bg-muted/75`,a&&`opacity-25 grayscale`,c&&l&&B[l]),children:[u.length>0&&(0,R.jsxs)(`div`,{className:`absolute -top-5 left-2 z-20 flex max-w-[210px] items-center gap-1`,children:[u.slice(0,4).map(e=>{let t=e.agentName??e.agent??`External`,n=`${e.sessionId??`none`}:${e.agentId??t}`;return(0,R.jsxs)(`span`,{className:k(`flex h-6 items-center gap-1 border-2 border-background px-1.5 font-mono text-[8px] font-bold shadow-md`,H(n)),title:`${t} · ${e.type} ${He(e)}`,children:[(0,R.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse bg-current`}),ze(t),e.symbol&&(0,R.jsx)(`span`,{className:`max-w-[80px] truncate`,children:e.symbol.name})]},e.id??`${n}:${e.filePath}`)}),u.length>4&&(0,R.jsxs)(`span`,{className:`border bg-card px-1 font-mono text-[8px] shadow`,children:[`+`,u.length-4]})]}),(0,R.jsx)(T,{type:`target`,position:p.Left,className:`!h-2.5 !w-2.5 !border-2 !border-card !bg-muted-foreground`}),(0,R.jsxs)(`button`,{type:`button`,className:`block w-full text-left`,onClick:t=>{if(t.shiftKey&&n.file){e.onShowHistory(n.file);return}e.onSelect(n)},onDoubleClick:()=>m&&e.onOpen(n),"aria-label":`${n.kind} ${n.label}`,children:[(0,R.jsxs)(`div`,{className:`flex items-start gap-3 p-3 pr-10`,children:[(0,R.jsx)(`span`,{className:k(`flex h-8 w-8 shrink-0 items-center justify-center border`,d.iconStyle),children:(0,R.jsx)(f,{className:`h-4 w-4`})}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[9px] font-bold uppercase tracking-[0.18em] text-muted-foreground`,children:[(0,R.jsx)(`span`,{children:n.kind}),n.external&&(0,R.jsx)(`span`,{className:`border border-border px-1 py-0.5 text-[8px] text-warning`,children:`external`}),n.lang&&(0,R.jsx)(`span`,{className:`ml-auto font-mono normal-case tracking-normal`,children:n.lang})]}),(0,R.jsx)(`div`,{className:`truncate font-mono text-[13px] font-semibold`,title:n.label,children:n.label}),(0,R.jsx)(`div`,{className:`mt-1 truncate text-[10px] text-muted-foreground`,title:h,children:h})]})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-3 border-t bg-muted/30 px-3 py-1.5 font-mono text-[9px] text-muted-foreground`,children:[(0,R.jsxs)(`span`,{title:t(`activity:codeMapVisuals.incomingRelationships`),children:[`← `,o]}),(0,R.jsxs)(`span`,{title:t(`activity:codeMapVisuals.outgoingRelationships`),children:[`→ `,s]}),n.symbolCount!==void 0&&n.kind===`file`&&(0,R.jsxs)(`span`,{className:`ml-auto`,children:[n.symbolCount,` sym`]}),c&&(0,R.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 font-bold text-warning`,children:[(0,R.jsx)(D,{className:`h-2.5 w-2.5 animate-pulse`}),` LIVE`]})]})]}),m&&(0,R.jsx)(`button`,{type:`button`,className:`absolute right-2 top-2 z-10 flex h-7 w-7 items-center justify-center border border-transparent text-muted-foreground opacity-0 transition hover:border-border hover:bg-muted hover:text-foreground group-hover:opacity-100 focus:opacity-100`,onClick:()=>e.onOpen(n),title:n.kind===`package`?`Open file map`:`Open symbol map`,"aria-label":`Open ${n.label} map`,children:(0,R.jsx)(v,{className:`h-3.5 w-3.5`})}),(0,R.jsx)(T,{type:`source`,position:p.Right,className:`!h-2.5 !w-2.5 !border-2 !border-card !bg-muted-foreground`})]})}function We(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function Ge(e,t){return e.graphNode===t.graphNode&&e.selected===t.selected&&e.dimmed===t.dimmed&&e.incoming===t.incoming&&e.outgoing===t.outgoing&&e.isActive===t.isActive&&e.activityType===t.activityType&&e.onSelect===t.onSelect&&e.onOpen===t.onOpen&&e.onShowHistory===t.onShowHistory&&We(e.activeOperations,t.activeOperations)}var Ke={codemap:(0,A.memo)(Ue,(e,t)=>Ge(e.data,t.data))},qe={nodes:[],edges:[]};function Je(e){return/Authentication required|Unauthorized/i.test(e)}function Ye({loading:e,error:t,graph:n,canvasNodeCount:r,flowNodes:a,flowEdges:o,onNodesChange:s,onEdgesChange:c,agentTrailCount:l}){let{t:u}=i();return(0,R.jsxs)(R.Fragment,{children:[e&&(0,R.jsxs)(`div`,{className:`absolute inset-0 z-20 flex flex-col items-center justify-center gap-3 bg-background/75 backdrop-blur-sm`,children:[(0,R.jsx)(S,{className:`h-7 w-7 animate-spin text-primary`}),(0,R.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-widest text-muted-foreground`,children:u(`activity:codeMap.mappingRelationships`)})]}),t&&!e&&(0,R.jsxs)(`div`,{className:`absolute inset-0 z-20 flex flex-col items-center justify-center gap-3 p-8 text-center`,children:[(0,R.jsx)(O,{className:`h-10 w-10 text-destructive`}),(0,R.jsx)(`p`,{className:`font-mono text-sm text-destructive`,children:t}),!Je(t)&&(0,R.jsxs)(`p`,{className:`max-w-md text-xs text-muted-foreground`,children:[`The map needs a codebase index. Run`,` `,(0,R.jsx)(`code`,{className:`border bg-muted px-1.5 py-0.5`,children:`codebase-index`}),` `,u(`activity:codeMap.onceThenReopenThisView`)]})]}),!e&&!t&&n.nodes.length===0&&(0,R.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-2 text-muted-foreground`,children:[(0,R.jsx)(O,{className:`h-8 w-8 opacity-40`}),(0,R.jsx)(`p`,{className:`text-xs`,children:u(`activity:codeMap.noIndexedNodesAtThisLevel`)})]}),!e&&!t&&n.nodes.length>1&&n.edges.length===0&&(0,R.jsxs)(`div`,{className:`pointer-events-none absolute left-1/2 top-14 z-10 -translate-x-1/2 border border-warning/40 bg-warning/10 px-3 py-2 text-center shadow backdrop-blur`,children:[(0,R.jsx)(`div`,{className:`font-mono text-[9px] font-bold uppercase tracking-wider text-warning`,children:u(`activity:codeMap.noResolvedRelationsInThisScope`)}),(0,R.jsx)(`div`,{className:`mt-0.5 text-[8px] text-muted-foreground`,children:u(`activity:codeMap.theUpgradedIndexWillRebuildAnd`)})]}),!t&&n.nodes.length>0&&(0,R.jsxs)(b,{nodes:a,edges:o,onNodesChange:s,onEdgesChange:c,nodeTypes:Ke,nodesConnectable:!1,nodesDraggable:!1,edgesFocusable:!1,elementsSelectable:!1,onlyRenderVisibleElements:!0,minZoom:.08,maxZoom:2.2,proOptions:{hideAttribution:!0},children:[(0,R.jsx)(ce,{variant:re.Dots,gap:r>60?32:22,size:1,color:`hsl(var(--muted-foreground))`,className:`!opacity-25`}),(0,R.jsx)(m,{position:`bottom-left`,showInteractive:!1,className:`!border !border-border !bg-card !shadow-md [&>button]:!border-border [&>button]:!bg-card [&>button]:!fill-foreground`}),r<=48&&(0,R.jsx)(_,{position:`bottom-right`,pannable:!0,zoomable:!0,className:`!h-[112px] !w-[180px] !border !border-border !bg-card !shadow-md`,maskColor:`hsl(var(--background) / 0.72)`,nodeColor:e=>{let t=e.data?.graphNode.kind;return t===`package`?`hsl(var(--primary))`:t===`file`?`hsl(var(--info))`:`hsl(var(--success))`}})]}),(0,R.jsxs)(`div`,{className:`pointer-events-none absolute bottom-3 left-1/2 z-10 flex -translate-x-1/2 items-center gap-3 border bg-card/90 px-3 py-1.5 font-mono text-[8px] text-muted-foreground shadow backdrop-blur`,children:[Object.entries(Re).map(([e,t])=>(0,R.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(`span`,{className:`h-0.5 w-3`,style:{backgroundColor:t}}),e.replace(`_`,` `)]},e)),(0,R.jsxs)(`span`,{className:`flex items-center gap-1 text-primary`,"data-testid":`agent-trail-count`,children:[(0,R.jsx)(`span`,{className:`w-4 border-t-2 border-dashed border-primary`}),`agent trail`,l>0?` ×${l}`:``]})]})]})}function Xe({layout:e,canvasMode:t,edgeFilter:n,canvasNodeCount:r,graphNodeCount:a,onLayoutChange:o,onCanvasModeChange:c,onEdgeFilterChange:l}){let{t:u}=i();return(0,R.jsxs)(`div`,{className:`pointer-events-none absolute left-3 right-3 top-3 z-10 flex items-center gap-2`,children:[(0,R.jsxs)(`div`,{className:`pointer-events-auto flex border bg-card/95 shadow-md backdrop-blur`,children:[(0,R.jsxs)(`button`,{type:`button`,className:k(`flex h-8 items-center gap-1.5 border-r px-2.5 text-[9px] font-semibold uppercase tracking-wider`,e===`layers`?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-muted`),onClick:()=>o(`layers`),children:[(0,R.jsx)(x,{className:`h-3 w-3`}),` `,u(`activity:codeMap.layers`)]}),(0,R.jsxs)(`button`,{type:`button`,className:k(`flex h-8 items-center gap-1.5 px-2.5 text-[9px] font-semibold uppercase tracking-wider`,e===`orbit`?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-muted`),onClick:()=>o(`orbit`),children:[(0,R.jsx)(s,{className:`h-3 w-3`}),` `,u(`activity:codeMap.relations`)]})]}),(0,R.jsxs)(`div`,{className:`pointer-events-auto flex border bg-card/95 shadow-md backdrop-blur`,children:[(0,R.jsxs)(`button`,{type:`button`,className:k(`h-8 border-r px-2.5 font-mono text-[9px] font-bold`,t===`smart`?`bg-success text-success-foreground`:`text-muted-foreground hover:bg-muted`),onClick:()=>c(`smart`),title:u(`activity:codeMap.keepTheFullTreeShowTheStrongestRelationsAndSelectedNeighbourhood`),children:[`SMART `,r,`/`,a]}),(0,R.jsx)(`button`,{type:`button`,className:k(`h-8 px-2.5 font-mono text-[9px] font-bold`,t===`all`?`bg-foreground text-background`:`text-muted-foreground hover:bg-muted`),onClick:()=>c(`all`),title:u(`activity:codeMap.renderEveryNodeAndRelationInThisScope`),children:u(`activity:codeMap.all`)})]}),(0,R.jsx)(`div`,{className:`pointer-events-auto ml-auto flex max-w-[60%] overflow-x-auto border bg-card/95 shadow-md backdrop-blur`,children:[`all`,`import`,`call`,`type_ref`,`inherit`,`implement`].map(e=>(0,R.jsx)(`button`,{type:`button`,className:k(`h-8 whitespace-nowrap border-r px-2.5 font-mono text-[9px] last:border-r-0`,n===e?`bg-foreground text-background`:`text-muted-foreground hover:bg-muted`),onClick:()=>l(e),children:e===`all`?`ALL LINKS`:e.replace(`_`,` `).toUpperCase()},e))})]})}function Ze({scope:e,graph:t,agentPresences:n,edgeWeight:r,connectedNodeCount:a,navigate:o}){let{t:s}=i();return(0,R.jsxs)(`header`,{className:`flex h-[62px] shrink-0 items-center gap-4 border-b bg-card px-4`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-[220px] items-center gap-3`,children:[(0,R.jsx)(`span`,{className:`flex h-9 w-9 items-center justify-center border border-primary bg-primary/10 text-primary`,children:(0,R.jsx)(O,{className:`h-4 w-4`})}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h1`,{className:`font-display text-sm font-semibold tracking-tight`,children:s(`activity:codeMap.codeAtlas`)}),(0,R.jsx)(`p`,{className:`text-[9px] uppercase tracking-[0.18em] text-muted-foreground`,children:s(`activity:codeMap.architectureIntelligence`)})]})]}),(0,R.jsxs)(`nav`,{className:`flex min-w-0 flex-1 items-center gap-1 font-mono text-[10px]`,"aria-label":s(`activity:codeMap.codeMapBreadcrumb`),children:[e.level!==`packages`&&(0,R.jsx)(`button`,{type:`button`,className:`mr-1 flex h-7 w-7 items-center justify-center border text-muted-foreground hover:bg-muted`,onClick:()=>{e.level===`symbols`?o({level:`files`,package:e.package??`(root)`}):o({level:`packages`})},"aria-label":s(`activity:codeMap.back`),children:(0,R.jsx)(ue,{className:`h-3.5 w-3.5`})}),(0,R.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1.5 px-1.5 py-1 text-muted-foreground hover:text-foreground`,onClick:()=>o({level:`packages`}),children:[(0,R.jsx)(c,{className:`h-3 w-3`}),` workspace`]}),e.level!==`packages`&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(d,{className:`h-3 w-3 text-muted-foreground`}),(0,R.jsx)(`button`,{type:`button`,className:`max-w-[220px] truncate px-1.5 py-1 hover:text-primary`,onClick:()=>o({level:`files`,package:e.package??`(root)`}),children:e.package??`(root)`})]}),e.level===`symbols`&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(d,{className:`h-3 w-3 text-muted-foreground`}),(0,R.jsx)(`span`,{className:`truncate px-1.5 py-1 text-primary`,children:I({id:``,label:e.file,kind:`file`,file:e.file,package:e.package})})]})]}),(0,R.jsxs)(`div`,{className:`hidden items-center gap-5 xl:flex`,children:[(0,R.jsxs)(`div`,{className:k(`flex h-8 items-center gap-2 border px-2.5`,n.length>0?`border-success/50 bg-success/10 text-success`:`text-muted-foreground`),children:[(0,R.jsx)(D,{className:k(`h-3 w-3`,n.length>0&&`animate-pulse`)}),(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{className:`font-mono text-[10px] font-bold`,children:[n.length,` LIVE`]}),(0,R.jsx)(`div`,{className:`text-[7px] uppercase tracking-wider`,children:`agents`})]})]}),(0,R.jsxs)(`div`,{className:`text-right`,children:[(0,R.jsx)(`div`,{className:`font-mono text-sm font-semibold`,children:t.nodes.length}),(0,R.jsx)(`div`,{className:`text-[8px] uppercase tracking-wider text-muted-foreground`,children:`nodes`})]}),(0,R.jsxs)(`div`,{className:`text-right`,children:[(0,R.jsx)(`div`,{className:`font-mono text-sm font-semibold`,children:t.edges.length}),(0,R.jsx)(`div`,{className:`text-[8px] uppercase tracking-wider text-muted-foreground`,children:`links`})]}),(0,R.jsxs)(`div`,{className:`text-right`,children:[(0,R.jsx)(`div`,{className:`font-mono text-sm font-semibold`,children:r}),(0,R.jsx)(`div`,{className:`text-[8px] uppercase tracking-wider text-muted-foreground`,children:`references`})]}),(0,R.jsxs)(`div`,{className:`text-right`,children:[(0,R.jsx)(`div`,{className:`font-mono text-sm font-semibold`,children:a}),(0,R.jsx)(`div`,{className:`text-[8px] uppercase tracking-wider text-muted-foreground`,children:`connected`})]})]})]})}function Qe({activity:e}){return(0,R.jsx)(`span`,{className:k(`shrink-0 border px-1.5 py-0.5 font-mono text-[8px] font-bold uppercase`,e.type===`delete`?`border-destructive/50 bg-destructive/10 text-destructive`:e.type===`read`?`border-info/50 bg-info/10 text-info`:e.type===`search`||e.type===`index`?`border-primary/50 bg-primary/10 text-primary`:`border-warning/50 bg-warning/10 text-warning`),children:e.filePath.startsWith(`(tool:`)?e.toolName:e.type})}function W({activity:e,onLocate:t,showAgent:n=!1}){let{t:r}=i(),o=e.agentName??e.agent??`External process`,s=`${e.sessionId??`none`}:${e.agentId??o}`;return(0,R.jsxs)(`button`,{type:`button`,className:`group flex w-full items-start gap-2 border-b px-3 py-2 text-left last:border-b-0 hover:bg-muted/70`,onClick:()=>!e.filePath.startsWith(`(`)&&t(e),title:`Locate ${e.filePath}`,children:[n&&(0,R.jsx)(`span`,{className:k(`mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center font-mono text-[8px] font-black`,H(s)),children:ze(o)}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(Qe,{activity:e}),n&&(0,R.jsx)(`span`,{className:`truncate text-[9px] font-semibold`,children:o}),e.status===`active`&&(0,R.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 font-mono text-[8px] font-bold text-success`,children:[(0,R.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse bg-success`}),` `,r(`activity:codeMap.live`)]}),e.watcherConfirmed&&(0,R.jsx)(f,{className:`ml-auto h-3 w-3 text-success`,"aria-label":r(`activity:codeMap.filesystemConfirmed`)}),e.attribution===`correlated`&&!e.watcherConfirmed&&(0,R.jsx)(`span`,{className:`ml-auto font-mono text-[7px] uppercase text-warning`,title:r(`activity:codeMap.correlatedFromTheOnlyActiveTool`),children:r(`activity:codeMap.correlated`)}),e.attribution===`external`&&(0,R.jsx)(`span`,{className:`ml-auto font-mono text-[7px] uppercase text-destructive`,children:`external`})]}),(0,R.jsx)(`div`,{className:`mt-1 truncate font-mono text-[9px] font-semibold`,title:e.filePath,children:Ve(e.filePath)}),(e.symbol||e.line)&&(0,R.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-1 truncate font-mono text-[8px] text-success`,children:[(0,R.jsx)(a,{className:`h-2.5 w-2.5 shrink-0`}),e.symbol?.name??`line ${e.line}`,e.symbol?.kind&&(0,R.jsxs)(`span`,{className:`text-muted-foreground`,children:[`· `,e.symbol.kind]})]}),e.change&&(0,R.jsxs)(`div`,{className:`mt-1 flex items-center gap-1 font-mono text-[8px]`,children:[(0,R.jsxs)(`span`,{className:`border border-success/40 bg-success/10 px-1 text-success`,children:[`+`,e.change.added]}),(0,R.jsxs)(`span`,{className:`border border-destructive/40 bg-destructive/10 px-1 text-destructive`,children:[`−`,e.change.removed]}),e.durationMs!==void 0&&(0,R.jsxs)(`span`,{className:`ml-auto text-muted-foreground`,children:[e.durationMs,`ms`]})]}),e.summary&&e.summary!==e.toolName&&(0,R.jsx)(`div`,{className:`mt-1 line-clamp-2 text-[8px] leading-3 text-muted-foreground`,children:e.summary})]}),!e.filePath.startsWith(`(`)&&(0,R.jsx)(v,{className:`mt-1 h-3 w-3 shrink-0 text-muted-foreground opacity-0 group-hover:opacity-100`})]})}function $e({presences:e,onLocate:t}){let{t:n}=i();return e.length===0?null:(0,R.jsxs)(`section`,{className:`pointer-events-auto absolute left-3 top-14 z-20 w-[304px] border bg-card/95 shadow-xl backdrop-blur`,children:[(0,R.jsxs)(`div`,{className:`flex h-9 items-center gap-2 border-b px-3`,children:[(0,R.jsx)(D,{className:`h-3.5 w-3.5 animate-pulse text-success`}),(0,R.jsx)(`h2`,{className:`text-[9px] font-black uppercase tracking-[0.18em]`,children:n(`activity:codeMap.liveAgentOperations`)}),(0,R.jsxs)(`span`,{className:`ml-auto bg-success px-1.5 py-0.5 font-mono text-[8px] font-bold text-success-foreground`,children:[e.length,` ONLINE`]})]}),(0,R.jsx)(`div`,{className:`max-h-[330px] overflow-y-auto`,children:e.map(e=>(0,R.jsxs)(`div`,{className:`border-b last:border-b-0`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 bg-muted/35 px-3 py-1.5`,children:[(0,R.jsx)(`span`,{className:k(`flex h-6 w-6 items-center justify-center font-mono text-[8px] font-black`,H(e.key)),children:ze(e.agentName)}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`div`,{className:`truncate text-[9px] font-bold`,children:e.agentName}),(0,R.jsxs)(`div`,{className:`truncate font-mono text-[7px] text-muted-foreground`,children:[`session `,e.sessionId.slice(0,12),` · agent `,e.agentId.slice(0,12)]})]}),(0,R.jsxs)(`span`,{className:`font-mono text-[8px] text-success`,children:[e.operations.length,` op`]})]}),e.operations.map(e=>(0,R.jsx)(W,{activity:e,onLocate:t},e.id??`${e.toolUseId}:${e.filePath}`))]},e.key))})]})}function et({paused:e,followLive:t,agentFilter:n,agents:r,onTogglePaused:o,onToggleFollow:s,onAgentFilter:c}){let{t:l}=i();return(0,R.jsxs)(`div`,{className:`pointer-events-auto absolute right-3 top-14 z-20 flex h-9 items-center border bg-card/95 shadow-lg backdrop-blur`,children:[(0,R.jsxs)(`button`,{type:`button`,className:k(`flex h-full items-center gap-1.5 border-r px-2.5 text-[8px] font-bold uppercase tracking-wider`,t?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-muted`),onClick:s,title:l(`activity:codeMap.automaticallyEnterTheFileFunctionUsedByTheNewestVisibleAgent`),children:[(0,R.jsx)(a,{className:`h-3 w-3`}),` `,l(`activity:codeMap.follow`)]}),(0,R.jsxs)(`button`,{type:`button`,className:k(`flex h-full items-center gap-1.5 border-r px-2.5 text-[8px] font-bold uppercase tracking-wider`,e?`bg-warning text-warning-foreground`:`text-success hover:bg-success/10`),onClick:o,title:e?`Resume the live telemetry stream`:`Freeze the current telemetry frame`,children:[e?(0,R.jsx)(E,{className:`h-3 w-3`}):(0,R.jsx)(C,{className:`h-3 w-3`}),e?`Resume`:`Live`]}),(0,R.jsxs)(`label`,{className:`flex h-full items-center gap-1.5 px-2 text-[8px] uppercase text-muted-foreground`,children:[l(`activity:codeMap.agent`),(0,R.jsxs)(`select`,{"aria-label":l(`activity:codeMap.filterCodemapByAgentAndSession`),className:`h-6 max-w-[170px] border bg-background px-1.5 font-mono text-[8px] text-foreground outline-none focus:border-primary`,value:n,onChange:e=>c(e.target.value),children:[(0,R.jsx)(`option`,{value:`all`,children:l(`activity:codeMap.allAgents`)}),r.map(e=>(0,R.jsxs)(`option`,{value:e.key,children:[e.agentName,` · `,e.sessionId.slice(0,10)]},e.key))]})]})]})}function tt({activeOperations:e,recentActivities:t,activityTotalCount:a,onLocate:o}){let{t:s}=i();return(0,R.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[e.length>0&&(0,R.jsxs)(`section`,{className:`border-b`,children:[(0,R.jsxs)(`div`,{className:`flex h-9 items-center gap-2 border-b bg-success/5 px-3`,children:[(0,R.jsx)(D,{className:`h-3 w-3 animate-pulse text-success`}),(0,R.jsx)(`h3`,{className:`text-[9px] font-bold uppercase tracking-[0.16em]`,children:s(`activity:codeMap.activeNow`)}),(0,R.jsx)(`span`,{className:`ml-auto font-mono text-[9px] text-success`,children:e.length})]}),e.map(e=>(0,R.jsx)(W,{activity:e,onLocate:o,showAgent:!0},e.id??`${e.toolUseId}:${e.filePath}`))]}),(0,R.jsxs)(`section`,{children:[(0,R.jsxs)(`div`,{className:`flex h-9 items-center gap-2 border-b px-3`,children:[(0,R.jsx)(r,{className:`h-3 w-3 text-muted-foreground`}),(0,R.jsx)(`h3`,{className:`text-[9px] font-bold uppercase tracking-[0.16em]`,children:s(`activity:codeMap.eventStream`)}),(0,R.jsxs)(`span`,{className:`ml-auto font-mono text-[8px] text-muted-foreground`,children:[a,` total`]})]}),t.length>0?t.map((e,t)=>(0,R.jsx)(W,{activity:e,onLocate:o,showAgent:!0},e.id??`${e.timestamp}:${t}`)):(0,R.jsxs)(`div`,{className:`flex flex-col items-center justify-center px-7 py-16 text-center`,children:[(0,R.jsx)(`span`,{className:`mb-4 flex h-12 w-12 items-center justify-center border bg-muted text-muted-foreground`,children:(0,R.jsx)(n,{className:`h-5 w-5`})}),(0,R.jsx)(`h3`,{className:`text-xs font-semibold`,children:s(`activity:codeMap.selectANodeOrWaitFor`)}),(0,R.jsx)(`p`,{className:`mt-2 text-[10px] leading-relaxed text-muted-foreground`,children:s(`activity:codeMap.relationsAppearOnSelectionToolCalls`)})]})]})]})}function G({node:e,incomingCount:t,outgoingCount:n,onOpenNode:a,onOpenActivity:o}){let{t:s}=i(),c=z[e.kind].icon;return(0,R.jsxs)(`div`,{className:`border-b bg-muted/25 p-3`,children:[(0,R.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:k(`flex h-8 w-8 items-center justify-center border`,z[e.kind].iconStyle),children:(0,R.jsx)(c,{className:`h-4 w-4`})}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsxs)(`div`,{className:`text-[8px] font-bold uppercase tracking-[0.18em] text-muted-foreground`,children:[e.external?`external `:``,e.kind]}),(0,R.jsx)(`div`,{className:`truncate font-mono text-xs font-semibold`,title:e.label,children:e.label})]})]}),(0,R.jsx)(`div`,{className:`break-all font-mono text-[9px] leading-relaxed text-muted-foreground`,children:e.file?I(e):e.package}),e.signature&&(0,R.jsx)(`pre`,{className:`mt-3 overflow-x-auto border bg-background p-2 font-mono text-[9px] leading-relaxed text-foreground`,children:e.signature}),(0,R.jsxs)(`div`,{className:`mt-3 grid grid-cols-3 border`,children:[(0,R.jsx)(nt,{value:t,label:s(`activity:codeMap.incoming`),className:`border-r text-info`}),(0,R.jsx)(nt,{value:n,label:s(`activity:codeMap.outgoing`),className:`border-r text-primary`}),(0,R.jsx)(nt,{value:e.symbolCount??e.fileCount??e.line??`—`,label:e.kind===`package`?`files`:e.kind===`file`?`symbols`:`line`})]}),(0,R.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[e.kind!==`symbol`&&(0,R.jsxs)(`button`,{type:`button`,className:`flex h-7 flex-1 items-center justify-center gap-1.5 border bg-foreground text-[9px] font-semibold uppercase tracking-wider text-background hover:opacity-90`,onClick:()=>a(e),children:[(0,R.jsx)(v,{className:`h-3 w-3`}),` Open `,e.kind===`package`?`files`:`symbols`]}),e.file&&(0,R.jsxs)(`button`,{type:`button`,className:`flex h-7 items-center justify-center gap-1.5 border px-2 text-[9px] uppercase text-muted-foreground hover:bg-muted`,onClick:()=>o(e.file),children:[(0,R.jsx)(r,{className:`h-3 w-3`}),` `,s(`activity:codeMap.activity`)]})]})]})}function nt({value:e,label:t,className:n}){return(0,R.jsxs)(`div`,{className:k(`p-2 text-center`,n),children:[(0,R.jsx)(`div`,{className:`font-mono text-sm font-semibold`,children:e}),(0,R.jsx)(`div`,{className:`text-[8px] uppercase text-muted-foreground`,children:t})]})}function K(e){let{t}=i(),{title:r,subtitle:a,items:s,graph:c,selectedId:l,expanded:u,onToggle:f,onSelect:p}=e;return(0,R.jsxs)(`section`,{className:`border-b py-3`,children:[(0,R.jsxs)(`div`,{className:`mb-2 flex items-end justify-between px-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h3`,{className:`text-[10px] font-bold uppercase tracking-[0.16em]`,children:r}),(0,R.jsx)(`p`,{className:`mt-0.5 text-[9px] text-muted-foreground`,children:a})]}),(0,R.jsx)(`span`,{className:`border bg-muted px-1.5 py-0.5 font-mono text-[9px]`,children:s.length})]}),s.length===0?(0,R.jsx)(`p`,{className:`px-3 py-2 text-[10px] text-muted-foreground`,children:t(`activity:codeMap.noRelationshipsInThisView`)}):s.map(e=>{let t=`${r}:${e.node.id}`,i=u.has(t),a=[...ve(c,e.node.id,`incoming`),...ve(c,e.node.id,`outgoing`)].filter((e,t,n)=>e.node.id!==l&&n.findIndex(t=>t.node.id===e.node.id)===t).slice(0,8);return(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{className:`group flex min-h-9 items-center gap-1 px-2 hover:bg-muted/70`,children:[(0,R.jsx)(`button`,{type:`button`,className:`flex h-6 w-5 shrink-0 items-center justify-center text-muted-foreground`,onClick:()=>a.length>0&&f(t),"aria-label":`${i?`Collapse`:`Expand`} relation ${e.node.label}`,children:a.length>0?i?(0,R.jsx)(o,{className:`h-3 w-3`}):(0,R.jsx)(d,{className:`h-3 w-3`}):(0,R.jsx)(`span`,{className:`h-px w-2 bg-border`})}),(0,R.jsxs)(`button`,{type:`button`,className:`min-w-0 flex-1 py-1 text-left`,onClick:()=>p(e.node),children:[(0,R.jsx)(`span`,{className:`block truncate font-mono text-[10px] font-semibold`,title:e.node.label,children:e.node.label}),(0,R.jsx)(`span`,{className:`block truncate text-[9px] text-muted-foreground`,children:e.node.package??e.node.symbolKind??e.node.kind})]}),(0,R.jsx)(`span`,{className:`border px-1 py-0.5 font-mono text-[8px] text-muted-foreground`,children:e.edge.refType}),(0,R.jsxs)(`span`,{className:`w-5 text-right font-mono text-[9px] text-muted-foreground`,children:[`×`,e.edge.weight]})]}),i&&a.map(e=>(0,R.jsxs)(`button`,{type:`button`,className:`relative flex h-7 w-full items-center gap-2 border-l border-border pl-11 pr-3 text-left text-[9px] text-muted-foreground hover:bg-muted hover:text-foreground`,onClick:()=>p(e.node),children:[(0,R.jsx)(`span`,{className:`absolute left-7 top-1/2 h-px w-3 bg-border`}),(0,R.jsx)(n,{className:`h-3 w-3 shrink-0`}),(0,R.jsx)(`span`,{className:`truncate font-mono`,children:e.node.label}),(0,R.jsx)(`span`,{className:`ml-auto font-mono opacity-70`,children:e.edge.refType})]},`${t}:${e.node.id}`))]},t)})]})}function rt({selectedNode:e,incoming:t,outgoing:n,filteredGraph:r,expandedRelations:a,activeOperations:o,recentActivities:s,activityTotalCount:c,selectedActivities:l,onClearSelection:u,onOpenNode:d,onOpenActivity:f,onLocateActivity:p,onToggleRelation:m,onSelectNode:h}){let{t:g}=i();return(0,R.jsxs)(`aside`,{className:`flex w-[326px] shrink-0 flex-col border-l bg-card/80`,children:[(0,R.jsxs)(`div`,{className:`flex h-10 items-center justify-between border-b px-3`,children:[(0,R.jsx)(`h2`,{className:`text-[10px] font-bold uppercase tracking-[0.18em]`,children:g(`activity:codeMap.relationInspector`)}),e&&(0,R.jsx)(`button`,{type:`button`,className:`text-muted-foreground hover:text-foreground`,onClick:u,"aria-label":g(`activity:codeMap.clearSelection`),children:(0,R.jsx)(y,{className:`h-3.5 w-3.5`})})]}),e?(0,R.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[(0,R.jsx)(G,{node:e,incomingCount:t.length,outgoingCount:n.length,onOpenNode:d,onOpenActivity:f}),l.length>0&&(0,R.jsxs)(`section`,{className:`border-b bg-success/5 py-2`,children:[(0,R.jsxs)(`div`,{className:`mb-1 flex items-center gap-2 px-3`,children:[(0,R.jsx)(D,{className:`h-3 w-3 animate-pulse text-success`}),(0,R.jsx)(`h3`,{className:`text-[9px] font-bold uppercase tracking-[0.16em]`,children:g(`activity:codeMap.agentsOnThisNode`)}),(0,R.jsx)(`span`,{className:`ml-auto font-mono text-[9px] text-success`,children:l.length})]}),l.map(e=>(0,R.jsx)(W,{activity:e,onLocate:p,showAgent:!0},e.id??`${e.toolUseId}:${e.filePath}`))]}),(0,R.jsx)(K,{title:g(`activity:codeMap.incoming`),subtitle:g(`activity:codeMap.whoDependsOnThis`),items:t,graph:r,selectedId:e.id,expanded:a,onToggle:m,onSelect:h}),(0,R.jsx)(K,{title:g(`activity:codeMap.outgoing`),subtitle:g(`activity:codeMap.whatThisDependsOn`),items:n,graph:r,selectedId:e.id,expanded:a,onToggle:m,onSelect:h})]}):(0,R.jsx)(tt,{activeOperations:o,recentActivities:s,activityTotalCount:c,onLocate:p})]})}function it({node:e,onSelect:t,virtual:n}){let r=z[e.kind].icon;return(0,R.jsxs)(`button`,{type:`button`,"data-index":n?.index,ref:n?e=>n.measureElement(e):void 0,className:k(`min-h-8 items-center gap-2 px-3 py-1 text-left hover:bg-muted`,n?`absolute left-0 flex w-full`:`flex w-full`),style:n?{transform:`translateY(${n.start}px)`}:void 0,onClick:()=>t(e),children:[(0,R.jsx)(r,{className:k(`h-3.5 w-3.5 shrink-0`,e.kind===`package`?`text-primary`:e.kind===`file`?`text-info`:`text-success`)}),(0,R.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`span`,{className:`block truncate font-mono text-[10px]`,children:e.label}),(0,R.jsx)(`span`,{className:`block truncate text-[8px] text-muted-foreground`,children:e.file??e.package??e.symbolKind})]}),(0,R.jsx)(`span`,{className:`text-[8px] uppercase text-muted-foreground`,children:e.kind.slice(0,3)})]},e.id)}var q=80,at=40;function J(e,t){if(!e||t.size===0)return!1;let n=M(e);if(t.has(n))return!0;for(let e of t)if(e.endsWith(`/${n}`)||n.endsWith(`/${e}`))return!0;return!1}var ot=(0,A.memo)(function e(t){let{t:n}=i(),{directory:r,packageName:a,depth:s,expandedDirectories:c,expandedFiles:f,loadingBranches:p,graphForFile:m,onToggleDirectory:g,onToggleFile:_,onSelectFile:y,onOpenFile:b,onSelectSymbol:te,selectedId:x,activeFileNorms:ne,activeSymbolIds:re,revealAllKeys:ie,onRevealAll:C}=t,w=`files:${a}:${r.path||`.`}`,ae=ie.has(w)?r.files:r.files.slice(0,q),oe=r.files.length-ae.length;return(0,R.jsxs)(R.Fragment,{children:[r.directories.map(n=>{let r=`${a}:${n.path}`,i=c.has(r);return(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`button`,{type:`button`,className:`flex h-7 w-full items-center gap-1.5 pr-2 text-left text-[11px] text-muted-foreground hover:bg-muted hover:text-foreground`,style:{paddingLeft:8+s*12},onClick:()=>g(r),children:[i?(0,R.jsx)(o,{className:`h-3 w-3`}):(0,R.jsx)(d,{className:`h-3 w-3`}),i?(0,R.jsx)(u,{className:`h-3.5 w-3.5 text-warning`}):(0,R.jsx)(l,{className:`h-3.5 w-3.5 text-warning`}),(0,R.jsx)(`span`,{className:`truncate`,children:n.name})]}),i&&(0,R.jsx)(e,{...t,directory:n,depth:s+1})]},r)}),ae.map(e=>{let t=f.has(e.file??e.id),r=N({level:`symbols`,file:e.file??e.label}),i=(e.file?m(e.file):void 0)?.nodes.filter(t=>t.kind===`symbol`&&t.file===e.file&&!t.external)??[],a=`symbols:${e.file??e.id}`,c=ie.has(a)?i:i.slice(0,at),l=i.length-c.length,u=J(e.file,ne);return(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{className:k(`group flex h-7 items-center pr-1 text-[11px] hover:bg-muted`,x===e.id&&`bg-primary/10 text-primary`),style:{paddingLeft:8+s*12},children:[(0,R.jsx)(`button`,{type:`button`,className:`flex h-6 w-4 shrink-0 items-center justify-center text-muted-foreground`,onClick:()=>_(e),"aria-label":`${t?`Collapse`:`Expand`} ${e.label}`,children:p.has(r)?(0,R.jsx)(S,{className:`h-3 w-3 animate-spin`}):t?(0,R.jsx)(o,{className:`h-3 w-3`}):(0,R.jsx)(d,{className:`h-3 w-3`})}),(0,R.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-1.5 text-left`,onClick:()=>y(e),onDoubleClick:()=>b(e),children:[(0,R.jsx)(h,{className:`h-3.5 w-3.5 shrink-0 text-info`}),u&&(0,R.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 animate-pulse bg-success`,title:n(`activity:codeMap.liveOperation`)}),(0,R.jsx)(`span`,{className:`truncate font-mono`,title:e.file,children:e.label}),(0,R.jsx)(`span`,{className:`ml-auto text-[9px] text-muted-foreground`,children:e.symbolCount??0})]}),(0,R.jsx)(`button`,{type:`button`,className:`ml-1 hidden h-5 w-5 items-center justify-center text-muted-foreground hover:text-foreground group-hover:flex`,onClick:()=>b(e),title:n(`activity:codeMap.openSymbolMap`),"aria-label":`Open ${e.label} map`,children:(0,R.jsx)(v,{className:`h-3 w-3`})})]}),t&&c.map(e=>(0,R.jsxs)(`button`,{type:`button`,className:k(`flex h-7 w-full items-center gap-1.5 pr-2 text-left text-[10px] hover:bg-muted`,x===e.id?`bg-primary/10 text-primary`:`text-muted-foreground`),style:{paddingLeft:38+s*12},onClick:()=>te(e),children:[(0,R.jsx)(ee,{className:`h-3 w-3 shrink-0 text-success`}),re.has(e.id)&&(0,R.jsx)(D,{className:`h-3 w-3 shrink-0 animate-pulse text-success`}),(0,R.jsx)(`span`,{className:`truncate font-mono`,children:e.label}),e.line&&(0,R.jsxs)(`span`,{className:`ml-auto font-mono text-[8px] opacity-60`,children:[`:`,e.line]})]},e.id)),t&&l>0&&(0,R.jsxs)(`button`,{type:`button`,className:`flex h-7 w-full items-center text-left font-mono text-[9px] text-primary hover:bg-muted`,style:{paddingLeft:38+s*12},onClick:()=>C(a),children:[`Show `,l,` more symbols`]})]},e.id)}),oe>0&&(0,R.jsxs)(`button`,{type:`button`,className:`flex h-7 w-full items-center text-left font-mono text-[9px] text-primary hover:bg-muted`,style:{paddingLeft:8+s*12},onClick:()=>C(w),children:[`Show `,oe,` more files`]})]})});function st({rootGraph:e,search:n,searchInput:r,searchResults:a,virtualizeSearch:s,searchVirtualizer:c,treeScrollRef:l,selectedId:u,expandedPackages:f,expandedDirectories:p,expandedFiles:m,loadingBranches:h,activeFileNorms:_,activeSymbolIds:ee,revealAllKeys:b,packageGraph:te,graphForFile:x,navigate:ne,togglePackage:re,toggleDirectory:ie,toggleFile:C,revealAllTree:w,selectFileFromTree:ae,selectSymbolFromTree:oe,selectSearchResult:se,handleOpenNode:ce,onSearchInputChange:T,onSearchChange:le}){let{t:E}=i();return(0,R.jsxs)(`aside`,{className:`flex w-[286px] shrink-0 flex-col border-r bg-card/70`,children:[(0,R.jsxs)(`div`,{className:`border-b p-3`,children:[(0,R.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,R.jsx)(`h2`,{className:`text-[10px] font-bold uppercase tracking-[0.18em]`,children:E(`activity:codeMapTree.codeTree`)}),(0,R.jsxs)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:[e.nodes.length,` roots`]})]}),(0,R.jsxs)(`label`,{className:`flex h-8 items-center gap-2 border bg-background px-2 focus-within:border-primary`,children:[(0,R.jsx)(g,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,R.jsx)(`input`,{className:`min-w-0 flex-1 bg-transparent font-mono text-[10px] outline-none placeholder:text-muted-foreground`,value:r,onChange:e=>T(e.target.value),placeholder:E(`activity:codeMapTree.findPackageFileSymbol`)}),r&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>{T(``),le(``)},"aria-label":E(`activity:codeMapTree.clearSearch`),children:(0,R.jsx)(y,{className:`h-3 w-3 text-muted-foreground`})})]})]}),(0,R.jsx)(`div`,{ref:l,className:`min-h-0 flex-1 overflow-y-auto py-2`,children:n.trim()?(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{className:`px-3 pb-2 text-[9px] text-muted-foreground`,children:[a.length,` loaded-map results`]}),a.length===0?(0,R.jsxs)(`p`,{className:`px-3 py-8 text-center text-[10px] text-muted-foreground`,children:[E(`activity:codeMapTree.noMatchInLoadedBranches`),(0,R.jsx)(`br`,{}),E(`activity:codeMapTree.expandAPackageToSearchIts`)]}):s?(0,R.jsx)(`div`,{style:{height:`${c.getTotalSize()}px`,width:`100%`,position:`relative`},children:c.getVirtualItems().map(e=>{let t=a[e.index];return t?(0,R.jsx)(it,{node:t,onSelect:se,virtual:{index:e.index,start:e.start,measureElement:c.measureElement}},t.id):null})}):a.map(e=>(0,R.jsx)(it,{node:e,onSelect:se},e.id))]}):e.nodes.map(e=>{let n=e.package??e.label,r=f.has(n),i=N({level:`files`,package:n}),a=te(n),s=a?Oe(a.nodes):void 0;return(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{className:k(`group flex h-8 items-center px-2 hover:bg-muted`,u===e.id&&`bg-primary/10 text-primary`),children:[(0,R.jsx)(`button`,{type:`button`,className:`flex h-6 w-5 items-center justify-center text-muted-foreground`,onClick:()=>re(e),"aria-label":`${r?`Collapse`:`Expand`} ${n}`,children:h.has(i)?(0,R.jsx)(S,{className:`h-3 w-3 animate-spin`}):r?(0,R.jsx)(o,{className:`h-3 w-3`}):(0,R.jsx)(d,{className:`h-3 w-3`})}),(0,R.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-2 text-left`,onClick:()=>ne({level:`packages`},e.id),onDoubleClick:()=>ne({level:`files`,package:n}),children:[(0,R.jsx)(t,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,R.jsx)(`span`,{className:`truncate font-mono text-[10px] font-semibold`,children:e.label}),(0,R.jsx)(`span`,{className:`ml-auto text-[9px] text-muted-foreground`,children:e.fileCount??0})]}),(0,R.jsx)(`button`,{type:`button`,className:`ml-1 hidden h-5 w-5 items-center justify-center text-muted-foreground hover:text-foreground group-hover:flex`,onClick:()=>ne({level:`files`,package:n}),title:E(`activity:codeMapTree.openFileMap`),"aria-label":`Open ${n} map`,children:(0,R.jsx)(v,{className:`h-3 w-3`})})]}),r&&s&&(0,R.jsx)(ot,{directory:s,packageName:n,depth:1,expandedDirectories:p,expandedFiles:m,loadingBranches:h,graphForFile:x,onToggleDirectory:ie,onToggleFile:C,onSelectFile:ae,onOpenFile:ce,onSelectSymbol:oe,selectedId:u,activeFileNorms:_,activeSymbolIds:ee,revealAllKeys:b,onRevealAll:w})]},e.id)})}),(0,R.jsxs)(`div`,{className:`border-t px-3 py-2 text-[9px] leading-relaxed text-muted-foreground`,children:[E(`activity:codeMapTree.clickToFocusDoubleClickTo`),(0,R.jsx)(`br`,{}),E(`activity:codeMapTree.branchesStayOpenWhileTheMap`)]})]})}function ct(e,t){let n=new Map(e.map(e=>[e.id,e])),r=e.length!==t.length,i=t.map((t,i)=>{let a=n.get(t.id);return a?a.type===t.type&&a.position.x===t.position.x&&a.position.y===t.position.y&&Ge(a.data,t.data)?(e[i]!==a&&(r=!0),a):(r=!0,{...a,...t,measured:a.measured}):(r=!0,t)});return r?i:e}function lt(e){return e.data?.renderKey}function ut(e,t){let n=new Map(e.map(e=>[e.id,e])),r=e.length!==t.length,i=t.map((t,i)=>{let a=n.get(t.id);return a&&lt(a)===lt(t)?(e[i]!==a&&(r=!0),a):(r=!0,t)});return r?i:e}function dt(){let[e,t]=(0,A.useState)({level:`packages`}),n=N(e),[r,i]=(0,A.useState)(qe),[a,o]=(0,A.useState)(!0),[s,c]=(0,A.useState)(null),[l,u]=(0,A.useState)(null),[d,f]=(0,A.useState)(`layers`),[p,m]=(0,A.useState)(`smart`),[h,g]=(0,A.useState)(`all`),[_,ee]=(0,A.useState)(``),[v,y]=(0,A.useState)(``),[b,x]=(0,A.useState)(new Set),[re,S]=(0,A.useState)(new Set),[C,w]=(0,A.useState)(new Set),[ce,T]=(0,A.useState)(new Set),[le,E]=(0,A.useState)(new Set),[ue,D]=(0,A.useState)(new Set),[de,O]=(0,A.useState)(0),[k,ge]=(0,A.useState)(null),[j,be]=(0,A.useState)(!1),[P,xe]=(0,A.useState)(`all`),[F,we]=(0,A.useState)(null),[Te,I]=(0,A.useState)(null),[Ee,De]=(0,A.useState)(0),L=(0,A.useRef)(new Map),z=(0,A.useRef)(null),B=(0,A.useRef)(null),V=(0,A.useRef)(``),H=(0,A.useRef)(``),U=(0,A.useRef)(null),Ve=(0,A.useRef)(new Set),{history:He,pulses:Ue,activeOperationsMap:We,activityTotalCount:Ge,resolveActivitySymbol:Ke,getActivityForFile:Je,sweepActivity:Qe}=fe(ie(e=>({history:e.history,pulses:e.pulses,activeOperationsMap:e.activeOperations,activityTotalCount:e.totalCount,resolveActivitySymbol:e.resolveActivitySymbol,getActivityForFile:e.getActivityForFile,sweepActivity:e._sweep}))),W=(0,A.useMemo)(()=>[...We.values()].flat(),[We]),tt=(0,A.useMemo)(()=>[...Ue.keys()].map(e=>He.get(e)?.[0]).filter(e=>!!e),[He,Ue]),G=(0,A.useMemo)(()=>{let e=[];for(let t of He.values())e.push(...t.slice(0,16));return e.sort((e,t)=>t.timestamp-e.timestamp).slice(0,16)},[He]),nt=(0,A.useMemo)(()=>pe([...W,...G]),[W,G]),K=(0,A.useMemo)(()=>{let e=F??W;return P===`all`?e:e.filter(e=>me(e)===P)},[W,P,F]),it=(0,A.useMemo)(()=>{let e=Te??G;return P===`all`?e:e.filter(e=>me(e)===P)},[P,Te,G]),q=(0,A.useDeferredValue)(K),at=(0,A.useDeferredValue)(it),J=(0,A.useDeferredValue)(tt),ot=(0,A.useMemo)(()=>pe(K),[K]),[lt,dt,ft]=ae([]),[pt,mt,ht]=se([]),{fitView:gt}=ne(),Y=(0,A.useCallback)(async(e,t=!1)=>{let n=N(e),r=L.current.get(n);if(r&&!t)return Ae(L.current,n,r,48),r;let i=await fetch(_e(e),{credentials:`same-origin`});if(!i.ok){if(i.status===401||i.status===403)throw Error(`Authentication required — open this dashboard from its token URL.`);let e=await i.json().catch(()=>({error:i.statusText}));throw Error(e.error??`HTTP ${i.status}`)}let a=await i.json();return Ae(L.current,n,a,48),O(e=>e+1),a},[]);(0,A.useEffect)(()=>{let e=window.setTimeout(()=>y(_),150);return()=>window.clearTimeout(e)},[_]);let _t=he(e=>e.generation),vt=(0,A.useRef)(0),yt=(0,A.useRef)(null);(0,A.useEffect)(()=>{let t=!1,n=_t>vt.current;return n&&(vt.current=_t,L.current.clear(),O(e=>e+1),x(new Set),S(new Set),w(new Set),E(new Set)),o(!0),c(null),Y(e,n).then(e=>{if(!t){if(i(e),!n){let t=z.current;z.current=null,u(t&&e.nodes.some(e=>e.id===t)?t:null)}o(!1)}}).catch(e=>{t||(c(e instanceof Error?e.message:String(e)),i(qe),o(!1))}),()=>{t=!0}},[n,Y,_t,e]);let X=(0,A.useCallback)((e,r)=>{if(z.current=r??null,N(e)===n){u(r??null),z.current=null;return}t(e)},[n]),bt=(0,A.useCallback)(async e=>{let t=N(e);if(!(L.current.has(t)||ue.has(t))){D(e=>new Set(e).add(t));try{await Y(e)}finally{D(e=>{let n=new Set(e);return n.delete(t),n})}}},[Y,ue]);(0,A.useEffect)(()=>{let e=!1,t=0;for(let n of W){if(t>=2)break;if(n.symbol||!n.toolUseId||n.filePath.startsWith(`(`))continue;let r=n.filePath;Ve.current.has(r)||(Ve.current.add(r),t+=1,Y({level:`symbols`,file:r}).then(t=>{if(e)return;let i=Ie(n,t.nodes);i&&Ke(n.toolUseId,r,{id:i.id,name:i.label,...i.symbolKind?{kind:i.symbolKind}:{},...i.line?{line:i.line}:{}})}).catch(()=>void 0).finally(()=>{Ve.current.delete(r)}))}return()=>{e=!0}},[W,Y,Ke]);let Z=(0,A.useMemo)(()=>({nodes:r.nodes,edges:h===`all`?r.edges:r.edges.filter(e=>e.refType===h)}),[r,h]),Q=r.nodes.find(e=>e.id===l),$=(0,A.useMemo)(()=>Ce(Z,l,p),[p,Z,l]),xt=(0,A.useMemo)(()=>l?ye(Z,l):new Set,[Z,l]),{incomingCounts:St,outgoingCounts:Ct}=(0,A.useMemo)(()=>{let e=new Map,t=new Map;for(let n of Z.edges)t.set(n.source,(t.get(n.source)??0)+1),e.set(n.target,(e.get(n.target)??0)+1);return{incomingCounts:e,outgoingCounts:t}},[Z]),wt=d===`orbit`?l??void 0:void 0,Tt=(0,A.useMemo)(()=>Se($,d,wt),[$,d,wt]),Et=(0,A.useMemo)(()=>[n,d,d===`orbit`?l??``:``,ke($)].join(``),[$,n,d,l]),Dt=(0,A.useCallback)(e=>{u(e.id),T(new Set)},[]),Ot=(0,A.useCallback)(e=>{e.kind===`package`&&X({level:`files`,package:e.package??e.label}),e.kind===`file`&&e.file&&X({level:`symbols`,file:e.file,package:e.package})},[X]),kt=(0,A.useMemo)(()=>[Fe(q),Fe(J),Fe(at)].join(``),[q,J,at]),At=(0,A.useMemo)(()=>{let e=new Set;for(let t of K)e.add(M(t.filePath));return e},[K]),jt=(0,A.useMemo)(()=>{let e=new Set;for(let t of K)t.symbol?.id&&e.add(t.symbol.id);return e},[K]);(0,A.useEffect)(()=>{let e=()=>{let e=Tt.map(({node:e})=>e),t=Pe(e,q),n=Pe(e,J),r=new Set(t.keys()),i=Tt.map(({node:e,position:r})=>{let i=t.get(e.id)??[],a=i[0]??n.get(e.id)?.[0];return{id:e.id,type:`codemap`,position:r,data:{graphNode:e,selected:e.id===l,dimmed:!!l&&!xt.has(e.id),incoming:St.get(e.id)??0,outgoing:Ct.get(e.id)??0,isActive:!!a,...a?{activityType:a.type}:{},activeOperations:i,onSelect:Dt,onOpen:Ot,onShowHistory:ge}}});dt(e=>ct(e,i));let a=6,o=$.edges.map((e,t)=>{let n=!!l&&(e.source===l||e.target===l),i=r.has(e.source)||r.has(e.target),o=i&&(n||a>0);o&&--a;let s=Re[e.refType]??`hsl(var(--muted-foreground))`,c=n||i?`smoothstep`:`default`;return{id:`edge:${e.source}:${e.target}:${t}`,source:e.source,target:e.target,type:c,animated:o,label:n?`${e.refType}${e.weight>1?` ×${e.weight}`:``}`:void 0,markerEnd:{type:te.ArrowClosed,color:s,width:14,height:14},style:{stroke:s,strokeWidth:i?Math.min(2.5+Math.log2(e.weight+1)*.65,5):n?Math.min(1.25+Math.log2(e.weight+1)*.65,4):1,opacity:i?1:l?n?.88:.08:.52},labelStyle:{fontSize:9,fontFamily:`var(--font-mono)`,fill:`hsl(var(--muted-foreground))`},labelBgStyle:{fill:`hsl(var(--card))`,fillOpacity:.92},labelBgPadding:[4,2],zIndex:i?4:n?2:0,data:{renderKey:`${e.refType}:${e.weight}:${l?n?`focused`:`dimmed`:`idle`}:${i?`live`:`still`}:${o?`anim`:`still`}:${c}`}}}),s=new Map,c=new Set(q.map(me));for(let e of[...at].sort((e,t)=>e.timestamp-t.timestamp)){let t=me(e),n=s.get(t);n?n.push(e):s.set(t,[e])}let u=[...s.entries()].map(([e,t])=>({agentKey:e,activities:t,live:c.has(e),latest:t[t.length-1]?.timestamp??0})).sort((e,t)=>Number(t.live)-Number(e.live)||t.latest-e.latest).slice(0,4),d=[];for(let{agentKey:e,activities:t,live:n}of u){let r=t.slice(-7).map(e=>({activity:e,node:$.nodes.find(t=>Ne(e,t))})).filter(e=>!!e.node).filter((e,t,n)=>t===0||e.node.id!==n[t-1]?.node.id),i=Be(e);for(let t=1;t<r.length;t++){let o=r[t-1],s=r[t],c=n&&a>0;c&&--a,d.push({id:`trail:${e}:${o.activity.timestamp}:${s.activity.timestamp}`,source:o.node.id,target:s.node.id,type:`smoothstep`,animated:c,label:t===r.length-1?`${ze(s.activity.agentName??s.activity.agent??`agent`)} TRAIL`:void 0,markerEnd:{type:te.ArrowClosed,color:i,width:13,height:13},style:{stroke:i,strokeWidth:2.5,strokeDasharray:`7 5`,opacity:.9},labelStyle:{fontSize:8,fontWeight:700,fill:i},labelBgStyle:{fill:`hsl(var(--card))`,fillOpacity:.94},labelBgPadding:[4,2],zIndex:6,data:{renderKey:`${i}:${t===r.length-1?`label`:`plain`}:${n?`live`:`still`}:${c?`anim`:`still`}`}})}}De(d.length),mt(e=>ut(e,[...o,...d]))},t=Et,n=H.current!==t;H.current=t,U.current!==null&&(window.clearTimeout(U.current),U.current=null),n?e():U.current=window.setTimeout(()=>{U.current=null,e()},120);let r;return V.current!==Et&&(r=window.setTimeout(()=>{V.current=Et;let e=$.nodes.length>48?0:240;gt({padding:.2,duration:e,maxZoom:1.25})},20)),()=>{U.current!==null&&(window.clearTimeout(U.current),U.current=null),r!==void 0&&window.clearTimeout(r)}},[kt,$,l,q,at,J,Et,xt,gt,Ot,Dt,St,Ct,Tt,mt,dt]),(0,A.useEffect)(()=>{let e=window.setInterval(()=>{Qe()},2e3);return()=>window.clearInterval(e)},[Qe]);let Mt=L.current.get(`packages`)??(e.level===`packages`?r:qe),Nt=(0,A.useCallback)(e=>L.current.get(N({level:`files`,package:e})),[de]),Pt=(0,A.useCallback)(e=>L.current.get(N({level:`symbols`,file:e})),[de]),Ft=(0,A.useCallback)(e=>{let t=e.filePath,n=Me(e.filePath),r=`file:${e.filePath}`;for(let i of L.current.values()){let a=i.nodes.find(t=>t.kind===`file`&&!t.external&&je(t.file,e.filePath));if(a){t=a.file??t,n=a.package??n,r=a.id;break}}if(e.symbol){X({level:`symbols`,file:t,package:n},e.symbol.id);return}X({level:`files`,package:n},r)},[X]);(0,A.useEffect)(()=>{if(!j||F)return;let e=[...K].filter(e=>!e.filePath.startsWith(`(`)).sort((e,t)=>t.timestamp-e.timestamp)[0];if(!e)return;let t=`${e.id??e.toolUseId}:${e.filePath}:${e.symbol?.id??`file`}`;B.current!==t&&(B.current=t,Ft(e))},[K,j,Ft,F]);let It=(0,A.useCallback)(()=>{if(F){we(null),I(null);return}we([...W]),I([...G])},[W,F,G]),Lt=(0,A.useCallback)(e=>{let t=e.package??e.label,n=!b.has(t);x(e=>{let r=new Set(e);return n?r.add(t):r.delete(t),r}),n&&bt({level:`files`,package:t}).then(()=>{let e=L.current.get(N({level:`files`,package:t})),n=e?Oe(e.nodes):void 0;n?.directories.length===1&&n.directories[0]&&S(e=>new Set(e).add(`${t}:${n.directories[0].path}`))}).catch(()=>void 0)},[bt,b]),Rt=(0,A.useCallback)(e=>{if(!e.file)return;let t=!C.has(e.file);w(n=>{let r=new Set(n);return t?r.add(e.file):r.delete(e.file),r}),t&&bt({level:`symbols`,file:e.file,package:e.package}).catch(()=>void 0)},[bt,C]),zt=(0,A.useCallback)(e=>{S(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),Bt=(0,A.useCallback)(e=>{E(t=>new Set(t).add(e))},[]),Vt=(0,A.useCallback)(e=>{X({level:`files`,package:e.package??`(root)`},e.id)},[X]),Ht=(0,A.useCallback)(e=>{e.file&&X({level:`symbols`,file:e.file,package:e.package},e.id)},[X]),Ut=(0,A.useMemo)(()=>{let e=v.trim().toLocaleLowerCase();if(!e)return[];let t=new Map;for(let n of L.current.values())for(let r of n.nodes)`${r.label} ${r.file??``} ${r.signature??``} ${r.package??``}`.toLocaleLowerCase().includes(e)&&t.set(r.id,r);return[...t.values()].sort((e,t)=>e.kind.localeCompare(t.kind)||e.label.localeCompare(t.label)).slice(0,80)},[v,de]),Wt=Ut.length>40,Gt=oe({count:Ut.length,getScrollElement:()=>yt.current,estimateSize:()=>40,overscan:8,enabled:Wt}),Kt=(0,A.useCallback)(e=>{e.kind===`package`?X({level:`packages`},e.id):e.kind===`file`?X({level:`files`,package:e.package??`(root)`},e.id):e.file&&X({level:`symbols`,file:e.file,package:e.package},e.id)},[X]),{incoming:qt,outgoing:Jt}=(0,A.useMemo)(()=>({incoming:Q?ve(Z,Q.id,`incoming`):[],outgoing:Q?ve(Z,Q.id,`outgoing`):[]}),[Z,Q]),{edgeWeight:Yt,connectedNodeCount:Xt}=(0,A.useMemo)(()=>{let e=0,t=new Set;for(let n of Z.edges)e+=n.weight,t.add(n.source),t.add(n.target);return{edgeWeight:e,connectedNodeCount:t.size}},[Z]),Zt=Q?K.filter(e=>Ne(e,Q)):[],Qt=k?Je(k):[];return(0,R.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-background`,children:[(0,R.jsx)(Ze,{scope:e,graph:r,agentPresences:ot,edgeWeight:Yt,connectedNodeCount:Xt,navigate:X}),(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,R.jsx)(st,{rootGraph:Mt,search:v,searchInput:_,searchResults:Ut,virtualizeSearch:Wt,searchVirtualizer:Gt,treeScrollRef:yt,selectedId:l,expandedPackages:b,expandedDirectories:re,expandedFiles:C,loadingBranches:ue,activeFileNorms:At,activeSymbolIds:jt,revealAllKeys:le,packageGraph:Nt,graphForFile:Pt,navigate:X,togglePackage:Lt,toggleDirectory:zt,toggleFile:Rt,revealAllTree:Bt,selectFileFromTree:Vt,selectSymbolFromTree:Ht,selectSearchResult:Kt,handleOpenNode:Ot,onSearchInputChange:ee,onSearchChange:y}),(0,R.jsxs)(`main`,{className:`relative min-w-0 flex-1 bg-[radial-gradient(circle_at_50%_0%,hsl(var(--primary)/0.055),transparent_38%)]`,children:[(0,R.jsx)(Xe,{layout:d,canvasMode:p,edgeFilter:h,canvasNodeCount:$.nodes.length,graphNodeCount:r.nodes.length,onLayoutChange:f,onCanvasModeChange:m,onEdgeFilterChange:g}),(0,R.jsx)($e,{presences:ot,onLocate:Ft}),(0,R.jsx)(et,{paused:F!==null,followLive:j,agentFilter:P,agents:nt,onTogglePaused:It,onToggleFollow:()=>{B.current=null,be(e=>!e)},onAgentFilter:e=>{B.current=null,xe(e)}}),(0,R.jsx)(Ye,{loading:a,error:s,graph:r,canvasNodeCount:$.nodes.length,flowNodes:lt,flowEdges:pt,onNodesChange:ft,onEdgesChange:ht,agentTrailCount:Ee})]}),(0,R.jsx)(rt,{selectedNode:Q,incoming:qt,outgoing:Jt,filteredGraph:Z,expandedRelations:ce,activeOperations:K,recentActivities:it,activityTotalCount:Ge,selectedActivities:Zt,onClearSelection:()=>u(null),onOpenNode:Ot,onOpenActivity:ge,onLocateActivity:Ft,onToggleRelation:e=>T(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),onSelectNode:Dt})]}),k&&(0,R.jsx)(Le,{historyFile:k,fileHistory:Qt,onClose:()=>ge(null)})]})}function ft(){return(0,R.jsx)(le,{children:(0,R.jsx)(dt,{})})}export{ft as CodeMap};