@wrongstack/webui 0.293.0 → 0.295.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (256) hide show
  1. package/dist/App.d.ts.map +1 -1
  2. package/dist/assets/AgentRosterView-C7u9H5Jp.js +11 -0
  3. package/dist/assets/AnalyticsDashboard-CZ8KAg7h.js +1 -0
  4. package/dist/assets/AudienceMemoryPanel-N6ErXDAb.js +3 -0
  5. package/dist/assets/ChangesView-fVxtWQ07.js +1 -0
  6. package/dist/assets/ChronicleDashboard-C-NQsArq.js +1 -0
  7. package/dist/assets/CodeEditor-B9k1HwTM.js +1 -0
  8. package/dist/assets/CodeMap-CZ7wFa8f.js +1 -0
  9. package/dist/assets/ConfirmModal-BvW6_eIc.js +1 -0
  10. package/dist/assets/{CronJobsPanel-ByJqIjCv.js → CronJobsPanel-C4zvyecc.js} +1 -1
  11. package/dist/assets/{DebugDashboard-B0pikasm.js → DebugDashboard-Z7ZFkSFX.js} +1 -1
  12. package/dist/assets/DesignGalleryView-DIsg05FX.js +1 -0
  13. package/dist/assets/{GoalView-DXO9txQs.js → GoalView-pBKJcLBt.js} +1 -1
  14. package/dist/assets/KanbanView-qzKvGeMx.js +3 -0
  15. package/dist/assets/{LazyMarkdown-BHoUIDge.js → LazyMarkdown-Cpjlf6IL.js} +3 -3
  16. package/dist/assets/MailboxDetailView-BKxA4wf_.js +1 -0
  17. package/dist/assets/MemoryManager-DO_Z8Scl.js +1 -0
  18. package/dist/assets/{ModelPicker-CEZN673P.js → ModelPicker-DOXb0iz4.js} +1 -1
  19. package/dist/assets/{OfficeMapPanel-B0j4e2O1.css → OfficeMapPanel-BFIF-EMt.css} +1 -1
  20. package/dist/assets/OfficeMapPanel-BVDeIWuD.js +4 -0
  21. package/dist/assets/ProcessMonitor-Ci000o1n.js +1 -0
  22. package/dist/assets/{QueuePanel-DMXksqFS.js → QueuePanel-63vvbJOy.js} +1 -1
  23. package/dist/assets/{RefreshDebugView-D08bCHA4.js → RefreshDebugView-8Sivo34V.js} +1 -1
  24. package/dist/assets/SddHub-DW97GpcS.js +2 -0
  25. package/dist/assets/{SessionsDashboard-BY77vax1.js → SessionsDashboard-DhNaepDJ.js} +1 -1
  26. package/dist/assets/SetupScreen-BewutFxF.js +1 -0
  27. package/dist/assets/SkillDetailView-d39kknmg.js +3 -0
  28. package/dist/assets/{SpecsView-CZg7e2ml.js → SpecsView-BOp0sUME.js} +1 -1
  29. package/dist/assets/TechStackView-DfFfTJVR.js +1 -0
  30. package/dist/assets/{TerminalPanel-SnRvUh6N.js → TerminalPanel-663hC2Jc.js} +1 -1
  31. package/dist/assets/{Toaster-BNdKxZ1U.js → Toaster-YMBi0Ssd.js} +1 -1
  32. package/dist/assets/activity-3HtRx2SK.js +5 -0
  33. package/dist/assets/activity-BGlYr63p.js +5 -0
  34. package/dist/assets/activity-BolwRvqr.js +5 -0
  35. package/dist/assets/activity-C8BMSvRx.js +5 -0
  36. package/dist/assets/{activity-Dyikq8Zm.js → activity-CM8z-okz.js} +4 -4
  37. package/dist/assets/activity-HfL12UVp.js +5 -0
  38. package/dist/assets/activity-Xd77MZv_.js +5 -0
  39. package/dist/assets/{button-Dy0bAtEY.js → button-5TIs9T5p.js} +1 -1
  40. package/dist/assets/{chat-store-CUODHW6c.js → chat-store-fBghgjNK.js} +7 -7
  41. package/dist/assets/{codemap-activity-store-CgtLR4PV.js → codemap-activity-store-C5DyqUoZ.js} +1 -1
  42. package/dist/assets/codemap-index-store-p2tz1Laz.js +1 -0
  43. package/dist/assets/{dialog-CBgO-uqz.js → dialog-BkCs93Vo.js} +1 -1
  44. package/dist/assets/empty-state-DrJ4uVh8.js +1 -0
  45. package/dist/assets/{i18n-Dk35g-uV.js → i18n-Cjk0Ya0G.js} +2 -2
  46. package/dist/assets/index-D0zt9ziw.css +1 -0
  47. package/dist/assets/index-HYvJnpTs.js +126 -0
  48. package/dist/assets/{input-B6FY_vtB.js → input-dEFwkTqb.js} +1 -1
  49. package/dist/assets/{mailbox-store-BY2SVw-s.js → mailbox-store-DC7x_eml.js} +1 -1
  50. package/dist/assets/progress-ring-CGN0o9DE.js +1 -0
  51. package/dist/assets/roster-ws-GsDcHg-w.js +1 -0
  52. package/dist/assets/{session-store-Coiik-Ib.js → session-store-DGtTSpPv.js} +1 -1
  53. package/dist/assets/{settings-C65WW7Jn.js → settings-24NUQrlz.js} +1 -1
  54. package/dist/assets/{settings-Dp5NIt-h.js → settings-BcyGqyX3.js} +1 -1
  55. package/dist/assets/{settings-B9dVH8oJ.js → settings-BhEHLxqK.js} +1 -1
  56. package/dist/assets/{settings-BBR9xBqW.js → settings-C67tfoiy.js} +1 -1
  57. package/dist/assets/{settings-BaZcBGA7.js → settings-CvkIXOQE.js} +1 -1
  58. package/dist/assets/{settings-BXWyZpz5.js → settings-DGTQ4aKo.js} +1 -1
  59. package/dist/assets/{settings-BK1-R1dO.js → settings-i7lxRYZu.js} +1 -1
  60. package/dist/assets/shared-C_yjayIp.js +1 -0
  61. package/dist/assets/stores-BSWgxKNz.js +6 -0
  62. package/dist/assets/ui-store-DPNSalc-.js +1 -0
  63. package/dist/assets/useWebSocket-BBOEYTRy.js +28 -0
  64. package/dist/assets/{utils-DEzFewqr.js → utils-YTsIExHc.js} +1 -1
  65. package/dist/assets/{vendor-DffL_bim.js → vendor-B8C0AAAG.js} +30 -30
  66. package/dist/assets/{view-navigation-BjlXpDXc.js → view-navigation-CV5XT76I.js} +1 -1
  67. package/dist/assets/ws-client-Cc6w_0zh.js +1 -0
  68. package/dist/components/AgentOfficeView.d.ts.map +1 -1
  69. package/dist/components/AgentRosterView.d.ts +16 -0
  70. package/dist/components/AgentRosterView.d.ts.map +1 -0
  71. package/dist/components/AgentRuntimePolicyEditor.d.ts +8 -0
  72. package/dist/components/AgentRuntimePolicyEditor.d.ts.map +1 -0
  73. package/dist/components/AvailabilityCalendarEditor.d.ts +1 -1
  74. package/dist/components/AvailabilityCalendarEditor.d.ts.map +1 -1
  75. package/dist/components/ChangesView.d.ts.map +1 -1
  76. package/dist/components/ChatInput/slash-commands.d.ts.map +1 -1
  77. package/dist/components/ChatInput/slash-routing.d.ts +2 -0
  78. package/dist/components/ChatInput/slash-routing.d.ts.map +1 -1
  79. package/dist/components/ChatInput.d.ts.map +1 -1
  80. package/dist/components/ChatView/index.d.ts.map +1 -1
  81. package/dist/components/ChronicleDashboard.d.ts.map +1 -1
  82. package/dist/components/CodeEditor.d.ts.map +1 -1
  83. package/dist/components/CodeMap.d.ts +6 -0
  84. package/dist/components/CodeMap.d.ts.map +1 -1
  85. package/dist/components/ContextDashboard.d.ts.map +1 -1
  86. package/dist/components/CronTrigger.d.ts +1 -1
  87. package/dist/components/CronTrigger.d.ts.map +1 -1
  88. package/dist/components/CustomRosterPanel.d.ts +38 -0
  89. package/dist/components/CustomRosterPanel.d.ts.map +1 -0
  90. package/dist/components/DesignGalleryView.d.ts.map +1 -1
  91. package/dist/components/FileActivityDrawer.d.ts +14 -0
  92. package/dist/components/FileActivityDrawer.d.ts.map +1 -1
  93. package/dist/components/FleetMonitor.d.ts.map +1 -1
  94. package/dist/components/KanbanDecompositionPanel.d.ts +28 -0
  95. package/dist/components/KanbanDecompositionPanel.d.ts.map +1 -0
  96. package/dist/components/KanbanTaskTree.d.ts +13 -0
  97. package/dist/components/KanbanTaskTree.d.ts.map +1 -0
  98. package/dist/components/KanbanVerificationDashboard.d.ts +12 -0
  99. package/dist/components/KanbanVerificationDashboard.d.ts.map +1 -0
  100. package/dist/components/KanbanView.d.ts +17 -1
  101. package/dist/components/KanbanView.d.ts.map +1 -1
  102. package/dist/components/MailboxDetailView.d.ts.map +1 -1
  103. package/dist/components/MailboxPanel.d.ts.map +1 -1
  104. package/dist/components/MemoryManager/MemoryDetail.d.ts +4 -4
  105. package/dist/components/MemoryManager/MemoryDetail.d.ts.map +1 -1
  106. package/dist/components/MemoryManager/MemoryEditor.d.ts.map +1 -1
  107. package/dist/components/MemoryManager/MemoryFilters.d.ts +4 -4
  108. package/dist/components/MemoryManager/MemoryFilters.d.ts.map +1 -1
  109. package/dist/components/MemoryManager/MemoryGraph.d.ts +4 -4
  110. package/dist/components/MemoryManager/MemoryGraph.d.ts.map +1 -1
  111. package/dist/components/MemoryManager/MemoryList.d.ts +3 -3
  112. package/dist/components/MemoryManager/MemoryList.d.ts.map +1 -1
  113. package/dist/components/MemoryManager/index.d.ts.map +1 -1
  114. package/dist/components/MemoryManager/shared.d.ts +15 -15
  115. package/dist/components/MemoryManager/shared.d.ts.map +1 -1
  116. package/dist/components/MessageBubble/index.d.ts.map +1 -1
  117. package/dist/components/OfficeMapCanvas/resolve.d.ts +17 -1
  118. package/dist/components/OfficeMapCanvas/resolve.d.ts.map +1 -1
  119. package/dist/components/OfficeMapCanvas/use-recently-finished.d.ts +21 -0
  120. package/dist/components/OfficeMapCanvas/use-recently-finished.d.ts.map +1 -0
  121. package/dist/components/OfficeMapCanvas.d.ts.map +1 -1
  122. package/dist/components/ProcessMonitor.d.ts.map +1 -1
  123. package/dist/components/QueuePanel.d.ts.map +1 -1
  124. package/dist/components/RefinePanel.d.ts +10 -3
  125. package/dist/components/RefinePanel.d.ts.map +1 -1
  126. package/dist/components/SddBoardView.d.ts.map +1 -1
  127. package/dist/components/SddTaskDrawer.d.ts.map +1 -1
  128. package/dist/components/SearchOverlay.d.ts.map +1 -1
  129. package/dist/components/SettingsPanel/BrainSection.d.ts.map +1 -1
  130. package/dist/components/SettingsPanel/ChimeraSettingsPanel.d.ts.map +1 -1
  131. package/dist/components/SettingsPanel/MCPSection.d.ts +4 -0
  132. package/dist/components/SettingsPanel/MCPSection.d.ts.map +1 -1
  133. package/dist/components/SettingsPanel/PluginToggleList.d.ts.map +1 -1
  134. package/dist/components/SettingsPanel/PreferenceControls.d.ts +3 -1
  135. package/dist/components/SettingsPanel/PreferenceControls.d.ts.map +1 -1
  136. package/dist/components/SettingsPanel/PreferenceToggle.d.ts +3 -1
  137. package/dist/components/SettingsPanel/PreferenceToggle.d.ts.map +1 -1
  138. package/dist/components/SettingsPanel/ProviderModelsPanel.d.ts.map +1 -1
  139. package/dist/components/SettingsPanel/ProviderSection.d.ts.map +1 -1
  140. package/dist/components/SettingsPanel/index.d.ts.map +1 -1
  141. package/dist/components/SettingsPanel/local-presets.d.ts +2 -29
  142. package/dist/components/SettingsPanel/local-presets.d.ts.map +1 -1
  143. package/dist/components/SetupScreen.d.ts.map +1 -1
  144. package/dist/components/ShortcutsOverlay.d.ts.map +1 -1
  145. package/dist/components/SidePanel/AgentsPanel.d.ts.map +1 -1
  146. package/dist/components/SidePanel/SessionPanel.d.ts.map +1 -1
  147. package/dist/components/SidePanel/SkillsList.d.ts.map +1 -1
  148. package/dist/components/SkillDetailView.d.ts.map +1 -1
  149. package/dist/components/TaskVerificationSection.d.ts +15 -0
  150. package/dist/components/TaskVerificationSection.d.ts.map +1 -0
  151. package/dist/components/TechStackView/DependencyDetail.d.ts +2 -1
  152. package/dist/components/TechStackView/DependencyDetail.d.ts.map +1 -1
  153. package/dist/components/TechStackView/DependencyTable.d.ts +2 -1
  154. package/dist/components/TechStackView/DependencyTable.d.ts.map +1 -1
  155. package/dist/components/TechStackView/index.d.ts.map +1 -1
  156. package/dist/components/TechStackView/shared.d.ts +37 -4
  157. package/dist/components/TechStackView/shared.d.ts.map +1 -1
  158. package/dist/components/VerificationReportPanel.d.ts +15 -0
  159. package/dist/components/VerificationReportPanel.d.ts.map +1 -0
  160. package/dist/components/activity-bar/index.d.ts.map +1 -1
  161. package/dist/components/agents/AgentDetailSection.d.ts.map +1 -1
  162. package/dist/components/agents/AgentRosterCard.d.ts.map +1 -1
  163. package/dist/components/agents/FleetSummaryBar.d.ts.map +1 -1
  164. package/dist/components/codemap-model.d.ts +9 -0
  165. package/dist/components/codemap-model.d.ts.map +1 -1
  166. package/dist/components/ui/api-key-display.d.ts +14 -0
  167. package/dist/components/ui/api-key-display.d.ts.map +1 -0
  168. package/dist/components/ui/empty-state.d.ts +29 -0
  169. package/dist/components/ui/empty-state.d.ts.map +1 -0
  170. package/dist/components/ui/progress-ring.d.ts +10 -0
  171. package/dist/components/ui/progress-ring.d.ts.map +1 -0
  172. package/dist/hooks/useGlobalKeyboardShortcuts.d.ts +1 -1
  173. package/dist/hooks/useGlobalKeyboardShortcuts.d.ts.map +1 -1
  174. package/dist/hooks/useWebSocket.d.ts +13 -13
  175. package/dist/hooks/useWebSocket.d.ts.map +1 -1
  176. package/dist/hooks/ws-handlers/chat-handlers.d.ts.map +1 -1
  177. package/dist/hooks/ws-handlers/fleet-handlers.d.ts.map +1 -1
  178. package/dist/hooks/ws-handlers/session-handlers.d.ts.map +1 -1
  179. package/dist/hooks/ws-handlers.d.ts +8 -7
  180. package/dist/hooks/ws-handlers.d.ts.map +1 -1
  181. package/dist/index.css +258 -7
  182. package/dist/index.css.map +2 -2
  183. package/dist/index.html +24 -23
  184. package/dist/index.js +14600 -8873
  185. package/dist/index.js.map +4 -4
  186. package/dist/lib/agent-office.d.ts +22 -0
  187. package/dist/lib/agent-office.d.ts.map +1 -1
  188. package/dist/lib/kanban-verification.d.ts +52 -0
  189. package/dist/lib/kanban-verification.d.ts.map +1 -0
  190. package/dist/lib/model-calendar.d.ts +1 -1
  191. package/dist/lib/model-calendar.d.ts.map +1 -1
  192. package/dist/lib/model-matrix-routes.d.ts +2 -191
  193. package/dist/lib/model-matrix-routes.d.ts.map +1 -1
  194. package/dist/lib/plugin-enablement.d.ts +1 -1
  195. package/dist/lib/plugin-enablement.d.ts.map +1 -1
  196. package/dist/lib/roster-ws.d.ts +48 -0
  197. package/dist/lib/roster-ws.d.ts.map +1 -0
  198. package/dist/lib/view-navigation.d.ts +1 -1
  199. package/dist/lib/view-navigation.d.ts.map +1 -1
  200. package/dist/lib/ws-client-utils.d.ts +1 -2
  201. package/dist/lib/ws-client-utils.d.ts.map +1 -1
  202. package/dist/lib/ws-client.d.ts +30 -22
  203. package/dist/lib/ws-client.d.ts.map +1 -1
  204. package/dist/protocol-compatibility.d.ts +12 -0
  205. package/dist/protocol-compatibility.d.ts.map +1 -0
  206. package/dist/providers.json +105 -85
  207. package/dist/stores/codemap-index-store.d.ts +9 -0
  208. package/dist/stores/codemap-index-store.d.ts.map +1 -0
  209. package/dist/stores/kanban-store.d.ts +4 -0
  210. package/dist/stores/kanban-store.d.ts.map +1 -1
  211. package/dist/stores/local-prefs.d.ts +2 -2
  212. package/dist/stores/local-prefs.d.ts.map +1 -1
  213. package/dist/stores/mailbox-store.d.ts +2 -0
  214. package/dist/stores/mailbox-store.d.ts.map +1 -1
  215. package/dist/stores/session-store.d.ts +1 -1
  216. package/dist/stores/session-store.d.ts.map +1 -1
  217. package/dist/stores/specs-store.d.ts +4 -0
  218. package/dist/stores/specs-store.d.ts.map +1 -1
  219. package/dist/stores/types.d.ts +1 -1
  220. package/dist/stores/types.d.ts.map +1 -1
  221. package/dist/stores/ui-store.d.ts +6 -4
  222. package/dist/stores/ui-store.d.ts.map +1 -1
  223. package/dist/stores/viz-store.d.ts.map +1 -1
  224. package/dist/types.d.ts +482 -68
  225. package/dist/types.d.ts.map +1 -1
  226. package/package.json +7 -6
  227. package/dist/assets/AnalyticsDashboard--x-f8QI-.js +0 -1
  228. package/dist/assets/AudienceMemoryPanel-j9I0RvhP.js +0 -3
  229. package/dist/assets/ChangesView-Bb5LXWiI.js +0 -1
  230. package/dist/assets/ChronicleDashboard-D34oKMQ_.js +0 -1
  231. package/dist/assets/CodeEditor-BkIIR8EU.js +0 -1
  232. package/dist/assets/CodeMap-Ej4UNFUm.js +0 -1
  233. package/dist/assets/ConfirmModal-4l0Tyazp.js +0 -1
  234. package/dist/assets/DesignGalleryView-CgLsdzTx.js +0 -1
  235. package/dist/assets/KanbanView--bFrj9Xa.js +0 -2
  236. package/dist/assets/MailboxDetailView-C-Vf3h1d.js +0 -1
  237. package/dist/assets/MemoryManager-DoHNBnKd.js +0 -1
  238. package/dist/assets/OfficeMapPanel-BMf4PTWo.js +0 -4
  239. package/dist/assets/ProcessMonitor-BtfARuHq.js +0 -1
  240. package/dist/assets/SddHub-QgMFn_rC.js +0 -2
  241. package/dist/assets/SetupScreen-CU7Mq-5T.js +0 -1
  242. package/dist/assets/SkillDetailView-6ZIVx1BG.js +0 -3
  243. package/dist/assets/TechStackView-9hfnNKx-.js +0 -1
  244. package/dist/assets/activity-AfUMXtSI.js +0 -5
  245. package/dist/assets/activity-Bd_pRifE.js +0 -5
  246. package/dist/assets/activity-Ct_QOdtL.js +0 -5
  247. package/dist/assets/activity-Cyx4UukM.js +0 -5
  248. package/dist/assets/activity-Ukyu3lON.js +0 -5
  249. package/dist/assets/activity-gaWDc806.js +0 -5
  250. package/dist/assets/index-DGX8tPCe.css +0 -1
  251. package/dist/assets/index-OmSX-BAb.js +0 -124
  252. package/dist/assets/shared-CpXz-tzA.js +0 -1
  253. package/dist/assets/stores-CUp_ut8r.js +0 -6
  254. package/dist/assets/ui-store-CwOvhFZG.js +0 -1
  255. package/dist/assets/useWebSocket-BJorYmOi.js +0 -27
  256. package/dist/assets/ws-client-Fnmzo7vN.js +0 -1
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Bn as t,Fr as n,Kt as r,Nt as i,Or as a,Pi as o,Qi as s,Vn as c,Vt as l,gi as u,li as d,oa as f,ot as p,pr as m,pt as h,rn as g,ta as _,tt as v,wi as y,xi as b,y as x,zr as ee}from"./vendor-DffL_bim.js";import"./i18n-Dk35g-uV.js";import{a as S,i as C,n as w,o as T,r as E,t as D}from"./monaco-C7izDJhg.js";import{t as te}from"./ws-client-Fnmzo7vN.js";import{t as O}from"./utils-DEzFewqr.js";import{i as k}from"./codemap-activity-store-CgtLR4PV.js";import{E as A,O as j,j as ne,o as re,u as ie}from"./stores-CUp_ut8r.js";import{s as M}from"./view-navigation-BjlXpDXc.js";import{b as ae,w as N,x as P}from"./index-OmSX-BAb.js";import{t as F}from"./monaco-theme-BoNOJHQB.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,B=5e3,V=1e4;function H(e){return I[e.split(`.`).pop()?.toLowerCase()??``]??`plaintext`}function U(e){return e.match(/([A-Za-z_$][\w$]*)$/)?.[1]??``}function W(e,t){return e.triggerCharacter?!0:t.length>=3}function G(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 oe(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(f(),1),q=v(),J=150,se=224,ce=38,le=/(write|edit|update|create|delete|rename|modified|changed)/i;function ue(e){return e.replace(/\\/g,`/`).replace(/^\.\//,``).replace(/\/{2,}/g,`/`).toLowerCase()}function Y(e,t){let n=ue(e),r=ue(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=>le.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 X(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=X(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??X(t.actor)??`external`,source:X(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??X(t.taskId),boardId:X(t.boardId)??e.scope.boardId,tool:X(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=P(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}=_(),[r,a]=(0,K.useState)(!0),[o,l]=(0,K.useState)(se),[d,f]=(0,K.useState)(`overview`),[p,h]=(0,K.useState)([]),[v,x]=(0,K.useState)(!1),[S,C]=(0,K.useState)(null),[w,T]=(0,K.useState)(null),E=(0,K.useRef)(null),D=ne(e=>e.wsUrl),A=k(e=>e.history),j=k(e=>e.activeOperations),M=ie(e=>e.activeBoard),N=re(e=>e.snapshot),P=(0,K.useMemo)(()=>te(D),[D]),F=(0,K.useCallback)(()=>{C(null),x(!0),typeof P.getGitDiff==`function`&&P.getGitDiff(e.path),typeof P.supportsCapability==`function`&&P.supportsCapability(`chronicle.query`)?P.send({type:`chronicle.query`,payload:{query:{path:e.path,resourceKind:`file`,order:`desc`,limit:150}}}):x(!1)},[P,e.path]);(0,K.useEffect)(()=>{h([]),T(null);let t=P.on(`chronicle.query_result`,t=>{if(t.type!==`chronicle.query_result`)return;let n=t.payload.events.filter(t=>t.resource?.path&&Y(t.resource.path,e.path));t.payload.events.length>0&&n.length===0||(h(n),x(!1))}),n=P.on(`chronicle.error`,e=>{e.type===`chronicle.error`&&(C(e.payload.message),x(!1))}),r=P.on(`git.diff`,t=>{if(t.type!==`git.diff`||!Y(t.payload.path,e.path))return;let n=t.payload;if(n.error||n.binary||n.tooLarge){T({text:e.savedContent,available:!1,error:n.error});return}T({text:n.oldText??``,available:!0})});return F(),()=>{t(),n(),r()}},[P,e.path,e.savedContent,F]),(0,K.useEffect)(()=>{let e=e=>{if(!E.current)return;let t=E.current.startY-e.clientY,n=Math.max(J,Math.floor(window.innerHeight*.62));l(Math.min(n,Math.max(J,E.current.startHeight+t)))},t=()=>{E.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 I=(0,K.useMemo)(()=>{let t=[];for(let[n,r]of A)Y(n,e.path)&&t.push(...r);for(let n of j.values())t.push(...n.filter(t=>Y(t.filePath,e.path)));return t},[j,e.path,A]),L=(0,K.useMemo)(()=>he([...I.map(me),...p.map(pe)]),[p,I]),R=(0,K.useMemo)(()=>de(L),[L]),z=w?.text??e.savedContent,B=(0,K.useMemo)(()=>be(z,e.content),[z,e.content]),V=(0,K.useMemo)(()=>[...new Set(L.map(e=>e.sessionId).filter(e=>!!e))],[L]),H=(0,K.useMemo)(()=>[...new Set(L.map(e=>e.actor).filter(Boolean))],[L]),U=(0,K.useMemo)(()=>[...new Set(L.map(e=>e.taskId).filter(e=>!!e))],[L]),W=(0,K.useCallback)(e=>{let t=M?.tasks.find(t=>t.id===e),n=N?.tasks.find(t=>t.id===e||t.shortId===e);return t?.title??n?.title??e},[M,N]),G=e=>{r||a(!0),E.current={startY:e.clientY,startHeight:r?o:J},document.body.style.cursor=`ns-resize`,document.body.style.userSelect=`none`},oe=[{id:`overview`,label:t(`activity:fileActivity.overview`),icon:(0,q.jsx)(s,{})},{id:`changes`,label:t(`activity:fileActivity.changes`),icon:(0,q.jsx)(n,{})},{id:`context`,label:t(`activity:fileActivity.context`),icon:(0,q.jsx)(c,{})},{id:`logs`,label:t(`activity:fileActivity.logs`),icon:(0,q.jsx)(i,{})}];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:r?o:ce},"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:G,onDoubleClick:()=>{a(!0),l(se)},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:()=>a(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":r,children:[(0,q.jsx)(ee,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,q.jsx)(`span`,{className:`truncate`,children:t(`activity:fileActivity.title`)}),r?(0,q.jsx)(y,{className:`h-3 w-3`}):(0,q.jsx)(b,{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))}),!B.large&&(B.added>0||B.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:[`+`,B.added]}),(0,q.jsxs)(`span`,{className:`text-destructive`,children:[`−`,B.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`,R.level===`churn`&&`bg-destructive/10 text-destructive`,R.level===`active`&&`bg-warning/10 text-warning`,R.level===`quiet`&&`bg-success/10 text-success`),children:[(0,q.jsx)(u,{className:`h-2.5 w-2.5`}),t(`activity:fileActivity.level.${R.level}`)]}),(0,q.jsx)(`span`,{className:`hidden text-[9px] text-muted-foreground lg:inline`,children:t(`activity:fileActivity.evidenceCount`,{count:L.length})}),r&&(0,q.jsx)(`button`,{type:`button`,onClick:F,className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,title:t(`activity:fileActivity.refresh`),children:(0,q.jsx)(g,{className:O(`h-3.5 w-3.5`,v&&`animate-spin`)})})]}),r&&(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:[oe.map(e=>(0,q.jsxs)(`button`,{type:`button`,onClick:()=>f(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`,d===e.id?`border-primary font-medium text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`),children:[e.icon,e.label]},e.id)),S&&(0,q.jsx)(`span`,{className:`ml-auto truncate px-2 text-[9px] text-warning`,children:S})]}),(0,q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[d===`overview`&&(0,q.jsx)(Ce,{analysis:R,records:L,sessions:V,agents:H,tasks:U,taskLabel:W}),d===`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)(m,{className:`h-3 w-3`}),(0,q.jsx)(`span`,{children:w?.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`)}),w?.error&&(0,q.jsx)(`span`,{className:`truncate text-warning`,children:w.error})]}),(0,q.jsx)(`div`,{className:`h-[calc(100%-24px)] min-h-[90px]`,children:(0,q.jsx)(ae,{oldText:z,newText:e.content,caption:e.path,fill:!0})})]}),d===`context`&&(0,q.jsx)(we,{sessions:V,agents:H,tasks:U,records:L,taskLabel:W,boardTitle:M?.title??N?.title}),d===`logs`&&(0,q.jsx)(Te,{records:L,loading:v})]})]})]})}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,records:t,sessions:r,agents:i,tasks:a,taskLabel:s}){let{t:u}=_();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:u(`activity:fileActivity.mutations30m`),value:e.mutationCount,icon:(0,q.jsx)(n,{})},{label:u(`activity:fileActivity.sessions`),value:r.length,icon:(0,q.jsx)(h,{})},{label:u(`activity:fileActivity.actors`),value:i.length,icon:(0,q.jsx)(o,{})},{label:u(`activity:fileActivity.linkedWork`),value:a.length,icon:(0,q.jsx)(c,{})}].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))}),(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)(l,{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:u(`activity:fileActivity.analysisTitle.${e.level}`)}),(0,q.jsx)(`p`,{className:`mt-0.5 text-muted-foreground`,children:u(`activity:fileActivity.analysisBody.${e.level}`,{mutations:e.mutationCount,actors:e.actorCount,sessions:e.sessionCount})})]})]}),a.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:[u(`activity:fileActivity.workLinks`),`:`]}),a.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:s(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:u(`activity:fileActivity.recentActivity`)}),(0,q.jsx)(`div`,{className:`divide-y divide-border/40`,children:t.length===0?(0,q.jsx)($,{text:u(`activity:fileActivity.noEvidence`)}):t.slice(0,5).map(e=>(0,q.jsx)(Ee,{record:e},`${e.id}:${e.at}`))})]})]})}function we({sessions:e,agents:t,tasks:n,records:r,taskLabel:i,boardTitle:a}){let{t:s}=_();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)(Z,{icon:(0,q.jsx)(h,{}),title:s(`activity:fileActivity.sessions`),empty:s(`activity:fileActivity.noSessions`),children:e.map(e=>(0,q.jsx)(Q,{title:ye(e),subtitle:`${r.filter(t=>t.sessionId===e).length} ${s(`activity:fileActivity.events`)}`,raw:e},e))}),(0,q.jsx)(Z,{icon:(0,q.jsx)(o,{}),title:s(`activity:fileActivity.actors`),empty:s(`activity:fileActivity.noActors`),children:t.map(e=>(0,q.jsx)(Q,{title:e,subtitle:`${r.filter(t=>t.actor===e).length} ${s(`activity:fileActivity.events`)}`},e))}),(0,q.jsx)(Z,{icon:(0,q.jsx)(c,{}),title:s(`activity:fileActivity.workLinks`),empty:s(`activity:fileActivity.noWorkLinks`),children:n.map(e=>(0,q.jsx)(Q,{title:i(e),subtitle:a??s(`activity:fileActivity.taskOrTodo`),raw:e},e))})]})}function Z({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 Q({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 Te({records:e,loading:n}){let{t:r}=_();return n&&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)(t,{className:`h-3.5 w-3.5 animate-spin`}),r(`activity:fileActivity.loadingEvidence`)]}):e.length===0?(0,q.jsx)($,{text:r(`activity:fileActivity.noEvidence`)}):(0,q.jsx)(`div`,{className:`divide-y divide-border/40`,children:e.map(e=>(0,q.jsx)(Ee,{record:e,raw:!0},`${e.id}:${e.at}`))})}function Ee({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`,le.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})}w.config({monaco:D});function De(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 Oe(){let e=A(e=>e.openFiles),t=A(e=>e.activeFilePath),n=A(e=>e.setActiveFile),r=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 i=e.path===t,a=e.path.split(`/`).pop()??e.path;return(0,q.jsxs)(`button`,{type:`button`,onClick:()=>n(e.path),onMouseDown:t=>{t.button===1&&(t.preventDefault(),r(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`,i?`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)(d,{className:`h-2 w-2 fill-current text-primary shrink-0`}),(0,q.jsx)(`span`,{className:`truncate`,children:a}),(0,q.jsx)(p,{className:O(`h-3 w-3 shrink-0 rounded-sm hover:bg-muted-foreground/20 opacity-0 group-hover:opacity-100 transition-opacity`,i&&`opacity-100`),onClick:t=>{t.stopPropagation(),r(e.path)}})]},e.path)})})}function ke(){let{t:e}=_(),t=A(e=>e.openFiles),n=A(e=>e.activeFilePath),i=A(e=>e.updateContent),{theme:o}=N(),s=(0,K.useRef)(null),c=(0,K.useRef)(n),l=(0,K.useRef)(new Map),u=(0,K.useMemo)(()=>t.find(e=>e.path===n)??null,[t,n]),d=n?H(n):`plaintext`,f=F(),[p,m]=(0,K.useState)(!1);(0,K.useEffect)(()=>{c.current=n},[n]),(0,K.useEffect)(()=>{let e=F();S.setTheme(e)},[o]),(0,K.useEffect)(()=>{let e=L.map(e=>T.registerCompletionItemProvider(e,{triggerCharacters:[`.`,`_`],provideCompletionItems:async(e,t,n,r)=>{let i=c.current;if(!i)return{suggestions:[]};let a=e.getOffsetAt(t),o=e.getValue(),s=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=U(d),p={triggerCharacter:n.triggerCharacter,triggerKind:n.triggerKind};if(!W(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(ne.getState().wsUrl),v=e=>e.map((e,t)=>({label:e.label,kind:De(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=oe({filePath:i,language:e.getLanguageId(),lineNumber:t.lineNumber,column:t.column,versionId:e.getVersionId(),triggerCharacter:n.triggerCharacter,linePrefix:d,suffix:u}),b=l.current.get(y);return b&&b.expiresAt>Date.now()?{suggestions:v(b.items)}:await new Promise(a=>{let c=!1,d=()=>{},h=null,g,b=e=>{c||(c=!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&&(l.current.set(y,{expiresAt:Date.now()+V,items:t.payload.items}),b(v(t.payload.items)))}),g=window.setTimeout(()=>b([]),B),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:s,suffix:u,triggerCharacter:n.triggerCharacter,triggerKind:n.triggerKind,allowLlm:G(p,f)})})}}));return()=>{e.forEach(e=>{e.dispose()})}},[]);let h=(0,K.useCallback)(()=>{let e=s.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},[]),g=(0,K.useCallback)(()=>{M(`chat`),requestAnimationFrame(()=>{document.querySelector(`[data-chat-textarea]`)?.focus()})},[]),v=(0,K.useCallback)(()=>{let e=c.current;if(!e)return;let t=h();t&&(j.getState().addRef({kind:`snippet`,path:e,startLine:t.startLine,endLine:t.endLine,content:t.content}),g())},[h,g]),y=(0,K.useCallback)(()=>{let e=c.current;e&&(j.getState().addRef({kind:`file`,path:e}),g())},[g]),b=(0,K.useCallback)(t=>{s.current=t,S.setTheme(F()),t.onDidChangeCursorSelection(()=>{let e=t.getSelection();m(!!e&&!e.isEmpty())}),t.addAction({id:`wrongstack-send-to-chat`,label:e(`activity:codeEditor.sendSelectionAction`),contextMenuGroupId:`wrongstack`,contextMenuOrder:0,precondition:void 0,keybindings:[C.CtrlCmd|C.Shift|E.KeyL],run:e=>{let t=e.getSelection();t&&!t.isEmpty()?v():y()}})},[v,y]),ee=(0,K.useCallback)(e=>{n&&e!==void 0&&i(n,e)},[n,i]);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)(`div`,{className:`flex h-full min-w-0 items-center justify-center`,children:(0,q.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`activity:codeEditor.noFilesOpen`)}),(0,q.jsx)(`p`,{className:`text-[11px] text-muted-foreground/75`,children:e(`activity:codeEditor.selectToEdit`)})]})}):(0,q.jsxs)(`div`,{className:`flex h-full min-w-0 flex-col overflow-hidden`,children:[(0,q.jsx)(Oe,{}),(0,q.jsxs)(`div`,{className:`relative min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(p||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:p?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(p?`activity:codeEditor.sendSelectedTitle`:`activity:codeEditor.mentionFileTitle`),children:[p?(0,q.jsx)(r,{className:`h-3 w-3`}):(0,q.jsx)(a,{className:`h-3 w-3`}),(0,q.jsx)(`span`,{children:e(p?`activity:codeEditor.sendToChat`:`activity:codeEditor.mentionFile`)})]})}),u?(0,q.jsx)(x,{language:d,value:u.content,onChange:ee,theme:f,onMount:b,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{ke as CodeEditor};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Bn as t,Bt as n,Cn as r,Et as i,Gi as a,Lr as o,Ni as s,Qi as c,Si as l,Sn as u,Sr as d,Ur as f,Zn as ee,_ as p,a as te,ar as ne,c as re,f as ie,g as m,h as ae,i as oe,in as h,ln as g,m as se,mn as ce,oa as _,ot as le,p as ue,pr as de,qt as fe,r as pe,s as v,tt as y,u as me,wi as b,xn as he,yr as x}from"./vendor-DffL_bim.js";import{t as S}from"./utils-DEzFewqr.js";import{i as ge,r as _e,t as C}from"./codemap-activity-store-CgtLR4PV.js";var w=e(_(),1);function T(e){return e.level===`packages`?`packages`:e.level===`files`?`files:${e.package}`:`symbols:${e.file}`}function ve(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 ye(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 be(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 xe(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 E(e){let t=new Set(e.nodes.map(e=>e.id)),n=xe(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 Se(e,t){if(e.nodes.length===0)return[];let n=xe(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=be(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 Ce(e,t,n){return t===`orbit`?Se(e,n):E(e)}function D(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){let e=t.indexOf(r);if(e>=0)return t.slice(e+r.length)}let i=t.lastIndexOf(`/src/`);return i>=0?t.slice(i+1):t.split(`/`).slice(-3).join(`/`)}var O=new WeakMap;function we(e){let t=O.get(e);if(t)return t;let n={name:``,path:``,directories:[],files:[]};for(let t of e.filter(e=>e.kind===`file`&&!e.external)){let e=D(t).split(`/`).filter(Boolean),r=e.pop()??t.label,i=n;for(let t of e){let e=i.path?`${i.path}/${t}`:t,n=i.directories.find(e=>e.name===t);n||(n={name:t,path:e,directories:[],files:[]},i.directories.push(n)),i=n}i.files.push({...t,label:r})}let r=e=>{e.directories.sort((e,t)=>e.name.localeCompare(t.name)),e.files.sort((e,t)=>e.label.localeCompare(t.label)),e.directories.forEach(r)};return r(n),O.set(e,n),n}var k=y(),Te={nodes:[],edges:[]},A={package:{icon:he,accent:`border-l-primary`,iconStyle:`bg-primary/12 text-primary`},file:{icon:o,accent:`border-l-info`,iconStyle:`bg-info/12 text-info`},symbol:{icon:s,accent:`border-l-success`,iconStyle:`bg-success/12 text-success`}},Ee={call:`hsl(var(--primary))`,import:`hsl(var(--info))`,type_ref:`hsl(var(--success))`,inherit:`hsl(var(--warning))`,implement:`hsl(var(--destructive))`},De={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`},j=[`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 M(e){return e.replace(/\\/g,`/`).replace(/^\.\//,``).toLocaleLowerCase()}function Oe(e,t){if(!e||!t)return!1;let n=M(e),r=M(t);return n===r||n.endsWith(`/${r}`)||r.endsWith(`/${n}`)}function ke(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 N(e,t){return t.kind===`package`?ke(e.filePath)===(t.package??t.label):Oe(e.filePath,t.file)?t.kind!==`symbol`||e.symbol?.id===t.id:!1}function Ae(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 je(e){let t=0;for(let n of e)t=t*31+n.charCodeAt(0)|0;return j[Math.abs(t)%j.length]??j[0]}function Me(e){let t=0;for(let n of e)t=t*31+n.charCodeAt(0)|0;return`hsl(${Math.abs(t)%360} 82% 58%)`}function Ne(e){let t=e.replace(/\\/g,`/`),n=t.lastIndexOf(`/packages/`),r=t.lastIndexOf(`/apps/`),i=Math.max(n,r);return i>=0?t.slice(i+1):t.split(`/`).slice(-3).join(`/`)}function Pe(e){return[e.symbol?.name,e.line?`L${e.line}`:void 0].filter(Boolean).join(` · `)}function Fe(e,t){let n=t.filter(t=>t.kind===`symbol`&&!t.external&&Oe(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 Ie=160;function Le(e,t,n){if(n===`all`||e.nodes.length<=Ie)return e;let r=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=>{r.has(e)&&o.size<Ie&&o.add(e)};if(t&&r.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,124),t=a.filter(e=>e.external).slice(0,36);for(let n of[...e,...t])s(n.id)}for(let e of a)s(e.id);return{nodes:e.nodes.filter(e=>o.has(e.id)),edges:e.edges.filter(e=>o.has(e.source)&&o.has(e.target))}}function Re({data:e}){let{graphNode:t,selected:n,dimmed:r,incoming:i,outgoing:a,isActive:o,activityType:s,activeOperations:c}=e,l=A[t.kind],u=l.icon,d=t.kind!==`symbol`,ee=t.kind===`symbol`?`${t.symbolKind??`symbol`}${t.line?` · L${t.line}`:``}`:t.kind===`file`?D(t):`${t.fileCount??0} files · ${t.symbolCount??0} symbols`;return(0,k.jsxs)(`div`,{className:S(`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,filter,box-shadow,border-color,background-color]`,l.accent,n&&`border-primary bg-primary/5 shadow-[0_0_0_2px_hsl(var(--primary)/0.18),0_16px_36px_hsl(var(--shadow-color)/0.18)]`,t.external&&`border-dashed bg-muted/75`,r&&`opacity-25 grayscale`,o&&s&&De[s]),children:[c.length>0&&(0,k.jsxs)(`div`,{className:`absolute -top-5 left-2 z-20 flex max-w-[210px] items-center gap-1`,children:[c.slice(0,4).map(e=>{let t=e.agentName??e.agent??`External`,n=`${e.sessionId??`none`}:${e.agentId??t}`;return(0,k.jsxs)(`span`,{className:S(`flex h-6 items-center gap-1 border-2 border-background px-1.5 font-mono text-[8px] font-bold shadow-md`,je(n)),title:`${t} · ${e.type} ${Pe(e)}`,children:[(0,k.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse bg-current`}),Ae(t),e.symbol&&(0,k.jsx)(`span`,{className:`max-w-[80px] truncate`,children:e.symbol.name})]},e.id??`${n}:${e.filePath}`)}),c.length>4&&(0,k.jsxs)(`span`,{className:`border bg-card px-1 font-mono text-[8px] shadow`,children:[`+`,c.length-4]})]}),(0,k.jsx)(v,{type:`target`,position:p.Left,className:`!h-2.5 !w-2.5 !border-2 !border-card !bg-muted-foreground`}),(0,k.jsxs)(`button`,{type:`button`,className:`block w-full text-left`,onClick:n=>{if(n.shiftKey&&t.file){e.onShowHistory(t.file);return}e.onSelect(t)},onDoubleClick:()=>d&&e.onOpen(t),"aria-label":`${t.kind} ${t.label}`,children:[(0,k.jsxs)(`div`,{className:`flex items-start gap-3 p-3 pr-10`,children:[(0,k.jsx)(`span`,{className:S(`flex h-8 w-8 shrink-0 items-center justify-center border`,l.iconStyle),children:(0,k.jsx)(u,{className:`h-4 w-4`})}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[9px] font-bold uppercase tracking-[0.18em] text-muted-foreground`,children:[(0,k.jsx)(`span`,{children:t.kind}),t.external&&(0,k.jsx)(`span`,{className:`border border-border px-1 py-0.5 text-[8px] text-warning`,children:`external`}),t.lang&&(0,k.jsx)(`span`,{className:`ml-auto font-mono normal-case tracking-normal`,children:t.lang})]}),(0,k.jsx)(`div`,{className:`truncate font-mono text-[13px] font-semibold`,title:t.label,children:t.label}),(0,k.jsx)(`div`,{className:`mt-1 truncate text-[10px] text-muted-foreground`,title:ee,children:ee})]})]}),(0,k.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,k.jsxs)(`span`,{title:`Incoming relationships`,children:[`← `,i]}),(0,k.jsxs)(`span`,{title:`Outgoing relationships`,children:[`→ `,a]}),t.symbolCount!==void 0&&t.kind===`file`&&(0,k.jsxs)(`span`,{className:`ml-auto`,children:[t.symbolCount,` sym`]}),o&&(0,k.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 font-bold text-warning`,children:[(0,k.jsx)(h,{className:`h-2.5 w-2.5 animate-pulse`}),` LIVE`]})]})]}),d&&(0,k.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(t),title:t.kind===`package`?`Open file map`:`Open symbol map`,"aria-label":`Open ${t.label} map`,children:(0,k.jsx)(f,{className:`h-3.5 w-3.5`})}),(0,k.jsx)(v,{type:`source`,position:p.Right,className:`!h-2.5 !w-2.5 !border-2 !border-card !bg-muted-foreground`})]})}function ze(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function P(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&&ze(e.activeOperations,t.activeOperations)}var Be={codemap:(0,w.memo)(Re,(e,t)=>P(e.data,t.data))};function Ve(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&&P(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 He(e){return e.data?.renderKey}function Ue(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&&He(a)===He(t)?(e[i]!==a&&(r=!0),a):(r=!0,t)});return r?i:e}function We(e){let{directory:n,packageName:r,depth:i,expandedDirectories:a,expandedFiles:c,loadingBranches:u,graphForFile:ee,onToggleDirectory:p,onToggleFile:te,onSelectFile:ne,onOpenFile:re,onSelectSymbol:ie,selectedId:m,activeOperations:ae}=e;return(0,k.jsxs)(k.Fragment,{children:[n.directories.map(t=>{let n=`${r}:${t.path}`,o=a.has(n);return(0,k.jsxs)(`div`,{children:[(0,k.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+i*12},onClick:()=>p(n),children:[o?(0,k.jsx)(b,{className:`h-3 w-3`}):(0,k.jsx)(l,{className:`h-3 w-3`}),o?(0,k.jsx)(d,{className:`h-3.5 w-3.5 text-warning`}):(0,k.jsx)(x,{className:`h-3.5 w-3.5 text-warning`}),(0,k.jsx)(`span`,{className:`truncate`,children:t.name})]}),o&&(0,k.jsx)(We,{...e,directory:t,depth:i+1})]},n)}),n.files.map(e=>{let n=c.has(e.file??e.id),r=T({level:`symbols`,file:e.file??e.label}),a=(e.file?ee(e.file):void 0)?.nodes.filter(t=>t.kind===`symbol`&&t.file===e.file&&!t.external)??[],d=ae.filter(t=>Oe(t.filePath,e.file));return(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`div`,{className:S(`group flex h-7 items-center pr-1 text-[11px] hover:bg-muted`,m===e.id&&`bg-primary/10 text-primary`),style:{paddingLeft:8+i*12},children:[(0,k.jsx)(`button`,{type:`button`,className:`flex h-6 w-4 shrink-0 items-center justify-center text-muted-foreground`,onClick:()=>te(e),"aria-label":`${n?`Collapse`:`Expand`} ${e.label}`,children:u.has(r)?(0,k.jsx)(t,{className:`h-3 w-3 animate-spin`}):n?(0,k.jsx)(b,{className:`h-3 w-3`}):(0,k.jsx)(l,{className:`h-3 w-3`})}),(0,k.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-1.5 text-left`,onClick:()=>ne(e),onDoubleClick:()=>re(e),children:[(0,k.jsx)(o,{className:`h-3.5 w-3.5 shrink-0 text-info`}),d.length>0&&(0,k.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 animate-pulse bg-success`,title:`${d.length} live operation(s)`}),(0,k.jsx)(`span`,{className:`truncate font-mono`,title:e.file,children:e.label}),(0,k.jsx)(`span`,{className:`ml-auto text-[9px] text-muted-foreground`,children:e.symbolCount??0})]}),(0,k.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:()=>re(e),title:`Open symbol map`,"aria-label":`Open ${e.label} map`,children:(0,k.jsx)(f,{className:`h-3 w-3`})})]}),n&&a.map(e=>(0,k.jsxs)(`button`,{type:`button`,className:S(`flex h-7 w-full items-center gap-1.5 pr-2 text-left text-[10px] hover:bg-muted`,m===e.id?`bg-primary/10 text-primary`:`text-muted-foreground`),style:{paddingLeft:38+i*12},onClick:()=>ie(e),children:[(0,k.jsx)(s,{className:`h-3 w-3 shrink-0 text-success`}),ae.some(t=>t.symbol?.id===e.id)&&(0,k.jsx)(h,{className:`h-3 w-3 shrink-0 animate-pulse text-success`}),(0,k.jsx)(`span`,{className:`truncate font-mono`,children:e.label}),e.line&&(0,k.jsxs)(`span`,{className:`ml-auto font-mono text-[8px] opacity-60`,children:[`:`,e.line]})]},e.id))]},e.id)})]})}function Ge(e){let{title:t,subtitle:n,items:r,graph:i,selectedId:a,expanded:o,onToggle:s,onSelect:c}=e;return(0,k.jsxs)(`section`,{className:`border-b py-3`,children:[(0,k.jsxs)(`div`,{className:`mb-2 flex items-end justify-between px-3`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`h3`,{className:`text-[10px] font-bold uppercase tracking-[0.16em]`,children:t}),(0,k.jsx)(`p`,{className:`mt-0.5 text-[9px] text-muted-foreground`,children:n})]}),(0,k.jsx)(`span`,{className:`border bg-muted px-1.5 py-0.5 font-mono text-[9px]`,children:r.length})]}),r.length===0?(0,k.jsx)(`p`,{className:`px-3 py-2 text-[10px] text-muted-foreground`,children:`No relationships in this view.`}):r.map(e=>{let n=`${t}:${e.node.id}`,r=o.has(n),u=[...ye(i,e.node.id,`incoming`),...ye(i,e.node.id,`outgoing`)].filter((e,t,n)=>e.node.id!==a&&n.findIndex(t=>t.node.id===e.node.id)===t).slice(0,8);return(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`div`,{className:`group flex min-h-9 items-center gap-1 px-2 hover:bg-muted/70`,children:[(0,k.jsx)(`button`,{type:`button`,className:`flex h-6 w-5 shrink-0 items-center justify-center text-muted-foreground`,onClick:()=>u.length>0&&s(n),"aria-label":`${r?`Collapse`:`Expand`} relation ${e.node.label}`,children:u.length>0?r?(0,k.jsx)(b,{className:`h-3 w-3`}):(0,k.jsx)(l,{className:`h-3 w-3`}):(0,k.jsx)(`span`,{className:`h-px w-2 bg-border`})}),(0,k.jsxs)(`button`,{type:`button`,className:`min-w-0 flex-1 py-1 text-left`,onClick:()=>c(e.node),children:[(0,k.jsx)(`span`,{className:`block truncate font-mono text-[10px] font-semibold`,title:e.node.label,children:e.node.label}),(0,k.jsx)(`span`,{className:`block truncate text-[9px] text-muted-foreground`,children:e.node.package??e.node.symbolKind??e.node.kind})]}),(0,k.jsx)(`span`,{className:`border px-1 py-0.5 font-mono text-[8px] text-muted-foreground`,children:e.edge.refType}),(0,k.jsxs)(`span`,{className:`w-5 text-right font-mono text-[9px] text-muted-foreground`,children:[`×`,e.edge.weight]})]}),r&&u.map(e=>(0,k.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:()=>c(e.node),children:[(0,k.jsx)(`span`,{className:`absolute left-7 top-1/2 h-px w-3 bg-border`}),(0,k.jsx)(de,{className:`h-3 w-3 shrink-0`}),(0,k.jsx)(`span`,{className:`truncate font-mono`,children:e.node.label}),(0,k.jsx)(`span`,{className:`ml-auto font-mono opacity-70`,children:e.edge.refType})]},`${n}:${e.node.id}`))]},n)})]})}function F({activity:e}){return(0,k.jsx)(`span`,{className:S(`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 I({activity:e,onLocate:t,showAgent:r=!1}){let a=e.agentName??e.agent??`External process`,o=`${e.sessionId??`none`}:${e.agentId??a}`;return(0,k.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:[r&&(0,k.jsx)(`span`,{className:S(`mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center font-mono text-[8px] font-black`,je(o)),children:Ae(a)}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,k.jsx)(F,{activity:e}),r&&(0,k.jsx)(`span`,{className:`truncate text-[9px] font-semibold`,children:a}),e.status===`active`&&(0,k.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 font-mono text-[8px] font-bold text-success`,children:[(0,k.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse bg-success`}),` LIVE`]}),e.watcherConfirmed&&(0,k.jsx)(n,{className:`ml-auto h-3 w-3 text-success`,"aria-label":`Filesystem confirmed`}),e.attribution===`correlated`&&!e.watcherConfirmed&&(0,k.jsx)(`span`,{className:`ml-auto font-mono text-[7px] uppercase text-warning`,title:`Correlated from the only active tool`,children:`~ correlated`}),e.attribution===`external`&&(0,k.jsx)(`span`,{className:`ml-auto font-mono text-[7px] uppercase text-destructive`,children:`external`})]}),(0,k.jsx)(`div`,{className:`mt-1 truncate font-mono text-[9px] font-semibold`,title:e.filePath,children:Ne(e.filePath)}),(e.symbol||e.line)&&(0,k.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-1 truncate font-mono text-[8px] text-success`,children:[(0,k.jsx)(i,{className:`h-2.5 w-2.5 shrink-0`}),e.symbol?.name??`line ${e.line}`,e.symbol?.kind&&(0,k.jsxs)(`span`,{className:`text-muted-foreground`,children:[`· `,e.symbol.kind]})]}),e.change&&(0,k.jsxs)(`div`,{className:`mt-1 flex items-center gap-1 font-mono text-[8px]`,children:[(0,k.jsxs)(`span`,{className:`border border-success/40 bg-success/10 px-1 text-success`,children:[`+`,e.change.added]}),(0,k.jsxs)(`span`,{className:`border border-destructive/40 bg-destructive/10 px-1 text-destructive`,children:[`−`,e.change.removed]}),e.durationMs!==void 0&&(0,k.jsxs)(`span`,{className:`ml-auto text-muted-foreground`,children:[e.durationMs,`ms`]})]}),e.summary&&e.summary!==e.toolName&&(0,k.jsx)(`div`,{className:`mt-1 line-clamp-2 text-[8px] leading-3 text-muted-foreground`,children:e.summary})]}),!e.filePath.startsWith(`(`)&&(0,k.jsx)(f,{className:`mt-1 h-3 w-3 shrink-0 text-muted-foreground opacity-0 group-hover:opacity-100`})]})}function Ke({presences:e,onLocate:t}){return e.length===0?null:(0,k.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,k.jsxs)(`div`,{className:`flex h-9 items-center gap-2 border-b px-3`,children:[(0,k.jsx)(h,{className:`h-3.5 w-3.5 animate-pulse text-success`}),(0,k.jsx)(`h2`,{className:`text-[9px] font-black uppercase tracking-[0.18em]`,children:`Live agent operations`}),(0,k.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,k.jsx)(`div`,{className:`max-h-[330px] overflow-y-auto`,children:e.map(e=>(0,k.jsxs)(`div`,{className:`border-b last:border-b-0`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2 bg-muted/35 px-3 py-1.5`,children:[(0,k.jsx)(`span`,{className:S(`flex h-6 w-6 items-center justify-center font-mono text-[8px] font-black`,je(e.key)),children:Ae(e.agentName)}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsx)(`div`,{className:`truncate text-[9px] font-bold`,children:e.agentName}),(0,k.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,k.jsxs)(`span`,{className:`font-mono text-[8px] text-success`,children:[e.operations.length,` op`]})]}),e.operations.map(e=>(0,k.jsx)(I,{activity:e,onLocate:t},e.id??`${e.toolUseId}:${e.filePath}`))]},e.key))})]})}function qe({paused:e,followLive:t,agentFilter:n,agents:r,onTogglePaused:a,onToggleFollow:o,onAgentFilter:s}){return(0,k.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,k.jsxs)(`button`,{type:`button`,className:S(`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:o,title:`Automatically enter the file/function used by the newest visible agent`,children:[(0,k.jsx)(i,{className:`h-3 w-3`}),` Follow`]}),(0,k.jsxs)(`button`,{type:`button`,className:S(`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:a,title:e?`Resume the live telemetry stream`:`Freeze the current telemetry frame`,children:[e?(0,k.jsx)(g,{className:`h-3 w-3`}):(0,k.jsx)(ce,{className:`h-3 w-3`}),e?`Resume`:`Live`]}),(0,k.jsxs)(`label`,{className:`flex h-full items-center gap-1.5 px-2 text-[8px] uppercase text-muted-foreground`,children:[`Agent`,(0,k.jsxs)(`select`,{"aria-label":`Filter CodeMap by agent and session`,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=>s(e.target.value),children:[(0,k.jsx)(`option`,{value:`all`,children:`ALL AGENTS`}),r.map(e=>(0,k.jsxs)(`option`,{value:e.key,children:[e.agentName,` · `,e.sessionId.slice(0,10)]},e.key))]})]})]})}function Je(){let[e,n]=(0,w.useState)({level:`packages`}),i=T(e),[o,s]=(0,w.useState)(Te),[d,p]=(0,w.useState)(!0),[g,ce]=(0,w.useState)(null),[_,v]=(0,w.useState)(null),[y,me]=(0,w.useState)(`layers`),[x,xe]=(0,w.useState)(`smart`),[E,Se]=(0,w.useState)(`all`),[O,De]=(0,w.useState)(``),[j,M]=(0,w.useState)(new Set),[je,Ne]=(0,w.useState)(new Set),[Pe,Ie]=(0,w.useState)(new Set),[Re,ze]=(0,w.useState)(new Set),[P,He]=(0,w.useState)(new Set),[F,Je]=(0,w.useState)(0),[L,Ye]=(0,w.useState)(null),[Xe,Ze]=(0,w.useState)(!1),[R,Qe]=(0,w.useState)(`all`),[z,$e]=(0,w.useState)(null),[et,tt]=(0,w.useState)(null),[nt,rt]=(0,w.useState)(0),B=(0,w.useRef)(new Map),V=(0,w.useRef)(null),H=(0,w.useRef)(null),it=(0,w.useRef)(``),U=ge(),W=(0,w.useMemo)(()=>[...U.activeOperations.values()].flat(),[U.activeOperations]),at=(0,w.useMemo)(()=>[...U.pulses.keys()].map(e=>U.history.get(e)?.[0]).filter(e=>!!e),[U.history,U.pulses]),G=(0,w.useMemo)(()=>{let e=[];for(let t of U.history.values())e.push(...t.slice(0,16));return e.sort((e,t)=>t.timestamp-e.timestamp).slice(0,16)},[U.history]),ot=(0,w.useMemo)(()=>_e([...W,...G]),[W,G]),K=(0,w.useMemo)(()=>{let e=z??W;return R===`all`?e:e.filter(e=>C(e)===R)},[W,R,z]),st=(0,w.useMemo)(()=>{let e=et??G;return R===`all`?e:e.filter(e=>C(e)===R)},[R,et,G]),ct=(0,w.useMemo)(()=>_e(K),[K]),[lt,ut,dt]=se([]),[ft,pt,mt]=ue([]),{fitView:ht}=ae(),q=(0,w.useCallback)(async(e,t=!1)=>{let n=T(e),r=B.current.get(n);if(r&&!t)return r;let i=await fetch(ve(e));if(!i.ok){let e=await i.json().catch(()=>({error:i.statusText}));throw Error(e.error??`HTTP ${i.status}`)}let a=await i.json();return B.current.set(n,a),Je(e=>e+1),a},[]);(0,w.useEffect)(()=>{let t=!1;return p(!0),ce(null),q(e).then(e=>{if(t)return;s(e);let n=V.current;V.current=null,v(n&&e.nodes.some(e=>e.id===n)?n:null),p(!1)}).catch(e=>{t||(ce(e instanceof Error?e.message:String(e)),s(Te),p(!1))}),()=>{t=!0}},[i,q]);let J=(0,w.useCallback)((e,t)=>{if(V.current=t??null,T(e)===i){v(t??null),V.current=null;return}n(e)},[i]),Y=(0,w.useCallback)(async e=>{let t=T(e);if(!(B.current.has(t)||P.has(t))){He(e=>new Set(e).add(t));try{await q(e)}finally{He(e=>{let n=new Set(e);return n.delete(t),n})}}},[q,P]);(0,w.useEffect)(()=>{let e=!1;for(let t of W)t.symbol||!t.toolUseId||t.filePath.startsWith(`(`)||q({level:`symbols`,file:t.filePath}).then(n=>{if(e)return;let r=Fe(t,n.nodes);r&&U.resolveActivitySymbol(t.toolUseId,t.filePath,{id:r.id,name:r.label,...r.symbolKind?{kind:r.symbolKind}:{},...r.line?{line:r.line}:{}})}).catch(()=>void 0);return()=>{e=!0}},[W,U.resolveActivitySymbol,q]);let X=(0,w.useMemo)(()=>({nodes:o.nodes,edges:E===`all`?o.edges:o.edges.filter(e=>e.refType===E)}),[o,E]),Z=o.nodes.find(e=>e.id===_),Q=(0,w.useMemo)(()=>Le(X,_,x),[x,X,_]),gt=(0,w.useMemo)(()=>_?be(X,_):new Set,[X,_]),{incomingCounts:_t,outgoingCounts:vt}=(0,w.useMemo)(()=>{let e=new Map,t=new Map;for(let n of X.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}},[X]),yt=y===`orbit`?_??void 0:void 0,bt=(0,w.useMemo)(()=>Ce(Q,y,yt),[Q,y,yt]),xt=(0,w.useMemo)(()=>[i,y,y===`orbit`?_??``:``,Q.nodes.map(e=>e.id).join(``),Q.edges.map(e=>`${e.source}>${e.target}:${e.refType}`).join(``)].join(``),[Q,i,y,_]),St=(0,w.useCallback)(e=>{v(e.id),ze(new Set)},[]),Ct=(0,w.useCallback)(e=>{e.kind===`package`&&J({level:`files`,package:e.package??e.label}),e.kind===`file`&&e.file&&J({level:`symbols`,file:e.file,package:e.package})},[J]);(0,w.useEffect)(()=>{let e=new Set(bt.filter(({node:e})=>K.some(t=>N(t,e))).map(({node:e})=>e.id)),t=bt.map(({node:e,position:t})=>{let n=K.filter(t=>N(t,e)),r=n[0]??at.find(t=>N(t,e));return{id:e.id,type:`codemap`,position:t,data:{graphNode:e,selected:e.id===_,dimmed:!!_&&!gt.has(e.id),incoming:_t.get(e.id)??0,outgoing:vt.get(e.id)??0,isActive:!!r,...r?{activityType:r.type}:{},activeOperations:n,onSelect:St,onOpen:Ct,onShowHistory:Ye}}});ut(e=>Ve(e,t));let n=Q.edges.map((t,n)=>{let r=!!_&&(t.source===_||t.target===_),i=e.has(t.source)||e.has(t.target),a=Ee[t.refType]??`hsl(var(--muted-foreground))`;return{id:`edge:${t.source}:${t.target}:${n}`,source:t.source,target:t.target,type:`smoothstep`,animated:i,label:r?`${t.refType}${t.weight>1?` ×${t.weight}`:``}`:void 0,markerEnd:{type:m.ArrowClosed,color:a,width:14,height:14},style:{stroke:a,strokeWidth:i?Math.min(2.5+Math.log2(t.weight+1)*.65,5):r?Math.min(1.25+Math.log2(t.weight+1)*.65,4):1,opacity:i?1:_?r?.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:r?2:0,data:{renderKey:`${t.refType}:${t.weight}:${_?r?`focused`:`dimmed`:`idle`}:${i?`live`:`still`}`}}}),r=new Map,i=new Set(K.map(C));for(let e of[...st].sort((e,t)=>e.timestamp-t.timestamp)){let t=C(e);r.set(t,[...r.get(t)??[],e])}let a=[];for(let[e,t]of r){let n=i.has(e),r=t.map(e=>({activity:e,node:Q.nodes.find(t=>N(e,t))})).filter(e=>!!e.node).filter((e,t,n)=>t===0||e.node.id!==n[t-1]?.node.id),o=Me(e);for(let t=1;t<r.length;t++){let i=r[t-1],s=r[t];a.push({id:`trail:${e}:${i.activity.timestamp}:${s.activity.timestamp}`,source:i.node.id,target:s.node.id,type:`smoothstep`,animated:n,label:t===r.length-1?`${Ae(s.activity.agentName??s.activity.agent??`agent`)} TRAIL`:void 0,markerEnd:{type:m.ArrowClosed,color:o,width:13,height:13},style:{stroke:o,strokeWidth:2.5,strokeDasharray:`7 5`,opacity:.9},labelStyle:{fontSize:8,fontWeight:700,fill:o},labelBgStyle:{fill:`hsl(var(--card))`,fillOpacity:.94},labelBgPadding:[4,2],zIndex:6,data:{renderKey:`${o}:${t===r.length-1?`label`:`plain`}:${n?`live`:`still`}`}})}}if(rt(a.length),pt(e=>Ue(e,[...n,...a])),it.current===xt)return;let o=window.setTimeout(()=>{it.current=xt,ht({padding:.2,duration:240,maxZoom:1.25})},20);return()=>window.clearTimeout(o)},[Q,_,K,st,xt,gt,ht,Ct,St,_t,vt,bt,at,pt,ut]),(0,w.useEffect)(()=>{let e=window.setInterval(()=>{U._sweep()},2e3);return()=>window.clearInterval(e)},[U._sweep]);let wt=B.current.get(`packages`)??(e.level===`packages`?o:Te),Tt=(0,w.useCallback)(e=>B.current.get(T({level:`files`,package:e})),[F]),Et=(0,w.useCallback)(e=>B.current.get(T({level:`symbols`,file:e})),[F]),$=(0,w.useCallback)(e=>{let t=e.filePath,n=ke(e.filePath),r=`file:${e.filePath}`;for(let i of B.current.values()){let a=i.nodes.find(t=>t.kind===`file`&&!t.external&&Oe(t.file,e.filePath));if(a){t=a.file??t,n=a.package??n,r=a.id;break}}if(e.symbol){J({level:`symbols`,file:t,package:n},e.symbol.id);return}J({level:`files`,package:n},r)},[J]);(0,w.useEffect)(()=>{if(!Xe||z)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`}`;H.current!==t&&(H.current=t,$(e))},[K,Xe,$,z]);let Dt=(0,w.useCallback)(()=>{if(z){$e(null),tt(null);return}$e([...W]),tt([...G])},[W,z,G]),Ot=(0,w.useCallback)(e=>{let t=e.package??e.label,n=!j.has(t);M(e=>{let r=new Set(e);return n?r.add(t):r.delete(t),r}),n&&Y({level:`files`,package:t}).then(()=>{let e=B.current.get(T({level:`files`,package:t})),n=e?we(e.nodes):void 0;n?.directories.length===1&&n.directories[0]&&Ne(e=>new Set(e).add(`${t}:${n.directories[0].path}`))}).catch(()=>void 0)},[Y,j]),kt=(0,w.useCallback)(e=>{if(!e.file)return;let t=!Pe.has(e.file);Ie(n=>{let r=new Set(n);return t?r.add(e.file):r.delete(e.file),r}),t&&Y({level:`symbols`,file:e.file,package:e.package}).catch(()=>void 0)},[Y,Pe]),At=(0,w.useCallback)(e=>{Ne(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),jt=(0,w.useCallback)(e=>{J({level:`files`,package:e.package??`(root)`},e.id)},[J]),Mt=(0,w.useCallback)(e=>{e.file&&J({level:`symbols`,file:e.file,package:e.package},e.id)},[J]),Nt=(0,w.useMemo)(()=>{let e=O.trim().toLocaleLowerCase();if(!e)return[];let t=new Map;for(let n of B.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)},[O,F]),Pt=(0,w.useCallback)(e=>{e.kind===`package`?J({level:`packages`},e.id):e.kind===`file`?J({level:`files`,package:e.package??`(root)`},e.id):e.file&&J({level:`symbols`,file:e.file,package:e.package},e.id)},[J]),{incoming:Ft,outgoing:It}=(0,w.useMemo)(()=>({incoming:Z?ye(X,Z.id,`incoming`):[],outgoing:Z?ye(X,Z.id,`outgoing`):[]}),[X,Z]),{edgeWeight:Lt,connectedNodeCount:Rt}=(0,w.useMemo)(()=>{let e=0,t=new Set;for(let n of X.edges)e+=n.weight,t.add(n.source),t.add(n.target);return{edgeWeight:e,connectedNodeCount:t.size}},[X]),zt=Z?K.filter(e=>N(e,Z)):[],Bt=L?U.getActivityForFile(L):[];return(0,k.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-background`,children:[(0,k.jsxs)(`header`,{className:`flex h-[62px] shrink-0 items-center gap-4 border-b bg-card px-4`,children:[(0,k.jsxs)(`div`,{className:`flex min-w-[220px] items-center gap-3`,children:[(0,k.jsx)(`span`,{className:`flex h-9 w-9 items-center justify-center border border-primary bg-primary/10 text-primary`,children:(0,k.jsx)(r,{className:`h-4 w-4`})}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`h1`,{className:`font-display text-sm font-semibold tracking-tight`,children:`Code Atlas`}),(0,k.jsx)(`p`,{className:`text-[9px] uppercase tracking-[0.18em] text-muted-foreground`,children:`Architecture intelligence`})]})]}),(0,k.jsxs)(`nav`,{className:`flex min-w-0 flex-1 items-center gap-1 font-mono text-[10px]`,"aria-label":`Code map breadcrumb`,children:[e.level!==`packages`&&(0,k.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`?J({level:`files`,package:e.package??`(root)`}):J({level:`packages`})},"aria-label":`Back`,children:(0,k.jsx)(a,{className:`h-3.5 w-3.5`})}),(0,k.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1.5 px-1.5 py-1 text-muted-foreground hover:text-foreground`,onClick:()=>J({level:`packages`}),children:[(0,k.jsx)(ne,{className:`h-3 w-3`}),` workspace`]}),e.level!==`packages`&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(l,{className:`h-3 w-3 text-muted-foreground`}),(0,k.jsx)(`button`,{type:`button`,className:`max-w-[220px] truncate px-1.5 py-1 hover:text-primary`,onClick:()=>J({level:`files`,package:e.package??`(root)`}),children:e.package??`(root)`})]}),e.level===`symbols`&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(l,{className:`h-3 w-3 text-muted-foreground`}),(0,k.jsx)(`span`,{className:`truncate px-1.5 py-1 text-primary`,children:D({id:``,label:e.file,kind:`file`,file:e.file,package:e.package})})]})]}),(0,k.jsxs)(`div`,{className:`hidden items-center gap-5 xl:flex`,children:[(0,k.jsxs)(`div`,{className:S(`flex h-8 items-center gap-2 border px-2.5`,ct.length>0?`border-success/50 bg-success/10 text-success`:`text-muted-foreground`),children:[(0,k.jsx)(h,{className:S(`h-3 w-3`,ct.length>0&&`animate-pulse`)}),(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`div`,{className:`font-mono text-[10px] font-bold`,children:[ct.length,` LIVE`]}),(0,k.jsx)(`div`,{className:`text-[7px] uppercase tracking-wider`,children:`agents`})]})]}),(0,k.jsxs)(`div`,{className:`text-right`,children:[(0,k.jsx)(`div`,{className:`font-mono text-sm font-semibold`,children:o.nodes.length}),(0,k.jsx)(`div`,{className:`text-[8px] uppercase tracking-wider text-muted-foreground`,children:`nodes`})]}),(0,k.jsxs)(`div`,{className:`text-right`,children:[(0,k.jsx)(`div`,{className:`font-mono text-sm font-semibold`,children:o.edges.length}),(0,k.jsx)(`div`,{className:`text-[8px] uppercase tracking-wider text-muted-foreground`,children:`links`})]}),(0,k.jsxs)(`div`,{className:`text-right`,children:[(0,k.jsx)(`div`,{className:`font-mono text-sm font-semibold`,children:Lt}),(0,k.jsx)(`div`,{className:`text-[8px] uppercase tracking-wider text-muted-foreground`,children:`references`})]}),(0,k.jsxs)(`div`,{className:`text-right`,children:[(0,k.jsx)(`div`,{className:`font-mono text-sm font-semibold`,children:Rt}),(0,k.jsx)(`div`,{className:`text-[8px] uppercase tracking-wider text-muted-foreground`,children:`connected`})]})]})]}),(0,k.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,k.jsxs)(`aside`,{className:`flex w-[286px] shrink-0 flex-col border-r bg-card/70`,children:[(0,k.jsxs)(`div`,{className:`border-b p-3`,children:[(0,k.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,k.jsx)(`h2`,{className:`text-[10px] font-bold uppercase tracking-[0.18em]`,children:`Code tree`}),(0,k.jsxs)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:[wt.nodes.length,` roots`]})]}),(0,k.jsxs)(`label`,{className:`flex h-8 items-center gap-2 border bg-background px-2 focus-within:border-primary`,children:[(0,k.jsx)(fe,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,k.jsx)(`input`,{className:`min-w-0 flex-1 bg-transparent font-mono text-[10px] outline-none placeholder:text-muted-foreground`,value:O,onChange:e=>De(e.target.value),placeholder:`Find package, file, symbol…`}),O&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>De(``),"aria-label":`Clear search`,children:(0,k.jsx)(le,{className:`h-3 w-3 text-muted-foreground`})})]})]}),(0,k.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-2`,children:O.trim()?(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`div`,{className:`px-3 pb-2 text-[9px] text-muted-foreground`,children:[Nt.length,` loaded-map results`]}),Nt.map(e=>{let t=A[e.kind].icon;return(0,k.jsxs)(`button`,{type:`button`,className:`flex min-h-8 w-full items-center gap-2 px-3 py-1 text-left hover:bg-muted`,onClick:()=>Pt(e),children:[(0,k.jsx)(t,{className:S(`h-3.5 w-3.5 shrink-0`,e.kind===`package`?`text-primary`:e.kind===`file`?`text-info`:`text-success`)}),(0,k.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,k.jsx)(`span`,{className:`block truncate font-mono text-[10px]`,children:e.label}),(0,k.jsx)(`span`,{className:`block truncate text-[8px] text-muted-foreground`,children:e.file??e.package??e.symbolKind})]}),(0,k.jsx)(`span`,{className:`text-[8px] uppercase text-muted-foreground`,children:e.kind.slice(0,3)})]},e.id)}),Nt.length===0&&(0,k.jsxs)(`p`,{className:`px-3 py-8 text-center text-[10px] text-muted-foreground`,children:[`No match in loaded branches.`,(0,k.jsx)(`br`,{}),`Expand a package to search its files.`]})]}):wt.nodes.map(e=>{let n=e.package??e.label,r=j.has(n),i=T({level:`files`,package:n}),a=Tt(n),o=a?we(a.nodes):void 0;return(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`div`,{className:S(`group flex h-8 items-center px-2 hover:bg-muted`,_===e.id&&`bg-primary/10 text-primary`),children:[(0,k.jsx)(`button`,{type:`button`,className:`flex h-6 w-5 items-center justify-center text-muted-foreground`,onClick:()=>Ot(e),"aria-label":`${r?`Collapse`:`Expand`} ${n}`,children:P.has(i)?(0,k.jsx)(t,{className:`h-3 w-3 animate-spin`}):r?(0,k.jsx)(b,{className:`h-3 w-3`}):(0,k.jsx)(l,{className:`h-3 w-3`})}),(0,k.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-2 text-left`,onClick:()=>J({level:`packages`},e.id),onDoubleClick:()=>J({level:`files`,package:n}),children:[(0,k.jsx)(he,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,k.jsx)(`span`,{className:`truncate font-mono text-[10px] font-semibold`,children:e.label}),(0,k.jsx)(`span`,{className:`ml-auto text-[9px] text-muted-foreground`,children:e.fileCount??0})]}),(0,k.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:()=>J({level:`files`,package:n}),title:`Open file map`,"aria-label":`Open ${n} map`,children:(0,k.jsx)(f,{className:`h-3 w-3`})})]}),r&&o&&(0,k.jsx)(We,{directory:o,packageName:n,depth:1,expandedDirectories:je,expandedFiles:Pe,loadingBranches:P,graphForFile:Et,onToggleDirectory:At,onToggleFile:kt,onSelectFile:jt,onOpenFile:Ct,onSelectSymbol:Mt,selectedId:_,activeOperations:K})]},e.id)})}),(0,k.jsxs)(`div`,{className:`border-t px-3 py-2 text-[9px] leading-relaxed text-muted-foreground`,children:[`Click to focus · double-click to enter`,(0,k.jsx)(`br`,{}),`Branches stay open while the map changes`]})]}),(0,k.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,k.jsxs)(`div`,{className:`absolute left-3 right-3 top-3 z-10 flex items-center gap-2 pointer-events-none`,children:[(0,k.jsxs)(`div`,{className:`pointer-events-auto flex border bg-card/95 shadow-md backdrop-blur`,children:[(0,k.jsxs)(`button`,{type:`button`,className:S(`flex h-8 items-center gap-1.5 border-r px-2.5 text-[9px] font-semibold uppercase tracking-wider`,y===`layers`?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-muted`),onClick:()=>me(`layers`),children:[(0,k.jsx)(ee,{className:`h-3 w-3`}),` Layers`]}),(0,k.jsxs)(`button`,{type:`button`,className:S(`flex h-8 items-center gap-1.5 px-2.5 text-[9px] font-semibold uppercase tracking-wider`,y===`orbit`?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-muted`),onClick:()=>me(`orbit`),children:[(0,k.jsx)(u,{className:`h-3 w-3`}),` Relations`]})]}),(0,k.jsxs)(`div`,{className:`pointer-events-auto flex border bg-card/95 shadow-md backdrop-blur`,children:[(0,k.jsxs)(`button`,{type:`button`,className:S(`h-8 border-r px-2.5 font-mono text-[9px] font-bold`,x===`smart`?`bg-success text-success-foreground`:`text-muted-foreground hover:bg-muted`),onClick:()=>xe(`smart`),title:`Keep the full tree, show the strongest relations and selected neighbourhood`,children:[`SMART `,Q.nodes.length,`/`,o.nodes.length]}),(0,k.jsx)(`button`,{type:`button`,className:S(`h-8 px-2.5 font-mono text-[9px] font-bold`,x===`all`?`bg-foreground text-background`:`text-muted-foreground hover:bg-muted`),onClick:()=>xe(`all`),title:`Render every node and relation in this scope`,children:`ALL`})]}),(0,k.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,k.jsx)(`button`,{type:`button`,className:S(`h-8 whitespace-nowrap border-r px-2.5 font-mono text-[9px] last:border-r-0`,E===e?`bg-foreground text-background`:`text-muted-foreground hover:bg-muted`),onClick:()=>Se(e),children:e===`all`?`ALL LINKS`:e.replace(`_`,` `).toUpperCase()},e))})]}),(0,k.jsx)(Ke,{presences:ct,onLocate:$}),(0,k.jsx)(qe,{paused:z!==null,followLive:Xe,agentFilter:R,agents:ot,onTogglePaused:Dt,onToggleFollow:()=>{H.current=null,Ze(e=>!e)},onAgentFilter:e=>{H.current=null,Qe(e)}}),d&&(0,k.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,k.jsx)(t,{className:`h-7 w-7 animate-spin text-primary`}),(0,k.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-widest text-muted-foreground`,children:`Mapping relationships`})]}),g&&!d&&(0,k.jsxs)(`div`,{className:`absolute inset-0 z-20 flex flex-col items-center justify-center gap-3 p-8 text-center`,children:[(0,k.jsx)(r,{className:`h-10 w-10 text-destructive`}),(0,k.jsx)(`p`,{className:`font-mono text-sm text-destructive`,children:g}),(0,k.jsxs)(`p`,{className:`max-w-md text-xs text-muted-foreground`,children:[`The map needs a codebase index. Run`,` `,(0,k.jsx)(`code`,{className:`border bg-muted px-1.5 py-0.5`,children:`codebase-index`}),` once, then reopen this view.`]})]}),!d&&!g&&o.nodes.length===0&&(0,k.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-2 text-muted-foreground`,children:[(0,k.jsx)(r,{className:`h-8 w-8 opacity-40`}),(0,k.jsx)(`p`,{className:`text-xs`,children:`No indexed nodes at this level.`})]}),!d&&!g&&o.nodes.length>1&&o.edges.length===0&&(0,k.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,k.jsx)(`div`,{className:`font-mono text-[9px] font-bold uppercase tracking-wider text-warning`,children:`No resolved relations in this scope`}),(0,k.jsx)(`div`,{className:`mt-0.5 text-[8px] text-muted-foreground`,children:`The upgraded index will rebuild and resolve call/import/type links automatically.`})]}),!g&&o.nodes.length>0&&(0,k.jsxs)(ie,{nodes:lt,edges:ft,onNodesChange:dt,onEdgesChange:mt,nodeTypes:Be,nodesConnectable:!1,nodesDraggable:!1,edgesFocusable:!1,elementsSelectable:!1,onlyRenderVisibleElements:Q.nodes.length>80,minZoom:.08,maxZoom:2.2,proOptions:{hideAttribution:!0},children:[(0,k.jsx)(pe,{variant:oe.Dots,gap:22,size:1,color:`hsl(var(--muted-foreground))`,className:`!opacity-25`}),(0,k.jsx)(te,{position:`bottom-left`,showInteractive:!1,className:`!border !border-border !bg-card !shadow-md [&>button]:!border-border [&>button]:!bg-card [&>button]:!fill-foreground`}),(0,k.jsx)(re,{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,k.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(Ee).map(([e,t])=>(0,k.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,k.jsx)(`span`,{className:`h-0.5 w-3`,style:{backgroundColor:t}}),e.replace(`_`,` `)]},e)),(0,k.jsxs)(`span`,{className:`flex items-center gap-1 text-primary`,"data-testid":`agent-trail-count`,children:[(0,k.jsx)(`span`,{className:`w-4 border-t-2 border-dashed border-primary`}),`agent trail`,nt>0?` ×${nt}`:``]})]})]}),(0,k.jsxs)(`aside`,{className:`flex w-[326px] shrink-0 flex-col border-l bg-card/80`,children:[(0,k.jsxs)(`div`,{className:`flex h-10 items-center justify-between border-b px-3`,children:[(0,k.jsx)(`h2`,{className:`text-[10px] font-bold uppercase tracking-[0.18em]`,children:`Relation inspector`}),Z&&(0,k.jsx)(`button`,{type:`button`,className:`text-muted-foreground hover:text-foreground`,onClick:()=>v(null),"aria-label":`Clear selection`,children:(0,k.jsx)(le,{className:`h-3.5 w-3.5`})})]}),Z?(0,k.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[(0,k.jsxs)(`div`,{className:`border-b bg-muted/25 p-3`,children:[(0,k.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,k.jsx)(`span`,{className:S(`flex h-8 w-8 items-center justify-center border`,A[Z.kind].iconStyle),children:(()=>{let e=A[Z.kind].icon;return(0,k.jsx)(e,{className:`h-4 w-4`})})()}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsxs)(`div`,{className:`text-[8px] font-bold uppercase tracking-[0.18em] text-muted-foreground`,children:[Z.external?`external `:``,Z.kind]}),(0,k.jsx)(`div`,{className:`truncate font-mono text-xs font-semibold`,title:Z.label,children:Z.label})]})]}),(0,k.jsx)(`div`,{className:`break-all font-mono text-[9px] leading-relaxed text-muted-foreground`,children:Z.file?D(Z):Z.package}),Z.signature&&(0,k.jsx)(`pre`,{className:`mt-3 overflow-x-auto border bg-background p-2 font-mono text-[9px] leading-relaxed text-foreground`,children:Z.signature}),(0,k.jsxs)(`div`,{className:`mt-3 grid grid-cols-3 border`,children:[(0,k.jsxs)(`div`,{className:`border-r p-2 text-center`,children:[(0,k.jsx)(`div`,{className:`font-mono text-sm font-semibold text-info`,children:Ft.length}),(0,k.jsx)(`div`,{className:`text-[8px] uppercase text-muted-foreground`,children:`incoming`})]}),(0,k.jsxs)(`div`,{className:`border-r p-2 text-center`,children:[(0,k.jsx)(`div`,{className:`font-mono text-sm font-semibold text-primary`,children:It.length}),(0,k.jsx)(`div`,{className:`text-[8px] uppercase text-muted-foreground`,children:`outgoing`})]}),(0,k.jsxs)(`div`,{className:`p-2 text-center`,children:[(0,k.jsx)(`div`,{className:`font-mono text-sm font-semibold`,children:Z.symbolCount??Z.fileCount??Z.line??`—`}),(0,k.jsx)(`div`,{className:`text-[8px] uppercase text-muted-foreground`,children:Z.kind===`package`?`files`:Z.kind===`file`?`symbols`:`line`})]})]}),(0,k.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[Z.kind!==`symbol`&&(0,k.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:()=>Ct(Z),children:[(0,k.jsx)(f,{className:`h-3 w-3`}),` Open`,` `,Z.kind===`package`?`files`:`symbols`]}),Z.file&&(0,k.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:()=>Ye(Z.file),children:[(0,k.jsx)(c,{className:`h-3 w-3`}),` Activity`]})]})]}),zt.length>0&&(0,k.jsxs)(`section`,{className:`border-b bg-success/5 py-2`,children:[(0,k.jsxs)(`div`,{className:`mb-1 flex items-center gap-2 px-3`,children:[(0,k.jsx)(h,{className:`h-3 w-3 animate-pulse text-success`}),(0,k.jsx)(`h3`,{className:`text-[9px] font-bold uppercase tracking-[0.16em]`,children:`Agents on this node`}),(0,k.jsx)(`span`,{className:`ml-auto font-mono text-[9px] text-success`,children:zt.length})]}),zt.map(e=>(0,k.jsx)(I,{activity:e,onLocate:$,showAgent:!0},e.id??`${e.toolUseId}:${e.filePath}`))]}),(0,k.jsx)(Ge,{title:`Incoming`,subtitle:`Who depends on this`,items:Ft,graph:X,selectedId:Z.id,expanded:Re,onToggle:e=>ze(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),onSelect:St}),(0,k.jsx)(Ge,{title:`Outgoing`,subtitle:`What this depends on`,items:It,graph:X,selectedId:Z.id,expanded:Re,onToggle:e=>ze(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),onSelect:St})]}):(0,k.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[K.length>0&&(0,k.jsxs)(`section`,{className:`border-b`,children:[(0,k.jsxs)(`div`,{className:`flex h-9 items-center gap-2 border-b bg-success/5 px-3`,children:[(0,k.jsx)(h,{className:`h-3 w-3 animate-pulse text-success`}),(0,k.jsx)(`h3`,{className:`text-[9px] font-bold uppercase tracking-[0.16em]`,children:`Active now`}),(0,k.jsx)(`span`,{className:`ml-auto font-mono text-[9px] text-success`,children:K.length})]}),K.map(e=>(0,k.jsx)(I,{activity:e,onLocate:$,showAgent:!0},e.id??`${e.toolUseId}:${e.filePath}`))]}),(0,k.jsxs)(`section`,{children:[(0,k.jsxs)(`div`,{className:`flex h-9 items-center gap-2 border-b px-3`,children:[(0,k.jsx)(c,{className:`h-3 w-3 text-muted-foreground`}),(0,k.jsx)(`h3`,{className:`text-[9px] font-bold uppercase tracking-[0.16em]`,children:`Event stream`}),(0,k.jsxs)(`span`,{className:`ml-auto font-mono text-[8px] text-muted-foreground`,children:[U.totalCount,` total`]})]}),st.length>0?st.map((e,t)=>(0,k.jsx)(I,{activity:e,onLocate:$,showAgent:!0},e.id??`${e.timestamp}:${t}`)):(0,k.jsxs)(`div`,{className:`flex flex-col items-center justify-center px-7 py-16 text-center`,children:[(0,k.jsx)(`span`,{className:`mb-4 flex h-12 w-12 items-center justify-center border bg-muted text-muted-foreground`,children:(0,k.jsx)(de,{className:`h-5 w-5`})}),(0,k.jsx)(`h3`,{className:`text-xs font-semibold`,children:`Select a node or wait for an agent`}),(0,k.jsx)(`p`,{className:`mt-2 text-[10px] leading-relaxed text-muted-foreground`,children:`Relations appear on selection. Tool calls and external filesystem touches stream here live.`})]})]})]})]})]}),L&&(0,k.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,k.jsxs)(`div`,{className:`flex h-12 items-center justify-between border-b px-4`,children:[(0,k.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,k.jsx)(c,{className:`h-4 w-4 shrink-0 text-warning`}),(0,k.jsx)(`span`,{className:`truncate font-mono text-[11px] font-semibold`,title:L,children:L})]}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>Ye(null),className:`flex h-7 w-7 items-center justify-center border text-muted-foreground hover:bg-muted`,"aria-label":`Close activity`,children:(0,k.jsx)(le,{className:`h-3.5 w-3.5`})})]}),(0,k.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-3`,children:Bt.length===0?(0,k.jsx)(`p`,{className:`py-12 text-center text-[10px] text-muted-foreground`,children:`No activity recorded for this file yet.`}):Bt.map((e,t)=>(0,k.jsxs)(`div`,{className:`mb-1 flex items-start gap-2 border p-2 text-[10px]`,children:[(0,k.jsx)(`span`,{className:S(`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,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsx)(`div`,{className:`font-mono text-[9px] text-muted-foreground`,children:new Date(e.timestamp).toLocaleTimeString()}),e.toolName&&(0,k.jsxs)(`div`,{className:`mt-1`,children:[`via `,e.toolName]}),e.agent&&(0,k.jsx)(`div`,{className:`text-muted-foreground`,children:e.agent}),e.summary&&(0,k.jsx)(`div`,{className:`mt-1 text-muted-foreground`,children:e.summary}),e.change&&(0,k.jsxs)(`div`,{className:`mt-1 flex items-center gap-1 font-mono text-[8px]`,children:[(0,k.jsxs)(`span`,{className:`border border-success/40 bg-success/10 px-1 text-success`,children:[`+`,e.change.added]}),(0,k.jsxs)(`span`,{className:`border border-destructive/40 bg-destructive/10 px-1 text-destructive`,children:[`−`,e.change.removed]}),e.change.before&&(0,k.jsx)(`span`,{className:`ml-1 truncate text-destructive/80`,title:e.change.before,children:e.change.before}),e.change.after&&(0,k.jsxs)(`span`,{className:`truncate text-success/80`,title:e.change.after,children:[`→ `,e.change.after]})]}),(0,k.jsxs)(`div`,{className:`mt-1 flex gap-2 font-mono text-[8px] uppercase text-muted-foreground`,children:[(0,k.jsx)(`span`,{children:e.status??`observed`}),(0,k.jsx)(`span`,{children:e.source??`legacy`}),e.durationMs!==void 0&&(0,k.jsxs)(`span`,{children:[e.durationMs,`ms`]}),e.watcherConfirmed&&(0,k.jsx)(`span`,{className:`text-success`,children:`fs verified`})]})]})]},`${e.timestamp}-${t}`))}),(0,k.jsxs)(`div`,{className:`border-t px-4 py-2 font-mono text-[9px] text-muted-foreground`,children:[Bt.length,` events · newest first`]})]})]})}function L(){return(0,k.jsx)(me,{children:(0,k.jsx)(Je,{})})}export{L as CodeMap};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{ea as t,oa as n,ta as r,tt as i}from"./vendor-DffL_bim.js";import"./i18n-Dk35g-uV.js";import{a,i as o,n as s,o as c,r as l,t as u}from"./dialog-CBgO-uqz.js";import{t as d}from"./button-Dy0bAtEY.js";import{t as f}from"./input-B6FY_vtB.js";var p=e(n(),1),m=i(),h=t()((e,t)=>({request:null,open:n=>{t().request?.resolve(!1),e({request:n})},settle:n=>{t().request?.resolve(n),e({request:null})}}));function g(e){return new Promise(t=>{h.getState().open({...e,resolve:t})})}function _(){let{t:e}=r(),t=h(e=>e.request),n=h(e=>e.settle);return(0,p.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Enter`&&(e.preventDefault(),h.getState().settle(!0))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]),(0,m.jsx)(u,{open:t!==null,onOpenChange:e=>{e||n(!1)},children:(0,m.jsxs)(s,{className:`max-w-md`,children:[(0,m.jsxs)(a,{children:[(0,m.jsx)(c,{children:t?.title}),t?.message&&(0,m.jsx)(l,{children:t.message})]}),(0,m.jsxs)(o,{className:`gap-2`,children:[(0,m.jsx)(d,{variant:`outline`,size:`sm`,onClick:()=>n(!1),children:t?.cancelLabel??e(`common:action.cancel`)}),(0,m.jsx)(d,{variant:t?.danger?`destructive`:`default`,size:`sm`,autoFocus:!0,onClick:()=>n(!0),children:t?.confirmLabel??e(`common:action.confirm`)})]})]})})}var v=t()((e,t)=>({request:null,open:n=>{t().request?.resolve(null),e({request:n})},settle:n=>{t().request?.resolve(n),e({request:null})}}));function y(e){return new Promise(t=>{v.getState().open({...e,resolve:t})})}function b(){let{t:e}=r(),t=v(e=>e.request),n=v(e=>e.settle),[i,h]=(0,p.useState)(``);(0,p.useEffect)(()=>{h(t?.defaultValue??``)},[t]);let g=()=>{let e=i.trim();n(e.length>0?e:null)};return(0,m.jsx)(u,{open:t!==null,onOpenChange:e=>{e||n(null)},children:(0,m.jsxs)(s,{className:`max-w-md`,children:[(0,m.jsxs)(a,{children:[(0,m.jsx)(c,{children:t?.title}),t?.message&&(0,m.jsx)(l,{children:t.message})]}),(0,m.jsx)(f,{autoFocus:!0,value:i,placeholder:t?.placeholder,onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),g())}}),(0,m.jsxs)(o,{className:`gap-2`,children:[(0,m.jsx)(d,{variant:`outline`,size:`sm`,onClick:()=>n(null),children:t?.cancelLabel??e(`common:action.cancel`)}),(0,m.jsx)(d,{size:`sm`,disabled:i.trim().length===0,onClick:g,children:t?.confirmLabel??e(`common:action.ok`)})]})]})})}export{y as i,b as n,g as r,_ as t};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Bt as t,Jr as n,Ti as r,bn as i,ia as a,oa as o,ot as s,qt as c,ta as l,tt as u}from"./vendor-DffL_bim.js";import"./i18n-Dk35g-uV.js";import{t as d}from"./useWebSocket-BJorYmOi.js";import{t as f}from"./utils-DEzFewqr.js";import{s as p}from"./view-navigation-BjlXpDXc.js";import{v as m}from"./index-OmSX-BAb.js";var h=e(o(),1);function g(e,t,n){return e<t?t:e>n?n:e}function _(e){let t=/^oklch\(\s*([^)]+)\)$/i.exec(e.trim());if(!t?.[1])return null;let n=(t[1].split(`/`)[0]??``).trim().split(/\s+/);if(n.length<3||!n[0]||!n[1]||!n[2])return null;let r=n[0].endsWith(`%`)?Number.parseFloat(n[0])/100:Number.parseFloat(n[0]),i=n[1].endsWith(`%`)?Number.parseFloat(n[1])/100*.4:Number.parseFloat(n[1]),a=Number.parseFloat(n[2].replace(/deg$/i,``));return[r,i,a].every(Number.isFinite)?[g(r,0,1),Math.max(0,i),a]:null}function v(e){return g(e<=.0031308?12.92*e:1.055*e**(1/2.4)-.055,0,1)}function y(e){return Math.round(e*255).toString(16).padStart(2,`0`)}function b(e){let t=_(e);if(!t)return null;let[n,r,i]=t,a=i*Math.PI/180,o=r*Math.cos(a),s=r*Math.sin(a),c=n+.3963377774*o+.2158037573*s,l=n-.1055613458*o-.0638541728*s,u=n-.0894841775*o-1.291485548*s,d=c**3,f=l**3,p=u**3,m=4.0767416621*d-3.3077115913*f+.2309699292*p,h=-1.2684380046*d+2.6097574011*f-.3413193965*p,g=-.0041960863*d-.7034186147*f+1.707614701*p;return`#${y(v(m))}${y(v(h))}${y(v(g))}`}function x(e){let t=e.trim(),n=b(t);if(n)return n.toLowerCase();let r=/^#([0-9a-f]{6})([0-9a-f]{2})?$/i.exec(t);if(r?.[1])return`#${r[1].toLowerCase()}`;let i=/^#([0-9a-f]{3})$/i.exec(t);return i?.[1]?`#${i[1].split(``).map(e=>e+e).join(``).toLowerCase()}`:null}var S=u(),C=[`web`,`react-native`,`flutter`,`swiftui`,`compose`],w=[`primary`,`accent`,`bg`,`surface`,`fg`,`border`];function T(e,t,n){let r={...e};for(let[e,i]of Object.entries(t))e.startsWith(`light.`)?n===`light`&&(r[e.slice(6)]=i):e.startsWith(`dark.`)?n===`dark`&&(r[e.slice(5)]=i):r[e]=i;return r}function E({t:e,label:t}){let n=e.bg??`#fff`,r=e.surface??n,i=e.fg??`#111`,a=e.muted??i,o=e.primary??`#3b82f6`,s=e.accent??o,c=e.border??a,l=e.radius??`0.5rem`,u=e.fontSans??`system-ui, sans-serif`,d=e.fontDisplay??u,f=e.shadow&&e.shadow!==`none`?e.shadow:void 0;return(0,S.jsxs)(`div`,{style:{background:n,color:i,fontFamily:u},className:`flex min-w-0 flex-col gap-2 overflow-hidden p-3`,children:[(0,S.jsx)(`div`,{className:`text-[9px] uppercase tracking-wide`,style:{color:a},children:t}),(0,S.jsxs)(`div`,{style:{background:r,border:`1px solid ${c}`,borderRadius:l,boxShadow:f},className:`flex min-w-0 flex-col gap-2 p-3`,children:[(0,S.jsx)(`div`,{style:{fontFamily:d},className:`text-base font-bold leading-tight`,children:`Aa Heading`}),(0,S.jsx)(`div`,{className:`text-[11px] leading-snug`,style:{color:a},children:`The quick brown fox jumps over the lazy dog.`}),(0,S.jsxs)(`div`,{className:`mt-1 flex min-w-0 items-center gap-1.5`,children:[(0,S.jsx)(`span`,{style:{background:o,color:n,borderRadius:l},className:`shrink-0 px-2.5 py-1 text-[10px] font-semibold`,children:`Primary`}),(0,S.jsx)(`span`,{style:{border:`1px solid ${c}`,color:i,borderRadius:l},className:`shrink-0 px-2 py-1 text-[10px]`,children:`Ghost`}),(0,S.jsx)(`span`,{style:{background:s,color:n,borderRadius:`999px`},className:`ml-auto shrink-0 px-2 py-0.5 text-[9px] font-semibold`,children:`Badge`})]}),(0,S.jsx)(`div`,{style:{border:`1px solid ${c}`,borderRadius:l,color:a},className:`text-[10px] px-2 py-1.5 mt-1`,children:`Input field…`})]})]})}function D({kit:e,overrides:t,onSet:n}){let[r,i]=(0,h.useState)(`light`),{t:a}=l(),o=T(r===`light`?e.light:e.dark,t,r);return(0,S.jsxs)(`div`,{className:`mt-1 rounded-lg border border-border/60 p-2 bg-muted/30`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[(0,S.jsx)(`span`,{className:`text-[10px] font-semibold uppercase text-muted-foreground`,children:a(`activity:design.colors`)}),(0,S.jsx)(`div`,{className:`ml-auto inline-flex rounded border border-border/60 overflow-hidden`,children:[`light`,`dark`].map(e=>(0,S.jsx)(`button`,{type:`button`,onClick:()=>i(e),className:f(`text-[10px] px-1.5 py-0.5`,r===e?`bg-primary text-primary-foreground`:`text-muted-foreground`),children:e},e))})]}),(0,S.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:w.filter(e=>o[e]).map(e=>{let t=x(o[e]??``)??`#000000`;return(0,S.jsxs)(`label`,{className:`flex min-w-[2rem] flex-col items-center gap-0.5`,title:`${e}: ${o[e]}`,children:[(0,S.jsx)(`input`,{type:`color`,value:t,onChange:t=>n(`${r}.${e}`,t.target.value),className:`w-6 h-6 rounded cursor-pointer bg-transparent border border-border/60 p-0`}),(0,S.jsx)(`span`,{className:`text-[8px] text-muted-foreground`,children:e})]},e)})})]})}function O({className:e}){let{client:o}=d(),{t:u}=l(),[g,_]=(0,h.useState)([]),[v,y]=(0,h.useState)(null),[b,x]=(0,h.useState)({}),[w,O]=(0,h.useState)(`web`),[k,A]=(0,h.useState)(``),[j,M]=(0,h.useState)(null);(0,h.useEffect)(()=>{if(!o)return;let e=e=>{let t=e.payload;_(t?.kits??[]),y(t?.activeKit??null),x(t?.overrides??{})},t=e=>{let t=e.payload;t?.ok&&t.kit&&(y(t.kit),x(t.overrides??{}))},n=e=>{let t=e.payload;t?.ok&&t.overrides&&x(t.overrides)},r=e=>{let t=e.payload;M(t?.ok?a.t(`activity:design.wrote`,{path:t.path}):a.t(`activity:design.materializeFailed`,{error:t?.error??`error`}))},i=e=>{let t=e.payload;if(!t?.ok){M(a.t(`activity:design.verifyError`,{error:t?.error??`error`}));return}let n=Math.round((t.score??1)*100);M(t.violationCount?a.t(`activity:design.verifyOffPalette`,{pct:n,count:t.violationCount,files:t.filesScanned}):a.t(`activity:design.verifyClean`,{files:t.filesScanned}))};return o.on(`design.list`,e),o.on(`design.use`,t),o.on(`design.set`,n),o.on(`design.materialize`,r),o.on(`design.verify`,i),o.send({type:`design.list`}),()=>{o.off(`design.list`,e),o.off(`design.use`,t),o.off(`design.set`,n),o.off(`design.materialize`,r),o.off(`design.verify`,i)}},[o]);let N=(0,h.useCallback)(e=>o?.send({type:`design.use`,payload:{kit:e,stack:w}}),[o,w]),P=(0,h.useCallback)((e,t)=>{x(n=>({...n,[e]:t})),o?.send({type:`design.set`,payload:{overrides:{[e]:t}}})},[o]),F=(0,h.useCallback)(()=>{M(a.t(`activity:design.writing`)),o?.send({type:`design.materialize`,payload:{stack:w}})},[o,w]),I=(0,h.useCallback)(()=>{M(a.t(`activity:design.scanning`)),o?.send({type:`design.verify`})},[o]),L=(0,h.useMemo)(()=>{let e=k.trim().toLowerCase();return[...e?g.filter(t=>t.id.includes(e)||t.name.toLowerCase().includes(e)||t.aesthetic.toLowerCase().includes(e)||t.tags.some(t=>t.includes(e))):g].sort((e,t)=>e.name.localeCompare(t.name))},[g,k]);return(0,S.jsxs)(`div`,{className:f(`flex h-full min-h-0 min-w-0 flex-col overflow-hidden bg-[hsl(var(--surface-2)/0.45)]`,e),children:[(0,S.jsx)(`div`,{className:`border-b border-border/60 p-3`,children:(0,S.jsx)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-3 shadow-sm`,children:(0,S.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center`,children:[(0,S.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,S.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,S.jsx)(i,{className:`h-4 w-4`})}),(0,S.jsxs)(`div`,{className:`min-w-0`,children:[(0,S.jsx)(`h2`,{className:`truncate text-sm font-semibold`,children:u(`activity:design.heading`)}),(0,S.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`activity:design.kitsCount`,{count:L.length})})]})]}),(0,S.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2 sm:flex-row sm:items-center lg:justify-end`,children:[(0,S.jsxs)(`label`,{className:`relative min-w-0 flex-1 sm:max-w-xs`,children:[(0,S.jsx)(c,{className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground/70`}),(0,S.jsx)(`input`,{value:k,onChange:e=>A(e.target.value),placeholder:u(`activity:design.searchPlaceholder`),className:`h-9 w-full rounded-md border border-border/70 bg-background/70 pl-8 pr-3 text-sm shadow-sm outline-none transition focus:border-primary/40 focus:ring-2 focus:ring-ring/30`})]}),(0,S.jsx)(`select`,{value:w,onChange:e=>O(e.target.value),className:`h-9 rounded-md border border-border/70 bg-background/70 px-2 text-sm shadow-sm`,title:u(`activity:design.stackTitle`),children:C.map(e=>(0,S.jsx)(`option`,{value:e,children:e},e))}),j&&(0,S.jsx)(`span`,{className:`min-w-0 truncate rounded-md border border-border/60 bg-muted/40 px-2 py-1 text-[11px] text-muted-foreground sm:max-w-56`,children:j}),(0,S.jsx)(`button`,{type:`button`,onClick:()=>p(`chat`),className:`inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground`,title:u(`common:action.close`),children:(0,S.jsx)(s,{className:`h-4 w-4`})})]})]})})}),(0,S.jsx)(`div`,{ref:m(`design-gallery`),className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain p-3 sm:p-4`,children:L.length===0?(0,S.jsxs)(`div`,{className:`ws-surface mx-auto mt-8 flex max-w-md flex-col items-center gap-3 rounded-xl p-6 text-center text-muted-foreground`,children:[(0,S.jsx)(i,{className:`h-8 w-8 text-primary/60`}),(0,S.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:u(`activity:design.kitsCount`,{count:0})}),(0,S.jsx)(`p`,{className:`text-xs`,children:u(`activity:design.searchPlaceholder`)})]}):(0,S.jsx)(`div`,{className:`grid gap-4 [grid-template-columns:repeat(auto-fill,minmax(min(100%,20rem),1fr))]`,children:L.map(e=>{let i=v===e.id,a=i?b:{};return(0,S.jsxs)(`div`,{className:f(`flex min-w-0 flex-col overflow-hidden rounded-xl border bg-card/75 shadow-sm`,i?`border-primary/60 ring-1 ring-primary/30`:`border-border/70`),children:[(0,S.jsxs)(`div`,{className:`grid min-h-[12rem] grid-cols-1 sm:grid-cols-2`,children:[(0,S.jsx)(E,{t:T(e.light,a,`light`),label:u(`activity:designStudio.light`)}),(0,S.jsx)(E,{t:T(e.dark,a,`dark`),label:u(`activity:designStudio.dark`)})]}),(0,S.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 border-t border-border/60 bg-card p-3`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,S.jsx)(`h3`,{className:`text-sm font-semibold truncate`,children:e.name}),(0,S.jsx)(`code`,{className:`text-[10px] text-muted-foreground`,children:e.id}),i&&(0,S.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-[9px] font-semibold uppercase text-primary ml-auto`,children:[(0,S.jsx)(r,{className:`w-3 h-3`}),` `,u(`activity:design.active`)]})]}),(0,S.jsx)(`p`,{className:`text-[11px] text-muted-foreground leading-snug`,children:e.aesthetic}),(0,S.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-2`,children:[(0,S.jsx)(`button`,{type:`button`,onClick:()=>N(e.id),className:f(`rounded-md px-2.5 py-1 text-[11px] font-medium transition`,i?`bg-primary/10 text-primary`:`bg-primary text-primary-foreground hover:opacity-90`),children:u(i?`activity:design.reapply`:`activity:design.use`)}),i&&(0,S.jsxs)(`button`,{type:`button`,onClick:F,className:`inline-flex items-center gap-1 rounded-md border border-border/60 px-2 py-1 text-[11px] font-medium hover:bg-muted`,title:u(`activity:design.materializeTitle`,{stack:w}),children:[(0,S.jsx)(n,{className:`w-3 h-3`}),` `,u(`activity:design.materialize`)]}),i&&(0,S.jsxs)(`button`,{type:`button`,onClick:I,className:`inline-flex items-center gap-1 rounded-md border border-border/60 px-2 py-1 text-[11px] font-medium hover:bg-muted`,title:u(`activity:design.verifyTitle`),children:[(0,S.jsx)(t,{className:`w-3 h-3`}),` `,u(`activity:design.verify`)]}),(0,S.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[10px] text-muted-foreground`,children:e.bestFor})]}),i&&(0,S.jsx)(D,{kit:e,overrides:a,onSet:P})]})]},e.id)})})})]})}export{O as DesignGalleryView};
@@ -1,2 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{$t as t,Bt as n,Ct as r,Ft as i,Gi as a,Jr as o,Kt as s,Mt as c,Pi as l,Pn as u,Qi as d,Ti as f,Vt as p,Xr as m,Yt as h,Zt as g,_i as _,bt as v,cn as y,di as b,ei as x,en as S,ht as ee,ji as C,kn as te,ln as w,mn as T,ni as ne,oa as E,oi as re,or as ie,ot as ae,pr as D,qt as O,rn as oe,tt as se,vi as ce,wi as k,wn as le,wt as ue}from"./vendor-DffL_bim.js";import{t as de}from"./ws-client-Fnmzo7vN.js";import{t as A}from"./utils-DEzFewqr.js";import{t as fe}from"./session-store-Coiik-Ib.js";import{b as pe,j as me,u as he}from"./stores-CUp_ut8r.js";import{n as ge,t as _e}from"./ModelPicker-CEZN673P.js";import{d as ve,u as ye,v as be}from"./index-OmSX-BAb.js";var j=e(E(),1);function xe(e){let t=me(e=>e.wsUrl),n=me(e=>e.provider),r=me(e=>e.model),[i,a]=(0,j.useState)([]),[o,s]=(0,j.useState)([]),[c,l]=(0,j.useState)({}),[u,d]=(0,j.useState)(``),[f,p]=(0,j.useState)(``);return(0,j.useEffect)(()=>{let e=de(t).on(`kanban.meta`,e=>{let t=e.payload?.data;t&&(a(t.tools??[]),s(t.skills??[]),l(t.fallbackProfiles??{}),t.sessionProvider&&d(t.sessionProvider),t.sessionModel&&p(t.sessionModel))});return()=>e()},[t]),(0,j.useEffect)(()=>{e&&de(t).send({type:`kanban.meta`})},[e,t]),{tools:i,skills:o,fallbackProfiles:c,sessionProvider:u||n,sessionModel:f||r}}function Se(e,t=!0){(0,j.useEffect)(()=>{let n=e.current;if(!n||!t)return;let r=e=>{if(!e.shiftKey||n.scrollWidth<=n.clientWidth+1)return;let t=Math.abs(e.deltaY)>Math.abs(e.deltaX)?e.deltaY:e.deltaX;t!==0&&(e.preventDefault(),n.scrollLeft+=t)},i=e=>{if(!e.ctrlKey&&!e.metaKey||n.scrollWidth<=n.clientWidth+1)return;let t=n.clientWidth*.8;e.key===`ArrowLeft`?(e.preventDefault(),n.scrollLeft-=t):e.key===`ArrowRight`&&(e.preventDefault(),n.scrollLeft+=t)};return n.addEventListener(`wheel`,r,{passive:!1}),n.addEventListener(`keydown`,i),()=>{n.removeEventListener(`wheel`,r),n.removeEventListener(`keydown`,i)}},[e,t])}var Ce=4320*60*1e3,we=new Set([`completed`,`archived`]);function Te(e,t){let n=B(t.now);if(n===null)throw TypeError(`Kanban audit requires a valid current time`);let r=P(t.liveAgentIdentities),i=N(e,t.defaultReviewStaleAfterMs??Ce),a=ke(e),o=[];for(let s of e.tasks)we.has(s.status)||(Ee(o,s,t.requireDueDate===!0),M(o,s,n,r),De(o,s,n,i),a.length>1&&Oe(o,s,a));return o.sort(Pe),{issues:o,counts:{error:o.filter(e=>e.severity===`error`).length,warning:o.filter(e=>e.severity===`warning`).length},affectedTaskCount:new Set(o.map(e=>e.taskId)).size}}function Ee(e,t,n){L(t.description)||V(e,t,`missing-description`,`warning`,`Add a description`),Me(t).length===0&&V(e,t,`missing-assignee`,`warning`,`Assign an owner`),n&&!L(t.dueDate)&&V(e,t,`missing-due-date`,`warning`,`Set a due date`),!R(t.labels)&&!R(t.tags)&&V(e,t,`missing-labels`,`warning`,`Add labels or tags`),!R(t.childTaskIds)&&!R(t.subtasks)&&V(e,t,`missing-subtasks`,`warning`,`Define subtasks`),R(t.successCriteria)||V(e,t,`missing-success-criteria`,`warning`,`Add success criteria`)}function M(e,t,n,r){let i=t.assignment;if(!(t.status===`in_progress`||i?.status===`running`))return;let a=Me(t);if(!i||a.length===0||!L(i.leaseId)||!L(i.leaseExpiresAt)){V(e,t,`abandoned-running-task`,`error`,`Running without a complete assignment lease`);return}let o=B(i.leaseExpiresAt);if(o===null||o<=n){V(e,t,`stale-running-task`,`error`,`Assignment lease is expired`);return}a.some(e=>r.has(F(e)))||V(e,t,`abandoned-running-task`,`error`,`Assigned agent is not live`)}function De(e,t,n,r){if(t.status!==`review`)return;let i=je(t,`review`)??B(t.updatedAt);i===null||n-i<=r||V(e,t,`stale-review`,`warning`,`Waiting in review for ${Math.max(1,Math.floor((n-i)/(3600*1e3)))}h`)}function Oe(e,t,n){let r=Ae(t);if(r.length<2)return;let i=new Map(n.map((e,t)=>[F(e),t]));for(let n=1;n<r.length;n+=1){let a=r[n-1],o=r[n];if(!a||!o)continue;let s=i.get(F(a.state)),c=i.get(F(o.state));if(!(s===void 0||c===void 0||Math.abs(c-s)<=1)){V(e,t,`skipped-lifecycle-state`,`error`,`Lifecycle skipped ${a.state} → ${o.state}`);return}}}function ke(e){let t=[e.lifecycle,e.lifecyclePolicy,e.managedLifecycle];for(let e of t){let t=Ne(e);if(t.length>1)return t;if(!e||typeof e!=`object`||Array.isArray(e))continue;let n=e;if(n.mode===`managed`&&n.columns){let e=[`backlog`,`todo`,`running`,`review`,`done`].map(e=>n.columns?.[e]).filter(e=>L(e));if(e.length===5)return e}for(let e of[n.states,n.statuses,n.order,n.managedStatuses]){let t=Ne(e);if(t.length>1)return t}}return[]}function N(e,t){let n=[e,e.lifecycle,e.lifecyclePolicy,e.managedLifecycle];for(let e of n){if(!e||typeof e!=`object`||Array.isArray(e))continue;let t=e;if(z(t.staleReviewAfterMs))return t.staleReviewAfterMs;if(z(t.reviewStaleAfterMs))return t.reviewStaleAfterMs;if(z(t.reviewStaleHours))return t.reviewStaleHours*60*60*1e3}return t}function Ae(e){let t=e.lifecycle?.history??e.lifecycleHistory??e.statusHistory??e.history;if(!Array.isArray(t))return[];let n=[];for(let e of t){if(typeof e==`string`&&L(e)){n.push({state:e.trim(),at:null});continue}if(!e||typeof e!=`object`)continue;let t=e,r=I(t.status,t.state,t.toStatus,t.to,t.columnId);r&&n.push({state:r,at:B(t.at??t.ts??t.timestamp??t.changedAt??t.createdAt)})}return n}function je(e,t){let n=null;for(let r of Ae(e))F(r.state)!==F(t)||r.at===null||(n=n===null?r.at:Math.max(n,r.at));return n}function Me(e){let t=e.assignment;return[e.assignee,e.assignedAgent,t?.agentId,t?.subagentId,t?.name].filter(L)}function Ne(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(L(n)){t.push(n.trim());continue}if(!n||typeof n!=`object`)continue;let e=n,r=I(e.id,e.status,e.state,e.name);r&&t.push(r)}return t}function P(e){let t=new Set;if(!e)return t;for(let n of e)L(n)&&t.add(F(n));return t}function F(e){return e.trim().toLocaleLowerCase()}function I(...e){for(let t of e)if(L(t))return t.trim();return null}function L(e){return typeof e==`string`&&e.trim().length>0}function R(e){return Array.isArray(e)&&e.length>0}function z(e){return typeof e==`number`&&Number.isFinite(e)&&e>0}function B(e){if(e instanceof Date){let t=e.getTime();return Number.isFinite(t)?t:null}if(typeof e==`number`)return Number.isFinite(e)?e:null;if(typeof e!=`string`||!e.trim())return null;let t=Date.parse(e);return Number.isFinite(t)?t:null}function V(e,t,n,r,i){e.push({id:`${t.id}:${n}`,taskId:t.id,taskTitle:t.title,code:n,severity:r,message:i})}function Pe(e,t){let n=Fe(e.severity)-Fe(t.severity);if(n!==0)return n;let r=e.taskTitle.localeCompare(t.taskTitle);return r===0?e.message.localeCompare(t.message):r}function Fe(e){return e===`error`?0:1}var Ie=[`id`,`name`,`type`];function H(e){if(typeof e==`string`)return e.trim()||void 0;if(typeof e==`number`||typeof e==`boolean`)return String(e);if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e;for(let e of Ie){let n=t[e];if(typeof n==`string`&&n.trim())return n.trim()}}var U=se();function W({options:e,selected:t,onChange:n,placeholder:r,emptyLabel:i}){let[a,o]=(0,j.useState)(!1),[s,c]=(0,j.useState)(``),l=(0,j.useRef)(null);(0,j.useEffect)(()=>{if(!a)return;let e=e=>{l.current&&!l.current.contains(e.target)&&o(!1)};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[a]);let u=(0,j.useMemo)(()=>{let t=new Map(e.map(e=>[e.value,e.label]));return e=>t.get(e)??e},[e]),d=(0,j.useMemo)(()=>{let t=s.trim().toLowerCase();return(t?e.filter(e=>`${e.value} ${e.label} ${e.tag??``}`.toLowerCase().includes(t)):e).slice(0,80)},[e,s]),p=e=>{n(t.includes(e)?t.filter(t=>t!==e):[...t,e])};return(0,U.jsxs)(`div`,{ref:l,className:`relative`,children:[t.length>0&&(0,U.jsx)(`div`,{className:`mb-1 flex flex-wrap gap-1`,children:t.map(e=>(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-muted px-1.5 py-0.5 text-[11px]`,children:[(0,U.jsx)(`span`,{className:`max-w-[150px] truncate`,children:u(e)}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>p(e),className:`text-muted-foreground hover:text-destructive`,"aria-label":`Remove ${u(e)}`,children:(0,U.jsx)(ae,{size:11})})]},e))}),(0,U.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),className:`flex w-full items-center gap-1.5 rounded-md border border-border bg-muted px-2 py-1.5 text-left text-xs transition-colors hover:border-primary/45 hover:bg-muted/80`,children:[(0,U.jsx)(y,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-muted-foreground`,children:r??`Add…`}),(0,U.jsx)(k,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`})]}),a&&(0,U.jsxs)(`div`,{className:`absolute z-50 mt-1 max-h-72 w-full min-w-[240px] overflow-hidden rounded-md border border-border/80 bg-popover shadow-xl`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-border/70 bg-muted/20 px-2 py-1.5`,children:[(0,U.jsx)(`input`,{value:s,onChange:e=>c(e.target.value),placeholder:`Filter…`,className:`min-w-0 flex-1 bg-transparent text-xs outline-none placeholder:text-muted-foreground`}),s&&(0,U.jsx)(`button`,{type:`button`,onClick:()=>c(``),className:`text-muted-foreground hover:text-foreground`,children:(0,U.jsx)(ae,{className:`h-3 w-3`})})]}),(0,U.jsxs)(`div`,{className:`max-h-60 overflow-y-auto py-1`,children:[d.map(e=>{let n=t.includes(e.value);return(0,U.jsxs)(`button`,{type:`button`,onClick:()=>p(e.value),className:A(`flex w-full items-start gap-1.5 px-2 py-1.5 text-left text-xs transition-colors hover:bg-muted`,n?`bg-primary/8 text-primary`:`text-foreground`),children:[n?(0,U.jsx)(f,{className:`mt-0.5 h-3 w-3 shrink-0 text-primary`}):(0,U.jsx)(`span`,{className:`w-3 shrink-0`}),(0,U.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`span`,{className:`block truncate`,children:e.label}),e.description&&(0,U.jsx)(`span`,{className:`mt-0.5 block truncate text-[10px] text-muted-foreground`,children:e.description})]}),e.tag&&(0,U.jsx)(`span`,{className:`mt-0.5 shrink-0 font-mono text-[9px] text-muted-foreground`,children:e.tag})]},e.value)}),d.length===0&&(0,U.jsx)(`div`,{className:`px-2 py-3 text-center text-[11px] text-muted-foreground`,children:e.length===0?i??`Nothing available`:`No match`})]})]})]})}function Le({audit:e,onSelectTask:t}){let[n,r]=(0,j.useState)(!0),a=(0,j.useId)();if((0,j.useEffect)(()=>{e.issues.length>0&&r(!0)},[e.issues.length]),e.issues.length===0)return null;let o=Re(e.issues);return(0,U.jsxs)(`section`,{"aria-labelledby":`${a}-title`,className:`shrink-0 border-b border-warning/25 bg-card/95 shadow-[inset_0_1px_0_hsl(var(--warning)/0.08)]`,children:[(0,U.jsxs)(`div`,{className:`flex min-h-10 flex-wrap items-center gap-2 px-3 py-2 sm:px-4`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,role:`status`,"aria-live":`polite`,children:[(0,U.jsx)(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-warning/25 bg-warning/10 text-warning`,children:(0,U.jsx)(i,{size:14,"aria-hidden":`true`})}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsxs)(`h2`,{id:`${a}-title`,className:`text-xs font-semibold text-foreground`,children:[`Kanban Cleaner found `,e.issues.length,` `,e.issues.length===1?`issue`:`issues`]}),(0,U.jsxs)(`p`,{className:`truncate text-[10px] text-muted-foreground`,children:[e.affectedTaskCount,` `,e.affectedTaskCount===1?`card needs`:`cards need`,` attention`]})]})]}),e.counts.error>0&&(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-destructive/25 bg-destructive/10 px-2 py-0.5 text-[10px] font-medium text-destructive`,children:[(0,U.jsx)(ce,{size:11,"aria-hidden":`true`}),` `,e.counts.error,` critical`]}),e.counts.warning>0&&(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-warning/25 bg-warning/10 px-2 py-0.5 text-[10px] font-medium text-warning`,children:[(0,U.jsx)(v,{size:11,"aria-hidden":`true`}),` `,e.counts.warning,` warning`]}),(0,U.jsx)(`button`,{type:`button`,"aria-expanded":n,"aria-controls":a,"aria-label":n?`Collapse Kanban Cleaner issues`:`Expand Kanban Cleaner issues`,onClick:()=>r(e=>!e),className:`flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,children:(0,U.jsx)(k,{size:14,"aria-hidden":`true`,className:A(`transition-transform`,n&&`rotate-180`)})})]}),n&&(0,U.jsx)(`ul`,{id:a,className:`grid max-h-36 gap-1 overflow-y-auto px-3 pb-2 sm:grid-cols-2 sm:px-4 xl:grid-cols-3`,children:o.map(({taskId:e,taskTitle:n,issues:r})=>(0,U.jsx)(`li`,{children:(0,U.jsxs)(`button`,{type:`button`,onClick:()=>t(e),"aria-label":`Open ${n}: ${r.map(e=>e.message).join(`, `)}`,className:`group flex w-full items-start gap-2 rounded-md border border-border/70 bg-background/70 px-2.5 py-2 text-left transition-colors hover:border-primary/40 hover:bg-primary/5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,children:[(0,U.jsx)(`span`,{className:A(`mt-1 h-1.5 w-1.5 shrink-0 rounded-full`,r.some(e=>e.severity===`error`)?`bg-destructive shadow-[0_0_8px_hsl(var(--destructive)/0.55)]`:`bg-warning shadow-[0_0_8px_hsl(var(--warning)/0.45)]`),"aria-hidden":`true`}),(0,U.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`span`,{className:`block truncate text-[11px] font-semibold text-foreground group-hover:text-primary`,children:n}),(0,U.jsx)(`span`,{className:`mt-0.5 block line-clamp-2 text-[10px] leading-4 text-muted-foreground`,children:r.map(e=>e.message).join(` · `)})]})]})},e))})]})}function Re(e){let t=new Map;for(let n of e){let e=t.get(n.taskId);e?e.issues.push(n):t.set(n.taskId,{taskId:n.taskId,taskTitle:n.taskTitle,issues:[n]})}return[...t.values()]}var ze={enabled:!1,enforcement:`confirm`,shellAccess:`confirm`,allow:[]};function Be({title:e,value:t,inherited:r,onSave:i}){let[a,o]=(0,j.useState)(t??ze),[s,c]=(0,j.useState)(He(t?.allow??[])),[l,u]=(0,j.useState)(He(t?.deny??[])),[d,f]=(0,j.useState)(null);return(0,j.useEffect)(()=>{o(t??ze),c(He(t?.allow??[])),u(He(t?.deny??[])),f(null)},[t]),(0,U.jsxs)(`details`,{className:`rounded-md border border-primary/25 bg-primary/5`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-3 py-2 text-xs font-semibold`,children:[(0,U.jsx)(n,{size:14,className:`text-primary`}),(0,U.jsx)(`span`,{children:e}),(0,U.jsx)(`span`,{className:`ml-auto font-normal text-muted-foreground`,children:t?.enabled?`${t.enforcement} · ${t.allow.length} allow · shell ${t.shellAccess}`:r?.enabled?`inherits board boundary`:`unrestricted`})]}),(0,U.jsxs)(`div`,{className:`space-y-2 border-t p-3 text-xs`,children:[r?.enabled&&(0,U.jsx)(`div`,{className:`rounded border border-warning/25 bg-warning/10 px-2 py-1.5 text-muted-foreground`,children:`Board policy remains authoritative. This task policy can only narrow that scope.`}),(0,U.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`input`,{type:`checkbox`,checked:a.enabled,onChange:e=>o({...a,enabled:e.target.checked})}),`Enable this boundary layer`]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,U.jsxs)(`label`,{children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[10px] font-medium uppercase text-muted-foreground`,children:`Outside scope`}),(0,U.jsxs)(`select`,{value:a.enforcement,onChange:e=>o({...a,enforcement:e.target.value}),className:`h-8 w-full rounded border bg-background px-2`,children:[(0,U.jsx)(`option`,{value:`confirm`,children:`Ask permission`}),(0,U.jsx)(`option`,{value:`block`,children:`Always block`})]})]}),(0,U.jsxs)(`label`,{children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[10px] font-medium uppercase text-muted-foreground`,children:`Shell / opaque tools`}),(0,U.jsxs)(`select`,{value:a.shellAccess,onChange:e=>o({...a,shellAccess:e.target.value}),className:`h-8 w-full rounded border bg-background px-2`,children:[(0,U.jsx)(`option`,{value:`confirm`,children:`Ask permission`}),(0,U.jsx)(`option`,{value:`block`,children:`Always block`}),(0,U.jsx)(`option`,{value:`allow`,children:`Allow`})]})]})]}),(0,U.jsx)(Ve,{label:`Allow selectors`,value:s,onChange:c}),(0,U.jsx)(Ve,{label:`Deny selectors`,value:l,onChange:u}),(0,U.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:`One per line: kind:access:path — for example directory:read_write:packages/webui or file:read:README.md. Kinds: file, directory, package, glob. If an access type has no allow selector, it remains unrestricted except for deny rules. Shell “Allow” is opaque and can cross path selectors.`}),d&&(0,U.jsx)(`div`,{className:`text-destructive`,children:d}),(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsxs)(`button`,{type:`button`,onClick:()=>{try{let e=Ue(s),t=Ue(l);i({...a,allow:e,...t.length?{deny:t}:{}}),f(null)}catch(e){f(e instanceof Error?e.message:String(e))}},className:`inline-flex h-8 flex-1 items-center justify-center gap-2 rounded bg-primary text-primary-foreground`,children:[(0,U.jsx)(h,{size:13}),` Save boundary`]}),t&&(0,U.jsx)(`button`,{type:`button`,onClick:()=>i(null),className:`h-8 rounded border px-3 text-muted-foreground hover:bg-muted`,children:`Remove layer`})]})]})]})}function Ve({label:e,value:t,onChange:n}){return(0,U.jsxs)(`label`,{className:`block`,children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[10px] font-medium uppercase text-muted-foreground`,children:e}),(0,U.jsx)(`textarea`,{rows:3,value:t,onChange:e=>n(e.target.value),className:`w-full resize-y rounded border bg-background px-2 py-1.5 font-mono text-[11px] outline-none focus:border-primary`})]})}function He(e){return e.map(e=>`${e.kind}:${e.access}:${e.path}`).join(`
2
- `)}function Ue(e){let t=new Set([`file`,`directory`,`package`,`glob`]),n=new Set([`read`,`write`,`read_write`]);return e.split(/\r?\n/).map(e=>e.trim()).filter(Boolean).map((e,r)=>{let i=e.indexOf(`:`),a=e.indexOf(`:`,i+1);if(i<=0||a<=i+1||a===e.length-1)throw Error(`Boundary line ${r+1} must use kind:access:path.`);let o=e.slice(0,i),s=e.slice(i+1,a),c=e.slice(a+1).trim();if(!t.has(o))throw Error(`Boundary line ${r+1} has unknown kind.`);if(!n.has(s))throw Error(`Boundary line ${r+1} has unknown access.`);return{kind:o,access:s,path:c}})}function We(e,t,n,r=new Date().toISOString()){return{format:`wrongstack-kanban-task-activity`,version:1,exportedAt:r,scope:n,task:e,events:t}}function G(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function K(e){return typeof e==`string`&&e.trim()?e.trim():void 0}function q(e){return e.type.startsWith(`task.file.`)?e.type===`task.file.read`?`execution`:`changes`:e.type.startsWith(`task.activity.`)?K(G(e.after).outcome)===`failed`?`failures`:e.type===`task.activity.attempt`?`execution`:`notes`:e.type.includes(`failed`)||e.type.includes(`cancelled`)?`failures`:e.type===`task.assigned`||e.type===`task.claimed`||e.type===`task.released`||e.type.startsWith(`task.assignment.`)||e.type===`task.stale_recovered`?`execution`:e.type.includes(`note`)||e.type.includes(`check`)||e.type.includes(`metric`)?`notes`:`changes`}function Ge(e){let t=G(e.before),n=G(e.after);return[...new Set([...Object.keys(t),...Object.keys(n)])].filter(e=>JSON.stringify(t[e])!==JSON.stringify(n[e])).map(e=>({field:e,before:t[e],after:n[e]}))}function Ke(e){if(e.type.startsWith(`task.file.`))return`File ${e.type.slice(10)}`.replace(/\b\w/g,e=>e.toUpperCase());if(e.type.startsWith(`task.activity.`))return`Recorded ${e.type.slice(14)}`.replace(/\b\w/g,e=>e.toUpperCase());switch(e.type){case`task.created`:return`Task created`;case`task.copied`:return`Task copied`;case`task.updated`:return`Task contract updated`;case`task.moved`:return`Task moved`;case`task.assigned`:return`Agent assigned`;case`task.claimed`:return`Task claimed`;case`task.released`:return`Assignment released`;case`task.assignment.updated`:return`Assignment updated`;case`task.assignment.running`:return`Agent started work`;case`task.assignment.completed`:return`Agent completed work`;case`task.assignment.failed`:return`Agent run failed`;case`task.assignment.cancelled`:return`Agent run cancelled`;case`task.assignment.heartbeat`:return`Agent heartbeat`;case`task.note.added`:return`Operator note added`;case`task.check.added`:return`Acceptance check added`;case`task.check.updated`:return`Acceptance check updated`;case`task.metric.added`:return`Goal metric added`;case`task.metric.updated`:return`Goal metric updated`;case`task.lifecycle.transition`:return`Lifecycle advanced`;case`task.assignment.snapshot`:return`Current assignment observed`;case`task.stale_recovered`:return`Stale assignment recovered`;case`task.reconciled`:return`Task state reconciled`;default:return e.type.replace(/^task\./,``).replaceAll(`.`,` `).replace(/\b\w/g,e=>e.toUpperCase())}}function qe(e){let t=G(e.before),n=G(e.after);if(e.type.startsWith(`task.file.`)){let e=K(n.filePath),t=K(n.toolName),r=typeof n.durationMs==`number`?n.durationMs:void 0,i=typeof n.lines==`number`?n.lines:void 0;return[e,t?`tool:${t}`:void 0,r===void 0?void 0:`${r}ms`,i===void 0?void 0:`${i} lines`].filter(Boolean).join(` · `)||void 0}if(e.type.startsWith(`task.activity.`))return[K(n.outcome),K(n.details)].filter(Boolean).join(` · `)||void 0;if(e.type===`task.moved`){let e=K(t.columnId),r=K(n.columnId);if(e||r)return`${e??`unknown`} → ${r??`unknown`}`}if(e.type===`task.updated`){let t=Ge(e);if(t.length)return`${t.length} field${t.length===1?``:`s`} changed: ${t.map(e=>e.field).join(`, `)}`}if(e.type===`task.lifecycle.transition`){let e=K(t.stage),r=K(n.stage);if(r)return e?`${e} → ${r}`:`Entered ${r}`}if(e.type===`task.assigned`||e.type===`task.assignment.snapshot`){let e=K(n.name)??K(n.agentId)??K(n.role),t=K(n.provider),r=K(n.model);return[e,t||r?`${t?`${t}/`:``}${r??`default`}`:void 0].filter(Boolean).join(` · `)||void 0}if(e.type.startsWith(`task.check.`))return[K(n.description),K(n.status)].filter(Boolean).join(` · `)||void 0;if(e.type.startsWith(`task.metric.`))return[K(n.name),K(n.status)].filter(Boolean).join(` · `)||void 0}function Je(e){let t=e.type;return K(G(e.after).outcome)===`failed`||t.includes(`failed`)||t.includes(`cancelled`)?`bg-destructive ring-destructive/20`:t.includes(`completed`)||t.includes(`reconciled`)?`bg-success ring-success/20`:t.includes(`running`)||t.includes(`claimed`)||t.includes(`assigned`)?`bg-info ring-info/20`:t.includes(`note`)?`bg-warning ring-warning/20`:`bg-primary ring-primary/20`}function Ye(e){let t=Date.parse(e);return Number.isFinite(t)?new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`}).format(t):e}function Xe(e){if(e===void 0)return`unset`;if(e===null)return`none`;if(typeof e==`string`)return e||`empty`;if(typeof e==`number`||typeof e==`boolean`)return String(e);try{return JSON.stringify(e)}catch{return String(e)}}function Ze(e,t,n){let r=t.filter(t=>t.taskId===e.id).map(e=>({...e}));(e=>r.some(t=>t.type===e))(`task.created`)||r.push({id:`created:${e.id}`,boardId:``,taskId:e.id,type:`task.created`,ts:e.createdAt,...n?{sessionId:n}:{},after:{title:e.title,status:`created`,columnId:e.columnId}});for(let[t,i]of(e.lifecycle?.history??[]).entries())r.some(e=>e.type===`task.lifecycle.transition`&&e.ts===i.at&&e.actor===i.actor)||r.push({id:`lifecycle:${e.id}:${t}`,boardId:``,taskId:e.id,type:`task.lifecycle.transition`,ts:i.at,actor:i.actor,...n?{sessionId:n}:{},before:i.from?{stage:i.from}:void 0,after:{stage:i.to,action:i.action,attachment:i.attachment},note:i.comment});for(let t of e.notes??[])r.some(e=>e.type===`task.note.added`&&e.note===t.content&&Math.abs(Date.parse(e.ts)-Date.parse(t.createdAt))<2e3)||r.push({id:`note:${t.id}`,boardId:``,taskId:e.id,type:`task.note.added`,ts:t.createdAt,actor:t.author,...n?{sessionId:n}:{},note:t.content});let i=r.some(e=>e.type===`task.assigned`||e.type===`task.claimed`||e.type.startsWith(`task.assignment.`));return e.assignment&&!i&&r.push({id:`assignment:${e.id}`,boardId:``,taskId:e.id,type:`task.assignment.snapshot`,ts:e.assignment.completedAt??e.assignment.dispatchedAt??e.assignment.claimedAt??e.updatedAt,actor:e.assignment.agentId??e.assignment.name??e.assignment.role,...n?{sessionId:n}:{},subagentId:e.assignment.subagentId,runTaskId:e.assignment.runTaskId,after:{...e.assignment},note:e.assignment.error??e.assignment.lastResult}),r.sort((e,t)=>t.ts.localeCompare(e.ts))}function Qe({event:e}){let t=G(e.after),n=K(t.provider),r=K(t.model),i=K(t.modelRouting),a=K(t.fallbackProfile),o=Array.isArray(t.fallbackModels)?t.fallbackModels.filter(e=>typeof e==`string`):[],s=typeof t.attempt==`number`?t.attempt:void 0,c=typeof t.maxAttempts==`number`?t.maxAttempts:void 0,l=K(t.status);return!n&&!r&&!i&&!a&&!o.length&&s===void 0&&!l?null:(0,U.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap gap-1 font-mono text-[9px] text-muted-foreground`,children:[l&&(0,U.jsxs)(`span`,{className:`rounded border border-border/60 px-1.5 py-0.5`,children:[`status:`,l]}),i&&(0,U.jsxs)(`span`,{className:`rounded border border-border/60 px-1.5 py-0.5`,children:[`route:`,i]}),(n||r)&&(0,U.jsxs)(`span`,{className:`rounded border border-border/60 px-1.5 py-0.5`,children:[`model:`,n?`${n}/`:``,r??`default`]}),a&&(0,U.jsxs)(`span`,{className:`rounded border border-border/60 px-1.5 py-0.5`,children:[`profile:`,a]}),o.map((e,t)=>(0,U.jsxs)(`span`,{className:`rounded border border-border/60 px-1.5 py-0.5`,children:[`fallback-`,t+1,`:`,e]},`${e}:${t}`)),s!==void 0&&(0,U.jsxs)(`span`,{className:`rounded border border-border/60 px-1.5 py-0.5`,children:[`attempt:`,s,c?`/${c}`:``]})]})}function $e({task:e,events:t,sessionId:n,loading:r=!1,error:i,onRefresh:a}){let[s,c]=(0,j.useState)(`all`),[l,u]=(0,j.useState)(``),[p,m]=(0,j.useState)(!1),h=(0,j.useMemo)(()=>Ze(e,t,n),[e,t,n]),g=(0,j.useMemo)(()=>({all:h.length,execution:h.filter(e=>q(e)===`execution`).length,changes:h.filter(e=>q(e)===`changes`).length,notes:h.filter(e=>q(e)===`notes`).length,failures:h.filter(e=>q(e)===`failures`).length}),[h]),_=(0,j.useMemo)(()=>{let e=l.trim().toLowerCase();return h.filter(t=>s!==`all`&&q(t)!==s?!1:!e||[Ke(t),t.type,t.actor,t.sessionId,t.subagentId,t.runTaskId,t.note,JSON.stringify(t.before),JSON.stringify(t.after)].filter(Boolean).join(` `).toLowerCase().includes(e))},[h,s,l]),v=ve(_,50,`${s}:${l}`),y=v.pageItems,b=[...new Set(h.map(e=>e.actor).filter(Boolean))].length,S=[...new Set(h.map(e=>e.sessionId??n).filter(Boolean))].length;return(0,U.jsxs)(`section`,{"aria-label":`Task activity`,className:`mt-5`,children:[(0,U.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,U.jsx)(d,{className:`size-3.5 text-primary`}),(0,U.jsx)(`h3`,{className:`text-xs font-semibold uppercase text-muted-foreground`,children:`Activity ledger`}),(0,U.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-[10px] tabular-nums text-muted-foreground`,children:[_.length,`/`,h.length]}),(0,U.jsxs)(`div`,{className:`ml-auto flex items-center gap-0.5`,children:[(0,U.jsx)(`button`,{type:`button`,onClick:async()=>{try{await navigator.clipboard.writeText(JSON.stringify(We(e,_,`filtered`),null,2)),m(!0)}catch{m(!1)}},className:`flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground`,"aria-label":`Copy visible task activity JSON`,title:`Copy filtered activity JSON`,children:p?(0,U.jsx)(f,{className:`size-3 text-success`}):(0,U.jsx)(x,{className:`size-3`})}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>{let t=JSON.stringify(We(e,h,`full`),null,2),n=URL.createObjectURL(new Blob([t],{type:`application/json`})),r=document.createElement(`a`);r.href=n,r.download=`${e.title.replace(/[^a-z0-9]+/gi,`-`).replace(/^-|-$/g,``).toLowerCase()||e.id}-activity.json`,r.click(),URL.revokeObjectURL(n)},className:`flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground`,"aria-label":`Download full task activity JSON`,title:`Download full activity JSON`,children:(0,U.jsx)(o,{className:`size-3`})}),a&&(0,U.jsx)(`button`,{type:`button`,onClick:a,className:`flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground`,"aria-label":`Refresh task activity`,children:(0,U.jsx)(oe,{className:A(`size-3`,r&&`animate-spin`)})})]})]}),(0,U.jsx)(`div`,{className:`mb-2 grid grid-cols-4 gap-px overflow-hidden rounded-md border border-border/60 bg-border/60 text-center`,children:[[`Events`,h.length],[`Actors`,b],[`Sessions`,S],[`Failures`,g.failures]].map(([e,t])=>(0,U.jsxs)(`div`,{className:`bg-background/90 px-1 py-1.5`,children:[(0,U.jsx)(`div`,{className:`text-xs font-semibold tabular-nums`,children:t}),(0,U.jsx)(`div`,{className:`text-[8px] uppercase text-muted-foreground`,children:e})]},String(e)))}),(0,U.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-1`,children:[`all`,`execution`,`changes`,`notes`,`failures`].map(e=>(0,U.jsxs)(`button`,{type:`button`,onClick:()=>c(e),className:A(`rounded border px-1.5 py-1 text-[9px] capitalize`,s===e?`border-primary/50 bg-primary/10 text-primary`:`border-border text-muted-foreground hover:text-foreground`),children:[e,` `,g[e]]},e))}),(0,U.jsxs)(`div`,{className:`relative mb-3`,children:[(0,U.jsx)(O,{className:`pointer-events-none absolute left-2 top-1/2 size-3 -translate-y-1/2 text-muted-foreground`}),(0,U.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),"aria-label":`Search task activity`,placeholder:`Search agent, session, model, result, field…`,className:`h-8 w-full rounded-md border bg-background pl-7 pr-7 text-[11px] outline-none focus:border-primary`}),l&&(0,U.jsx)(`button`,{type:`button`,onClick:()=>u(``),"aria-label":`Clear task activity search`,className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,children:(0,U.jsx)(ae,{className:`size-3`})})]}),i&&(0,U.jsx)(`div`,{className:`mb-2 rounded-md border border-destructive/30 bg-destructive/5 px-2.5 py-2 text-[11px] text-destructive`,children:i}),_.length===0?(0,U.jsx)(`div`,{className:`rounded-md border border-dashed px-3 py-6 text-center text-[11px] text-muted-foreground`,children:`No activity matches this filter.`}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`ol`,{className:`relative ml-1.5 space-y-0 border-l border-border/70`,children:y.map(e=>{let t=qe(e),r=e.sessionId??n,i=Ge(e),a=q(e)===`failures`,o=e.type.includes(`completed`)||K(G(e.after).outcome)===`succeeded`;return(0,U.jsxs)(`li`,{className:`relative pb-4 pl-4 last:pb-0`,children:[(0,U.jsx)(`span`,{className:A(`absolute -left-[5px] top-1.5 size-2 rounded-full ring-4`,Je(e))}),(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`p`,{className:`text-xs font-medium leading-5`,children:Ke(e)}),(0,U.jsx)(`code`,{className:`block truncate text-[8px] text-muted-foreground/70`,title:e.type,children:e.type})]}),(0,U.jsx)(`time`,{dateTime:e.ts,title:new Date(e.ts).toLocaleString(),className:`shrink-0 text-[9px] text-muted-foreground`,children:Ye(e.ts)})]}),t&&(0,U.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap text-[11px] leading-4 text-muted-foreground`,children:t}),e.note&&(0,U.jsxs)(`div`,{className:A(`mt-1.5 max-h-32 overflow-y-auto whitespace-pre-wrap rounded border px-2 py-1.5 text-[10px] leading-4`,a?`border-destructive/30 bg-destructive/5 text-destructive`:o?`border-success/30 bg-success/5 text-success`:`border-border/70 bg-muted/35 text-foreground`),children:[(0,U.jsxs)(`strong`,{children:[a?`Error`:o?`Result`:`Reason / result`,`:`]}),` `,e.note]}),i.length>0&&e.type!==`task.assigned`&&e.type!==`task.assignment.snapshot`&&!e.type.startsWith(`task.file.`)&&(0,U.jsx)(`div`,{className:`mt-1.5 space-y-1 rounded border border-border/60 bg-background/50 p-1.5`,children:i.map(e=>(0,U.jsxs)(`div`,{className:`grid grid-cols-[5rem_minmax(0,1fr)] gap-1.5 text-[9px] leading-4`,children:[(0,U.jsx)(`code`,{className:`truncate text-primary`,title:e.field,children:e.field}),(0,U.jsxs)(`span`,{className:`min-w-0 break-all text-muted-foreground`,children:[(0,U.jsx)(`span`,{className:`line-through opacity-70`,children:Xe(e.before)}),` `,(0,U.jsx)(`span`,{"aria-hidden":!0,children:`→`}),` `,(0,U.jsx)(`span`,{className:`text-foreground`,children:Xe(e.after)})]})]},e.field))}),(0,U.jsx)(Qe,{event:e}),(e.actor||r||e.subagentId||e.runTaskId||e.correlationId)&&(0,U.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap gap-1 font-mono text-[9px] text-muted-foreground`,children:[e.actor&&(0,U.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5`,children:[`agent:`,e.actor]}),r&&(0,U.jsxs)(`span`,{className:`max-w-52 truncate rounded bg-muted px-1.5 py-0.5`,title:r,children:[`session:`,r]}),e.subagentId&&(0,U.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5`,children:[`subagent:`,e.subagentId]}),e.runTaskId&&(0,U.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5`,children:[`run:`,e.runTaskId]}),e.correlationId&&(0,U.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5`,children:[`trace:`,e.correlationId]})]}),(0,U.jsxs)(`details`,{className:`mt-1.5 text-[9px] text-muted-foreground`,children:[(0,U.jsx)(`summary`,{className:`cursor-pointer hover:text-foreground`,children:`Full event payload`}),(0,U.jsx)(`pre`,{className:`mt-1 max-h-64 overflow-auto rounded border bg-muted/30 p-2 text-[9px] leading-4 text-foreground`,children:JSON.stringify(e,null,2)})]})]},e.id)})}),(0,U.jsx)(ye,{page:v.page,pageSize:v.pageSize,totalItems:v.totalItems,onPageChange:v.setPage,className:`mt-3`,itemLabel:`activity events`})]})]})}function et(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function J(e){return typeof e==`string`&&e.trim()?e.trim():void 0}function tt(e){return e.type===`task.assigned`||e.type===`task.claimed`||e.type===`task.released`||e.type===`task.assignment.snapshot`||e.type===`task.stale_recovered`||e.type.startsWith(`task.assignment.`)}function nt(e,t){return J(t.status)||(e.type===`task.claimed`?`claimed`:e.type===`task.released`?`released`:e.type===`task.stale_recovered`?`recovered`:e.type.split(`.`).at(-1)??`unknown`)}function rt(e){return[`completed`,`failed`,`cancelled`,`released`,`recovered`].includes(e)}function it(e,t){if(!t)return;let n=Date.parse(e),r=Date.parse(t);return Number.isFinite(n)&&Number.isFinite(r)?Math.max(0,r-n):void 0}function at(e,t,n){let r=Ze(e,t,n).filter(tt).sort((e,t)=>e.ts.localeCompare(t.ts)),i=new Map,a=0,o=0,s=!1;for(let e of r){let t=et(e.after),r=Number(t.attempt),c=e.type===`task.assigned`||e.type===`task.claimed`;Number.isFinite(r)&&r>0?a=Math.trunc(r):c&&(a===0||s)?a=o+1:a===0&&(a=1),o=Math.max(o,a);let l=nt(e,t),u=i.get(a)??{attempt:a,status:l,startedAt:e.ts,fallbackModels:[],sessionIds:new Set,eventCount:0};u.status=l,u.eventCount+=1,(e.sessionId??n)&&u.sessionIds.add(e.sessionId??n),u.owner=J(t.name)??J(t.agentId)??J(t.role)??e.actor??u.owner,u.provider=J(t.provider)??u.provider,u.model=J(t.model)??u.model,u.routingMode=J(t.modelRouting)??u.routingMode,u.fallbackProfile=J(t.fallbackProfile)??u.fallbackProfile,Array.isArray(t.fallbackModels)&&(u.fallbackModels=t.fallbackModels.filter(e=>typeof e==`string`)),u.subagentId=e.subagentId??J(t.subagentId)??u.subagentId,u.runTaskId=e.runTaskId??J(t.runTaskId)??u.runTaskId,l===`running`&&!u.runningAt&&(u.runningAt=e.ts),l===`completed`&&(u.result=J(t.lastResult)??e.note??u.result),(l===`failed`||l===`cancelled`)&&(u.error=J(t.error)??e.note??u.error),rt(l)&&(u.endedAt=e.ts),i.set(a,u),s=rt(l)}return[...i.values()].map(e=>({...e,sessionIds:[...e.sessionIds],durationMs:it(e.startedAt,e.endedAt)})).sort((e,t)=>t.attempt-e.attempt)}function ot(e){if(e===void 0)return`running`;if(e<1e3)return`${e}ms`;let t=Math.round(e/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function st(e){return e===`completed`?`bg-success/10 text-success`:e===`failed`||e===`cancelled`?`bg-destructive/10 text-destructive`:e===`running`?`bg-info/10 text-info`:`bg-muted text-muted-foreground`}function ct({task:e,events:t,sessionId:n}){let r=at(e,t,n),i=ve(r,8,e.id);return r.length?(0,U.jsxs)(`details`,{open:!0,className:`mt-3 rounded-md border border-border/70 bg-muted/15`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-3 py-2.5 [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(ie,{className:`size-4 text-primary`}),(0,U.jsx)(`span`,{className:`text-xs font-semibold`,children:`Execution attempts`}),(0,U.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-[9px] text-muted-foreground`,children:[r.length,` total`]}),(0,U.jsxs)(`span`,{className:`rounded px-1.5 py-0.5 text-[9px] ${st(r[0].status)}`,children:[`latest:`,r[0].status]}),(0,U.jsx)(k,{className:`ml-auto size-3.5 text-muted-foreground`})]}),(0,U.jsxs)(`div`,{className:`space-y-2 border-t border-border/60 p-2.5`,children:[i.pageItems.map(e=>(0,U.jsxs)(`section`,{className:`rounded-md border bg-background/70 p-2.5`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 text-[10px]`,children:[(0,U.jsxs)(`strong`,{className:`text-xs`,children:[`Attempt #`,e.attempt]}),(0,U.jsx)(`span`,{className:`rounded px-1.5 py-0.5 ${st(e.status)}`,children:e.status}),(0,U.jsxs)(`span`,{className:`ml-auto inline-flex items-center gap-1 text-muted-foreground`,children:[(0,U.jsx)(ue,{className:`size-3`}),` `,ot(e.durationMs),` · `,e.eventCount,` `,`events`]})]}),(0,U.jsxs)(`div`,{className:`mt-2 grid gap-1 text-[10px] text-muted-foreground sm:grid-cols-2`,children:[(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,U.jsx)(l,{className:`size-3`}),` `,e.owner??`Unknown agent`]}),(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-mono`,children:[(0,U.jsx)(g,{className:`size-3`}),e.provider||e.model?`${e.provider?`${e.provider}/`:``}${e.model??`default`}`:e.routingMode??`default route`]}),(0,U.jsxs)(`span`,{className:`font-mono`,children:[`session:`,e.sessionIds.join(`, `)||`unknown`]}),(0,U.jsxs)(`span`,{className:`font-mono`,children:[`subagent:`,e.subagentId??`—`,` · run:`,e.runTaskId??`—`]})]}),(e.fallbackProfile||e.fallbackModels.length>0)&&(0,U.jsxs)(`p`,{className:`mt-1.5 break-all font-mono text-[9px] text-muted-foreground`,children:[`fallback:`,[e.fallbackProfile?`profile:${e.fallbackProfile}`:``,...e.fallbackModels].filter(Boolean).join(` → `)]}),e.error&&(0,U.jsxs)(`p`,{className:`mt-2 whitespace-pre-wrap rounded border border-destructive/30 bg-destructive/5 px-2 py-1.5 text-[10px] text-destructive`,children:[(0,U.jsx)(`strong`,{children:`Error:`}),` `,e.error]}),e.result&&(0,U.jsxs)(`p`,{className:`mt-2 max-h-32 overflow-y-auto whitespace-pre-wrap rounded border border-success/30 bg-success/5 px-2 py-1.5 text-[10px] text-success`,children:[(0,U.jsx)(`strong`,{children:`Result:`}),` `,e.result]})]},e.attempt)),(0,U.jsx)(ye,{page:i.page,pageSize:i.pageSize,totalItems:i.totalItems,onPageChange:i.setPage,compact:!0,itemLabel:`execution attempts`})]})]}):null}function lt(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function Y(e){return H(e)}function ut(e,t){return(t??[]).map(t=>{let n=e.tasks.find(e=>e.id===t);return{id:t,title:n?.title??t,status:n?.status??`missing`}})}function dt(e,t,n,r,i,a,o){let s=Ze(t,n,r),c=ut(e,t.dependsOn),l=c.filter(e=>![`completed`,`archived`].includes(e.status)),u=t.assignment,d=(o??e.presence??[]).filter(e=>e.taskId===t.id),f=lt(s.find(e=>e.type===`task.assigned`||e.type===`task.claimed`||e.type.startsWith(`task.assignment.`))?.after),p=Y(u?.modelRouting)??Y(f.modelRouting)??`session`,m=Y(u?.provider)??Y(f.provider)??(p===`session`?Y(i):void 0),h=Y(u?.model)??Y(f.model)??(p===`session`?Y(a):void 0),g=(Array.isArray(u?.fallbackModels)?u.fallbackModels:Array.isArray(f.fallbackModels)?f.fallbackModels:[]).map(Y).filter(e=>e!==void 0),_=Y(u?.fallbackProfile)??Y(f.fallbackProfile),v=Y(u?.name)??Y(u?.agentId)??Y(u?.role)??Y(t.assignee)??Y(t.assignedAgent)??`Unassigned`,y=t.lifecycle?.history.at(-1),b=s.find(e=>e.note&&e.type!==`task.note.added`)?.note,x=`Placed in ${e.columns.find(e=>e.id===t.columnId)?.title??t.columnId}.`;u?.error?x=`Agent run failed: ${u.error}`:l.length?x=`Blocked by ${l.map(e=>e.title).join(`, `)}.`:y?.comment?x=y.comment:b?x=b:t.status===`review`?x=`Implementation is waiting for review evidence or approval.`:t.status===`in_progress`?x=`${v} is currently working on this task.`:t.status===`completed`&&(x=`The task and its current assignment are complete.`);let S=s.map(e=>Number(lt(e.after).attempt)).filter(e=>Number.isFinite(e)),ee=s.filter(e=>e.type===`task.claimed`||e.type===`task.assigned`).length,C=s.find(e=>q(e)===`failures`),te=s.find(e=>e.type.includes(`completed`));return{column:e.columns.find(e=>e.id===t.columnId)?.title??t.columnId,reason:x,owner:v,routingMode:p,provider:m,model:h,primaryModel:m||h?`${m?`${m}/`:``}${h??`default`}`:`Session default`,fallbackRoute:[_?`profile:${_}`:``,...g].filter(Boolean).join(` → `)||`None configured`,blockers:l,dependencies:c,actors:[...new Set([...s.map(e=>e.actor).filter(e=>!!e),...d.map(e=>e.agentId)])],sessions:[...new Set([...s.map(e=>e.sessionId??r),...d.map(e=>e.sessionId)].filter(e=>!!e))],presence:d.map(e=>`${e.agentName??e.agentId} · ${e.active?`active`:`last seen ${X(e.lastSeenAt)}`}`),activePresence:d.filter(e=>e.active).length,attempts:Math.max(u?.attempt??0,...S,ee),failures:s.filter(e=>e.type.includes(`failed`)).length,completions:s.filter(e=>e.type.includes(`completed`)).length,lastFailure:u?.lastFailureKind??u?.error??C?.note,lastResult:u?.lastResult??te?.note,eventCount:s.length,lastActivity:s[0]}}function X(e){if(!e)return`—`;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function ft(e,t){if(!e)return`—`;let n=Date.parse(e),r=t?Date.parse(t):Date.now();if(!Number.isFinite(n)||!Number.isFinite(r))return`—`;let i=Math.max(0,Math.round((r-n)/6e4));return i<1?`<1m`:i<60?`${i}m`:`${Math.floor(i/60)}h ${i%60}m`}function Z({label:e,value:t,mono:n=!1}){return(0,U.jsxs)(`div`,{className:`grid grid-cols-[7rem_minmax(0,1fr)] gap-2 py-1 text-[11px]`,children:[(0,U.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,U.jsx)(`dd`,{className:n?`break-all font-mono text-[10px]`:`min-w-0 break-words`,children:t})]})}function pt({icon:e,title:t,children:n}){return(0,U.jsxs)(`section`,{className:`rounded-md border border-border/70 bg-background/55 p-2.5`,children:[(0,U.jsxs)(`h4`,{className:`mb-1.5 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[e,t]}),(0,U.jsx)(`dl`,{className:`divide-y divide-border/35`,children:n})]})}function mt({items:e}){return e.length?(0,U.jsx)(`span`,{className:`space-y-1`,children:e.map(e=>(0,U.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsx)(`span`,{className:`truncate`,title:e.title,children:e.title}),(0,U.jsx)(`span`,{className:`shrink-0 rounded bg-muted px-1 py-0.5 text-[9px]`,children:e.status})]},e.id))}):(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:`None`})}function ht({board:e,task:t,events:r,presence:i,sessionId:a,sessionProvider:o,sessionModel:s}){let c=dt(e,t,r,a,o,s,i),u=t.assignment,f=t.successCriteria?.length??0,p=t.successCriteria?.filter(e=>e.status===`passed`).length??0,m=[t.parentTaskId,...t.childTaskIds??[],t.chain?.previousTaskId,t.chain?.nextTaskId,t.mergedIntoTaskId,...t.mergedFromTaskIds??[]].filter(e=>!!e),h=ut(e,[...new Set(m)]);return(0,U.jsxs)(`details`,{open:!0,className:`mt-3 rounded-md border border-primary/25 bg-primary/[0.025]`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-3 py-2.5 [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(C,{className:`size-4 text-primary`}),(0,U.jsx)(`span`,{className:`text-xs font-semibold`,children:`Task intelligence`}),(0,U.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-[9px] uppercase text-muted-foreground`,children:t.status}),(0,U.jsxs)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:[c.eventCount,` events`]}),(0,U.jsx)(k,{className:`size-3.5 text-muted-foreground`})]}),(0,U.jsxs)(`div`,{className:`space-y-2.5 border-t border-border/60 p-2.5`,children:[(0,U.jsxs)(`section`,{className:`rounded-md border border-info/25 bg-info/5 p-2.5`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 text-[10px]`,children:[(0,U.jsx)(`span`,{className:`rounded bg-info/10 px-1.5 py-0.5 font-semibold text-info`,children:c.column}),(0,U.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5`,children:[`stage:`,t.lifecycle?.currentStage??`legacy`]}),(0,U.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5`,children:[`priority:`,t.priority]}),(0,U.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5`,children:[`type:`,t.type??`inferred`]})]}),(0,U.jsxs)(`p`,{className:`mt-2 text-[11px] leading-4`,children:[(0,U.jsx)(`strong`,{children:`Why here:`}),` `,c.reason]}),c.blockers.length>0&&(0,U.jsxs)(`p`,{className:`mt-1 text-[10px] text-warning`,children:[c.blockers.length,` unresolved blocker`,c.blockers.length===1?``:`s`]})]}),(0,U.jsxs)(`div`,{className:`grid gap-2 xl:grid-cols-2`,children:[(0,U.jsxs)(pt,{icon:(0,U.jsx)(l,{className:`size-3`}),title:`Ownership & runtime`,children:[(0,U.jsx)(Z,{label:`Owner`,value:c.owner}),(0,U.jsx)(Z,{label:`Assignee`,value:Y(t.assignee)??Y(t.assignedAgent)??`—`}),(0,U.jsx)(Z,{label:`Agent ID`,value:Y(u?.agentId)??`—`,mono:!0}),(0,U.jsx)(Z,{label:`Agent name / role`,value:[Y(u?.name),Y(u?.role)].filter(Boolean).join(` · `)||`—`}),(0,U.jsx)(Z,{label:`Run status`,value:Y(u?.status)??`unassigned`}),(0,U.jsx)(Z,{label:`Subagent`,value:Y(u?.subagentId)??`—`,mono:!0}),(0,U.jsx)(Z,{label:`Run task`,value:Y(u?.runTaskId)??`—`,mono:!0}),(0,U.jsx)(Z,{label:`Session(s)`,value:c.sessions.join(`, `)||`Unknown`,mono:!0}),(0,U.jsx)(Z,{label:`Users / presence`,value:c.presence.length?c.presence.join(`, `):`No task-scoped presence recorded`})]}),(0,U.jsxs)(pt,{icon:(0,U.jsx)(g,{className:`size-3`}),title:`Model route & fallback`,children:[(0,U.jsx)(Z,{label:`Routing mode`,value:c.routingMode}),(0,U.jsx)(Z,{label:`Primary`,value:c.primaryModel,mono:!0}),(0,U.jsx)(Z,{label:`Provider`,value:c.provider??`—`,mono:!0}),(0,U.jsx)(Z,{label:`Model`,value:c.model??`—`,mono:!0}),(0,U.jsx)(Z,{label:`Fallback route`,value:c.fallbackRoute,mono:!0}),(0,U.jsx)(Z,{label:`Skills`,value:u?.skills?.map(Y).filter(Boolean).join(`, `)||`Default`}),(0,U.jsx)(Z,{label:`Tools`,value:u?.tools?.map(Y).filter(Boolean).join(`, `)||`Default toolset`}),(0,U.jsx)(Z,{label:`Capabilities`,value:u?.allowedCapabilities?.map(Y).filter(Boolean).join(`, `)||`Safe defaults`,mono:!0})]}),(0,U.jsxs)(pt,{icon:(0,U.jsx)(n,{className:`size-3`}),title:`Execution policy & outcome`,children:[(0,U.jsx)(Z,{label:`Attempts`,value:`${c.attempts}${u?.maxAttempts?` / ${u.maxAttempts}`:``}`}),(0,U.jsx)(Z,{label:`Retry policy`,value:u?.retryPolicy??t.retryPolicy??`off`}),(0,U.jsx)(Z,{label:`Cost ceiling`,value:(u?.costCeilingUsd??t.costCeilingUsd)==null?`Unbounded`:`$${(u?.costCeilingUsd??t.costCeilingUsd).toFixed(2)}`}),(0,U.jsx)(Z,{label:`Failures / done`,value:`${c.failures} / ${c.completions}`}),(0,U.jsx)(Z,{label:`Checks`,value:`${p} / ${f} passed`}),(0,U.jsx)(Z,{label:`Last failure`,value:c.lastFailure??`—`}),(0,U.jsx)(Z,{label:`Result`,value:c.lastResult??`No result recorded`})]}),(0,U.jsxs)(pt,{icon:(0,U.jsx)(d,{className:`size-3`}),title:`Timing & audit coverage`,children:[(0,U.jsx)(Z,{label:`Created`,value:X(t.createdAt)}),(0,U.jsx)(Z,{label:`Updated`,value:X(t.updatedAt)}),(0,U.jsx)(Z,{label:`Due`,value:X(t.dueDate)}),(0,U.jsx)(Z,{label:`Dispatched`,value:X(u?.dispatchedAt??u?.claimedAt)}),(0,U.jsx)(Z,{label:`Completed`,value:X(u?.completedAt??t.completedAt)}),(0,U.jsx)(Z,{label:`Duration`,value:ft(u?.dispatchedAt??u?.claimedAt,u?.completedAt)}),(0,U.jsx)(Z,{label:`Heartbeat`,value:X(u?.heartbeatAt)}),(0,U.jsx)(Z,{label:`Lease expires`,value:X(u?.leaseExpiresAt)}),(0,U.jsx)(Z,{label:`Actors`,value:c.actors.join(`, `)||`Unknown`,mono:!0})]})]}),(0,U.jsxs)(pt,{icon:(0,U.jsx)(D,{className:`size-3`}),title:`Dependencies, chain & provenance`,children:[(0,U.jsx)(Z,{label:`Dependencies`,value:(0,U.jsx)(mt,{items:c.dependencies})}),(0,U.jsx)(Z,{label:`Other relations`,value:(0,U.jsx)(mt,{items:h})}),(0,U.jsx)(Z,{label:`Chain`,value:t.chain?`${t.chain.chainId} · position ${t.chain.order}`:`None`,mono:!0}),(0,U.jsx)(Z,{label:`Origin system`,value:t.origin?.system??`manual`}),(0,U.jsx)(Z,{label:`Origin IDs`,value:t.origin&&[t.origin.graphId,t.origin.phaseId,t.origin.taskId,t.origin.specId].filter(Boolean).join(` · `)||`—`,mono:!0}),(0,U.jsx)(Z,{label:`Task ID`,value:t.id,mono:!0}),(0,U.jsx)(Z,{label:`Board ID`,value:e.id,mono:!0})]})]})]})}function gt(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function _t(e){return e===`completed`||e===`failed`||e===`cancelled`}function vt(e,t){return t?Math.round(e/t*100):0}function yt(e,t,n,r=new Date){let i=[],a=n.filter(e=>e.taskId===t.id),o=a.filter(e=>e.type!==`task.created`),s=o.filter(e=>e.type!==`task.assignment.heartbeat`&&e.type!==`task.assignment.snapshot`),c=s.filter(e=>!!e.note?.trim()),l=t.assignment,u=r.getTime(),d=100,f=(e,t=0)=>{i.some(t=>t.id===e.id)||(i.push(e),d=Math.max(0,d-t))};t.dueDate&&![`completed`,`archived`].includes(t.status)&&Date.parse(t.dueDate)<u&&f({id:`overdue`,severity:`critical`,category:`operational`,title:`Task is overdue`,detail:`Due date ${t.dueDate} has passed while status is ${t.status}.`,remediation:`Re-plan the due date or record the blocker and owner response.`});let p=(t.dependsOn??[]).filter(t=>!e.tasks.some(e=>e.id===t));p.length&&f({id:`missing-dependency`,severity:`critical`,category:`operational`,title:`Dependency references are broken`,detail:`${p.length} dependency task${p.length===1?``:`s`} cannot be found.`,remediation:`Repair or remove the missing dependency IDs before dispatch.`});let m=(t.dependsOn??[]).filter(t=>{let n=e.tasks.find(e=>e.id===t);return n&&![`completed`,`archived`].includes(n.status)});m.length&&f({id:`unresolved-dependency`,severity:`warning`,category:`operational`,title:`Dependencies are unresolved`,detail:`${m.length} dependency task${m.length===1?``:`s`} still block execution.`,remediation:`Complete dependencies or explicitly waive them with a decision event.`}),(l?.status===`failed`||l?.error)&&f({id:`assignment-failed`,severity:`critical`,category:`operational`,title:`Latest agent run failed`,detail:l.error??l.lastFailureKind??`Assignment status is failed.`,remediation:`Review the failed attempt evidence, adjust routing, then retry or block the task.`}),l?.status===`failed`&&l.maxAttempts!==void 0&&(l.attempt??0)>=l.maxAttempts&&f({id:`retry-exhausted`,severity:`critical`,category:`operational`,title:`Retry budget is exhausted`,detail:`${l.attempt??0}/${l.maxAttempts} attempts have been consumed.`,remediation:`Escalate for a new route or explicitly increase the attempt budget.`}),l&&[`queued`,`running`].includes(l.status)&&l.leaseExpiresAt&&Date.parse(l.leaseExpiresAt)<=u&&f({id:`lease-expired`,severity:`critical`,category:`operational`,title:`Assignment lease has expired`,detail:`Lease expired at ${l.leaseExpiresAt} while run status is ${l.status}.`,remediation:`Recover, release, or retry the stale assignment.`}),l?.status===`running`&&l.heartbeatAt&&u-Date.parse(l.heartbeatAt)>5*6e4&&f({id:`heartbeat-stale`,severity:`warning`,category:`operational`,title:`Agent heartbeat is stale`,detail:`No heartbeat has been recorded since ${l.heartbeatAt}.`,remediation:`Inspect the subagent/run and recover the assignment if it is no longer alive.`}),t.status===`in_progress`&&!l&&f({id:`unowned-in-progress`,severity:`warning`,category:`operational`,title:`In-progress task has no assignment`,detail:`The task claims active work but has no inspectable agent assignment.`,remediation:`Assign an agent or return the task to ready/blocked.`});let h=(t.successCriteria??[]).filter(e=>e.status===`failed`),g=(t.successCriteria??[]).filter(e=>e.status===`pending`);h.length&&f({id:`failed-checks`,severity:t.status===`completed`?`critical`:`warning`,category:`operational`,title:`Acceptance checks failed`,detail:`${h.length} completion check${h.length===1?``:`s`} failed.`,remediation:`Resolve or explicitly waive failed acceptance evidence.`}),t.status===`completed`&&g.length&&f({id:`completed-with-pending-checks`,severity:`critical`,category:`operational`,title:`Completed task still has pending checks`,detail:`${g.length} acceptance check${g.length===1?``:`s`} remain pending.`,remediation:`Move the task back to review or complete the missing checks.`}),a.length?a.some(e=>e.type===`task.created`)||f({id:`missing-creation-event`,severity:`warning`,category:`audit`,title:`Creation provenance is missing`,detail:`The loaded event range does not contain task.created.`,remediation:`Load deeper history or record the legacy origin explicitly.`},10):f({id:`no-durable-events`,severity:`critical`,category:`audit`,title:`No durable activity events loaded`,detail:`Current state cannot be traced to an append-only task event.`,remediation:`Refresh activity; migrate legacy state or record an observation event.`},25);let _=vt(o.filter(e=>!!e.actor).length,o.length),v=vt(o.filter(e=>!!e.sessionId).length,o.length),y=vt(c.length,s.length);o.length&&_<100&&f({id:`actor-coverage`,severity:`warning`,category:`audit`,title:`Some mutations have no actor`,detail:`Actor coverage is ${_}%.`,remediation:`Ensure every route/tool mutation supplies agent or operator identity.`},10),o.length&&v<100&&f({id:`session-coverage`,severity:`warning`,category:`audit`,title:`Some mutations have no session`,detail:`Session coverage is ${v}%.`,remediation:`Propagate session identity into all task event contexts.`},10),s.length&&y<50&&f({id:`reason-coverage`,severity:`info`,category:`audit`,title:`Decision rationale is sparse`,detail:`Only ${y}% of mutations include a reason or outcome.`,remediation:`Use the change-reason and decision/outcome fields for meaningful mutations.`},10);let b={...gt([...a].sort((e,t)=>t.ts.localeCompare(e.ts)).find(e=>e.type===`task.assigned`||e.type.startsWith(`task.assignment.`))?.after),...l??{}},x=!!(b.provider||b.model||b.modelRouting);l&&!x&&f({id:`missing-route`,severity:`warning`,category:`audit`,title:`Execution route is not inspectable`,detail:`Assignment has no routing mode, provider, or model.`,remediation:`Reassign with explicit session/fixed/fallback routing metadata.`},10);let S=!!(l?.lastResult||l?.error||a.some(e=>_t(String(gt(e.after).status??``))&&!!e.note?.trim()));return _t(l?.status)&&!S&&f({id:`missing-terminal-evidence`,severity:`critical`,category:`audit`,title:`Terminal run has no result or error evidence`,detail:`Assignment ended as ${l?.status} without an inspectable output.`,remediation:`Record the final result/error and supporting evidence.`},15),i.sort((e,t)=>{let n={critical:0,warning:1,info:2};return n[e.severity]-n[t.severity]}),{score:d,findings:i,critical:i.filter(e=>e.severity===`critical`).length,warnings:i.filter(e=>e.severity===`warning`).length,coverage:{durableEvents:a.length,actorPercent:_,sessionPercent:v,reasonPercent:y,hasExecutionRoute:x,hasTerminalEvidence:S}}}function bt(e){return e===`critical`?`border-destructive/30 bg-destructive/5 text-destructive`:e===`warning`?`border-warning/30 bg-warning/5 text-warning`:`border-info/30 bg-info/5 text-info`}function xt({board:e,task:t,events:n}){let r=yt(e,t,n),i=ve(r.findings,8,t.id);return(0,U.jsxs)(`details`,{open:!0,className:`mt-3 rounded-md border border-border/70 bg-muted/10`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-3 py-2.5 [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(p,{className:`size-4 text-primary`}),(0,U.jsx)(`span`,{className:`text-xs font-semibold`,children:`Risk & audit quality`}),(0,U.jsxs)(`span`,{className:`rounded px-1.5 py-0.5 text-[9px] ${r.score>=90?`bg-success/10 text-success`:r.score>=70?`bg-warning/10 text-warning`:`bg-destructive/10 text-destructive`}`,children:[`audit `,r.score,`/100`]}),r.critical>0&&(0,U.jsxs)(`span`,{className:`rounded bg-destructive/10 px-1.5 py-0.5 text-[9px] text-destructive`,children:[r.critical,` critical`]}),(0,U.jsx)(k,{className:`ml-auto size-3.5 text-muted-foreground`})]}),(0,U.jsxs)(`div`,{className:`space-y-2 border-t border-border/60 p-2.5`,children:[(0,U.jsx)(`div`,{className:`grid grid-cols-3 gap-1 text-center sm:grid-cols-6`,children:[[`Events`,r.coverage.durableEvents],[`Actor`,`${r.coverage.actorPercent}%`],[`Session`,`${r.coverage.sessionPercent}%`],[`Reasons`,`${r.coverage.reasonPercent}%`],[`Route`,r.coverage.hasExecutionRoute?`yes`:`no`],[`Outcome`,r.coverage.hasTerminalEvidence?`yes`:`no`]].map(([e,t])=>(0,U.jsxs)(`div`,{className:`rounded border bg-background/70 px-1 py-1.5`,children:[(0,U.jsx)(`div`,{className:`text-[11px] font-semibold`,children:t}),(0,U.jsx)(`div`,{className:`text-[8px] uppercase text-muted-foreground`,children:e})]},String(e)))}),r.findings.length===0?(0,U.jsxs)(`div`,{className:`flex items-center gap-2 rounded border border-success/30 bg-success/5 px-2.5 py-2 text-[11px] text-success`,children:[(0,U.jsx)(_,{className:`size-4`}),` No deterministic task risks detected.`]}):(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[i.pageItems.map(e=>(0,U.jsxs)(`section`,{className:`rounded border px-2.5 py-2 ${bt(e.severity)}`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] font-semibold`,children:[e.category===`audit`?(0,U.jsx)(m,{className:`size-3.5`}):(0,U.jsx)(v,{className:`size-3.5`}),e.title,(0,U.jsxs)(`span`,{className:`ml-auto text-[8px] uppercase opacity-75`,children:[e.category,` · `,e.severity]})]}),(0,U.jsx)(`p`,{className:`mt-1 text-[10px] leading-4 opacity-90`,children:e.detail}),(0,U.jsxs)(`p`,{className:`mt-1 text-[9px] leading-4 opacity-75`,children:[(0,U.jsx)(`strong`,{children:`Next:`}),` `,e.remediation]})]},e.id)),(0,U.jsx)(ye,{page:i.page,pageSize:i.pageSize,totalItems:i.totalItems,onPageChange:i.setPage,compact:!0,itemLabel:`risk findings`})]})]})]})}var St=5e3,Ct=12;function wt(e){let t=Math.max(0,Date.now()-Date.parse(e));return t<6e4?`just now`:t<36e5?`${Math.floor(t/6e4)}m ago`:`${Math.floor(t/36e5)}h ago`}function Tt({presence:e=[]}){return e.length===0?null:(0,U.jsxs)(`section`,{"aria-label":`Board presence`,className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-border bg-card/50 px-4 py-2`,children:[(0,U.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:`Live board users`}),e.map(e=>(0,U.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5 rounded-full border border-border bg-background px-2.5 py-1 text-xs shadow-sm`,title:`Session ${e.sessionId} · last seen ${e.lastSeenAt}`,children:[(0,U.jsx)(`span`,{role:`img`,"aria-label":e.active?`active`:`inactive`,className:A(`h-2 w-2 shrink-0 rounded-full`,e.active?`bg-success`:`bg-muted-foreground/50`)}),(0,U.jsx)(b,{size:13,"aria-hidden":`true`}),(0,U.jsx)(`span`,{className:`max-w-32 truncate font-medium`,children:e.agentName??e.agentId}),(0,U.jsx)(`span`,{className:`max-w-32 truncate text-muted-foreground`,children:e.sessionId}),(0,U.jsx)(re,{size:12,className:`text-muted-foreground`,"aria-hidden":`true`}),(0,U.jsx)(`time`,{dateTime:e.lastSeenAt,className:`tabular-nums text-muted-foreground`,children:wt(e.lastSeenAt)})]},e.id))]})}function Et({board:e,snapshot:t,sendKanban:r}){let[i,a]=(0,j.useState)(!1),[o,s]=(0,j.useState)(!0),[c,l]=(0,j.useState)(`deterministic`),[u,f]=(0,j.useState)(`session`),[p,m]=(0,j.useState)(``),[g,_]=(0,j.useState)(``),[v,y]=(0,j.useState)(``),[b,x]=(0,j.useState)([]),[S,ee]=(0,j.useState)([]),[C,te]=(0,j.useState)(10),w=ge(i&&c===`agentic`),T=xe(i&&c===`agentic`);(0,j.useEffect)(()=>{let t=e.supervisor;s(t?.enabled??!0),l(t?.mode??`deterministic`),f(t?.routing?.mode??`session`),m(t?.routing?.provider??``),_(t?.routing?.model??``),y(t?.routing?.fallbackProfile??``),x(t?.routing?.fallbackModels??[]),ee(t?.skills??[]),te(Math.max(2,Math.round((t?.intervalMs??1e4)/1e3)))},[e.id,e.supervisor]);let ne=()=>{let t={mode:u,...u===`fixed`&&p?{provider:p}:{},...u===`fixed`&&g?{model:g}:{},...u===`fallback_profile`&&v?{fallbackProfile:v}:{},...b.length?{fallbackModels:b}:{}};r(`kanban.update`,{boardId:e.id,supervisor:{enabled:o,mode:c,intervalMs:Math.max(2,C)*1e3,recoveryMode:`auto`,...c===`agentic`?{routing:t,skills:S}:{}}}),window.setTimeout(()=>r(`kanban.supervisor.audit`,{boardId:e.id}),150)},E=o?t?.status??`starting`:`disabled`;return(0,U.jsxs)(`div`,{className:`shrink-0 border-b bg-background/80`,children:[(0,U.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`flex w-full items-center gap-2 px-4 py-1.5 text-left text-[11px] hover:bg-muted/40`,children:[(0,U.jsx)(n,{size:13,className:E===`healthy`?`text-success`:`text-warning`}),(0,U.jsx)(`span`,{className:`font-semibold`,children:`Kanban Agent`}),(0,U.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 capitalize text-muted-foreground`,children:[c,` · `,E]}),t?.summary&&(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-muted-foreground`,children:t.summary}),(0,U.jsx)(`span`,{className:`ml-auto text-muted-foreground`,children:t?.lastAuditAt?`checked ${zt(t.lastAuditAt)} ago`:`not checked`}),(0,U.jsx)(k,{size:13,className:A(`transition-transform`,i&&`rotate-180`)})]}),i&&(0,U.jsxs)(`div`,{className:`grid gap-3 border-t p-3 text-xs lg:grid-cols-[220px_220px_1fr_auto]`,children:[(0,U.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md border bg-card px-2 py-2`,children:[(0,U.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),(0,U.jsx)(`span`,{children:`Watch this board`})]}),(0,U.jsx)($,{label:`Supervisor engine`,value:c,options:[`deterministic`,`agentic`],onChange:e=>l(e)}),(0,U.jsxs)(`label`,{className:`block`,children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:`Audit interval (seconds)`}),(0,U.jsx)(`input`,{type:`number`,min:2,value:C,onChange:e=>te(Number(e.target.value)||2),className:`h-8 w-full rounded-md border bg-background px-2 outline-none focus:border-primary`})]}),(0,U.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,U.jsxs)(`button`,{type:`button`,onClick:ne,className:`inline-flex h-8 items-center gap-1 rounded-md bg-primary px-3 text-primary-foreground`,children:[(0,U.jsx)(h,{size:13}),` Save`]}),(0,U.jsxs)(`button`,{type:`button`,onClick:()=>r(`kanban.supervisor.audit`,{boardId:e.id}),className:`inline-flex h-8 items-center gap-1 rounded-md border px-3 hover:bg-muted`,children:[(0,U.jsx)(d,{size:13}),` Audit now`]})]}),c===`deterministic`?(0,U.jsx)(`div`,{className:`lg:col-span-4 rounded-md border border-success/20 bg-success/5 px-3 py-2 text-muted-foreground`,children:`Deterministic mode uses no provider, model, token, or billing. It repairs assignment/status/column drift and recovers expired leases.`}):(0,U.jsxs)(`div`,{className:`grid gap-3 lg:col-span-4 lg:grid-cols-2`,children:[(0,U.jsx)($,{label:`Kanban Agent model source`,value:u,options:[`session`,`fixed`,`fallback_profile`],onChange:e=>f(e)}),u===`fixed`&&(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:`Fixed provider / model`}),(0,U.jsx)(_e,{value:g||void 0,provider:p||void 0,candidates:w,placeholder:`Select exact provider / model…`,onPick:(e,t)=>{_(e),m(t)}})]}),u===`fallback_profile`&&(0,U.jsx)($,{label:`Fallback profile (first model is primary)`,value:v,options:Object.keys(T.fallbackProfiles),placeholder:`Select configured profile…`,onChange:y}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:`Supervisor skills`}),(0,U.jsx)(W,{options:T.skills.map(e=>({value:e.name,label:e.name,description:e.description,tag:e.source})),selected:S,onChange:ee,placeholder:`Force-load agentic skills…`})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:`Extra fallback models`}),(0,U.jsx)(W,{options:w.map(e=>({value:`${e.provider}/${e.model}`,label:e.label,tag:e.provider})),selected:b,onChange:x,placeholder:`Optional ordered fallbacks…`})]})]})]})]})}function Dt(e){let t=e?.tags??[],n=t.includes(`sdd`)?`sdd`:t.includes(`goal`)?`goal`:null;if(!n)return null;let r=t.find(e=>e.startsWith(`run:`))?.slice(4);return{engine:n,...r?{runId:r}:{}}}function Ot({onClose:e}){let t=me(e=>e.wsUrl),n=fe(e=>e.session?.id??null),i=pe(e=>e.agents),{boards:o,boardTotal:s,activeBoardTotal:c,orphanedBoardTotal:l,activeBoardId:u,activeBoard:d,loading:f,error:p,queueHealth:m,supervisorSnapshot:h,setLoading:g,setActiveBoardId:_}=he(),[v,b]=(0,j.useState)(``),[S,ee]=(0,j.useState)(1),[C,te]=(0,j.useState)([]),[w,T]=(0,j.useState)(``),E=(0,j.useRef)(null);Se(E);let[re,ie]=(0,j.useState)(``),[D,O]=(0,j.useState)(null),[se,ce]=(0,j.useState)([]),[k,le]=(0,j.useState)(),[ue,ge]=(0,j.useState)(!1),[_e,ve]=(0,j.useState)(null),[be,xe]=(0,j.useState)(0),[Ce,we]=(0,j.useState)(null),Ee=(0,j.useRef)(null),M=(0,j.useMemo)(()=>de(t),[t]),De=d?.tasks.find(e=>e.id===D)??null,Oe=(0,j.useMemo)(()=>{let e=new Set;for(let t of i.values())t.status===`running`&&(e.add(t.id),e.add(t.name));return e},[i]),ke=(0,j.useMemo)(()=>{let e=new Set;n&&e.add(n);for(let t of C)e.add(t);for(let t of i.values())t.status===`running`&&t.sessionId&&e.add(t.sessionId);return[...e]},[i,C,n]),N=e=>e.presence?.some(e=>e.active)===!0||e.tags?.some(e=>e.startsWith(`session:`)&&ke.includes(e.slice(8)))===!0,Ae=o.filter(N),je=o.filter(e=>!N(e)),Me=(0,j.useMemo)(()=>d?Te(d,{now:Date.now(),liveAgentIdentities:Oe,requireDueDate:d.lifecycle?.mode===`managed`}):null,[d,Oe]),Ne=(0,j.useMemo)(()=>d?d.tasks.filter(e=>e.status===`in_progress`||e.assignment?.status===`running`||e.assignment?.status===`queued`).reduce((e,t)=>e+(t.costCeilingUsd??0),0):0,[d]),P=(e,t={})=>{g(!0),M.send({type:e,payload:t})},F=(e,t={})=>{M.send({type:e,payload:t})},I=(0,j.useMemo)(()=>Dt(d),[d]),L=(e=S)=>P(`kanban.list`,{page:e,pageSize:Ct,activeSessionIds:ke}),R=(e=u)=>{e&&P(`kanban.get`,{boardId:e})};(0,j.useEffect)(()=>{L()},[]),(0,j.useEffect)(()=>{let e=!1,t=async()=>{try{let t=await fetch(`/api/sessions`);if(!t.ok)return;let n=await t.json();if(!Array.isArray(n)||e)return;let r=n.filter(e=>!!e&&typeof e==`object`&&typeof e.sessionId==`string`&&e.status!==`lost`).map(e=>e.sessionId).sort();te(e=>e.length===r.length&&e.every((e,t)=>e===r[t])?e:r)}catch{}};t();let n=window.setInterval(t,8e3);return()=>{e=!0,window.clearInterval(n)}},[]),(0,j.useEffect)(()=>{let e=n?o.find(e=>e.tags?.includes(`session:${n}`)):void 0,t=!!(n&&e)&&Ee.current!==n,r=t?e:u?void 0:o[0];r?.id&&(t&&(Ee.current=n),_(r.id),P(`kanban.get`,{boardId:r.id}))},[o,u,n,_]),(0,j.useEffect)(()=>{d&&D&&!d.tasks.some(e=>e.id===D)&&O(null)},[d,D]),(0,j.useEffect)(()=>{u&&(P(`kanban.health`,{boardId:u}),P(`kanban.supervisor.status`,{boardId:u}))},[u]),(0,j.useEffect)(()=>{if(!u)return;let e=setInterval(()=>{M.send({type:`kanban.get`,payload:{boardId:u}}),M.send({type:`kanban.health`,payload:{boardId:u}})},5e3);return()=>clearInterval(e)},[u,M]),(0,j.useEffect)(()=>{let e=setInterval(()=>{M.send({type:`kanban.list`,payload:{page:S,pageSize:Ct,activeSessionIds:ke}})},8e3);return()=>clearInterval(e)},[ke,S,M]);let z=e=>{ee(e),_(null),L(e)};(0,j.useEffect)(()=>{le(void 0)},[u,D]),(0,j.useEffect)(()=>{if(!u||!D)return;let e=u,t=D;ge(!0),ve(null);let n=M.on(`kanban.task.activity`,n=>{let r=n.payload;if(r.success===!1){ve(r.error??`Task activity could not be loaded.`),ge(!1);return}r.data?.boardId!==e||r.data.taskId!==t||(ce(r.data.events??[]),le(r.data.presence??[]),ge(!1))});return M.send({type:`kanban.task.activity`,payload:{boardId:e,taskId:t,limit:St}}),n},[u,D,De?.updatedAt,be,M]),(0,j.useEffect)(()=>{if(!(!u||!D))return M.on.bind(M)(`kanban.task.activity.changed`,e=>{let t=e.payload;t.boardId===u&&t.taskId===D&&xe(e=>e+1)})},[u,D,M]);let B=()=>{let e=v.trim();e&&(b(``),P(`kanban.create`,{title:e,lifecycle:{mode:`managed`,columns:{backlog:`backlog`,todo:`todo`,running:`in-progress`,review:`review`,done:`done`}}}))},V=()=>{if(!d)return;let e=w.trim();e&&(T(``),P(`kanban.task.add`,{boardId:d.id,title:e,columnId:d.columns[0]?.id??`backlog`,activityNote:`Task created manually in WebUI.`}),window.setTimeout(()=>R(d.id),150))},Pe=()=>{if(!d)return;let e=re.trim();e&&(ie(``),P(`kanban.column.add`,{boardId:d.id,title:e}),window.setTimeout(()=>R(d.id),150))},Fe=()=>{d&&(P(`kanban.delete`,{boardId:d.id}),window.setTimeout(L,150))},Ie=()=>{d&&(P(`kanban.duplicate`,{boardId:d.id,title:`${d.title} Copy`}),window.setTimeout(L,150))},H=e=>{d&&(P(`kanban.task.remove`,{boardId:d.id,taskId:e.id}),window.setTimeout(()=>R(d.id),150))},W=(e,t)=>{if(!d)return;let n=d.tasks.find(t=>t.id===e),r=d.columns.find(e=>e.id===n?.columnId)?.title,i=d.columns.find(e=>e.id===t)?.title??t;P(`kanban.task.move`,{boardId:d.id,taskId:e,columnId:t,activityNote:`Moved in WebUI${r?` from ${r}`:``} to ${i}.`}),window.setTimeout(()=>R(d.id),150)};return(0,U.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col bg-background text-foreground md:flex-row`,children:[(0,U.jsxs)(`aside`,{className:`flex max-h-[45dvh] w-full shrink-0 flex-col border-b bg-card/40 md:max-h-none md:w-[280px] md:border-b-0 md:border-r`,children:[(0,U.jsxs)(`div`,{className:`flex h-12 items-center gap-2 border-b px-3`,children:[(0,U.jsx)(`button`,{type:`button`,title:`Back`,onClick:e,className:`flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,U.jsx)(a,{size:16})}),(0,U.jsx)(ne,{size:17,className:`text-primary`}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:`Kanban`}),(0,U.jsxs)(`div`,{className:`truncate text-[11px] text-muted-foreground`,children:[s,` boards · `,c,` active · `,l,` orphaned`]})]}),(0,U.jsx)(`button`,{type:`button`,title:`Refresh`,onClick:()=>L(),className:`flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,U.jsx)(oe,{size:15,className:f?`animate-spin`:void 0})})]}),(0,U.jsxs)(`div`,{className:`flex gap-1 border-b p-2`,children:[(0,U.jsx)(`input`,{value:v,onChange:e=>b(e.target.value),onKeyDown:e=>{e.key===`Enter`&&B()},placeholder:`New board`,className:`min-w-0 flex-1 rounded-md border bg-background px-2 py-1.5 text-sm outline-none focus:border-primary`}),(0,U.jsx)(`button`,{type:`button`,title:`Create board`,onClick:B,className:`flex h-8 w-8 items-center justify-center rounded-md bg-primary text-primary-foreground hover:bg-primary/90`,children:(0,U.jsx)(y,{size:16})})]}),(0,U.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-2`,children:[Ae.length>0&&(0,U.jsxs)(`div`,{className:`mb-1 px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-success`,children:[`Active session · `,c]}),Ae.map(e=>(0,U.jsxs)(`button`,{type:`button`,onClick:()=>{_(e.id),P(`kanban.get`,{boardId:e.id})},className:A(`mb-1 w-full rounded-md px-2 py-2 text-left transition-colors`,u===e.id?`bg-primary/10 text-foreground`:`text-muted-foreground hover:bg-muted hover:text-foreground`),children:[(0,U.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e.title}),(0,U.jsxs)(`div`,{className:`mt-0.5 flex items-center justify-between text-[11px]`,children:[(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,U.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-success`}),e.taskCount,` tasks`]}),(0,U.jsxs)(`span`,{children:[e.completedTaskCount,` done`]})]})]},e.id)),je.length>0&&(0,U.jsxs)(`div`,{className:`mb-1 mt-2 px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[`No active session · `,l]}),je.map(e=>(0,U.jsxs)(`button`,{type:`button`,onClick:()=>{_(e.id),P(`kanban.get`,{boardId:e.id})},className:A(`mb-1 w-full rounded-md px-2 py-2 text-left transition-colors`,u===e.id?`bg-primary/10 text-foreground`:`text-muted-foreground hover:bg-muted hover:text-foreground`),children:[(0,U.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e.title}),(0,U.jsxs)(`div`,{className:`mt-0.5 flex items-center justify-between text-[11px]`,children:[(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,U.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-muted-foreground/45`}),e.taskCount,` tasks`]}),(0,U.jsxs)(`span`,{children:[e.completedTaskCount,` done`]})]})]},e.id))]}),(0,U.jsx)(ye,{page:S,pageSize:Ct,totalItems:s,onPageChange:z,compact:!0,itemLabel:`boards`})]}),(0,U.jsxs)(`main`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,U.jsxs)(`header`,{className:`flex min-h-12 shrink-0 flex-wrap items-center gap-2 border-b px-3 py-2 sm:px-4`,children:[(0,U.jsxs)(`div`,{className:`w-full min-w-0 sm:w-auto sm:flex-1`,children:[(0,U.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:d?.title??`No board selected`}),(0,U.jsx)(`div`,{className:`truncate text-[11px] text-muted-foreground`,children:d?`${d.columns.length} columns / ${d.tasks.length} tasks`:`Create or select a board`})]}),d&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`input`,{value:w,onChange:e=>T(e.target.value),onKeyDown:e=>{e.key===`Enter`&&V()},placeholder:`New task`,className:`h-8 w-[calc(100%-2.5rem)] min-w-0 flex-none rounded-md border bg-background px-2 text-sm outline-none focus:border-primary sm:w-56`}),(0,U.jsx)(`button`,{type:`button`,title:`Add task`,onClick:V,className:`flex h-8 w-8 items-center justify-center rounded-md bg-primary text-primary-foreground hover:bg-primary/90`,children:(0,U.jsx)(y,{size:16})}),(0,U.jsx)(`input`,{value:re,onChange:e=>ie(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Pe()},placeholder:`New column`,className:`h-8 w-[calc(100%-2.5rem)] min-w-0 flex-none rounded-md border bg-background px-2 text-sm outline-none focus:border-primary sm:w-44`}),(0,U.jsx)(`button`,{type:`button`,title:`Add column`,onClick:Pe,className:`hidden h-8 w-8 items-center justify-center rounded-md border text-muted-foreground hover:bg-muted hover:text-foreground sm:flex`,children:(0,U.jsx)(ne,{size:16})}),(0,U.jsx)(`button`,{type:`button`,title:`Duplicate board`,onClick:Ie,className:`flex h-8 w-8 items-center justify-center rounded-md border text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,U.jsx)(x,{size:16})}),(0,U.jsx)(`button`,{type:`button`,title:`Delete board`,onClick:Fe,className:`hidden h-8 w-8 items-center justify-center rounded-md border text-muted-foreground hover:bg-destructive/10 hover:text-destructive sm:flex`,children:(0,U.jsx)(r,{size:16})})]})]}),d&&(0,U.jsx)(Tt,{presence:d.presence}),d&&(0,U.jsx)(`div`,{className:`shrink-0 border-b px-3 py-2 sm:px-4`,children:(0,U.jsx)(Be,{title:`Board boundary`,value:d.boundary,onSave:e=>{P(`kanban.update`,{boardId:d.id,boundary:e}),window.setTimeout(()=>R(d.id),150)}})}),d&&I&&(0,U.jsx)(kt,{runLink:I,sendRaw:F}),d&&!I&&d.tasks.length>0&&(0,U.jsx)(At,{boardId:d.id,sendKanban:P}),d&&(0,U.jsx)(Et,{board:d,snapshot:h,sendKanban:P}),Me&&(0,U.jsx)(Le,{audit:Me,onSelectTask:O}),p&&(0,U.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-2 border-b border-destructive/30 bg-destructive/10 px-4 text-sm text-destructive`,children:[(0,U.jsx)(ae,{size:15}),(0,U.jsx)(`span`,{className:`truncate`,children:p})]}),(0,U.jsx)(`div`,{ref:E,className:`kanban-scroll-area min-h-0 flex-1 overflow-x-auto overflow-y-hidden overscroll-contain`,children:d?(0,U.jsxs)(U.Fragment,{children:[m&&(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-4 border-b px-4 py-2 text-xs text-muted-foreground`,children:[(0,U.jsx)(`span`,{className:`font-medium text-foreground`,children:`Queue health`}),m.counts.ready>0&&(0,U.jsxs)(`span`,{title:`Claimable tasks`,className:`inline-flex items-center gap-1 text-success`,children:[m.counts.ready,` ready`]}),m.counts.running>0&&(0,U.jsxs)(`span`,{title:`Running assignments`,className:`inline-flex items-center gap-1 text-warning`,children:[m.counts.running,` running`]}),m.counts.review>0&&(0,U.jsxs)(`span`,{title:`In review`,className:`inline-flex items-center gap-1 text-primary`,children:[m.counts.review,` review`]}),m.counts.blocked>0&&(0,U.jsxs)(`span`,{title:`Manually blocked`,className:`inline-flex items-center gap-1 text-destructive`,children:[m.counts.blocked,` blocked`]}),m.counts.failed>0&&(0,U.jsxs)(`span`,{title:`Failed tasks`,className:`inline-flex items-center gap-1 text-destructive`,children:[m.counts.failed,` failed`]}),m.dependencyBlocked.count>0&&(0,U.jsxs)(`span`,{title:`Ready/pending tasks blocked by dependencies`,className:`inline-flex items-center gap-1 rounded bg-warning/10 px-1.5 py-0.5 text-warning`,children:[m.dependencyBlocked.count,` blocked by deps`]}),m.staleAssignments.count>0&&(0,U.jsxs)(`span`,{title:`Expired lease assignments`,className:`inline-flex items-center gap-1 rounded bg-destructive/10 px-1.5 py-0.5 text-destructive`,children:[m.staleAssignments.count,` stale`]}),m.heartbeatDue.count===0&&m.staleAssignments.count===0&&m.dependencyBlocked.count===0&&(0,U.jsx)(`span`,{className:`text-success`,children:`healthy`}),Ne>0&&(0,U.jsxs)(`span`,{title:`Sum of costCeilingUsd for running/queued tasks`,className:`inline-flex items-center gap-1 text-info`,children:[`~$`,Ne.toFixed(2),` running cost`]})]}),(0,U.jsx)(`div`,{className:`flex h-full min-w-max gap-3 p-4`,children:[...d.columns].sort((e,t)=>e.order-t.order).map(e=>(0,U.jsx)(Nt,{board:d,column:e,selectedTaskId:D,dragTaskId:Ce,setDragTaskId:we,onSelectTask:O,onDeleteTask:H,onMoveTask:W},e.id))})]}):(0,U.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`No kanban board selected.`})})]}),(0,U.jsx)(It,{boards:o,board:d,task:De,runLink:I,onClose:()=>O(null),sendKanban:P,sendRaw:F,refreshBoard:R,activityEvents:se,activityPresence:k,activityLoading:ue,activityError:_e,activitySessionId:d?.tags?.find(e=>e.startsWith(`session:`))?.slice(8),refreshActivity:()=>xe(e=>e+1)})]})}function kt({runLink:e,sendRaw:n}){let r=e.engine===`sdd`,i=r?`sdd.board`:`goal`,a=`inline-flex items-center gap-1 rounded-md border px-2 py-1 text-[11px] font-medium hover:bg-muted`;return(0,U.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b bg-primary/5 px-4 py-1.5`,children:[(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-primary/15 px-1.5 py-0.5 text-[10px] font-semibold uppercase text-primary`,children:[(0,U.jsx)(S,{size:11}),` `,e.engine]}),(0,U.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Live run — steer it from here`}),(0,U.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,U.jsxs)(`button`,{type:`button`,className:a,onClick:()=>n(`${i}.pause`),children:[(0,U.jsx)(T,{size:12}),` Pause`]}),(0,U.jsxs)(`button`,{type:`button`,className:a,onClick:()=>n(`${i}.resume`),children:[(0,U.jsx)(w,{size:12}),` Resume`]}),r&&(0,U.jsxs)(`button`,{type:`button`,className:a,onClick:()=>n(`sdd.board.retry_all_failed`),children:[(0,U.jsx)(t,{size:12}),` Retry failed`]}),(0,U.jsxs)(`button`,{type:`button`,className:A(a,`text-destructive hover:bg-destructive/10`),onClick:()=>n(`${i}.stop`),children:[(0,U.jsx)(c,{size:12}),` Stop`]})]})]})}function At({boardId:e,sendKanban:t}){let n=`inline-flex items-center gap-1 rounded-md border px-2 py-1 text-[11px] font-medium text-primary hover:bg-primary/10`;return(0,U.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b bg-muted/30 px-4 py-1.5`,children:[(0,U.jsx)(S,{size:13,className:`text-primary`}),(0,U.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Run this board as a live agent job:`}),(0,U.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,U.jsx)(`button`,{type:`button`,className:n,onClick:()=>t(`kanban.run.start`,{boardId:e,engine:`goal`}),children:`Start as Goal`}),(0,U.jsx)(`button`,{type:`button`,className:n,onClick:()=>t(`kanban.run.start`,{boardId:e,engine:`sdd`}),children:`Start as SDD`})]})]})}function jt({runLink:e,runTaskId:n,modelCandidates:r,sendRaw:i}){let a=e.engine===`sdd`,[o,s]=(0,j.useState)(!1),[l,u]=(0,j.useState)(``),d=`inline-flex flex-1 items-center justify-center gap-1 rounded-md border py-1.5 text-xs font-medium hover:bg-muted`,p=()=>{let e=l.trim();e&&(i(a?`sdd.board.reassign`:`goal.assignTask`,{taskId:n,agentName:e}),s(!1),u(``))};return(0,U.jsxs)(`div`,{className:`mt-4 rounded-md border bg-primary/5 p-2.5`,children:[(0,U.jsx)(`div`,{className:`mb-2 text-[10px] font-semibold uppercase tracking-wide text-primary`,children:`Run controls`}),a&&(0,U.jsxs)(`div`,{className:`mb-2`,children:[(0,U.jsx)(`div`,{className:`mb-1 text-[10px] uppercase text-muted-foreground`,children:`Worker model`}),(0,U.jsx)(_e,{candidates:r,placeholder:`Set model for this task…`,onPick:(e,t)=>i(`sdd.board.set_task_model`,{taskId:n,model:e,provider:t})})]}),o?(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,U.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&p(),e.key===`Escape`&&s(!1)},placeholder:`New worker name`,className:`min-w-0 flex-1 rounded-md border bg-background px-2 py-1.5 text-xs outline-none focus:border-primary`}),(0,U.jsx)(`button`,{type:`button`,onClick:p,className:`rounded-md bg-primary/10 px-2 py-1.5 text-primary`,children:(0,U.jsx)(f,{size:14})}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>s(!1),className:`rounded-md bg-muted px-2 py-1.5`,children:(0,U.jsx)(ae,{size:14})})]}):(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,U.jsxs)(`button`,{type:`button`,className:d,onClick:()=>i(a?`sdd.board.retry`:`goal.retryTask`,{taskId:n}),children:[(0,U.jsx)(t,{size:13}),` Retry`]}),(0,U.jsxs)(`button`,{type:`button`,className:d,onClick:()=>s(!0),children:[(0,U.jsx)(ee,{size:13}),` Reassign`]}),a?(0,U.jsxs)(`button`,{type:`button`,className:A(d,`text-destructive hover:bg-destructive/10`),onClick:()=>i(`sdd.board.cancel_task`,{taskId:n}),children:[(0,U.jsx)(c,{size:13}),` Cancel`]}):(0,U.jsxs)(`button`,{type:`button`,className:d,onClick:()=>i(`goal.runTask`,{taskId:n}),children:[(0,U.jsx)(w,{size:13}),` Run now`]})]})]})}function Mt(e,t){let n=t.assignment,r=yt(e,t,[]).findings.filter(e=>e.category===`operational`),i=H(n?.provider),a=H(n?.model);return{owner:H(n?.name)??H(n?.agentId)??H(n?.role)??H(t.assignee)??H(t.assignedAgent)??`Unassigned`,route:i||a?`${i?`${i}/`:``}${a??`default`}`:n?.modelRouting===`session`?`session default`:`default route`,blockers:(t.dependsOn??[]).filter(t=>{let n=e.tasks.find(e=>e.id===t);return!n||![`completed`,`archived`].includes(n.status)}).length,attempts:n?.attempt?`${n.attempt}${n.maxAttempts?`/${n.maxAttempts}`:``}`:`0`,fallbackCount:+!!n?.fallbackProfile+(n?.fallbackModels?.length??0),activeUsers:(e.presence??[]).filter(e=>e.taskId===t.id&&e.active).length,failed:t.status===`failed`||n?.status===`failed`||!!n?.error,criticalRisks:r.filter(e=>e.severity===`critical`).length,warningRisks:r.filter(e=>e.severity===`warning`).length}}function Nt({board:e,column:t,selectedTaskId:n,dragTaskId:i,setDragTaskId:a,onSelectTask:o,onDeleteTask:s,onMoveTask:c}){let l=e.tasks.filter(e=>e.columnId===t.id).sort((e,t)=>e.order-t.order);return(0,U.jsxs)(`section`,{className:A(`flex h-full shrink-0 flex-col rounded-md border bg-muted/25 transition-[width] duration-200`,l.length===0?`w-[180px]`:`w-[310px]`),children:[(0,U.jsxs)(`div`,{className:`flex h-10 shrink-0 items-center gap-2 border-b px-3`,children:[(0,U.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-full`,style:{background:t.color??`hsl(var(--primary))`}}),(0,U.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-sm font-semibold`,children:t.title}),(0,U.jsx)(`span`,{className:`rounded bg-background px-1.5 py-0.5 text-[11px] text-muted-foreground`,children:l.length})]}),(0,U.jsx)(`ul`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto p-2 [scrollbar-gutter:stable]`,onDragOver:e=>e.preventDefault(),onDrop:n=>{n.preventDefault(),e.lifecycle?.mode!==`managed`&&i&&c(i,t.id),a(null)},children:l.map(t=>{let i=Mt(e,t);return(0,U.jsxs)(`li`,{draggable:e.lifecycle?.mode!==`managed`,onDragStart:()=>{e.lifecycle?.mode!==`managed`&&a(t.id)},onDragEnd:()=>a(null),className:A(`relative rounded-md border bg-background p-3 shadow-sm transition-colors`,n===t.id?`border-primary`:`hover:border-primary/50`),children:[(0,U.jsx)(`button`,{type:`button`,"aria-label":`Select task: ${t.title}`,onClick:()=>o(t.id),className:`absolute inset-0 cursor-pointer rounded-md`}),(0,U.jsxs)(`div`,{className:`pointer-events-none relative flex items-start gap-2`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`div`,{className:`line-clamp-2 text-sm font-medium leading-5`,children:t.title}),t.description&&(0,U.jsx)(`div`,{className:`mt-1 line-clamp-2 text-xs leading-4 text-muted-foreground`,children:t.description})]}),(0,U.jsx)(`button`,{type:`button`,title:`Delete task`,"aria-label":`Delete task: ${t.title}`,onClick:()=>s(t),className:`pointer-events-auto relative flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-destructive/10 hover:text-destructive`,children:(0,U.jsx)(r,{size:14})})]}),(0,U.jsxs)(`div`,{className:`pointer-events-none relative mt-2 flex flex-wrap items-center gap-1.5 text-[11px]`,children:[(0,U.jsx)(`span`,{className:Ht(t.priority),children:t.priority}),(0,U.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-muted-foreground`,children:t.status}),i.owner!==`Unassigned`&&(0,U.jsx)(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 text-primary`,children:i.owner}),t.assignment&&(0,U.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-muted-foreground`,children:i.route}),t.assignment?.attempt?(0,U.jsxs)(`span`,{className:`rounded bg-info/10 px-1.5 py-0.5 text-info`,children:[`attempt `,i.attempts]}):null,i.fallbackCount>0&&(0,U.jsxs)(`span`,{className:`rounded bg-info/10 px-1.5 py-0.5 text-info`,children:[i.fallbackCount,` fallback`]}),i.blockers>0?(0,U.jsxs)(`span`,{className:`rounded bg-warning/10 px-1.5 py-0.5 text-warning`,children:[i.blockers,` blocker`]}):null,i.activeUsers>0&&(0,U.jsxs)(`span`,{className:`rounded bg-success/10 px-1.5 py-0.5 text-success`,children:[i.activeUsers,` active`]}),i.failed&&(0,U.jsx)(`span`,{className:`rounded bg-destructive/10 px-1.5 py-0.5 text-destructive`,children:`run failed`}),i.criticalRisks>0&&(0,U.jsxs)(`span`,{className:`rounded bg-destructive/10 px-1.5 py-0.5 text-destructive`,children:[i.criticalRisks,` critical risk`]}),i.warningRisks>0&&(0,U.jsxs)(`span`,{className:`rounded bg-warning/10 px-1.5 py-0.5 text-warning`,children:[i.warningRisks,` warning`]}),t.chain&&(0,U.jsxs)(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 text-primary`,children:[`chain `,t.chain.order+1]}),t.assignment?.skills?.length?(0,U.jsxs)(`span`,{className:`rounded bg-success/10 px-1.5 py-0.5 text-success`,children:[t.assignment.skills.length,` skills`]}):null]})]},t.id)})})]})}var Pt=[`architect`,`developer`,`reviewer`,`tester`,`verifier`,`security`,`documenter`,`external`,`leader`,`shadow`,`subagent`],Ft=[{value:`fs.read`,label:`Read files`,description:`fs.read`},{value:`fs.write`,label:`Write files (in project)`,description:`fs.write`},{value:`fs.write.outside-project`,label:`Write outside project`,description:`fs.write.outside-project`},{value:`net.outbound`,label:`Outbound network`,description:`net.outbound`},{value:`shell.exec`,label:`Run project commands`,description:`shell.exec`},{value:`shell.restricted`,label:`Restricted shell`,description:`shell.restricted`},{value:`shell.arbitrary`,label:`Arbitrary shell`,description:`shell.arbitrary`},{value:`session.todo`,label:`Session todos`,description:`session.todo`},{value:`tool.meta`,label:`Tool metadata`,description:`tool.meta`},{value:`tool.mutate.any`,label:`Invoke any tool`,description:`tool.mutate.any`},{value:`memory.read`,label:`Read memory`,description:`memory.read`},{value:`memory.write`,label:`Write memory`,description:`memory.write`},{value:`package.install`,label:`Install packages`,description:`package.install`},{value:`subagent.spawn`,label:`Spawn subagents`,description:`subagent.spawn`},{value:`config.mutate`,label:`Mutate config / trust`,description:`config.mutate`}];function It({boards:e,board:t,task:r,runLink:i,onClose:a,sendKanban:o,sendRaw:c,refreshBoard:l,activityEvents:d,activityPresence:p,activityLoading:m,activityError:g,activitySessionId:_,refreshActivity:v}){let[b,S]=(0,j.useState)(``),[C,w]=(0,j.useState)(``),[T,ne]=(0,j.useState)(``),[E,re]=(0,j.useState)(``),[ie,D]=(0,j.useState)(``),[O,oe]=(0,j.useState)(`session`),[se,ce]=(0,j.useState)(``),[ue,de]=(0,j.useState)([]),[fe,pe]=(0,j.useState)([]),[me,he]=(0,j.useState)([]),[ve,ye]=(0,j.useState)([]),[Se,Ce]=(0,j.useState)(``),we=ge(!!r),Te=xe(!!r),Ee=H(Te.sessionProvider),M=H(Te.sessionModel),De=be(`kanban-task-inspector`,!!r),[Oe,ke]=(0,j.useState)(!1),[N,Ae]=(0,j.useState)(!1),[je,Me]=(0,j.useState)(``),[Ne,P]=(0,j.useState)(``),[F,I]=(0,j.useState)(``),[L,R]=(0,j.useState)(`pending`),[z,B]=(0,j.useState)(``),[V,Pe]=(0,j.useState)(``),[Fe,Ie]=(0,j.useState)(``),[Le,Re]=(0,j.useState)(`medium`),[ze,Ve]=(0,j.useState)(`chore`),[He,Ue]=(0,j.useState)(``),[We,G]=(0,j.useState)([]),[K,q]=(0,j.useState)([]),[Ge,Ke]=(0,j.useState)(!1),[qe,Je]=(0,j.useState)(``),[Ye,Xe]=(0,j.useState)(``),[Ze,Qe]=(0,j.useState)(`off`),[et,J]=(0,j.useState)(``),[tt,nt]=(0,j.useState)(``),[rt,it]=(0,j.useState)(``),[at,ot]=(0,j.useState)(``),[st,lt]=(0,j.useState)(``),[Y,ut]=(0,j.useState)(`observation`),[dt,X]=(0,j.useState)(`unknown`),[ft,Z]=(0,j.useState)(``);(0,j.useEffect)(()=>{let n=H(r?.assignment?.provider),i=H(r?.assignment?.model);S(H(r?.assignment?.agentId)??H(r?.assignedAgent)??``),w(H(r?.assignment?.name)??``),ne(H(r?.assignment?.role)??``),re(n??``),D(i??``),oe(r?.assignment?.modelRouting??(n||i?`fixed`:`session`)),ce(H(r?.assignment?.fallbackProfile)??``),de(r?.assignment?.fallbackModels??[]),pe(r?.assignment?.skills??[]),he(r?.assignment?.tools??[]),ye(r?.assignment?.allowedCapabilities??[]),Ce(e.find(e=>e.id!==t?.id)?.id??``),Me(r?.title??``),P(r?.description??``),I(r?.dueDate??``),R(r?.status??`pending`),B(``),Pe(``),Ie(``),Re(r?.priority??`medium`),Ve(r?.type??`chore`),Ue(r?.labels?.join(`, `)??``),G(r?.dependsOn??[]),q(r?.chain&&t?t.tasks.filter(e=>e.chain?.chainId===r.chain?.chainId).sort((e,t)=>(e.chain?.order??0)-(t.chain?.order??0)).map(e=>e.id):r?[r.id]:[]),Ke(!1),Je(r?.estimatedHours?.toString()??``),Xe(r?.actualHours?.toString()??``),Qe(r?.retryPolicy??r?.assignment?.retryPolicy??`off`),J((r?.costCeilingUsd??r?.assignment?.costCeilingUsd)?.toString()??``),nt(r?.assignment?.maxAttempts?.toString()??``),it(``),ot(``),lt(``),ut(`observation`),X(`unknown`),Z(``)},[t?.id,e,r]);let pt=e=>({boardId:t?.id,taskId:r?.id,...b.trim()?{agentId:b.trim()}:{},...C.trim()?{name:C.trim()}:{},...T.trim()?{role:T.trim()}:{},modelRouting:O,...O===`fixed`&&E.trim()?{provider:E.trim()}:{},...O===`fixed`&&ie.trim()?{model:ie.trim()}:{},...O===`fallback_profile`&&se.trim()?{fallbackProfile:se.trim()}:{},fallbackModels:ue,skills:fe,tools:me,allowedCapabilities:ve,...tt?{maxAttempts:Number(tt)}:{},...et?{costCeilingUsd:Number(et)}:{},retryPolicy:Ze,activityNote:ft.trim()||`${e===`dispatch`?`Dispatched`:`Assigned`} from WebUI to ${C.trim()||b.trim()||T.trim()||`the configured agent route`}.`}),mt=()=>{!t||!r||!je.trim()||(o(`kanban.task.update`,{boardId:t.id,taskId:r.id,title:je.trim(),description:Ne,dueDate:F||null,...t.lifecycle?.mode===`managed`?{}:{status:L},priority:Le,type:ze,labels:He.split(`,`).map(e=>e.trim()).filter(Boolean),dependsOn:We,...r.chain&&K.length<=1?{chain:null}:{},estimatedHours:qe?Number(qe):0,actualHours:Ye?Number(Ye):0,retryPolicy:Ze,costCeilingUsd:et?Number(et):null,activityNote:ft.trim()||`Task contract edited in WebUI.`}),K.length>1&&o(`kanban.task.chain`,{boardId:t.id,taskIds:K,enforceDependencies:Ge}),window.setTimeout(()=>l(t.id),180),Z(``))},gt=[`backlog`,`todo`,`running`,`review`,`done`],_t=r?.lifecycle?.currentStage,vt=_t?gt.indexOf(_t):-1,yt=vt>=0&&vt<gt.length-1?gt[vt+1]:void 0,bt=()=>{!t||!r||!yt||!z.trim()||(o(`kanban.task.transition`,{boardId:t.id,taskId:r.id,to:yt,actor:b.trim()||C.trim()||r.assignee||r.assignedAgent||`webui-agent`,comment:z.trim(),...V.trim()?{action:V.trim()}:{},...Fe.trim()?{attachment:{url:Fe.trim(),type:`url`,title:`Evidence for ${r.title}`}}:{}}),window.setTimeout(()=>l(t.id),180))},St=()=>{!t||!r||!rt.trim()||(o(`kanban.task.check.add`,{boardId:t.id,taskId:r.id,description:rt.trim(),checkType:`manual`}),it(``))},Ct=()=>{!t||!r||!at.trim()||(o(`kanban.task.activity.add`,{boardId:t.id,taskId:r.id,kind:Y,outcome:dt,summary:at.trim(),...st.trim()?{details:st.trim()}:{},actor:C.trim()||b.trim()||`webui-operator`}),ot(``),lt(``),window.setTimeout(v,150))};return r?(0,U.jsxs)(`aside`,{"aria-label":`Task inspector`,"data-expanded":N?`true`:`false`,className:A(`flex max-h-[42dvh] w-full shrink-0 flex-col border-t bg-card/40 transition-[width] duration-200 ease-out md:max-h-none md:border-l md:border-t-0`,N?`fixed inset-0 z-50 h-dvh max-h-none w-screen border-0 bg-card transition-none md:w-screen md:border-0`:`md:w-[420px] xl:w-[480px]`),children:[(0,U.jsxs)(`div`,{className:A(`flex h-12 items-center gap-2 border-b px-3`,N&&`px-5`),children:[(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:`Task`}),(0,U.jsx)(`div`,{className:`truncate text-[11px] text-muted-foreground`,children:r.id.slice(0,8)})]}),(0,U.jsx)(`button`,{type:`button`,title:N?`Collapse task details`:`Expand task details`,"aria-label":N?`Collapse task details`:`Expand task details`,"aria-pressed":N,onClick:()=>Ae(e=>!e),className:`flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground`,children:N?(0,U.jsx)(te,{size:16}):(0,U.jsx)(u,{size:16})}),(0,U.jsx)(`button`,{type:`button`,title:`Close`,onClick:()=>{Ae(!1),a()},className:`flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,U.jsx)(ae,{size:16})})]}),r?(0,U.jsxs)(`div`,{ref:De,className:A(`min-h-0 flex-1 overflow-y-auto overscroll-contain p-3`,N&&`px-5 py-4 xl:px-7`),children:[(0,U.jsxs)(`div`,{className:`space-y-3 rounded-md border bg-background p-2.5`,children:[(0,U.jsx)(Be,{title:`Task boundary`,value:r.boundary,inherited:t?.boundary,onSave:e=>{t&&(o(`kanban.task.update`,{boardId:t.id,taskId:r.id,boundary:e,activityNote:`Task boundary edited in WebUI.`}),window.setTimeout(()=>l(t.id),150))}}),(0,U.jsx)(Q,{label:`Title`,value:je,onChange:Me}),(0,U.jsxs)(`label`,{className:`block`,children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:`Description / working context`}),(0,U.jsx)(`textarea`,{value:Ne,onChange:e=>P(e.target.value),rows:5,className:`w-full resize-y rounded-md border bg-background px-2 py-1.5 text-xs leading-5 outline-none focus:border-primary`})]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[t?.lifecycle?.mode===`managed`?(0,U.jsxs)(`div`,{className:`rounded-md border bg-muted/30 px-2 py-1.5`,children:[(0,U.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:`Managed stage`}),(0,U.jsx)(`div`,{className:`mt-1 text-xs font-semibold capitalize`,children:r.lifecycle?.currentStage??`Backlog`})]}):(0,U.jsx)($,{label:`Status`,value:L,options:[`pending`,`ready`,`in_progress`,`blocked`,`review`,`completed`,`failed`,`archived`],onChange:e=>R(e)}),(0,U.jsx)($,{label:`Priority`,value:Le,options:[`critical`,`high`,`medium`,`low`],onChange:e=>Re(e)}),(0,U.jsx)($,{label:`Type`,value:ze,options:[`feature`,`bugfix`,`refactor`,`docs`,`test`,`chore`],onChange:e=>Ve(e)}),(0,U.jsx)(Q,{label:`Labels (comma separated)`,value:He,onChange:Ue})]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,U.jsx)(Q,{label:`Due date (ISO or YYYY-MM-DD)`,value:F,onChange:I}),(0,U.jsx)(Q,{label:`Estimated hours`,value:qe,onChange:Je}),(0,U.jsx)(Q,{label:`Actual hours`,value:Ye,onChange:Xe})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:`Dependencies`}),(0,U.jsx)(W,{options:(t?.tasks??[]).filter(e=>e.id!==r.id).map(e=>({value:e.id,label:e.title,description:e.status})),selected:We,onChange:G,placeholder:`Select blocking tasks…`})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:`Task chain (selection order)`}),(0,U.jsx)(W,{options:(t?.tasks??[]).map(e=>({value:e.id,label:e.title,description:e.status})),selected:K,onChange:e=>q(e.includes(r.id)?e:[r.id,...e]),placeholder:`Add tasks to a sequential chain…`}),(0,U.jsxs)(`label`,{className:`mt-1.5 flex items-center gap-2 text-[11px] text-muted-foreground`,children:[(0,U.jsx)(`input`,{type:`checkbox`,checked:Ge,onChange:e=>Ke(e.target.checked)}),`Enforce chain order as dependencies`]})]}),(0,U.jsx)(Q,{label:`Change / assignment reason (persisted to activity)`,value:ft,onChange:Z}),(0,U.jsxs)(`button`,{type:`button`,onClick:mt,className:`inline-flex h-9 w-full items-center justify-center gap-2 rounded-md bg-primary text-sm text-primary-foreground hover:bg-primary/90`,children:[(0,U.jsx)(h,{size:15}),` Save task contract`]}),t?.lifecycle?.mode===`managed`&&yt&&(0,U.jsxs)(`section`,{"aria-label":`Managed lifecycle transition`,className:`space-y-2 rounded-md border border-primary/30 bg-primary/5 p-2.5`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wide text-primary`,children:`Kanban Agent transition`}),(0,U.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[_t,` → `,yt,`; no stages can be skipped.`]})]}),(0,U.jsx)(n,{size:16,className:`text-primary`})]}),(0,U.jsx)(Q,{label:`Completed action / reviewer action`,value:V,onChange:Pe}),(0,U.jsx)(Q,{label:`Truthful progress comment (required)`,value:z,onChange:B}),(0,U.jsx)(Q,{label:`Evidence attachment URL`,value:Fe,onChange:Ie}),(0,U.jsxs)(`button`,{type:`button`,disabled:!z.trim(),onClick:bt,className:`inline-flex h-9 w-full items-center justify-center gap-2 rounded-md bg-primary text-sm text-primary-foreground hover:bg-primary/90 disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,U.jsx)(le,{size:15}),` Advance to `,yt]})]})]}),t&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(ht,{board:t,task:r,events:d,presence:p,sessionId:_,sessionProvider:Ee,sessionModel:M}),(0,U.jsx)(ct,{task:r,events:d,sessionId:_}),(0,U.jsx)(xt,{board:t,task:r,events:d})]}),(0,U.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-2 text-xs`,children:[(0,U.jsx)(Vt,{label:`Source`,value:r.origin?.system??`manual`}),(0,U.jsx)(Vt,{label:`Task ID`,value:r.id.slice(0,8)}),(0,U.jsx)(Vt,{label:`Run`,value:r.assignment?.status??`unassigned`}),(0,U.jsx)(Vt,{label:`Column`,value:Lt(t,r.columnId)})]}),r.assignment&&(0,U.jsx)(Bt,{assignment:r.assignment}),i&&r.origin?.taskId&&(0,U.jsx)(jt,{runLink:i,runTaskId:r.origin.taskId,modelCandidates:we,sendRaw:c}),!i&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,U.jsx)($,{label:`Primary model source`,value:O,options:[`session`,`fixed`,`fallback_profile`],onChange:e=>oe(e)}),O===`session`&&(0,U.jsxs)(`div`,{className:`rounded-md border bg-info/5 px-2 py-1.5 text-[11px] text-muted-foreground`,children:[`Uses the live session model: `,Ee?`${Ee}/`:``,M||`not available`,`.`]}),O===`fixed`&&(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:`Fixed provider / model`}),(0,U.jsx)(_e,{value:ie||void 0,provider:E||void 0,candidates:we,placeholder:`Select exact provider / model…`,onPick:(e,t)=>{D(e),re(t)}})]}),O===`fallback_profile`&&(0,U.jsx)($,{label:`Fallback profile (first model is primary)`,value:se,options:Object.keys(Te.fallbackProfiles),placeholder:`Select configured profile…`,onChange:ce}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:`Fallback models`}),(0,U.jsx)(W,{options:we.map(e=>({value:`${e.provider}/${e.model}`,label:e.label,description:e.description,tag:e.provider})),selected:ue,onChange:de,placeholder:`Add fallback model…`,emptyLabel:`No models — add a provider in Settings`})]}),(0,U.jsx)($,{label:`Role`,value:T,options:Pt,placeholder:`Select a role…`,onChange:ne}),(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:[`Agentic skills`,` `,(0,U.jsx)(`span`,{className:`text-muted-foreground/70`,children:`· force-loaded into the worker`})]}),(0,U.jsx)(W,{options:Te.skills.map(e=>({value:e.name,label:e.name,description:e.description,tag:e.source})),selected:fe,onChange:pe,placeholder:`Assign required skills…`,emptyLabel:`No skills registered`})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:[`Tools`,` `,(0,U.jsx)(`span`,{className:`text-muted-foreground/70`,children:`· blank = full default toolset`})]}),(0,U.jsx)(W,{options:Te.tools.map(e=>({value:e.name,label:e.name,description:e.description})),selected:me,onChange:he,placeholder:`Restrict to specific tools…`,emptyLabel:`Tool list unavailable on this server`})]}),(0,U.jsxs)(`div`,{className:`rounded-md border bg-background/60`,children:[(0,U.jsxs)(`button`,{type:`button`,onClick:()=>ke(e=>!e),className:`flex w-full items-center justify-between px-2 py-1.5 text-[11px] font-medium text-muted-foreground hover:text-foreground`,children:[`Advanced`,(0,U.jsx)(k,{size:13,className:A(`transition-transform`,Oe&&`rotate-180`)})]}),Oe&&(0,U.jsxs)(`div`,{className:`space-y-3 border-t p-2`,children:[(0,U.jsx)(Q,{label:`Agent name (optional)`,value:C,onChange:w}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,U.jsx)($,{label:`Retry policy`,value:Ze,options:[`off`,`incremental`,`exponential`],onChange:e=>Qe(e)}),(0,U.jsx)(Q,{label:`Max attempts`,value:tt,onChange:nt}),(0,U.jsx)(Q,{label:`Cost ceiling USD`,value:et,onChange:J})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:[`Capabilities`,` `,(0,U.jsx)(`span`,{className:`text-muted-foreground/70`,children:`· blank = safe defaults`})]}),(0,U.jsx)(W,{options:Ft,selected:ve,onChange:ye,placeholder:`Grant a capability…`})]})]})]})]}),(0,U.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-2`,children:[(0,U.jsxs)(`button`,{type:`button`,onClick:()=>{!t||!r||(o(`kanban.task.assign`,pt(`assign`)),Z(``),window.setTimeout(()=>l(t.id),150))},className:`inline-flex h-9 items-center justify-center gap-2 rounded-md border text-sm hover:bg-muted`,children:[(0,U.jsx)(ee,{size:15}),`Assign`]}),(0,U.jsxs)(`button`,{type:`button`,onClick:()=>{!t||!r||(o(`kanban.task.dispatch`,pt(`dispatch`)),Z(``),window.setTimeout(()=>l(t.id),200))},className:`inline-flex h-9 items-center justify-center gap-2 rounded-md bg-primary text-sm text-primary-foreground hover:bg-primary/90`,children:[(0,U.jsx)(s,{size:15}),`Dispatch`]})]})]}),e.length>1&&!i?(0,U.jsxs)(`div`,{className:`mt-4 space-y-2 rounded-md border bg-background p-2`,children:[(0,U.jsxs)(`label`,{className:`block`,children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:`Target board`}),(0,U.jsx)(`select`,{value:Se,onChange:e=>Ce(e.target.value),className:`h-8 w-full rounded-md border bg-background px-2 text-sm outline-none focus:border-primary`,children:e.filter(e=>e.id!==t?.id).map(e=>(0,U.jsx)(`option`,{value:e.id,children:e.title},e.id))})]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,U.jsxs)(`button`,{type:`button`,onClick:()=>{!t||!r||!Se||o(`kanban.task.copy`,{boardId:t.id,taskId:r.id,targetBoardId:Se})},disabled:!Se,className:`inline-flex h-9 items-center justify-center gap-2 rounded-md border text-sm hover:bg-muted disabled:opacity-50`,children:[(0,U.jsx)(x,{size:15}),`Copy`]}),(0,U.jsxs)(`button`,{type:`button`,onClick:()=>{!t||!r||!Se||o(`kanban.task.transfer`,{boardId:t.id,taskId:r.id,targetBoardId:Se})},disabled:!Se,className:`inline-flex h-9 items-center justify-center gap-2 rounded-md border text-sm hover:bg-muted disabled:opacity-50`,children:[(0,U.jsx)(le,{size:15}),`Transfer`]})]})]}):null,(0,U.jsxs)(`div`,{className:`mt-5`,children:[(0,U.jsx)(`div`,{className:`mb-2 text-xs font-semibold uppercase text-muted-foreground`,children:`Completion checks`}),(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(r.successCriteria??[]).map(e=>(0,U.jsxs)(`div`,{className:`grid grid-cols-[auto_1fr_92px] items-center gap-2 rounded-md border bg-background px-2 py-1.5 text-xs`,children:[(0,U.jsx)(f,{size:13,className:e.status===`passed`?`text-success`:`text-muted-foreground`}),(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:e.description}),(0,U.jsx)(`select`,{value:e.status,onChange:n=>o(`kanban.task.check.update`,{boardId:t?.id,taskId:r.id,checkId:e.id,status:n.target.value}),className:`h-7 rounded border bg-background px-1 text-[11px]`,children:[`pending`,`passed`,`failed`,`skipped`].map(e=>(0,U.jsx)(`option`,{value:e,children:e},e))})]},e.id)),(0,U.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,U.jsx)(`input`,{value:rt,onChange:e=>it(e.target.value),onKeyDown:e=>e.key===`Enter`&&St(),placeholder:`Add a verifiable completion check…`,className:`h-8 min-w-0 flex-1 rounded-md border bg-background px-2 text-xs outline-none focus:border-primary`}),(0,U.jsx)(`button`,{type:`button`,onClick:St,className:`h-8 rounded-md border px-2 hover:bg-muted`,children:(0,U.jsx)(y,{size:14})})]})]})]}),(0,U.jsx)($e,{task:r,events:d,sessionId:_,loading:m,error:g,onRefresh:v}),(0,U.jsxs)(`div`,{className:`mt-4`,children:[(0,U.jsx)(`div`,{className:`mb-2 text-xs font-semibold uppercase text-muted-foreground`,children:`Record decision / outcome`}),(0,U.jsxs)(`div`,{className:`mb-1.5 grid grid-cols-2 gap-1.5`,children:[(0,U.jsx)(`select`,{value:Y,onChange:e=>ut(e.target.value),"aria-label":`Task activity kind`,className:`h-8 rounded-md border bg-background px-2 text-xs`,children:[`decision`,`attempt`,`result`,`blocker`,`observation`].map(e=>(0,U.jsx)(`option`,{value:e,children:e},e))}),(0,U.jsx)(`select`,{value:dt,onChange:e=>X(e.target.value),"aria-label":`Task activity outcome`,className:`h-8 rounded-md border bg-background px-2 text-xs`,children:[`unknown`,`succeeded`,`failed`,`partial`,`skipped`].map(e=>(0,U.jsx)(`option`,{value:e,children:e},e))})]}),(0,U.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,U.jsx)(`input`,{value:at,onChange:e=>ot(e.target.value),onKeyDown:e=>e.key===`Enter`&&Ct(),placeholder:`What was decided, attempted, or produced?`,className:`h-8 min-w-0 flex-1 rounded-md border bg-background px-2 text-xs outline-none focus:border-primary`}),(0,U.jsx)(`button`,{type:`button`,onClick:Ct,className:`h-8 rounded-md border px-2 hover:bg-muted`,"aria-label":`Record task decision or outcome`,children:(0,U.jsx)(y,{size:14})})]}),(0,U.jsx)(`input`,{value:st,onChange:e=>lt(e.target.value),placeholder:`Optional evidence, rationale, command, link, or failure detail…`,"aria-label":`Task activity details`,className:`mt-1.5 h-8 w-full rounded-md border bg-background px-2 text-xs outline-none focus:border-primary`})]})]}):null]}):null}function Lt(e,t){return e?.columns.find(e=>e.id===t)?.title??t}var Rt={assigned:`bg-info/10 text-info`,queued:`bg-info/10 text-info`,running:`bg-warning/10 text-warning`,completed:`bg-success/10 text-success`,failed:`bg-destructive/10 text-destructive`,cancelled:`bg-muted text-muted-foreground`};function zt(e,t){if(!e)return null;let n=Date.parse(e);if(Number.isNaN(n))return null;let r=t?Date.parse(t):Date.now();if(Number.isNaN(r))return null;let i=Math.max(0,Math.round((r-n)/1e3));if(i<60)return`${i}s`;let a=Math.floor(i/60);return a<60?`${a}m ${i%60}s`:`${Math.floor(a/60)}h ${a%60}m`}function Bt({assignment:e}){let t=e.status===`running`,n=zt(e.dispatchedAt,e.completedAt),r=H(e.name)??H(e.agentId),i=H(e.role),a=H(e.provider),o=H(e.model),s=[];return r&&s.push({label:`Agent`,value:r}),i&&s.push({label:`Role`,value:i}),e.modelRouting&&s.push({label:`Model source`,value:e.modelRouting}),(a||o)&&s.push({label:`Model`,value:(0,U.jsxs)(`span`,{className:`font-mono text-[11px]`,children:[a?`${a}/`:``,o??`—`]})}),e.subagentId&&s.push({label:`Subagent`,value:(0,U.jsx)(`span`,{className:`font-mono text-[11px]`,children:e.subagentId})}),n&&s.push({label:e.completedAt?`Duration`:`Elapsed`,value:n}),typeof e.attempt==`number`&&s.push({label:`Attempt`,value:`${e.attempt}${e.maxAttempts?` / ${e.maxAttempts}`:``}`}),e.costCeilingUsd&&s.push({label:`Cost ceiling`,value:`$${e.costCeilingUsd.toFixed(2)}`}),e.fallbackProfile&&s.push({label:`Fallback profile`,value:e.fallbackProfile}),e.fallbackModels?.length&&s.push({label:`Fallbacks`,value:e.fallbackModels.join(` → `)}),e.skills?.length&&s.push({label:`Skills`,value:e.skills.join(`, `)}),e.tools?.length&&s.push({label:`Tools`,value:e.tools.join(`, `)}),e.leaseExpiresAt&&s.push({label:`Lease expires`,value:new Date(e.leaseExpiresAt).toLocaleString()}),(0,U.jsxs)(`div`,{className:`mt-4 rounded-md border bg-background p-2.5`,children:[(0,U.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:`Live run`}),(0,U.jsxs)(`span`,{className:A(`ml-auto inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium capitalize`,Rt[e.status]??`bg-muted text-muted-foreground`),children:[t&&(0,U.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse rounded-full bg-current`,"aria-hidden":!0}),e.status]})]}),s.length>0&&(0,U.jsx)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-xs`,children:s.map(e=>(0,U.jsxs)(`div`,{className:`contents`,children:[(0,U.jsx)(`dt`,{className:`text-muted-foreground`,children:e.label}),(0,U.jsx)(`dd`,{className:`min-w-0 truncate text-right text-foreground`,children:e.value})]},e.label))}),e.lastResult&&(0,U.jsxs)(`div`,{className:`mt-2`,children:[(0,U.jsx)(`div`,{className:`mb-1 text-[10px] uppercase text-muted-foreground`,children:`Last result`}),(0,U.jsx)(`div`,{className:`max-h-24 overflow-y-auto whitespace-pre-wrap rounded bg-muted px-2 py-1 text-[11px] leading-relaxed text-foreground`,children:e.lastResult})]}),e.error&&(0,U.jsx)(`div`,{className:`mt-2 rounded border border-destructive/30 bg-destructive/10 px-2 py-1 text-[11px] text-destructive`,children:e.error})]})}function Vt({label:e,value:t}){return(0,U.jsxs)(`div`,{className:`rounded-md border bg-background px-2 py-1.5`,children:[(0,U.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground`,children:e}),(0,U.jsx)(`div`,{className:`mt-0.5 truncate text-xs font-medium`,children:t})]})}function Q({label:e,value:t,onChange:n}){return(0,U.jsxs)(`label`,{className:`block`,children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:e}),(0,U.jsx)(`input`,{value:t,onChange:e=>n(e.target.value),className:`h-8 w-full rounded-md border bg-background px-2 text-sm outline-none focus:border-primary`})]})}function $({label:e,value:t,options:n,placeholder:r,onChange:i}){return(0,U.jsxs)(`label`,{className:`block`,children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:e}),(0,U.jsxs)(`select`,{value:t,onChange:e=>i(e.target.value),className:`h-8 w-full rounded-md border bg-background px-2 text-sm outline-none focus:border-primary`,children:[r&&(0,U.jsx)(`option`,{value:``,children:r}),n.map(e=>(0,U.jsx)(`option`,{value:e,children:e},e))]})]})}function Ht(e){let t=`rounded px-1.5 py-0.5`;return e===`critical`?`${t} bg-destructive/10 text-destructive`:e===`high`?`${t} bg-warning/10 text-warning`:e===`low`?`${t} bg-muted text-muted-foreground`:`${t} bg-info/10 text-info`}export{Ot as KanbanView};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{An as t,Dt as n,Fn as r,Gi as i,Kt as a,Li as o,Or as s,Qt as c,_i as l,ai as u,ia as d,li as f,mt as p,nn as m,oa as h,ot as g,pi as _,ta as v,tt as y,ur as b,zn as x}from"./vendor-DffL_bim.js";import"./i18n-Dk35g-uV.js";import{n as S}from"./ui-store-CwOvhFZG.js";import{t as C}from"./utils-DEzFewqr.js";import{t as w}from"./mailbox-store-BY2SVw-s.js";import{s as T}from"./view-navigation-BjlXpDXc.js";import{s as E,t as D}from"./LazyMarkdown-BHoUIDge.js";var O=e(h(),1),k=y(),A={note:s,ask:_,assign:a,steer:c,btw:o,broadcast:a,status:f,result:l},j={high:`border-destructive/25 bg-destructive/10 text-destructive`,normal:`border-border bg-muted text-muted-foreground`,low:`border-primary/20 bg-primary/10 text-primary`};function M(e){return new Date(e).toLocaleString()}function N(e){let t=new Date(e),n=Date.now()-t.getTime();return n<6e4?d.t(`common:time.justNow`):n<36e5?d.t(`common:time.minutesAgo`,{count:Math.round(n/6e4)}):n<864e5?d.t(`common:time.hoursAgo`,{count:Math.round(n/36e5)}):n<6048e5?d.t(`common:time.daysAgo`,{count:Math.round(n/864e5)}):t.toLocaleDateString()}function P(){let{t:e}=v();return(0,k.jsx)(`div`,{className:`flex h-full min-h-0 flex-1 items-center justify-center bg-[hsl(var(--surface-2)/0.45)] p-4`,children:(0,k.jsxs)(`div`,{className:`ws-surface flex max-w-md flex-col items-center gap-3 rounded-xl p-6 text-center text-muted-foreground`,children:[(0,k.jsx)(`span`,{className:`flex h-12 w-12 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,k.jsx)(r,{className:`h-6 w-6`})}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{className:`text-sm font-semibold text-foreground`,children:e(`activity:mailbox.emptyDetail`)}),(0,k.jsx)(`div`,{className:`mt-1 text-xs`,children:e(`activity:mailbox.emptyDetailHint`)})]})]})})}function F({readBy:e}){let{t}=v(),n=Object.entries(e);return n.length===0?null:(0,k.jsxs)(`div`,{className:`space-y-1`,children:[(0,k.jsx)(`div`,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wide`,children:t(`activity:mailbox.readBy`)}),(0,k.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:n.map(([e,t])=>(0,k.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] bg-success/10 text-success`,title:M(t),children:[(0,k.jsx)(l,{className:`h-2.5 w-2.5`}),e]},e))})]})}function I({className:e}){let{t:r}=v(),a=S(e=>e.selectedMailMessage),o=S(e=>e.setSelectedMailMessage);(0,O.useEffect)(()=>()=>{o(null)},[o]);function s(){o(null),T(`chat`)}if(!a)return(0,k.jsx)(P,{});let c=A[a.type]??t,d=r(`activity:mailbox.type.${a.type}`,{defaultValue:a.type}),f=j[a.priority]??j.normal,h=a.scope?{scope:a.scope,recipientSessionId:a.recipientSessionId}:w(a.to),_=a.to===`*`||a.to===`all`?r(`activity:mailbox.everyone`):a.to,y=h.scope===`session`?r(`activity:mailbox.sessionScope`,{sid:h.recipientSessionId??``}):h.scope===`project`?r(`activity:mailbox.projectScope`):r(`activity:mailbox.directScope`);return(0,k.jsx)(`div`,{className:C(`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-[hsl(var(--surface-2)/0.45)] p-3`,e),children:(0,k.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,k.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-border/70 px-3 py-3 sm:px-4 shrink-0`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:s,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md border border-border/70 bg-background/60 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,title:r(`activity:mailbox.backToChat`),children:(0,k.jsx)(i,{className:`h-4 w-4`})}),(0,k.jsx)(`div`,{className:C(`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg`,a.completed?`bg-success/10`:`bg-primary/10`),children:(0,k.jsx)(c,{className:C(`h-4 w-4`,a.completed?`text-success`:`text-primary`)})}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,k.jsx)(`h2`,{className:`text-sm font-semibold text-foreground truncate`,children:a.subject}),a.completed&&(0,k.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 rounded-md border border-success/25 bg-success/8 px-1.5 py-0.5 text-[10px] font-semibold text-success`,children:[(0,k.jsx)(l,{className:`h-3 w-3`}),r(`activity:mailbox.completed`)]}),(0,k.jsx)(`span`,{className:C(`rounded-md border px-1.5 py-0.5 text-[10px] font-semibold uppercase`,f),children:a.priority||`normal`})]}),(0,k.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-2 text-[11px] text-muted-foreground`,children:[(0,k.jsx)(`span`,{className:`min-w-0 truncate font-medium text-foreground/80`,children:a.from}),(0,k.jsx)(`span`,{children:`→`}),(0,k.jsx)(`span`,{className:`min-w-0 truncate`,children:_}),h.scope===`session`&&(0,k.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-semibold bg-warning/12 text-warning`,title:r(`activity:mailbox.sessionScopeTitle`,{sid:h.recipientSessionId??``}),children:[(0,k.jsx)(x,{className:`h-2.5 w-2.5`}),r(`activity:mailbox.sessionLabel`)]}),h.scope===`project`&&(0,k.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-semibold bg-primary/12 text-primary`,children:[(0,k.jsx)(b,{className:`h-2.5 w-2.5`}),r(`activity:mailbox.projectLabel`)]}),(0,k.jsx)(`span`,{className:`opacity-40`,children:`•`}),(0,k.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,k.jsx)(u,{className:`h-3 w-3`}),N(a.timestamp)]})]})]}),(0,k.jsx)(`button`,{type:`button`,onClick:s,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,title:r(`activity:mailbox.closeTitle`),children:(0,k.jsx)(g,{className:`h-4 w-4`})})]}),(0,k.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,k.jsx)(`div`,{className:`mx-auto w-full max-w-4xl px-4 py-5`,children:(0,k.jsx)(`div`,{className:`markdown-content prose prose-sm dark:prose-invert max-w-none text-sm leading-relaxed`,children:(0,k.jsx)(D,{components:E,children:a.body})})})}),(0,k.jsxs)(`div`,{className:`border-t border-border/70 bg-muted/20 px-4 py-3 shrink-0`,children:[(0,k.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-x-6 gap-y-2 text-xs`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,k.jsx)(n,{className:`h-3 w-3 shrink-0`}),(0,k.jsx)(`span`,{children:d})]}),(0,k.jsx)(`div`,{className:`flex items-center gap-1.5`,children:(0,k.jsx)(`span`,{className:C(`rounded border px-1.5 py-0.5 text-[10px] font-semibold uppercase`,f),children:a.priority||`normal`})}),(0,k.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,k.jsx)(p,{className:`h-3 w-3 shrink-0`}),(0,k.jsx)(`span`,{className:`truncate`,title:a.from,children:a.from})]}),(0,k.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[h.scope===`session`?(0,k.jsx)(x,{className:`h-3 w-3 shrink-0 text-warning`}):(0,k.jsx)(b,{className:`h-3 w-3 shrink-0 text-primary`}),(0,k.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide shrink-0`,children:r(`activity:mailbox.scopeLabel`)}),(0,k.jsx)(`span`,{className:`truncate`,children:y})]}),(0,k.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,k.jsx)(u,{className:`h-3 w-3 shrink-0`}),(0,k.jsx)(`span`,{children:M(a.timestamp)})]}),a.replyTo&&(0,k.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground col-span-2`,children:[(0,k.jsx)(m,{className:`h-3 w-3 shrink-0`}),(0,k.jsx)(`span`,{className:`truncate`,children:r(`activity:mailbox.replyTo`,{id:a.replyTo})})]}),a.completed&&a.completedBy&&(0,k.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground col-span-2`,children:[(0,k.jsx)(l,{className:`h-3 w-3 shrink-0 text-success`}),(0,k.jsx)(`span`,{children:a.completedAt?r(`activity:mailbox.completedByAt`,{name:a.completedBy,time:M(a.completedAt)}):r(`activity:mailbox.completedBy`,{name:a.completedBy})})]}),a.outcome&&(0,k.jsxs)(`div`,{className:`flex items-start gap-1.5 text-muted-foreground col-span-2 sm:col-span-4`,children:[(0,k.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide shrink-0 mt-0.5`,children:r(`activity:mailbox.outcome`)}),(0,k.jsx)(`span`,{children:a.outcome})]}),a.taskContext&&(0,k.jsxs)(`div`,{className:`flex items-start gap-1.5 text-muted-foreground col-span-2 sm:col-span-4`,children:[(0,k.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide shrink-0 mt-0.5`,children:r(`activity:mailbox.task`)}),(0,k.jsx)(`span`,{children:a.taskContext})]})]}),Object.keys(a.readBy??{}).length>0&&(0,k.jsx)(`div`,{className:`mt-3 pt-3 border-t border-border/50`,children:(0,k.jsx)(F,{readBy:a.readBy})})]})]})})}export{I as MailboxDetailView};