@wrongstack/webui 0.295.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 (153) 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-tGlXeqV5.js → AnalyticsDashboard-CZ8KAg7h.js} +1 -1
  4. package/dist/assets/{AudienceMemoryPanel-D45M-Fr6.js → AudienceMemoryPanel-N6ErXDAb.js} +2 -2
  5. package/dist/assets/{ChangesView-Otr6kwYr.js → ChangesView-fVxtWQ07.js} +1 -1
  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-C7H16wDN.js → ConfirmModal-BvW6_eIc.js} +1 -1
  10. package/dist/assets/{CronJobsPanel-CT6XRgmQ.js → CronJobsPanel-C4zvyecc.js} +1 -1
  11. package/dist/assets/{DebugDashboard-DZy3VUpn.js → DebugDashboard-Z7ZFkSFX.js} +1 -1
  12. package/dist/assets/{DesignGalleryView-CQkuFsfj.js → DesignGalleryView-DIsg05FX.js} +1 -1
  13. package/dist/assets/{GoalView-CTqdYc-z.js → GoalView-pBKJcLBt.js} +1 -1
  14. package/dist/assets/KanbanView-qzKvGeMx.js +3 -0
  15. package/dist/assets/{LazyMarkdown-DWlQpo_8.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-fGNsJUXK.js → ModelPicker-DOXb0iz4.js} +1 -1
  19. package/dist/assets/OfficeMapPanel-BVDeIWuD.js +4 -0
  20. package/dist/assets/{ProcessMonitor-BtgVvQgx.js → ProcessMonitor-Ci000o1n.js} +1 -1
  21. package/dist/assets/{QueuePanel-BGSxmdqf.js → QueuePanel-63vvbJOy.js} +1 -1
  22. package/dist/assets/{RefreshDebugView-B_wCBpFb.js → RefreshDebugView-8Sivo34V.js} +1 -1
  23. package/dist/assets/SddHub-DW97GpcS.js +2 -0
  24. package/dist/assets/{SessionsDashboard-DLOhC9JZ.js → SessionsDashboard-DhNaepDJ.js} +1 -1
  25. package/dist/assets/SetupScreen-BewutFxF.js +1 -0
  26. package/dist/assets/SkillDetailView-d39kknmg.js +3 -0
  27. package/dist/assets/{SpecsView-Dh9YG8Id.js → SpecsView-BOp0sUME.js} +1 -1
  28. package/dist/assets/TechStackView-DfFfTJVR.js +1 -0
  29. package/dist/assets/{TerminalPanel-3rZfmUfb.js → TerminalPanel-663hC2Jc.js} +1 -1
  30. package/dist/assets/Toaster-YMBi0Ssd.js +1 -0
  31. package/dist/assets/activity-3HtRx2SK.js +5 -0
  32. package/dist/assets/activity-BGlYr63p.js +5 -0
  33. package/dist/assets/activity-BolwRvqr.js +5 -0
  34. package/dist/assets/activity-C8BMSvRx.js +5 -0
  35. package/dist/assets/activity-CM8z-okz.js +5 -0
  36. package/dist/assets/activity-HfL12UVp.js +5 -0
  37. package/dist/assets/activity-Xd77MZv_.js +5 -0
  38. package/dist/assets/{button-GVbauxIJ.js → button-5TIs9T5p.js} +1 -1
  39. package/dist/assets/{chat-store-BEcTB7SD.js → chat-store-fBghgjNK.js} +2 -2
  40. package/dist/assets/{codemap-activity-store-DrrI6G7M.js → codemap-activity-store-C5DyqUoZ.js} +1 -1
  41. package/dist/assets/codemap-index-store-p2tz1Laz.js +1 -0
  42. package/dist/assets/{dialog-BjPQYovj.js → dialog-BkCs93Vo.js} +1 -1
  43. package/dist/assets/{empty-state-DJc37Wg1.js → empty-state-DrJ4uVh8.js} +1 -1
  44. package/dist/assets/{i18n-c37VNlP9.js → i18n-Cjk0Ya0G.js} +2 -2
  45. package/dist/assets/index-D0zt9ziw.css +1 -0
  46. package/dist/assets/index-HYvJnpTs.js +126 -0
  47. package/dist/assets/{input-BVi5hYQz.js → input-dEFwkTqb.js} +1 -1
  48. package/dist/assets/{mailbox-store-DSvN5ZEo.js → mailbox-store-DC7x_eml.js} +1 -1
  49. package/dist/assets/progress-ring-CGN0o9DE.js +1 -0
  50. package/dist/assets/{roster-ws-BD-ATeja.js → roster-ws-GsDcHg-w.js} +1 -1
  51. package/dist/assets/{session-store-K_ozfq0o.js → session-store-DGtTSpPv.js} +1 -1
  52. package/dist/assets/{shared-BQ9yQXDx.js → shared-C_yjayIp.js} +1 -1
  53. package/dist/assets/stores-BSWgxKNz.js +6 -0
  54. package/dist/assets/{ui-store-DxFtiYFb.js → ui-store-DPNSalc-.js} +1 -1
  55. package/dist/assets/useWebSocket-BBOEYTRy.js +28 -0
  56. package/dist/assets/{utils-DvgvNCoT.js → utils-YTsIExHc.js} +1 -1
  57. package/dist/assets/{vendor-BmsAdDhb.js → vendor-B8C0AAAG.js} +27 -27
  58. package/dist/assets/{view-navigation-D8lN47bJ.js → view-navigation-CV5XT76I.js} +1 -1
  59. package/dist/assets/ws-client-Cc6w_0zh.js +1 -0
  60. package/dist/components/AgentRosterView.d.ts.map +1 -1
  61. package/dist/components/ChatInput.d.ts.map +1 -1
  62. package/dist/components/ChronicleDashboard.d.ts.map +1 -1
  63. package/dist/components/CodeMap.d.ts +6 -0
  64. package/dist/components/CodeMap.d.ts.map +1 -1
  65. package/dist/components/ContextDashboard.d.ts.map +1 -1
  66. package/dist/components/CronTrigger.d.ts +1 -1
  67. package/dist/components/CronTrigger.d.ts.map +1 -1
  68. package/dist/components/FileActivityDrawer.d.ts +14 -0
  69. package/dist/components/FileActivityDrawer.d.ts.map +1 -1
  70. package/dist/components/FleetMonitor.d.ts.map +1 -1
  71. package/dist/components/KanbanDecompositionPanel.d.ts +28 -0
  72. package/dist/components/KanbanDecompositionPanel.d.ts.map +1 -0
  73. package/dist/components/KanbanTaskTree.d.ts +13 -0
  74. package/dist/components/KanbanTaskTree.d.ts.map +1 -0
  75. package/dist/components/KanbanVerificationDashboard.d.ts +12 -0
  76. package/dist/components/KanbanVerificationDashboard.d.ts.map +1 -0
  77. package/dist/components/KanbanView.d.ts +17 -1
  78. package/dist/components/KanbanView.d.ts.map +1 -1
  79. package/dist/components/OfficeMapCanvas.d.ts.map +1 -1
  80. package/dist/components/QueuePanel.d.ts.map +1 -1
  81. package/dist/components/RefinePanel.d.ts +10 -3
  82. package/dist/components/RefinePanel.d.ts.map +1 -1
  83. package/dist/components/SddBoardView.d.ts.map +1 -1
  84. package/dist/components/SddTaskDrawer.d.ts.map +1 -1
  85. package/dist/components/SearchOverlay.d.ts.map +1 -1
  86. package/dist/components/SettingsPanel/BrainSection.d.ts.map +1 -1
  87. package/dist/components/SettingsPanel/ChimeraSettingsPanel.d.ts.map +1 -1
  88. package/dist/components/SettingsPanel/index.d.ts.map +1 -1
  89. package/dist/components/SidePanel/AgentsPanel.d.ts.map +1 -1
  90. package/dist/components/SidePanel/SessionPanel.d.ts.map +1 -1
  91. package/dist/components/TaskVerificationSection.d.ts +15 -0
  92. package/dist/components/TaskVerificationSection.d.ts.map +1 -0
  93. package/dist/components/TechStackView/DependencyDetail.d.ts +2 -1
  94. package/dist/components/TechStackView/DependencyDetail.d.ts.map +1 -1
  95. package/dist/components/TechStackView/DependencyTable.d.ts +2 -1
  96. package/dist/components/TechStackView/DependencyTable.d.ts.map +1 -1
  97. package/dist/components/TechStackView/index.d.ts.map +1 -1
  98. package/dist/components/TechStackView/shared.d.ts +37 -4
  99. package/dist/components/TechStackView/shared.d.ts.map +1 -1
  100. package/dist/components/activity-bar/index.d.ts.map +1 -1
  101. package/dist/components/agents/AgentDetailSection.d.ts.map +1 -1
  102. package/dist/components/agents/AgentRosterCard.d.ts.map +1 -1
  103. package/dist/components/agents/FleetSummaryBar.d.ts.map +1 -1
  104. package/dist/components/codemap-model.d.ts +9 -0
  105. package/dist/components/codemap-model.d.ts.map +1 -1
  106. package/dist/components/ui/progress-ring.d.ts +10 -0
  107. package/dist/components/ui/progress-ring.d.ts.map +1 -0
  108. package/dist/hooks/ws-handlers/session-handlers.d.ts.map +1 -1
  109. package/dist/hooks/ws-handlers.d.ts.map +1 -1
  110. package/dist/index.css +7 -7
  111. package/dist/index.css.map +1 -1
  112. package/dist/index.html +23 -22
  113. package/dist/index.js +6176 -4279
  114. package/dist/index.js.map +4 -4
  115. package/dist/lib/kanban-verification.d.ts +52 -0
  116. package/dist/lib/kanban-verification.d.ts.map +1 -0
  117. package/dist/stores/codemap-index-store.d.ts +9 -0
  118. package/dist/stores/codemap-index-store.d.ts.map +1 -0
  119. package/dist/stores/kanban-store.d.ts +4 -0
  120. package/dist/stores/kanban-store.d.ts.map +1 -1
  121. package/dist/stores/local-prefs.d.ts.map +1 -1
  122. package/dist/stores/specs-store.d.ts +4 -0
  123. package/dist/stores/specs-store.d.ts.map +1 -1
  124. package/dist/stores/ui-store.d.ts +3 -1
  125. package/dist/stores/ui-store.d.ts.map +1 -1
  126. package/dist/types.d.ts +120 -1
  127. package/dist/types.d.ts.map +1 -1
  128. package/package.json +7 -7
  129. package/dist/assets/AgentRosterView-y-MCHghy.js +0 -7
  130. package/dist/assets/ChronicleDashboard-BvsfI25e.js +0 -1
  131. package/dist/assets/CodeEditor-DtD0-wwy.js +0 -1
  132. package/dist/assets/CodeMap-CVmu16Ec.js +0 -1
  133. package/dist/assets/KanbanView-DryFcAzY.js +0 -3
  134. package/dist/assets/MailboxDetailView-CsI_6HsE.js +0 -1
  135. package/dist/assets/MemoryManager-D_bjR09v.js +0 -1
  136. package/dist/assets/OfficeMapPanel-KRrwpmvi.js +0 -4
  137. package/dist/assets/SddHub-BryXNdFd.js +0 -2
  138. package/dist/assets/SetupScreen-DsXgzxA1.js +0 -1
  139. package/dist/assets/SkillDetailView-ChyQLtrl.js +0 -3
  140. package/dist/assets/TechStackView-RJGVF44_.js +0 -1
  141. package/dist/assets/Toaster-BzC_AdG5.js +0 -1
  142. package/dist/assets/activity-7VmgGy-T.js +0 -5
  143. package/dist/assets/activity-BzwApar4.js +0 -5
  144. package/dist/assets/activity-CCUWlVKh.js +0 -5
  145. package/dist/assets/activity-DAHFiOfU.js +0 -5
  146. package/dist/assets/activity-DkkpH2Tf.js +0 -5
  147. package/dist/assets/activity-DqsX-GMs.js +0 -5
  148. package/dist/assets/activity-t0PmZ94i.js +0 -5
  149. package/dist/assets/index-196U0qsu.js +0 -125
  150. package/dist/assets/index-n_-BWskP.css +0 -1
  151. package/dist/assets/stores-DVhvmaer.js +0 -6
  152. package/dist/assets/useWebSocket-kb2VPjLc.js +0 -28
  153. package/dist/assets/ws-client-BydCS6yi.js +0 -1
@@ -1,4 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{$i as t,Bn as n,Cn as r,Cr as i,Dn as a,Fn as o,Jt as s,Kt as c,Li as l,Mn as u,Nn as d,Nr as f,Nt as p,Oi as m,Or as h,Pn as g,Qn as _,Tt as v,Un as y,Yr as b,Zr as x,_ as S,a as ee,aa as C,at as w,bi as te,c as T,ca as E,ci as ne,ct as D,d as re,ei as O,f as ie,h as k,hn as ae,i as oe,ir as A,it as se,ji as ce,l as le,li as j,lr as ue,lt as de,m as fe,mt as M,na as N,o as P,oi as pe,ot as F,p as me,pt as he,qt as ge,r as _e,s as ve,si as I,tt as ye,u as be,ua as xe,ur as Se,v as Ce,wr as we,xi as Te}from"./vendor-BmsAdDhb.js";import"./i18n-c37VNlP9.js";import{s as Ee}from"./ws-client-BydCS6yi.js";import{t as L}from"./utils-DvgvNCoT.js";import{t as De}from"./session-store-K_ozfq0o.js";import{b as Oe,c as R,g as ke,l as Ae}from"./stores-DVhvmaer.js";import{r as je}from"./mailbox-store-DSvN5ZEo.js";import{f as z}from"./markdown-L6DLSM7f.js";import{c as B,s as V,t as H}from"./LazyMarkdown-DWlQpo_8.js";import{C as Me,b as Ne,p as Pe,w as Fe}from"./index-196U0qsu.js";var U=e(xe(),1);function Ie(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function W(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function G(e){return typeof e==`string`&&e.trim()?e.trim():void 0}function K(e,t){for(let n of t){let t=G(e[n]);if(t)return t}}function q(e,t){for(let n of t){let t=W(e[n]);if(t!==void 0)return t}}function Le(e){return e.split(/[\\/]/).filter(Boolean).pop()??e}function Re(e){return e?e.split(/\r?\n/).length:0}function ze(e){let t=0,n=0;for(let r of e.split(/\r?\n/))r.startsWith(`+++`)||r.startsWith(`---`)||(r.startsWith(`+`)&&(t+=1),r.startsWith(`-`)&&(n+=1));return t||n?{added:t,removed:n}:null}function Be(e){let t=e.split(/\r?\n/,1)[0]?.trim()??e;return t.length>72?`${t.slice(0,69)}…`:t}function Ve(e){let t=e.toLowerCase().replace(/[.:/-]+/g,`_`);return/^(read|view|open_file|read_file)|file_read/.test(t)?`read`:/^(write|create|save)|file_write/.test(t)?`write`:/edit|update|patch|replace|apply_patch/.test(t)?`edit`:/bash|shell|terminal|exec|command|powershell|cmd/.test(t)?`terminal`:/fetch|browser|browse|http|url|web/.test(t)?`web`:/search|grep|find|glob|query/.test(t)?`search`:/memory|recall|remember/.test(t)?`memory`:`other`}function He(e,t){let n=(Array.isArray(e.fileTargets)?e.fileTargets:[]).flatMap(e=>{let t=Ie(e),n=K(t,[`filePath`,`file_path`,`path`]);return n?[{filePath:n,operation:G(t.operation),line:q(t,[`line`,`startLine`,`start_line`]),endLine:q(t,[`endLine`,`end_line`])}]:[]});if(n.length>0)return n;let r=K(t,[`file_path`,`filePath`,`path`,`filename`,`target_file`,`targetFile`]);return r?[{filePath:r,line:q(t,[`line`,`start_line`,`startLine`,`offset`]),endLine:q(t,[`end_line`,`endLine`])}]:[]}function Ue(e,t){let n=e?.line??q(t,[`line`,`start_line`,`startLine`,`offset`]),r=e?.endLine??q(t,[`end_line`,`endLine`]),i=q(t,[`limit`,`line_count`,`lineCount`]);return r===void 0&&n!==void 0&&i!==void 0&&i>0&&(r=n+i-1),n!==void 0&&r!==void 0?{start:n,end:r,label:`L${n}–${r}`}:n===void 0?{}:{start:n,label:`L${n}`}}function We(e,t,n,r,i,a){let o=Ue(a,n),s=a?.filePath??K(n,[`file_path`,`filePath`,`path`,`filename`]),c=s?Le(s):void 0;if(e===`read`)return{target:s,summary:i===void 0?o.label?`${o.label} queued to read`:`Reading file`:`${i.toLocaleString()} lines read`,lineLabel:o.label};if(e===`write`){let e=K(n,[`content`,`text`,`data`]),t=q(r,[`inputLines`])??(e?Re(e):void 0);return{target:s,summary:t===void 0?`Writing file`:`${t.toLocaleString()} lines written`,lineLabel:o.label}}if(e===`edit`){let e=K(n,[`patch`,`diff`]),t=e?ze(e):null,i=K(n,[`old_string`,`oldString`,`search`]),a=K(n,[`new_string`,`newString`,`replacement`]),c=q(r,[`addedLines`]),l=q(r,[`removedLines`]),u=q(r,[`oldLines`]),d=q(r,[`newLines`]);return{target:s,summary:t||c!==void 0||l!==void 0?`+${t?.added??c??0} / −${t?.removed??l??0} lines`:i!==void 0||a!==void 0||u!==void 0||d!==void 0?`${i?Re(i):u??0} → ${a?Re(a):d??0} lines`:o.label?`${o.label} updated`:`Updating file`,lineLabel:o.label}}if(e===`terminal`){let e=K(n,[`command`,`cmd`,`script`,`shell`])??t;return{summary:Be(e),target:e}}if(e===`web`){let e=K(n,[`url`,`href`,`uri`]),t=K(n,[`query`,`q`,`search`]);return{target:e??t,summary:e?`Fetched ${e}`:t?`Looked up “${t}”`:`Went online`}}if(e===`search`){let e=K(n,[`query`,`pattern`,`q`,`search`])??c;return{target:s??e,summary:e?`Searched “${e}”`:`Searching project`}}if(e===`memory`){let e=K(n,[`query`,`text`,`key`]);return{target:e,summary:e?`Recalled “${e}”`:`Checking memory`}}return{target:s,summary:c?`${t} · ${c}`:t}}function Ge(e,t){let n=G(t.name)??G(t.toolName);if(n)return n;if(e.kind===`agent:tool`)return e.target??void 0;if(e.kind.startsWith(`tool:`))return e.source}function Ke(e,t,n){return G(t.agentId)??G(t.subagentId)??(e.kind===`agent:tool`?e.source:void 0)??(e.source!==n&&e.source!==`filesystem`?e.source:void 0)??`leader`}function qe(e){return G(e.parentSessionId)??G(e.sessionId)}function Je(e,t){return e.kind===`tool:started`||e.kind===`tool:progress`?`running`:t.ok===!1?`failed`:`succeeded`}function Ye(e){if(![`tool:started`,`tool:progress`,`tool:executed`,`agent:tool`].includes(e.kind))return null;let t=Ie(e.data),n=Ge(e,t);if(!n)return null;let r=Ke(e,t,n),i=t.input,a=Ie(i),o=He(t,a),s=W(t.outputLines),c=Ve(n),l=We(c,n,a,t,s,o[0]),u=G(t.id),d=Math.floor(e.timestamp/2e3),f=Je(e,t),p=W(t.durationMs);return{id:u?`${r}:${u}`:`${r}:${n}:${d}`,agentId:r,agentName:G(t.agentName),sessionId:qe(t),toolName:n,kind:c,status:f,startedAt:f===`running`?e.timestamp:Math.max(0,e.timestamp-(p??0)),...f===`running`?{}:{completedAt:e.timestamp},durationMs:p,target:l.target,summary:l.summary,lineLabel:l.lineLabel,outputLines:s,outputBytes:W(t.outputBytes),outputTokens:W(t.outputTokens),input:i,output:G(t.output),fileTargets:o,raw:e.raw??t}}function Xe(e,t,n){return e?.length?tt(e.map(e=>({id:`snapshot:${n??`session`}:${t}:${e.id}`,kind:`tool:executed`,timestamp:e.completedAt,source:t,target:e.name,label:e.name,data:{...e,agentId:t,sessionId:n},flowGroup:`agent:${t}`})),t,n):[]}function Ze(e){return e?.length?e.map(e=>({id:e.id,direction:e.direction,from:e.from,to:e.to,type:e.type,subject:e.subject,body:``,priority:`normal`,timestamp:new Date(e.at).toISOString(),timestampMs:e.at,unread:e.direction===`incoming`})).sort((e,t)=>t.timestampMs-e.timestampMs).slice(0,12):[]}function Qe(e,t,n=3e4){let r=new Map;e.forEach((e,t)=>{for(let n of[e.agent.serverId,e.agent.mailboxId,e.agent.name]){let e=J(n);e&&!r.has(e)&&r.set(e,t)}});let i=new Set,a=[];for(let o of e){let e=o.mail[0];if(!e||i.has(e.id)||t-e.timestampMs>n)continue;let s=r.get(J(e.from)),c=r.get(J(e.to));s===void 0||c===void 0||s===c||(i.add(e.id),a.push({id:e.id,mail:e,fromIndex:s,toIndex:c}))}return a}function $e(e,t){return e.toLowerCase()===t.toLowerCase()}function J(e){return e?.trim().toLowerCase()??``}function et(e,t,n){let r=new Set([t.serverId,t.mailboxId,t.name].map(J).filter(e=>e.length>0)),i=n?`@session:${J(n)}`:``,a=J(t.role),o=J(t.serverId)===`leader`||J(t.serverId).startsWith(`leader@`)||a===`lead`||a===`leader`;return e.flatMap(e=>{let t=J(e.from),n=J(e.to),a=r.has(t),s=n===`*`||n===`all`||i.length>0&&n===i,c=(e.audience!==`leaders`||o)&&(r.has(n)||o&&s);if(!c&&!a)return[];let l=Date.parse(e.timestamp);return[{...e,direction:c?`incoming`:`outgoing`,timestampMs:Number.isFinite(l)?l:0,unread:c&&!Object.keys(e.readBy??{}).some(e=>r.has(J(e)))}]}).sort((e,t)=>t.timestampMs-e.timestampMs).slice(0,8)}function tt(e,t,n){let r=new Map;for(let i=e.length-1;i>=0;--i){let a=e[i];if(!a)continue;let o=Ye(a);if(!o||!$e(o.agentId,t)||n&&o.sessionId&&o.sessionId!==n)continue;let s=r.get(o.id);r.set(o.id,s?{...s,...o,startedAt:Math.min(s.startedAt,o.startedAt),fileTargets:o.fileTargets.length>0?o.fileTargets:s.fileTargets,input:o.input??s.input,output:o.output??s.output,raw:o.raw??s.raw}:o)}let i=[...r.values()].sort((e,t)=>(t.completedAt??t.startedAt)-(e.completedAt??e.startedAt));return i.filter((e,t)=>e.input!==void 0||e.fileTargets.length>0||e.output!==void 0||!i.some((n,r)=>r!==t&&n.toolName===e.toolName&&(n.input!==void 0||n.fileTargets.length>0||n.output!==void 0)&&Math.abs((n.completedAt??n.startedAt)-(e.completedAt??e.startedAt))<2500))}function nt(e,t,n){let r=Ve(t),i={read:`Reading a file`,write:`Writing a file`,edit:`Updating code`,terminal:`Running a command`,web:`Working online`,search:`Searching project`,memory:`Checking memory`,other:t};return{id:`${e}:live:${t}`,agentId:e,sessionId:n,toolName:t,kind:r,status:`running`,startedAt:Date.now(),summary:i[r],fileTargets:[]}}function rt(e){return e==null||!Number.isFinite(e)?`0`:e<1e3?String(Math.round(e)):e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(1)}M`}function it(e,t){if(!e)return`never`;let n=Date.parse(e);if(!Number.isFinite(n))return`never`;let r=Math.max(0,Math.round((t-n)/1e3));return r<60?`${r}s ago`:r<3600?`${Math.round(r/60)}m ago`:r<86400?`${Math.round(r/3600)}h ago`:`${Math.round(r/86400)}d ago`}function at(e,t){if(!e)return``;let n=Date.parse(e);if(!Number.isFinite(n))return``;let r=Math.max(0,Math.round((t-n)/1e3));return r<60?`${r}s`:r<3600?`${Math.round(r/60)}m`:`${Math.round(r/3600)}h`}function ot(e){if(!e)return;let t=e.split(`/`);return t[t.length-1]?.slice(0,18)}function st(e,t=56){if(!e)return;let n=e.replace(/\s+/g,` `).trim();if(n)return n.length<=t?n:t<=1?`…`:`${n.slice(0,t-1).trimEnd()}…`}function ct(e,t){if(e.length===0)return{positions:new Map,columns:0,rows:0,columnWidth:380};let n=Math.max(1,...e.map(e=>e.agentCount)),r=Math.max(380,Math.min(3,n)*190+80),i=e=>270+Math.max(1,...e.map(e=>Math.ceil(Math.max(1,e.agentCount)/3)))*150,a=Math.max(320,t.width),o=Math.max(240,t.height),s=1,c=-1/0,l=1/0;for(let t=1;t<=e.length;t+=1){let n=[];for(let r=0;r<e.length;r+=t)n.push(i(e.slice(r,r+t)));let u=n.length,d=Math.max(660,Math.min(t,e.length)*r),f=320+n.reduce((e,t)=>e+t,0)+Math.max(0,u-1)*100,p=Math.min(a/d,o/f),m=Math.abs(Math.log(d/f/(a/o)));(p>c+1e-9||Math.abs(p-c)<=1e-9&&m<l)&&(s=t,c=p,l=m)}let u=new Map,d=370;for(let t=0;t<e.length;t+=s){let n=e.slice(t,t+s);n.forEach((e,t)=>{u.set(e.id,{x:600+(t-(n.length-1)/2)*r,y:d})}),d+=i(n)+100}return{positions:u,columns:s,rows:Math.ceil(e.length/s),columnWidth:r}}function lt(e,t,n,r=640){let i=Math.min(3,n),a=Math.floor(t/i),o=t%i;return{x:e-(Math.min(i,n-a*i)-1)*190/2+o*190,y:r+a*150}}function ut(e){return e===`tui`?`tui`:e===`repl`||e===`cli`?`repl`:`webui`}function dt(e){return e===`tui`?`TUI`:e===`repl`?`REPL`:`WebUI`}function ft(e){switch(e){case`running`:case`active`:return`active`;case`idle`:return`idle`;case`completed`:return`completed`;case`failed`:case`error`:return`error`;case`stopped`:return`offline`;default:return`idle`}}function pt(e){if(e)return e.split(`/`).filter(Boolean).pop()??e}function mt(e){let t=pt(e)??e??``;return t.length>10?`…${t.slice(-8)}`:t}function ht(e,t){let n=pt(t);if(n)return e.find(e=>pt(e.sessionId)===n)}function gt(e,t){let n=ft(t.status);return{officeId:`${e}__agent-${t.id}`,serverId:t.id,name:t.name??t.id,status:n,iteration:t.iteration??0,toolCalls:t.toolCalls??0,costUsd:t.costUsd??0,tokensIn:t.tokensIn??0,tokensOut:t.tokensOut??0,ctxPct:t.ctxPct,model:t.model,currentTool:t.currentTool,currentTask:t.description,taskId:t.taskId,presenceSource:`fleet`}}function _t(e,t){return e===`cli`?`CLI`:e===`repl`?`REPL`:dt(t)}function vt(e,t,n=[],r=new Map,i=Date.now()){let a=new Set,o=[];for(let n of e){let e=ut(n.clientType),r=_t(n.clientType,e),i=`client-${n.pid??n.sessionId}`,s=[],c=!1;for(let e of n.agents){a.add(e.id);let n=t.get(e.id),r=ft(n?.status??e.status);(r===`active`||r===`streaming`)&&(c=!0),s.push({officeId:`${i}__agent-${e.id}`,serverId:e.id,name:n?.name??e.name??e.id,status:r,iteration:n?.iteration??e.iterations??0,toolCalls:n?.toolCalls??e.toolCalls??0,costUsd:n?.costUsd??e.costUsd??0,tokensIn:n?.tokensIn??e.tokensIn??0,tokensOut:n?.tokensOut??e.tokensOut??0,ctxPct:n?.ctxPct??e.ctxPct,model:n?.model??e.model,lastActivityAt:e.lastActivityAt,currentTool:n?.currentTool??e.currentTool,currentTask:e.currentTask??n?.description,taskId:e.taskId??n?.taskId,recentTools:e.recentTools,recentMail:e.recentMail,activity:e.activity,presenceSource:`registry`})}let l=n.status===`closing`||n.status===`stale`||n.status===`lost`?`offline`:c?`active`:`idle`,u=n.agents.find(e=>e.id===`leader`);o.push({id:i,type:e,label:`${r} · ${n.pid?`PID ${n.pid}`:mt(n.sessionId)}`,sublabel:[`session ${mt(n.sessionId)}`,n.gitBranch?`⎇ ${n.gitBranch}`:``,n.workingDir?n.workingDir.split(/[\\/]/).filter(Boolean).pop():``].filter(Boolean).join(` · `),status:l,sessionId:n.sessionId,pid:n.pid,branch:n.gitBranch,workingDir:n.workingDir,startedAt:n.startedAt,lastHeartbeatAt:n.lastHeartbeatAt,latestPrompt:u?.latestPrompt,latestPromptAt:u?.latestPromptAt,activeInstruction:u?.status===`running`||u?.status===`streaming`?u.latestPrompt??u.currentTask:void 0,todos:u?.todos,agents:s})}for(let e of n.filter(e=>e.online)){let t=ht(o,e.sessionId);if(!t)continue;let n=e.name.trim().toLowerCase(),r=t.agents.find(t=>t.serverId===e.agentId||t.name.trim().toLowerCase()===n);r&&(a.add(e.agentId),r.mailboxId=e.agentId,r.role=e.role,r.currentTask=r.currentTask??e.currentTask,r.currentTool=r.currentTool??e.currentTool)}let s=[...t.values()].filter(e=>!a.has(e.id)),c,l=()=>{if(c)return c;let e=o.find(e=>e.type===`webui`);return e?(c=e,e):(c={id:`client-self`,type:`webui`,label:`This WebUI`,sublabel:`Web UI`,status:`idle`,agents:[]},o.push(c),c)};for(let e of s){let t=ht(o,e.sessionId)??l(),n=gt(t.id,e);(n.status===`active`||n.status===`streaming`)&&t.status!==`offline`&&(t.status=`active`),t.agents.push(n),a.add(e.id)}for(let[e,t]of r){if(a.has(e)||i-t.finishedAt>9e5)continue;let n=ht(o,t.agent.sessionId);n&&n.agents.push(gt(n.id,t.agent))}return o.length===0&&o.push({id:`client-self`,type:`webui`,label:`This WebUI`,sublabel:`Web UI · connecting…`,status:`idle`,agents:[]}),o}function yt(e){return e.startsWith(`tool`)?`hsl(var(--warning))`:e.startsWith(`mailbox`)?`hsl(var(--info))`:e.startsWith(`provider`)?`hsl(var(--primary))`:e.startsWith(`agent`)||e.startsWith(`subagent`)?`hsl(var(--success))`:e.includes(`error`)?`hsl(var(--destructive))`:`hsl(var(--primary))`}var bt=new Set([`completed`,`failed`,`timeout`,`stopped`]);function xt(e){let t=(0,U.useRef)(new Map).current;return(0,U.useMemo)(()=>{let n=Date.now(),r=new Set;for(let i of e.values())if(r.add(i.id),bt.has(i.status)){let e=t.get(i.id);e?e.agent=i:t.set(i.id,{agent:i,finishedAt:i.completedAt??n})}else t.delete(i.id);for(let[e,n]of[...t.entries()])!r.has(e)&&!bt.has(n.agent.status)&&t.set(e,{agent:{...n.agent,status:`stopped`},finishedAt:n.finishedAt});for(let[e,r]of t)n-r.finishedAt>9e5&&t.delete(e);return{map:t,now:n}},[e,t])}var Y=ye(),St=[`bot`,`cactus`,`duck`,`radio`],Ct={leader:`plum`,builder:`ocean`,researcher:`mint`,reviewer:`rose`,planner:`amber`,operator:`graphite`},wt={leader:0,builder:1,researcher:2,reviewer:3,planner:4,operator:5},Tt={read:ge,write:f,edit:f,terminal:p,web:b,search:i,memory:d,other:pe},Et={leader:ce,builder:pe,researcher:ge,reviewer:m,planner:y,operator:p};function Dt(e){if(e.serverId===`leader`||e.serverId.startsWith(`leader@`))return`leader`;let t=[e.role,e.name,e.currentTask].filter(Boolean).join(` `).toLowerCase();return/review|critic|audit|security|test|qa|verify|checker/.test(t)?`reviewer`:/research|analyst|explor|investig|search|hunter|recon/.test(t)?`researcher`:/plan|architect|design|coordinat|strateg|spec/.test(t)?`planner`:/build|implement|code|develop|engineer|refactor|fix|frontend|backend/.test(t)?`builder`:`operator`}function Ot(e,t){let n=2166136261;for(let t=0;t<e.length;t+=1)n^=e.charCodeAt(t),n=Math.imul(n,16777619);let r=n>>>0;return{palette:Ct[t],layout:r%4,clutter:Math.floor(r/4)%3,avatar:wt[t],motion:Math.floor(r/31)%4,charm:St[Math.floor(r/47)%St.length]}}function kt(e,t=22){let n=e.split(`/`).filter(Boolean).pop()??e;return n.length>t?`${n.slice(0,t-1)}…`:n}function At(e,t=46){if(!e||e.length<=t)return e;let n=e.split(/[\\/]/).slice(-2).join(`/`);return n.length<=t?`…/${n}`:`…${e.slice(-(t-1))}`}function jt(e,t){let n=Math.max(0,Math.floor((t-e)/1e3));if(n<5)return`now`;if(n<60)return`${n}s`;let r=Math.floor(n/60);return r<60?`${r}m`:`${Math.floor(r/60)}h`}function Mt(e){return e===void 0?`—`:e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(+(e<1e4))} s`}function Nt(e,t){if(!e)return`—`;let n=Date.parse(e);if(!Number.isFinite(n))return`—`;let r=Math.max(0,Math.floor((t-n)/1e3));return r<60?`${r}s`:r<3600?`${Math.floor(r/60)}m`:r<86400?`${Math.floor(r/3600)}h`:`${Math.floor(r/86400)}d`}function Pt(e){if(e===void 0)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Ft(e){let t=new Set,n=new Set,r=new Set,i=0,a=0,o={files:0,reads:0,writes:0,edits:0,linesAdded:0,linesRemoved:0,terminalCalls:0,incomingMail:0,outgoingMail:0};for(let s of e){let e=s.agent.activity;for(let n of e?.filesTouched??[])t.add(n);o.reads+=e?.reads??0,o.writes+=e?.writes??0,o.edits+=e?.edits??0,o.linesAdded+=e?.linesAdded??0,o.linesRemoved+=e?.linesRemoved??0,o.terminalCalls+=e?.terminalCalls??0,i+=e?.mailReceived??0,a+=e?.mailSent??0;for(let e of s.mail)(e.direction===`incoming`?n:r).add(e.id)}return o.files=t.size,o.incomingMail=Math.max(i,n.size),o.outgoingMail=Math.max(a,r.size),o}function It(e,t,n){return n.map((n,r)=>({...nt(e.serverId,n.name,t.sessionId),id:`${e.serverId}:log:${n.at}:${r}`,kind:Ve(n.name),status:n.ok?`succeeded`:`failed`,startedAt:Math.max(0,n.at-n.durationMs),completedAt:n.at,durationMs:n.durationMs,summary:n.ok?`${n.name} completed`:`${n.name} failed`}))}function Lt(...e){let t=[];for(let n of e.flat()){let e=n.completedAt??n.startedAt;t.some(t=>(t.id===n.id||t.toolName===n.toolName)&&Math.abs((t.completedAt??t.startedAt)-e)<2500)||t.push(n)}return t.sort((e,t)=>(t.completedAt??t.startedAt)-(e.completedAt??e.startedAt))}function Rt(...e){let t=new Map;for(let n of e.flat())t.set(n.id,n);return[...t.values()].sort((e,t)=>t.timestampMs-e.timestampMs).slice(0,12)}function zt({kind:e,active:t}){let n=Tt[e];return(0,Y.jsxs)(`span`,{className:L(`agent-office__tool-glyph`,`is-${e}`,t&&`is-active`),children:[e===`read`&&(0,Y.jsx)(h,{className:`agent-office__file-underlay`,"aria-hidden":`true`}),(0,Y.jsx)(n,{"aria-hidden":`true`})]})}function Bt({active:e,failed:t,role:n,variant:r,motion:i}){let a=Et[n];return(0,Y.jsxs)(`div`,{className:L(`agent-office__avatar`,`is-${n}`,`is-avatar-${r}`,`is-motion-${i}`,e&&`is-active`,!e&&!t&&`is-idle`,t&&`is-failed`),"aria-hidden":`true`,children:[(0,Y.jsx)(`span`,{className:`agent-office__avatar-chair`}),(0,Y.jsx)(`span`,{className:`agent-office__avatar-body`}),(0,Y.jsxs)(`span`,{className:`agent-office__avatar-head`,children:[(0,Y.jsx)(`span`,{className:`agent-office__avatar-hair`}),(0,Y.jsx)(`span`,{className:`agent-office__avatar-face`}),(0,Y.jsx)(`span`,{className:`agent-office__avatar-mouth`}),(0,Y.jsx)(`span`,{className:`agent-office__avatar-headset`})]}),(0,Y.jsx)(`span`,{className:`agent-office__avatar-arm`}),(0,Y.jsx)(`span`,{className:`agent-office__avatar-prop`}),(0,Y.jsx)(`span`,{className:`agent-office__avatar-role-badge`,children:(0,Y.jsx)(a,{})})]})}function Vt({call:e,compact:t=!1,onSelect:n}){let r=e.status===`running`;return(0,Y.jsxs)(`button`,{type:`button`,className:L(`agent-office__parcel`,`is-${e.kind}`,t&&`is-compact`,r&&`is-running`,e.status===`failed`&&`is-failed`),onClick:n,"aria-label":`${e.toolName}: ${e.summary}`,children:[(0,Y.jsx)(zt,{kind:e.kind,active:r}),(0,Y.jsxs)(`span`,{className:`agent-office__parcel-copy`,children:[(0,Y.jsxs)(`span`,{className:`agent-office__parcel-topline`,children:[(0,Y.jsx)(`strong`,{children:e.toolName}),e.lineLabel&&(0,Y.jsx)(`span`,{className:`agent-office__line-chip`,children:e.lineLabel})]}),!t&&e.target&&(0,Y.jsx)(`span`,{className:`agent-office__parcel-target`,children:At(e.target)}),(0,Y.jsx)(`span`,{className:`agent-office__parcel-summary`,children:e.summary})]}),(0,Y.jsx)(`span`,{className:`agent-office__parcel-state`,"aria-hidden":`true`,children:r?(0,Y.jsx)(`span`,{className:`agent-office__pulse-dot`}):e.status===`failed`?(0,Y.jsx)(F,{}):(0,Y.jsx)(m,{})})]})}function Ht({mail:e,compact:t=!1,onSelect:n}){let r=e.direction===`incoming`;return(0,Y.jsxs)(`button`,{type:`button`,className:L(`agent-office__mail-parcel`,t&&`is-compact`,r?`is-incoming`:`is-outgoing`,e.unread&&`is-unread`),onClick:n,"aria-label":`${r?`Incoming`:`Outgoing`} mail: ${e.subject}`,children:[(0,Y.jsx)(`span`,{className:`agent-office__mail-icon`,children:r?(0,Y.jsx)(A,{"aria-hidden":`true`}):(0,Y.jsx)(c,{"aria-hidden":`true`})}),(0,Y.jsxs)(`span`,{className:`agent-office__parcel-copy`,children:[(0,Y.jsx)(`strong`,{children:r?`${e.from} →`:`→ ${e.to}`}),(0,Y.jsx)(`span`,{className:`agent-office__parcel-summary`,children:e.subject})]}),(0,Y.jsx)(o,{"aria-hidden":`true`})]})}function Ut({office:e,now:t}){let{t:n}=C(),{client:r,agents:i,stats:a}=e,s=r.lastHeartbeatAt?Date.parse(r.lastHeartbeatAt):NaN,c=Number.isFinite(s)&&t-s<2e4,l=Number.isFinite(s)&&!c,u=i.some(({agent:e})=>e.presenceSource===`registry`),d=c?`VERIFIED`:l?`DELAYED`:u?`REGISTRY`:`LOCAL`,m=i.some(({agent:e})=>e.recentTools!==void 0||e.activity!==void 0),h=i.some(({agent:e})=>e.toolCalls>0&&e.recentTools===void 0&&e.activity===void 0);return(0,Y.jsxs)(`header`,{className:`agent-office__client-header`,children:[(0,Y.jsxs)(`div`,{className:`agent-office__client-title`,children:[(0,Y.jsx)(`span`,{className:`agent-office__client-icon`,children:(0,Y.jsx)(ce,{"aria-hidden":`true`})}),(0,Y.jsxs)(`div`,{className:`agent-office__client-copy`,children:[(0,Y.jsx)(`strong`,{children:r.label}),(0,Y.jsx)(`span`,{children:r.sublabel||r.sessionId})]}),(0,Y.jsxs)(`div`,{className:`agent-office__client-presence`,children:[(0,Y.jsxs)(`span`,{className:`agent-office__client-agent-count`,children:[i.length,` `,n(`activity:agentOffice.agents`)]}),(0,Y.jsxs)(`span`,{className:L(`agent-office__presence-chip`,!l&&`is-live`,l&&`is-legacy`),children:[(0,Y.jsx)(D,{"aria-hidden":`true`}),` `,d]}),(0,Y.jsxs)(`span`,{className:`agent-office__presence-chip`,children:[(0,Y.jsx)(j,{"aria-hidden":`true`}),` `,Nt(r.startedAt,t),` UP`]}),(0,Y.jsxs)(`span`,{className:L(`agent-office__presence-chip`,h?`is-legacy`:m&&`is-telemetry`),children:[(0,Y.jsx)(N,{"aria-hidden":`true`}),h?`RECONNECT`:m?`TOOLS LIVE`:`READY`]})]})]}),(0,Y.jsxs)(`fieldset`,{className:`agent-office__client-stats`,"aria-label":`Session activity totals`,children:[(0,Y.jsxs)(`span`,{title:`Unique files touched`,children:[(0,Y.jsx)(we,{}),` `,(0,Y.jsx)(`strong`,{children:a.files}),` FILES`]}),(0,Y.jsxs)(`span`,{title:`File reads`,children:[(0,Y.jsx)(ge,{}),` `,(0,Y.jsx)(`strong`,{children:a.reads}),` READ`]}),(0,Y.jsxs)(`span`,{title:`Files written`,children:[(0,Y.jsx)(f,{}),` `,(0,Y.jsx)(`strong`,{children:a.writes}),` WRITE`]}),(0,Y.jsxs)(`span`,{title:`Files edited`,children:[(0,Y.jsx)(f,{}),` `,(0,Y.jsx)(`strong`,{children:a.edits}),` EDIT`]}),(0,Y.jsxs)(`span`,{className:`agent-office__client-delta`,title:`Lines added and removed`,children:[(0,Y.jsxs)(`strong`,{children:[`+`,a.linesAdded]}),` / `,(0,Y.jsxs)(`b`,{children:[`−`,a.linesRemoved]})]}),(0,Y.jsxs)(`span`,{title:`Terminal commands`,children:[(0,Y.jsx)(p,{}),` `,(0,Y.jsx)(`strong`,{children:a.terminalCalls}),` TERM`]}),(0,Y.jsxs)(`span`,{title:`Incoming and outgoing mail`,children:[(0,Y.jsx)(o,{}),` `,(0,Y.jsx)(`strong`,{children:a.incomingMail}),`↓ `,(0,Y.jsx)(`strong`,{children:a.outgoingMail}),`↑`]})]})]})}function Wt({office:e,now:t,onSelect:n}){let{t:r}=C(),{client:i}=e,a=i.todos!==void 0,o=i.todos??[],s=o.filter(e=>e.status!==`completed`),c=o.length-s.length,l=!!i.activeInstruction,d=i.activeInstruction??i.latestPrompt,f=i.latestPromptAt!==void 0&&t-i.latestPromptAt<3e4,p=()=>n({kind:`briefing`,officeLabel:i.label,prompt:d,promptAt:i.latestPromptAt,instructionActive:l,telemetryConnected:a,todos:o});return(0,Y.jsxs)(`section`,{className:`agent-office__briefing`,"aria-label":r(`activity:agentOffice.officeBriefing`),children:[(0,Y.jsxs)(`button`,{type:`button`,className:L(`agent-office__prompt-card`,l&&`is-active`,f&&`is-fresh`,!a&&`is-waiting`),onClick:p,children:[(0,Y.jsx)(`span`,{className:`agent-office__briefing-icon is-prompt`,children:(0,Y.jsx)(u,{"aria-hidden":`true`})}),(0,Y.jsxs)(`span`,{className:`agent-office__briefing-copy`,children:[(0,Y.jsx)(`span`,{children:r(l?`activity:agentOffice.activeInstruction`:`activity:agentOffice.leaderPrompt`)}),(0,Y.jsx)(`strong`,{children:d??r(a?`activity:agentOffice.noPrompt`:`activity:agentOffice.telemetryWaiting`)})]}),l&&(0,Y.jsxs)(`span`,{className:`agent-office__instruction-live`,children:[(0,Y.jsx)(`i`,{"aria-hidden":`true`}),` LIVE`]}),i.latestPromptAt!==void 0&&(0,Y.jsx)(`time`,{dateTime:new Date(i.latestPromptAt).toISOString(),children:jt(i.latestPromptAt,t)})]}),(0,Y.jsxs)(`button`,{type:`button`,className:L(`agent-office__todo-board`,s.length>0&&`has-active`,!a&&`is-waiting`),onClick:p,children:[(0,Y.jsxs)(`span`,{className:`agent-office__todo-heading`,children:[(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(y,{"aria-hidden":`true`}),` `,r(`activity:agentOffice.activeTodos`)]}),(0,Y.jsx)(`strong`,{children:a?r(`activity:agentOffice.todoProgress`,{done:c,total:o.length}):r(`activity:agentOffice.syncWaiting`)})]}),(0,Y.jsxs)(`span`,{className:`agent-office__todo-preview`,children:[a?s.length>0?s.slice(0,3).map(e=>(0,Y.jsxs)(`span`,{className:L(`agent-office__todo-line`,`is-${e.status}`),children:[(0,Y.jsx)(`i`,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{children:e.activeForm||e.content})]},e.id)):(0,Y.jsxs)(`span`,{className:`agent-office__todo-empty`,children:[(0,Y.jsx)(te,{"aria-hidden":`true`}),o.length>0?r(`activity:agentOffice.allTodosDone`):r(`activity:agentOffice.noActiveTodos`)]}):(0,Y.jsxs)(`span`,{className:`agent-office__todo-empty is-waiting`,children:[(0,Y.jsx)(N,{"aria-hidden":`true`}),r(`activity:agentOffice.todoTelemetryWaiting`)]}),s.length>3&&(0,Y.jsx)(`span`,{className:`agent-office__todo-more`,children:r(`activity:agentOffice.moreTodos`,{count:s.length-3})})]})]})]})}function Gt({active:e}){let{t}=C();return(0,Y.jsxs)(`div`,{className:`agent-office__parcel agent-office__parcel--empty`,children:[(0,Y.jsx)(`span`,{className:`agent-office__tool-glyph`,children:(0,Y.jsx)(l,{"aria-hidden":`true`})}),(0,Y.jsxs)(`span`,{className:`agent-office__parcel-copy`,children:[(0,Y.jsx)(`strong`,{children:t(e?`activity:agentOffice.thinking`:`activity:agentOffice.waiting`)}),(0,Y.jsx)(`span`,{children:t(e?`activity:agentOffice.preparing`:`activity:agentOffice.deskReady`)})]})]})}function Kt({model:e,now:t,onSelect:n,routedMailIds:r}){let{t:i}=C(),{agent:a,client:s,current:c,display:l,history:u,mail:d}=e,f=a.status===`active`||a.status===`streaming`,p=a.status===`error`,h=d[0],g=Dt(a),_=Ot(`${s.sessionId}:${a.serverId}:${a.name}`,g),v=h&&t-h.timestampMs<3e4&&!r?.has(h.id),b=u.slice(0,6),x=b[0]?.completedAt??b[0]?.startedAt??l?.completedAt??l?.startedAt,S=c?`is-tool-${c.kind}`:void 0;return(0,Y.jsxs)(`article`,{className:L(`agent-office__lane`,`is-desk-${_.palette}`,`is-layout-${_.layout}`,`is-clutter-${_.clutter}`,f&&`is-active`,p&&`is-failed`),children:[(0,Y.jsxs)(`div`,{className:`agent-office__identity`,children:[(0,Y.jsxs)(`div`,{className:`agent-office__identity-line`,children:[(0,Y.jsx)(`span`,{className:L(`agent-office__status-dot`,f&&`is-active`,p&&`is-failed`)}),(0,Y.jsx)(`strong`,{title:a.name,children:a.name}),(0,Y.jsxs)(`span`,{className:`agent-office__agent-verified`,title:a.presenceSource===`registry`?`Verified by live session registry`:`Verified by local fleet state`,children:[(0,Y.jsx)(m,{"aria-hidden":`true`}),a.presenceSource===`registry`?`LIVE`:`LOCAL`]})]}),(0,Y.jsx)(`span`,{className:`agent-office__role`,children:a.role??(a.serverId===`leader`||a.serverId.startsWith(`leader@`)?i(`activity:agentOffice.leadAgent`):i(`activity:agentOffice.agent`))}),(0,Y.jsxs)(`div`,{className:`agent-office__agent-meta`,children:[(0,Y.jsx)(`span`,{children:s.branch?`⎇ ${s.branch}`:s.type.toUpperCase()}),(0,Y.jsx)(`span`,{children:i(`activity:agentOffice.callsCount`,{count:a.toolCalls})}),a.model&&(0,Y.jsx)(`span`,{className:`agent-office__model-chip`,title:a.model,children:kt(a.model)})]}),a.currentTask&&(0,Y.jsxs)(`button`,{type:`button`,className:`agent-office__agent-task`,onClick:()=>n({kind:`task`,task:a.currentTask??``,taskId:a.taskId,agentName:a.name}),children:[(0,Y.jsx)(y,{"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`strong`,{children:i(`activity:agentOffice.currentTask`)}),(0,Y.jsx)(`small`,{children:a.currentTask})]})]}),!a.currentTask&&f&&(0,Y.jsxs)(`div`,{className:`agent-office__agent-task is-missing`,children:[(0,Y.jsx)(N,{"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`strong`,{children:i(`activity:agentOffice.currentTask`)}),(0,Y.jsx)(`small`,{children:s.todos===void 0?i(`activity:agentOffice.telemetryWaiting`):i(`activity:agentOffice.taskNotReported`)})]})]}),h&&(0,Y.jsxs)(`button`,{type:`button`,className:L(`agent-office__identity-mail`,h.unread&&`is-unread`),onClick:()=>n({kind:`mail`,mail:h,agentName:a.name}),"aria-label":`${d.length} mail messages. Latest: ${h.subject}`,children:[(0,Y.jsx)(o,{"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsxs)(`strong`,{children:[d.length,` MAIL`]}),(0,Y.jsx)(`small`,{children:h.subject})]})]})]}),(0,Y.jsxs)(`div`,{className:L(`agent-office__scene`,S),children:[(0,Y.jsxs)(`div`,{className:`agent-office__window`,"aria-hidden":`true`,children:[(0,Y.jsx)(`span`,{}),(0,Y.jsx)(`span`,{}),(0,Y.jsx)(`span`,{})]}),(0,Y.jsxs)(`div`,{className:`agent-office__plant`,"aria-hidden":`true`,children:[(0,Y.jsx)(`span`,{}),(0,Y.jsx)(`i`,{}),(0,Y.jsx)(`b`,{})]}),(0,Y.jsxs)(`div`,{className:`agent-office__desk-zone`,"aria-hidden":`true`,children:[(0,Y.jsx)(Bt,{active:f,failed:p,role:g,variant:_.avatar,motion:_.motion}),(0,Y.jsx)(`span`,{className:`agent-office__monitor`,children:l?(0,Y.jsx)(zt,{kind:l.kind,active:c!==void 0}):(0,Y.jsx)(pe,{})}),(0,Y.jsxs)(`span`,{className:`agent-office__activity-fx`,children:[(0,Y.jsx)(`span`,{}),(0,Y.jsx)(`i`,{}),(0,Y.jsx)(`b`,{})]}),(0,Y.jsx)(`span`,{className:`agent-office__desk`}),(0,Y.jsx)(`span`,{className:`agent-office__desk-lamp`}),(0,Y.jsxs)(`span`,{className:`agent-office__desk-clutter`,children:[(0,Y.jsx)(`i`,{}),(0,Y.jsx)(`b`,{})]}),(0,Y.jsxs)(`span`,{className:L(`agent-office__desk-charm`,`is-${_.charm}`),children:[(0,Y.jsx)(`i`,{}),(0,Y.jsx)(`b`,{})]}),(0,Y.jsxs)(`span`,{className:L(`agent-office__mug`,`is-${g}`),children:[(0,Y.jsx)(`i`,{"aria-hidden":`true`}),(0,Y.jsx)(`b`,{"aria-hidden":`true`})]})]}),v&&(0,Y.jsx)(`div`,{className:L(`agent-office__mail-flyby`,`is-${h.direction}`),children:(0,Y.jsx)(Ht,{mail:h,compact:!0,onSelect:()=>n({kind:`mail`,mail:h,agentName:a.name})},h.id)}),(0,Y.jsxs)(`div`,{className:L(`agent-office__conveyor`,c&&`is-moving`),children:[(0,Y.jsxs)(`div`,{className:`agent-office__belt`,"aria-hidden":`true`,children:[(0,Y.jsx)(`span`,{}),(0,Y.jsx)(`span`,{}),(0,Y.jsx)(`span`,{}),(0,Y.jsx)(`span`,{}),(0,Y.jsx)(`span`,{}),(0,Y.jsx)(`span`,{})]}),(0,Y.jsx)(`div`,{className:`agent-office__current-action`,children:l?(0,Y.jsx)(Vt,{call:l,onSelect:()=>n({kind:`tool`,call:l,agentName:a.name})},l.id):(0,Y.jsx)(Gt,{active:f})})]})]}),(0,Y.jsxs)(`div`,{className:`agent-office__history`,children:[(0,Y.jsxs)(`div`,{className:`agent-office__history-heading`,children:[(0,Y.jsx)(`span`,{children:i(`activity:agentOffice.recent`)}),x!==void 0&&(0,Y.jsx)(`span`,{children:jt(x,t)})]}),(0,Y.jsx)(`div`,{className:`agent-office__history-list`,children:b.length>0?b.map(e=>(0,Y.jsx)(Vt,{call:e,compact:!0,onSelect:()=>n({kind:`tool`,call:e,agentName:a.name})},`tool:${e.id}`)):(0,Y.jsx)(`span`,{className:`agent-office__history-empty`,children:a.toolCalls>0&&a.recentTools===void 0&&a.activity===void 0?i(`activity:agentOffice.telemetryReconnect`):i(`activity:agentOffice.noCalls`)})})]})]})}function qt(e){return e.agent.status===`active`||e.agent.status===`streaming`||e.agent.status===`error`}function Jt({agents:e,now:t,onSelect:n}){let{t:r}=C();return(0,Y.jsxs)(`section`,{className:`agent-office__lounge`,"aria-label":r(`activity:agentOffice.breakRoom`),children:[(0,Y.jsxs)(`header`,{className:`agent-office__lounge-heading`,children:[(0,Y.jsx)(I,{"aria-hidden":`true`}),(0,Y.jsx)(`strong`,{children:r(`activity:agentOffice.breakRoom`)}),(0,Y.jsx)(`span`,{children:r(`activity:agentOffice.onBreak`,{count:e.length})})]}),(0,Y.jsx)(`div`,{className:`agent-office__lounge-seats`,children:e.map(e=>{let{agent:i,history:a,mail:s}=e,c=Dt(i),l=Et[c],u=s.filter(e=>e.unread).length,d=a[0]?.completedAt??a[0]?.startedAt,f=s[0],p=()=>{i.currentTask?n({kind:`task`,task:i.currentTask,taskId:i.taskId,agentName:i.name}):f&&n({kind:`mail`,mail:f,agentName:i.name})},m=!!i.currentTask||!!f;return(0,Y.jsxs)(`button`,{type:`button`,className:L(`agent-office__lounge-seat`,`is-${c}`),onClick:p,disabled:!m,children:[(0,Y.jsx)(`span`,{className:`agent-office__lounge-avatar`,children:(0,Y.jsx)(l,{"aria-hidden":`true`})}),(0,Y.jsxs)(`span`,{className:`agent-office__lounge-copy`,children:[(0,Y.jsx)(`strong`,{children:i.name}),(0,Y.jsx)(`small`,{children:i.role??r(`activity:agentOffice.agent`)})]}),(0,Y.jsxs)(`span`,{className:`agent-office__lounge-meta`,children:[d!==void 0&&(0,Y.jsx)(`span`,{children:jt(d,t)}),u>0&&(0,Y.jsxs)(`span`,{className:`agent-office__lounge-mail`,children:[(0,Y.jsx)(o,{"aria-hidden":`true`}),` `,u]})]})]},e.key)})})]})}function X({label:e,value:t}){return(0,Y.jsxs)(`div`,{className:`agent-office__detail-row`,children:[(0,Y.jsx)(`span`,{children:e}),(0,Y.jsx)(`strong`,{children:t})]})}function Yt({selected:e,onClose:t}){let{t:n}=C(),{call:r,agentName:i}=e,a=Tt[r.kind],o=Pt(r.input),s=Pt(r.output);return(0,Y.jsxs)(`aside`,{className:`agent-office__detail`,"aria-label":`${r.toolName} details`,children:[(0,Y.jsxs)(`div`,{className:`agent-office__detail-header`,children:[(0,Y.jsx)(`div`,{className:L(`agent-office__detail-icon`,`is-${r.kind}`),children:(0,Y.jsx)(a,{"aria-hidden":`true`})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:n(`activity:agentOffice.toolCall`)}),(0,Y.jsx)(`h2`,{children:r.toolName})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`Close details`,children:(0,Y.jsx)(F,{})})]}),(0,Y.jsxs)(`div`,{className:`agent-office__detail-status`,children:[(0,Y.jsx)(`span`,{className:L(`agent-office__status-dot`,r.status===`running`&&`is-active`,r.status===`failed`&&`is-failed`)}),(0,Y.jsx)(`strong`,{children:r.summary}),(0,Y.jsx)(`span`,{children:r.status})]}),(0,Y.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,Y.jsx)(`h3`,{children:n(`activity:agentOffice.execution`)}),(0,Y.jsx)(X,{label:n(`activity:agentOffice.agent`),value:i}),(0,Y.jsx)(X,{label:n(`activity:agentOffice.started`),value:new Date(r.startedAt).toLocaleTimeString()}),(0,Y.jsx)(X,{label:n(`activity:agentOffice.duration`),value:Mt(r.durationMs)}),r.sessionId&&(0,Y.jsx)(X,{label:n(`activity:agentOffice.session`),value:At(r.sessionId,28)})]}),(r.target||r.fileTargets.length>0)&&(0,Y.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,Y.jsx)(`h3`,{children:n(`activity:agentOffice.target`)}),r.target&&(0,Y.jsx)(`code`,{className:`agent-office__target-code`,children:r.target}),r.fileTargets.map((e,t)=>(0,Y.jsxs)(`div`,{className:`agent-office__file-target`,children:[(0,Y.jsx)(h,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{children:e.filePath}),(e.line||e.endLine)&&(0,Y.jsxs)(`strong`,{children:[`L`,e.line??1,e.endLine?`–${e.endLine}`:``]})]},`${e.filePath}:${t}`))]}),(r.outputLines!==void 0||r.outputBytes!==void 0||r.outputTokens!==void 0)&&(0,Y.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,Y.jsx)(`h3`,{children:n(`activity:agentOffice.resultSize`)}),(0,Y.jsxs)(`div`,{className:`agent-office__metric-grid`,children:[r.outputLines!==void 0&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`strong`,{children:r.outputLines.toLocaleString()}),(0,Y.jsx)(`span`,{children:n(`activity:agentOffice.lines`)})]}),r.outputBytes!==void 0&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`strong`,{children:r.outputBytes.toLocaleString()}),(0,Y.jsx)(`span`,{children:n(`activity:agentOffice.bytes`)})]}),r.outputTokens!==void 0&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`strong`,{children:[`≈`,r.outputTokens.toLocaleString()]}),(0,Y.jsx)(`span`,{children:n(`activity:agentOffice.tokens`)})]})]})]}),o&&(0,Y.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,Y.jsx)(`h3`,{children:n(`activity:agentOffice.input`)}),(0,Y.jsx)(`pre`,{children:(0,Y.jsx)(`code`,{children:o})})]}),s&&(0,Y.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,Y.jsx)(`h3`,{children:n(`activity:agentOffice.outputPreview`)}),(0,Y.jsx)(`pre`,{children:(0,Y.jsx)(`code`,{children:s})})]})]})}function Xt({selected:e,onClose:t}){let{t:r}=C(),{mail:i,agentName:a}=e;return(0,Y.jsxs)(`aside`,{className:`agent-office__detail`,"aria-label":`${i.subject} details`,children:[(0,Y.jsxs)(`div`,{className:`agent-office__detail-header`,children:[(0,Y.jsx)(`div`,{className:`agent-office__detail-icon is-mail`,children:(0,Y.jsx)(o,{"aria-hidden":`true`})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:i.direction===`incoming`?`INCOMING MAIL`:`OUTGOING MAIL`}),(0,Y.jsx)(`h2`,{children:i.subject})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`Close mail details`,children:(0,Y.jsx)(F,{})})]}),(0,Y.jsxs)(`div`,{className:`agent-office__detail-status`,children:[(0,Y.jsx)(`span`,{className:L(`agent-office__status-dot`,i.unread&&`is-active`)}),(0,Y.jsxs)(`strong`,{children:[i.from,` → `,i.to]}),(0,Y.jsx)(`span`,{children:i.type}),i.audience===`leaders`&&(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(n,{className:`h-3 w-3`}),` `,r(`activity:mailbox.audienceLeaders`)]})]}),(0,Y.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,Y.jsx)(`h3`,{children:r(`activity:mailbox.messages`)}),(0,Y.jsx)(X,{label:r(`activity:agentOffice.agent`),value:a}),(0,Y.jsx)(X,{label:r(`activity:agentOffice.started`),value:new Date(i.timestampMs).toLocaleTimeString()}),(0,Y.jsx)(X,{label:`Priority`,value:i.priority}),(0,Y.jsx)(X,{label:`Route`,value:`${i.from} → ${i.to}`})]}),(0,Y.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,Y.jsx)(`h3`,{children:i.subject}),(0,Y.jsx)(`div`,{className:`agent-office__mail-body`,children:i.body})]})]})}function Zt({selected:e,onClose:t}){let{t:n}=C();return(0,Y.jsxs)(`aside`,{className:`agent-office__detail`,"aria-label":`${e.agentName} task details`,children:[(0,Y.jsxs)(`div`,{className:`agent-office__detail-header`,children:[(0,Y.jsx)(`div`,{className:`agent-office__detail-icon is-task`,children:(0,Y.jsx)(y,{"aria-hidden":`true`})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:n(`activity:agentOffice.currentTask`)}),(0,Y.jsx)(`h2`,{children:e.agentName})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`Close task details`,children:(0,Y.jsx)(F,{})})]}),(0,Y.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,Y.jsx)(`h3`,{children:n(`activity:agentOffice.task`)}),e.taskId&&(0,Y.jsx)(X,{label:`ID`,value:e.taskId}),(0,Y.jsx)(`div`,{className:`agent-office__task-body`,children:e.task})]})]})}function Qt({selected:e,onClose:t}){let{t:n}=C(),r=e.todos.filter(e=>e.status!==`completed`).length;return(0,Y.jsxs)(`aside`,{className:`agent-office__detail`,"aria-label":`${e.officeLabel} briefing`,children:[(0,Y.jsxs)(`div`,{className:`agent-office__detail-header`,children:[(0,Y.jsx)(`div`,{className:`agent-office__detail-icon is-briefing`,children:(0,Y.jsx)(u,{"aria-hidden":`true`})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:e.instructionActive?n(`activity:agentOffice.activeInstruction`):n(`activity:agentOffice.officeBriefing`)}),(0,Y.jsx)(`h2`,{children:e.officeLabel})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`Close office briefing`,children:(0,Y.jsx)(F,{})})]}),(0,Y.jsxs)(`div`,{className:`agent-office__detail-status`,children:[(0,Y.jsx)(`span`,{className:L(`agent-office__status-dot`,(e.instructionActive||r>0)&&`is-active`)}),(0,Y.jsx)(`strong`,{children:e.telemetryConnected?n(`activity:agentOffice.activeTodos`):n(`activity:agentOffice.telemetryWaiting`)}),(0,Y.jsx)(`span`,{children:e.telemetryConnected?r:`—`})]}),(0,Y.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,Y.jsx)(`h3`,{children:e.instructionActive?n(`activity:agentOffice.activeInstruction`):n(`activity:agentOffice.leaderPrompt`)}),e.promptAt!==void 0&&(0,Y.jsx)(X,{label:n(`activity:agentOffice.promptReceived`),value:new Date(e.promptAt).toLocaleString()}),(0,Y.jsx)(`div`,{className:`agent-office__task-body`,children:e.prompt??(e.telemetryConnected?n(`activity:agentOffice.noPrompt`):n(`activity:agentOffice.telemetryWaiting`))})]}),(0,Y.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,Y.jsx)(`h3`,{children:n(`activity:agentOffice.todos`)}),(0,Y.jsx)(`div`,{className:`agent-office__todo-detail-list`,children:e.telemetryConnected?e.todos.length>0?e.todos.map(e=>(0,Y.jsxs)(`div`,{className:L(`agent-office__todo-detail`,`is-${e.status}`),children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`strong`,{children:e.content}),(0,Y.jsx)(`small`,{children:n(`activity:agentOffice.todoStatus.${e.status}`)})]})]},e.id)):(0,Y.jsx)(`span`,{className:`agent-office__history-empty`,children:n(`activity:agentOffice.noActiveTodos`)}):(0,Y.jsx)(`span`,{className:`agent-office__history-empty`,children:n(`activity:agentOffice.todoTelemetryWaiting`)})})]})]})}function $t({selected:e,onClose:t}){return e.kind===`tool`?(0,Y.jsx)(Yt,{selected:e,onClose:t}):e.kind===`mail`?(0,Y.jsx)(Xt,{selected:e,onClose:t}):e.kind===`task`?(0,Y.jsx)(Zt,{selected:e,onClose:t}):(0,Y.jsx)(Qt,{selected:e,onClose:t})}function en(){let{t:e}=C(),t=Ae(e=>e.liveSessions),n=Ae(e=>e.aggregate),r=Oe(e=>e.agents),i=je(e=>e.agents),a=je(e=>e.messages),s=Ee(e=>e.toolEvents),c=De(e=>e.projectName),u=xt(r),[d,f]=(0,U.useState)(null),p=(0,U.useMemo)(()=>vt(t,r,i,u.map,u.now),[t,r,i,u]),m=(0,U.useMemo)(()=>p.flatMap(e=>e.agents.map(t=>{let n=Lt(tt(s,t.serverId,e.sessionId),Xe(t.recentTools,t.serverId,e.sessionId),It(t,e,r.get(t.serverId)?.toolLog??[])),i=t.status===`active`||t.status===`streaming`,o=n.find(e=>e.status===`running`);!o&&i&&t.currentTool&&(o=nt(t.serverId,t.currentTool,e.sessionId));let c=o??n[0],l=n.filter(e=>e.status!==`running`).slice(0,6),u=Rt(Ze(t.recentMail),et(a,t,e.sessionId));return{key:t.officeId,client:e,agent:t,calls:n,current:o,display:c,history:l,mail:u}})),[p,r,a,s]),h=(0,U.useMemo)(()=>p.map(e=>{let t=m.filter(t=>t.client.id===e.id);return{client:e,agents:t,stats:Ft(t)}}).filter(e=>e.agents.length>0),[p,m]),g=m.filter(({agent:e})=>e.status===`active`||e.status===`streaming`).length,_=c||t.find(e=>e.projectName)?.projectName||e(`activity:office.fleetHq`),v=Date.now();return(0,Y.jsxs)(`div`,{className:`agent-office`,children:[(0,Y.jsxs)(`header`,{className:`agent-office__header`,children:[(0,Y.jsxs)(`div`,{className:`agent-office__title`,children:[(0,Y.jsx)(`span`,{className:`agent-office__brand-mark`,children:(0,Y.jsx)(ce,{"aria-hidden":`true`})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:e(`activity:agentOffice.liveProjectOffice`)}),(0,Y.jsx)(`h1`,{children:_})]})]}),(0,Y.jsxs)(`div`,{className:`agent-office__live-pill`,children:[(0,Y.jsx)(`span`,{}),` LIVE`]}),(0,Y.jsxs)(`div`,{className:`agent-office__summary`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(l,{}),(0,Y.jsx)(`strong`,{children:m.length}),(0,Y.jsx)(`span`,{children:e(`activity:agentOffice.agents`)})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(w,{}),(0,Y.jsx)(`strong`,{children:g}),(0,Y.jsx)(`span`,{children:e(`activity:agentOffice.working`)})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(N,{}),(0,Y.jsx)(`strong`,{children:n.toolCalls.toLocaleString()}),(0,Y.jsx)(`span`,{children:e(`activity:agentOffice.toolCalls`)})]})]})]}),(0,Y.jsx)(`main`,{className:`agent-office__floor`,children:m.length>0?h.map(t=>{let n=t.agents.filter(qt),r=t.agents.filter(e=>!qt(e)),i=Qe(n,v),a=new Set(i.map(e=>e.id));return(0,Y.jsxs)(`section`,{className:`agent-office__client-office`,children:[(0,Y.jsx)(Ut,{office:t,now:v}),(0,Y.jsx)(Wt,{office:t,now:v,onSelect:f}),n.length>0&&(0,Y.jsxs)(`div`,{className:`agent-office__column-headings`,"aria-hidden":`true`,children:[(0,Y.jsx)(`span`,{children:e(`activity:agentOffice.team`)}),(0,Y.jsx)(`span`,{children:e(`activity:agentOffice.liveDesk`)}),(0,Y.jsx)(`span`,{children:e(`activity:agentOffice.lastActions`)})]}),(0,Y.jsxs)(`div`,{className:`agent-office__client-desks`,children:[n.map(e=>(0,Y.jsx)(Kt,{model:e,now:v,onSelect:f,routedMailIds:a},e.key)),i.length>0&&(0,Y.jsx)(`div`,{className:`agent-office__mail-routes`,"aria-hidden":`true`,children:i.map(e=>(0,Y.jsx)(`div`,{className:`agent-office__mail-route`,style:{"--from":`${(e.fromIndex+.5)/n.length*100}%`,"--to":`${(e.toIndex+.5)/n.length*100}%`},children:(0,Y.jsx)(`span`,{className:`agent-office__mail-route-parcel`,children:(0,Y.jsx)(o,{"aria-hidden":`true`})})},e.id))}),n.length===0&&(0,Y.jsxs)(`div`,{className:`agent-office__desks-empty`,children:[(0,Y.jsx)(I,{"aria-hidden":`true`}),e(`activity:agentOffice.desksEmpty`)]})]}),r.length>0&&(0,Y.jsx)(Jt,{agents:r,now:v,onSelect:f})]},t.client.id)}):(0,Y.jsxs)(`div`,{className:`agent-office__empty-state`,children:[(0,Y.jsx)(`span`,{children:(0,Y.jsx)(D,{"aria-hidden":`true`})}),(0,Y.jsx)(`h2`,{children:e(`activity:agentOffice.readyTitle`)}),(0,Y.jsx)(`p`,{children:e(`activity:agentOffice.readyBody`)})]})}),(0,Y.jsxs)(`footer`,{className:`agent-office__footer`,children:[(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`span`,{className:`agent-office__status-dot is-active`}),` `,e(`activity:agentOffice.liveEvent`)]}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(Se,{}),` `,e(`activity:agentOffice.connectedSessions`,{count:t.length})]}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(j,{}),` `,e(`activity:agentOffice.detailHint`)]})]}),d&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`button`,{type:`button`,className:`agent-office__detail-backdrop`,onClick:()=>f(null),"aria-label":`Close tool details`}),(0,Y.jsx)($t,{selected:d,onClose:()=>f(null)})]})]})}function tn(e){if(e<1e3)return`${e}ms`;let t=Math.round(e/100);return t<600?`${(t/10).toFixed(1)}s`:`${Math.floor(t/600)}m ${Math.round(t%600/10)}s`}var nn={user:{Icon:M,labelKey:`activity:message.roleYou`,avatarBg:`bg-primary`,avatarColor:`text-primary-foreground`,avatarRing:`ring-2 ring-offset-2 ring-offset-background ring-primary/20`,bubbleBg:`bg-transparent`,bubbleBorder:`border-primary/40`,textColor:`text-foreground`},assistant:{Icon:l,labelKey:`activity:message.roleAssistant`,avatarBg:`bg-accent`,avatarColor:`text-accent-foreground`,avatarRing:`ring-2 ring-offset-2 ring-offset-background ring-accent/20`,bubbleBg:`bg-card`,bubbleBorder:`border-border`,textColor:`text-foreground`},tool:{Icon:v,labelKey:`activity:message.roleTool`,avatarBg:`bg-secondary`,avatarColor:`text-secondary-foreground`,avatarRing:`ring-2 ring-offset-2 ring-offset-background ring-secondary/20`,bubbleBg:`bg-muted/80`,bubbleBorder:`border-border`,textColor:`text-foreground`},system:{Icon:l,labelKey:`activity:transcript.kindSystem`,avatarBg:`bg-muted`,avatarColor:`text-muted-foreground`,avatarRing:`ring-2 ring-offset-2 ring-offset-background ring-muted/20`,bubbleBg:`bg-muted/50`,bubbleBorder:`border-border`,textColor:`text-muted-foreground`},error:{Icon:Te,labelKey:`activity:transcript.kindError`,avatarBg:`bg-destructive`,avatarColor:`text-destructive-foreground`,avatarRing:`ring-2 ring-offset-2 ring-offset-background ring-destructive/20`,bubbleBg:`bg-destructive/5`,bubbleBorder:`border-destructive/20`,textColor:`text-destructive`}};function rn({entry:e}){let{t}=C();return e.role===`error`?(0,Y.jsx)(Me,{text:e.text}):e.role===`tool`?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5 tool-details`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-foreground`,children:[(0,Y.jsx)(v,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{className:`font-mono`,children:e.tool??t(`activity:watch.toolFallback`)}),e.durationMs!==void 0&&(0,Y.jsxs)(`span`,{className:`ml-auto text-[10px] text-muted-foreground font-normal tabular-nums`,children:[(0,Y.jsx)(ne,{className:`h-3 w-3 inline mr-0.5 align-text-bottom`}),tn(e.durationMs)]})]}),e.input!==void 0&&e.input!==null&&(0,Y.jsx)(`div`,{className:`p-3 bg-muted/50 rounded-lg overflow-x-auto`,children:(0,Y.jsx)(Ne,{input:e.input})}),e.output!==void 0&&e.output!==null?(0,Y.jsx)(`div`,{className:`text-sm leading-relaxed markdown-content`,children:typeof e.output==`string`?(0,Y.jsx)(H,{remarkPlugins:[z],rehypePlugins:B,components:V,children:e.output}):(0,Y.jsx)(`pre`,{className:`whitespace-pre-wrap font-mono text-xs bg-card rounded-lg p-2 border border-border overflow-x-auto`,children:JSON.stringify(e.output,null,2)})}):e.text?(0,Y.jsx)(`div`,{className:`text-sm leading-relaxed markdown-content`,children:(0,Y.jsx)(H,{remarkPlugins:[z],rehypePlugins:B,components:V,children:e.text})}):null,e.isError&&(0,Y.jsxs)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/5 px-3 py-2`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-destructive`,children:t(`activity:watch.toolFailed`)}),e.text&&(0,Y.jsx)(`pre`,{className:`mt-1 text-xs whitespace-pre-wrap text-destructive/80`,children:e.text})]})]}):(0,Y.jsx)(`div`,{className:`text-sm leading-relaxed markdown-content`,children:(0,Y.jsx)(H,{remarkPlugins:[z],rehypePlugins:B,components:V,children:e.text})})}function an({entry:e,isContinuation:t=!1}){let{t:n}=C(),r=nn[e.role],i=r.Icon;return(0,Y.jsxs)(`div`,{className:`group flex gap-3 animate-message msg-bubble rounded-lg transition-shadow`,children:[t?(0,Y.jsx)(`div`,{className:`flex-shrink-0 w-8`}):(0,Y.jsx)(`div`,{className:L(`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center`,r.avatarBg,r.avatarColor,r.avatarRing),children:(0,Y.jsx)(i,{className:`h-4 w-4`})}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5 min-w-0 flex-1`,children:[!t&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:L(`text-xs font-medium`,r.textColor),children:e.role===`tool`&&e.tool?e.tool:n(r.labelKey)}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:new Date(e.ts).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}),e.role===`tool`&&e.durationMs!==void 0&&(0,Y.jsxs)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[`· `,tn(e.durationMs)]})]}),(0,Y.jsx)(`div`,{className:L(`rounded-2xl px-4 py-3 border`,e.role===`user`&&`rounded-br-md`,e.role===`assistant`&&`rounded-bl-md`,e.role===`tool`&&`rounded-bl-sm`,e.role===`system`&&`rounded-bl-sm opacity-70`,e.role===`error`&&`rounded-bl-sm`,r.bubbleBg,r.bubbleBorder),children:(0,Y.jsx)(`div`,{className:L(`text-sm leading-relaxed markdown-content`,r.textColor),children:(0,Y.jsx)(rn,{entry:e})})}),e.text&&e.role!==`error`&&(0,Y.jsx)(`div`,{className:`opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,Y.jsx)(Fe,{text:e.text,label:n(`common:action.copy`)})})]})]})}var on=[`steer`,`ask`,`assign`,`note`],sn=2500;function cn({sessionId:e,limit:t=200}){let[n,r]=(0,U.useState)(null),{t:i}=C(),[a,o]=(0,U.useState)(null),[s,c]=(0,U.useState)(``),[u,d]=(0,U.useState)(!1),[f,p]=(0,U.useState)(null),[m,h]=(0,U.useState)(`steer`),[g,_]=(0,U.useState)(`high`),[v,y]=(0,U.useState)([]),[b,x]=(0,U.useState)(!1),S=(0,U.useRef)(null),ee=(0,U.useRef)(!0),w=(0,U.useRef)(!0),te=Ae(e=>e.liveSessions),T=(0,U.useMemo)(()=>te.find(t=>t.sessionId===e),[te,e]),ne=(0,U.useMemo)(()=>{let e=T;return e?`${e.status}|${e.agents.map(e=>`${e.id}:${e.status}:${e.toolCalls??0}:${e.iterations??0}`).join(`,`)}`:``},[T]),D=T?.status===`active`||(T?.agents.some(e=>e.status===`running`||e.status===`streaming`)??!1),re=(0,U.useMemo)(()=>{if(!T)return null;let e=T.agents.find(e=>e.status===`running`||e.status===`streaming`);return e?.currentTool?`🔧 ${e.currentTool}`:e?i(`activity:sessionWatch.working`,{name:e.name??e.id}):null},[T,i]),O=(0,U.useMemo)(()=>{if(!T)return null;let e=T.agents.find(e=>e.partialText&&(e.status===`streaming`||e.status===`running`))??T.agents.find(e=>e.partialText);return e?.partialText?{label:e.id===`leader`?i(`activity:sessionWatch.claude`):e.name||e.id,text:e.partialText}:null},[T,i]),ie=(0,U.useCallback)(async()=>{try{let n=await fetch(`/api/sessions/${encodeURIComponent(e)}/events?limit=${t}`);if(!n.ok)throw Error(`HTTP ${n.status}`);let i=await n.json();w.current&&(r(i),o(null))}catch(e){w.current&&o(e instanceof Error?e.message:String(e))}},[e,t]),k=(0,U.useCallback)(async()=>{try{let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/mailbox`);if(!t.ok)return;let n=await t.json();w.current&&Array.isArray(n.thread)&&y(n.thread)}catch{}},[e]);(0,U.useEffect)(()=>{w.current=!0,r(null),o(null),y([]),ie(),k();let e=setInterval(()=>{document.hidden||(ie(),k())},sn);return()=>{w.current=!1,clearInterval(e)}},[ie,k]),(0,U.useEffect)(()=>{ne&&ie()},[ne,ie]),(0,U.useEffect)(()=>{ee.current&&S.current&&(S.current.scrollTop=S.current.scrollHeight)},[n,O]);let ae=()=>{let e=S.current;e&&(ee.current=e.scrollHeight-e.scrollTop-e.clientHeight<40)},oe=async()=>{let t=s.trim();if(!(!t||u)){d(!0),p(null);try{let n=await fetch(`/api/sessions/${encodeURIComponent(e)}/message`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:t,type:m,priority:g})});if(!n.ok)throw Error(`HTTP ${n.status}`);c(``),p(D?E.t(`activity:sessionWatch.sentRunning`):E.t(`activity:sessionWatch.sentIdle`)),k()}catch(e){p(E.t(`activity:sessionWatch.sentFailed`,{error:e instanceof Error?e.message:String(e)}))}finally{d(!1)}}},A=async()=>{if(!b){x(!0),p(null);try{let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/interrupt`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({reason:E.t(`activity:sessionWatch.interruptReason`)})});if(!t.ok)throw Error(`HTTP ${t.status}`);p(E.t(`activity:sessionWatch.interruptSent`)),k()}catch(e){p(E.t(`activity:sessionWatch.interruptFailed`,{error:e instanceof Error?e.message:String(e)}))}finally{x(!1)}}},se=n?.entries??[];return(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5 shrink-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] uppercase tracking-wide text-muted-foreground`,children:[(0,Y.jsx)(`span`,{className:L(`h-1.5 w-1.5 rounded-full`,D?`bg-success animate-pulse`:`bg-muted-foreground`)}),i(`activity:sessionWatch.liveStream`)]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n&&(0,Y.jsxs)(`div`,{className:`text-[10px] text-muted-foreground`,children:[i(`activity:sessionWatch.events`,{count:n.total}),` · `,n.status]}),D&&(0,Y.jsx)(`button`,{type:`button`,onClick:()=>void A(),disabled:b,title:i(`activity:sessionWatch.interruptTitle`),className:`rounded border border-destructive/40 bg-destructive/15 px-1.5 py-0.5 text-[10px] text-destructive hover:bg-destructive/25 disabled:opacity-40 transition-colors`,children:i(b?`activity:sessionWatch.interrupting`:`activity:sessionWatch.interrupt`)})]})]}),re&&(0,Y.jsxs)(`div`,{className:`mb-1.5 shrink-0 text-[10px] text-foreground truncate`,children:[`▶ `,re]}),a&&(0,Y.jsxs)(`div`,{className:`text-[11px] text-destructive mb-1 shrink-0`,children:[`· `,a]}),(0,Y.jsxs)(`div`,{ref:S,onScroll:ae,className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain space-y-1.5 pr-1`,children:[se.length===0&&!a&&(0,Y.jsx)(`div`,{className:`text-[11px] text-muted-foreground italic`,children:i(`activity:sessionWatch.loading`)}),se.map((e,t)=>(0,Y.jsx)(an,{entry:e,isContinuation:t>0&&se[t-1].role===e.role},`${e.ts}-${t}`)),O&&(0,Y.jsxs)(`div`,{className:`flex gap-3 animate-message`,children:[(0,Y.jsx)(`div`,{className:`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center bg-accent text-accent-foreground ring-2 ring-offset-2 ring-offset-background ring-accent/20`,children:(0,Y.jsx)(l,{className:`h-4 w-4 animate-pulse`})}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5 max-w-[85%] min-w-0`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground px-1`,children:O.label}),(0,Y.jsx)(`div`,{className:`rounded-2xl rounded-bl-md px-4 py-3 bg-card border border-border`,children:(0,Y.jsxs)(`span`,{className:`text-sm leading-relaxed text-foreground whitespace-pre-wrap break-words`,children:[O.text,(0,Y.jsx)(`span`,{className:`animate-pulse text-primary`,children:`▋`})]})})]})]})]}),v.length>0&&(0,Y.jsxs)(`div`,{className:`mt-2 pt-2 border-t border-border shrink-0 max-h-28 overflow-y-auto space-y-1`,children:[(0,Y.jsx)(`div`,{className:`text-[9px] uppercase tracking-wide text-muted-foreground`,children:i(`activity:mailbox.messages`)}),v.slice(-6).map(e=>{let t=e.completed?i(`activity:sessionWatch.done`):e.readByLeader?i(`activity:sessionWatch.read`):i(`activity:sessionWatch.delivered`);return(0,Y.jsxs)(`div`,{className:`text-[10px] leading-snug`,children:[(0,Y.jsx)(`span`,{className:L(`font-semibold mr-1.5`,e.fromLeader?`text-accent`:`text-primary`),children:e.fromLeader?i(`activity:sessionWatch.agent`):i(`activity:sessionWatch.you`)}),(0,Y.jsx)(`span`,{className:`text-foreground whitespace-pre-wrap break-words`,children:e.body}),!e.fromLeader&&(0,Y.jsx)(`span`,{className:L(`ml-1.5 text-[9px]`,e.completed?`text-success`:e.readByLeader?`text-primary`:`text-muted-foreground`),children:t})]},e.id)})]}),(0,Y.jsxs)(`div`,{className:`mt-2 pt-2 border-t border-border shrink-0`,children:[(0,Y.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5`,children:[(0,Y.jsx)(`select`,{value:m,onChange:e=>h(e.target.value),title:i(`activity:sessionWatch.msgType.${m}Hint`),className:`rounded bg-muted border border-border px-1.5 py-0.5 text-[10px] text-foreground focus:outline-none focus:ring-1 focus:ring-ring`,children:on.map(e=>(0,Y.jsx)(`option`,{value:e,children:i(`activity:sessionWatch.msgType.${e}Label`)},e))}),(0,Y.jsxs)(`select`,{value:g,onChange:e=>_(e.target.value),title:i(`activity:sessionWatch.priority`),className:`rounded bg-muted border border-border px-1.5 py-0.5 text-[10px] text-foreground focus:outline-none focus:ring-1 focus:ring-ring`,children:[(0,Y.jsx)(`option`,{value:`high`,children:`high`}),(0,Y.jsx)(`option`,{value:`normal`,children:`normal`}),(0,Y.jsx)(`option`,{value:`low`,children:`low`})]})]}),(0,Y.jsxs)(`div`,{className:`flex items-end gap-1.5`,children:[(0,Y.jsx)(`textarea`,{value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),oe())},rows:2,placeholder:i(`activity:sessionWatch.placeholder`,{label:i(`activity:sessionWatch.msgType.${m}Label`)}),className:`flex-1 resize-none rounded-md bg-muted border border-border px-2 py-1 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring`}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>void oe(),disabled:u||!s.trim(),className:`shrink-0 rounded-md bg-primary text-primary-foreground px-2.5 py-1.5 text-xs hover:bg-primary/90 disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,children:u?`…`:i(`activity:sessionWatch.send`)})]}),f&&(0,Y.jsx)(`div`,{className:`mt-1 text-[10px] text-muted-foreground`,children:f}),(0,Y.jsx)(`div`,{className:`mt-0.5 text-[9px] text-muted-foreground`,children:i(`activity:sessionWatch.sendHint`)})]})]})}var Z={primary:`hsl(var(--primary))`,info:`hsl(var(--info))`,success:`hsl(var(--success))`,warning:`hsl(var(--warning))`,destructive:`hsl(var(--destructive))`,muted:`hsl(var(--muted-foreground))`},ln=.12;function un(e){return Math.min(100,Math.max(0,e??0))}function Q({status:e,small:t,activity:n=0}){let r=t?`w-2 h-2`:`w-3 h-3`,i=t?4+n*4:6+n*6,a={idle:`bg-muted-foreground`,active:`bg-success`,streaming:`bg-primary`,completed:`bg-primary`,error:`bg-destructive`,offline:`bg-muted-foreground/60`},o={idle:Z.muted,active:Z.success,streaming:Z.primary,completed:Z.primary,error:Z.destructive,offline:Z.muted};return(0,Y.jsx)(`span`,{className:L(`rounded-full`,r,n>0&&`animate-pulse`,a[e]),style:{boxShadow:n>0?`0 0 ${i}px ${o[e]}`:void 0}})}function $(){let e={opacity:0,width:1,height:1,minWidth:0,border:`none`,background:`transparent`};return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(ve,{type:`target`,position:S.Top,style:e,isConnectable:!1}),(0,Y.jsx)(ve,{type:`source`,position:S.Bottom,style:e,isConnectable:!1})]})}function dn({data:e}){let{t}=C();return(0,Y.jsxs)(`div`,{className:`mt-2 flex items-center justify-between border-t border-border/60 pt-1.5 text-[10px] text-muted-foreground`,children:[(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`span`,{className:`font-mono text-foreground`,children:e.agentCount??0}),` `,t(`activity:office.agentsSuffix`)]}),e.startedAt&&(0,Y.jsx)(`span`,{children:t(`activity:office.upPrefix`,{time:at(e.startedAt,Date.now())})})]})}function fn({data:e}){let{t}=C(),n=e.status===`active`||e.status===`streaming`,r=e.status===`error`,i=e.status===`offline`,o=e.color||Z.info;return(0,Y.jsxs)(`div`,{className:L(`rounded-xl border-2 p-4 min-w-[180px] transition-all backdrop-blur-sm`,n&&`shadow-lg shadow-primary/15`,r&&`border-destructive/50 bg-destructive/10`,i&&`border-border/70 bg-muted/35 opacity-60`,!n&&!r&&!i&&`border-primary/30 bg-primary/10`),children:[(0,Y.jsx)($,{}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,Y.jsx)(`div`,{className:L(`flex items-center justify-center w-10 h-10 rounded-lg`,n?`bg-primary/15`:`bg-primary/10`),children:(0,Y.jsx)(a,{className:`h-5 w-5`,style:{color:o}})}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold truncate`,style:{color:o},children:e.label}),(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:t(`activity:office.webuiClient`)})]}),(0,Y.jsx)(Q,{status:e.status,activity:e.vizActivity??0})]}),e.sublabel&&(0,Y.jsx)(`div`,{className:`mb-2 truncate text-[10px] text-muted-foreground`,children:e.sublabel}),(0,Y.jsx)(`div`,{className:`flex items-center gap-2 text-[10px] text-muted-foreground`,children:i?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(de,{className:`h-3 w-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{children:t(`activity:office.disconnected`)})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(D,{className:`h-3 w-3 text-success`}),(0,Y.jsx)(`span`,{children:t(`activity:office.connected`)})]})}),n&&(0,Y.jsx)(`div`,{className:`mt-2 h-1 overflow-hidden rounded-full bg-primary/20`,children:(0,Y.jsx)(`div`,{className:`h-full animate-pulse bg-primary`,style:{width:`60%`}})}),(0,Y.jsx)(dn,{data:e})]})}function pn({data:e}){let{t}=C(),n=e.status===`active`||e.status===`streaming`,r=e.status===`error`,i=e.color||Z.success;return(0,Y.jsxs)(`div`,{className:L(`rounded-xl border-2 p-4 min-w-[180px] transition-all backdrop-blur-sm`,n&&`shadow-lg shadow-success/15`,r&&`border-destructive/50 bg-destructive/10`,!n&&!r&&`border-success/30 bg-success/10`),children:[(0,Y.jsx)($,{}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,Y.jsx)(`div`,{className:L(`flex items-center justify-center w-10 h-10 rounded-lg`,n?`bg-success/15`:`bg-success/10`),children:(0,Y.jsx)(v,{className:`h-5 w-5`,style:{color:i}})}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold truncate`,style:{color:i},children:e.label}),(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:t(`activity:office.tuiClient`)})]}),(0,Y.jsx)(Q,{status:e.status,activity:e.vizActivity??0})]}),e.sublabel&&(0,Y.jsx)(`div`,{className:`mb-2 truncate text-[10px] text-muted-foreground`,children:e.sublabel}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,Y.jsx)(v,{className:`h-3 w-3 text-success`}),(0,Y.jsx)(`span`,{children:t(`activity:office.terminal`)})]}),(0,Y.jsx)(dn,{data:e})]})}function mn({data:e}){let{t}=C(),n=e.status===`active`||e.status===`streaming`,r=e.color||Z.warning;return(0,Y.jsxs)(`div`,{className:L(`rounded-xl border-2 p-4 min-w-[160px] transition-all backdrop-blur-sm`,n&&`shadow-lg shadow-warning/15`,!n&&`border-warning/30 bg-warning/10`),children:[(0,Y.jsx)($,{}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,Y.jsx)(`div`,{className:L(`flex items-center justify-center w-10 h-10 rounded-lg`,n?`bg-warning/15`:`bg-warning/10`),children:(0,Y.jsx)(v,{className:`h-5 w-5`,style:{color:r}})}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold truncate`,style:{color:r},children:e.label}),(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:t(`activity:office.repl`)})]}),(0,Y.jsx)(Q,{status:e.status,activity:e.vizActivity??0})]}),e.sublabel&&(0,Y.jsx)(`div`,{className:`mb-1 truncate text-[10px] text-muted-foreground`,children:e.sublabel}),(0,Y.jsx)(dn,{data:e})]})}function hn({data:e}){let{t}=C(),n=e.status===`active`||e.status===`streaming`,r=e.color||Z.primary;return(0,Y.jsxs)(`div`,{className:`relative min-w-[200px] rounded-xl border-2 border-border/70 bg-card/90 p-4 shadow-lg backdrop-blur-sm transition-all`,children:[(0,Y.jsx)($,{}),(0,Y.jsx)(`div`,{className:`absolute -top-3 left-1/2 -translate-x-1/2 rounded-full bg-primary px-2 py-0.5 text-[11px] font-bold text-primary-foreground`,children:t(`activity:office.coordinator`)}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 mb-3 mt-2`,children:[(0,Y.jsx)(`div`,{className:L(`flex items-center justify-center w-12 h-12 rounded-xl`,n?`bg-primary/15`:`bg-primary/10`),children:(0,Y.jsx)(O,{className:`h-6 w-6`,style:{color:r}})}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-sm font-bold truncate`,style:{color:r},children:e.label}),(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:e.sublabel||t(`activity:office.fleetSummary`)})]}),(0,Y.jsx)(Q,{status:e.status,activity:e.vizActivity??0})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-[10px] mb-2`,children:[(0,Y.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,Y.jsxs)(`div`,{className:`font-mono`,children:[(0,Y.jsx)(`span`,{className:`text-success`,children:e.agentsActive||0}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:` / `}),(0,Y.jsx)(`span`,{className:`text-primary`,children:e.agentsTotal||0})]}),(0,Y.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:officeMap.agents`)})]}),(0,Y.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,Y.jsx)(`div`,{className:`font-mono text-warning`,children:(e.toolCalls||0).toLocaleString()}),(0,Y.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:office.toolCallsLabel`)})]}),(0,Y.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,Y.jsx)(`div`,{className:`font-mono text-foreground`,children:rt(e.tokensIn)}),(0,Y.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:office.tokensLabel`)})]}),(0,Y.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,Y.jsxs)(`div`,{className:`font-mono text-success`,children:[`$`,(e.costUsd||0).toFixed(3)]}),(0,Y.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:office.cost`)})]})]}),n&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-primary`,children:[(0,Y.jsx)(`span`,{className:`h-2 w-2 animate-pulse rounded-full bg-primary`}),t(`activity:office.coordinatingFleet`)]})]})}function gn({data:e}){let{t}=C(),n=e.status===`active`||e.status===`streaming`,r=e.status===`error`,i=e.status===`completed`,a=e.color||Z.primary,o=un(e.ctxPct);return(0,Y.jsxs)(`div`,{className:L(`w-[170px] min-w-0 max-w-[170px] overflow-hidden rounded-lg border p-3 transition-all backdrop-blur-sm`,n&&`border-primary/50 bg-primary/10 shadow-lg shadow-primary/10`,r&&`border-destructive/50 bg-destructive/10`,i&&`border-border/70 bg-muted/35`,!n&&!r&&!i&&`border-primary/30 bg-primary/10`),children:[(0,Y.jsx)($,{}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[(0,Y.jsx)(l,{className:`h-4 w-4 shrink-0`,style:{color:a}}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-[11px] font-bold truncate`,style:{color:a},children:e.label}),e.model&&(0,Y.jsx)(`div`,{className:`truncate text-[10px] text-muted-foreground`,children:ot(e.model)})]}),(0,Y.jsx)(Q,{status:e.status,small:!0,activity:e.vizActivity??0})]}),e.currentTask&&(0,Y.jsxs)(`div`,{className:`mb-1.5 flex min-w-0 items-center gap-1 overflow-hidden text-[11px] text-primary`,children:[(0,Y.jsx)(`span`,{className:L(`h-1.5 w-1.5 shrink-0 rounded-full bg-primary`,n&&`animate-pulse`)}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate font-mono`,title:e.currentTask,children:st(e.currentTask,72)})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-2 gap-y-0.5 text-[11px] mb-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex justify-between`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`iter`}),(0,Y.jsx)(`span`,{className:`font-mono text-foreground`,children:e.iteration||0})]}),(0,Y.jsxs)(`div`,{className:`flex justify-between`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`tools`}),(0,Y.jsx)(`span`,{className:`font-mono text-warning`,children:e.toolCalls||0})]}),(0,Y.jsxs)(`div`,{className:`flex justify-between`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`tok`}),(0,Y.jsx)(`span`,{className:`font-mono text-foreground`,children:rt((e.tokensIn||0)+(e.tokensOut||0))})]}),(0,Y.jsxs)(`div`,{className:`flex justify-between`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`cost`}),(0,Y.jsxs)(`span`,{className:`font-mono text-success`,children:[`$`,(e.costUsd||0).toFixed(3)]})]})]}),o>0&&(0,Y.jsxs)(`div`,{className:`mb-1`,children:[(0,Y.jsxs)(`div`,{className:`mb-0.5 flex justify-between text-[10px] text-muted-foreground`,children:[(0,Y.jsx)(`span`,{children:`ctx`}),(0,Y.jsxs)(`span`,{className:L(`font-mono`,o>=90?`text-destructive`:o>=70?`text-warning`:`text-muted-foreground`),children:[o,`%`]})]}),(0,Y.jsx)(`div`,{className:`h-1 overflow-hidden rounded-full bg-muted`,children:(0,Y.jsx)(`div`,{className:L(`h-full`,o>=90?`bg-destructive`:o>=70?`bg-warning`:`bg-primary`),style:{width:`${o}%`}})})]}),e.lastActivityAt&&(0,Y.jsxs)(`div`,{className:L(`flex items-center gap-1 text-[10px]`,n?`text-muted-foreground/70`:`text-muted-foreground`),children:[i&&(0,Y.jsx)(`span`,{className:`text-success`,children:t(`activity:office.donePrefix`)}),r&&(0,Y.jsx)(`span`,{className:`text-destructive`,children:t(`activity:office.failedPrefix`)}),(0,Y.jsx)(`span`,{children:t(`activity:office.seenPrefix`,{time:it(e.lastActivityAt,Date.now())})})]})]})}function _n({data:e}){let{t:n}=C();return(0,Y.jsxs)(`div`,{className:L(`rounded-lg border border-dashed p-3 min-w-[120px] transition-all opacity-40`,`border-border/70 bg-muted/30`),children:[(0,Y.jsx)($,{}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,Y.jsx)(t,{className:`h-4 w-4 text-muted-foreground`}),(0,Y.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,Y.jsx)(`div`,{className:`truncate text-[10px] text-muted-foreground`,children:e.label})}),(0,Y.jsx)(Q,{status:e.status,small:!0,activity:e.vizActivity??0})]}),(0,Y.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:n(`activity:office.availableDesk`)})]})}function vn({data:e}){let{t}=C(),n=e.color||Z.warning,r=(e.unreadCount||0)>0;return(0,Y.jsxs)(`div`,{className:L(`rounded-xl border-2 p-4 min-w-[160px] transition-all backdrop-blur-sm`,r&&`border-warning/50 bg-warning/10 shadow-lg shadow-warning/10`,!r&&`border-warning/30 bg-warning/6`),children:[(0,Y.jsx)($,{}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,Y.jsx)(`div`,{className:L(`flex items-center justify-center w-10 h-10 rounded-lg`,r?`bg-warning/18`:`bg-warning/10`),children:(0,Y.jsx)(o,{className:`h-5 w-5`,style:{color:n}})}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold`,style:{color:n},children:t(`activity:office.mailboxHub`)}),(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:r?t(`activity:office.unreadSuffix`,{count:e.unreadCount||0}):t(`activity:office.allClear`)})]}),r&&(0,Y.jsx)(`div`,{className:`flex h-5 w-5 items-center justify-center rounded-full bg-warning text-[10px] font-bold text-background`,children:e.unreadCount})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-[10px]`,children:[(0,Y.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-warning`,children:[(0,Y.jsx)(c,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{children:e.messageCount||0})]}),(0,Y.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:office.total`)})]}),(0,Y.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-success`,children:[(0,Y.jsx)(A,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{children:e.unreadCount||0})]}),(0,Y.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:office.unreadLabel`)})]})]}),e.sublabel&&(0,Y.jsxs)(`div`,{className:`mt-2 truncate border-t border-border/60 pt-1.5 text-[11px] text-muted-foreground`,children:[`✉ `,e.sublabel]})]})}var yn={webui:fn,tui:pn,repl:mn,coordinator:hn,agent:gn,mailbox:vn,desk:_n},bn={wire:({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:i,targetPosition:a,data:o,selected:s})=>{let c=o?.color||Z.primary,l=R(e=>e.animateEdges),u=o?.animated&&l?Math.max(.15,o?.intensity??.6):0,[d,f,p]=Ce({sourceX:e,sourceY:t,sourcePosition:i??S.Bottom,targetX:n,targetY:r,targetPosition:a??S.Top,curvature:.28}),m=5+u*7,h=5+u*4,g=m+h,_=`${Math.max(.5,1.6-u).toFixed(2)}s`;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`path`,{d,fill:`none`,stroke:c,strokeWidth:s?2.5:1.4,strokeOpacity:s?.9:.28,className:`react-flow__edge-path`}),u>.05&&(0,Y.jsx)(`path`,{d,fill:`none`,stroke:c,strokeWidth:2.2,strokeOpacity:.45+u*.5,strokeDasharray:`${m} ${h}`,strokeLinecap:`round`,style:{filter:`drop-shadow(0 0 ${2+u*4}px ${c})`},children:(0,Y.jsx)(`animate`,{attributeName:`stroke-dashoffset`,from:g,to:`0`,dur:_,repeatCount:`indefinite`})}),o?.label&&u>.1&&(0,Y.jsx)(P,{children:(0,Y.jsx)(`div`,{style:{position:`absolute`,transform:`translate(-50%, -50%) translate(${f}px, ${p}px)`},className:`pointer-events-none max-w-[220px] truncate whitespace-nowrap rounded-full border border-border/70 bg-card/90 px-1.5 py-0.5 text-[8px] font-medium text-foreground backdrop-blur-sm`,children:o.label})})]})}};function xn(){let{t:e}=C(),{clientCounts:t,currentSession:n,totalAgents:r,activeAgents:i,aggregate:o}=Ae(se(e=>({clientCounts:e.clientCounts,currentSession:e.currentSession,totalAgents:e.totalAgents,activeAgents:e.activeAgents,aggregate:e.aggregate}))),s=t.tui+t.webui+t.repl,c=e=>e?.toLocaleString()??`0`;return(0,Y.jsxs)(`div`,{className:`absolute left-4 top-20 z-10 rounded-xl border border-border/70 bg-card/90 p-3 text-foreground shadow-xl backdrop-blur`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,Y.jsx)(N,{className:`h-3.5 w-3.5 text-success`}),(0,Y.jsx)(`span`,{className:`text-[10px] font-bold uppercase text-muted-foreground`,children:e(`activity:office.sessionStats`)})]}),(0,Y.jsxs)(`div`,{className:`space-y-1.5 text-[10px]`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(he,{className:`h-3 w-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.clients`)})]}),(0,Y.jsxs)(`span`,{className:`font-mono text-foreground`,children:[i,` `,(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`/`}),` `,(0,Y.jsx)(`span`,{className:`text-success`,children:s})]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 pl-4 text-[9px]`,children:[t.tui>0&&(0,Y.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(v,{className:`h-2.5 w-2.5 text-success`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`TUI`}),(0,Y.jsx)(`span`,{className:`font-mono text-success`,children:t.tui})]}),t.webui>0&&(0,Y.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(a,{className:`h-2.5 w-2.5 text-primary`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`WebUI`}),(0,Y.jsx)(`span`,{className:`font-mono text-primary`,children:t.webui})]}),t.repl>0&&(0,Y.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(v,{className:`h-2.5 w-2.5 text-warning`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`REPL`}),(0,Y.jsx)(`span`,{className:`font-mono text-warning`,children:t.repl})]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(l,{className:`h-3 w-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:officeMap.agents`)})]}),(0,Y.jsxs)(`span`,{className:`font-mono text-foreground`,children:[i,` `,(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`/`}),` `,(0,Y.jsx)(`span`,{className:`text-primary`,children:r})]})]}),n.model&&(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(O,{className:`h-3 w-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:officeMap.model`)})]}),(0,Y.jsx)(`span`,{className:`max-w-[120px] truncate font-mono text-primary`,title:n.model,children:n.model.split(`/`).pop()?.slice(0,16)})]}),n.mode&&(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(w,{className:`h-3 w-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:officeMap.mode`)})]}),(0,Y.jsx)(`span`,{className:L(`font-mono uppercase text-[9px] px-1.5 py-0.5 rounded`,n.mode===`auto`&&`bg-primary/10 text-primary`,n.mode===`suggest`&&`bg-success/10 text-success`,n.mode===`off`&&`bg-muted text-muted-foreground`,![`auto`,`suggest`,`off`].includes(n.mode||``)&&`bg-muted text-muted-foreground`),children:n.mode})]}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(ue,{className:`h-3 w-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.toolCallsLabel`)})]}),(0,Y.jsx)(`span`,{className:`font-mono text-warning`,children:c(o.toolCalls)})]}),(0,Y.jsxs)(`div`,{className:`mt-1.5 space-y-1 border-t border-border/70 pt-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(`span`,{className:`text-[8px] text-muted-foreground`,children:`IN`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.input`)})]}),(0,Y.jsx)(`span`,{className:`font-mono text-[9px] text-foreground`,children:c(o.tokensIn)})]}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(`span`,{className:`text-[8px] text-muted-foreground`,children:`OUT`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.output`)})]}),(0,Y.jsx)(`span`,{className:`font-mono text-[9px] text-foreground`,children:c(o.tokensOut)})]})]}),(0,Y.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-between gap-4 border-t border-border/70 pt-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(x,{className:`h-3 w-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.cost`)})]}),(0,Y.jsx)(`span`,{className:`font-mono font-medium text-success`,children:(e=>e==null?`$0.0000`:`$${e.toFixed(4)}`)(o.costUsd)})]})]})]})}function Sn({events:e,now:t}){let{t:n}=C(),r=e.slice(0,14);return(0,Y.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 z-10 pointer-events-none px-3 pb-3`,children:(0,Y.jsxs)(`div`,{className:`pointer-events-auto mx-auto max-w-3xl rounded-lg border border-border/70 bg-card/90 px-3 py-2 shadow-xl backdrop-blur`,children:[(0,Y.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-1.5 text-[10px] uppercase text-primary`,children:[(0,Y.jsx)(N,{className:`h-3 w-3`}),n(`activity:office.liveActivity`)]}),r.length===0?(0,Y.jsx)(`div`,{className:`text-[11px] italic text-muted-foreground`,children:n(`activity:office.waitingActivity`)}):(0,Y.jsx)(`div`,{className:`flex flex-col gap-0.5 max-h-32 overflow-hidden`,children:r.map(e=>{let r=Math.max(0,Math.round((t-e.timestamp)/1e3));return(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] leading-tight`,children:[(0,Y.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0`,style:{backgroundColor:yt(e.kind)}}),(0,Y.jsx)(`span`,{className:`flex-1 truncate text-foreground`,children:e.label}),(0,Y.jsx)(`span`,{className:`shrink-0 tabular-nums text-muted-foreground`,children:r<1?n(`activity:office.now`):`${r}s`})]},e.id)})})]})})}function Cn(){let{t:e}=C(),{fitView:t}=k(),n=(0,U.useRef)(null),[r,i]=(0,U.useState)({width:1280,height:720});(0,U.useEffect)(()=>{let e=n.current;if(!e)return;let t=()=>{let{width:t,height:n}=e.getBoundingClientRect();t<1||n<1||i(e=>Math.abs(e.width-t)<2&&Math.abs(e.height-n)<2?e:{width:t,height:n})};t();let r=new ResizeObserver(t);return r.observe(e),()=>r.disconnect()},[]);let u=Ee(e=>e.events),d=Oe(e=>e.agents),f=Oe(e=>e.agentTranscripts),p=Oe(e=>e.leaderId),m=Ae(e=>e.liveSessions),h=je(e=>e.messages),y=je(e=>e.agents),b=De(e=>e.session),x=xt(d),S=(0,U.useMemo)(()=>vt(m,d,y,x.map,x.now),[m,d,y,x]),w=R(e=>e.showHud),te=R(e=>e.showLegend),E=R(e=>e.showMinimap),ne=R(e=>e.showControls),D=R(e=>e.showFeed),ae=R(e=>e.setShowFeed),A=R(e=>e.background),[se,j,ue]=fe([]),[de,M,N]=me([]),[P,pe]=(0,U.useState)(null),[F,he]=(0,U.useState)(null),[ge,ve]=(0,U.useState)(!1),[I,ye]=(0,U.useState)(``),[be,xe]=(0,U.useState)(!1),[Se,Ce]=(0,U.useState)(null),we=(0,U.useMemo)(()=>{if(P?.data.kind!==`agent`)return ke;let e=P.data.serverId??(P.id.includes(`__agent-`)?P.id.split(`__agent-`).pop():P.id.replace(/^agent-/,``));return e?f.get(e)??ke:ke},[f,P]),Te=(0,U.useCallback)(async()=>{let e=I.trim();if(!(!e||be)){xe(!0),Ce(null);try{let t=await fetch(`/api/fleet/broadcast`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:e})});if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();ye(``),Ce(`Delivered to ${n.delivered??0}/${n.targets??0} session(s)`)}catch(e){Ce(`Failed: ${e instanceof Error?e.message:String(e)}`)}finally{xe(!1)}}},[I,be]),z=(0,U.useRef)(new Map),B=4e3,V=(0,U.useRef)(new Map),H=(0,U.useRef)(new Map),Me=(0,U.useRef)(new Map),Ne=(0,U.useRef)(new Map),Fe=(0,U.useRef)(``);(0,U.useEffect)(()=>{let n=[],i=[],a=Date.now(),o=ct(S.map(e=>({id:e.id,agentCount:e.agents.length})),r),s=h.filter(e=>!e.completed&&(e.readByCount??0)===0).length,c=h.length?[...h].sort((e,t)=>Date.parse(t.timestamp)-Date.parse(e.timestamp))[0]:void 0;n.push({id:`mailbox`,type:`mailbox`,position:{x:830,y:50},data:{label:e(`activity:office.mailboxHub`),kind:`mailbox`,status:s>0?`active`:`idle`,unreadCount:s,messageCount:h.length,sublabel:c?`${c.from} → ${c.to}: ${c.subject}`:void 0,color:Z.warning}});let l=0,u=0,f=0,m=0,g=0;for(let e of S)for(let t of e.agents)u+=1,(t.status===`active`||t.status===`streaming`)&&(l+=1),f+=t.toolCalls,m+=t.costUsd,g+=t.tokensIn+t.tokensOut;let _=p?d.get(p):null,v=l>0;n.push({id:`coordinator`,type:`coordinator`,position:{x:370,y:50},data:{label:e(`activity:office.fleetHqLabel`),sublabel:e(`activity:office.clientsSuffix`,{count:S.length}),kind:`coordinator`,status:_?.status===`failed`?`error`:v?`active`:`idle`,connections:S.length,agentsActive:l,agentsTotal:u,toolCalls:f,costUsd:m,tokensIn:g,color:Z.primary}});let y={tui:Z.success,webui:Z.info,repl:Z.warning};for(let t of S){let r=o.positions.get(t.id)??{x:600,y:370},c=r.x,l=r.y,u=y[t.type],d=t.status===`active`;if(n.push({id:t.id,type:t.type,position:{x:c,y:l},data:{label:t.label,sublabel:t.sublabel,kind:t.type,status:t.status,sessionId:t.sessionId,pid:t.pid,branch:t.branch,workingDir:t.workingDir,startedAt:t.startedAt,agentCount:t.agents.length,color:u}}),i.push({id:`${t.id}->coordinator`,source:t.id,target:`coordinator`,type:`wire`,animated:d,data:{color:u,animated:d,label:e(`activity:office.controlLabel`),flowType:`task`}}),i.push({id:`mailbox->${t.id}`,source:`mailbox`,target:t.id,type:`wire`,animated:s>0,data:{color:Z.warning,animated:s>0,label:s>0?`${s}`:void 0,flowType:`mail`}}),t.agents.length===0){n.push({id:`desk-${t.id}`,type:`desk`,position:{x:c,y:l+270},data:{label:e(`activity:office.idleDesk`),kind:`agent`,status:`idle`,color:Z.muted}});continue}t.agents.forEach((r,o)=>{let s=r.status===`active`||r.status===`streaming`,u=Ne.current.get(r.serverId);if(u&&(r.toolCalls>u.toolCalls||r.iteration>u.iteration)||s){z.current.set(r.officeId,a+B);let e=H.current.get(r.officeId)??0;H.current.set(r.officeId,Math.min(1,e+(1-e)*.5));for(let e of[`${t.id}->${r.officeId}`,`${t.id}->coordinator`]){let t=V.current.get(e)??0;V.current.set(e,Math.min(1,t+.5))}}Ne.current.set(r.serverId,{toolCalls:r.toolCalls,iteration:r.iteration}),n.push({id:r.officeId,type:`agent`,position:lt(c,o,t.agents.length,l+270),data:{label:r.name,kind:`agent`,status:r.status,serverId:r.serverId,sessionId:t.sessionId,currentTask:r.currentTask,iteration:r.iteration,toolCalls:r.toolCalls,costUsd:r.costUsd,tokensIn:r.tokensIn,tokensOut:r.tokensOut,ctxPct:r.ctxPct,model:r.model,lastActivityAt:r.lastActivityAt,color:Z.primary}}),i.push({id:`${t.id}->${r.officeId}`,source:t.id,target:r.officeId,type:`wire`,animated:s,data:{color:Z.primary,animated:s,label:s?st(r.currentTask,48)??e(`activity:office.taskFallback`):void 0,flowType:`task`}})})}let b=new Set(S.flatMap(e=>e.agents.map(e=>e.serverId)));for(let e of[...Ne.current.keys()])b.has(e)||Ne.current.delete(e);let x=n.map(e=>{let t=z.current.get(e.id),n=H.current.get(e.id)??0;return t&&t>a&&e.data.status!==`error`&&e.data.status!==`offline`?{...e,data:{...e.data,status:`active`,vizActivity:n}}:{...e,data:{...e.data,vizActivity:n}}}),ee=i.map(e=>{let t=V.current.get(e.id)??0;return t>.05?{...e,animated:!0,data:{...e.data,animated:!0,intensity:t}}:e}),C=new Map;for(let e of x)C.set(e.id,{...e.position});Me.current=C,j(x),M(ee);let w=[`${Math.round(r.width)}x${Math.round(r.height)}`,`${o.columns}x${o.rows}`,S.map(e=>`${e.id}:${e.agents.length}`).join(`|`),x.map(e=>e.id).sort().join(`|`)].join(`:`);if(w!==Fe.current){Fe.current=w;let e=setTimeout(()=>t({padding:ln,duration:300}),50);return()=>clearTimeout(e)}},[S,p,d,h,b,r,B,j,M,t]);let Ie=S.flatMap(e=>e.agents.map(t=>({clientId:e.id,clientType:e.type,officeId:t.officeId,serverId:t.serverId}))),W=S.map(e=>e.id),G=new Map;for(let e of Ie)(!G.has(e.serverId)||e.clientType===`webui`)&&G.set(e.serverId,e.officeId);function K(e){return G.get(e)??`agent-${e}`}function q(e){let t=e.split(`__agent-`)[0];return t&&t!==e?`${t}->${e}`:`coordinator->${e}`}function Le(e){switch(e.kind){case`mailbox:send`:case`mailbox:deliver`:return{nodes:[`mailbox`],edges:e.kind===`mailbox:send`?W.map(e=>`mailbox->${e}`):[],status:`active`};case`agent:spawned`:{let t=K(e.source);return{nodes:[`coordinator`,t],edges:[q(t)],status:`active`}}case`agent:tool`:case`tool:started`:case`tool:progress`:{let t=K(e.source);return{nodes:[`coordinator`,t],edges:[q(t)],status:e.kind===`tool:progress`||e.kind===`tool:started`?`streaming`:`active`}}case`tool:executed`:{let t=K(e.target??e.source);return{nodes:[t],edges:[q(t)],status:`active`}}case`provider:call`:case`provider:delta`:case`provider:response`:return{nodes:[`coordinator`],edges:[],status:e.kind===`provider:delta`?`streaming`:`active`};case`iteration:start`:case`iteration:end`:return{nodes:[`coordinator`],edges:Ie.map(e=>q(e.officeId)),status:e.kind===`iteration:start`?`streaming`:`active`};case`agent:text`:{let t=K(e.source);return{nodes:[t],edges:[q(t)],status:`streaming`}}case`agent:status`:{let t=K(e.source);return{nodes:[`coordinator`,t],edges:[q(t)],status:e.data&&typeof e.data==`object`&&`status`in e.data&&String(e.data.status)===`failed`?`error`:`completed`}}case`agent:ctx`:return{nodes:[K(e.source)],edges:[],status:`active`};case`budget:extended`:return{nodes:[`coordinator`,K(e.source)],edges:[],status:`active`};case`context:compacted`:case`context:repaired`:return{nodes:[`coordinator`],edges:[],status:`active`};case`error`:return{nodes:e.source?[K(e.source)]:[],edges:[],status:`error`};case`cost:update`:return{nodes:[`coordinator`],edges:[],status:`active`};case`fleet:snapshot`:{let t=e.data?.sessions??[],n=[`coordinator`];for(let e of t)if(e.agents)for(let t of e.agents){let e=K(t.id);n.includes(e)||n.push(e)}return{nodes:n,edges:[],status:`active`}}default:return{nodes:[],edges:[],status:`idle`}}}(0,U.useEffect)(()=>{if(u.length===0)return;let e=u[0];if(!e)return;let{nodes:t,edges:n,status:r}=Le(e),i=Date.now();t.length>0&&(t.forEach(e=>{z.current.set(e,i+B);let t=H.current.get(e)??0;H.current.set(e,Math.min(1,t+(1-t)*.5))}),j(e=>e.map(e=>t.includes(e.id)?{...e,data:{...e.data,status:r,vizActivity:H.current.get(e.id)??0}}:e))),n.length>0&&(n.forEach(e=>{let t=V.current.get(e)??0;V.current.set(e,Math.min(1,t+.5))}),M(e=>e.map(e=>n.includes(e.id)?{...e,animated:!0,data:{...e.data,animated:!0,intensity:V.current.get(e.id)??1}}:e)))},[u,j,M,B,d]),(0,U.useEffect)(()=>{let e=setInterval(()=>{let e=new Map,t=!1;for(let[n,r]of V.current){let i=r*.85;i<.05?(V.current.delete(n),e.set(n,{intensity:0,animated:!1}),t=!0):(V.current.set(n,i),e.set(n,{intensity:i,animated:!0}),t=!0)}t&&M(t=>t.map(t=>{let n=e.get(t.id);return n?{...t,animated:n.animated,data:{...t.data,animated:n.animated,intensity:n.intensity}}:t}));let n=new Map,r=!1;for(let[e,t]of H.current){let i=t*.9;i<.03?(H.current.delete(e),n.set(e,0),r=!0):(H.current.set(e,i),n.set(e,i),r=!0)}r&&j(e=>e.map(e=>{let t=n.get(e.id);return t===void 0?e:{...e,data:{...e.data,vizActivity:t}}}))},1e3);return()=>clearInterval(e)},[M,j]);let Re=(0,U.useCallback)(e=>M(t=>re({...e,type:`wire`},t)),[M]),ze=(0,U.useCallback)((e,t)=>{pe(t)},[]),Be=(0,U.useCallback)(()=>{pe(null)},[]);(0,U.useEffect)(()=>{if(!F)return;let e=e=>{e.key===`Escape`&&he(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[F]);let Ve=(0,U.useCallback)(()=>{j(e=>e.map(e=>{let t=Me.current.get(e.id);return t?{...e,position:{...t}}:e})),setTimeout(()=>t({padding:ln,duration:300}),50)},[j,t]),[,He]=(0,U.useState)(0);return(0,U.useEffect)(()=>{let e=setInterval(()=>{document.hidden||He(e=>e+1)},2e3);return()=>clearInterval(e)},[]),(0,Y.jsxs)(`div`,{ref:n,className:`relative h-full w-full overflow-hidden bg-[hsl(var(--surface-2)/0.55)]`,children:[(0,Y.jsx)(`div`,{className:`absolute inset-0 opacity-[0.03]`,style:{backgroundImage:`
2
- linear-gradient(rgba(255,255,255,0.1) 1px, transparent 1px),
3
- linear-gradient(90deg, rgba(255,255,255,0.1) 1px, transparent 1px)
4
- `,backgroundSize:`40px 40px`}}),w&&(0,Y.jsx)(xn,{}),(0,Y.jsx)(`div`,{className:`absolute top-3 left-1/2 -translate-x-1/2 z-10`,children:(0,Y.jsx)(`div`,{className:`rounded-lg border border-border/70 bg-card/90 px-4 py-2 shadow-xl backdrop-blur`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-bold text-foreground`,children:[(0,Y.jsx)(ce,{className:`h-4 w-4 text-primary`}),e(`activity:office.fleetHq`),(0,Y.jsx)(`span`,{className:`ml-2 h-2 w-2 animate-pulse rounded-full bg-success`}),(0,Y.jsx)(`span`,{className:`text-[10px] font-normal text-muted-foreground`,children:e(`activity:office.live`)})]})})}),te&&(0,Y.jsxs)(`div`,{className:`absolute bottom-4 left-4 z-10 rounded-lg border border-border/70 bg-card/90 p-3 text-[10px] shadow-xl backdrop-blur`,children:[(0,Y.jsx)(`div`,{className:`mb-2 font-bold text-foreground`,children:e(`activity:office.legendStatus`)}),(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`h-2 w-2 animate-pulse rounded-full bg-success`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.legendActive`)})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`h-2 w-2 rounded-full bg-muted-foreground`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.legendIdle`)})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`h-2 w-2 animate-pulse rounded-full bg-destructive`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.legendError`)})]})]})]}),te&&(0,Y.jsxs)(`div`,{className:`absolute bottom-4 right-4 z-10 rounded-lg border border-border/70 bg-card/90 p-3 text-[10px] shadow-xl backdrop-blur`,children:[(0,Y.jsx)(`div`,{className:`mb-2 font-bold text-foreground`,children:e(`activity:office.legendConnections`)}),(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-warning`,children:`✉`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.legendMail`)})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-primary`,children:`→`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.legendTask`)})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-success`,children:`●`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.legendStatusConn`)})]})]})]}),(0,Y.jsxs)(ie,{nodes:se,edges:de,onNodesChange:ue,onEdgesChange:N,onConnect:Re,onNodeClick:ze,onPaneClick:Be,nodeTypes:yn,edgeTypes:bn,fitView:!0,fitViewOptions:{padding:ln},minZoom:.15,maxZoom:1.5,defaultEdgeOptions:{type:`wire`},proOptions:{hideAttribution:!0},children:[(0,Y.jsxs)(le,{position:`top-right`,className:`flex items-center gap-2`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:Ve,title:e(`activity:office.arrangeTitle`),className:`flex items-center gap-1.5 rounded-md border border-border/70 bg-card/90 px-2.5 py-1.5 text-xs text-foreground shadow-sm transition-colors hover:bg-accent`,children:[(0,Y.jsx)(_,{className:`h-3.5 w-3.5`}),e(`activity:office.arrange`)]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>ae(!D),title:e(`activity:office.feedTitle`),className:L(`flex items-center gap-1.5 px-2.5 py-1.5 rounded-md border text-xs transition-colors`,D?`border-primary/35 bg-primary/10 text-primary`:`border-border/70 bg-card/90 text-muted-foreground hover:bg-accent hover:text-foreground`),children:[(0,Y.jsx)(s,{className:`h-3.5 w-3.5`}),e(`activity:office.feed`)]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>ve(e=>!e),title:e(`activity:office.broadcastTitle`),className:L(`flex items-center gap-1.5 px-2.5 py-1.5 rounded-md border text-xs transition-colors`,ge?`border-warning/35 bg-warning/10 text-warning`:`border-border/70 bg-card/90 text-muted-foreground hover:bg-accent hover:text-foreground`),children:[(0,Y.jsx)(c,{className:`h-3.5 w-3.5`}),e(`activity:office.broadcast`)]})]}),A!==`none`&&(0,Y.jsx)(_e,{variant:A===`lines`?oe.Lines:A===`cross`?oe.Cross:oe.Dots,gap:20,size:1,color:`hsl(var(--border) / 0.35)`}),ne&&(0,Y.jsx)(ee,{className:`rounded-lg border border-border/70 bg-card/90 [&>button]:bg-card [&>button]:text-foreground`}),E&&(0,Y.jsx)(T,{className:`rounded-lg border border-border/70 bg-card/90`,nodeColor:e=>{switch(e.data.kind){case`coordinator`:return Z.primary;case`webui`:return Z.info;case`tui`:return Z.success;case`repl`:return Z.warning;case`mailbox`:return Z.warning;case`agent`:return Z.primary;default:return Z.primary}},maskColor:`hsl(var(--background) / 0.72)`})]}),D&&(0,Y.jsx)(Sn,{events:u,now:Date.now()}),ge&&(0,Y.jsxs)(`div`,{className:`absolute right-4 top-16 z-30 w-80 rounded-xl border border-warning/35 bg-card/95 p-3 shadow-2xl backdrop-blur`,children:[(0,Y.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] font-semibold text-warning`,children:[(0,Y.jsx)(c,{className:`h-3.5 w-3.5`}),` `,e(`activity:office.broadcastToAll`)]}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>ve(!1),className:`text-base leading-none text-muted-foreground hover:text-foreground`,children:`×`})]}),(0,Y.jsx)(`textarea`,{value:I,onChange:e=>ye(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),Te())},rows:3,placeholder:e(`activity:office.broadcastPlaceholder`),className:`w-full resize-none rounded-md border border-border/70 bg-background/70 px-2 py-1 text-[11px] text-foreground placeholder:text-muted-foreground focus:border-warning/45 focus:outline-none`}),(0,Y.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-between`,children:[(0,Y.jsx)(`span`,{className:`text-[9px] text-muted-foreground`,children:e(`activity:office.broadcastSendHint`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>void Te(),disabled:be||!I.trim(),className:`rounded-md border border-warning/35 bg-warning/12 px-2.5 py-1 text-[11px] text-warning transition-colors hover:bg-warning/18 disabled:cursor-not-allowed disabled:opacity-40`,children:be?`…`:e(`activity:office.broadcast`)})]}),Se&&(0,Y.jsx)(`div`,{className:`mt-1 text-[10px] text-muted-foreground`,children:Se})]}),P&&(0,Y.jsxs)(`div`,{className:L(`absolute top-20 right-4 bg-background border border-border rounded-lg p-4 shadow-xl z-20`,P.data.kind===`agent`?`w-[28rem] max-w-[calc(100%-2rem)]`:P.data.sessionId?`w-80`:`w-64`),children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[P.data.kind===`webui`&&(0,Y.jsx)(a,{className:`h-4 w-4 text-info`}),P.data.kind===`tui`&&(0,Y.jsx)(v,{className:`h-4 w-4 text-success`}),P.data.kind===`coordinator`&&(0,Y.jsx)(O,{className:`h-4 w-4 text-primary`}),P.data.kind===`agent`&&(0,Y.jsx)(l,{className:`h-4 w-4 text-primary`}),P.data.kind===`mailbox`&&(0,Y.jsx)(o,{className:`h-4 w-4 text-warning`}),(0,Y.jsx)(`span`,{className:`text-sm font-bold text-foreground`,children:P.data.label})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[P.data.sessionId&&(0,Y.jsx)(`button`,{type:`button`,title:e(`activity:office.openFullView`),onClick:()=>he({sessionId:P.data.sessionId,label:P.data.label}),className:`text-muted-foreground hover:text-primary`,children:(0,Y.jsx)(g,{className:`h-3.5 w-3.5`})}),(0,Y.jsx)(`button`,{type:`button`,onClick:Be,className:`text-muted-foreground hover:text-foreground text-lg leading-none`,children:`×`})]})]}),(()=>{let t=P.data,n=Date.now(),r=({k:e,v:t,accent:n})=>(0,Y.jsxs)(`div`,{className:`flex justify-between gap-3`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:e}),(0,Y.jsx)(`span`,{className:L(`font-mono truncate text-right`,n??`text-foreground/80`),children:t})]}),i=t.kind===`agent`,a=t.kind===`webui`||t.kind===`tui`||t.kind===`repl`,o=(t.tokensIn||0)+(t.tokensOut||0),s=un(t.ctxPct);return(0,Y.jsxs)(`div`,{className:`space-y-1.5 text-xs`,children:[(0,Y.jsx)(r,{k:`Status`,v:String(t.status).toUpperCase(),accent:L(t.status===`active`&&`text-success`,t.status===`streaming`&&`text-primary`,t.status===`error`&&`text-destructive`,t.status===`idle`&&`text-muted-foreground`,t.status===`offline`&&`text-muted-foreground/70`)}),i&&(0,Y.jsxs)(Y.Fragment,{children:[t.model&&(0,Y.jsx)(r,{k:`Model`,v:ot(t.model),accent:`text-primary`}),t.currentTask&&(0,Y.jsxs)(`div`,{className:`pt-1`,children:[(0,Y.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:e(`activity:agentOffice.currentTask`)}),(0,Y.jsx)(`div`,{className:`mt-1 max-h-32 overflow-y-auto whitespace-pre-wrap break-words font-mono text-[10px] text-primary`,children:t.currentTask})]}),(0,Y.jsx)(r,{k:`Iterations`,v:t.iteration||0,accent:`text-primary`}),(0,Y.jsx)(r,{k:`Tool calls`,v:t.toolCalls||0,accent:`text-warning`}),(0,Y.jsx)(r,{k:`Tokens in`,v:rt(t.tokensIn)}),(0,Y.jsx)(r,{k:`Tokens out`,v:rt(t.tokensOut)}),(0,Y.jsx)(r,{k:`Tokens total`,v:rt(o)}),s>0&&(0,Y.jsx)(r,{k:`Context`,v:`${s}%`,accent:s>=90?`text-destructive`:s>=70?`text-warning`:`text-foreground/70`}),(0,Y.jsx)(r,{k:`Cost`,v:`$${(t.costUsd||0).toFixed(4)}`,accent:`text-success`}),t.lastActivityAt&&(0,Y.jsx)(r,{k:`Last seen`,v:it(t.lastActivityAt,n),accent:`text-muted-foreground`}),(0,Y.jsx)(`div`,{className:`pt-2`,children:(0,Y.jsx)(Pe,{entries:we,agentName:t.label,compact:!0,maxHeightClassName:`max-h-64`})})]}),a&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(r,{k:`Surface`,v:dt(t.kind),accent:`text-foreground/80`}),t.branch&&(0,Y.jsx)(r,{k:`Branch`,v:`⎇ ${t.branch}`,accent:`text-foreground/70`}),t.pid!=null&&(0,Y.jsx)(r,{k:`PID`,v:t.pid}),t.workingDir&&(0,Y.jsx)(r,{k:`Dir`,v:t.workingDir,accent:`text-muted-foreground`}),(0,Y.jsx)(r,{k:`Agents`,v:t.agentCount??0,accent:`text-primary`}),t.startedAt&&(0,Y.jsx)(r,{k:`Uptime`,v:at(t.startedAt,n),accent:`text-foreground/70`})]}),t.kind===`mailbox`&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(r,{k:`Total messages`,v:t.messageCount||0,accent:`text-warning`}),(0,Y.jsx)(r,{k:`Unread`,v:t.unreadCount||0,accent:`text-warning`}),h.length>0&&(0,Y.jsxs)(`div`,{className:`mt-1 space-y-1 border-t border-border pt-2`,children:[(0,Y.jsx)(`div`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:e(`activity:office.recent`)}),[...h].sort((e,t)=>Date.parse(t.timestamp)-Date.parse(e.timestamp)).slice(0,6).map(t=>(0,Y.jsxs)(`div`,{className:`flex items-start gap-1.5 text-[10px]`,children:[(0,Y.jsx)(`span`,{className:L(`mt-1 h-1.5 w-1.5 shrink-0 rounded-full`,!t.completed&&(t.readByCount??0)===0?`bg-warning`:t.completed?`bg-success`:`bg-muted`)}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`div`,{className:`truncate text-foreground/80`,children:t.subject||e(`activity:office.noSubject`)}),(0,Y.jsxs)(`div`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:[t.from,` → `,t.to,` · `,it(t.timestamp,n),t.audience===`leaders`?` · ${e(`activity:mailbox.audienceLeaders`)}`:``]})]})]},t.id))]})]}),t.kind===`coordinator`&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(r,{k:`Connections`,v:t.connections||0,accent:`text-primary`}),(0,Y.jsx)(r,{k:`Iterations`,v:t.iteration||0,accent:`text-primary`})]}),(i||a)&&t.sessionId&&(0,Y.jsx)(`div`,{className:`mt-2 border-t border-border pt-2 h-72`,children:(0,Y.jsx)(cn,{sessionId:t.sessionId})})]})})()]}),F&&(0,Y.jsxs)(`div`,{className:`absolute inset-y-0 right-0 z-30 flex w-[min(680px,92%)] flex-col border-l border-border bg-background shadow-2xl`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border px-4 py-2.5 shrink-0 bg-card`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,Y.jsx)(l,{className:`h-4 w-4 text-primary shrink-0`}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`div`,{className:`truncate text-sm font-bold text-foreground`,children:F.label}),(0,Y.jsx)(`div`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:e(`activity:office.fullOperationStream`)})]})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>he(null),title:e(`activity:office.closeEsc`),className:`text-muted-foreground hover:text-foreground text-xl leading-none shrink-0`,children:`×`})]}),(0,Y.jsx)(`div`,{className:`flex-1 min-h-0 p-4`,children:(0,Y.jsx)(cn,{sessionId:F.sessionId,limit:500})})]})]})}function wn(){let{t:e}=C(),t=R(e=>e.viewMode),n=R(e=>e.setViewMode),i=[{id:`office`,label:e(`activity:agentOffice.office`),description:e(`activity:agentOffice.officeDescription`),icon:ae},{id:`topology`,label:e(`activity:agentOffice.topology`),description:e(`activity:agentOffice.topologyDescription`),icon:r}],a=(e,t)=>{let r;if(e.key===`ArrowLeft`&&(r=(t-1+i.length)%i.length),e.key===`ArrowRight`&&(r=(t+1)%i.length),e.key===`Home`&&(r=0),e.key===`End`&&(r=i.length-1),r===void 0)return;e.preventDefault();let a=i[r];a&&(n(a.id),e.currentTarget.parentElement?.querySelectorAll(`[role="tab"]`)[r]?.focus())};return(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 w-full flex-col bg-background`,children:[(0,Y.jsx)(`nav`,{"aria-label":`${e(`activity:agentOffice.office`)} / ${e(`activity:agentOffice.topology`)}`,className:`relative z-[60] shrink-0 border-b border-border bg-card/95 px-3 pt-2 shadow-[0_8px_28px_hsl(var(--shadow-color)/0.1)] backdrop-blur-xl sm:px-5`,children:(0,Y.jsx)(`div`,{role:`tablist`,"aria-orientation":`horizontal`,className:`mx-auto grid w-full max-w-3xl grid-cols-2 gap-1`,children:i.map((e,r)=>{let i=e.icon,o=t===e.id;return(0,Y.jsxs)(`button`,{id:`office-map-tab-${e.id}`,type:`button`,role:`tab`,"aria-selected":o,"aria-controls":`office-map-view-panel`,tabIndex:o?0:-1,onClick:()=>n(e.id),onKeyDown:e=>a(e,r),className:L(`group relative flex min-w-0 items-center gap-2.5 border-b-2 px-3 py-2.5 text-left transition-all duration-200 sm:gap-3 sm:px-5`,o?`border-primary bg-primary/[0.07] text-foreground`:`border-transparent text-muted-foreground hover:border-border hover:bg-accent/60 hover:text-foreground`),children:[(0,Y.jsx)(`span`,{className:L(`grid h-8 w-8 shrink-0 place-items-center rounded-lg border transition-colors`,o?`border-primary/35 bg-primary/15 text-primary`:`border-border bg-background/70 text-muted-foreground group-hover:text-foreground`),children:(0,Y.jsx)(i,{className:`h-4 w-4`,"aria-hidden":`true`})}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`strong`,{className:`block truncate font-display text-xs font-semibold sm:text-sm`,children:e.label}),(0,Y.jsx)(`small`,{className:`hidden truncate font-mono text-[9px] font-normal text-muted-foreground sm:block`,children:e.description})]}),(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:L(`ml-auto h-1.5 w-1.5 shrink-0 rounded-full transition-all`,o?`bg-primary shadow-[0_0_0_4px_hsl(var(--primary)/0.12)]`:`bg-border`)})]},e.id)})})}),(0,Y.jsx)(`div`,{id:`office-map-view-panel`,role:`tabpanel`,"aria-labelledby":`office-map-tab-${t}`,className:`relative min-h-0 flex-1`,children:t===`office`?(0,Y.jsx)(en,{}):(0,Y.jsx)(be,{children:(0,Y.jsx)(Cn,{})})})]})}export{wn as OfficeMapPanel};
@@ -1,2 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{$n as t,$t as n,Ar as r,Cn as i,Ct as a,Di as o,Et as s,Ft as c,Hi as l,It as u,Kt as d,Li as f,Mt as p,Ni as m,Oi as h,Pn as g,Pt as _,Ti as v,Tt as y,Vn as b,Vt as x,Yi as S,_ as C,a as w,aa as T,at as E,bi as ee,bt as D,c as te,ca as O,ci as k,ei as A,en as j,f as M,gt as ne,h as N,hr as re,i as P,kn as ie,ln as F,mn as ae,mt as I,na as L,ot as R,pi as z,pr as B,qr as V,r as H,s as U,tt as W,u as G,ua as K,yi as q,yt as oe}from"./vendor-BmsAdDhb.js";import"./i18n-c37VNlP9.js";import{t as se}from"./useWebSocket-kb2VPjLc.js";import{t as J}from"./utils-DvgvNCoT.js";import{a as ce,o as Y}from"./stores-DVhvmaer.js";import{s as le}from"./view-navigation-D8lN47bJ.js";import{a as ue,i as de,n as fe,o as pe,r as me,t as he}from"./dialog-BjPQYovj.js";import{n as ge,t as _e}from"./ModelPicker-fGNsJUXK.js";import{t as X}from"./button-GVbauxIJ.js";import{u as ve,y as ye}from"./index-196U0qsu.js";import{SpecsView as be}from"./SpecsView-Dh9YG8Id.js";var Z=e(K(),1),xe={pending:{label:`Pending`,icon:q,text:`text-muted-foreground`,ring:`border-border/70 bg-muted/45`,dot:`bg-muted-foreground`,hex:`hsl(var(--muted-foreground))`},queued:{label:`Ready`,icon:q,text:`text-primary`,ring:`border-primary/35 bg-primary/10`,dot:`bg-primary`,hex:`hsl(var(--primary))`},in_progress:{label:`Running`,icon:b,spin:!0,text:`text-warning`,ring:`border-warning/45 bg-warning/10`,dot:`bg-warning`,hex:`hsl(var(--warning))`},blocked:{label:`Blocked`,icon:q,text:`text-destructive`,ring:`border-destructive/30 bg-destructive/10`,dot:`bg-destructive`,hex:`hsl(var(--destructive))`},review:{label:`Review`,icon:q,text:`text-primary`,ring:`border-primary/35 bg-primary/10`,dot:`bg-primary`,hex:`hsl(var(--info))`},failed:{label:`Failed`,icon:R,text:`text-destructive`,ring:`border-destructive/45 bg-destructive/10`,dot:`bg-destructive`,hex:`hsl(var(--destructive))`},completed:{label:`Done`,icon:h,text:`text-success`,ring:`border-success/35 bg-success/10`,dot:`bg-success`,hex:`hsl(var(--success))`},cancelled:{label:`Cancelled`,icon:l,text:`text-muted-foreground`,ring:`border-border/70 bg-muted/45`,dot:`bg-muted-foreground`,hex:`hsl(var(--muted-foreground))`}};function Se(e){return xe[e]??xe.pending}var Ce={critical:{text:`text-destructive`,chip:`bg-destructive/10 text-destructive`},high:{text:`text-warning`,chip:`bg-warning/12 text-warning`},medium:{text:`text-primary`,chip:`bg-primary/10 text-primary`},low:{text:`text-muted-foreground`,chip:`bg-muted text-muted-foreground`}};function we(e){return Ce[e]??Ce.medium}var Te={running:`border-primary/35 bg-primary/10 text-primary`,paused:`border-warning/35 bg-warning/10 text-warning`,stopped:`border-border/70 bg-muted text-muted-foreground`,completed:`border-success/35 bg-success/10 text-success`,failed:`border-destructive/35 bg-destructive/10 text-destructive`,deadlocked:`border-destructive/35 bg-destructive/10 text-destructive`,idle:`border-border bg-muted text-muted-foreground`},Ee=[`bg-warning`,`bg-primary`,`bg-success`,`bg-destructive`,`bg-secondary`,`bg-muted-foreground`,`bg-accent`],De={started:{icon:F,color:`text-warning`},completed:{icon:h,color:`text-success`},failed:{icon:R,color:`text-destructive`},retrying:{icon:n,color:`text-warning`},wave:{icon:t,color:`text-primary`},deadlock:{icon:D,color:`text-destructive`},verification_failed:{icon:x,color:`text-destructive`},conflict:{icon:B,color:`text-warning`},split:{icon:_,color:`text-primary`},supervisor:{icon:m,color:`text-primary`}};function Oe(e){let t=e.trim().split(/\s+/);return((t[0]?.[0]??``)+(t[1]?.[0]??``)).toUpperCase()||`·`}function ke(e){let t=Math.max(0,Math.floor(e/1e3));if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?t%60?`${n}m ${t%60}s`:`${n}m`:`${Math.floor(n/60)}h ${n%60}m`}function Ae(e,t){let n=Math.max(0,Math.floor((t-e)/1e3));if(n<60)return`${n}s`;let r=Math.floor(n/60);return r<60?`${r}m`:`${Math.floor(r/60)}h`}var Q=W();function je({feed:e,now:t}){let{t:n}=T();return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-border px-3 py-2 text-xs font-semibold text-foreground`,children:[(0,Q.jsx)(L,{className:`h-3.5 w-3.5 text-warning`}),n(`activity:sdd.activityHeading`)]}),(0,Q.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 space-y-1 overflow-auto overscroll-contain p-2`,children:e.length===0?(0,Q.jsx)(`p`,{className:`px-1 pt-4 text-center text-[11px] text-muted-foreground`,children:n(`activity:sdd.feedEmpty`)}):e.map((e,n)=>{let r=De[e.kind]??De.started,i=r.icon;return(0,Q.jsxs)(`div`,{className:J(`sdd-rise flex items-start gap-2 rounded-md px-2 py-1.5 text-[11px]`,n===0?`bg-muted`:`hover:bg-muted`),children:[(0,Q.jsx)(i,{className:J(`mt-0.5 h-3.5 w-3.5 shrink-0`,r.color)}),(0,Q.jsx)(`span`,{className:`flex-1 leading-snug text-foreground`,children:e.text}),(0,Q.jsx)(`span`,{className:`shrink-0 tabular-nums text-[10px] text-muted-foreground`,children:Ae(e.ts,t)})]},`${e.ts}-${n}`)})})]})}function Me({open:e,onOpenChange:t,snapshot:n,busy:r,onConfirm:i}){let{t:o}=T(),s=n?.mergedCommits?.length??0,c=n?.baseBranch,[l,u]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{e&&u(!1)},[e]);let d=n?.status===`running`||n?.status===`paused`,f=(0,Z.useMemo)(()=>{let e=new Set;for(let t of n?.tasks??[])t.worktreeBranch&&e.add(t.worktreeBranch);return e.size},[n?.tasks]),p=(0,Z.useMemo)(()=>{let e=new Set;for(let t of n?.tasks??[])t.displayStatus===`in_progress`&&t.agentName&&e.add(t.agentName);return e.size},[n?.tasks]);return(0,Q.jsx)(he,{open:e,onOpenChange:e=>!r&&t(e),children:(0,Q.jsxs)(fe,{className:`sm:max-w-lg border-destructive/50`,children:[(0,Q.jsxs)(ue,{children:[(0,Q.jsxs)(pe,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(a,{className:`h-5 w-5 text-destructive`}),o(`activity:sdd.destroyTitle`)]}),(0,Q.jsx)(me,{children:o(`activity:sdd.destroyDesc`)})]}),(0,Q.jsxs)(`ul`,{className:`space-y-1.5 py-1 text-sm`,children:[d&&(0,Q.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(`span`,{className:`mt-0.5 text-destructive`,children:`■`}),(0,Q.jsx)(`span`,{children:p>0?o(`activity:sdd.stopRunAgents`,{count:p}):o(`activity:sdd.stopRun`)})]}),(0,Q.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(`span`,{className:`mt-0.5 text-destructive`,children:`■`}),(0,Q.jsx)(`span`,{children:f>0?o(`activity:sdd.removeWorktreesCount`,{count:f}):o(`activity:sdd.removeWorktreesAll`)})]}),(0,Q.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(`span`,{className:`mt-0.5 text-destructive`,children:`■`}),(0,Q.jsx)(`span`,{children:o(`activity:sdd.deleteArtifacts`)})]})]}),s>0&&(0,Q.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-md border border-warning/30 bg-warning/5 p-2.5 text-sm`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:l,onChange:e=>u(e.target.checked),className:`mt-0.5 h-4 w-4 accent-warning`}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:o(`activity:sdd.revertMerged`,{count:s})}),` `,`on `,(0,Q.jsx)(`code`,{className:`text-xs`,children:c??o(`activity:sdd.baseBranchFallback`)}),(0,Q.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:o(`activity:sdd.revertHint`)})]})]}),(0,Q.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md bg-muted/50 p-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(D,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-warning`}),o(s>0&&!l?`activity:sdd.noteLeaveMerged`:`activity:sdd.noteAbandon`)]}),(0,Q.jsxs)(de,{className:`gap-2 sm:gap-2`,children:[(0,Q.jsx)(X,{variant:`outline`,size:`sm`,disabled:r,onClick:()=>t(!1),children:o(`common:action.cancel`)}),(0,Q.jsx)(X,{size:`sm`,disabled:r,onClick:()=>i(l),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:r?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(b,{className:`mr-1 h-3.5 w-3.5 animate-spin`}),` `,o(`activity:sdd.destroying`)]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(a,{className:`mr-1 h-3.5 w-3.5`}),` `,o(`activity:sdd.destroyAll`)]})})]})]})})}var Ne=300,Pe=128,Fe=240,Ie={pending:{ring:`border-border/70`,chip:`bg-muted text-muted-foreground`,dot:`bg-muted-foreground`},queued:{ring:`border-primary/35`,chip:`bg-primary/10 text-primary`,dot:`bg-primary`},in_progress:{ring:`border-warning/45`,chip:`bg-warning/12 text-warning`,dot:`bg-warning`},blocked:{ring:`border-destructive/30`,chip:`bg-destructive/10 text-destructive`,dot:`bg-destructive`},review:{ring:`border-primary/35`,chip:`bg-primary/10 text-primary`,dot:`bg-primary`},failed:{ring:`border-destructive/45`,chip:`bg-destructive/10 text-destructive`,dot:`bg-destructive`},completed:{ring:`border-success/35`,chip:`bg-success/12 text-success`,dot:`bg-success`},cancelled:{ring:`border-border/70`,chip:`bg-muted text-muted-foreground`,dot:`bg-muted-foreground`}};function Le({data:e}){let t=e.task,{t:r}=T(),i=Ie[t.displayStatus],a=t.displayStatus===`in_progress`,o=t.displayStatus===`completed`?h:t.displayStatus===`failed`?R:a?b:q;return(0,Q.jsxs)(`div`,{className:J(`sdd-node-enter group relative rounded-lg border bg-card/95 px-2.5 py-2 text-left shadow-lg backdrop-blur`,i.ring,a&&`sdd-node-running`,t.displayStatus===`completed`&&`sdd-node-complete`,t.displayStatus===`failed`&&`sdd-node-failed`,e.onTaskClick&&`hover:brightness-125`),style:{width:Fe,animationDelay:`${Math.min(e.index*45,600)}ms`},children:[e.onTaskClick&&(0,Q.jsx)(`button`,{type:`button`,"aria-label":r(`activity:sdd.openTask`,{title:t.title,defaultValue:`Open task: ${t.title}`}),className:`absolute inset-0 z-10 cursor-pointer rounded-lg`,onClick:()=>e.onTaskClick?.(t.id)}),(0,Q.jsx)(U,{type:`target`,position:C.Left,isConnectable:!1,className:`!h-1.5 !w-1.5 !border-0 !bg-border`}),(0,Q.jsx)(U,{type:`source`,position:C.Right,isConnectable:!1,className:`!h-1.5 !w-1.5 !border-0 !bg-border`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(o,{className:J(`h-3.5 w-3.5`,a&&`animate-spin`,i.chip.split(` `).find(e=>e.startsWith(`text`)))}),(0,Q.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:t.shortId}),(0,Q.jsx)(`span`,{className:J(`font-mono text-[10px] font-bold uppercase`,we(t.priority).text),children:t.priority[0]}),(0,Q.jsx)(`span`,{className:J(`ml-auto rounded px-1.5 py-px text-[9px] font-medium`,i.chip),children:r(`activity:sdd.status.${t.displayStatus}`)})]}),(0,Q.jsx)(`p`,{className:`mt-1 line-clamp-2 text-[11px] leading-snug text-foreground`,children:t.title}),(t.agentName||t.worktreeBranch)&&(0,Q.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5`,children:[t.agentName&&(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(`span`,{className:J(`flex h-4 w-4 items-center justify-center rounded-full text-[8px] font-bold text-white`,a?`bg-warning sdd-agent-live`:`bg-muted-foreground`),children:Oe(t.agentName)}),(0,Q.jsx)(`span`,{className:`max-w-[88px] truncate text-[10px] text-muted-foreground`,children:t.agentName})]}),t.retries?(0,Q.jsxs)(`span`,{className:`flex items-center gap-0.5 text-[9px] text-destructive`,children:[(0,Q.jsx)(n,{className:`h-2.5 w-2.5`}),t.retries]}):null,t.worktreeBranch&&(0,Q.jsxs)(`span`,{className:`ml-auto flex items-center gap-0.5 text-[9px] text-muted-foreground`,title:t.worktreeBranch,children:[(0,Q.jsx)(re,{className:`h-2.5 w-2.5`}),(0,Q.jsx)(`span`,{className:`max-w-[70px] truncate`,children:t.worktreeBranch.replace(/^.*\//,``)})]})]})]})}function Re({data:e}){return(0,Q.jsx)(`div`,{className:`whitespace-nowrap text-[11px] font-bold uppercase text-muted-foreground`,children:e.label})}var ze={task:Le,colLabel:Re};function Be(e,t,n){let r=new Map(e.map(e=>[e.shortId,e])),i=[],a=0;t.forEach((e,t)=>{i.push({id:`__col_${t}`,position:{x:t*Ne,y:-52},data:{label:e.label},draggable:!1,selectable:!1,type:`colLabel`,style:{pointerEvents:`none`}}),e.taskIds.forEach((e,o)=>{let s=r.get(e);s&&i.push({id:s.id,position:{x:t*Ne,y:o*Pe},data:{task:s,index:a++,onTaskClick:n},type:`task`,draggable:!0})})});let o=[];for(let t of e)for(let e of t.deps){let n=r.get(e);if(!n)continue;let i=n.displayStatus===`completed`&&(t.displayStatus===`in_progress`||t.displayStatus===`queued`);o.push({id:`${n.id}->${t.id}`,source:n.id,target:t.id,animated:i,className:i?`sdd-edge-flow`:void 0,style:{stroke:Se(t.displayStatus).hex,strokeWidth:i?2.2:1.4,opacity:t.displayStatus===`pending`?.4:.85}})}return{nodes:i,edges:o}}function Ve({tasks:e,columns:t,onTaskClick:n}){let{fitView:r}=N(),{nodes:i,edges:a}=(0,Z.useMemo)(()=>Be(e,t,n),[e,t,n]),o=e.length;return(0,Z.useEffect)(()=>{let e=setTimeout(()=>r({padding:.18,duration:400}),60);return()=>clearTimeout(e)},[o,r]),(0,Q.jsxs)(M,{nodes:i,edges:a,nodeTypes:ze,fitView:!0,fitViewOptions:{padding:.18},minZoom:.2,maxZoom:1.6,proOptions:{hideAttribution:!0},nodesConnectable:!1,elementsSelectable:!!n,children:[(0,Q.jsx)(H,{variant:P.Dots,gap:22,size:1,color:`hsl(var(--border))`}),(0,Q.jsx)(w,{showInteractive:!1,className:`!bottom-2 !left-2`}),(0,Q.jsx)(te,{pannable:!0,zoomable:!0,nodeStrokeWidth:2,maskColor:`hsl(var(--background) / 0.65)`,nodeColor:e=>{let t=e.data?.task?.displayStatus;return t?Se(t).hex:`hsl(var(--muted-foreground))`},className:`!bottom-2 !right-2 !h-24 !w-40 overflow-hidden rounded-md border border-border/70 bg-card`})]})}function He({tasks:e,columns:t,onTaskClick:n}){return(0,Q.jsx)(G,{children:(0,Q.jsx)(Ve,{tasks:e,columns:t,onTaskClick:n})})}var Ue=[{key:`pending`,labelKey:`kanbanBacklog`,accent:`border-border/70`,head:`text-muted-foreground`},{key:`queued`,labelKey:`kanbanReady`,accent:`border-primary/35`,head:`text-primary`},{key:`in_progress`,labelKey:`kanbanRunning`,accent:`border-warning/45`,head:`text-warning`},{key:`review`,labelKey:`kanbanReview`,accent:`border-primary/35`,head:`text-primary`},{key:`failed`,labelKey:`kanbanFailed`,accent:`border-destructive/35`,head:`text-destructive`},{key:`completed`,labelKey:`kanbanDone`,accent:`border-success/35`,head:`text-success`}];function We({tasks:e,selectedId:t,onTaskClick:n}){let{t:r}=T(),i=(0,Z.useMemo)(()=>{let t=new Map;for(let e of Ue)t.set(e.key,[]);for(let n of e){let e=n.displayStatus===`blocked`?`pending`:n.displayStatus===`cancelled`?`failed`:n.displayStatus;(t.get(e)??t.get(`pending`))?.push(n)}return t},[e]);return(0,Q.jsx)(`div`,{className:`flex h-full min-h-0 min-w-0 gap-3 overflow-x-auto p-4`,children:Ue.map(e=>{let a=i.get(e.key)??[];return(0,Q.jsxs)(`div`,{className:`flex min-h-0 w-64 shrink-0 flex-col`,children:[(0,Q.jsxs)(`div`,{className:J(`mb-2 flex items-center gap-2 border-b-2 pb-1.5`,e.accent),children:[(0,Q.jsx)(`span`,{className:J(`text-xs font-bold uppercase tracking-wide`,e.head),children:r(`activity:sdd.${e.labelKey}`)}),(0,Q.jsx)(`span`,{className:`rounded-full bg-muted px-1.5 text-[10px] text-muted-foreground`,children:a.length})]}),(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto overscroll-contain pr-1`,children:[a.map(e=>(0,Q.jsx)(Ge,{task:e,selected:e.id===t,onClick:()=>n(e.id)},e.id)),a.length===0&&(0,Q.jsx)(`div`,{className:`rounded-md border border-dashed border-border py-6 text-center text-[10px] text-muted-foreground`,children:r(`activity:sdd.kanbanEmpty`)})]})]},e.key)})})}function Ge({task:e,selected:t,onClick:r}){let i=e.displayStatus===`in_progress`;return(0,Q.jsxs)(`button`,{type:`button`,onClick:r,className:J(`sdd-node-enter w-full rounded-lg border bg-card/85 p-2 text-left shadow-sm transition hover:border-primary/35 hover:bg-accent/35`,t?`border-primary/55 ring-1 ring-primary/35`:`border-border/70`,i&&`sdd-node-running`,e.displayStatus===`completed`&&`sdd-node-complete`,e.displayStatus===`failed`&&`sdd-node-failed`),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[i&&(0,Q.jsx)(b,{className:`h-3 w-3 animate-spin text-warning`}),e.displayStatus===`completed`&&(0,Q.jsx)(h,{className:`h-3 w-3 text-success`}),e.displayStatus===`failed`&&(0,Q.jsx)(R,{className:`h-3 w-3 text-destructive`}),(0,Q.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.shortId}),(0,Q.jsx)(`span`,{className:J(`ml-auto rounded px-1.5 text-[9px] font-bold uppercase`,we(e.priority).chip),children:e.priority})]}),(0,Q.jsx)(`p`,{className:`mt-1 line-clamp-2 text-[11px] leading-snug text-foreground`,children:e.title}),(e.agentName||e.worktreeBranch||e.retries)&&(0,Q.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5`,children:[e.agentName&&(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(`span`,{className:J(`flex h-4 w-4 items-center justify-center rounded-full text-[8px] font-bold text-white`,i?`bg-warning sdd-agent-live`:`bg-muted-foreground`),children:Oe(e.agentName)}),(0,Q.jsx)(`span`,{className:`max-w-[80px] truncate text-[10px] text-muted-foreground`,children:e.agentName})]}),e.retries?(0,Q.jsxs)(`span`,{className:`flex items-center gap-0.5 text-[9px] text-destructive`,children:[(0,Q.jsx)(n,{className:`h-2.5 w-2.5`}),e.retries]}):null,e.worktreeBranch&&(0,Q.jsx)(re,{className:`ml-auto h-2.5 w-2.5 text-muted-foreground`})]})]})}function Ke({task:e,allTasks:t,feed:r,now:i,expanded:o,modelCandidates:s,defaultModel:c,onClose:l,onToggleExpanded:u,onRetry:d,onReassign:f,onSetModel:m,onSetVerification:v,onCancel:y,onDelete:b,onSplit:x,onSelectTask:C}){let{t:w}=T(),E=Se(e.displayStatus),ee=E.icon,D=e.displayStatus===`in_progress`,te=e.displayStatus===`pending`||e.displayStatus===`blocked`||e.displayStatus===`queued`,[O,A]=(0,Z.useState)(!1),[j,M]=(0,Z.useState)(``),[N,P]=(0,Z.useState)(null),[F,ae]=(0,Z.useState)(!1),[I,L]=(0,Z.useState)(``),[z,B]=(0,Z.useState)(!1),[V,H]=(0,Z.useState)(e.verificationCommand??``),U=()=>{j.trim()&&(f(e.id,j.trim()),A(!1),M(``))},W=()=>{let t=I.split(`
2
- `).map(e=>e.trim()).filter(Boolean).map(e=>{let[t,...n]=e.split(`::`),r=(t??``).trim();return{title:r,description:n.join(`::`).trim()||r}}).filter(e=>e.title);t.length&&(x(e.id,t),ae(!1),L(``))},G=(0,Z.useMemo)(()=>new Map(t.map(e=>[e.shortId,e])),[t]),K=(0,Z.useMemo)(()=>t.filter(t=>t.deps.includes(e.shortId)),[t,e.shortId]),q=(0,Z.useMemo)(()=>r.filter(t=>t.taskId===e.id||t.taskShortId===e.shortId),[r,e.id,e.shortId]),oe=e.startedAt&&!e.completedAt?ke(i-e.startedAt):e.startedAt&&e.completedAt?ke(e.completedAt-e.startedAt):null;return(0,Q.jsxs)(`div`,{className:`sdd-rise flex h-full min-h-0 min-w-0 flex-col`,children:[(0,Q.jsxs)(`div`,{className:J(`flex items-center gap-2 border-b border-border/70 bg-card/70 px-3 py-2`,o&&`px-5 py-3`),children:[(0,Q.jsx)(`button`,{type:`button`,onClick:l,className:`text-muted-foreground hover:text-foreground`,title:w(`activity:sddTask.backTitle`),children:(0,Q.jsx)(S,{className:`h-4 w-4`})}),(0,Q.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:e.shortId}),u&&(0,Q.jsx)(`button`,{type:`button`,onClick:u,className:`ml-1 inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition hover:bg-muted hover:text-foreground`,title:w(o?`activity:sddTask.collapseTitle`:`activity:sddTask.expandTitle`),"aria-label":w(o?`activity:sddTask.collapseTitle`:`activity:sddTask.expandTitle`),"aria-pressed":o,children:o?(0,Q.jsx)(ie,{className:`h-4 w-4`}):(0,Q.jsx)(g,{className:`h-4 w-4`})}),(0,Q.jsxs)(`span`,{className:J(`ml-auto flex items-center gap-1 rounded-full border px-2 py-0.5 text-[11px]`,E.ring,E.text),children:[(0,Q.jsx)(ee,{className:J(`h-3 w-3`,D&&`animate-spin`)}),E.label]})]}),(0,Q.jsxs)(`div`,{className:J(`min-h-0 min-w-0 flex-1 overflow-auto overscroll-contain`,o?`grid grid-cols-2 content-start gap-4 p-5`:`space-y-3 p-3`),children:[(0,Q.jsx)(`h3`,{className:J(`text-sm font-semibold leading-snug text-foreground`,o&&`col-span-2 text-lg`),children:e.title}),e.agentName&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-border/70 bg-muted/45 p-2`,children:[(0,Q.jsx)(`span`,{className:J(`flex h-7 w-7 items-center justify-center rounded-full text-[10px] font-bold text-white`,D?`bg-warning sdd-agent-live`:`bg-muted-foreground`),children:Oe(e.agentName)}),(0,Q.jsxs)(`div`,{className:`leading-tight`,children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-foreground`,children:e.agentName}),(0,Q.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:w(D?`activity:sddTask.workingOn`:`activity:sddTask.assigned`)})]})]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-2 gap-1.5 text-[11px]`,children:[(0,Q.jsx)(Je,{label:w(`activity:sddTask.metaPriority`),children:(0,Q.jsx)(`span`,{className:J(`font-medium uppercase`,we(e.priority).text),children:e.priority})}),(0,Q.jsx)(Je,{label:w(`activity:sddTask.metaType`),children:e.type}),oe&&(0,Q.jsx)(Je,{label:e.completedAt?w(`activity:sddTask.metaDuration`):w(`activity:sddTask.metaElapsed`),children:(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(k,{className:`h-3 w-3 text-muted-foreground`}),oe]})}),e.retries?(0,Q.jsx)(Je,{label:w(`activity:sddTask.metaRetries`),children:(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 text-destructive`,children:[(0,Q.jsx)(n,{className:`h-3 w-3`}),e.retries]})}):null,e.worktreeBranch&&(0,Q.jsx)(Je,{label:w(`activity:sddTask.metaWorktree`),full:!0,children:(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 font-mono text-foreground`,title:e.worktreeBranch,children:[(0,Q.jsx)(re,{className:`h-3 w-3 text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.worktreeBranch})]})})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[w(`activity:sddTask.workerModel`),!e.model&&c&&(0,Q.jsxs)(`span`,{className:`font-normal normal-case text-muted-foreground`,children:[`· `,w(`activity:sddTask.runDefault`,{model:c})]})]}),(0,Q.jsx)(_e,{value:e.model,provider:e.provider,candidates:s,placeholder:c?w(`activity:sddTask.runDefaultPlaceholderModel`,{model:c}):w(`activity:sddTask.runDefaultPlaceholder`),onPick:(t,n)=>m(e.id,t,n),onReset:e.model?()=>m(e.id,void 0,void 0):void 0}),e.fallbackModels&&e.fallbackModels.length>0&&(0,Q.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:e.fallbackModels.map(e=>(0,Q.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-[9px] text-muted-foreground`,children:[`↳ `,e]},e))})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[w(`activity:sddTask.verificationCmd`),(0,Q.jsxs)(`span`,{className:`font-normal normal-case text-muted-foreground`,children:[`· `,w(`activity:sddTask.gatesCompletion`)]})]}),z?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`input`,{value:V,onChange:e=>H(e.target.value),onKeyDown:t=>{t.key===`Enter`?(v(e.id,V.trim()||void 0),B(!1)):t.key===`Escape`&&(H(e.verificationCommand??``),B(!1))},placeholder:w(`activity:sddTask.verifyPlaceholder`),className:`w-full rounded border border-border bg-background px-2 py-1 font-mono text-[11px] text-foreground`}),(0,Q.jsxs)(`div`,{className:`flex gap-1`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{v(e.id,V.trim()||void 0),B(!1)},className:`rounded bg-primary px-2 py-0.5 text-[10px] text-primary-foreground hover:opacity-90`,children:w(`common:action.save`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{H(e.verificationCommand??``),B(!1)},className:`rounded bg-muted px-2 py-0.5 text-[10px] text-muted-foreground hover:bg-muted/80`,children:w(`common:action.cancel`)})]})]}):e.verificationCommand?(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(`code`,{className:`flex-1 truncate rounded bg-muted px-1.5 py-0.5 font-mono text-[10px] text-foreground`,children:e.verificationCommand}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>B(!0),className:`rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground hover:bg-muted/80`,children:w(`common:action.edit`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>v(e.id,void 0),className:`rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground hover:bg-muted/80`,children:w(`common:action.clear`)})]}):(0,Q.jsx)(`button`,{type:`button`,onClick:()=>B(!0),className:`rounded border border-dashed border-border px-2 py-1 text-[10px] text-muted-foreground hover:bg-muted`,children:w(`activity:sddTask.addVerify`)})]}),e.description&&(0,Q.jsxs)(`div`,{className:J(o&&`col-span-2`),children:[(0,Q.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:w(`activity:sddTask.description`)}),(0,Q.jsx)(`p`,{className:`whitespace-pre-wrap rounded-md bg-muted p-2 text-[11px] leading-relaxed text-foreground`,children:e.description})]}),(0,Q.jsx)(qe,{events:q,expanded:o}),e.deps.length>0&&(0,Q.jsx)(Ye,{title:w(`activity:sddTask.dependsOn`),shortIds:e.deps,byShort:G,onSelectTask:C}),K.length>0&&(0,Q.jsx)(Ye,{title:w(`activity:sddTask.blocks`),shortIds:K.map(e=>e.shortId),byShort:G,onSelectTask:C})]}),(0,Q.jsxs)(`div`,{className:J(`border-t border-border p-2`,o&&`px-5 py-3`),children:[O?(0,Q.jsxs)(`div`,{className:`sdd-rise flex items-center gap-1.5`,children:[(0,Q.jsx)(`input`,{value:j,onChange:e=>M(e.target.value),onKeyDown:e=>{e.key===`Enter`&&U(),e.key===`Escape`&&A(!1)},placeholder:w(`activity:sddTask.newWorkerPlaceholder`),className:`min-w-0 flex-1 rounded-md border border-border/70 bg-background px-2 py-1.5 text-xs outline-none focus:border-primary/60`}),(0,Q.jsx)(`button`,{type:`button`,onClick:U,disabled:!j.trim(),className:`rounded-md bg-primary/10 px-2 py-1.5 text-xs font-medium text-primary hover:bg-primary/15 disabled:opacity-40`,children:(0,Q.jsx)(h,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>A(!1),className:`rounded-md bg-muted px-2 py-1.5 text-xs text-muted-foreground hover:bg-muted`,children:(0,Q.jsx)(R,{className:`h-3.5 w-3.5`})})]}):N?(0,Q.jsxs)(`div`,{className:`sdd-rise flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`flex-1 text-xs text-foreground`,children:w(N===`stop`?`activity:sddTask.confirmStop`:`activity:sddTask.confirmDelete`)}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{N===`stop`?y(e.id):b(e.id),P(null)},className:`inline-flex items-center gap-1 rounded-md bg-destructive/10 px-2.5 py-1.5 text-xs font-medium text-destructive hover:bg-destructive/15`,children:[(0,Q.jsx)(h,{className:`h-3.5 w-3.5`}),` `,w(N===`stop`?`common:action.stop`:`common:action.delete`)]}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>P(null),className:`rounded-md bg-muted px-2 py-1.5 text-xs text-muted-foreground hover:bg-muted`,children:(0,Q.jsx)(R,{className:`h-3.5 w-3.5`})})]}):(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>d(e.id),title:w(`activity:sddTask.retryTitle`),className:`inline-flex flex-1 items-center justify-center gap-1 rounded-md bg-warning/12 py-1.5 text-xs font-medium text-warning hover:bg-warning/18`,children:[(0,Q.jsx)(n,{className:`h-3.5 w-3.5`}),` `,w(`common:action.retry`)]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>A(!0),className:`inline-flex flex-1 items-center justify-center gap-1 rounded-md bg-primary/10 py-1.5 text-xs font-medium text-primary hover:bg-primary/15`,children:[(0,Q.jsx)(ne,{className:`h-3.5 w-3.5`}),` `,w(`activity:sddTask.reassign`)]}),D&&(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>P(`stop`),title:w(`activity:sddTask.stopTitle`),className:`inline-flex flex-1 items-center justify-center gap-1 rounded-md bg-destructive/10 py-1.5 text-xs font-medium text-destructive hover:bg-destructive/15`,children:[(0,Q.jsx)(p,{className:`h-3.5 w-3.5`}),` `,w(`common:action.stop`)]}),!D&&(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>ae(!0),title:w(`activity:sddTask.splitTitle`),className:`inline-flex flex-1 items-center justify-center gap-1 rounded-md bg-primary/10 py-1.5 text-xs font-medium text-primary hover:bg-primary/15`,children:[(0,Q.jsx)(_,{className:`h-3.5 w-3.5`}),` `,w(`activity:sddTask.split`)]}),te&&(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>P(`delete`),title:w(`activity:sddTask.deleteTitle`),className:`inline-flex flex-1 items-center justify-center gap-1 rounded-md bg-destructive/10 py-1.5 text-xs font-medium text-destructive hover:bg-destructive/15`,children:[(0,Q.jsx)(a,{className:`h-3.5 w-3.5`}),` `,w(`common:action.delete`)]})]}),F&&(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-col gap-2`,children:[(0,Q.jsx)(`label`,{className:`text-[11px] text-muted-foreground`,htmlFor:`sdd-split-input`,children:w(`activity:sddTask.splitHint`)}),(0,Q.jsx)(`textarea`,{id:`sdd-split-input`,rows:3,value:I,onChange:e=>L(e.target.value),placeholder:w(`activity:sddTask.splitPlaceholder`),className:`w-full resize-y rounded-md border border-border/70 bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-ring`}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:W,className:`inline-flex flex-1 items-center justify-center gap-1 rounded-md bg-primary/10 py-1.5 text-xs font-medium text-primary hover:bg-primary/15`,children:[(0,Q.jsx)(_,{className:`h-3.5 w-3.5`}),` `,w(`activity:sddTask.splitInto`)]}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{ae(!1),L(``)},className:`rounded-md bg-muted px-2 py-1.5 text-xs text-muted-foreground hover:bg-muted`,children:(0,Q.jsx)(R,{className:`h-3.5 w-3.5`})})]})]})]})]})}function qe({events:e,expanded:t}){let{t:n}=T();return(0,Q.jsxs)(`section`,{className:J(`rounded-lg border border-border/70 bg-background/45`,t&&`col-span-2`),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/60 px-3 py-2.5`,children:[(0,Q.jsx)(L,{className:`h-4 w-4 text-primary`}),(0,Q.jsx)(`h4`,{className:`text-xs font-semibold text-foreground`,children:n(`activity:sddTask.eventLog`)}),(0,Q.jsx)(`span`,{className:`rounded-full bg-muted px-2 py-0.5 text-[10px] text-muted-foreground`,children:e.length}),(0,Q.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:n(`activity:sddTask.newestFirst`)})]}),e.length===0?(0,Q.jsx)(`p`,{className:`px-3 py-5 text-center text-[11px] text-muted-foreground`,children:n(`activity:sddTask.noEvents`)}):(0,Q.jsx)(`div`,{className:J(`divide-y divide-border/45 overflow-auto`,t?`max-h-[32rem]`:`max-h-72`),children:e.map((e,t)=>{let n=e.kind===`file`,i=e.kind===`tool`,a=e.ok===!1||e.kind===`failed`||e.kind===`verification_failed`,o=n?r:i?y:L;return(0,Q.jsxs)(`div`,{className:J(`grid grid-cols-[4.75rem_1rem_minmax(0,1fr)] gap-2 px-3 py-2.5 text-[11px]`,a&&`bg-destructive/[0.035]`),children:[(0,Q.jsx)(`time`,{dateTime:new Date(e.ts).toISOString(),className:`font-mono text-[10px] text-muted-foreground`,title:new Date(e.ts).toLocaleString(),children:new Date(e.ts).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}),(0,Q.jsx)(o,{className:J(`mt-0.5 h-3.5 w-3.5`,a?`text-destructive`:n?`text-info`:i?`text-warning`:`text-primary`)}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[e.action&&(0,Q.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-[10px] font-medium text-foreground`,children:e.action}),e.agentName&&(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:e.agentName}),e.durationMs!==void 0&&(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:e.durationMs<1e3?`${Math.round(e.durationMs)}ms`:`${(e.durationMs/1e3).toFixed(1)}s`})]}),e.filePath?(0,Q.jsx)(`code`,{className:`mt-1 block break-all font-mono text-[10px] leading-relaxed text-foreground`,children:e.filePath}):e.detail?(0,Q.jsx)(`code`,{className:`mt-1 block break-words font-mono text-[10px] leading-relaxed text-muted-foreground`,children:e.detail}):(0,Q.jsx)(`p`,{className:`mt-1 break-words leading-relaxed text-foreground`,children:e.text})]})]},`${e.ts}-${e.kind}-${t}`)})})]})}function Je({label:e,children:t,full:n}){return(0,Q.jsxs)(`div`,{className:J(`rounded-md border border-border bg-muted/50 px-2 py-1`,n&&`col-span-2`),children:[(0,Q.jsx)(`div`,{className:`text-[9px] uppercase tracking-wide text-muted-foreground`,children:e}),(0,Q.jsx)(`div`,{className:`text-foreground`,children:t})]})}function Ye({title:e,shortIds:t,byShort:n,onSelectTask:r}){return(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:e}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.map(e=>{let t=n.get(e);return(0,Q.jsxs)(`button`,{type:`button`,disabled:!t,onClick:()=>t&&r(t.id),className:`flex items-center gap-1 rounded-full border border-border bg-muted px-2 py-0.5 text-[10px] text-foreground hover:bg-muted disabled:opacity-50`,title:t?.title,children:[(0,Q.jsx)(`span`,{className:J(`h-1.5 w-1.5 rounded-full`,Se(t?.displayStatus??`pending`).dot)}),(0,Q.jsx)(`span`,{className:`font-mono`,children:e})]},e)})})]})}function Xe({pct:e}){let t=2*Math.PI*26,n=t-Math.max(0,Math.min(100,e))/100*t;return(0,Q.jsxs)(`div`,{className:`relative h-16 w-16 shrink-0`,children:[(0,Q.jsxs)(`svg`,{viewBox:`0 0 64 64`,className:`h-16 w-16 -rotate-90`,role:`img`,"aria-label":`Progress`,children:[(0,Q.jsx)(`circle`,{cx:`32`,cy:`32`,r:26,fill:`none`,stroke:`hsl(var(--muted))`,strokeWidth:`6`}),(0,Q.jsx)(`circle`,{cx:`32`,cy:`32`,r:26,fill:`none`,stroke:`url(#sddgrad)`,strokeWidth:`6`,strokeLinecap:`round`,strokeDasharray:t,strokeDashoffset:n,style:{transition:`stroke-dashoffset 0.6s cubic-bezier(0.16,1,0.3,1)`}}),(0,Q.jsx)(`defs`,{children:(0,Q.jsxs)(`linearGradient`,{id:`sddgrad`,x1:`0`,y1:`0`,x2:`1`,y2:`1`,children:[(0,Q.jsx)(`stop`,{offset:`0%`,stopColor:`hsl(var(--primary))`}),(0,Q.jsx)(`stop`,{offset:`100%`,stopColor:`hsl(var(--info))`})]})})]}),(0,Q.jsxs)(`div`,{className:`absolute inset-0 flex items-center justify-center text-sm font-bold text-foreground`,children:[Math.round(e),`%`]})]})}function Ze({onClose:e}){let{t}=T(),{client:r}=se(),i=Y(e=>e.snapshot),o=Y(e=>e.lifecycleResult),s=Y(e=>e.destroying),c=Y(e=>e.setDestroying),l=Y(e=>e.setLifecycleResult),[u,d]=(0,Z.useState)(()=>Date.now()),[f,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(`graph`),[y,b]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{r?.send?.({type:`sdd.board.get`})},[r]);let x=i&&(i.status===`running`||i.status===`paused`);(0,Z.useEffect)(()=>{if(!x)return;let e=setInterval(()=>d(Date.now()),1e3);return d(Date.now()),()=>clearInterval(e)},[x]);let S=(0,Z.useCallback)(e=>r?.send?.(e),[r]),C=(0,Z.useRef)(null),w=(0,Z.useCallback)(e=>{C.current=null,S({type:`sdd.board.destroy`,payload:{revertMerged:e}})},[S]),ee=(0,Z.useCallback)(e=>{b(!1),l(null),c(!0),x?(S({type:`sdd.board.stop`,payload:{}}),C.current={revertMerged:e,deadline:Date.now()+2e4}):w(e)},[x,S,w,c,l]);(0,Z.useEffect)(()=>{let e=C.current;e&&(!x||Date.now()>=e.deadline)&&w(e.revertMerged)},[x,i,w]);let te=(0,Z.useCallback)(()=>{l(null),S({type:`sdd.board.cleanup_worktrees`,payload:{}})},[S,l]),O=(0,Z.useCallback)(()=>{l(null),S({type:`sdd.board.rollback`,payload:{}})},[S,l]),k=(0,Z.useMemo)(()=>(i?.tasks??[]).map(e=>({id:e.id,shortId:e.shortId,title:e.title,displayStatus:e.displayStatus,priority:e.priority,deps:e.deps,agentName:e.agentName,worktreeBranch:e.worktreeBranch})),[i?.tasks]),j=(0,Z.useMemo)(()=>{let e=new Map;for(let t of i?.tasks??[])t.displayStatus===`in_progress`&&t.agentName&&e.set(t.agentName,{name:t.agentName,task:t.title});return[...e.values()]},[i?.tasks]),M=(0,Z.useCallback)(e=>m(e),[]),ne=(0,Z.useCallback)(()=>{m(null),g(!1)},[]),N=(0,Z.useCallback)(e=>S({type:`sdd.board.retry`,payload:{taskId:e}}),[S]),re=(0,Z.useCallback)(()=>S({type:`sdd.board.retry_all_failed`,payload:{}}),[S]),P=(0,Z.useCallback)((e,t)=>{let n=t.trim();n&&S({type:`sdd.board.reassign`,payload:{taskId:e,agentName:n}})},[S]),ie=(0,Z.useCallback)((e,t,n)=>S({type:`sdd.board.set_task_model`,payload:{taskId:e,model:t,provider:n}}),[S]),I=(0,Z.useCallback)((e,t)=>S({type:`sdd.board.set_task_verification`,payload:{taskId:e,verificationCommand:t}}),[S]),z=(0,Z.useCallback)(e=>S({type:`sdd.board.cancel_task`,payload:{taskId:e}}),[S]),B=(0,Z.useCallback)(e=>{S({type:`sdd.board.delete_task`,payload:{taskId:e}}),m(null),g(!1)},[S]),H=(0,Z.useCallback)((e,t)=>{S({type:`sdd.board.split_task`,payload:{taskId:e,subtasks:t}}),m(null),g(!1)},[S]),U=ge(f!==null),W=(0,Z.useMemo)(()=>i?.tasks.find(e=>e.id===f)??null,[i?.tasks,f]),G=i?.progress,K=i?.diagnostics?.deadlockChains??[];return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col bg-background`,children:[(0,Q.jsxs)(`header`,{className:`sdd-sheen shrink-0 border-b border-border px-4 pb-3 pt-2.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(L,{className:`h-5 w-5 text-warning`}),(0,Q.jsx)(`h1`,{className:`text-lg font-semibold text-foreground`,children:i?.title??t(`activity:sddBoard.titleFallback`)}),i&&(0,Q.jsx)(`span`,{className:J(`rounded-full border px-2 py-0.5 text-[11px] font-medium capitalize`,Te[i.status]??Te.idle),children:i.status}),i?.defaultModel&&(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 rounded-full border border-border bg-muted px-2 py-0.5 text-[10px] text-muted-foreground`,title:t(`activity:sddBoard.defaultModelTitle`),children:[(0,Q.jsx)(A,{className:`h-3 w-3 text-primary`}),i.defaultModel]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[i&&(0,Q.jsx)(`div`,{className:`flex items-center rounded-md border border-border bg-muted p-0.5 text-[11px]`,children:[`graph`,`kanban`].map(e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>v(e),className:J(`rounded px-2 py-0.5 capitalize transition`,_===e?`bg-primary/12 text-primary`:`text-muted-foreground hover:text-foreground`),children:t(e===`graph`?`activity:sddBoard.graphLabel`:`activity:sddBoard.kanbanLabel`)},e))}),x&&(G?.failed??0)>0&&(0,Q.jsxs)(`button`,{type:`button`,onClick:re,title:t(`activity:sddBoard.retryAllTitle`),className:`inline-flex items-center gap-1 rounded-md bg-warning/15 px-2.5 py-1 text-xs font-medium text-warning hover:bg-warning/25`,children:[(0,Q.jsx)(n,{className:`h-3.5 w-3.5`}),` `,t(`activity:sddBoard.retryFailed`,{count:G?.failed??0})]}),x&&(0,Q.jsxs)(Q.Fragment,{children:[i?.status===`paused`?(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>S({type:`sdd.board.resume`,payload:{}}),className:`inline-flex items-center gap-1 rounded-md bg-success/15 px-2.5 py-1 text-xs font-medium text-success hover:bg-success/25`,children:[(0,Q.jsx)(F,{className:`h-3.5 w-3.5`}),` `,t(`activity:sddBoard.resume`)]}):(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>S({type:`sdd.board.pause`,payload:{}}),className:`inline-flex items-center gap-1 rounded-md bg-warning/15 px-2.5 py-1 text-xs font-medium text-warning hover:bg-warning/25`,children:[(0,Q.jsx)(ae,{className:`h-3.5 w-3.5`}),` `,t(`activity:sddBoard.pause`)]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>S({type:`sdd.board.stop`,payload:{}}),className:`inline-flex items-center gap-1 rounded-md bg-destructive/15 px-2.5 py-1 text-xs font-medium text-destructive hover:bg-destructive/25`,children:[(0,Q.jsx)(p,{className:`h-3.5 w-3.5`}),` `,t(`activity:sddBoard.stop`)]})]}),i&&!x&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:te,title:t(`activity:sddBoard.cleanTitle`),className:`inline-flex items-center gap-1 rounded-md bg-muted px-2.5 py-1 text-xs font-medium text-muted-foreground hover:bg-muted/80`,children:[(0,Q.jsx)(V,{className:`h-3.5 w-3.5`}),` `,t(`activity:sddBoard.cleanWorktrees`)]}),(i.mergedCommits?.length??0)>0&&(0,Q.jsxs)(`button`,{type:`button`,onClick:O,title:t(`activity:sddBoard.rollbackTitle`,{count:i.mergedCommits?.length??0,base:i.baseBranch??t(`activity:sdd.baseBranchFallback`)}),className:`inline-flex items-center gap-1 rounded-md bg-warning/15 px-2.5 py-1 text-xs font-medium text-warning hover:bg-warning/25`,children:[(0,Q.jsx)(oe,{className:`h-3.5 w-3.5`}),` `,t(`activity:sddBoard.rollback`,{count:i.mergedCommits?.length??0})]})]}),i&&(s?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-destructive/15 px-2.5 py-1 text-xs font-medium text-destructive`,children:[(0,Q.jsx)(n,{className:`h-3.5 w-3.5 animate-spin`}),` `,t(x?`activity:sddBoard.stopping`:`activity:sddBoard.destroying`)]}):(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>b(!0),title:t(`activity:sddBoard.destroyTitle`),className:`inline-flex items-center gap-1 rounded-md bg-destructive px-2.5 py-1 text-xs font-medium text-destructive-foreground hover:bg-destructive/90`,children:[(0,Q.jsx)(a,{className:`h-3.5 w-3.5`}),` `,t(`activity:sddBoard.destroy`)]})),(0,Q.jsx)(X,{variant:`ghost`,size:`icon`,onClick:e,children:(0,Q.jsx)(R,{className:`h-4 w-4`})})]})]}),i&&G&&(0,Q.jsxs)(`div`,{className:`mt-2.5 flex items-center gap-5`,children:[(0,Q.jsx)(Xe,{pct:G.percentComplete}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 text-xs`,children:[(0,Q.jsx)(et,{label:t(`activity:sddBoard.statDone`),value:`${G.completed}/${G.total}`,color:`text-success`}),G.inProgress>0&&(0,Q.jsx)(et,{label:t(`activity:sddBoard.statRunning`),value:G.inProgress,color:`text-warning`}),G.failed>0&&(0,Q.jsx)(et,{label:t(`activity:sddBoard.statFailed`),value:G.failed,color:`text-destructive`}),(0,Q.jsx)(et,{label:t(`activity:sddBoard.statWave`),value:i.wave+1,color:`text-primary`}),x&&i.startedAt>0&&(0,Q.jsx)(et,{label:t(`activity:sddBoard.statElapsed`),value:ke(u-i.startedAt),color:`text-foreground`})]}),(0,Q.jsx)(`div`,{className:`flex min-h-[24px] items-center gap-1.5`,children:j.length===0?(0,Q.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:t(`activity:sddBoard.noActiveWorkers`)}):j.map((e,t)=>(0,Q.jsxs)(`span`,{title:`${e.name} → ${e.task}`,className:`flex items-center gap-1 rounded-full bg-muted py-0.5 pl-0.5 pr-2`,children:[(0,Q.jsx)(`span`,{className:J(`sdd-agent-live flex h-5 w-5 items-center justify-center rounded-full text-[9px] font-bold text-white`,Ee[t%Ee.length]),children:Oe(e.name)}),(0,Q.jsx)(`span`,{className:`max-w-[90px] truncate text-[11px] text-foreground`,children:e.name})]},e.name))})]})]})]}),o&&(0,Q.jsx)($e,{result:o,onDismiss:()=>l(null)}),K.length>0&&(0,Q.jsxs)(`div`,{className:`flex items-start gap-2 border-b border-destructive/30 bg-destructive/5 px-4 py-2 text-xs text-destructive`,children:[(0,Q.jsx)(D,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`font-semibold`,children:t(`activity:sddBoard.deadlock`)}),K.map(e=>(0,Q.jsxs)(`div`,{className:`font-mono`,children:[e.blocked,` ← `,e.blockedBy.join(`, `)]},e.blocked))]})]}),(0,Q.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`relative min-h-0 min-w-0 flex-1 overflow-hidden`,children:i?_===`graph`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(He,{tasks:k,columns:i.columns,onTaskClick:M}),(0,Q.jsx)(`div`,{className:`pointer-events-none absolute bottom-2 left-1/2 -translate-x-1/2 rounded-full bg-black/40 px-2 py-0.5 text-[10px] text-muted-foreground backdrop-blur`,children:t(`activity:sddBoard.clickTaskHint`)})]}):(0,Q.jsx)(We,{tasks:i.tasks,selectedId:f,onTaskClick:M}):(0,Q.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 text-sm text-muted-foreground`,children:[(0,Q.jsx)(E,{className:`h-10 w-10 text-primary/40`}),(0,Q.jsx)(`p`,{className:`text-foreground`,children:t(`activity:sddBoard.noRunTitle`)}),(0,Q.jsx)(`p`,{className:`max-w-sm text-center text-xs text-muted-foreground`,children:t(`activity:sddBoard.noRunBody`)})]})}),i&&(0,Q.jsx)(`aside`,{"data-testid":`sdd-task-panel`,"data-expanded":h&&W?`true`:`false`,className:J(`shrink-0 border-l border-border bg-card transition-[width] duration-200 ease-out`,h&&W?`w-[min(72rem,72vw)]`:`w-80`),children:W?(0,Q.jsx)(Ke,{task:W,allTasks:i.tasks,feed:i.taskEvents?.[W.id]??i.feed??[],now:u,expanded:h,modelCandidates:U,defaultModel:i.defaultModel,onClose:ne,onToggleExpanded:()=>g(e=>!e),onRetry:N,onReassign:P,onSetModel:ie,onSetVerification:I,onCancel:z,onDelete:B,onSplit:H,onSelectTask:m},W.id):(0,Q.jsx)(je,{feed:i.feed??[],now:u})})]}),(0,Q.jsx)(Me,{open:y,onOpenChange:b,snapshot:i,busy:s,onConfirm:ee})]})}function Qe(e){let t=e.op===`cleanup_worktrees`?`lcClean`:e.op===`rollback`?`lcRollback`:`lcDestroy`,n=O.t(`activity:sddBoard.${t}`);if(!e.ok)return O.t(`activity:sddBoard.lcFailed`,{op:n,reason:e.reason??O.t(`activity:sddBoard.lcUnknownError`)});let r=[];typeof e.removed==`number`&&r.push(O.t(`activity:sddBoard.lcWorktrees`,{count:e.removed})),typeof e.reverted==`number`&&e.reverted>0&&r.push(O.t(`activity:sddBoard.lcCommits`,{count:e.reverted})),e.deleted?.length&&r.push(O.t(`activity:sddBoard.lcDeleted`,{items:e.deleted.join(`, `)}));let i=r.length?r.join(` · `):O.t(`activity:sddBoard.lcNothing`);return e.reason?O.t(`activity:sddBoard.lcNote`,{op:n,body:i,reason:e.reason}):O.t(`activity:sddBoard.lcOk`,{op:n,body:i})}function $e({result:e,onDismiss:t}){let n=!e.ok||!!e.reason;return(0,Q.jsxs)(`div`,{className:J(`flex items-start gap-2 border-b px-4 py-2 text-xs`,n?`border-warning/30 bg-warning/5 text-warning`:`border-success/30 bg-success/5 text-success`),children:[n?(0,Q.jsx)(z,{className:`mt-0.5 h-4 w-4 shrink-0`}):(0,Q.jsx)(ee,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,Q.jsx)(`span`,{className:`flex-1`,children:Qe(e)}),(0,Q.jsx)(`button`,{type:`button`,onClick:t,className:`shrink-0 opacity-60 hover:opacity-100`,children:(0,Q.jsx)(R,{className:`h-3.5 w-3.5`})})]})}function et({label:e,value:t,color:n}){return(0,Q.jsxs)(`span`,{className:`flex items-baseline gap-1`,children:[(0,Q.jsx)(`span`,{className:J(`font-semibold tabular-nums`,n),children:t}),(0,Q.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:e})]})}var tt={idle:`phaseStart`,questioning:`phaseInterview`,spec_review:`phaseSpecReview`,implementation:`phasePlanning`,task_review:`phaseTaskReview`,executing:`phaseRunning`,done:`phaseDone`},nt=[`questioning`,`spec_review`,`implementation`,`task_review`,`executing`];function rt({onClose:e,onRunStarted:t}){let{t:n}=T(),{client:r}=se(),a=ce(e=>e.snapshot),l=ce(e=>e.agentText),f=ce(e=>e.error),p=ce(e=>e.startedRunId),m=ce(e=>e.setStartedRunId),[g,_]=(0,Z.useState)(``),[y,x]=(0,Z.useState)(``),[S,C]=(0,Z.useState)(!1),[w,E]=(0,Z.useState)(!0),[ee,D]=(0,Z.useState)(!0),[te,O]=(0,Z.useState)(!1),[k,A]=(0,Z.useState)(void 0),[M,ne]=(0,Z.useState)(void 0),[N,re]=(0,Z.useState)([]),[P,ie]=(0,Z.useState)(4),[F,ae]=(0,Z.useState)(!0),I=ge(te),L=(0,Z.useCallback)(e=>r?.send?.(e),[r]),z=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{L({type:`sdd.spec.get`})},[L]),(0,Z.useEffect)(()=>{z.current?.scrollIntoView({behavior:`smooth`,block:`end`})},[a?.answers.length??0,l]),(0,Z.useEffect)(()=>{p&&(t?.(),m(null))},[t,m,p]);let B=a?.busy??!1,V=a?.phase??`idle`,H=!!a;(0,Z.useEffect)(()=>{H&&C(!1)},[H]);let U=a?.answers[a.answers.length-1]?.question??``,W=!!a&&(a.taskCount>0||!!a.graphId||V===`task_review`||V===`executing`),G=()=>{let e=g.trim();!e||B||S||(C(!0),L({type:`sdd.spec.start`,payload:{goal:e}}))},K=()=>{let e=y.trim();!e||B||(L({type:`sdd.spec.message`,payload:{text:e}}),x(``))},q=()=>!B&&L({type:`sdd.spec.approve`,payload:{}}),oe=()=>{L({type:`sdd.run.start`,payload:{parallelSlots:P,worktrees:F,...k?{model:k,provider:M}:{},...N.length?{fallbackModels:N}:{}}}),O(!1)},Y=(0,Z.useMemo)(()=>(a?.board?.tasks??[]).map(e=>({id:e.id,shortId:e.shortId,title:e.title,displayStatus:e.displayStatus,priority:e.priority,deps:e.deps,agentName:e.agentName,worktreeBranch:e.worktreeBranch,retries:e.retries})),[a?.board]),le=Y.length>0;return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col bg-background`,children:[(0,Q.jsxs)(`header`,{className:`sdd-sheen flex shrink-0 items-center justify-between border-b border-border px-4 py-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(c,{className:`h-5 w-5 text-primary`}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h1`,{className:`text-lg font-semibold`,children:a?.title||n(`activity:sddWizard.titleFallback`)}),H&&(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[n(`activity:sddWizard.${tt[V]??`phaseStart`}`),V===`questioning`&&` · ${n(`activity:sddWizard.questionsSuffix`,{cur:a?.questionCount??0,max:a?.maxQuestions??0})}`,a&&a.taskCount>0?` · ${n(`activity:sddWizard.tasksSuffix`,{count:a.taskCount})}`:``]})]}),B&&(0,Q.jsx)(b,{className:`h-4 w-4 animate-spin text-muted-foreground`})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[W&&(0,Q.jsxs)(`div`,{className:`relative flex items-center gap-1.5`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>O(e=>!e),title:n(`activity:sddWizard.runCfgTitle`),className:J(`inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs font-medium`,k||N.length?`border-primary/40 bg-primary/10 text-primary`:`border-border bg-muted text-muted-foreground hover:text-foreground`),children:[(0,Q.jsx)(u,{className:`h-3.5 w-3.5`}),k||n(`activity:sddWizard.modelsLabel`)]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:oe,className:`inline-flex items-center gap-1 rounded-md bg-success/15 px-2.5 py-1 text-xs font-medium text-success hover:bg-success/25`,children:[(0,Q.jsx)(j,{className:`h-3.5 w-3.5`}),` `,n(`activity:sddWizard.startRun`)]}),te&&(0,Q.jsxs)(`div`,{className:`sdd-rise absolute right-0 top-9 z-50 w-72 rounded-lg border border-border bg-popover p-3 shadow-xl`,children:[(0,Q.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:n(`activity:sddWizard.defaultWorkerModel`)}),(0,Q.jsx)(_e,{value:k,provider:M,candidates:I,placeholder:n(`activity:sddWizard.leaderDefaultPlaceholder`),resetLabel:n(`activity:sddWizard.useSessionDefault`),onPick:(e,t)=>{A(e),ne(t)},onReset:k?()=>{A(void 0),ne(void 0)}:void 0}),(0,Q.jsx)(`div`,{className:`mb-1 mt-3 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:n(`activity:sddWizard.fallbackChain`)}),(0,Q.jsx)(ve,{value:N,candidates:I,onChange:re}),(0,Q.jsx)(`p`,{className:`mt-2 text-[10px] text-muted-foreground`,children:n(`activity:sddWizard.appliesToAll`)}),(0,Q.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`label`,{htmlFor:`sdd-slots`,className:`text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:n(`activity:sddWizard.parallelAgents`)}),(0,Q.jsx)(`input`,{id:`sdd-slots`,type:`number`,min:1,max:16,value:P,onChange:e=>{let t=Number.parseInt(e.target.value,10);ie(Number.isFinite(t)?Math.min(16,Math.max(1,t)):1)},className:`w-16 rounded-md border border-border bg-background px-2 py-1 text-right text-xs outline-none focus:border-primary`})]}),(0,Q.jsxs)(`label`,{className:`mt-2 flex cursor-pointer items-center justify-between gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:n(`activity:sddWizard.isolateWorktrees`)}),(0,Q.jsx)(`input`,{type:`checkbox`,checked:F,onChange:e=>ae(e.target.checked),className:`h-3.5 w-3.5 accent-primary`})]}),(0,Q.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:n(F?`activity:sddWizard.worktreeOn`:`activity:sddWizard.worktreeOff`)})]})]}),(0,Q.jsx)(X,{variant:`ghost`,size:`icon`,onClick:e,children:(0,Q.jsx)(R,{className:`h-4 w-4`})})]})]}),H&&(0,Q.jsx)(`div`,{className:`flex shrink-0 items-center gap-1 border-b bg-card/50 px-4 py-1.5 text-[11px]`,children:nt.map((e,t)=>{let r=e===V,i=nt.indexOf(V)>t;return(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsxs)(`span`,{className:J(`rounded-full px-2 py-0.5`,r?`bg-primary/15 text-primary`:i?`text-success`:`text-muted-foreground`),children:[i&&(0,Q.jsx)(h,{className:`mr-0.5 inline h-3 w-3`}),n(`activity:sddWizard.${tt[e]}`)]}),t<nt.length-1&&(0,Q.jsx)(`span`,{className:`text-muted-foreground/65`,children:`→`})]},e)})}),(0,Q.jsxs)(`div`,{ref:ye(`sdd-wizard`),className:`min-h-0 flex-1 overflow-auto overscroll-contain p-4`,children:[f&&(0,Q.jsx)(`div`,{className:`mb-3 rounded-md border border-destructive/40 bg-destructive/5 p-2 text-xs text-destructive`,children:f}),H?(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[le&&(0,Q.jsxs)(`div`,{className:`sdd-rise overflow-hidden rounded-lg border border-primary/20 bg-[hsl(var(--surface-2)/0.85)]`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>E(e=>!e),className:`flex w-full items-center gap-1.5 border-b border-border/60 px-3 py-1.5 text-[11px] font-medium text-primary hover:bg-muted/40`,children:[w?(0,Q.jsx)(o,{className:`h-3.5 w-3.5`}):(0,Q.jsx)(v,{className:`h-3.5 w-3.5`}),(0,Q.jsx)(i,{className:`h-3.5 w-3.5`}),n(`activity:sddWizard.taskGraphSummary`,{count:a?.taskCount??0}),(0,Q.jsx)(`span`,{className:`ml-auto text-muted-foreground`,children:n(w?`activity:sddWizard.dragToExplore`:`activity:sddWizard.show`)})]}),w&&(0,Q.jsx)(`div`,{className:`h-[32dvh] min-h-[200px]`,children:(0,Q.jsx)(He,{tasks:Y,columns:a?.board?.columns??[]})})]}),(0,Q.jsxs)(`div`,{className:`mx-auto max-w-2xl space-y-3`,children:[a?.goal&&(0,Q.jsxs)(`div`,{className:`rounded-md border border-border bg-muted/30 px-3 py-2`,children:[(0,Q.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[(0,Q.jsx)(s,{className:`h-3 w-3`}),` `,n(`activity:sddWizard.goalLabel`)]}),(0,Q.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-foreground/90`,children:a.goal})]}),a?.answers.length||l&&V===`questioning`||B?(0,Q.jsxs)(`div`,{className:`space-y-2.5`,children:[a?.answers.map(e=>(0,Q.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,Q.jsx)(at,{speaker:`assistant`,text:e.question}),(0,Q.jsx)(at,{speaker:`user`,text:e.answer})]},e.question.slice(0,64))),l&&V===`questioning`&&l!==U&&(0,Q.jsx)(at,{speaker:`assistant`,text:l}),B&&(0,Q.jsx)(at,{speaker:`assistant`,text:``,thinking:!0})]}):null,a?.spec&&(0,Q.jsxs)(`div`,{className:`sdd-rise rounded-md border border-border bg-card p-3`,children:[(0,Q.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-sm font-semibold`,children:[(0,Q.jsx)(c,{className:`h-3.5 w-3.5 text-primary`}),a.spec.title]}),(0,Q.jsx)(`p`,{className:`mb-2 text-xs text-muted-foreground`,children:a.spec.overview}),(0,Q.jsx)(`ul`,{className:`space-y-0.5 text-xs`,children:a.spec.requirements.map(e=>(0,Q.jsxs)(`li`,{className:`flex gap-1.5`,children:[(0,Q.jsx)(`span`,{className:J(`shrink-0 font-mono uppercase`,we(e.priority).text),children:e.priority[0]}),(0,Q.jsx)(`span`,{children:e.description})]},`${e.priority}-${e.description.slice(0,32)}`))})]}),l&&(V===`implementation`||V===`task_review`)&&(0,Q.jsxs)(`div`,{className:`sdd-rise rounded-md border border-border bg-card`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>D(e=>!e),className:`flex w-full items-center gap-1.5 border-b border-border/60 px-3 py-2 text-sm font-semibold hover:bg-muted/40`,children:[ee?(0,Q.jsx)(o,{className:`h-3.5 w-3.5`}):(0,Q.jsx)(v,{className:`h-3.5 w-3.5`}),(0,Q.jsx)(c,{className:`h-3.5 w-3.5 text-primary`}),` `,n(`activity:sddWizard.implementationPlan`)]}),ee&&(0,Q.jsx)(`div`,{className:`max-h-[40dvh] overflow-auto px-3 py-2`,children:(0,Q.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-foreground/90`,children:it(l)})})]}),l&&V!==`questioning`&&V!==`implementation`&&V!==`task_review`&&!a?.spec&&(0,Q.jsx)(at,{speaker:`assistant`,text:l}),(V===`spec_review`||V===`implementation`||V===`task_review`)&&(0,Q.jsxs)(X,{variant:`secondary`,onClick:q,disabled:B,children:[(0,Q.jsx)(h,{className:`mr-1.5 h-4 w-4`}),n(V===`spec_review`?`activity:sddWizard.approveSpec`:V===`task_review`?`activity:sddWizard.approveTasks`:`activity:sddWizard.approvePlan`)]}),(0,Q.jsx)(`div`,{ref:z})]})]}):(0,Q.jsxs)(`div`,{className:`mx-auto mt-8 max-w-xl`,children:[(0,Q.jsx)(`label`,{className:`mb-2 block text-sm font-medium`,htmlFor:`sdd-goal`,children:n(`activity:sddWizard.goalPrompt`)}),(0,Q.jsx)(`textarea`,{id:`sdd-goal`,value:g,onChange:e=>_(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&G()},rows:4,placeholder:n(`activity:sddWizard.goalPlaceholder`),className:`w-full resize-none rounded-md border border-border bg-card px-3 py-2 text-sm outline-none focus:border-primary`}),(0,Q.jsx)(X,{className:`mt-3`,onClick:G,disabled:!g.trim()||S,children:S?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(b,{className:`mr-1.5 h-4 w-4 animate-spin`}),` `,n(`activity:sddWizard.startingInterview`)]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(c,{className:`mr-1.5 h-4 w-4`}),` `,n(`activity:sddWizard.startInterview`)]})}),(0,Q.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:n(`activity:sddWizard.introBody`)})]})]}),H&&V!==`executing`&&V!==`done`&&(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-end gap-2 border-t bg-card px-4 py-2`,children:[(0,Q.jsx)(`textarea`,{value:y,onChange:e=>x(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),K())},rows:1,placeholder:n(V===`questioning`?`activity:sddWizard.answerPlaceholder`:`activity:sddWizard.changePlaceholder`),disabled:B,className:`max-h-32 flex-1 resize-none rounded-md border border-border bg-background px-3 py-2 text-sm outline-none focus:border-primary disabled:opacity-50`}),(0,Q.jsx)(X,{size:`icon`,onClick:K,disabled:B||!y.trim(),children:(0,Q.jsx)(d,{className:`h-4 w-4`})})]})]})}function it(e){let t=e.replace(/```json[\s\S]*?```/gi,``).trim();return t.length>0?t:e.trim()}function at({speaker:e,text:t,live:n,thinking:r}){let i=e===`user`;return(0,Q.jsxs)(`div`,{className:J(`sdd-rise flex items-start gap-2`,i&&`flex-row-reverse`),children:[(0,Q.jsx)(`span`,{className:J(`mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-full`,i?`bg-info/15 text-info`:`bg-primary/15 text-primary`,(n||r)&&`sdd-agent-live`),children:i?(0,Q.jsx)(I,{className:`h-3.5 w-3.5`}):(0,Q.jsx)(f,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(`div`,{className:J(`max-w-[80%] whitespace-pre-wrap rounded-2xl px-3 py-2 text-sm leading-relaxed text-foreground`,i?`rounded-tr-sm bg-info/10`:`rounded-tl-sm bg-muted`),children:r?(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 py-0.5`,children:[(0,Q.jsx)(`span`,{className:`h-1.5 w-1.5 animate-bounce rounded-full bg-muted-foreground [animation-delay:-200ms]`}),(0,Q.jsx)(`span`,{className:`h-1.5 w-1.5 animate-bounce rounded-full bg-muted-foreground [animation-delay:-100ms]`}),(0,Q.jsx)(`span`,{className:`h-1.5 w-1.5 animate-bounce rounded-full bg-muted-foreground`})]}):t})]})}var $=[{id:`project`,labelKey:`activity:sddhub.tabProject`},{id:`board`,labelKey:`activity:sddhub.tabBoard`},{id:`specs`,labelKey:`activity:sddhub.tabSpecs`}];function ot(){let{t:e}=T(),[t,n]=(0,Z.useState)(`project`),r=()=>le(`chat`),i=(0,Z.useCallback)(()=>n(`board`),[]),a=(e,t)=>{let r;if(e.key===`ArrowLeft`&&(r=(t-1+$.length)%$.length),e.key===`ArrowRight`&&(r=(t+1)%$.length),e.key===`Home`&&(r=0),e.key===`End`&&(r=$.length-1),r===void 0)return;e.preventDefault();let i=$[r];i&&(n(i.id),e.currentTarget.parentElement?.querySelectorAll(`[role="tab"]`)[r]?.focus())};return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col bg-background`,children:[(0,Q.jsx)(`div`,{role:`tablist`,"aria-orientation":`horizontal`,className:`flex shrink-0 items-end border-b border-border/70 bg-card px-4`,children:$.map((r,i)=>{let o=t===r.id;return(0,Q.jsxs)(`button`,{id:`sdd-hub-tab-${r.id}`,type:`button`,role:`tab`,"aria-selected":o,"aria-controls":`sdd-hub-panel-${r.id}`,tabIndex:o?0:-1,onClick:()=>n(r.id),onKeyDown:e=>a(e,i),className:J(`relative px-4 py-2.5 text-sm font-medium transition-colors`,o?`text-foreground`:`text-muted-foreground hover:text-foreground`),children:[e(r.labelKey),o&&(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`absolute bottom-0 left-0 right-0 h-0.5 bg-primary`})]},r.id)})}),(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:[(0,Q.jsx)(`div`,{id:`sdd-hub-panel-project`,role:`tabpanel`,"aria-labelledby":`sdd-hub-tab-project`,hidden:t!==`project`,className:`h-full overflow-y-auto overscroll-contain`,children:(0,Q.jsx)(rt,{onClose:r,onRunStarted:i})}),(0,Q.jsx)(`div`,{id:`sdd-hub-panel-board`,role:`tabpanel`,"aria-labelledby":`sdd-hub-tab-board`,hidden:t!==`board`,className:`h-full overflow-y-auto overscroll-contain`,children:(0,Q.jsx)(Ze,{onClose:r})}),(0,Q.jsx)(`div`,{id:`sdd-hub-panel-specs`,role:`tabpanel`,"aria-labelledby":`sdd-hub-tab-specs`,hidden:t!==`specs`,className:`h-full overflow-y-auto overscroll-contain`,children:(0,Q.jsx)(be,{onClose:r})})]})]})}export{ot as SddHub};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Di as t,Ft as n,Gr as r,Li as i,Oi as a,Rt as o,Ti as s,Ut as c,Vn as l,aa as u,ca as d,cn as f,fr as p,gr as m,it as h,ni as g,nr as _,qi as v,rn as y,t as b,tt as x,ua as S}from"./vendor-BmsAdDhb.js";import"./i18n-c37VNlP9.js";import{t as C}from"./useWebSocket-kb2VPjLc.js";import{t as w}from"./ws-client-BydCS6yi.js";import{t as T}from"./utils-DvgvNCoT.js";import{j as ee}from"./stores-DVhvmaer.js";import{s as E}from"./view-navigation-D8lN47bJ.js";import{n as D}from"./Toaster-BzC_AdG5.js";import{a as O,n as te,o as k,r as ne,t as re}from"./dialog-BjPQYovj.js";import{t as A}from"./button-GVbauxIJ.js";import{t as j}from"./input-BVi5hYQz.js";import{c as M,d as N,f as P,o as F,s as I,v as L}from"./index-196U0qsu.js";var R=e(S(),1),ie=e(b(),1),z=x();function ae(e,t=8e3){return new Promise((n,r)=>{let i=setTimeout(()=>{a(),r(Error(`timeout`))},t),a=e.on(`key.operation_result`,e=>{clearTimeout(i),a(),n(e.payload)})})}var B=I();async function oe(e,t){try{let n=await fetch(e,{signal:t});if(!n.ok)throw Error(`HTTP ${n.status}`);let r=await n.json();if(!Array.isArray(r))throw Error(`Expected JSON array`);let i=r.filter(e=>typeof e.id==`string`&&typeof e.name==`string`&&typeof e.family==`string`);return i.length>0?i:B}catch{return B}}function se({popular:e,catalogProvider:n,savedProvider:i,onKeySaved:o}){let{t:d}=u(),[f,p]=(0,R.useState)(``),[h,_]=(0,R.useState)(!1),[v,y]=(0,R.useState)(!!i?.apiKeys.some(e=>e.isActive)),[b,x]=(0,R.useState)(!1),[S,C]=(0,R.useState)(!1),[E,M]=(0,R.useState)(!1),[N,P]=(0,R.useState)(null);(0,R.useEffect)(()=>{E&&e.referral&&ie.toDataURL(e.referral.url,{width:200,margin:2,color:{dark:`#000000`,light:`#ffffff`}}).then(e=>P(e)).catch(()=>P(null))},[E,e.referral]);let F=async()=>{if(f.trim()){_(!0);try{let t=w(ee.getState().wsUrl),r=ae(t);n?t.addKey(e.id,`default`,f.trim()):t.send({type:`provider.add`,payload:{id:e.id,family:e.family,apiKey:f.trim()}});let i=await r;if(!i.success)throw Error(i.message);y(!0),p(``),D.success(d(`setup:screen.toasts.keySaved`,{name:e.name})),o(e.id)}catch(t){let n=t instanceof Error&&t.message&&t.message!==`timeout`?t.message:null;D.error(n??d(`setup:screen.toasts.keySaveFailed`,{name:e.name}))}finally{_(!1)}}},I=e=>{e.key===`Enter`&&f.trim()&&F()},L=async()=>{if(e.referral)try{await navigator.clipboard.writeText(e.referral.url),C(!0),D.success(d(`setup:screen.toasts.referralCopied`)),setTimeout(()=>C(!1),2e3)}catch{D.error(d(`setup:screen.toasts.referralCopyFailed`))}},B=n&&n.modelCount>0;return(0,z.jsxs)(`div`,{className:T(`rounded-xl border p-4 transition-all`,v?`border-success/30 bg-success/5`:`bg-gradient-to-br ${e.color}`),children:[(0,z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,z.jsx)(`span`,{className:`text-2xl shrink-0 mt-0.5`,children:e.icon}),(0,z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`h3`,{className:`text-sm font-semibold`,children:e.name}),v&&(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded-full bg-success/10 text-success border border-success/20`,children:[(0,z.jsx)(a,{className:`h-2.5 w-2.5`}),d(`setup:screen.card.keySaved`)]}),e.referral&&!v&&(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded-full bg-warning/10 text-warning border border-warning/20`,children:[(0,z.jsx)(m,{className:`h-2.5 w-2.5`}),d(`setup:screen.card.referral`)]})]}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e.description}),e.referral&&!v&&(0,z.jsxs)(`p`,{className:`text-[11px] text-warning/80 mt-1`,children:[`🎁 `,e.referral.reward]}),v?B?(0,z.jsxs)(`button`,{type:`button`,onClick:()=>x(!b),className:`mt-2 text-[11px] text-muted-foreground hover:text-foreground transition-colors flex items-center gap-1`,children:[d(`setup:screen.providers.modelsAvailable`,{count:n?.modelCount??0}),b?(0,z.jsx)(t,{className:`h-3 w-3`}):(0,z.jsx)(s,{className:`h-3 w-3`})]}):null:(0,z.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,z.jsx)(j,{type:`password`,placeholder:e.keyPlaceholder,value:f,onChange:e=>p(e.target.value),onKeyDown:I,className:`font-mono text-sm`}),(0,z.jsx)(A,{onClick:F,disabled:!f.trim()||h,size:`sm`,className:`shrink-0`,children:h?(0,z.jsx)(l,{className:`h-4 w-4 animate-spin`}):d(`setup:screen.card.save`)})]}),e.docsUrl&&(0,z.jsxs)(`a`,{href:e.docsUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground transition-colors`,children:[d(`setup:screen.card.getKey`),` `,(0,z.jsx)(r,{className:`h-3 w-3`})]}),e.referral&&(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:L,className:`inline-flex items-center gap-1 text-[11px] text-warning/80 hover:text-warning transition-colors`,children:S?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(a,{className:`h-3 w-3`}),` `,d(`setup:screen.card.copied`)]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(g,{className:`h-3 w-3`}),` `,d(`setup:screen.card.copyReferral`)]})}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>M(!0),className:`inline-flex items-center gap-1 text-[11px] text-warning/80 hover:text-warning transition-colors`,children:[(0,z.jsx)(c,{className:`h-3 w-3`}),` `,d(`setup:screen.card.share`)]})]})]})]})]}),(0,z.jsx)(re,{open:E,onOpenChange:M,children:(0,z.jsxs)(te,{className:`sm:max-w-md`,children:[(0,z.jsxs)(O,{children:[(0,z.jsxs)(k,{className:`flex items-center gap-2`,children:[(0,z.jsx)(m,{className:`h-4 w-4 text-warning`}),d(`setup:screen.share.title`,{name:e.name})]}),(0,z.jsx)(ne,{children:d(`setup:screen.share.description`)})]}),(0,z.jsx)(`div`,{className:`flex flex-col items-center gap-4 py-4`,children:e.referral&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`text-sm text-center`,children:(0,z.jsxs)(`p`,{className:`font-medium text-warning`,children:[`🎁 `,e.referral.reward]})}),N?(0,z.jsx)(`div`,{className:`rounded-lg border border-border p-2 bg-white`,children:(0,z.jsx)(`img`,{src:N,alt:d(`setup:screen.card.qrAlt`,{name:e.name}),className:`w-[200px] h-[200px]`})}):(0,z.jsx)(`div`,{className:`w-[200px] h-[200px] rounded-lg border border-border flex items-center justify-center bg-muted`,children:(0,z.jsx)(l,{className:`h-6 w-6 animate-spin text-muted-foreground`})}),(0,z.jsxs)(`div`,{className:`w-full space-y-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-center gap-2`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>{let t=encodeURIComponent(`Check out ${e.name}! 🎁 ${e.referral.reward}`),n=encodeURIComponent(e.referral.url);window.open(`https://twitter.com/intent/tweet?text=${t}&url=${n}`,`_blank`,`noopener,noreferrer`)},className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg border border-border bg-card text-xs text-foreground hover:bg-muted transition-colors`,title:d(`setup:screen.share.twitter`),children:[(0,z.jsx)(`svg`,{role:`img`,"aria-hidden":`true`,className:`h-3.5 w-3.5`,fill:`currentColor`,viewBox:`0 0 24 24`,children:(0,z.jsx)(`path`,{d:`M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z`})}),`X`]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>{let t=encodeURIComponent(e.referral.url),n=encodeURIComponent(`Check out ${e.name}! ${e.referral.reward}`);window.open(`https://www.linkedin.com/sharing/share-offsite/?url=${t}&summary=${n}`,`_blank`,`noopener,noreferrer`)},className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg border border-border bg-card text-xs text-foreground hover:bg-muted transition-colors`,title:d(`setup:screen.share.linkedin`),children:[(0,z.jsx)(`svg`,{role:`img`,"aria-hidden":`true`,className:`h-3.5 w-3.5`,fill:`currentColor`,viewBox:`0 0 24 24`,children:(0,z.jsx)(`path`,{d:`M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z`})}),`LinkedIn`]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>{let t=encodeURIComponent(`Check out ${e.name}! 🎁 ${e.referral.reward} ${e.referral.url}`);window.open(`https://t.me/share/url?url=${t}`,`_blank`,`noopener,noreferrer`)},className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg border border-border bg-card text-xs text-foreground hover:bg-muted transition-colors`,title:d(`setup:screen.share.telegram`),children:[(0,z.jsx)(`svg`,{role:`img`,"aria-hidden":`true`,className:`h-3.5 w-3.5`,fill:`currentColor`,viewBox:`0 0 24 24`,children:(0,z.jsx)(`path`,{d:`M11.944 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.056 0zm4.962 7.224c.1-.002.321.023.465.14a.506.506 0 0 1 .171.325c.016.093.036.306.02.472-.18 1.898-.962 6.502-1.36 8.627-.168.9-.499 1.201-.82 1.23-.696.065-1.225-.46-1.9-.902-1.056-.693-1.653-1.124-2.678-1.8-1.185-.78-.417-1.21.258-1.91.177-.184 3.247-2.977 3.307-3.23.007-.032.014-.15-.056-.212s-.174-.041-.249-.024c-.106.024-1.793 1.14-5.061 3.345-.48.33-.913.49-1.302.48-.428-.008-1.252-.241-1.865-.44-.752-.245-1.349-.374-1.297-.789.027-.216.325-.437.893-.663 3.498-1.524 5.83-2.529 6.998-3.014 3.332-1.386 4.025-1.627 4.476-1.635z`})}),`Telegram`]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>{let t=encodeURIComponent(`Check out ${e.name}! 🎁 ${e.referral.reward}`),n=encodeURIComponent(e.referral.url);window.open(`https://wa.me/?text=${t}%20${n}`,`_blank`,`noopener,noreferrer`)},className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg border border-border bg-card text-xs text-foreground hover:bg-muted transition-colors`,title:d(`setup:screen.share.whatsapp`),children:[(0,z.jsx)(`svg`,{role:`img`,"aria-hidden":`true`,className:`h-3.5 w-3.5`,fill:`currentColor`,viewBox:`0 0 24 24`,children:(0,z.jsx)(`path`,{d:`M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.134 1.585 5.934L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z`})}),`WhatsApp`]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>{let t=encodeURIComponent(e.referral.url),n=encodeURIComponent(`${e.name} - ${e.referral.reward}`);window.open(`https://www.reddit.com/submit?url=${t}&title=${n}`,`_blank`,`noopener,noreferrer`)},className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg border border-border bg-card text-xs text-foreground hover:bg-muted transition-colors`,title:d(`setup:screen.share.reddit`),children:[(0,z.jsx)(`svg`,{role:`img`,"aria-hidden":`true`,className:`h-3.5 w-3.5`,fill:`currentColor`,viewBox:`0 0 24 24`,children:(0,z.jsx)(`path`,{d:`M12 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0zm5.01 4.744c.688 0 1.25.561 1.25 1.249a1.25 1.25 0 0 1-2.498.056l-2.597-.547-.8 3.747c1.824.07 3.48.632 4.674 1.488.308-.309.73-.491 1.207-.491.968 0 1.754.786 1.754 1.754 0 .716-.435 1.333-1.01 1.614a3.111 3.111 0 0 1 .042.52c0 2.694-3.13 4.87-7.004 4.87-3.874 0-7.004-2.176-7.004-4.87 0-.183.015-.366.043-.534A1.748 1.748 0 0 1 4.028 12c0-.968.786-1.754 1.754-1.754.463 0 .898.196 1.207.49 1.207-.883 2.878-1.43 4.744-1.487l.885-4.182a.342.342 0 0 1 .14-.197.35.35 0 0 1 .238-.042l2.906.617a1.214 1.214 0 0 0 1.108-.701 1.25 1.25 0 0 1 2.144.33zm-8.811 8.748c-.968 0-1.754.786-1.754 1.754 0 .968.786 1.754 1.754 1.754.968 0 1.754-.786 1.754-1.754 0-.968-.786-1.754-1.754-1.754zm7.944 0c-.968 0-1.754.786-1.754 1.754 0 .968.786 1.754 1.754 1.754.968 0 1.754-.786 1.754-1.754 0-.968-.786-1.754-1.754-1.754z`})}),`Reddit`]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>{let t=encodeURIComponent(`Check out ${e.name}! 🎁 ${e.referral.reward}`),n=encodeURIComponent(e.referral.url);window.open(`https://www.facebook.com/sharer/sharer.php?u=${n}&quote=${t}`,`_blank`,`noopener,noreferrer`)},className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg border border-border bg-card text-xs text-foreground hover:bg-muted transition-colors`,title:d(`setup:screen.share.facebook`),children:[(0,z.jsx)(`svg`,{role:`img`,"aria-hidden":`true`,className:`h-3.5 w-3.5`,fill:`currentColor`,viewBox:`0 0 24 24`,children:(0,z.jsx)(`path`,{d:`M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z`})}),`Facebook`]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>{let t=encodeURIComponent(`Check out ${e.name}! 🎁 ${e.referral.reward}`),n=encodeURIComponent(e.referral.url);window.open(`mailto:?subject=${t}&body=${n}`,`_blank`,`noopener,noreferrer`)},className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-muted text-muted-foreground text-xs hover:bg-muted/80 transition-colors`,title:d(`setup:screen.share.email`),children:[(0,z.jsx)(`svg`,{role:`img`,"aria-hidden":`true`,className:`h-3.5 w-3.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,viewBox:`0 0 24 24`,children:(0,z.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M21.75 6.75v10.5a2.25 2.25 0 01-2.25 2.25H4.5a2.25 2.25 0 01-2.25-2.25V6.75m19.5 0A2.25 2.25 0 0019.5 4.5h-15a2.25 2.25 0 00-2.25 2.25m19.5 0v.243a2.25 2.25 0 01-1.07 1.916l-7.5 4.615a2.25 2.25 0 01-2.36 0L3.32 8.91a2.25 2.25 0 01-1.07-1.916V6.75`})}),`Email`]})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(j,{value:e.referral.url,readOnly:!0,className:`font-mono text-xs flex-1`}),(0,z.jsx)(A,{size:`sm`,variant:`outline`,onClick:L,className:`shrink-0`,children:S?(0,z.jsx)(a,{className:`h-4 w-4`}):(0,z.jsx)(g,{className:`h-4 w-4`})})]}),(0,z.jsx)(`p`,{className:`text-[11px] text-muted-foreground text-center`,children:d(`setup:screen.share.hint`)})]})]})})]})})]})}function ce({onKeySaved:e}){let{t}=u(),[n,r]=(0,R.useState)(!1),[i,a]=(0,R.useState)(``),[o,c]=(0,R.useState)(`openai-compatible`),[d,p]=(0,R.useState)(``),[m,h]=(0,R.useState)(``),[g,_]=(0,R.useState)(!1),{setFieldRef:v,handleKeyDown:y}=M(),b=async()=>{if(i.trim()){_(!0);try{let n=w(ee.getState().wsUrl),s=ae(n);n.send({type:`provider.add`,payload:{id:i.trim(),family:o,baseUrl:d.trim()||void 0,apiKey:m.trim()||void 0}});let c=await s;if(!c.success)throw Error(c.message);D.success(t(`setup:screen.toasts.providerAdded`,{id:i.trim()})),e(i.trim()),a(``),p(``),h(``),r(!1)}catch(e){let n=e instanceof Error&&e.message&&e.message!==`timeout`?e.message:null;D.error(n??t(`setup:screen.toasts.providerAddFailed`))}finally{_(!1)}}};return(0,z.jsxs)(`div`,{className:`rounded-xl border border-dashed border-border/60 overflow-hidden`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>r(!n),className:`w-full flex items-center gap-3 p-4 text-left hover:bg-muted/30 transition-colors`,children:[(0,z.jsx)(`div`,{className:`w-10 h-10 rounded-lg bg-muted/50 flex items-center justify-center`,children:(0,z.jsx)(f,{className:`h-5 w-5 text-muted-foreground`})}),(0,z.jsxs)(`div`,{className:`flex-1`,children:[(0,z.jsx)(`h3`,{className:`text-sm font-medium`,children:t(`setup:screen.custom.title`)}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`setup:screen.custom.description`)})]}),(0,z.jsx)(s,{className:T(`h-4 w-4 text-muted-foreground transition-transform`,n&&`rotate-90`)})]}),n&&(0,z.jsxs)(`div`,{className:`px-4 pb-4 space-y-3 border-t border-border/40`,children:[(0,z.jsxs)(`div`,{className:`space-y-1.5 pt-3`,children:[(0,z.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground block`,children:t(`setup:screen.custom.localServers`)}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:F.map(e=>(0,z.jsx)(A,{type:`button`,size:`sm`,variant:i===e.id?`default`:`outline`,onClick:()=>{a(e.id),c(`openai-compatible`),p(e.defaultBaseUrl),e.noAuth&&h(``)},title:e.hint,children:e.label},e.id))})]}),(0,z.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground mb-1 block`,children:t(`setup:screen.custom.providerId`)}),(0,z.jsx)(j,{placeholder:`e.g. my-llm`,value:i,onChange:e=>a(e.target.value),className:`text-sm`,ref:v(0),onKeyDown:e=>y(e,0)})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground mb-1 block`,children:t(`setup:screen.custom.family`)}),(0,z.jsxs)(`select`,{value:o,onChange:e=>c(e.target.value),className:`flex h-9 w-full rounded-md border border-input bg-transparent px-3 text-sm`,ref:v(1),onKeyDown:e=>y(e,1),children:[(0,z.jsx)(`option`,{value:`openai-compatible`,children:t(`setup:screen.custom.familyOpenAiCompatible`)}),(0,z.jsx)(`option`,{value:`openai`,children:`OpenAI`}),(0,z.jsx)(`option`,{value:`anthropic`,children:`Anthropic`}),(0,z.jsx)(`option`,{value:`google`,children:`Google`})]})]})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground mb-1 block`,children:t(`setup:screen.custom.baseUrl`)}),(0,z.jsx)(j,{placeholder:`e.g. http://localhost:11434/v1`,value:d,onChange:e=>p(e.target.value),className:`text-sm font-mono`,ref:v(2),onKeyDown:e=>y(e,2)})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground mb-1 block`,children:t(`setup:screen.custom.apiKey`)}),(0,z.jsx)(j,{type:`password`,placeholder:t(`setup:screen.custom.apiKeyPlaceholder`),value:m,onChange:e=>h(e.target.value),className:`text-sm font-mono`,ref:v(3),onKeyDown:e=>y(e,3)})]}),(0,z.jsxs)(A,{onClick:b,disabled:!i.trim()||g,size:`sm`,ref:v(4),onKeyDown:e=>y(e,4,b),children:[g?(0,z.jsx)(l,{className:`h-4 w-4 animate-spin mr-2`}):null,t(`setup:screen.custom.add`)]})]})]})}function V(){let{t:e}=u(),{model:t,setProvider:r,setModel:c,wsConnected:f,wsUrl:m}=ee(h(e=>({model:e.model,setProvider:e.setProvider,setModel:e.setModel,wsConnected:e.wsConnected,wsUrl:e.wsUrl})));C();let[g,b]=(0,R.useState)(`keys`),[x,S]=(0,R.useState)([]),[O,te]=(0,R.useState)({}),[k,ne]=(0,R.useState)([]),[re,j]=(0,R.useState)(!1),[M,F]=(0,R.useState)(null),[I,ie]=(0,R.useState)(0),[ae,V]=(0,R.useState)(new Set),[le,ue]=(0,R.useState)(B),[H,U]=(0,R.useState)(!1),[de,fe]=(0,R.useState)(0),[pe,me]=(0,R.useState)(0),[W,he]=(0,R.useState)(null),G=(0,R.useRef)(!0);(0,R.useEffect)(()=>{let e=new AbortController,t=`${window.location.origin}/providers.json`;return U(!0),oe(t,e.signal).then(t=>{if(t!==B){if(ue(t),U(!1),!G.current){let e=t.length-pe;e>0?D.success(d.t(`setup:screen.toasts.providersLoadedNew`,{count:t.length,diff:e})):e<0?D.success(d.t(`setup:screen.toasts.providersLoadedRemoved`,{count:t.length,diff:Math.abs(e)})):D.success(d.t(`setup:screen.toasts.providersLoadedNoChanges`,{count:t.length})),me(t.length)}he(new Date);return}return oe(`https://raw.githubusercontent.com/WrongStack/WrongStack/main/packages/webui/public/providers.json`,e.signal)}).then(e=>{if(e){if(ue(e),!G.current){let t=e.length-pe;t>0?D.success(d.t(`setup:screen.toasts.providersLoadedNew`,{count:e.length,diff:t})):t<0?D.success(d.t(`setup:screen.toasts.providersLoadedRemoved`,{count:e.length,diff:Math.abs(t)})):D.success(d.t(`setup:screen.toasts.providersLoadedNoChanges`,{count:e.length})),me(e.length)}he(new Date)}}).catch(()=>{G.current||D.error(d.t(`setup:screen.toasts.providersRefreshFailed`))}).finally(()=>{U(!1),G.current=!1}),()=>e.abort()},[de]);let[K,q]=(0,R.useState)(null),[J,Y]=(0,R.useState)(null),[ge,_e]=(0,R.useState)(!1);(0,R.useEffect)(()=>{if(!f)return;let e=w(m),n=setTimeout(()=>{n=null,j(!1),F(d.t(`setup:screen.errors.backendNotResponding`))},8e3),r=()=>{n&&=(clearTimeout(n),null)},i=e.on(`provider.catalog`,e=>{if(e.type===`provider.catalog`){r(),F(null);let t=e.payload.providers.sort((e,t)=>e.id.localeCompare(t.id));S(t),j(!1)}}),a=e.on(`provider.models`,e=>{if(e.type===`provider.models`){let n=e.payload;te(e=>({...e,[n.provider]:n.models})),_e(!1),n.models.length===1?Y(n.models[0].id):t&&n.models.some(e=>e.id===t)&&Y(t)}}),o=e.on(`providers.saved`,e=>{if(e.type===`providers.saved`){let t=e.payload.providers.sort((e,t)=>e.id.localeCompare(t.id));ne(t);let n=new Set(t.filter(e=>e.apiKeys.some(e=>e.isActive)).map(e=>e.id));V(n)}});return F(null),j(!0),e.listProviders(),()=>{r(),i?.(),a?.(),o?.()}},[f,m,t,I]);let ve=(0,R.useCallback)(()=>{F(null),ie(e=>e+1)},[]),ye=(0,R.useCallback)(()=>{fe(e=>e+1)},[]),be=(0,R.useCallback)(t=>{let n=new Date().getTime()-t.getTime(),r=Math.floor(n/1e3);if(r<10)return e(`setup:screen.time.justNow`);if(r<60)return e(`setup:screen.time.secondsAgo`,{count:r});let i=Math.floor(r/60);if(i<60)return e(`setup:screen.time.minutesAgo`,{count:i});let a=Math.floor(i/60);if(a<24)return e(`setup:screen.time.hoursAgo`,{count:a});let o=Math.floor(a/24);return e(`setup:screen.time.daysAgo`,{count:o})},[e]),xe=(0,R.useCallback)(e=>{V(t=>new Set([...t,e]))},[]),X=ae.size>0,Se=(0,R.useCallback)(()=>{if(!X){if(k.length>0){let e=k[0];q(e.id),b(`done`)}return}let e=k.find(e=>e.apiKeys.some(e=>e.isActive));e&&(q(e.id),b(`done`))},[X,k]);(0,R.useEffect)(()=>{if(!K||!f||g!==`done`)return;let e=w(m);O[K]||(_e(!0),e.listProviderModels(K))},[K,f,m,O,g]);let Ce=K?O[K]??[]:[],we=(0,R.useCallback)(()=>{if(!K||!J)return;r(K),c(J);let e=w(m);e.switchModel(K,J);let t=null,n=()=>{t&&clearTimeout(t)},i=e.on(`key.operation_result`,t=>{let r=t.payload;n(),i(),r.success?(e.newSession(),E(`chat`)):D.error(r.message)});t=setTimeout(()=>{n(),i(),D.error(d.t(`setup:screen.errors.modelSwitchTimeout`))},5e3)},[K,J,r,c,m]),Te=new Set(le.map(e=>e.id)),Ee=x.filter(e=>!Te.has(e.id)).sort((e,t)=>e.id.localeCompare(t.id)),Z=P(Ee,10,g),Q=P(k,9,g),$=P(Ce,12,K);return(0,z.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,z.jsxs)(`header`,{className:`flex shrink-0 flex-col gap-3 border-b bg-card px-4 py-4 sm:flex-row sm:items-center sm:justify-between sm:px-6`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,z.jsx)(`img`,{src:`/wrongstack.svg`,alt:`WrongStack`,draggable:!1,className:`ws-brand-logo h-10 w-10 shrink-0 border border-border/70 shadow-sm`}),(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`h1`,{className:`truncate text-lg font-semibold`,children:e(`setup:screen.header.title`)}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground sm:truncate`,children:e(`setup:screen.header.subtitle`)})]})]}),X&&(0,z.jsxs)(A,{onClick:Se,size:`sm`,className:`w-full sm:w-auto`,children:[e(`setup:screen.header.continue`),(0,z.jsx)(v,{className:`h-4 w-4 ml-1.5`})]})]}),(0,z.jsx)(L,{className:`min-h-0 flex-1`,children:g===`keys`?(0,z.jsxs)(`div`,{className:`mx-auto max-w-3xl space-y-8 p-4 sm:p-6`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-sm`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-primary font-medium`,children:[(0,z.jsx)(_,{className:`h-4 w-4`}),(0,z.jsx)(`span`,{children:e(`setup:screen.steps.addKeys`)})]}),(0,z.jsx)(s,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-muted-foreground`,children:[(0,z.jsx)(i,{className:`h-4 w-4`}),(0,z.jsx)(`span`,{children:e(`setup:screen.steps.pickModel`)})]}),(0,z.jsx)(s,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-muted-foreground`,children:[(0,z.jsx)(n,{className:`h-4 w-4`}),(0,z.jsx)(`span`,{children:e(`setup:screen.steps.start`)})]})]}),(0,z.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl border border-primary/20 bg-primary/5 p-4`,children:[(0,z.jsx)(o,{className:`h-5 w-5 text-primary shrink-0 mt-0.5`}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`text-sm font-medium`,children:e(`setup:screen.security.title`)}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e(`setup:screen.security.body`)})]})]}),M?(0,z.jsxs)(`div`,{className:`flex flex-col items-center text-center gap-4 py-12 rounded-xl border border-destructive/30 bg-destructive/5 px-6`,children:[(0,z.jsx)(`div`,{className:`w-12 h-12 rounded-xl bg-destructive/10 border border-destructive/30 flex items-center justify-center`,children:(0,z.jsx)(p,{className:`h-6 w-6 text-destructive`})}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`text-sm font-medium text-destructive`,children:e(`setup:screen.errors.backendUnreachable`)}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1 max-w-sm`,children:M})]}),(0,z.jsxs)(A,{onClick:ve,size:`sm`,variant:`outline`,children:[(0,z.jsx)(l,{className:`h-4 w-4 mr-2`}),e(`setup:screen.errors.retry`)]})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`space-y-3`,children:[(0,z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,z.jsx)(`h2`,{className:`text-sm font-medium text-muted-foreground uppercase tracking-wider`,children:e(`setup:screen.providers.popular`)}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[H&&(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-muted-foreground`,children:[(0,z.jsx)(l,{className:`h-3 w-3 animate-spin`}),e(`setup:screen.providers.updating`)]}),W&&!H&&(0,z.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,title:W.toLocaleString(),children:be(W)}),(0,z.jsxs)(`button`,{type:`button`,onClick:ye,disabled:H,className:`inline-flex items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,title:e(`setup:screen.providers.refreshTitle`),children:[(0,z.jsx)(y,{className:T(`h-3 w-3`,H&&`animate-spin`)}),e(`setup:screen.providers.refresh`)]})]})]}),(0,z.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:le.map(e=>(0,z.jsx)(se,{popular:e,catalogProvider:x.find(t=>t.id===e.id),savedProvider:k.find(t=>t.id===e.id),onKeySaved:xe},e.id))})]}),Ee.length>0&&(0,z.jsxs)(`div`,{className:`space-y-3`,children:[(0,z.jsx)(`h2`,{className:`text-sm font-medium text-muted-foreground uppercase tracking-wider`,children:e(`setup:screen.providers.more`)}),(0,z.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:Z.pageItems.map(t=>(0,z.jsx)(se,{popular:{id:t.id,name:t.name,description:e(`setup:screen.providers.catalogDescription`,{family:t.family,count:t.modelCount}),icon:`🔗`,color:`from-muted/60 to-muted/20 border-border hover:border-primary/40`,keyPlaceholder:`API key`,family:t.family},catalogProvider:t,savedProvider:k.find(e=>e.id===t.id),onKeySaved:xe},t.id))}),(0,z.jsx)(N,{page:Z.page,pageSize:Z.pageSize,totalItems:Z.totalItems,onPageChange:Z.setPage,itemLabel:`providers`})]}),(0,z.jsxs)(`div`,{className:`space-y-3`,children:[(0,z.jsx)(`h2`,{className:`text-sm font-medium text-muted-foreground uppercase tracking-wider`,children:e(`setup:screen.providers.selfHosted`)}),(0,z.jsx)(ce,{onKeySaved:xe})]})]}),re&&(0,z.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,z.jsx)(l,{className:`h-6 w-6 animate-spin text-muted-foreground`})}),X&&(0,z.jsx)(`div`,{className:`sticky bottom-0 -mx-4 border-t bg-background/80 px-4 py-4 backdrop-blur-sm sm:-mx-6 sm:px-6`,children:(0,z.jsxs)(A,{onClick:Se,className:`w-full`,size:`lg`,children:[(0,z.jsx)(i,{className:`h-4 w-4 mr-2`}),e(`setup:screen.start.pickAndStart`),(0,z.jsx)(v,{className:`h-4 w-4 ml-2`})]})})]}):(0,z.jsxs)(`div`,{className:`mx-auto max-w-2xl space-y-8 p-4 sm:p-6`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-sm`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-success`,children:[(0,z.jsx)(a,{className:`h-4 w-4`}),(0,z.jsx)(`span`,{children:e(`setup:screen.steps.keys`)})]}),(0,z.jsx)(s,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-primary font-medium`,children:[(0,z.jsx)(i,{className:`h-4 w-4`}),(0,z.jsx)(`span`,{children:e(`setup:screen.steps.pickModel`)})]}),(0,z.jsx)(s,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-muted-foreground`,children:[(0,z.jsx)(n,{className:`h-4 w-4`}),(0,z.jsx)(`span`,{children:e(`setup:screen.steps.start`)})]})]}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>b(`keys`),className:`text-xs text-muted-foreground hover:text-foreground transition-colors`,children:e(`setup:screen.start.addMoreKeys`)}),(0,z.jsxs)(`div`,{className:`space-y-3`,children:[(0,z.jsxs)(`h2`,{className:`text-base font-semibold flex items-center gap-2`,children:[(0,z.jsx)(i,{className:`h-4 w-4 text-primary`}),e(`setup:screen.start.chooseProvider`)]}),(0,z.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 gap-2`,children:Q.pageItems.map(t=>(0,z.jsxs)(`button`,{type:`button`,onClick:()=>{q(t.id),Y(null)},className:T(`rounded-lg border p-3 text-left transition-all text-sm`,K===t.id?`border-primary bg-primary/10 ring-1 ring-primary/30`:`border-border hover:border-primary/40 hover:bg-primary/5`),children:[(0,z.jsx)(`span`,{className:`font-medium`,children:t.id}),(0,z.jsx)(`span`,{className:`block text-[11px] text-muted-foreground mt-0.5`,children:e(`setup:screen.start.activeKeys`,{count:t.apiKeys.filter(e=>e.isActive).length})})]},t.id))}),(0,z.jsx)(N,{page:Q.page,pageSize:Q.pageSize,totalItems:Q.totalItems,onPageChange:Q.setPage,itemLabel:`saved providers`})]}),K&&(0,z.jsxs)(`div`,{className:`space-y-3`,children:[(0,z.jsxs)(`h2`,{className:`text-base font-semibold flex items-center gap-2`,children:[(0,z.jsx)(n,{className:`h-4 w-4 text-primary`}),e(`setup:screen.start.chooseModel`)]}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`setup:screen.start.modelsFor`,{provider:K})}),ge?(0,z.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,z.jsx)(l,{className:`h-6 w-6 animate-spin text-muted-foreground`})}):Ce.length>0?(0,z.jsx)(`div`,{className:`grid grid-cols-1 gap-2`,children:$.pageItems.map(e=>{let t=e.contextWindow?`${(e.contextWindow/1e6).toFixed(0)}M ctx`:null;return(0,z.jsx)(`button`,{type:`button`,onClick:()=>Y(e.id),className:T(`w-full text-left rounded-xl border p-3 transition-all`,`hover:border-primary/40 hover:bg-primary/5`,J===e.id?`border-primary bg-primary/10 ring-1 ring-primary/30`:`border-border bg-card`),children:(0,z.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,z.jsx)(`span`,{className:`font-medium text-sm`,children:e.name}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 mt-1`,children:[t&&(0,z.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,children:t}),e.capabilities.slice(0,3).map(e=>(0,z.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-primary/10 text-primary border border-primary/20`,children:e},e))]})]}),J===e.id&&(0,z.jsx)(`div`,{className:`flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-primary`,children:(0,z.jsx)(a,{className:`h-3 w-3 text-primary-foreground`})})]})},e.id)})}):(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground py-8 text-center`,children:e(`setup:screen.errors.noModels`)}),(0,z.jsx)(N,{page:$.page,pageSize:$.pageSize,totalItems:$.totalItems,onPageChange:$.setPage,itemLabel:`models`})]}),K&&J&&(0,z.jsxs)(`div`,{className:`sticky bottom-0 -mx-4 border-t bg-background/80 px-4 py-4 backdrop-blur-sm sm:-mx-6 sm:px-6`,children:[(0,z.jsx)(`div`,{className:`mb-3 flex min-w-0 items-center justify-between gap-2 text-sm text-muted-foreground`,children:(0,z.jsxs)(`span`,{className:`min-w-0 truncate`,children:[K,` / `,J]})}),(0,z.jsxs)(A,{onClick:we,className:`w-full`,size:`lg`,children:[(0,z.jsx)(i,{className:`h-4 w-4 mr-2`}),e(`setup:screen.start.startSession`),(0,z.jsx)(v,{className:`h-4 w-4 ml-2`})]})]})]})})]})}export{V as SetupScreen};
@@ -1,3 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-BmsAdDhb.js","assets/rolldown-runtime-QTnfLwEv.js","assets/monaco-C7izDJhg.js","assets/monaco-Br_kD0ds.css","assets/markdown-L6DLSM7f.js","assets/vendor-BMdWcCR4.css"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Ar as t,Ct as n,Ei as r,Ft as ee,Oi as te,Ti as ne,Vn as i,Wi as a,Xr as re,_n as ie,aa as ae,ca as o,fn as oe,fr as se,ni as ce,ot as s,rn as le,tt as c,ua as l,wr as ue,zi as de}from"./vendor-BmsAdDhb.js";import"./i18n-c37VNlP9.js";import{n as fe}from"./ui-store-DxFtiYFb.js";import{s as u}from"./monaco-C7izDJhg.js";import{t as pe}from"./useWebSocket-kb2VPjLc.js";import{t as d}from"./utils-DvgvNCoT.js";import{s as me}from"./view-navigation-D8lN47bJ.js";import{a as he,n as ge,o as _e,t as ve}from"./dialog-BjPQYovj.js";import{d as f}from"./markdown-L6DLSM7f.js";import{s as p,t as m}from"./LazyMarkdown-DWlQpo_8.js";import{y as ye}from"./index-196U0qsu.js";import{t as be}from"./empty-state-DJc37Wg1.js";var h=e(l(),1),g=c(),xe=(0,h.lazy)(()=>u(()=>import(`./vendor-BmsAdDhb.js`).then(e=>e.S),__vite__mapDeps([0,1,2,3,4,5])));function _(e){return e===`project`||e===`user`}function Se(e){let t=e.match(/^(.+?)\/SKILL(?:\.save)?\.md$/);return t?t[1]:null}function Ce({source:e}){let{t}=ae(),n=e===`project`?`project`:e===`user`?`user`:`bundled`;return(0,g.jsx)(`span`,{className:d(`inline-flex items-center rounded-md border px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide`,n===`project`&&`border-success/25 bg-success/8 text-success`,n===`user`&&`border-primary/25 bg-primary/10 text-primary`,n===`bundled`&&`border-border/70 bg-muted/60 text-muted-foreground`),children:t(`activity:skillDetail.${{project:`scopeProject`,user:`scopeGlobal`,bundled:`scopeBundled`}[n]}`)})}function v({className:e}){let{t:c}=ae(),{client:l}=pe(),u=fe(e=>e.skillsState),v=fe(e=>e.setSkillsState),y=u.selectedSkill,b=u.navHistory,x=u.historyIndex,[S,C]=(0,h.useState)(null),[we,w]=(0,h.useState)(!1),[T,E]=(0,h.useState)(null),Te=ye(`skill-detail`,!!S),[D,O]=(0,h.useState)(!1),[k,A]=(0,h.useState)(``),[j,M]=(0,h.useState)(!1),[N,P]=(0,h.useState)(null),[F,I]=(0,h.useState)(!1),[L,R]=(0,h.useState)(null),[z,B]=(0,h.useState)(!1),V=(0,h.useRef)(``),[H,Ee]=(0,h.useState)(!1),[U,W]=(0,h.useState)(null),[De,Oe]=(0,h.useState)(!1),[G,K]=(0,h.useState)(null),[q,ke]=(0,h.useState)(!1),[Ae,je]=(0,h.useState)([]),J=(0,h.useRef)(u);J.current=u;let Y=(0,h.useRef)(!1),X=(0,h.useMemo)(()=>k?{lines:k.split(`
3
- `).length,words:k.trim()?k.trim().split(/\s+/).length:0,chars:k.length}:{lines:0,words:0,chars:0},[k]),Z=(0,h.useMemo)(()=>{if(!k)return null;let e=5*1024*1024,t=new Blob([k]).size;return t>=e?{level:`critical`,used:t,limit:e}:t>=4194304?{level:`warn`,used:t,limit:e}:null},[k]);(0,h.useEffect)(()=>{if(!L)return;let e=setTimeout(()=>R(null),2e3);return()=>clearTimeout(e)},[L]),(0,h.useEffect)(()=>{if(!D||!y)return;let e=setInterval(()=>{k&&k!==V.current&&(V.current=k,localStorage.setItem(`skills_draft_${y.name}`,JSON.stringify({content:k,savedAt:Date.now()})),R(Date.now()))},5e3);return()=>clearInterval(e)},[D,k,y]),(0,h.useEffect)(()=>{if(!y||!D)return;let e=localStorage.getItem(`skills_draft_${y.name}`);if(e)try{let{content:t}=JSON.parse(e);t&&t!==k&&t!==V.current&&(A(t),V.current=t,B(!0))}catch{}},[y?.name,D]),(0,h.useEffect)(()=>{if(!l||!y)return;w(!0),C(null),E(null);let e=setTimeout(()=>{w(!1),E(o.t(`activity:skillDetail.timeoutError`))},1e4),t=t=>{clearTimeout(e);let n=t;n.payload.error?E(n.payload.error):n.payload.name&&C(n.payload),w(!1)},n=e=>{let t=e;Ee(!1);let n=J.current;if(t.payload.success){let e={...n.knownRefs};for(let n of t.payload.updated??[])e[n.name]=n.newRef;v({...n,knownRefs:e,updateAvailableCount:0}),W({updated:t.payload.updated??[],unchanged:t.payload.unchanged??[],errors:t.payload.errors??[]}),l.send({type:`skills.list`},{echoToChat:!1})}else W({updated:[],unchanged:[],errors:[{name:``,error:t.payload.error??o.t(`activity:skillDetail.updateFailed`)}]})},r=e=>{let t=e;t.payload.skills&&je(t.payload.skills)};return l.on(`skills.content`,t),l.on(`skills.updated`,n),l.on(`skills.list`,r),l.send({type:`skills.content`,payload:{name:y.name,source:y.source}}),()=>{clearTimeout(e),l.off(`skills.content`,t),l.off(`skills.updated`,n),l.off(`skills.list`,r)}},[l,y?.name,y?.source]),(0,h.useEffect)(()=>{D&&(O(!1),A(``),P(null))},[y?.name]);let Q=(0,h.useCallback)(e=>Ae.find(t=>t.name.toLowerCase()===e.toLowerCase()),[Ae]),Me=(0,h.useCallback)(e=>{let t=Q(e);if(t){Y.current=!1;let e=b.slice(0,x+1);e.push(t),v({...J.current,selectedSkill:t,navHistory:e,historyIndex:e.length-1}),O(!1),A(``),W(null)}},[Q,b,x,v]),Ne=(0,h.useCallback)(()=>{if(x<=0)return;Y.current=!0;let e=x-1,t=b[e];v({...J.current,selectedSkill:t,historyIndex:e}),O(!1),A(``),W(null)},[x,b,v]),Pe=(0,h.useCallback)(()=>{if(x>=b.length-1)return;Y.current=!0;let e=x+1,t=b[e];v({...J.current,selectedSkill:t,historyIndex:e}),O(!1),A(``),W(null)},[x,b,v]),$=(0,h.useCallback)(()=>{me(`chat`)},[]),Fe=(0,h.useCallback)(()=>{S&&(A(S.body),V.current=S.body,B(!1),P(null),O(!0),I(!1))},[S]),Ie=(0,h.useCallback)(()=>{O(!1),A(``),P(null),I(!1),B(!1),y&&localStorage.removeItem(`skills_draft_${y.name}`)},[y]),Le=(0,h.useCallback)(()=>{!y||!S||(B(!1),A(S.body),V.current=S.body,y&&localStorage.removeItem(`skills_draft_${y.name}`))},[y,S]),Re=(0,h.useCallback)(()=>{if(!l||!y||!k.trim())return;M(!0),P(null);let e=t=>{let n=t;M(!1),n.payload.success?(V.current=``,localStorage.removeItem(`skills_draft_${y.name}`),B(!1),O(!1),l.send({type:`skills.content`,payload:{name:y.name,source:y.source}}),l.send({type:`skills.list`},{echoToChat:!1})):P(n.payload.error??o.t(`activity:skillDetail.saveFailed`)),l.off(`skills.edited`,e)};l.on(`skills.edited`,e),l.editSkill(y.name,k)},[l,y,k]),ze=(0,h.useCallback)(()=>{!l||!y||(Ee(!0),W(null),l.checkForUpdates(y.name,y.source===`user`))},[l,y]),Be=(0,h.useCallback)(()=>{y?.sourceUrl&&navigator.clipboard.writeText(y.sourceUrl).then(()=>{Oe(!0),setTimeout(()=>Oe(!1),2e3)})},[y]),Ve=(0,h.useCallback)(()=>{if(!S?.body)return;let e=new Blob([S.body],{type:`text/markdown`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`${S.name.replace(/\//g,`_`)}-SKILL.md`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)},[S]),He=(0,h.useCallback)(async e=>{if(!l||!e)return;ke(!0);let t=e=>{let n=e;ke(!1),n.payload.success?(K(null),l.send({type:`skills.list`},{echoToChat:!1}),$()):P(n.payload.error??o.t(`activity:skillDetail.uninstallFailed`)),l.off(`skills.uninstalled`,t)};l.on(`skills.uninstalled`,t),l.uninstallSkill(e.name,e.source===`user`)},[l,$]);return y?(0,g.jsxs)(`div`,{className:d(`flex h-full min-h-0 min-w-0 flex-col gap-3 overflow-hidden bg-[hsl(var(--surface-2)/0.45)] p-3`,e),children:[(0,g.jsxs)(`div`,{className:`shrink-0 rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,g.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-start lg:justify-between`,children:[(0,g.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,g.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,g.jsx)(`span`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,g.jsx)(ee,{className:`h-4 w-4`})}),(0,g.jsx)(`h1`,{className:`min-w-0 truncate text-base font-semibold`,children:y.name}),y.version&&(0,g.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`v`,y.version]}),(0,g.jsx)(Ce,{source:y.source})]}),(0,g.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1 line-clamp-2`,children:y.description||y.trigger}),y.sourceUrl&&(0,g.jsxs)(`div`,{className:`mt-2 flex min-w-0 items-center gap-1`,children:[(0,g.jsxs)(`a`,{href:`https://${y.sourceUrl.replace(`github:`,``)}`,target:`_blank`,rel:`noopener noreferrer`,className:`flex min-w-0 items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground`,title:c(`activity:skillDetail.openSourceRepo`),children:[(0,g.jsx)(se,{className:`h-3 w-3 shrink-0`}),(0,g.jsx)(`span`,{className:`truncate font-mono`,children:y.sourceUrl})]}),(0,g.jsx)(`button`,{type:`button`,onClick:Be,className:`flex shrink-0 items-center text-muted-foreground transition-colors hover:text-foreground`,title:c(`activity:skillDetail.copySourceUrl`),children:De?(0,g.jsx)(te,{className:`h-3 w-3 text-success`}):(0,g.jsx)(ce,{className:`h-3 w-3`})})]}),y.scope.length>0&&(0,g.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-2`,children:y.scope.map(e=>(0,g.jsx)(`span`,{className:`px-1.5 py-0.5 text-[10px] rounded bg-muted text-muted-foreground`,children:e},e))}),U&&(0,g.jsxs)(`div`,{className:`mt-2 text-xs space-y-1`,children:[U.updated.length>0&&(0,g.jsx)(`div`,{className:`text-success`,children:c(`activity:skillDetail.updatedLabel`,{list:U.updated.map(e=>`${e.name} (${e.oldRef} → ${e.newRef})`).join(`, `)})}),U.unchanged.length>0&&(0,g.jsx)(`div`,{className:`text-muted-foreground`,children:c(`activity:skillDetail.upToDateLabel`,{list:U.unchanged.join(`, `)})}),U.errors.length>0&&(0,g.jsx)(`div`,{className:`text-destructive`,children:c(`activity:skillDetail.errorsLabel`,{list:U.errors.map(e=>`${e.name?`${e.name}: `:``}${e.error}`).join(`; `)})})]})]}),(0,g.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 lg:ml-auto lg:shrink-0 lg:justify-end`,children:[_(y.source)&&y.sourceUrl&&(0,g.jsx)(`button`,{type:`button`,onClick:ze,disabled:H,className:`flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:opacity-50`,title:c(`activity:skillDetail.checkUpdatesTitle`),children:H?(0,g.jsx)(i,{className:`h-3.5 w-3.5 animate-spin`}):(0,g.jsx)(le,{className:`h-3.5 w-3.5`})}),y.source!==`bundled`&&!D&&(0,g.jsx)(`button`,{type:`button`,onClick:Ve,className:`flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,title:c(`activity:skillDetail.exportTitle`),children:(0,g.jsx)(re,{className:`h-3.5 w-3.5`})}),_(y.source)&&!D&&(0,g.jsx)(`button`,{type:`button`,onClick:Fe,className:`flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,title:c(`activity:skillDetail.editTitle`),children:(0,g.jsx)(oe,{className:`h-3.5 w-3.5`})}),_(y.source)&&(0,g.jsx)(`button`,{type:`button`,onClick:()=>K(y),className:`flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive`,title:c(`activity:skillDetail.uninstallTitle`),children:(0,g.jsx)(n,{className:`h-3.5 w-3.5`})}),(0,g.jsx)(`button`,{type:`button`,onClick:$,className:`flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground`,title:c(`activity:skillDetail.closeTitle`),children:(0,g.jsx)(s,{className:`h-4 w-4`})})]})]}),b.length>1&&(0,g.jsxs)(`div`,{className:`mt-3 flex min-w-0 items-center gap-1 rounded-lg border border-border/60 bg-muted/35 px-2 py-1`,children:[(0,g.jsx)(`button`,{type:`button`,onClick:Ne,disabled:x<=0,className:d(`rounded p-1 transition-colors`,x<=0?`text-muted-foreground/65 cursor-not-allowed`:`hover:bg-accent text-muted-foreground cursor-pointer`),title:c(`activity:skillDetail.backTitle`),children:(0,g.jsx)(r,{className:`h-4 w-4`})}),(0,g.jsx)(`button`,{type:`button`,onClick:Pe,disabled:x>=b.length-1,className:d(`rounded p-1 transition-colors`,x>=b.length-1?`text-muted-foreground/65 cursor-not-allowed`:`hover:bg-accent text-muted-foreground cursor-pointer`),title:c(`activity:skillDetail.forwardTitle`),children:(0,g.jsx)(ne,{className:`h-4 w-4`})}),(0,g.jsx)(`div`,{className:`flex items-center gap-0.5 overflow-x-auto text-xs`,children:b.map((e,t)=>(0,g.jsxs)(`span`,{className:`flex items-center shrink-0`,children:[t>0&&(0,g.jsx)(ne,{className:`h-3 w-3 text-muted-foreground/65 mx-0.5 shrink-0`}),(0,g.jsx)(`button`,{type:`button`,onClick:()=>{t<x&&(Y.current=!0,v({...J.current,selectedSkill:e,historyIndex:t}),O(!1),A(``),W(null))},className:d(`hover:text-primary cursor-pointer transition-colors`,t===x?`text-primary font-medium`:`text-muted-foreground`),children:e.name})]},e.name+t))})]})]}),S&&(S.relatedFiles.length>0||S.references.length>0)&&(0,g.jsxs)(`div`,{className:`shrink-0 space-y-2 rounded-xl border border-border/70 bg-card/70 px-4 py-3 shadow-sm`,children:[S.relatedFiles.length>0&&(0,g.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground`,children:[(0,g.jsx)(ue,{className:`h-3 w-3`}),(0,g.jsx)(`span`,{className:`font-medium uppercase tracking-wide`,children:c(`activity:skillDetail.relatedFiles`)})]}),S.relatedFiles.map(e=>{let t=Se(e);return t&&Q(t)?(0,g.jsxs)(`button`,{type:`button`,onClick:()=>Me(t),className:`inline-flex min-w-0 items-center gap-1 rounded-md border border-border/70 bg-background/60 px-1.5 py-0.5 text-[10px] transition-colors hover:border-primary/40 hover:text-primary`,title:c(`activity:skillDetail.goToSkillTitle`,{name:t}),children:[(0,g.jsx)(a,{className:`h-2.5 w-2.5`}),e]},e):(0,g.jsx)(`span`,{className:`rounded-md border border-border/70 bg-background/60 px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:e},e)})]}),S.references.length>0&&(0,g.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground`,children:[(0,g.jsx)(t,{className:`h-3 w-3`}),(0,g.jsx)(`span`,{className:`font-medium uppercase tracking-wide`,children:c(`activity:skillDetail.references`)})]}),S.references.map(e=>{let t=Se(e)??e.replace(/\.md$/,``);return Q(t)?(0,g.jsxs)(`button`,{type:`button`,onClick:()=>Me(t),className:`inline-flex min-w-0 items-center gap-1 rounded-md border border-primary/20 bg-primary/5 px-1.5 py-0.5 text-[10px] text-primary transition-colors hover:border-primary/30 hover:bg-primary/10`,title:c(`activity:skillDetail.goToSkillTitle`,{name:t}),children:[(0,g.jsx)(a,{className:`h-2.5 w-2.5`}),t]},e):(0,g.jsx)(`span`,{className:`rounded-md bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:t},e)})]})]}),(0,g.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-hidden rounded-xl border border-border/70 bg-card/70 shadow-sm`,children:we?(0,g.jsxs)(`div`,{className:`flex h-full min-h-[16rem] flex-col items-center justify-center p-8 text-center text-muted-foreground`,children:[(0,g.jsx)(i,{className:`mx-auto mb-2 h-6 w-6 animate-spin text-primary`}),(0,g.jsx)(`p`,{children:c(`activity:skillDetail.loadingContent`)})]}):D?(0,g.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,g.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2 border-b border-border/70 bg-muted/30 px-4 py-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,g.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,g.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:c(`activity:skillDetail.editingLabel`,{name:y.name})}),(0,g.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:c(`activity:skillDetail.editStats`,{lines:X.lines,words:X.words,chars:X.chars})}),Z&&(0,g.jsx)(`span`,{className:`text-xs tabular-nums ${Z.level===`critical`?`font-medium text-destructive`:`text-warning`}`,children:c(`activity:skillDetail.charsWarningFmt`,{used:(Z.used/(1024*1024)).toFixed(1),limit:(Z.limit/(1024*1024)).toFixed(0)})}),L&&(0,g.jsx)(`span`,{className:`text-xs text-success animate-pulse`,children:c(`activity:skillDetail.draftSaved`)}),z&&(0,g.jsx)(`span`,{className:`animate-pulse text-xs text-warning`,children:c(`activity:skillDetail.draftRestored`)})]}),(0,g.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[N&&(0,g.jsx)(`span`,{className:`text-xs text-destructive`,children:N}),z&&(0,g.jsx)(`button`,{type:`button`,onClick:Le,className:`rounded-md border border-warning/35 px-2 py-1 text-[10px] text-warning transition-colors hover:bg-warning/10`,children:c(`activity:skillDetail.discardDraft`)}),(0,g.jsx)(`button`,{type:`button`,onClick:Ie,className:`rounded-md border border-border/70 px-2 py-1 text-xs transition-colors hover:bg-accent`,children:c(`common:action.cancel`)}),(0,g.jsx)(`button`,{type:`button`,onClick:()=>I(e=>!e),title:c(F?`activity:skillDetail.hidePreviewTitle`:`activity:skillDetail.splitViewTitle`),className:`rounded-md border px-2 py-1 text-xs transition-colors ${F?`border-primary/40 bg-primary/10 text-primary`:`border-border/70 text-muted-foreground hover:bg-accent`}`,children:(0,g.jsx)(ie,{className:`h-3 w-3 inline`})}),(0,g.jsx)(`button`,{type:`button`,onClick:Re,disabled:j||!k.trim(),className:`rounded-md bg-primary px-3 py-1 text-xs text-primary-foreground shadow-sm shadow-primary/15 transition-colors hover:bg-primary/90 disabled:opacity-50`,children:j?(0,g.jsx)(i,{className:`h-3 w-3 animate-spin inline`}):c(`common:action.save`)})]})]}),F?(0,g.jsxs)(`div`,{className:`flex flex-1 min-h-0 gap-0.5`,children:[(0,g.jsx)(`div`,{className:`flex-1 min-w-0 flex flex-col min-h-0`,children:(0,g.jsx)(h.Suspense,{fallback:null,children:(0,g.jsx)(xe,{value:k,onChange:e=>A(e.target.value??``),language:`markdown`,className:`flex-1`,style:{fontSize:12,backgroundColor:`transparent`,minHeight:0},placeholder:c(`activity:skillDetail.contentPlaceholder`)})})}),(0,g.jsx)(`div`,{className:`w-px bg-border flex-shrink-0`}),(0,g.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain bg-background/45 p-4 prose prose-sm dark:prose-invert max-w-none`,children:(0,g.jsx)(m,{rehypePlugins:[f],components:p,children:k})})]}):(0,g.jsx)(h.Suspense,{fallback:null,children:(0,g.jsx)(xe,{value:k,onChange:e=>A(e.target.value??``),language:`markdown`,className:`flex-1`,style:{fontSize:12,backgroundColor:`transparent`,minHeight:0},placeholder:c(`activity:skillDetail.contentPlaceholder`)})})]}):S?(0,g.jsx)(`div`,{ref:Te,className:`h-full min-h-0 overflow-y-auto overscroll-contain p-5 sm:p-6 prose prose-sm dark:prose-invert max-w-none`,children:(0,g.jsx)(m,{rehypePlugins:[f],components:p,children:S.body})}):T?(0,g.jsxs)(`div`,{className:`flex h-full min-h-[16rem] flex-col items-center justify-center p-8 text-center`,children:[(0,g.jsx)(`p`,{className:`text-destructive mb-2`,children:c(`activity:skillDetail.loadFailed`)}),(0,g.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:T}),(0,g.jsx)(`button`,{type:`button`,onClick:()=>{l&&y&&(w(!0),E(null),l.send({type:`skills.content`,payload:{name:y.name,source:y.source}}))},className:`mt-4 rounded-md border border-border/70 px-3 py-1.5 text-xs transition-colors hover:bg-accent`,children:c(`common:action.retry`)})]}):(0,g.jsx)(`div`,{className:`flex h-full min-h-[16rem] items-center justify-center p-8 text-center text-muted-foreground`,children:c(`activity:skillDetail.noContent`)})}),(0,g.jsx)(ve,{open:!!G,onOpenChange:e=>{e||K(null)},children:(0,g.jsxs)(ge,{className:`flex max-h-[calc(100dvh-2rem)] w-[380px] max-w-[90vw] flex-col gap-0 overflow-hidden p-0`,showCloseButton:!1,children:[(0,g.jsxs)(he,{className:`flex shrink-0 items-center justify-between border-b border-border/70 p-4 sm:flex-row sm:justify-between sm:space-y-0`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,g.jsx)(n,{className:`h-4 w-4 text-destructive`}),(0,g.jsx)(_e,{className:`font-semibold text-sm`,children:c(`activity:skillDetail.uninstallSkillHeading`)})]}),(0,g.jsx)(`button`,{type:`button`,onClick:()=>K(null),"aria-label":c(`common:action.close`),className:`rounded p-1 text-muted-foreground hover:bg-accent hover:text-accent-foreground`,children:(0,g.jsx)(s,{className:`h-4 w-4`})})]}),(0,g.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto overscroll-contain p-4`,children:[(0,g.jsx)(`p`,{className:`text-sm`,children:G&&c(`activity:skillDetail.uninstallConfirm`,{name:G.name})}),(0,g.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:G&&c(`activity:skillDetail.uninstallRemovePath`,{path:G.path})})]}),(0,g.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-border/70 bg-muted/20 p-4`,children:[(0,g.jsx)(`button`,{type:`button`,onClick:()=>K(null),disabled:q,className:`rounded-md border border-border/70 px-3 py-1.5 text-xs transition-colors hover:bg-accent disabled:opacity-50`,children:c(`common:action.cancel`)}),(0,g.jsxs)(`button`,{type:`button`,onClick:()=>G&&He(G),disabled:q,className:`flex items-center gap-1.5 rounded-md bg-destructive px-3 py-1.5 text-xs text-destructive-foreground transition-colors hover:bg-destructive/90 disabled:cursor-not-allowed disabled:opacity-50`,children:[q&&(0,g.jsx)(i,{className:`h-3 w-3 animate-spin`}),c(`activity:skillDetail.uninstallAction`)]})]})]})})]}):(0,g.jsx)(be,{icon:(0,g.jsx)(de,{className:`h-6 w-6`}),title:c(`activity:skillDetail.noSkillSelected`),description:c(`activity:skillDetail.selectSkillHint`),action:{label:c(`activity:skillDetail.goToChat`),onClick:$},className:e})}export{v as SkillDetailView};