@wrongstack/webui 0.306.4 → 0.307.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.
- package/dist/assets/AgentRosterView-Bb5m_XjZ.js +9 -0
- package/dist/assets/AnalyticsDashboard-lqPCAo9u.js +1 -0
- package/dist/assets/AudienceMemoryPanel-putWTq5V.js +3 -0
- package/dist/assets/{ChangesView-DplR2Twb.js → ChangesView-Cw-qvOLA.js} +1 -1
- package/dist/assets/ChronicleDashboard-DQdMkTLQ.js +1 -0
- package/dist/assets/CodeEditor-BAv2f4se.js +2 -0
- package/dist/assets/CodeMap-BB1WETLd.js +1 -0
- package/dist/assets/ConfirmModal-LBZaZgsG.js +1 -0
- package/dist/assets/CronJobsPanel-DE5CVuSW.js +1 -0
- package/dist/assets/{DeadCodeScanPanel-Dp6vW6pV.js → DeadCodeScanPanel-nlQ9nL3Y.js} +1 -1
- package/dist/assets/{DebugDashboard-d4ETqxOe.js → DebugDashboard-CgRH9SvC.js} +1 -1
- package/dist/assets/{DesignGalleryView-3jRTmgzx.js → DesignGalleryView-Uwo3JXyu.js} +1 -1
- package/dist/assets/GoalView-Cc4B-0Qd.js +1 -0
- package/dist/assets/KanbanView-CK4bvZfi.js +3 -0
- package/dist/assets/MailboxDetailView-CGwtSBcH.js +1 -0
- package/dist/assets/{MemoryDrawer-DIrEAQNI.js → MemoryDrawer-Cw1IiFCO.js} +1 -1
- package/dist/assets/MemoryManager-l0R8JBzL.js +1 -0
- package/dist/assets/{ModelPicker-OSfUtS6_.js → ModelPicker-DC-XCx0f.js} +1 -1
- package/dist/assets/OfficeMapPanel-CUI0PJBI.js +4 -0
- package/dist/assets/{ProcessMonitor-SLnEEbRY.js → ProcessMonitor-DLD6PrVx.js} +1 -1
- package/dist/assets/PromptJournalView-Cf1szLLw.js +1 -0
- package/dist/assets/{QueuePanel-BszNSrlq.js → QueuePanel-O7IsaKUs.js} +1 -1
- package/dist/assets/{RefreshDebugView-DA6cPIhw.js → RefreshDebugView-CuKbgI-T.js} +1 -1
- package/dist/assets/RequirementIntakeView-Bg8ZoV7J.js +1 -0
- package/dist/assets/{SageTabs-BR09lBUK.js → SageTabs-Bk8VDMmR.js} +2 -2
- package/dist/assets/SddFlowGraph-DdYgCVM_.js +1 -0
- package/dist/assets/SddHub-tQztZlHf.js +2 -0
- package/dist/assets/{SessionInspectView-Bf3X0qK8.js → SessionInspectView-BnoD3YER.js} +1 -1
- package/dist/assets/SessionList-BRbF7FVS.js +1 -0
- package/dist/assets/{SessionsDashboard-CwuOKWQc.js → SessionsDashboard-7heYIhHQ.js} +1 -1
- package/dist/assets/SetupScreen-CQW-6bhj.js +1 -0
- package/dist/assets/SkillDetailView-DdxB0JI4.js +3 -0
- package/dist/assets/{SpecsView-Do8eQuTN.js → SpecsView-BAnFfPPH.js} +1 -1
- package/dist/assets/TechStackView-DJeNOZE9.js +2 -0
- package/dist/assets/{TerminalPanel-Pq97A882.js → TerminalPanel-v3SC9LTq.js} +1 -1
- package/dist/assets/Toaster-wXvKXbbS.js +1 -0
- package/dist/assets/{activity-Dr_u3dOm.js → activity-C0qPnCbW.js} +2 -2
- package/dist/assets/{activity-Dzgvt4Nh.js → activity-DTSVEiLK.js} +2 -2
- package/dist/assets/{activity-L2_b8Uan.js → activity-DWHlYL9x.js} +2 -2
- package/dist/assets/{activity-gB90peLu.js → activity-DjnYvN9C.js} +2 -2
- package/dist/assets/{activity-Dg9Q9kwt.js → activity-fdbTRXeg.js} +3 -3
- package/dist/assets/{activity-BI4XyF_x.js → activity-jL8-j1D0.js} +2 -2
- package/dist/assets/{activity-IttuV5ar.js → activity-phJuGuf4.js} +2 -2
- package/dist/assets/{button-DvHe5h9X.js → button-DvpRpKkt.js} +1 -1
- package/dist/assets/{chat-CdiY7G6Z.js → chat-CzaGXz_W.js} +1 -1
- package/dist/assets/chat-store-c0pGYczr.js +17 -0
- package/dist/assets/codemap-activity-store-BH7Mh4k9.js +1 -0
- package/dist/assets/codemap-index-store-BFm1TzVW.js +1 -0
- package/dist/assets/{commandPalette-DpaemFux.js → commandPalette-BovBiPec.js} +1 -1
- package/dist/assets/common-BBHmIHQW.js +1 -0
- package/dist/assets/common-C3PzxyXg.js +1 -0
- package/dist/assets/common-CUWL8eNX.js +1 -0
- package/dist/assets/common-CvSB5NM3.js +1 -0
- package/dist/assets/common-DT2FL9xN.js +1 -0
- package/dist/assets/common-DuR5FTPN.js +1 -0
- package/dist/assets/common-xPePelft.js +1 -0
- package/dist/assets/{css.worker-B1A7g9RU.js → css.worker-DRH2OcAG.js} +14 -14
- package/dist/assets/{dialog-jbs7gu-q.js → dialog-BJjDUqb3.js} +1 -1
- package/dist/assets/{empty-state-D-ojp6Gp.js → empty-state-Cefmzojx.js} +1 -1
- package/dist/assets/{html.worker-NdFMIQdB.js → html.worker-DQLddT9h.js} +17 -17
- package/dist/assets/i18n-CDoHRskt.js +2 -0
- package/dist/assets/index-BRJ_UrGk.js +133 -0
- package/dist/assets/index-BRs425Ir.css +1 -0
- package/dist/assets/{input-oJ0Gehqp.js → input-BtoHcCl9.js} +1 -1
- package/dist/assets/json.worker-D_Dqrls5.js +62 -0
- package/dist/assets/mailbox-store-bF96Ih2G.js +1 -0
- package/dist/assets/markdown-CIRD7kOg.js +44 -0
- package/dist/assets/monaco-BCqJp2xW.js +1236 -0
- package/dist/assets/{monaco-theme-DSeCDzQy.js → monaco-theme-CR1QvFi2.js} +1 -1
- package/dist/assets/{rolldown-runtime-QTnfLwEv.js → rolldown-runtime-hePW80VL.js} +1 -1
- package/dist/assets/{roster-ws-DobwmzEj.js → roster-ws-CK52jAnG.js} +1 -1
- package/dist/assets/session-store-BgiP4PnQ.js +1 -0
- package/dist/assets/{settings-t7_uBgp_.js → settings-CbtB0i7o.js} +1 -1
- package/dist/assets/{setup-BFcmn89w.js → setup-DfcCCvUO.js} +1 -1
- package/dist/assets/{shared-CiaNczO0.js → shared-B3czc2Dj.js} +1 -1
- package/dist/assets/stores-DSGsI875.js +7 -0
- package/dist/assets/{toasts-BL_8kH4B.js → toasts-DOfXc7Rt.js} +1 -1
- package/dist/assets/{ts.worker-XonqDHUu.js → ts.worker-DkYoA6bF.js} +45 -45
- package/dist/assets/ui-store-xx1NssJI.js +1 -0
- package/dist/assets/useWebSocket-BFFntyS4.js +29 -0
- package/dist/assets/utils-tsZEnrBH.js +1 -0
- package/dist/assets/vendor-C_zEzV4N.js +139 -0
- package/dist/assets/{view-navigation-D-afwlSZ.js → view-navigation-CZKugncK.js} +1 -1
- package/dist/assets/ws-client-B3MVz75-.js +1 -0
- package/dist/assets/xterm-BWzBEEhg.js +18 -0
- package/dist/components/ChatInput/composer-button-bar.d.ts +24 -0
- package/dist/components/ChatInput/next-steps-helpers.d.ts +19 -0
- package/dist/components/ChatInput/use-chat-input-mcp.d.ts +8 -0
- package/dist/components/ChatInput/use-refine-timeout.d.ts +9 -0
- package/dist/components/ChatView/ChatDisplayToggles.d.ts +18 -0
- package/dist/components/ChatView/ChatHeader.d.ts +60 -0
- package/dist/components/ChatView/ChatRowView.d.ts +9 -0
- package/dist/components/ChatView/ToggleSwitch.d.ts +6 -0
- package/dist/components/ChatView/useChatViewState.d.ts +80 -0
- package/dist/components/ContextBar.d.ts +15 -2
- package/dist/components/FileExplorer/FileExplorerModals.d.ts +44 -0
- package/dist/components/FileExplorer/TreeRow.d.ts +23 -0
- package/dist/components/FileExplorer/tree-helpers.d.ts +16 -0
- package/dist/components/FileExplorer/types.d.ts +19 -0
- package/dist/components/MemoryManager/MemoryDrawerToolbar.d.ts +8 -0
- package/dist/components/MemoryManager/MemoryManagerHeader.d.ts +7 -0
- package/dist/components/MemoryManager/MemoryManagerStatsBar.d.ts +8 -0
- package/dist/components/MemoryManager/useMemoryManagerState.d.ts +85 -0
- package/dist/components/PromptJournalView.d.ts +2 -0
- package/dist/components/SddWizard.d.ts +0 -6
- package/dist/components/SettingsPanel/AgentSettingsTab.d.ts +5 -0
- package/dist/components/SettingsPanel/ContextSettingsTab.d.ts +4 -0
- package/dist/components/SettingsPanel/ExecutionSettingsTab.d.ts +6 -0
- package/dist/components/SettingsPanel/LogsSettingsTab.d.ts +4 -0
- package/dist/components/TechStackView/shared.d.ts +1 -0
- package/dist/components/self-learning/SelfLearningAgentList.d.ts +9 -0
- package/dist/components/self-learning/SelfLearningDetail.d.ts +39 -0
- package/dist/components/self-learning/types.d.ts +30 -0
- package/dist/components/self-learning/use-self-learning-state.d.ts +46 -0
- package/dist/hooks/ws-handlers/files-mailbox-handlers.d.ts +19 -0
- package/dist/hooks/ws-handlers/session-context-handlers.d.ts +18 -0
- package/dist/hooks/ws-handlers/session-execution-handlers.d.ts +24 -0
- package/dist/hooks/ws-handlers/session-handlers.d.ts +3 -36
- package/dist/hooks/ws-handlers/session-replay-handlers.d.ts +22 -0
- package/dist/index.html +31 -31
- package/dist/index.js +18021 -15149
- package/dist/lib/view-navigation.d.ts +1 -1
- package/dist/lib/ws-client-domain-methods.d.ts +86 -0
- package/dist/lib/ws-client.d.ts +2 -83
- package/dist/stores/chat-queue-helpers.d.ts +9 -0
- package/dist/stores/chat-retention.d.ts +14 -0
- package/dist/stores/chat-store-types.d.ts +106 -0
- package/dist/stores/chat-store.d.ts +6 -183
- package/dist/stores/file-store.d.ts +72 -3
- package/dist/stores/session-store.d.ts +20 -0
- package/dist/stores/ui-store.d.ts +3 -3
- package/dist/types/client-message.d.ts +51 -0
- package/dist/types/protocol-core.d.ts +2 -0
- package/dist/types/runtime.d.ts +1 -0
- package/dist/types/server-message.d.ts +76 -0
- package/package.json +20 -20
- package/dist/assets/AgentRosterView-X4NWBm16.js +0 -9
- package/dist/assets/AnalyticsDashboard-CvEY3lEY.js +0 -1
- package/dist/assets/AudienceMemoryPanel-ChhQVsbD.js +0 -3
- package/dist/assets/ChronicleDashboard-BpykJceZ.js +0 -1
- package/dist/assets/CodeEditor-DQDKQlAo.js +0 -1
- package/dist/assets/CodeMap-CnlnHM8P.js +0 -1
- package/dist/assets/ConfirmModal-BD6pUkAB.js +0 -1
- package/dist/assets/CronJobsPanel-Dp9xc7vb.js +0 -1
- package/dist/assets/GoalView-CoMRM0Vo.js +0 -1
- package/dist/assets/KanbanView-BMHq13vg.js +0 -3
- package/dist/assets/MailboxDetailView-C0n5fMGN.js +0 -1
- package/dist/assets/MemoryManager-CEfDQuV9.js +0 -1
- package/dist/assets/OfficeMapPanel-TIRw1a9O.js +0 -4
- package/dist/assets/RequirementIntakeView-CN7Yympd.js +0 -1
- package/dist/assets/SddFlowGraph-B-5J7zOV.js +0 -1
- package/dist/assets/SddHub-CkjrCykN.js +0 -2
- package/dist/assets/SessionList-cAmzxd3Z.js +0 -1
- package/dist/assets/SetupScreen-DZUvrhr0.js +0 -1
- package/dist/assets/SkillDetailView-CULufBnT.js +0 -3
- package/dist/assets/TechStackView-B2v5LoJp.js +0 -1
- package/dist/assets/Toaster-Dic3369l.js +0 -1
- package/dist/assets/chat-store-BgCgMMd0.js +0 -17
- package/dist/assets/codemap-activity-store-DBdfN0ix.js +0 -1
- package/dist/assets/codemap-index-store-45CkVCxN.js +0 -1
- package/dist/assets/common-BXJbu5Y-.js +0 -1
- package/dist/assets/common-BiNu_WzQ.js +0 -1
- package/dist/assets/common-COVxQ0FV.js +0 -1
- package/dist/assets/common-Ch7JihXD.js +0 -1
- package/dist/assets/common-DPaTeTls.js +0 -1
- package/dist/assets/common-DdGpRh8j.js +0 -1
- package/dist/assets/common-pI6fYZW3.js +0 -1
- package/dist/assets/i18n-nlW2iAya.js +0 -2
- package/dist/assets/index-eK0iH6jY.js +0 -133
- package/dist/assets/index-mNf-KFcC.css +0 -1
- package/dist/assets/json.worker-Ax0gao5O.js +0 -62
- package/dist/assets/mailbox-store-BuLRsYu3.js +0 -1
- package/dist/assets/markdown-sSmz-Ua_.js +0 -44
- package/dist/assets/monaco-BLUV5g0U.js +0 -1236
- package/dist/assets/session-store-DkPaOIhe.js +0 -1
- package/dist/assets/stores-BpVw7ENx.js +0 -7
- package/dist/assets/ui-store-FVcXVdRC.js +0 -1
- package/dist/assets/useWebSocket-Dh-clEvj.js +0 -29
- package/dist/assets/utils-D1fGupR8.js +0 -1
- package/dist/assets/vendor-AeHpGMaG.js +0 -139
- package/dist/assets/ws-client-B7j8isQb.js +0 -1
- package/dist/assets/xterm-DUBp1lnG.js +0 -35
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Bn as t,Br as n,Ca as r,Ft as i,Gi as a,Ia as o,Mn as s,Ni as c,Nn as l,Oa as u,On as d,Ot as f,Pr as p,Qi as m,Va as h,Vt as g,Wt as _,Zt as v,_ as y,a as b,an as x,ar as S,ca as C,dt as w,ea as ee,f as te,fr as T,i as ne,jt as E,lt as D,ma as O,n as k,pi as A,r as j,s as re,si as ie,ta as ae,un as oe,vn as M,wn as se,yi as ce}from"./vendor-AeHpGMaG.js";import"./i18n-nlW2iAya.js";import{t as le}from"./useWebSocket-Dh-clEvj.js";import{t as N}from"./utils-D1fGupR8.js";import{I as ue}from"./stores-BpVw7ENx.js";import{n as de}from"./ui-store-FVcXVdRC.js";import{a as fe,i as pe,n as me,o as he,r as ge,t as P}from"./dialog-jbs7gu-q.js";import{t as F}from"./button-DvHe5h9X.js";import{t as I}from"./input-oJ0Gehqp.js";import{c as _e}from"./index-eK0iH6jY.js";import{t as L}from"./roster-ws-DobwmzEj.js";import{_ as ve,a as R,b as ye,c as be,d as xe,f as Se,g as z,h as B,i as V,l as Ce,m as H,n as U,o as we,p as Te,r as Ee,s as De,t as W,u as Oe,v as ke,y as G}from"./shared-CiaNczO0.js";import{t as Ae}from"./MemoryDrawer-DIrEAQNI.js";var K=e(h(),1),q=D();function je({busyAction:e,deletingId:t,memories:n,onCancel:r,onConfirm:i,onOpenChange:a}){let{t:s}=o();return(0,q.jsx)(P,{open:!!t,onOpenChange:a,children:(0,q.jsxs)(me,{className:`max-w-md`,children:[(0,q.jsxs)(fe,{children:[(0,q.jsx)(`span`,{className:`mb-2 flex size-10 items-center justify-center border border-destructive/35 bg-destructive/10 text-destructive`,children:(0,q.jsx)(E,{className:`size-4`})}),(0,q.jsx)(he,{children:s(`activity:memoryManager.deleteTitle`)}),(0,q.jsx)(ge,{className:`leading-6`,children:s(`activity:deleteMemoryDialog.sageWillMarkTheRecordDeleted`)})]}),(0,q.jsx)(`div`,{className:`border border-border/70 bg-background/45 p-3 text-xs text-muted-foreground`,children:z(n.find(e=>e.id===t)?.text??``,180)}),(0,q.jsxs)(pe,{children:[(0,q.jsx)(F,{variant:`outline`,onClick:r,disabled:e===`delete`,children:s(`common:action.cancel`)}),(0,q.jsxs)(F,{variant:`destructive`,onClick:i,disabled:e===`delete`,children:[e===`delete`?(0,q.jsx)(S,{className:`size-4 animate-spin`}):(0,q.jsx)(E,{className:`size-4`}),s(e===`delete`?`activity:memoryManager.deletingLabel`:`activity:memoryManager.actionDeleteMemory`)]})]})]})})}var Me=212,Ne=188;function Pe(e){return e.length>14?`${e.slice(0,11)}…`:e}function Fe(e,t=58){let n=e.replace(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t-1)}…`:n}function Ie(e){return e.type===`symbol`?[e.path,e.symbol?`#${e.symbol}`:``].filter(Boolean).join(``):e.path??e.command??e.symbol??e.role??e.type}function Le(e){return e===`active`?`border-success/45 bg-success/10 text-success`:e===`stale`?`border-warning/45 bg-warning/10 text-warning`:e===`contradicted`?`border-destructive/45 bg-destructive/10 text-destructive`:e===`superseded`?`border-warning/35 bg-warning/5 text-warning`:`border-border bg-muted/55 text-muted-foreground`}function Re({data:e}){let{entry:t,center:n}=e;return(0,q.jsxs)(`div`,{className:n?`border border-primary/70 bg-card px-3 py-2.5 text-card-foreground shadow-[0_0_0_1px_hsl(var(--primary)/0.2),0_0_24px_hsl(var(--primary)/0.12)]`:`border border-border/80 bg-card/95 px-3 py-2.5 text-card-foreground shadow-lg`,style:{width:Me},title:t.text,children:[(0,q.jsx)(re,{type:`target`,position:y.Top,className:`!border-background !bg-muted-foreground`}),(0,q.jsx)(re,{type:`source`,position:y.Bottom,className:`!border-background !bg-primary`}),(0,q.jsx)(re,{type:`source`,position:y.Right,className:`!border-background !bg-primary`}),(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`border px-1.5 py-0.5 text-[9px] font-bold uppercase ${Le(t.status)}`,children:t.status}),(0,q.jsx)(`span`,{className:`ml-auto truncate font-mono text-[9px] text-muted-foreground`,children:Pe(t.id)})]}),(0,q.jsx)(`p`,{className:`mt-2 line-clamp-2 text-[11px] leading-4 text-foreground/90`,children:Fe(t.text)}),(0,q.jsx)(`p`,{className:`mt-1 font-mono text-[9px] uppercase text-muted-foreground`,children:t.kind})]})}function ze({data:e}){return(0,q.jsxs)(`div`,{className:`border border-info/40 bg-info/8 px-2.5 py-2 text-card-foreground shadow-lg`,style:{width:Ne},title:e.label,children:[(0,q.jsx)(re,{type:`target`,position:y.Left,className:`!border-background !bg-info`}),(0,q.jsx)(`p`,{className:`font-mono text-[9px] font-bold uppercase text-info`,children:e.anchor.type}),(0,q.jsx)(`p`,{className:`mt-1 truncate font-mono text-[10px] text-foreground/85`,children:e.label})]})}var Be={memoryNode:Re,anchorNode:ze};function Ve(e,t){return{id:e,revision:0,scope:`project`,kind:`fact`,status:`deleted`,text:t(`activity:memoryManager.memoryUnavailable`),importance:0,confidence:0,freshness:0,tags:[],anchors:[],createdAt:``,updatedAt:``}}function He({nodes:e,edges:t,className:n}){return(0,q.jsx)(`div`,{className:N(`w-full`,n),children:(0,q.jsxs)(te,{nodes:e,edges:t,nodeTypes:Be,fitView:!0,fitViewOptions:{padding:.24,maxZoom:1.05},minZoom:.4,maxZoom:1.5,nodesConnectable:!1,elementsSelectable:!1,panOnScroll:!1,zoomOnScroll:!1,proOptions:{hideAttribution:!0},children:[(0,q.jsx)(j,{variant:ne.Dots,gap:18,size:1,color:`hsl(var(--muted-foreground) / 0.18)`}),(0,q.jsx)(b,{showInteractive:!1,className:`!border-border !bg-card !shadow-lg`})]})})}function Ue({centerMemory:e,allMemories:t,graphEdges:n,loading:r=!1,error:i=null}){let{t:a}=o(),[s,c]=(0,K.useState)(!1),l=`mem:${e.id}`,u=(0,K.useMemo)(()=>n.filter(e=>e.from===l&&e.to.startsWith(`mem:`)||e.to===l&&e.from.startsWith(`mem:`)).slice(0,24),[l,n]),{nodes:d,edges:f}=(0,K.useMemo)(()=>{let n=[],r=[],i=new Map(t.map(e=>[e.id,e]));n.push({id:e.id,type:`memoryNode`,position:{x:320-Me/2,y:120},data:{entry:e,center:!0}});let o=[...e.supersededBy?[{id:e.supersededBy,relation:`superseded by`}]:[],...(e.supersedes??[]).map(e=>({id:e,relation:`supersedes`})),...(e.contradicts??[]).map(e=>({id:e,relation:`contradicts`}))];for(let e of u){let t=(e.from===l?e.to:e.from).slice(4);o.some(n=>n.id===t&&n.relation===e.relation)||o.push({id:t,relation:e.relation,weight:e.weight,evidence:e.evidence})}let s=320-(o.length-1)*220/2;return o.forEach((t,o)=>{let c=i.get(t.id)??Ve(t.id,a),l=t.relation===`superseded by`,u=l?0:280+Math.floor(o/3)*130,d=l?320-Me/2:s+o*220-Me/2;n.push({id:`memory:${t.id}:${o}`,type:`memoryNode`,position:{x:d,y:u},data:{entry:c,center:!1}});let f=t.relation===`contradicts`,p=l?`memory:${t.id}:${o}`:e.id,m=l?e.id:`memory:${t.id}:${o}`;r.push({id:`relation:${t.relation}:${t.id}:${o}`,source:p,target:m,type:`smoothstep`,animated:!f,label:t.weight===void 0?t.relation:`${t.relation} ${t.weight.toFixed(2)}`,data:{evidence:t.evidence??[]},style:{stroke:f?`hsl(var(--destructive))`:`hsl(var(--primary))`,strokeWidth:1.7,...f?{strokeDasharray:`5 4`}:{}},labelStyle:{fill:f?`hsl(var(--destructive))`:`hsl(var(--muted-foreground))`,fontSize:9,fontWeight:700},labelBgStyle:{fill:`hsl(var(--card))`,fillOpacity:.9}})}),e.anchors.forEach((t,i)=>{let a=`anchor:${i}`;n.push({id:a,type:`anchorNode`,position:{x:540,y:120+(i-(e.anchors.length-1)/2)*66},data:{anchor:t,label:Ie(t)}}),r.push({id:`anchor-edge:${i}`,source:e.id,target:a,type:`smoothstep`,style:{stroke:`hsl(var(--info))`,strokeWidth:1.3}})}),{nodes:n,edges:r}},[t,e,l,u]);return d.length<=1&&!r&&!i?null:(0,q.jsxs)(`section`,{className:`overflow-hidden border border-border/75 bg-background/35`,"aria-label":a(`activity:memoryManager.graphAria`),children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/70 bg-card/55 px-3 py-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-muted-foreground`,children:a(`activity:memoryManager.graphHeading`)}),d.length>1&&(0,q.jsxs)(F,{variant:`ghost`,size:`sm`,onClick:()=>c(!0),className:`h-6 gap-1 px-2 text-[9px] font-bold uppercase tracking-[0.12em]`,"aria-label":a(`activity:memoryManager.graphFullscreenAria`),children:[(0,q.jsx)(A,{className:`size-3`}),a(`activity:memoryManager.graphOpenFullscreen`)]})]}),(0,q.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:r?a(`activity:memoryManager.loadingGraph`):a(`activity:memoryManager.graphStats`,{nodes:d.length,edges:f.length})})]}),i&&(0,q.jsx)(`p`,{className:`border-b border-destructive/25 bg-destructive/5 px-3 py-2 text-[10px] text-destructive`,children:i}),d.length>1&&(0,q.jsx)(He,{nodes:d,edges:f,className:`h-[320px]`}),u.some(e=>e.evidence?.length)&&(0,q.jsx)(`div`,{className:`grid gap-1 border-t border-border/70 bg-card/35 px-3 py-2`,children:u.filter(e=>e.evidence?.length).slice(0,12).map(e=>{let t=(e.from===l?e.to:e.from).slice(4);return(0,q.jsxs)(`p`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:[(0,q.jsx)(`span`,{className:`text-info`,children:e.relation}),` `,Pe(t),` · why:`,` `,e.evidence?.join(`, `)]},e.id)})}),s&&(0,q.jsx)(P,{open:s,onOpenChange:c,children:(0,q.jsxs)(me,{className:`flex max-h-[90dvh] max-w-[90vw] flex-col p-0`,showCloseButton:!1,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/70 bg-card/55 px-4 py-3`,children:[(0,q.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-muted-foreground`,children:a(`activity:memoryManager.graphHeadingFull`,{id:e.id})}),(0,q.jsx)(F,{variant:`ghost`,size:`sm`,onClick:()=>c(!1),className:`h-7 gap-1 px-2 text-[10px]`,children:a(`common:action.close`)})]}),(0,q.jsx)(`div`,{className:`min-h-0 flex-1 px-4 pb-4`,children:(0,q.jsx)(He,{nodes:d,edges:f,className:`h-[65vh]`})})]})})]})}function We({memory:e,allMemories:t,relatedMemories:n,graphEdges:i,graphLoading:a,graphError:s,onClose:l,onOpenMemory:u,onEdit:f,onDelete:p,onTagSelect:m,onNotice:h}){let{t:g}=o();return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-border/70 bg-card/65 px-4 py-3 backdrop-blur-xl`,children:[(0,q.jsx)(F,{variant:`ghost`,size:`icon`,className:`md:hidden`,onClick:l,"aria-label":g(`activity:memoryManager.backToList`),children:(0,q.jsx)(r,{className:`size-4`})}),(0,q.jsx)(`span`,{className:N(`text-[10px] font-bold uppercase tracking-[0.14em]`,B(e.kind)),children:Ee[e.kind]??e.kind}),(0,q.jsx)(Ce,{status:e.status}),(0,q.jsx)(`span`,{className:`border border-border/70 px-2 py-0.5 font-mono text-[9px] uppercase text-muted-foreground`,children:e.scope}),e.audience&&(0,q.jsxs)(`span`,{className:`flex items-center gap-1 border border-primary/30 bg-primary/10 px-2 py-0.5 font-mono text-[9px] text-primary`,title:Te(e.audience),children:[(0,q.jsx)(C,{className:`size-3`}),Te(e.audience)]}),(0,q.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,q.jsx)(F,{variant:`ghost`,size:`icon`,"aria-label":g(`activity:memoryManager.copyId`),title:g(`activity:memoryManager.copyId`),onClick:()=>{navigator.clipboard?.writeText(e.id),h(g(`activity:memoryManager.copiedNotice`))},children:(0,q.jsx)(c,{className:`size-4`})}),(0,q.jsxs)(F,{variant:`outline`,size:`sm`,onClick:()=>f(e.id),disabled:e.status===`deleted`,children:[(0,q.jsx)(d,{className:`size-3.5`}),` `,g(`common:action.edit`)]}),(0,q.jsxs)(F,{variant:`destructive`,size:`sm`,onClick:p,disabled:e.status===`deleted`,children:[(0,q.jsx)(E,{className:`size-3.5`}),` `,g(`common:action.delete`)]})]})]}),(0,q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-4 md:p-5`,children:(0,q.jsxs)(`div`,{className:`mx-auto max-w-5xl space-y-5`,children:[(0,q.jsx)(Ge,{memory:e}),(0,q.jsx)(Ke,{memory:e}),e.tags.length>0&&(0,q.jsx)(qe,{tags:e.tags,onTagSelect:m}),e.anchors.length>0&&(0,q.jsx)(Je,{anchors:e.anchors}),n.length>0&&(0,q.jsx)(Ye,{relatedMemories:n,allMemories:t,onOpenMemory:u}),(0,q.jsx)(Ue,{centerMemory:e,allMemories:t,graphEdges:i,loading:a,error:s}),(0,q.jsx)(Xe,{memory:e}),e.status===`deleted`&&(0,q.jsx)(Ze,{contextPolicy:e.contextPolicy})]})})]})}function Ge({memory:e}){let{t}=o();return(0,q.jsxs)(`div`,{className:`relative overflow-hidden border border-border/75 bg-card/55 p-5 shadow-[inset_0_1px_0_hsl(var(--foreground)/0.04)]`,children:[(0,q.jsx)(`div`,{className:`pointer-events-none absolute -right-10 -top-10 size-36 bg-[radial-gradient(circle,hsl(var(--info)/0.13),transparent_68%)]`}),(0,q.jsx)(`p`,{className:`relative whitespace-pre-wrap text-sm leading-7 text-foreground md:text-[15px]`,children:e.text}),e.summary&&(0,q.jsx)(`p`,{className:`relative mt-4 border-l-2 border-info/50 pl-3 text-xs italic leading-5 text-muted-foreground`,children:e.summary}),(0,q.jsxs)(`div`,{className:`relative mt-5 flex flex-wrap items-center gap-2 border-t border-border/60 pt-3`,children:[(0,q.jsx)(`code`,{className:`min-w-0 break-all font-mono text-[10px] text-muted-foreground`,children:e.id}),(0,q.jsx)(`span`,{className:`ml-auto font-mono text-[10px] text-muted-foreground`,children:t(`activity:memoryManager.revisionSuffix`,{n:e.revision})})]})]})}function Ke({memory:e}){let{t}=o();return(0,q.jsx)(`div`,{className:`grid gap-px bg-border/60 sm:grid-cols-3`,children:[[t(`activity:memoryManager.editorImportance`),e.importance,v],[t(`activity:memoryManager.editorConfidence`),e.confidence,a],[t(`activity:memoryManager.editorFreshness`),e.freshness,M]].map(([e,t,n])=>(0,q.jsxs)(`div`,{className:`bg-card/60 p-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(n,{className:`size-3.5 text-info`}),(0,q.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.13em] text-muted-foreground`,children:e}),(0,q.jsxs)(`span`,{className:`ml-auto font-mono text-xs font-bold tabular-nums`,children:[Math.round(t*100),`%`]})]}),(0,q.jsx)(`div`,{className:`mt-2 h-1 bg-muted`,children:(0,q.jsx)(`div`,{className:`h-full bg-info shadow-[0_0_8px_hsl(var(--info)/0.45)]`,style:{width:`${Math.round(t*100)}%`}})})]},e))})}function qe({tags:e,onTagSelect:t}){let{t:n}=o();return(0,q.jsxs)(`section`,{children:[(0,q.jsxs)(`h3`,{className:`mb-2 flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:[(0,q.jsx)(i,{className:`size-3.5 text-info`}),` `,n(`activity:memoryManager.tagsLabel`)]}),(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map(e=>(0,q.jsxs)(`button`,{type:`button`,onClick:()=>t(e),className:`border border-info/25 bg-info/5 px-2 py-1 font-mono text-[10px] text-info hover:border-info/55 hover:bg-info/10`,children:[`#`,e]},e))})]})}function Je({anchors:e}){let{t}=o();return(0,q.jsxs)(`section`,{className:`border border-border/75 bg-card/40`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/65 px-3 py-2.5`,children:[(0,q.jsxs)(`h3`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:[(0,q.jsx)(ie,{className:`size-3.5 text-info`}),` `,t(`activity:memoryManager.editorAnchors`)]}),(0,q.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.length})]}),(0,q.jsx)(`ul`,{className:`divide-y divide-border/55`,children:e.map((e,t)=>(0,q.jsxs)(`li`,{className:`flex min-w-0 items-start gap-3 px-3 py-2.5`,children:[(0,q.jsx)(`span`,{className:`mt-0.5 flex size-7 shrink-0 items-center justify-center border border-info/25 bg-info/5 text-info`,children:e.type===`command`?(0,q.jsx)(g,{className:`size-3.5`}):(0,q.jsx)(ie,{className:`size-3.5`})}),(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`p`,{className:`text-[9px] font-bold uppercase text-muted-foreground`,children:e.type}),(0,q.jsxs)(`p`,{className:`mt-0.5 break-all font-mono text-[10px] leading-4 text-foreground/85`,children:[e.path??e.command??e.role??`—`,e.symbol?`#${e.symbol}`:``]})]}),(e.lineStart||e.lineEnd)&&(0,q.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono text-[9px] text-muted-foreground`,children:[`L`,e.lineStart??`?`,`–`,e.lineEnd??`?`]})]},`${e.type}:${e.path??e.command??e.symbol??e.role}:${t}`))})]})}function Ye({relatedMemories:e,allMemories:t,onOpenMemory:n}){let{t:r}=o();return(0,q.jsxs)(`section`,{className:`border border-border/75 bg-card/40`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/65 px-3 py-2.5`,children:[(0,q.jsxs)(`h3`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:[(0,q.jsx)(p,{className:`size-3.5 text-info`}),` `,r(`activity:memoryManager.memoryRelationships`)]}),(0,q.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.length})]}),(0,q.jsx)(`ul`,{className:`divide-y divide-border/55`,children:e.map(e=>{let i=t.find(t=>t.id===e.id);return(0,q.jsx)(`li`,{children:(0,q.jsxs)(`button`,{type:`button`,disabled:!i,onClick:()=>i&&n(i.id),className:`group flex w-full min-w-0 items-center gap-3 px-3 py-2.5 text-left hover:bg-info/5 disabled:cursor-not-allowed disabled:opacity-55`,children:[(0,q.jsx)(`span`,{className:N(`w-24 shrink-0 text-[9px] font-bold uppercase`,e.relation===`Contradicts`?`text-destructive`:`text-info`),children:e.relation}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs`,children:i?z(i.text,95):r(`activity:memoryManager.referencedUnavailable`)}),(0,q.jsx)(`code`,{className:`hidden max-w-32 truncate font-mono text-[9px] text-muted-foreground sm:block`,children:e.id}),i&&(0,q.jsx)(m,{className:`size-3.5 shrink-0 text-muted-foreground group-hover:text-info`})]})},`${e.relation}:${e.id}`)})})]})}function Xe({memory:e}){let{t:n}=o();return(0,q.jsx)(`section`,{className:`grid gap-px bg-border/60 sm:grid-cols-2 lg:grid-cols-4`,children:[[n(`activity:memoryManager.metaCreated`),H(e.createdAt),O],[n(`activity:memoryManager.metaUpdated`),H(e.updatedAt),M],[n(`activity:memoryManager.metaLastAccessed`),H(e.lastAccessedAt),t],[n(`activity:memoryManager.metaLastVerified`),H(e.lastVerifiedAt),v]].map(([e,t,n])=>(0,q.jsxs)(`div`,{className:`bg-card/50 p-3`,children:[(0,q.jsx)(n,{className:`size-3.5 text-muted-foreground`}),(0,q.jsx)(`p`,{className:`mt-2 text-[9px] font-bold uppercase tracking-[0.12em] text-muted-foreground`,children:e}),(0,q.jsx)(`p`,{className:`mt-1 text-[10px] leading-4 text-foreground/85`,children:t})]},e))})}function Ze({contextPolicy:e}){let{t}=o();return(0,q.jsxs)(`div`,{className:`flex items-start gap-3 border border-border bg-muted/50 p-4 text-xs text-muted-foreground`,children:[(0,q.jsx)(u,{className:`mt-0.5 size-4 shrink-0`}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`font-bold text-foreground`,children:t(`activity:memoryManager.deletedMemory`)}),(0,q.jsx)(`p`,{className:`mt-1 leading-5`,children:t(e===`never`?`activity:memoryManager.deletedNeverPolicy`:`activity:memoryManager.deletedEligiblePolicy`)})]})]})}function Qe({mode:e,draft:t,busy:n,error:r,onChange:i,onCancel:a,onSubmit:s}){let{t:c}=o(),l=(0,K.useRef)(null),[u,p]=(0,K.useState)([]);(0,K.useEffect)(()=>{l.current?.focus();let e=new AbortController;return L(`agent-roster.list`,{},e.signal).then(e=>{let t=e.roles;Array.isArray(t)&&p(t.filter(e=>typeof e==`string`))}).catch(()=>void 0),()=>e.abort()},[]);let m=(e,n)=>{i({...t,[e]:n})},h=()=>{m(`anchors`,[...t.anchors,{type:`file`,path:``}])};return(0,q.jsxs)(`form`,{className:`flex min-h-0 flex-1 flex-col`,onSubmit:e=>{e.preventDefault(),s()},"aria-busy":n,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-border/70 bg-card/70 px-4 py-3 backdrop-blur-xl`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`flex size-8 items-center justify-center border border-info/35 bg-info/10 text-info`,children:e===`create`?(0,q.jsx)(_,{className:`size-4`}):(0,q.jsx)(d,{className:`size-4`})}),(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`p`,{className:`truncate text-sm font-bold`,children:c(e===`create`?`activity:memoryManager.captureMemory`:`activity:memoryManager.editMemory`)}),(0,q.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:c(e===`create`?`activity:memoryManager.editorCreateHint`:`activity:memoryManager.editorEditHint`)})]})]}),(0,q.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,q.jsxs)(F,{type:`button`,variant:`ghost`,size:`sm`,onClick:a,disabled:n,children:[(0,q.jsx)(w,{className:`size-3.5`}),` `,c(`common:action.cancel`)]}),(0,q.jsxs)(F,{type:`submit`,size:`sm`,disabled:n||!t.text.trim(),children:[n?(0,q.jsx)(S,{className:`size-3.5 animate-spin`}):e===`create`?(0,q.jsx)(se,{className:`size-3.5`}):(0,q.jsx)(oe,{className:`size-3.5`}),c(n?`common:action.saving`:e===`create`?`activity:memoryManager.createMemory`:`activity:memoryManager.saveChanges`)]})]})]}),(0,q.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto overscroll-contain p-4 md:p-5`,children:(0,q.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-5`,children:[r&&(0,q.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-2 border border-destructive/40 bg-destructive/10 px-3 py-2.5 text-sm text-destructive`,children:[(0,q.jsx)(f,{className:`mt-0.5 size-4 shrink-0`}),(0,q.jsx)(`span`,{children:r})]}),(0,q.jsxs)(`section`,{className:`border border-border/75 bg-card/45 p-4`,children:[(0,q.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h3`,{className:`text-xs font-bold uppercase tracking-[0.14em]`,children:c(`activity:memoryManager.editorKnowledge`)}),(0,q.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:c(`activity:memEditor.writeTheDurableFactOrDecision`)})]}),(0,q.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground tabular-nums`,children:c(`activity:memoryManager.editorCharCount`,{count:t.text.length})})]}),(0,q.jsx)(`label`,{htmlFor:`memory-text`,className:`sr-only`,children:c(`activity:memoryManager.editorContentLabel`)}),(0,q.jsx)(`textarea`,{ref:l,id:`memory-text`,value:t.text,onChange:e=>m(`text`,e.target.value),rows:7,required:!0,placeholder:c(`activity:memoryManager.editorContentPlaceholder`),className:`min-h-36 w-full resize-y border border-input bg-background/75 px-3 py-3 text-sm leading-6 text-foreground shadow-inner placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`})]}),(0,q.jsxs)(`section`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`label`,{htmlFor:`memory-kind`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:c(`activity:memoryManager.editorKind`)}),(0,q.jsx)(`select`,{id:`memory-kind`,value:t.kind,onChange:e=>m(`kind`,e.target.value),className:`h-10 w-full border border-input bg-background px-3 text-sm`,children:V.map(e=>(0,q.jsx)(`option`,{value:e,children:Ee[e]},e))})]}),e===`create`?(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`label`,{htmlFor:`memory-scope`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:c(`activity:memoryManager.editorScope`)}),(0,q.jsx)(`select`,{id:`memory-scope`,value:t.scope,onChange:e=>m(`scope`,e.target.value),className:`h-10 w-full border border-input bg-background px-3 text-sm`,children:R.map(e=>(0,q.jsx)(`option`,{value:e,children:e},e))})]}):(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`label`,{htmlFor:`memory-status`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:c(`activity:memoryManager.editorLifecycleStatus`)}),(0,q.jsx)(`select`,{id:`memory-status`,value:t.status,onChange:e=>m(`status`,e.target.value),className:`h-10 w-full border border-input bg-background px-3 text-sm`,children:U.map(e=>(0,q.jsx)(`option`,{value:e,children:e},e))})]}),(0,q.jsxs)(`div`,{className:N(`min-w-0`,e===`create`?`sm:col-span-2 lg:col-span-1`:``),children:[(0,q.jsx)(`label`,{htmlFor:`memory-tags`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:c(`activity:memoryManager.tagsLabel`)}),(0,q.jsx)(I,{id:`memory-tags`,value:t.tags,onChange:e=>m(`tags`,e.target.value),placeholder:c(`activity:memEditor.architectureWebuiWorkflow`),className:`h-10 bg-background`})]})]}),(0,q.jsxs)(`section`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,q.jsx)(be,{id:`memory-importance`,label:c(`activity:memoryManager.editorImportance`),value:t.importance,onChange:e=>m(`importance`,e)}),(0,q.jsx)(be,{id:`memory-confidence`,label:c(`activity:memoryManager.editorConfidence`),value:t.confidence,onChange:e=>m(`confidence`,e)}),(0,q.jsx)(be,{id:`memory-freshness`,label:c(`activity:memoryManager.editorFreshness`),value:t.freshness,onChange:e=>m(`freshness`,e)})]}),(0,q.jsxs)(`section`,{className:`border border-border/75 bg-card/45 p-4`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h3`,{className:`text-xs font-bold uppercase tracking-[0.14em]`,children:c(`activity:memoryManager.editorAnchors`)}),(0,q.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:c(`activity:memEditor.bindKnowledgeToFilesSymbolsPackages`)})]}),(0,q.jsxs)(F,{type:`button`,variant:`outline`,size:`sm`,onClick:h,children:[(0,q.jsx)(se,{className:`size-3.5`}),` `,c(`activity:memoryManager.addAnchor`)]})]}),t.anchors.length===0?(0,q.jsxs)(`button`,{type:`button`,onClick:h,className:`mt-4 flex w-full items-center justify-center gap-2 border border-dashed border-border px-4 py-7 text-xs text-muted-foreground transition-colors hover:border-info/50 hover:bg-info/5 hover:text-info`,children:[(0,q.jsx)(T,{className:`size-4`}),` `,c(`activity:memoryManager.noAnchors`)]}):(0,q.jsx)(`div`,{className:`mt-4 space-y-2`,children:t.anchors.map((e,n)=>(0,q.jsxs)(`div`,{className:`grid gap-2 border border-border/65 bg-background/40 p-2 sm:grid-cols-[9rem_minmax(0,1fr)_auto]`,children:[(0,q.jsxs)(`label`,{className:`sr-only`,htmlFor:`anchor-type-${n}`,children:[`Anchor `,n+1,` type`]}),(0,q.jsx)(`select`,{id:`anchor-type-${n}`,value:e.type,onChange:e=>{let r=e.target.value,i=r===`command`?{type:r,command:``}:r===`agent`?{type:r,role:``}:{type:r,path:``},a=t.anchors.map((e,t)=>t===n?i:e);m(`anchors`,a)},className:`h-10 border border-input bg-background px-2 text-xs`,children:W.map(e=>(0,q.jsx)(`option`,{value:e,children:e},e))}),(0,q.jsxs)(`div`,{className:N(`grid min-w-0 gap-2`,e.type===`symbol`&&`sm:grid-cols-[minmax(0,1fr)_11rem]`),children:[(0,q.jsxs)(`label`,{className:`sr-only`,htmlFor:`anchor-value-${n}`,children:[`Anchor `,n+1,` value`]}),(0,q.jsx)(I,{id:`anchor-value-${n}`,list:e.type===`agent`?`memory-agent-role-options`:void 0,value:Oe(e),onChange:e=>{let r=t.anchors.map((t,r)=>r===n?ye(t,e.target.value):t);m(`anchors`,r)},placeholder:e.type===`command`?`pnpm test --filter webui`:e.type===`agent`?`reviewer`:`packages/webui/src/App.tsx`,className:`h-10 min-w-0 bg-background font-mono text-xs`}),e.type===`symbol`&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`label`,{className:`sr-only`,htmlFor:`anchor-symbol-${n}`,children:[`Anchor `,n+1,` symbol`]}),(0,q.jsx)(I,{id:`anchor-symbol-${n}`,value:e.symbol??``,onChange:e=>{let r=t.anchors.map((t,r)=>r===n?{...t,symbol:e.target.value}:t);m(`anchors`,r)},placeholder:c(`activity:memoryManager.editorSymbolPlaceholder`),className:`h-10 bg-background font-mono text-xs`})]})]}),(0,q.jsx)(F,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Remove anchor ${n+1}`,onClick:()=>m(`anchors`,t.anchors.filter((e,t)=>t!==n)),children:(0,q.jsx)(E,{className:`size-4 text-destructive`})})]},`${e.type}:${n}`))}),(0,q.jsx)(`datalist`,{id:`memory-agent-role-options`,children:u.map(e=>(0,q.jsx)(`option`,{value:e},e))})]}),(0,q.jsxs)(`section`,{className:`grid gap-3 border border-border/75 bg-card/45 p-4 sm:grid-cols-2`,children:[(0,q.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,q.jsx)(`h3`,{className:`text-xs font-bold uppercase tracking-[0.14em]`,children:c(`activity:memoryManager.editorRelationships`)}),(0,q.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:c(`activity:memoryManager.editorRelationshipsHint`)})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{htmlFor:`memory-supersedes`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:c(`activity:memoryManager.editorSupersedes`)}),(0,q.jsx)(I,{id:`memory-supersedes`,value:t.supersedes,onChange:e=>m(`supersedes`,e.target.value),placeholder:c(`activity:memEditor.memIdMemId`),className:`h-10 bg-background font-mono text-xs`})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{htmlFor:`memory-contradicts`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:c(`activity:memoryManager.editorContradicts`)}),(0,q.jsx)(I,{id:`memory-contradicts`,value:t.contradicts,onChange:e=>m(`contradicts`,e.target.value),placeholder:c(`activity:memEditor.memIdMemId`),className:`h-10 bg-background font-mono text-xs`})]})]}),(0,q.jsxs)(`section`,{className:`space-y-2`,children:[(0,q.jsx)(`h3`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:c(`activity:memEditor.audienceOptional`)}),(0,q.jsx)(`p`,{className:`text-[10px] text-muted-foreground/70`,children:c(`activity:memEditor.targetThisMemoryToSpecificAgent`)}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{htmlFor:`memory-audience-roles`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:c(`activity:memEditor.roles`)}),(0,q.jsx)(I,{id:`memory-audience-roles`,value:t.audienceRoles,onChange:e=>m(`audienceRoles`,e.target.value),placeholder:c(`activity:memEditor.reviewerRefactorPlanner`),className:`h-9 bg-background font-mono text-xs`})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{htmlFor:`memory-audience-task-types`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:c(`activity:memoryManager.editorTaskTypes`)}),(0,q.jsx)(I,{id:`memory-audience-task-types`,value:t.audienceTaskTypes,onChange:e=>m(`audienceTaskTypes`,e.target.value),placeholder:c(`activity:memEditor.reviewRefactorBugfix`),className:`h-9 bg-background font-mono text-xs`})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{htmlFor:`memory-audience-modes`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:c(`activity:memEditor.modes`)}),(0,q.jsx)(I,{id:`memory-audience-modes`,value:t.audienceModes,onChange:e=>m(`audienceModes`,e.target.value),placeholder:c(`activity:memEditor.teachCodeReview`),className:`h-9 bg-background font-mono text-xs`})]})]})]})})]})}function $e({searchQuery:e,statusFilter:t,kindFilter:r,audienceOnly:a,tagFilter:s,hasFilters:c,allTags:l,stats:u,onSearchChange:d,onStatusFilterChange:f,onKindFilterChange:p,onToggleAudienceOnly:m,onTagFilterChange:h,onClearFilters:g}){let{t:_}=o(),[v,y]=(0,K.useState)(!!s),b=v||!!s,S=l.length>0;return(0,q.jsxs)(`div`,{className:`shrink-0 space-y-2 overflow-hidden border-b border-border/70 bg-card/45 p-3`,children:[(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,q.jsx)(x,{className:`pointer-events-none absolute left-3 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,q.jsx)(I,{"aria-label":_(`activity:memoryManager.searchAria`),value:e,onChange:e=>d(e.target.value),placeholder:_(`activity:memoryManager.searchPlaceholder`),className:`h-10 min-w-0 bg-background pl-9 pr-8 text-xs`}),e&&(0,q.jsx)(`button`,{type:`button`,"aria-label":_(`activity:memoryManager.clearSearchAria`),onClick:()=>d(``),className:`absolute right-2 top-1/2 -translate-y-1/2 p-1 text-muted-foreground hover:text-foreground`,children:(0,q.jsx)(w,{className:`size-3.5`})})]}),(0,q.jsx)(F,{variant:a?`default`:`ghost`,size:`icon`,onClick:m,"aria-label":_(`activity:memoryManager.audienceFilterAria`),title:_(`activity:memoryManager.audienceFilterTitle`),className:`shrink-0`,children:(0,q.jsx)(C,{className:`size-4`})}),c&&(0,q.jsx)(F,{variant:`ghost`,size:`icon`,onClick:g,"aria-label":_(`activity:memoryManager.clearFiltersAria`),title:_(`activity:memoryManager.clearFiltersTitle`),children:(0,q.jsx)(n,{className:`size-4`})})]}),(0,q.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,q.jsx)(`label`,{className:`sr-only`,htmlFor:`memory-status-filter`,children:_(`activity:memoryManager.filterByStatus`)}),(0,q.jsxs)(`select`,{id:`memory-status-filter`,value:t,onChange:e=>f(e.target.value),className:`h-9 min-w-0 border border-input bg-background px-2 text-xs`,children:[(0,q.jsx)(`option`,{value:`all`,children:_(`activity:memoryManager.allStatuses`)}),we.map(e=>(0,q.jsxs)(`option`,{value:e,children:[e,` · `,u?.byStatus[e]??0]},e))]}),(0,q.jsx)(`label`,{className:`sr-only`,htmlFor:`memory-kind-filter`,children:_(`activity:memoryManager.filterByKind`)}),(0,q.jsxs)(`select`,{id:`memory-kind-filter`,value:r,onChange:e=>p(e.target.value),className:`h-9 min-w-0 border border-input bg-background px-2 text-xs`,children:[(0,q.jsx)(`option`,{value:`all`,children:_(`activity:memoryManager.allKinds`)}),V.map(e=>(0,q.jsxs)(`option`,{value:e,children:[Ee[e],` · `,u?.byKind[e]??0]},e))]})]}),S&&(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{s||y(e=>!e)},"aria-expanded":b,"aria-controls":`memory-tags-panel`,disabled:!!s,className:N(`flex items-center gap-1.5 px-1 py-0.5 text-[10px] uppercase tracking-wide transition-colors`,b?`text-foreground`:`text-muted-foreground hover:text-foreground`,!!s&&`cursor-default`),title:s?`Active filter: ${s} (click the chip to clear)`:b?`Hide tag filters`:`Show tag filters (${l.length})`,children:[(0,q.jsx)(ee,{className:N(`size-3 transition-transform`,!b&&`-rotate-90`)}),(0,q.jsx)(i,{className:`size-3`}),(0,q.jsx)(`span`,{className:`font-semibold`,children:_(`activity:memoryManager.tagsLabel`)}),(0,q.jsx)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:l.length})]}),s&&(0,q.jsx)(`span`,{role:`status`,"aria-label":`Active tag filter: ${s}`,className:`border border-info/55 bg-info/10 px-1 font-mono text-[9px] uppercase text-info`,children:s})]}),S&&b&&(0,q.jsxs)(`fieldset`,{id:`memory-tags-panel`,className:`min-w-0 border-0 p-0`,children:[(0,q.jsx)(`legend`,{className:`sr-only`,children:_(`activity:memoryManager.popularTags`)}),(0,q.jsx)(`div`,{className:`no-scrollbar flex gap-1.5 overflow-x-auto pb-0.5`,children:l.slice(0,18).map(([e,t])=>(0,q.jsxs)(`button`,{type:`button`,"aria-pressed":s===e,onClick:()=>h(s===e?null:e),className:N(`flex shrink-0 items-center gap-1 border px-2 py-1 text-[10px] transition-colors`,s===e?`border-info/55 bg-info/10 text-info`:`border-border/70 bg-background/45 text-muted-foreground hover:border-info/35 hover:text-foreground`),children:[(0,q.jsx)(i,{className:`size-2.5`}),` `,e,(0,q.jsx)(`span`,{className:`font-mono opacity-60`,children:t})]},e))})]})]})}var et=100;function tt({memoryListRef:e,memories:t,filteredMemories:n,selectedId:r,onSelectMemory:i,onOpenCreate:a,onClearFilters:s}){let{t:c}=o(),l=n.length>et,u=k({count:n.length,getScrollElement:()=>e.current,estimateSize:()=>100,overscan:8,enabled:l});return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-border/60 px-3 py-2 text-[10px] text-muted-foreground`,children:[(0,q.jsx)(`span`,{children:c(`activity:memoryManager.memoryCountSummary`,{shown:n.length,total:t.length})}),(0,q.jsx)(`span`,{className:`font-mono uppercase`,children:c(`activity:memoryManager.updatedSortLabel`)})]}),(0,q.jsx)(`section`,{ref:e,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,"aria-label":c(`activity:memoryManager.listAria`),children:n.length===0?(0,q.jsx)(J,{hasMemories:t.length>0,onOpenCreate:a,onClearFilters:s}):l?(0,q.jsx)(`div`,{style:{height:`${u.getTotalSize()}px`,width:`100%`,position:`relative`},children:u.getVirtualItems().map(e=>{let t=n[e.index];return t?(0,q.jsx)(`div`,{"data-index":e.index,ref:u.measureElement,style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${e.start}px)`},children:(0,q.jsx)(nt,{memory:t,isSelected:r===t.id,onClick:()=>i(t.id)})},t.id):null})}):n.map(e=>(0,q.jsx)(nt,{memory:e,isSelected:r===e.id,onClick:()=>i(e.id)},e.id))})]})}function J({hasMemories:e,onOpenCreate:t,onClearFilters:r}){let{t:i}=o();return(0,q.jsxs)(`div`,{className:`flex min-h-64 flex-col items-center justify-center px-6 text-center`,children:[(0,q.jsx)(`span`,{className:`flex size-12 items-center justify-center border border-dashed border-border text-muted-foreground`,children:(0,q.jsx)(ce,{className:`size-5`})}),(0,q.jsx)(`h2`,{className:`mt-4 text-sm font-bold`,children:i(e?`activity:memoryManager.noMatching`:`activity:memoryManager.buildGraph`)}),(0,q.jsx)(`p`,{className:`mt-1 max-w-xs text-xs leading-5 text-muted-foreground`,children:i(e?`activity:memoryManager.emptyFiltered`:`activity:memoryManager.emptyCapture`)}),(0,q.jsxs)(F,{className:`mt-4`,variant:`outline`,size:`sm`,onClick:e?r:t,children:[e?(0,q.jsx)(n,{className:`size-3.5`}):(0,q.jsx)(se,{className:`size-3.5`}),i(e?`activity:memoryManager.clearFilters`:`activity:memoryManager.createFirst`)]})]})}function nt({memory:e,isSelected:t,onClick:n}){return(0,q.jsxs)(`button`,{type:`button`,"aria-current":t?`true`:void 0,onClick:n,className:N(`group relative block w-full border-b border-border/55 px-3 py-3 text-left transition-[background-color,border-color] hover:bg-info/5`,t&&`bg-info/8`),children:[t&&(0,q.jsx)(`span`,{className:`absolute inset-y-0 left-0 w-0.5 bg-info shadow-[0_0_10px_hsl(var(--info)/0.7)]`}),(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,q.jsx)(`span`,{className:N(`truncate text-[10px] font-bold uppercase tracking-[0.1em]`,B(e.kind)),children:Ee[e.kind]??e.kind}),(0,q.jsx)(Ce,{status:e.status}),(0,q.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono text-[9px] text-muted-foreground`,children:[`r`,e.revision]})]}),(0,q.jsx)(`p`,{className:N(`mt-2 line-clamp-2 text-xs leading-5 text-foreground/90`,e.status===`deleted`&&`line-through opacity-60`),children:z(e.text)}),(0,q.jsxs)(`div`,{className:`mt-2 flex min-w-0 items-center gap-1.5`,children:[(0,q.jsx)(`span`,{className:`border border-border/60 bg-background/50 px-1.5 py-0.5 font-mono text-[9px] uppercase text-muted-foreground`,children:e.scope}),e.audience&&(0,q.jsxs)(`span`,{className:`flex items-center gap-0.5 border border-primary/30 bg-primary/10 px-1.5 py-0.5 font-mono text-[9px] text-primary`,children:[(0,q.jsx)(C,{className:`size-2.5`}),(e.audience.roles??e.audience.taskTypes??e.audience.modes??[]).slice(0,1)[0]??`scoped`]}),e.tags.slice(0,2).map(e=>(0,q.jsxs)(`span`,{className:`max-w-24 truncate border border-border/60 px-1.5 py-0.5 font-mono text-[9px] text-muted-foreground`,children:[`#`,e]},e)),e.tags.length>2&&(0,q.jsxs)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:[`+`,e.tags.length-2]}),(0,q.jsx)(`span`,{className:`ml-auto shrink-0 text-[9px] text-muted-foreground`,children:ke(e.updatedAt)}),(0,q.jsx)(m,{className:`size-3 shrink-0 text-muted-foreground transition-transform group-hover:translate-x-0.5 group-hover:text-info`})]})]})}function rt({onCapture:e}){let{t}=o();return(0,q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center p-8 text-center`,children:[(0,q.jsxs)(`div`,{className:`relative flex size-20 items-center justify-center border border-info/25 bg-info/5 text-info`,children:[(0,q.jsx)(C,{className:`size-8`}),(0,q.jsx)(`span`,{className:`absolute inset-2 border border-info/10`})]}),(0,q.jsx)(`h2`,{className:`mt-5 text-lg font-bold`,children:t(`activity:memoryManager.emptyTitle`)}),(0,q.jsx)(`p`,{className:`mt-2 max-w-md text-sm leading-6 text-muted-foreground`,children:t(`activity:memoryManager.emptyBody`)}),(0,q.jsxs)(`div`,{className:`mt-6 grid w-full max-w-lg gap-2 sm:grid-cols-3`,children:[(0,q.jsxs)(`div`,{className:`border border-border/70 bg-card/45 p-3`,children:[(0,q.jsx)(ae,{className:`mx-auto size-4 text-success`}),(0,q.jsx)(`p`,{className:`mt-2 text-[10px] font-bold uppercase`,children:t(`activity:memoryManager.emptyVerifiedAnchors`)})]}),(0,q.jsxs)(`div`,{className:`border border-border/70 bg-card/45 p-3`,children:[(0,q.jsx)(C,{className:`mx-auto size-4 text-info`}),(0,q.jsx)(`p`,{className:`mt-2 text-[10px] font-bold uppercase`,children:t(`activity:memoryManager.emptyTypedRelations`)})]}),(0,q.jsxs)(`div`,{className:`border border-border/70 bg-card/45 p-3`,children:[(0,q.jsx)(se,{className:`mx-auto size-4 text-warning`}),(0,q.jsx)(`p`,{className:`mt-2 text-[10px] font-bold uppercase`,children:t(`activity:memoryManager.emptyAgentRecall`)})]})]}),(0,q.jsxs)(F,{onClick:e,children:[(0,q.jsx)(se,{className:`size-4`}),` `,t(`activity:memoryManager.captureButton`)]})]})}function it({listCandidates:e,resolveCandidate:t,onOpenMemory:n,client:r,active:i}){let{t:a}=o(),[s,c]=(0,K.useState)([]),[l,u]=(0,K.useState)(!1),[d,p]=(0,K.useState)(null),[m,h]=(0,K.useState)(null),[g,_]=(0,K.useState)(!1),[v,y]=(0,K.useState)(()=>new Set),b=(0,K.useRef)(0),x=(0,K.useCallback)(()=>{let t=++b.current;u(!0),p(null);let n=r.on(`memory.sage.listCandidates`,e=>{if(t===b.current){if(n(),e.payload.error)p(String(e.payload.error)),c([]);else{let t=(Array.isArray(e.payload.candidates)?e.payload.candidates:[]).filter(e=>e.status===`pending`);c(t),y(e=>{let n=new Set;for(let r of e)t.some(e=>e.id===r)&&n.add(r);return n})}u(!1)}}),i=setTimeout(()=>{t===b.current&&(n(),u(!1),p(a(`activity:memoryManager.reviewLoadTimeout`)))},15e3);return e({includeResolved:!1},{echoToChat:!1}),()=>{clearTimeout(i),n()}},[r,e,a]);(0,K.useEffect)(()=>{if(i)return x()},[i,x]);let C=(0,K.useCallback)((e,n)=>new Promise(i=>{let a=r.on(`memory.sage.candidateResolve`,e=>{a();let t=e.payload.error;i(!t)});t({candidateId:e,action:n,reason:n===`reject`?`Rejected via Memory Review tab`:void 0},{echoToChat:!1}),setTimeout(()=>{a(),i(!1)},15e3)}),[r,t]),ee=(0,K.useCallback)(async(e,t)=>{h(e),await C(e,t),h(null),x()},[x,C]),te=(0,K.useCallback)(async e=>{let t=[...v];if(t.length!==0){_(!0);for(let n of t)await C(n,e);_(!1),y(new Set),x()}},[x,C,v]),T=e=>{y(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},ne=()=>{y(new Set(s.map(e=>e.id)))},E=()=>y(new Set);if(l&&s.length===0)return(0,q.jsxs)(`div`,{className:`flex flex-1 items-center justify-center gap-2 p-6 text-sm text-muted-foreground`,children:[(0,q.jsx)(S,{className:`size-4 animate-spin`}),a(`activity:memoryManager.reviewLoading`)]});if(d&&s.length===0)return(0,q.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center`,children:[(0,q.jsx)(f,{className:`size-5 text-warning`}),(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:d}),(0,q.jsxs)(F,{size:`sm`,variant:`outline`,onClick:()=>x(),children:[(0,q.jsx)(M,{className:`size-3.5`}),` `,a(`common:action.retry`)]})]});if(s.length===0)return(0,q.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-2 p-8 text-center`,children:[(0,q.jsx)(ae,{className:`size-6 text-success`}),(0,q.jsx)(`p`,{className:`text-sm font-medium`,children:a(`activity:memoryManager.reviewEmptyTitle`)}),(0,q.jsx)(`p`,{className:`max-w-sm text-xs text-muted-foreground`,children:a(`activity:memoryManager.reviewEmptyHint`)}),(0,q.jsxs)(F,{size:`sm`,variant:`ghost`,onClick:()=>x(),children:[(0,q.jsx)(M,{className:`size-3.5`}),` `,a(`common:action.refresh`)]})]});let D=v.size,O=D===s.length&&s.length>0;return(0,q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2 border-b border-border/60 px-3 py-2`,children:[(0,q.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-wide text-muted-foreground`,children:a(`activity:memoryManager.reviewPendingCount`,{count:s.length})}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,q.jsx)(F,{size:`sm`,variant:`ghost`,className:`h-7 text-[11px]`,onClick:O?E:ne,children:a(O?`activity:memoryManager.reviewClearSelection`:`activity:memoryManager.reviewSelectAll`)}),(0,q.jsxs)(F,{size:`sm`,className:`h-7`,disabled:D===0||g,onClick:()=>void te(`accept`),children:[g?(0,q.jsx)(S,{className:`size-3 animate-spin`}):(0,q.jsx)(ae,{className:`size-3`}),a(`activity:memoryManager.reviewBulkAccept`),D>0?` (${D})`:``]}),(0,q.jsxs)(F,{size:`sm`,variant:`outline`,className:`h-7`,disabled:D===0||g,onClick:()=>void te(`reject`),children:[(0,q.jsx)(w,{className:`size-3`}),a(`activity:memoryManager.reviewBulkKeep`),D>0?` (${D})`:``]}),(0,q.jsx)(F,{size:`sm`,variant:`ghost`,className:`h-7`,onClick:()=>x(),disabled:l,children:(0,q.jsx)(M,{className:N(`size-3.5`,l&&`animate-spin`)})})]})]}),(0,q.jsx)(`ul`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto p-3`,children:s.map(e=>{let t=e.targetMemoryId??e.memoryId,r=e.reviewReason??e.reason??``,i=m===e.id||g,o=v.has(e.id);return(0,q.jsx)(`li`,{className:N(`rounded-md border bg-card/60 p-3 text-sm shadow-sm`,o?`border-primary/50 ring-1 ring-primary/20`:`border-border/70`),children:(0,q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,q.jsx)(`input`,{type:`checkbox`,className:`mt-1 size-3.5 accent-primary`,checked:o,disabled:g,onChange:()=>T(e.id),"aria-label":a(`activity:memoryManager.reviewSelectOne`)}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 text-[10px] uppercase tracking-wide text-muted-foreground`,children:[(0,q.jsx)(`span`,{className:`font-mono text-warning`,children:e.suggestedAction??`review`}),(0,q.jsx)(`span`,{children:`·`}),(0,q.jsx)(`span`,{children:ke(e.createdAt)}),e.tags?.includes(`triage`)&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{children:`·`}),(0,q.jsx)(`span`,{className:`text-info`,children:`triage`})]})]}),(0,q.jsx)(`p`,{className:`mt-1.5 text-[13px] leading-snug text-foreground`,children:z(e.text,220)}),r?(0,q.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:r}):null,t?(0,q.jsxs)(`button`,{type:`button`,className:`mt-1 font-mono text-[10px] text-primary hover:underline`,onClick:()=>n?.(t),children:[t.slice(0,16),`…`]}):null,(0,q.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:[(0,q.jsxs)(F,{size:`sm`,className:`h-7`,disabled:i,onClick:()=>void ee(e.id,`accept`),children:[m===e.id?(0,q.jsx)(S,{className:`size-3 animate-spin`}):(0,q.jsx)(ae,{className:`size-3`}),a(`activity:memoryManager.actionAcceptDeletion`)]}),(0,q.jsxs)(F,{size:`sm`,variant:`outline`,className:`h-7`,disabled:i,onClick:()=>void ee(e.id,`reject`),children:[(0,q.jsx)(w,{className:`size-3`}),a(`activity:memoryManager.actionKeep`)]})]})]})]})},e.id)})})]})}function at(e,t){let n=t.searchQuery.trim().toLowerCase();return e.filter(e=>{if(t.statusFilter!==`all`&&e.status!==t.statusFilter||t.kindFilter!==`all`&&e.kind!==t.kindFilter||t.tagFilter&&!e.tags.includes(t.tagFilter)||t.audienceOnly&&!e.audience)return!1;if(!n)return!0;let r=e.anchors.map(e=>[e.path,e.symbol,e.command,e.role].filter(Boolean).join(` `)).join(` `),i=e.audience?[e.audience.roles?.join(` `)??``,e.audience.taskTypes?.join(` `)??``,e.audience.modes?.join(` `)??``].join(` `):``;return[e.id,e.text,e.summary??``,e.kind,e.scope,e.tags.join(` `),r,i].join(` `).toLowerCase().includes(n)})}function ot(e){let t=new Map;for(let n of e)for(let e of n.tags)t.set(e,(t.get(e)??0)+1);return[...t.entries()].sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0]))}function st(e){if(!e)return[];let t=[];e.supersededBy&&t.push({relation:`Superseded by`,id:e.supersededBy});for(let n of e.supersedes??[])t.push({relation:`Supersedes`,id:n});for(let n of e.contradicts??[])t.push({relation:`Contradicts`,id:n});return t}function Y(){let{t:e}=o(),{client:t,listSageMemoriesPage:n,listMemoryCandidates:i,rememberSage:a,updateSage:c,deleteSage:u,getSageGraph:d,recoverSage:p,resolveMemoryCandidate:m}=le(),h=ue(e=>e.wsConnected),g=de(e=>e.setCurrentView),_=_e(`memory`),[v,y]=(0,K.useState)([]),[b,x]=(0,K.useState)(null),[S,w]=(0,K.useState)(!0),[ee,te]=(0,K.useState)(!1),[T,ne]=(0,K.useState)(null),[E,D]=(0,K.useState)(null),[O,k]=(0,K.useState)(null),[A,j]=(0,K.useState)(null),[re,ie]=(0,K.useState)([]),[oe,ce]=(0,K.useState)([]),[fe,pe]=(0,K.useState)(null),[me,he]=(0,K.useState)(!1),[ge,P]=(0,K.useState)(!1),[I,L]=(0,K.useState)(!1),[R,ye]=(0,K.useState)(Se),[be,z]=(0,K.useState)(Se),[B,V]=(0,K.useState)(null),[Ce,H]=(0,K.useState)(null),[U,we]=(0,K.useState)(``),[Te,Ee]=(0,K.useState)(`all`),[W,Oe]=(0,K.useState)(`all`),[ke,Me]=(0,K.useState)(!1),[Ne,Pe]=(0,K.useState)(null),[Fe,Ie]=(0,K.useState)(`active`),Le=Fe===`deleted`,Re=Fe===`review`,[ze,Be]=(0,K.useState)(null),[Ve,He]=(0,K.useState)(!1),[Ue,Ge]=(0,K.useState)(!1),[Ke,qe]=(0,K.useState)({}),[Je,Ye]=(0,K.useState)(!1),[Xe,Ze]=(0,K.useState)(null),et=(0,K.useRef)(!1),J=(0,K.useRef)(!0),nt=(0,K.useRef)(0),Y=(0,K.useRef)(0),ct=(0,K.useRef)(null),X=(0,K.useRef)(null),lt=(0,K.useMemo)(()=>{let e=new Set;for(let t of v)for(let n of t.anchors??[])n.type===`file`&&n.path&&e.add(n.path);return e},[v]),ut=(0,K.useMemo)(()=>JSON.stringify(R)!==JSON.stringify(be),[be,R]),Z=(0,K.useMemo)(()=>v.find(e=>e.id===A)??null,[v,A]),dt=(0,K.useCallback)(e=>{let r=e!==null,i=++nt.current;ct.current?.(),ne(null),r?Ge(!0):(te(!0),et.current||w(!0));let a=()=>{},o=null,s=!1,c=()=>{s||(s=!0,o!==null&&clearTimeout(o),a(),ct.current===c&&(ct.current=null))};a=t.on(`memory.sage.listPage`,e=>{if(i!==nt.current||!J.current){c();return}if(c(),e.payload.error)ne(e.payload.error);else{let t=e.payload.memories??[];y(e=>r?[...e,...t]:t),Be(e.payload.nextCursor??null),He(!!e.payload.nextCursor);let n=e.payload.statusCounts??{};qe(n);let i=Object.values(n).reduce((e,t)=>e+t,0);e.payload.stats?x(e.payload.stats):x(e=>({total:i,byStatus:n,byKind:e?.byKind??{},edges:e?.edges??0})),et.current=!0,r||j(e=>e&&t.some(t=>t.id===e)?e:null)}w(!1),te(!1),Ge(!1)}),o=setTimeout(()=>{i!==nt.current||!J.current||(c(),ne(`The memory store did not respond. Check the WebSocket connection and try again.`),w(!1),te(!1),Ge(!1))},2e4),ct.current=c,n({limit:100,...Le?{statuses:[`deleted`]}:{},...e?{cursor:e}:{},...U.trim()?{query:U.trim()}:{},...W===`all`?{}:{kind:W}},{echoToChat:!1})},[t,W,n,U,Le]),Q=(0,K.useCallback)(()=>{Be(null),He(!1),dt(null)},[dt]),ft=(0,K.useCallback)(()=>{Ue||!ze||dt(ze)},[dt,Ue,ze]);(0,K.useEffect)(()=>(J.current=!0,Q(),()=>{J.current=!1,nt.current+=1,Y.current+=1,ct.current?.(),X.current?.()}),[Q]),(0,K.useEffect)(()=>{if(ie([]),ce([]),pe(null),!A){he(!1);return}let e=A;he(!0);let n=null,r=t.on(`memory.sage.graph`,t=>{t.payload.query===e&&(n!==null&&clearTimeout(n),ie(t.payload.edges??[]),ce(t.payload.memories??[]),pe(t.payload.error??null),he(!1))});return n=setTimeout(()=>{pe(`Relationship graph did not respond in time.`),he(!1)},15e3),d(e,{maxDepth:1,limit:120},{echoToChat:!1}),()=>{n!==null&&clearTimeout(n),r()}},[t,d,A]);let pt=(0,K.useRef)(h);(0,K.useEffect)(()=>{h&&!pt.current&&et.current&&Q(),pt.current=h},[Q,h]),(0,K.useEffect)(()=>{if(!O)return;let e=setTimeout(()=>k(null),4e3);return()=>clearTimeout(e)},[O]);let mt=(0,K.useCallback)(()=>!ut||!ge&&!I||window.confirm(`Discard the unsaved memory changes?`),[I,ut,ge]),ht=(0,K.useCallback)(()=>{if(!mt())return;let e=Se();ye(e),z(e),L(!0),P(!1),j(null),D(null)},[mt]),gt=(0,K.useCallback)(e=>{mt()&&(j(e),L(!1),P(!1),D(null))},[mt]),_t=(0,K.useCallback)(e=>{let t=e===void 0?Z:v.find(t=>t.id===e)??null;if(!t||t.status===`deleted`)return;e!==void 0&&j(e);let n=xe(t);ye(n),z(n),P(!0),L(!1),D(null)},[v,Z]),vt=(0,K.useCallback)(()=>{mt()&&(P(!1),L(!1),D(null))},[mt]),yt=(0,K.useCallback)((n,r,i)=>{if(!R.text.trim()){D(`Memory content is required.`);return}let a=++Y.current;X.current?.(),V(i),D(null),k(null);let o=()=>{},s=null,c=!1,l=()=>{c||(c=!0,s!==null&&clearTimeout(s),o(),X.current===l&&(X.current=null))},u=t=>{if(a!==Y.current||!J.current){l();return}if(l(),V(null),t.payload.error||!t.payload.memory){D(t.payload.error??`The server returned no memory record.`);return}let n=t.payload.memory;y(e=>{let t=e.filter(e=>e.id!==n.id);return[n,...t]}),j(n.id),L(!1),P(!1),k(e(i===`create`?`activity:memoryManager.memoryCaptured`:`activity:memoryManager.memoryUpdated`)),Q()};o=n===`memory.sage.remember`?t.on(`memory.sage.remember`,u):t.on(`memory.sage.update`,u),s=setTimeout(()=>{a!==Y.current||!J.current||(l(),V(null),D(e(`activity:memoryManager.mutationTimeout`,{verb:e(i===`create`?`activity:memoryManager.createAction`:`common:action.save`)})))},2e4),X.current=l,r()},[t,R.text,Q,e]),bt=(0,K.useCallback)(()=>{yt(`memory.sage.remember`,()=>a({text:R.text.trim(),kind:R.kind,scope:R.scope,tags:G(R.tags),importance:R.importance,confidence:R.confidence,freshness:R.freshness,anchors:ve(R.anchors),...G(R.audienceRoles).length||G(R.audienceTaskTypes).length||G(R.audienceModes).length?{audience:{roles:G(R.audienceRoles),taskTypes:G(R.audienceTaskTypes),modes:G(R.audienceModes)}}:{},supersedes:G(R.supersedes),contradicts:G(R.contradicts)},{echoToChat:!1}),`create`)},[R,a,yt]),xt=(0,K.useCallback)(()=>{Z&&yt(`memory.sage.update`,()=>c(Z.id,{text:R.text.trim(),kind:R.kind,status:R.status,tags:G(R.tags),importance:R.importance,confidence:R.confidence,freshness:R.freshness,anchors:ve(R.anchors),...G(R.audienceRoles).length||G(R.audienceTaskTypes).length||G(R.audienceModes).length?{audience:{roles:G(R.audienceRoles),taskTypes:G(R.audienceTaskTypes),modes:G(R.audienceModes)}}:{},supersedes:G(R.supersedes),contradicts:G(R.contradicts)},{echoToChat:!1}),`update`)},[R,yt,Z,c]),St=(0,K.useCallback)(()=>{if(!Ce)return;let e=++Y.current;X.current?.(),V(`delete`),D(null);let n=()=>{},r=null,i=!1,a=()=>{i||(i=!0,r!==null&&clearTimeout(r),n(),X.current===a&&(X.current=null))};n=t.on(`memory.sage.delete`,t=>{if(e!==Y.current||!J.current){a();return}if(a(),V(null),!t.payload.success){D(t.payload.message||`Delete failed.`);return}H(null),j(null),P(!1),k(`Memory deleted and relationship edges cleaned up.`),Q()}),r=setTimeout(()=>{e!==Y.current||!J.current||(a(),V(null),D(`Delete timed out. The memory may still exist; refresh to confirm.`))},2e4),X.current=a,u(Ce,`Deleted from the WebUI Memory Manager.`)},[t,u,Ce,Q]),Ct=(0,K.useCallback)((e,n,r)=>{let i=++Y.current;X.current?.(),D(null);let a=()=>{},o=null,s=!1,c=()=>{s||(s=!0,o!==null&&clearTimeout(o),a(),X.current===c&&(X.current=null))};a=t.on(e,e=>{if(i!==Y.current||!J.current){c();return}c(),r(e.payload)}),o=setTimeout(()=>{i!==Y.current||!J.current||(c(),D(`The memory store did not respond. Check the WebSocket connection and try again.`))},2e4),X.current=c,n()},[t]),wt=(0,K.useMemo)(()=>at(v,{searchQuery:U,statusFilter:Te,kindFilter:W,tagFilter:Ne,audienceOnly:ke}),[ke,W,v,U,Te,Ne]),Tt=(0,K.useMemo)(()=>ot(v),[v]),Et=(0,K.useMemo)(()=>st(Z),[Z]),Dt=(0,K.useCallback)(()=>{we(``),Ee(`all`),Oe(`all`),Me(!1),Pe(null)},[]),Ot=!!(U||Te!==`all`||W!==`all`||Ne||ke),kt=I||!!Z,$=Je&&!!Xe;return S&&v.length===0?(0,q.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-background`,"aria-busy":`true`,children:[(0,q.jsxs)(`div`,{className:`border-b border-border/70 bg-card/70 px-5 py-4`,children:[(0,q.jsx)(`div`,{className:`h-3 w-28 animate-pulse bg-muted`}),(0,q.jsx)(`div`,{className:`mt-3 h-7 w-56 animate-pulse bg-muted`})]}),(0,q.jsxs)(`div`,{className:`grid flex-1 gap-px bg-border/60 md:grid-cols-[minmax(300px,0.82fr)_minmax(0,1.35fr)]`,children:[(0,q.jsx)(`div`,{className:`space-y-px bg-background p-4`,children:Array.from({length:7},(e,t)=>(0,q.jsx)(`div`,{className:`h-24 animate-pulse border border-border/60 bg-card/45`},t))}),(0,q.jsx)(`div`,{className:`hidden bg-background p-6 md:block`,children:(0,q.jsx)(`div`,{className:`h-full animate-pulse border border-border/60 bg-card/35`})})]}),(0,q.jsx)(`span`,{className:`sr-only`,role:`status`,children:e(`activity:memoryManager.loadingSageContent`)})]}):T&&v.length===0?(0,q.jsx)(`div`,{className:`flex h-full min-h-0 items-center justify-center bg-background p-6`,children:(0,q.jsxs)(`div`,{className:`max-w-md border border-destructive/35 bg-card p-6 shadow-2xl`,children:[(0,q.jsx)(`span`,{className:`flex size-11 items-center justify-center border border-destructive/35 bg-destructive/10 text-destructive`,children:(0,q.jsx)(f,{className:`size-5`})}),(0,q.jsx)(`h2`,{className:`mt-4 text-lg font-bold`,children:e(`activity:memoryManager.storeUnavailable`)}),(0,q.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-muted-foreground`,children:T}),(0,q.jsxs)(`div`,{className:`mt-5 flex gap-2`,children:[(0,q.jsxs)(F,{onClick:Q,children:[(0,q.jsx)(M,{className:`size-4`}),` `,e(`common:action.retry`)]}),(0,q.jsxs)(F,{variant:`outline`,onClick:()=>g(`chat`),children:[(0,q.jsx)(r,{className:`size-4`}),` `,e(`activity:memoryManager.backToChat`)]})]})]})}):(0,q.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-background`,children:[(0,q.jsxs)(`header`,{className:`relative shrink-0 overflow-hidden border-b border-border/70 bg-card/72 px-4 py-3 backdrop-blur-xl sm:px-5`,children:[(0,q.jsx)(`div`,{className:`pointer-events-none absolute inset-y-0 right-0 w-1/2 bg-[radial-gradient(circle_at_right,hsl(var(--info)/0.11),transparent_68%)]`}),(0,q.jsxs)(`div`,{className:`relative flex flex-wrap items-center gap-3`,children:[(0,q.jsx)(F,{variant:`ghost`,size:`icon`,onClick:()=>g(`chat`),"aria-label":e(`activity:memoryManager.backToChat`),title:e(`activity:memoryManager.backToChat`),children:(0,q.jsx)(r,{className:`size-4`})}),(0,q.jsx)(`span`,{className:`flex size-10 items-center justify-center border border-info/40 bg-info/10 text-info shadow-[0_0_20px_hsl(var(--info)/0.12)]`,children:(0,q.jsx)(C,{className:`size-5`})}),(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`h1`,{className:`text-base font-bold sm:text-lg`,children:e(`activity:memoryManager.sageHeading`)}),(0,q.jsx)(`span`,{className:`border border-success/35 bg-success/10 px-2 py-0.5 font-mono text-[9px] font-bold uppercase text-success`,children:e(`activity:memoryManager.projectKnowledge`)})]}),(0,q.jsx)(`p`,{className:`mt-0.5 max-w-2xl text-[10px] text-muted-foreground sm:text-xs`,children:e(`activity:memoryManager.sageSubtitle`)})]}),(0,q.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,q.jsxs)(`span`,{className:N(`hidden items-center gap-1.5 border px-2 py-1 font-mono text-[9px] uppercase sm:flex`,h?`border-success/30 text-success`:`border-warning/30 text-warning`),children:[(0,q.jsx)(`span`,{className:`size-1.5 bg-current`}),` `,e(h?`activity:memoryManager.liveStore`:`activity:memoryManager.reconnecting`)]}),(0,q.jsxs)(F,{variant:`outline`,size:`sm`,onClick:Q,disabled:ee,"aria-label":e(`activity:memoryManager.refreshAria`),children:[(0,q.jsx)(M,{className:N(`size-3.5`,ee&&`animate-spin`)}),(0,q.jsx)(`span`,{className:`hidden sm:inline`,children:e(`common:action.refresh`)})]}),(0,q.jsxs)(F,{size:`sm`,onClick:ht,children:[(0,q.jsx)(se,{className:`size-3.5`}),` `,e(`activity:memoryManager.newMemory`)]})]})]})]}),(0,q.jsxs)(`div`,{className:`grid shrink-0 grid-cols-2 gap-px border-b border-border/70 bg-border/60 sm:grid-cols-4`,children:[(0,q.jsx)(De,{label:e(`activity:memoryManager.tabMemories`),value:b?.total??v.length,hint:`${wt.length} visible`}),(0,q.jsx)(De,{label:e(`activity:memoryManager.tabActive`),value:b?.byStatus.active??v.filter(e=>e.status===`active`).length,hint:`retrievable`,tone:`success`}),(0,q.jsx)(De,{label:e(`activity:memoryManager.tabNeedsReview`),value:(b?.byStatus.stale??0)+(b?.byStatus.contradicted??0),hint:e(`activity:memoryManager.staleConflicts`),tone:`warning`}),(0,q.jsx)(`div`,{className:`hidden sm:block`,children:(0,q.jsx)(De,{label:e(`activity:memoryManager.tabGraphEdges`),value:b?.edges??0,hint:`${Tt.length} tags`,tone:`info`})})]}),(()=>{let e=v.filter(e=>e.audience).length;if(e===0)return null;let t=new Set;for(let e of v)if(e.audience){for(let n of e.audience.roles??[])t.add(n);for(let n of e.audience.taskTypes??[])t.add(n);for(let n of e.audience.modes??[])t.add(n)}return(0,q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-border/70 bg-primary/5 px-4 py-1.5`,children:[(0,q.jsx)(C,{className:`size-3.5 text-primary`}),(0,q.jsxs)(`span`,{className:`text-[11px] font-medium text-primary`,children:[e,` audience-scoped memory`,e===1?``:`ies`]}),t.size>0&&(0,q.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`(`,[...t].sort().join(`, `),`)`]})]})})(),(O||T||E)&&(0,q.jsxs)(`div`,{className:`shrink-0 border-b border-border/70 px-4 py-2`,"aria-live":`polite`,children:[O&&(0,q.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2 text-xs text-success`,children:[(0,q.jsx)(ae,{className:`size-3.5`}),` `,O]}),T&&(0,q.jsxs)(`div`,{role:`alert`,className:`flex items-center gap-2 text-xs text-warning`,children:[(0,q.jsx)(f,{className:`size-3.5`}),` `,T,` Existing content remains available.`]}),E&&!ge&&!I&&(0,q.jsxs)(`div`,{role:`alert`,className:`flex items-center gap-2 text-xs text-destructive`,children:[(0,q.jsx)(f,{className:`size-3.5`}),` `,E]})]}),(0,q.jsxs)(`div`,{className:`grid min-h-0 flex-1 md:grid-cols-[minmax(320px,0.82fr)_minmax(0,1.35fr)]`,children:[(0,q.jsxs)(`section`,{className:N(`min-h-0 border-r border-border/70 bg-card/25`,kt?`hidden md:flex md:flex-col`:`flex flex-col`),"aria-label":e(`activity:memoryManager.libraryAria`),children:[(0,q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 border-b border-border/60 px-3 pt-1`,role:`tablist`,"aria-label":e(`activity:memoryManager.viewAria`),children:[(0,q.jsx)(F,{type:`button`,variant:`ghost`,size:`sm`,role:`tab`,"aria-selected":Fe===`active`,onClick:()=>Ie(`active`),className:N(`h-7 rounded-b-none border-b-2 px-3 text-[11px]`,Fe===`active`?`border-primary text-foreground`:`border-transparent text-muted-foreground`),children:e(`activity:memoryManager.tabActive`)}),(0,q.jsx)(F,{type:`button`,variant:`ghost`,size:`sm`,role:`tab`,"aria-selected":Re,onClick:()=>Ie(`review`),className:N(`h-7 rounded-b-none border-b-2 px-3 text-[11px]`,Re?`border-primary text-foreground`:`border-transparent text-muted-foreground`),children:e(`activity:memoryManager.tabReview`)}),(0,q.jsxs)(F,{type:`button`,variant:`ghost`,size:`sm`,role:`tab`,"aria-selected":Le,onClick:()=>Ie(`deleted`),className:N(`h-7 rounded-b-none border-b-2 px-3 text-[11px]`,Le?`border-primary text-foreground`:`border-transparent text-muted-foreground`),children:[e(`activity:memoryManager.tabDeleted`),typeof Ke.deleted==`number`?` (${Ke.deleted})`:``]})]}),Re?(0,q.jsx)(it,{active:Re,client:t,listCandidates:i,resolveCandidate:m,onOpenMemory:gt}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)($e,{searchQuery:U,statusFilter:Te,kindFilter:W,audienceOnly:ke,tagFilter:Ne,hasFilters:Ot,allTags:Tt,stats:b,onSearchChange:we,onStatusFilterChange:Ee,onKindFilterChange:Oe,onToggleAudienceOnly:()=>Me(e=>!e),onTagFilterChange:Pe,onClearFilters:Dt}),(0,q.jsx)(tt,{memoryListRef:_,memories:v,filteredMemories:wt,selectedId:A,onSelectMemory:gt,onOpenCreate:ht,onClearFilters:Dt}),Ve?(0,q.jsx)(`div`,{className:`shrink-0 border-t border-border/60 p-2`,children:(0,q.jsx)(F,{type:`button`,variant:`outline`,size:`sm`,onClick:ft,disabled:Ue,className:`h-7 w-full text-[11px]`,children:Ue?e(`common:action.loading`):`Load more (${v.length} loaded)`})}):null]})]}),(0,q.jsxs)(`section`,{className:N(`min-h-0 bg-background`,kt?`flex flex-col`:`hidden md:flex md:flex-col`),"aria-label":e(`activity:memoryManager.detailAria`),children:[v.some(e=>(e.anchors??[]).some(e=>e.type===`file`&&e.path))&&(0,q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-border/60 bg-card/30 px-3 py-1.5`,children:[(0,q.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:e(`activity:memoryManager.fileDrawerLabel`)}),(0,q.jsx)(`input`,{type:`text`,list:`memory-drawer-file-list`,value:Xe??``,onChange:e=>{let t=e.target.value.trim()||null;t&<.has(t)?(Ze(t),Ye(!0)):Ze(t||null)},placeholder:e(`activity:memoryManager.selectFilePlaceholder`),className:`min-w-0 max-w-[260px] flex-1 truncate rounded-sm border border-border/60 bg-background px-1.5 py-0.5 text-[10px] font-mono`,"aria-label":e(`activity:memoryManager.fileForDrawerAria`),"data-testid":`memory-drawer-file-select`}),(0,q.jsx)(`datalist`,{id:`memory-drawer-file-list`,children:[...lt].sort().map(e=>(0,q.jsx)(`option`,{value:e},e))}),(0,q.jsxs)(F,{type:`button`,size:`sm`,variant:$?`default`:`outline`,onClick:()=>{Xe&&Ye(e=>!e)},disabled:!Xe,className:`h-7 shrink-0 gap-1 px-2 text-[11px]`,"aria-pressed":$,title:e($?`activity:memoryManager.hideFileDrawer`:`activity:memoryManager.showFileDrawer`),children:[$?(0,q.jsx)(l,{className:`size-3`}):(0,q.jsx)(s,{className:`size-3`}),e($?`activity:memoryManager.hideDrawer`:`activity:memoryManager.showDrawer`)]})]}),I?(0,q.jsx)(Qe,{mode:`create`,draft:R,busy:B===`create`,error:E,onChange:ye,onCancel:vt,onSubmit:bt}):Z?ge?(0,q.jsx)(Qe,{mode:`edit`,draft:R,busy:B===`update`,error:E,onChange:ye,onCancel:vt,onSubmit:xt}):$?(0,q.jsx)(Ae,{filePath:Xe,open:$,onClose:()=>Ye(!1),onShowMemory:e=>j(e),onAcceptDeletion:(e,t)=>{Ct(`memory.sage.candidateResolve`,()=>m({candidateId:e,action:`accept`}),n=>{if(n.error){D(n.error);return}k(`Accepted hygiene review for ${t.slice(0,12)}… (candidate ${e.slice(0,12)}…).`),Q()})},onKeep:(e,t)=>{Ct(`memory.sage.candidateResolve`,()=>m({candidateId:e,action:`reject`}),n=>{if(n.error){D(n.error);return}k(`Kept ${t.slice(0,12)}… (candidate ${e.slice(0,12)}… rejected).`),Q()})},onUpdate:e=>{_t(e)},onMarkPermanent:e=>{Ct(`memory.sage.update`,()=>c(e,{persistence:`permanent`}),t=>{if(t.error||!t.memory){D(t.error??`The server returned no memory record.`);return}k(`Memory ${e.slice(0,12)}… promoted to permanent.`),Q()})},onRecover:e=>{Ct(`memory.sage.recover`,()=>p({id:e,reason:`recovered via file drawer`}),t=>{if(t.error){D(t.error);return}k(`Recovered ${e.slice(0,12)}…`),Q()})}}):(0,q.jsx)(We,{memory:Z,allMemories:[...v,...oe],relatedMemories:Et,graphEdges:re,graphLoading:me,graphError:fe,onClose:()=>j(null),onOpenMemory:gt,onEdit:_t,onDelete:()=>H(Z.id),onTagSelect:e=>{Pe(e),j(null)},onNotice:k}):(0,q.jsx)(rt,{onCapture:ht})]})]}),(0,q.jsx)(je,{busyAction:B,deletingId:Ce,memories:v,onCancel:()=>H(null),onConfirm:St,onOpenChange:e=>{!e&&B!==`delete`&&H(null)}})]})}export{Y as MemoryManager};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{$n as t,Aa as n,Bn as r,Da as i,Gr as a,Ia as o,Ji as s,Ki as c,Mi as l,Na as u,Nt as d,Oi as f,Or as p,Qn as m,Sr as h,Va as g,Vt as _,Wn as v,Wr as y,Xn as b,Yr as x,Zn as S,_ as C,a as w,an as T,c as E,d as ee,da as D,dt as O,ei as k,f as te,gi as A,gr as j,h as ne,i as re,in as M,ji as N,jn as ie,ki as ae,kr as oe,l as se,lt as ce,m as le,mt as ue,o as de,oa as fe,p as pe,pt as P,r as me,rr as he,s as ge,sn as F,sr as I,ta as L,u as R,ut as _e,v as z,vi as ve,xi as ye,xt as be,yt as xe,za as B}from"./vendor-AeHpGMaG.js";import"./i18n-nlW2iAya.js";import{s as Se}from"./ws-client-B7j8isQb.js";import{t as V}from"./utils-D1fGupR8.js";import{t as Ce}from"./session-store-DkPaOIhe.js";import{T as we,d as H,f as Te,x as Ee}from"./stores-BpVw7ENx.js";import{r as De}from"./mailbox-store-BuLRsYu3.js";import{d as Oe}from"./markdown-sSmz-Ua_.js";import{S as ke,_ as Ae,d as je,f as Me,g as Ne,l as Pe,u as Fe}from"./index-eK0iH6jY.js";var U=e(g(),1);function Ie(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function Le(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function W(e){return typeof e==`string`&&e.trim()?e.trim():void 0}function G(e,t){for(let n of t){let t=W(e[n]);if(t)return t}}function K(e,t){for(let n of t){let t=Le(e[n]);if(t!==void 0)return t}}function Re(e){return e.split(/[\\/]/).filter(Boolean).pop()??e}function ze(e){return e?e.split(/\r?\n/).length:0}function Be(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 Ve(e){let t=e.split(/\r?\n/,1)[0]?.trim()??e;return t.length>72?`${t.slice(0,69)}…`:t}function He(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 Ue(e,t){let n=(Array.isArray(e.fileTargets)?e.fileTargets:[]).flatMap(e=>{let t=Ie(e),n=G(t,[`filePath`,`file_path`,`path`]);return n?[{filePath:n,operation:W(t.operation),line:K(t,[`line`,`startLine`,`start_line`]),endLine:K(t,[`endLine`,`end_line`])}]:[]});if(n.length>0)return n;let r=G(t,[`file_path`,`filePath`,`path`,`filename`,`target_file`,`targetFile`]);return r?[{filePath:r,line:K(t,[`line`,`start_line`,`startLine`,`offset`]),endLine:K(t,[`end_line`,`endLine`])}]:[]}function We(e,t){let n=e?.line??K(t,[`line`,`start_line`,`startLine`,`offset`]),r=e?.endLine??K(t,[`end_line`,`endLine`]),i=K(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 Ge(e,t,n,r,i,a){let o=We(a,n),s=a?.filePath??G(n,[`file_path`,`filePath`,`path`,`filename`]),c=s?Re(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=G(n,[`content`,`text`,`data`]),t=K(r,[`inputLines`])??(e?ze(e):void 0);return{target:s,summary:t===void 0?`Writing file`:`${t.toLocaleString()} lines written`,lineLabel:o.label}}if(e===`edit`){let e=G(n,[`patch`,`diff`]),t=e?Be(e):null,i=G(n,[`old_string`,`oldString`,`search`]),a=G(n,[`new_string`,`newString`,`replacement`]),c=K(r,[`addedLines`]),l=K(r,[`removedLines`]),u=K(r,[`oldLines`]),d=K(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?ze(i):u??0} → ${a?ze(a):d??0} lines`:o.label?`${o.label} updated`:`Updating file`,lineLabel:o.label}}if(e===`terminal`){let e=G(n,[`command`,`cmd`,`script`,`shell`])??t;return{summary:Ve(e),target:e}}if(e===`web`){let e=G(n,[`url`,`href`,`uri`]),t=G(n,[`query`,`q`,`search`]);return{target:e??t,summary:e?`Fetched ${e}`:t?`Looked up “${t}”`:`Went online`}}if(e===`search`){let e=G(n,[`query`,`pattern`,`q`,`search`])??c;return{target:s??e,summary:e?`Searched “${e}”`:`Searching project`}}if(e===`memory`){let e=G(n,[`query`,`text`,`key`]);return{target:e,summary:e?`Recalled “${e}”`:`Checking memory`}}return{target:s,summary:c?`${t} · ${c}`:t}}function Ke(e,t){let n=W(t.name)??W(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 qe(e,t,n){return W(t.agentId)??W(t.subagentId)??(e.kind===`agent:tool`?e.source:void 0)??(e.source!==n&&e.source!==`filesystem`?e.source:void 0)??`leader`}function Je(e){return W(e.parentSessionId)??W(e.sessionId)}function Ye(e,t){return e.kind===`tool:started`||e.kind===`tool:progress`?`running`:t.ok===!1?`failed`:`succeeded`}function Xe(e){if(![`tool:started`,`tool:progress`,`tool:executed`,`agent:tool`].includes(e.kind))return null;let t=Ie(e.data),n=Ke(e,t);if(!n)return null;let r=qe(e,t,n),i=t.input,a=Ie(i),o=Ue(t,a),s=Le(t.outputLines),c=He(n),l=Ge(c,n,a,t,s,o[0]),u=W(t.id),d=Math.floor(e.timestamp/2e3),f=Ye(e,t),p=Le(t.durationMs);return{id:u?`${r}:${u}`:`${r}:${n}:${d}`,agentId:r,agentName:W(t.agentName),sessionId:Je(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:Le(t.outputBytes),outputTokens:Le(t.outputTokens),input:i,output:W(t.output),fileTargets:o,raw:e.raw??t}}function Ze(e,t,n){return e?.length?nt(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 Qe(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 $e(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=q(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(q(e.from)),c=r.get(q(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 et(e,t){return e.toLowerCase()===t.toLowerCase()}function q(e){return e?.trim().toLowerCase()??``}function tt(e,t,n){let r=new Set([t.serverId,t.mailboxId,t.name].map(q).filter(e=>e.length>0)),i=n?`@session:${q(n)}`:``,a=q(t.role),o=q(t.serverId)===`leader`||q(t.serverId).startsWith(`leader@`)||a===`lead`||a===`leader`;return e.flatMap(e=>{let t=q(e.from),n=q(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(q(e)))}]}).sort((e,t)=>t.timestampMs-e.timestampMs).slice(0,8)}function nt(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=Xe(a);if(!o||!et(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 rt(e,t,n){let r=He(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:[]}}var J=ce(),it={read:T,write:k,edit:k,terminal:_,web:A,search:y,memory:S,other:f};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 ot(e){return e===void 0?`—`:e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(+(e<1e4))} s`}function st(e){if(e===void 0)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Y({label:e,value:t}){return(0,J.jsxs)(`div`,{className:`agent-office__detail-row`,children:[(0,J.jsx)(`span`,{children:e}),(0,J.jsx)(`strong`,{children:t})]})}function ct({selected:e,onClose:t}){let{t:n}=o(),{call:r,agentName:i}=e,a=it[r.kind],s=st(r.input),c=st(r.output);return(0,J.jsxs)(`aside`,{className:`agent-office__detail`,"aria-label":`${r.toolName} details`,children:[(0,J.jsxs)(`div`,{className:`agent-office__detail-header`,children:[(0,J.jsx)(`div`,{className:V(`agent-office__detail-icon`,`is-${r.kind}`),children:(0,J.jsx)(a,{"aria-hidden":`true`})}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{children:n(`activity:agentOffice.toolCall`)}),(0,J.jsx)(`h2`,{children:r.toolName})]}),(0,J.jsx)(`button`,{type:`button`,onClick:t,"aria-label":n(`activity:agentOffice.closeDetails`),children:(0,J.jsx)(O,{})})]}),(0,J.jsxs)(`div`,{className:`agent-office__detail-status`,children:[(0,J.jsx)(`span`,{className:V(`agent-office__status-dot`,r.status===`running`&&`is-active`,r.status===`failed`&&`is-failed`)}),(0,J.jsx)(`strong`,{children:r.summary}),(0,J.jsx)(`span`,{children:r.status})]}),(0,J.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,J.jsx)(`h3`,{children:n(`activity:agentOffice.execution`)}),(0,J.jsx)(Y,{label:n(`activity:agentOffice.agent`),value:i}),(0,J.jsx)(Y,{label:n(`activity:agentOffice.started`),value:new Date(r.startedAt).toLocaleTimeString()}),(0,J.jsx)(Y,{label:n(`activity:agentOffice.duration`),value:ot(r.durationMs)}),r.sessionId&&(0,J.jsx)(Y,{label:n(`activity:agentOffice.session`),value:at(r.sessionId,28)})]}),(r.target||r.fileTargets.length>0)&&(0,J.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,J.jsx)(`h3`,{children:n(`activity:agentOffice.target`)}),r.target&&(0,J.jsx)(`code`,{className:`agent-office__target-code`,children:r.target}),r.fileTargets.map((e,t)=>(0,J.jsxs)(`div`,{className:`agent-office__file-target`,children:[(0,J.jsx)(x,{"aria-hidden":`true`}),(0,J.jsx)(`span`,{children:e.filePath}),(e.line||e.endLine)&&(0,J.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,J.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,J.jsx)(`h3`,{children:n(`activity:agentOffice.resultSize`)}),(0,J.jsxs)(`div`,{className:`agent-office__metric-grid`,children:[r.outputLines!==void 0&&(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`strong`,{children:r.outputLines.toLocaleString()}),(0,J.jsx)(`span`,{children:n(`activity:agentOffice.lines`)})]}),r.outputBytes!==void 0&&(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`strong`,{children:r.outputBytes.toLocaleString()}),(0,J.jsx)(`span`,{children:n(`activity:agentOffice.bytes`)})]}),r.outputTokens!==void 0&&(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`strong`,{children:[`≈`,r.outputTokens.toLocaleString()]}),(0,J.jsx)(`span`,{children:n(`activity:agentOffice.tokens`)})]})]})]}),s&&(0,J.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,J.jsx)(`h3`,{children:n(`activity:agentOffice.input`)}),(0,J.jsx)(`pre`,{children:(0,J.jsx)(`code`,{children:s})})]}),c&&(0,J.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,J.jsx)(`h3`,{children:n(`activity:agentOffice.outputPreview`)}),(0,J.jsx)(`pre`,{children:(0,J.jsx)(`code`,{children:c})})]})]})}function lt({selected:e,onClose:n}){let{t:r}=o(),{mail:i,agentName:a}=e;return(0,J.jsxs)(`aside`,{className:`agent-office__detail`,"aria-label":`${i.subject} details`,children:[(0,J.jsxs)(`div`,{className:`agent-office__detail-header`,children:[(0,J.jsx)(`div`,{className:`agent-office__detail-icon is-mail`,children:(0,J.jsx)(t,{"aria-hidden":`true`})}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{children:i.direction===`incoming`?`INCOMING MAIL`:`OUTGOING MAIL`}),(0,J.jsx)(`h2`,{children:i.subject})]}),(0,J.jsx)(`button`,{type:`button`,onClick:n,"aria-label":r(`activity:agentOffice.closeMailDetails`),children:(0,J.jsx)(O,{})})]}),(0,J.jsxs)(`div`,{className:`agent-office__detail-status`,children:[(0,J.jsx)(`span`,{className:V(`agent-office__status-dot`,i.unread&&`is-active`)}),(0,J.jsxs)(`strong`,{children:[i.from,` → `,i.to]}),(0,J.jsx)(`span`,{children:i.type}),i.audience===`leaders`&&(0,J.jsxs)(`span`,{children:[(0,J.jsx)(he,{className:`h-3 w-3`}),` `,r(`activity:mailbox.audienceLeaders`)]})]}),(0,J.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,J.jsx)(`h3`,{children:r(`activity:mailbox.messages`)}),(0,J.jsx)(Y,{label:r(`activity:agentOffice.agent`),value:a}),(0,J.jsx)(Y,{label:r(`activity:agentOffice.started`),value:new Date(i.timestampMs).toLocaleTimeString()}),(0,J.jsx)(Y,{label:r(`activity:agentOffice.priority`),value:i.priority}),(0,J.jsx)(Y,{label:r(`activity:agentOffice.route`),value:`${i.from} → ${i.to}`})]}),(0,J.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,J.jsx)(`h3`,{children:i.subject}),(0,J.jsx)(`div`,{className:`agent-office__mail-body`,children:i.body})]})]})}function ut({selected:e,onClose:t}){let{t:n}=o();return(0,J.jsxs)(`aside`,{className:`agent-office__detail`,"aria-label":`${e.agentName} task details`,children:[(0,J.jsxs)(`div`,{className:`agent-office__detail-header`,children:[(0,J.jsx)(`div`,{className:`agent-office__detail-icon is-task`,children:(0,J.jsx)(I,{"aria-hidden":`true`})}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{children:n(`activity:agentOffice.currentTask`)}),(0,J.jsx)(`h2`,{children:e.agentName})]}),(0,J.jsx)(`button`,{type:`button`,onClick:t,"aria-label":n(`activity:agentOffice.closeTaskDetails`),children:(0,J.jsx)(O,{})})]}),(0,J.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,J.jsx)(`h3`,{children:n(`activity:agentOffice.task`)}),e.taskId&&(0,J.jsx)(Y,{label:`ID`,value:e.taskId}),(0,J.jsx)(`div`,{className:`agent-office__task-body`,children:e.task})]})]})}function dt({selected:e,onClose:t}){let{t:n}=o(),r=e.todos.filter(e=>e.status!==`completed`).length;return(0,J.jsxs)(`aside`,{className:`agent-office__detail`,"aria-label":`${e.officeLabel} briefing`,children:[(0,J.jsxs)(`div`,{className:`agent-office__detail-header`,children:[(0,J.jsx)(`div`,{className:`agent-office__detail-icon is-briefing`,children:(0,J.jsx)(b,{"aria-hidden":`true`})}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{children:e.instructionActive?n(`activity:agentOffice.activeInstruction`):n(`activity:agentOffice.officeBriefing`)}),(0,J.jsx)(`h2`,{children:e.officeLabel})]}),(0,J.jsx)(`button`,{type:`button`,onClick:t,"aria-label":n(`activity:agentOffice.closeOfficeBriefing`),children:(0,J.jsx)(O,{})})]}),(0,J.jsxs)(`div`,{className:`agent-office__detail-status`,children:[(0,J.jsx)(`span`,{className:V(`agent-office__status-dot`,(e.instructionActive||r>0)&&`is-active`)}),(0,J.jsx)(`strong`,{children:e.telemetryConnected?n(`activity:agentOffice.activeTodos`):n(`activity:agentOffice.telemetryWaiting`)}),(0,J.jsx)(`span`,{children:e.telemetryConnected?r:`—`})]}),(0,J.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,J.jsx)(`h3`,{children:e.instructionActive?n(`activity:agentOffice.activeInstruction`):n(`activity:agentOffice.leaderPrompt`)}),e.promptAt!==void 0&&(0,J.jsx)(Y,{label:n(`activity:agentOffice.promptReceived`),value:new Date(e.promptAt).toLocaleString()}),(0,J.jsx)(`div`,{className:`agent-office__task-body`,children:e.prompt??(e.telemetryConnected?n(`activity:agentOffice.noPrompt`):n(`activity:agentOffice.telemetryWaiting`))})]}),(0,J.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,J.jsx)(`h3`,{children:n(`activity:agentOffice.todos`)}),(0,J.jsx)(`div`,{className:`agent-office__todo-detail-list`,children:e.telemetryConnected?e.todos.length>0?e.todos.map(e=>(0,J.jsxs)(`div`,{className:V(`agent-office__todo-detail`,`is-${e.status}`),children:[(0,J.jsx)(`span`,{"aria-hidden":`true`}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`strong`,{children:e.content}),(0,J.jsx)(`small`,{children:n(`activity:agentOffice.todoStatus.${e.status}`)})]})]},e.id)):(0,J.jsx)(`span`,{className:`agent-office__history-empty`,children:n(`activity:agentOffice.noActiveTodos`)}):(0,J.jsx)(`span`,{className:`agent-office__history-empty`,children:n(`activity:agentOffice.todoTelemetryWaiting`)})})]})]})}function ft({selected:e,onClose:t}){return e.kind===`tool`?(0,J.jsx)(ct,{selected:e,onClose:t}):e.kind===`mail`?(0,J.jsx)(lt,{selected:e,onClose:t}):e.kind===`task`?(0,J.jsx)(ut,{selected:e,onClose:t}):(0,J.jsx)(dt,{selected:e,onClose:t})}function pt(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 mt(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 ht(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 gt(e){if(!e)return;let t=e.split(`/`);return t[t.length-1]?.slice(0,18)}function _t(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 vt(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 yt(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 bt(e){return e===`tui`?`tui`:e===`repl`||e===`cli`?`repl`:`webui`}function xt(e){return e===`tui`?`TUI`:e===`repl`?`REPL`:`WebUI`}function St(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 Ct(e){if(e)return e.split(`/`).filter(Boolean).pop()??e}function wt(e){let t=Ct(e)??e??``;return t.length>10?`…${t.slice(-8)}`:t}function Tt(e,t){let n=Ct(t);if(n)return e.find(e=>Ct(e.sessionId)===n)}function Et(e,t){let n=St(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 Dt(e,t){return e===`cli`?`CLI`:e===`repl`?`REPL`:xt(t)}function Ot(e,t,n=[],r=new Map,i=Date.now()){let a=new Set,o=[];for(let n of e){let e=bt(n.clientType),r=Dt(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=St(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}`:wt(n.sessionId)}`,sublabel:[`session ${wt(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=Tt(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=Tt(o,e.sessionId)??l(),n=Et(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=Tt(o,t.agent.sessionId);n&&n.agents.push(Et(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 kt(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 At=new Set([`completed`,`failed`,`timeout`,`stopped`]);function jt(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),At.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)&&!At.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 Mt=[`bot`,`cactus`,`duck`,`radio`],Nt={leader:`plum`,builder:`ocean`,researcher:`mint`,reviewer:`rose`,planner:`amber`,operator:`graphite`},Pt={leader:0,builder:1,researcher:2,reviewer:3,planner:4,operator:5},Ft={read:T,write:k,edit:k,terminal:_,web:A,search:y,memory:S,other:f},It={leader:fe,builder:f,researcher:T,reviewer:L,planner:I,operator:_};function Lt(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 Rt(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:Nt[t],layout:r%4,clutter:Math.floor(r/4)%3,avatar:Pt[t],motion:Math.floor(r/31)%4,charm:Mt[Math.floor(r/47)%Mt.length]}}function zt(e,t=22){let n=e.split(`/`).filter(Boolean).pop()??e;return n.length>t?`${n.slice(0,t-1)}…`:n}function Bt(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 Vt(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 Ht(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 Ut(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 Wt(e,t,n){return n.map((n,r)=>({...rt(e.serverId,n.name,t.sessionId),id:`${e.serverId}:log:${n.at}:${r}`,kind:He(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 Gt(...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 Kt(...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 qt({kind:e,active:t}){let n=Ft[e];return(0,J.jsxs)(`span`,{className:V(`agent-office__tool-glyph`,`is-${e}`,t&&`is-active`),children:[e===`read`&&(0,J.jsx)(x,{className:`agent-office__file-underlay`,"aria-hidden":`true`}),(0,J.jsx)(n,{"aria-hidden":`true`})]})}function Jt({active:e,failed:t,role:n,variant:r,motion:i}){let a=It[n];return(0,J.jsxs)(`div`,{className:V(`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,J.jsx)(`span`,{className:`agent-office__avatar-chair`}),(0,J.jsx)(`span`,{className:`agent-office__avatar-body`}),(0,J.jsxs)(`span`,{className:`agent-office__avatar-head`,children:[(0,J.jsx)(`span`,{className:`agent-office__avatar-hair`}),(0,J.jsx)(`span`,{className:`agent-office__avatar-face`}),(0,J.jsx)(`span`,{className:`agent-office__avatar-mouth`}),(0,J.jsx)(`span`,{className:`agent-office__avatar-headset`})]}),(0,J.jsx)(`span`,{className:`agent-office__avatar-arm`}),(0,J.jsx)(`span`,{className:`agent-office__avatar-prop`}),(0,J.jsx)(`span`,{className:`agent-office__avatar-role-badge`,children:(0,J.jsx)(a,{})})]})}function Yt({call:e,compact:t=!1,onSelect:n}){let r=e.status===`running`;return(0,J.jsxs)(`button`,{type:`button`,className:V(`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,J.jsx)(qt,{kind:e.kind,active:r}),(0,J.jsxs)(`span`,{className:`agent-office__parcel-copy`,children:[(0,J.jsxs)(`span`,{className:`agent-office__parcel-topline`,children:[(0,J.jsx)(`strong`,{children:e.toolName}),e.lineLabel&&(0,J.jsx)(`span`,{className:`agent-office__line-chip`,children:e.lineLabel})]}),!t&&e.target&&(0,J.jsx)(`span`,{className:`agent-office__parcel-target`,children:Bt(e.target)}),(0,J.jsx)(`span`,{className:`agent-office__parcel-summary`,children:e.summary})]}),(0,J.jsx)(`span`,{className:`agent-office__parcel-state`,"aria-hidden":`true`,children:r?(0,J.jsx)(`span`,{className:`agent-office__pulse-dot`}):e.status===`failed`?(0,J.jsx)(O,{}):(0,J.jsx)(L,{})})]})}function Xt({mail:e,compact:n=!1,onSelect:r}){let i=e.direction===`incoming`;return(0,J.jsxs)(`button`,{type:`button`,className:V(`agent-office__mail-parcel`,n&&`is-compact`,i?`is-incoming`:`is-outgoing`,e.unread&&`is-unread`),onClick:r,"aria-label":`${i?`Incoming`:`Outgoing`} mail: ${e.subject}`,children:[(0,J.jsx)(`span`,{className:`agent-office__mail-icon`,children:i?(0,J.jsx)(h,{"aria-hidden":`true`}):(0,J.jsx)(M,{"aria-hidden":`true`})}),(0,J.jsxs)(`span`,{className:`agent-office__parcel-copy`,children:[(0,J.jsx)(`strong`,{children:i?`${e.from} →`:`→ ${e.to}`}),(0,J.jsx)(`span`,{className:`agent-office__parcel-summary`,children:e.subject})]}),(0,J.jsx)(t,{"aria-hidden":`true`})]})}function Zt({office:e,now:r}){let{t:i}=o(),{client:s,agents:c,stats:u}=e,d=s.lastHeartbeatAt?Date.parse(s.lastHeartbeatAt):NaN,f=Number.isFinite(d)&&r-d<2e4,p=Number.isFinite(d)&&!f,m=c.some(({agent:e})=>e.presenceSource===`registry`),h=f?`VERIFIED`:p?`DELAYED`:m?`REGISTRY`:`LOCAL`,g=c.some(({agent:e})=>e.recentTools!==void 0||e.activity!==void 0),v=c.some(({agent:e})=>e.toolCalls>0&&e.recentTools===void 0&&e.activity===void 0);return(0,J.jsxs)(`header`,{className:`agent-office__client-header`,children:[(0,J.jsxs)(`div`,{className:`agent-office__client-title`,children:[(0,J.jsx)(`span`,{className:`agent-office__client-icon`,children:(0,J.jsx)(fe,{"aria-hidden":`true`})}),(0,J.jsxs)(`div`,{className:`agent-office__client-copy`,children:[(0,J.jsx)(`strong`,{children:s.label}),(0,J.jsx)(`span`,{children:s.sublabel||s.sessionId})]}),(0,J.jsxs)(`div`,{className:`agent-office__client-presence`,children:[(0,J.jsxs)(`span`,{className:`agent-office__client-agent-count`,children:[c.length,` `,i(`activity:agentOffice.agents`)]}),(0,J.jsxs)(`span`,{className:V(`agent-office__presence-chip`,!p&&`is-live`,p&&`is-legacy`),children:[(0,J.jsx)(P,{"aria-hidden":`true`}),` `,h]}),(0,J.jsxs)(`span`,{className:`agent-office__presence-chip`,children:[(0,J.jsx)(l,{"aria-hidden":`true`}),` `,Ht(s.startedAt,r),` UP`]}),(0,J.jsxs)(`span`,{className:V(`agent-office__presence-chip`,v?`is-legacy`:g&&`is-telemetry`),children:[(0,J.jsx)(n,{"aria-hidden":`true`}),v?`RECONNECT`:g?`TOOLS LIVE`:`READY`]})]})]}),(0,J.jsxs)(`fieldset`,{className:`agent-office__client-stats`,"aria-label":i(`activity:agentOffice.sessionActivityTotals`),children:[(0,J.jsxs)(`span`,{title:i(`activity:agentOffice.uniqueFilesTouched`),children:[(0,J.jsx)(a,{}),` `,(0,J.jsx)(`strong`,{children:u.files}),` `,i(`activity:agentOffice.files`)]}),(0,J.jsxs)(`span`,{title:i(`activity:agentOffice.fileReads`),children:[(0,J.jsx)(T,{}),` `,(0,J.jsx)(`strong`,{children:u.reads}),` `,i(`activity:agentOffice.read`)]}),(0,J.jsxs)(`span`,{title:i(`activity:agentOffice.filesWritten`),children:[(0,J.jsx)(k,{}),` `,(0,J.jsx)(`strong`,{children:u.writes}),` `,i(`activity:agentOffice.write`)]}),(0,J.jsxs)(`span`,{title:i(`activity:agentOffice.filesEdited`),children:[(0,J.jsx)(k,{}),` `,(0,J.jsx)(`strong`,{children:u.edits}),` `,i(`activity:agentOffice.edit`)]}),(0,J.jsxs)(`span`,{className:`agent-office__client-delta`,title:i(`activity:agentOffice.linesAddedAndRemoved`),children:[(0,J.jsxs)(`strong`,{children:[`+`,u.linesAdded]}),` / `,(0,J.jsxs)(`b`,{children:[`−`,u.linesRemoved]})]}),(0,J.jsxs)(`span`,{title:i(`activity:agentOffice.terminalCommands`),children:[(0,J.jsx)(_,{}),` `,(0,J.jsx)(`strong`,{children:u.terminalCalls}),` `,i(`activity:agentOffice.term`)]}),(0,J.jsxs)(`span`,{title:i(`activity:agentOffice.incomingAndOutgoingMail`),children:[(0,J.jsx)(t,{}),` `,(0,J.jsx)(`strong`,{children:u.incomingMail}),`↓ `,(0,J.jsx)(`strong`,{children:u.outgoingMail}),`↑`]})]})]})}function Qt({office:e,now:t,onSelect:r}){let{t:i}=o(),{client:a}=e,s=a.todos!==void 0,l=a.todos??[],u=l.filter(e=>e.status!==`completed`),d=l.length-u.length,f=!!a.activeInstruction,p=a.activeInstruction??a.latestPrompt,m=a.latestPromptAt!==void 0&&t-a.latestPromptAt<3e4,h=()=>r({kind:`briefing`,officeLabel:a.label,prompt:p,promptAt:a.latestPromptAt,instructionActive:f,telemetryConnected:s,todos:l});return(0,J.jsxs)(`section`,{className:`agent-office__briefing`,"aria-label":i(`activity:agentOffice.officeBriefing`),children:[(0,J.jsxs)(`button`,{type:`button`,className:V(`agent-office__prompt-card`,f&&`is-active`,m&&`is-fresh`,!s&&`is-waiting`),onClick:h,children:[(0,J.jsx)(`span`,{className:`agent-office__briefing-icon is-prompt`,children:(0,J.jsx)(b,{"aria-hidden":`true`})}),(0,J.jsxs)(`span`,{className:`agent-office__briefing-copy`,children:[(0,J.jsx)(`span`,{children:i(f?`activity:agentOffice.activeInstruction`:`activity:agentOffice.leaderPrompt`)}),(0,J.jsx)(`strong`,{children:p??i(s?`activity:agentOffice.noPrompt`:`activity:agentOffice.telemetryWaiting`)})]}),f&&(0,J.jsxs)(`span`,{className:`agent-office__instruction-live`,children:[(0,J.jsx)(`i`,{"aria-hidden":`true`}),` `,i(`activity:agentOffice.live`)]}),a.latestPromptAt!==void 0&&(0,J.jsx)(`time`,{dateTime:new Date(a.latestPromptAt).toISOString(),children:Vt(a.latestPromptAt,t)})]}),(0,J.jsxs)(`button`,{type:`button`,className:V(`agent-office__todo-board`,u.length>0&&`has-active`,!s&&`is-waiting`),onClick:h,children:[(0,J.jsxs)(`span`,{className:`agent-office__todo-heading`,children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(I,{"aria-hidden":`true`}),` `,i(`activity:agentOffice.activeTodos`)]}),(0,J.jsx)(`strong`,{children:s?i(`activity:agentOffice.todoProgress`,{done:d,total:l.length}):i(`activity:agentOffice.syncWaiting`)})]}),(0,J.jsxs)(`span`,{className:`agent-office__todo-preview`,children:[s?u.length>0?u.slice(0,3).map(e=>(0,J.jsxs)(`span`,{className:V(`agent-office__todo-line`,`is-${e.status}`),children:[(0,J.jsx)(`i`,{"aria-hidden":`true`}),(0,J.jsx)(`span`,{children:e.activeForm||e.content})]},e.id)):(0,J.jsxs)(`span`,{className:`agent-office__todo-empty`,children:[(0,J.jsx)(c,{"aria-hidden":`true`}),l.length>0?i(`activity:agentOffice.allTodosDone`):i(`activity:agentOffice.noActiveTodos`)]}):(0,J.jsxs)(`span`,{className:`agent-office__todo-empty is-waiting`,children:[(0,J.jsx)(n,{"aria-hidden":`true`}),i(`activity:agentOffice.todoTelemetryWaiting`)]}),u.length>3&&(0,J.jsx)(`span`,{className:`agent-office__todo-more`,children:i(`activity:agentOffice.moreTodos`,{count:u.length-3})})]})]})]})}function $t({active:e}){let{t}=o();return(0,J.jsxs)(`div`,{className:`agent-office__parcel agent-office__parcel--empty`,children:[(0,J.jsx)(`span`,{className:`agent-office__tool-glyph`,children:(0,J.jsx)(D,{"aria-hidden":`true`})}),(0,J.jsxs)(`span`,{className:`agent-office__parcel-copy`,children:[(0,J.jsx)(`strong`,{children:t(e?`activity:agentOffice.thinking`:`activity:agentOffice.waiting`)}),(0,J.jsx)(`span`,{children:t(e?`activity:agentOffice.preparing`:`activity:agentOffice.deskReady`)})]})]})}function en({model:e,now:r,onSelect:i,routedMailIds:a}){let{t:s}=o(),{agent:c,client:l,current:u,display:d,history:p,mail:m}=e,h=c.status===`active`||c.status===`streaming`,g=c.status===`error`,_=m[0],v=Lt(c),y=Rt(`${l.sessionId}:${c.serverId}:${c.name}`,v),b=_&&r-_.timestampMs<3e4&&!a?.has(_.id),x=p.slice(0,6),S=x[0]?.completedAt??x[0]?.startedAt??d?.completedAt??d?.startedAt,C=u?`is-tool-${u.kind}`:void 0;return(0,J.jsxs)(`article`,{className:V(`agent-office__lane`,`is-desk-${y.palette}`,`is-layout-${y.layout}`,`is-clutter-${y.clutter}`,h&&`is-active`,g&&`is-failed`),children:[(0,J.jsxs)(`div`,{className:`agent-office__identity`,children:[(0,J.jsxs)(`div`,{className:`agent-office__identity-line`,children:[(0,J.jsx)(`span`,{className:V(`agent-office__status-dot`,h&&`is-active`,g&&`is-failed`)}),(0,J.jsx)(`strong`,{title:c.name,children:c.name}),(0,J.jsxs)(`span`,{className:`agent-office__agent-verified`,title:c.presenceSource===`registry`?`Verified by live session registry`:`Verified by local fleet state`,children:[(0,J.jsx)(L,{"aria-hidden":`true`}),c.presenceSource===`registry`?`LIVE`:`LOCAL`]})]}),(0,J.jsx)(`span`,{className:`agent-office__role`,children:c.role??(c.serverId===`leader`||c.serverId.startsWith(`leader@`)?s(`activity:agentOffice.leadAgent`):s(`activity:agentOffice.agent`))}),(0,J.jsxs)(`div`,{className:`agent-office__agent-meta`,children:[(0,J.jsx)(`span`,{children:l.branch?`⎇ ${l.branch}`:l.type.toUpperCase()}),(0,J.jsx)(`span`,{children:s(`activity:agentOffice.callsCount`,{count:c.toolCalls})}),c.model&&(0,J.jsx)(`span`,{className:`agent-office__model-chip`,title:c.model,children:zt(c.model)})]}),c.currentTask&&(0,J.jsxs)(`button`,{type:`button`,className:`agent-office__agent-task`,onClick:()=>i({kind:`task`,task:c.currentTask??``,taskId:c.taskId,agentName:c.name}),children:[(0,J.jsx)(I,{"aria-hidden":`true`}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`strong`,{children:s(`activity:agentOffice.currentTask`)}),(0,J.jsx)(`small`,{children:c.currentTask})]})]}),!c.currentTask&&h&&(0,J.jsxs)(`div`,{className:`agent-office__agent-task is-missing`,children:[(0,J.jsx)(n,{"aria-hidden":`true`}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`strong`,{children:s(`activity:agentOffice.currentTask`)}),(0,J.jsx)(`small`,{children:l.todos===void 0?s(`activity:agentOffice.telemetryWaiting`):s(`activity:agentOffice.taskNotReported`)})]})]}),_&&(0,J.jsxs)(`button`,{type:`button`,className:V(`agent-office__identity-mail`,_.unread&&`is-unread`),onClick:()=>i({kind:`mail`,mail:_,agentName:c.name}),"aria-label":`${m.length} mail messages. Latest: ${_.subject}`,children:[(0,J.jsx)(t,{"aria-hidden":`true`}),(0,J.jsxs)(`span`,{children:[(0,J.jsxs)(`strong`,{children:[m.length,` MAIL`]}),(0,J.jsx)(`small`,{children:_.subject})]})]})]}),(0,J.jsxs)(`div`,{className:V(`agent-office__scene`,C),children:[(0,J.jsxs)(`div`,{className:`agent-office__window`,"aria-hidden":`true`,children:[(0,J.jsx)(`span`,{}),(0,J.jsx)(`span`,{}),(0,J.jsx)(`span`,{})]}),(0,J.jsxs)(`div`,{className:`agent-office__plant`,"aria-hidden":`true`,children:[(0,J.jsx)(`span`,{}),(0,J.jsx)(`i`,{}),(0,J.jsx)(`b`,{})]}),(0,J.jsxs)(`div`,{className:`agent-office__desk-zone`,"aria-hidden":`true`,children:[(0,J.jsx)(Jt,{active:h,failed:g,role:v,variant:y.avatar,motion:y.motion}),(0,J.jsx)(`span`,{className:`agent-office__monitor`,children:d?(0,J.jsx)(qt,{kind:d.kind,active:u!==void 0}):(0,J.jsx)(f,{})}),(0,J.jsxs)(`span`,{className:`agent-office__activity-fx`,children:[(0,J.jsx)(`span`,{}),(0,J.jsx)(`i`,{}),(0,J.jsx)(`b`,{})]}),(0,J.jsx)(`span`,{className:`agent-office__desk`}),(0,J.jsx)(`span`,{className:`agent-office__desk-lamp`}),(0,J.jsxs)(`span`,{className:`agent-office__desk-clutter`,children:[(0,J.jsx)(`i`,{}),(0,J.jsx)(`b`,{})]}),(0,J.jsxs)(`span`,{className:V(`agent-office__desk-charm`,`is-${y.charm}`),children:[(0,J.jsx)(`i`,{}),(0,J.jsx)(`b`,{})]}),(0,J.jsxs)(`span`,{className:V(`agent-office__mug`,`is-${v}`),children:[(0,J.jsx)(`i`,{"aria-hidden":`true`}),(0,J.jsx)(`b`,{"aria-hidden":`true`})]})]}),b&&(0,J.jsx)(`div`,{className:V(`agent-office__mail-flyby`,`is-${_.direction}`),children:(0,J.jsx)(Xt,{mail:_,compact:!0,onSelect:()=>i({kind:`mail`,mail:_,agentName:c.name})},_.id)}),(0,J.jsxs)(`div`,{className:V(`agent-office__conveyor`,u&&`is-moving`),children:[(0,J.jsxs)(`div`,{className:`agent-office__belt`,"aria-hidden":`true`,children:[(0,J.jsx)(`span`,{}),(0,J.jsx)(`span`,{}),(0,J.jsx)(`span`,{}),(0,J.jsx)(`span`,{}),(0,J.jsx)(`span`,{}),(0,J.jsx)(`span`,{})]}),(0,J.jsx)(`div`,{className:`agent-office__current-action`,children:d?(0,J.jsx)(Yt,{call:d,onSelect:()=>i({kind:`tool`,call:d,agentName:c.name})},d.id):(0,J.jsx)($t,{active:h})})]})]}),(0,J.jsxs)(`div`,{className:`agent-office__history`,children:[(0,J.jsxs)(`div`,{className:`agent-office__history-heading`,children:[(0,J.jsx)(`span`,{children:s(`activity:agentOffice.recent`)}),S!==void 0&&(0,J.jsx)(`span`,{children:Vt(S,r)})]}),(0,J.jsx)(`div`,{className:`agent-office__history-list`,children:x.length>0?x.map(e=>(0,J.jsx)(Yt,{call:e,compact:!0,onSelect:()=>i({kind:`tool`,call:e,agentName:c.name})},`tool:${e.id}`)):(0,J.jsx)(`span`,{className:`agent-office__history-empty`,children:c.toolCalls>0&&c.recentTools===void 0&&c.activity===void 0?s(`activity:agentOffice.telemetryReconnect`):s(`activity:agentOffice.noCalls`)})})]})]})}function tn(e){return e.agent.status===`active`||e.agent.status===`streaming`||e.agent.status===`error`}function nn({agents:e,now:n,onSelect:r}){let{t:i}=o();return(0,J.jsxs)(`section`,{className:`agent-office__lounge`,"aria-label":i(`activity:agentOffice.breakRoom`),children:[(0,J.jsxs)(`header`,{className:`agent-office__lounge-heading`,children:[(0,J.jsx)(ae,{"aria-hidden":`true`}),(0,J.jsx)(`strong`,{children:i(`activity:agentOffice.breakRoom`)}),(0,J.jsx)(`span`,{children:i(`activity:agentOffice.onBreak`,{count:e.length})})]}),(0,J.jsx)(`div`,{className:`agent-office__lounge-seats`,children:e.map(e=>{let{agent:a,history:o,mail:s}=e,c=Lt(a),l=It[c],u=s.filter(e=>e.unread).length,d=o[0]?.completedAt??o[0]?.startedAt,f=s[0],p=()=>{a.currentTask?r({kind:`task`,task:a.currentTask,taskId:a.taskId,agentName:a.name}):f&&r({kind:`mail`,mail:f,agentName:a.name})},m=!!a.currentTask||!!f;return(0,J.jsxs)(`button`,{type:`button`,className:V(`agent-office__lounge-seat`,`is-${c}`),onClick:p,disabled:!m,children:[(0,J.jsx)(`span`,{className:`agent-office__lounge-avatar`,children:(0,J.jsx)(l,{"aria-hidden":`true`})}),(0,J.jsxs)(`span`,{className:`agent-office__lounge-copy`,children:[(0,J.jsx)(`strong`,{children:a.name}),(0,J.jsx)(`small`,{children:a.role??i(`activity:agentOffice.agent`)})]}),(0,J.jsxs)(`span`,{className:`agent-office__lounge-meta`,children:[d!==void 0&&(0,J.jsx)(`span`,{children:Vt(d,n)}),u>0&&(0,J.jsxs)(`span`,{className:`agent-office__lounge-mail`,children:[(0,J.jsx)(t,{"aria-hidden":`true`}),` `,u]})]})]},e.key)})})]})}function rn(){let{t:e}=o(),r=Te(e=>e.liveSessions),i=Te(e=>e.aggregate),a=we(e=>e.agents),s=De(e=>e.agents),c=De(e=>e.messages),u=Se(e=>e.toolEvents),d=Ce(e=>e.projectName),f=jt(a),[p,m]=(0,U.useState)(null),h=(0,U.useMemo)(()=>Ot(r,a,s,f.map,f.now),[r,a,s,f]),g=(0,U.useMemo)(()=>h.flatMap(e=>e.agents.map(t=>{let n=Gt(nt(u,t.serverId,e.sessionId),Ze(t.recentTools,t.serverId,e.sessionId),Wt(t,e,a.get(t.serverId)?.toolLog??[])),r=t.status===`active`||t.status===`streaming`,i=n.find(e=>e.status===`running`);!i&&r&&t.currentTool&&(i=rt(t.serverId,t.currentTool,e.sessionId));let o=i??n[0],s=n.filter(e=>e.status!==`running`).slice(0,6),l=Kt(Qe(t.recentMail),tt(c,t,e.sessionId));return{key:t.officeId,client:e,agent:t,calls:n,current:i,display:o,history:s,mail:l}})),[h,a,c,u]),_=(0,U.useMemo)(()=>h.map(e=>{let t=g.filter(t=>t.client.id===e.id);return{client:e,agents:t,stats:Ut(t)}}).filter(e=>e.agents.length>0),[h,g]),v=g.filter(({agent:e})=>e.status===`active`||e.status===`streaming`).length,y=d||r.find(e=>e.projectName)?.projectName||e(`activity:office.fleetHq`),b=Date.now();return(0,J.jsxs)(`div`,{className:`agent-office`,children:[(0,J.jsxs)(`header`,{className:`agent-office__header`,children:[(0,J.jsxs)(`div`,{className:`agent-office__title`,children:[(0,J.jsx)(`span`,{className:`agent-office__brand-mark`,children:(0,J.jsx)(fe,{"aria-hidden":`true`})}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{children:e(`activity:agentOffice.liveProjectOffice`)}),(0,J.jsx)(`h1`,{children:y})]})]}),(0,J.jsxs)(`div`,{className:`agent-office__live-pill`,children:[(0,J.jsx)(`span`,{}),` `,e(`activity:agentOffice.live`)]}),(0,J.jsxs)(`div`,{className:`agent-office__summary`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(D,{}),(0,J.jsx)(`strong`,{children:g.length}),(0,J.jsx)(`span`,{children:e(`activity:agentOffice.agents`)})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(_e,{}),(0,J.jsx)(`strong`,{children:v}),(0,J.jsx)(`span`,{children:e(`activity:agentOffice.working`)})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(n,{}),(0,J.jsx)(`strong`,{children:i.toolCalls.toLocaleString()}),(0,J.jsx)(`span`,{children:e(`activity:agentOffice.toolCalls`)})]})]})]}),(0,J.jsx)(`main`,{className:`agent-office__floor`,children:g.length>0?_.map(n=>{let r=n.agents.filter(tn),i=n.agents.filter(e=>!tn(e)),a=$e(r,b),o=new Set(a.map(e=>e.id));return(0,J.jsxs)(`section`,{className:`agent-office__client-office`,children:[(0,J.jsx)(Zt,{office:n,now:b}),(0,J.jsx)(Qt,{office:n,now:b,onSelect:m}),r.length>0&&(0,J.jsxs)(`div`,{className:`agent-office__column-headings`,"aria-hidden":`true`,children:[(0,J.jsx)(`span`,{children:e(`activity:agentOffice.team`)}),(0,J.jsx)(`span`,{children:e(`activity:agentOffice.liveDesk`)}),(0,J.jsx)(`span`,{children:e(`activity:agentOffice.lastActions`)})]}),(0,J.jsxs)(`div`,{className:`agent-office__client-desks`,children:[r.map(e=>(0,J.jsx)(en,{model:e,now:b,onSelect:m,routedMailIds:o},e.key)),a.length>0&&(0,J.jsx)(`div`,{className:`agent-office__mail-routes`,"aria-hidden":`true`,children:a.map(e=>(0,J.jsx)(`div`,{className:`agent-office__mail-route`,style:{"--from":`${(e.fromIndex+.5)/r.length*100}%`,"--to":`${(e.toIndex+.5)/r.length*100}%`},children:(0,J.jsx)(`span`,{className:`agent-office__mail-route-parcel`,children:(0,J.jsx)(t,{"aria-hidden":`true`})})},e.id))}),r.length===0&&(0,J.jsxs)(`div`,{className:`agent-office__desks-empty`,children:[(0,J.jsx)(ae,{"aria-hidden":`true`}),e(`activity:agentOffice.desksEmpty`)]})]}),i.length>0&&(0,J.jsx)(nn,{agents:i,now:b,onSelect:m})]},n.client.id)}):(0,J.jsxs)(`div`,{className:`agent-office__empty-state`,children:[(0,J.jsx)(`span`,{children:(0,J.jsx)(P,{"aria-hidden":`true`})}),(0,J.jsx)(`h2`,{children:e(`activity:agentOffice.readyTitle`)}),(0,J.jsx)(`p`,{children:e(`activity:agentOffice.readyBody`)})]})}),(0,J.jsxs)(`footer`,{className:`agent-office__footer`,children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`span`,{className:`agent-office__status-dot is-active`}),` `,e(`activity:agentOffice.liveEvent`)]}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(oe,{}),` `,e(`activity:agentOffice.connectedSessions`,{count:r.length})]}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(l,{}),` `,e(`activity:agentOffice.detailHint`)]})]}),p&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`button`,{type:`button`,className:`agent-office__detail-backdrop`,onClick:()=>m(null),"aria-label":e(`activity:agentOffice.closeToolDetails`)}),(0,J.jsx)(ft,{selected:p,onClose:()=>m(null)})]})]})}function an(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 on={user:{Icon:be,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:D,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:d,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:D,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:s,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 sn({entry:e}){let{t}=o();return e.role===`error`?(0,J.jsx)(je,{text:e.text}):e.role===`tool`?(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5 tool-details`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-foreground`,children:[(0,J.jsx)(d,{className:`h-3 w-3`}),(0,J.jsx)(`span`,{className:`font-mono`,children:e.tool??t(`activity:watch.toolFallback`)}),e.durationMs!==void 0&&(0,J.jsxs)(`span`,{className:`ml-auto text-[10px] text-muted-foreground font-normal tabular-nums`,children:[(0,J.jsx)(N,{className:`h-3 w-3 inline mr-0.5 align-text-bottom`}),an(e.durationMs)]})]}),e.input!==void 0&&e.input!==null&&(0,J.jsx)(`div`,{className:`p-3 bg-muted/50 rounded-lg overflow-x-auto`,children:(0,J.jsx)(Pe,{input:e.input})}),e.output!==void 0&&e.output!==null?(0,J.jsx)(`div`,{className:`text-sm leading-relaxed markdown-content`,children:typeof e.output==`string`?(0,J.jsx)(Fe,{remarkPlugins:[Oe],rehypePlugins:Ae,components:Ne,children:e.output}):(0,J.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,J.jsx)(`div`,{className:`text-sm leading-relaxed markdown-content`,children:(0,J.jsx)(Fe,{remarkPlugins:[Oe],rehypePlugins:Ae,components:Ne,children:e.text})}):null,e.isError&&(0,J.jsxs)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/5 px-3 py-2`,children:[(0,J.jsx)(`span`,{className:`text-xs font-medium text-destructive`,children:t(`activity:watch.toolFailed`)}),e.text&&(0,J.jsx)(`pre`,{className:`mt-1 text-xs whitespace-pre-wrap text-destructive/80`,children:e.text})]})]}):(0,J.jsx)(`div`,{className:`text-sm leading-relaxed markdown-content`,children:(0,J.jsx)(Fe,{remarkPlugins:[Oe],rehypePlugins:Ae,components:Ne,children:e.text})})}function cn({entry:e,isContinuation:t=!1}){let{t:n}=o(),r=on[e.role],i=r.Icon;return(0,J.jsxs)(`div`,{className:`group flex gap-3 animate-message msg-bubble rounded-lg transition-shadow`,children:[t?(0,J.jsx)(`div`,{className:`flex-shrink-0 w-8`}):(0,J.jsx)(`div`,{className:V(`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center`,r.avatarBg,r.avatarColor,r.avatarRing),children:(0,J.jsx)(i,{className:`h-4 w-4`})}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5 min-w-0 flex-1`,children:[!t&&(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:V(`text-xs font-medium`,r.textColor),children:e.role===`tool`&&e.tool?e.tool:n(r.labelKey)}),(0,J.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,J.jsxs)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[`· `,an(e.durationMs)]})]}),(0,J.jsx)(`div`,{className:V(`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,J.jsx)(`div`,{className:V(`text-sm leading-relaxed markdown-content`,r.textColor),children:(0,J.jsx)(sn,{entry:e})})}),e.text&&e.role!==`error`&&(0,J.jsx)(`div`,{className:`opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,J.jsx)(Me,{text:e.text,label:n(`common:action.copy`)})})]})]})}var ln=[`steer`,`ask`,`assign`,`note`],un=2500;function dn({sessionId:e,limit:t=200}){let[n,r]=(0,U.useState)(null),{t:i}=o(),[a,s]=(0,U.useState)(null),[c,l]=(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),C=(0,U.useRef)(!0),w=(0,U.useRef)(!0),T=Te(e=>e.liveSessions),E=(0,U.useMemo)(()=>T.find(t=>t.sessionId===e),[T,e]),ee=(0,U.useMemo)(()=>{let e=E;return e?`${e.status}|${e.agents.map(e=>`${e.id}:${e.status}:${e.toolCalls??0}:${e.iterations??0}`).join(`,`)}`:``},[E]),O=E?.status===`active`||(E?.agents.some(e=>e.status===`running`||e.status===`streaming`)??!1),k=(0,U.useMemo)(()=>{if(!E)return null;let e=E.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},[E,i]),te=(0,U.useMemo)(()=>{if(!E)return null;let e=E.agents.find(e=>e.partialText&&(e.status===`streaming`||e.status===`running`))??E.agents.find(e=>e.partialText);return e?.partialText?{label:e.id===`leader`?i(`activity:sessionWatch.claude`):e.name||e.id,text:e.partialText}:null},[E,i]),A=(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),s(null))}catch(e){w.current&&s(e instanceof Error?e.message:String(e))}},[e,t]),j=(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),s(null),y([]),A(),j();let e=setInterval(()=>{document.hidden||(A(),j())},un);return()=>{w.current=!1,clearInterval(e)}},[A,j]),(0,U.useEffect)(()=>{ee&&A()},[ee,A]),(0,U.useEffect)(()=>{C.current&&S.current&&(S.current.scrollTop=S.current.scrollHeight)},[n,te]);let ne=()=>{let e=S.current;e&&(C.current=e.scrollHeight-e.scrollTop-e.clientHeight<40)},re=async()=>{let t=c.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}`);l(``),p(O?B.t(`activity:sessionWatch.sentRunning`):B.t(`activity:sessionWatch.sentIdle`)),j()}catch(e){p(B.t(`activity:sessionWatch.sentFailed`,{error:e instanceof Error?e.message:String(e)}))}finally{d(!1)}}},M=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:B.t(`activity:sessionWatch.interruptReason`)})});if(!t.ok)throw Error(`HTTP ${t.status}`);p(B.t(`activity:sessionWatch.interruptSent`)),j()}catch(e){p(B.t(`activity:sessionWatch.interruptFailed`,{error:e instanceof Error?e.message:String(e)}))}finally{x(!1)}}},N=n?.entries??[];return(0,J.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5 shrink-0`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] uppercase tracking-wide text-muted-foreground`,children:[(0,J.jsx)(`span`,{className:V(`h-1.5 w-1.5 rounded-full`,O?`bg-success animate-pulse`:`bg-muted-foreground`)}),i(`activity:sessionWatch.liveStream`)]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n&&(0,J.jsxs)(`div`,{className:`text-[10px] text-muted-foreground`,children:[i(`activity:sessionWatch.events`,{count:n.total}),` · `,n.status]}),O&&(0,J.jsx)(`button`,{type:`button`,onClick:()=>void M(),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`)})]})]}),k&&(0,J.jsxs)(`div`,{className:`mb-1.5 shrink-0 text-[10px] text-foreground truncate`,children:[`▶ `,k]}),a&&(0,J.jsxs)(`div`,{className:`text-[11px] text-destructive mb-1 shrink-0`,children:[`· `,a]}),(0,J.jsxs)(`div`,{ref:S,onScroll:ne,className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain space-y-1.5 pr-1`,children:[N.length===0&&!a&&(0,J.jsx)(`div`,{className:`text-[11px] text-muted-foreground italic`,children:i(`activity:sessionWatch.loading`)}),N.map((e,t)=>(0,J.jsx)(cn,{entry:e,isContinuation:t>0&&N[t-1].role===e.role},`${e.ts}-${t}`)),te&&(0,J.jsxs)(`div`,{className:`flex gap-3 animate-message`,children:[(0,J.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,J.jsx)(D,{className:`h-4 w-4 animate-pulse`})}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5 max-w-[85%] min-w-0`,children:[(0,J.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground px-1`,children:te.label}),(0,J.jsx)(`div`,{className:`rounded-2xl rounded-bl-md px-4 py-3 bg-card border border-border`,children:(0,J.jsxs)(`span`,{className:`text-sm leading-relaxed text-foreground whitespace-pre-wrap break-words`,children:[te.text,(0,J.jsx)(`span`,{className:`animate-pulse text-primary`,children:`▋`})]})})]})]})]}),v.length>0&&(0,J.jsxs)(`div`,{className:`mt-2 pt-2 border-t border-border shrink-0 max-h-28 overflow-y-auto space-y-1`,children:[(0,J.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,J.jsxs)(`div`,{className:`text-[10px] leading-snug`,children:[(0,J.jsx)(`span`,{className:V(`font-semibold mr-1.5`,e.fromLeader?`text-accent`:`text-primary`),children:e.fromLeader?i(`activity:sessionWatch.agent`):i(`activity:sessionWatch.you`)}),(0,J.jsx)(`span`,{className:`text-foreground whitespace-pre-wrap break-words`,children:e.body}),!e.fromLeader&&(0,J.jsx)(`span`,{className:V(`ml-1.5 text-[9px]`,e.completed?`text-success`:e.readByLeader?`text-primary`:`text-muted-foreground`),children:t})]},e.id)})]}),(0,J.jsxs)(`div`,{className:`mt-2 pt-2 border-t border-border shrink-0`,children:[(0,J.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5`,children:[(0,J.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:ln.map(e=>(0,J.jsx)(`option`,{value:e,children:i(`activity:sessionWatch.msgType.${e}Label`)},e))}),(0,J.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,J.jsx)(`option`,{value:`high`,children:`high`}),(0,J.jsx)(`option`,{value:`normal`,children:`normal`}),(0,J.jsx)(`option`,{value:`low`,children:`low`})]})]}),(0,J.jsxs)(`div`,{className:`flex items-end gap-1.5`,children:[(0,J.jsx)(`textarea`,{value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),re())},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,J.jsx)(`button`,{type:`button`,onClick:()=>void re(),disabled:u||!c.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,J.jsx)(`div`,{className:`mt-1 text-[10px] text-muted-foreground`,children:f}),(0,J.jsx)(`div`,{className:`mt-0.5 text-[9px] text-muted-foreground`,children:i(`activity:sessionWatch.sendHint`)})]})]})}var X={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))`},fn=.12;function pn(e){return Math.min(100,Math.max(0,e??0))}function Z({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:X.muted,active:X.success,streaming:X.primary,completed:X.primary,error:X.destructive,offline:X.muted};return(0,J.jsx)(`span`,{className:V(`rounded-full`,r,n>0&&`animate-pulse`,a[e]),style:{boxShadow:n>0?`0 0 ${i}px ${o[e]}`:void 0}})}function Q(){let e={opacity:0,width:1,height:1,minWidth:0,border:`none`,background:`transparent`};return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(ge,{type:`target`,position:C.Top,style:e,isConnectable:!1}),(0,J.jsx)(ge,{type:`source`,position:C.Bottom,style:e,isConnectable:!1})]})}function mn({data:e}){let{t}=o();return(0,J.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,J.jsxs)(`span`,{children:[(0,J.jsx)(`span`,{className:`font-mono text-foreground`,children:e.agentCount??0}),` `,t(`activity:office.agentsSuffix`)]}),e.startedAt&&(0,J.jsx)(`span`,{children:t(`activity:office.upPrefix`,{time:ht(e.startedAt,Date.now())})})]})}function hn({data:e}){let{t}=o(),n=e.status===`active`||e.status===`streaming`,r=e.status===`error`,i=e.status===`offline`,a=e.color||X.info;return(0,J.jsxs)(`div`,{className:V(`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,J.jsx)(Q,{}),(0,J.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,J.jsx)(`div`,{className:V(`flex items-center justify-center w-10 h-10 rounded-lg`,n?`bg-primary/15`:`bg-primary/10`),children:(0,J.jsx)(v,{className:`h-5 w-5`,style:{color:a}})}),(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsx)(`div`,{className:`text-xs font-bold truncate`,style:{color:a},children:e.label}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:t(`activity:office.webuiClient`)})]}),(0,J.jsx)(Z,{status:e.status,activity:e.vizActivity??0})]}),e.sublabel&&(0,J.jsx)(`div`,{className:`mb-2 truncate text-[10px] text-muted-foreground`,children:e.sublabel}),(0,J.jsx)(`div`,{className:`flex items-center gap-2 text-[10px] text-muted-foreground`,children:i?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(ue,{className:`h-3 w-3 text-muted-foreground`}),(0,J.jsx)(`span`,{children:t(`activity:office.disconnected`)})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(P,{className:`h-3 w-3 text-success`}),(0,J.jsx)(`span`,{children:t(`activity:office.connected`)})]})}),n&&(0,J.jsx)(`div`,{className:`mt-2 h-1 overflow-hidden rounded-full bg-primary/20`,children:(0,J.jsx)(`div`,{className:`h-full animate-pulse bg-primary`,style:{width:`60%`}})}),(0,J.jsx)(mn,{data:e})]})}function gn({data:e}){let{t}=o(),n=e.status===`active`||e.status===`streaming`,r=e.status===`error`,i=e.color||X.success;return(0,J.jsxs)(`div`,{className:V(`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,J.jsx)(Q,{}),(0,J.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,J.jsx)(`div`,{className:V(`flex items-center justify-center w-10 h-10 rounded-lg`,n?`bg-success/15`:`bg-success/10`),children:(0,J.jsx)(d,{className:`h-5 w-5`,style:{color:i}})}),(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsx)(`div`,{className:`text-xs font-bold truncate`,style:{color:i},children:e.label}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:t(`activity:office.tuiClient`)})]}),(0,J.jsx)(Z,{status:e.status,activity:e.vizActivity??0})]}),e.sublabel&&(0,J.jsx)(`div`,{className:`mb-2 truncate text-[10px] text-muted-foreground`,children:e.sublabel}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,J.jsx)(d,{className:`h-3 w-3 text-success`}),(0,J.jsx)(`span`,{children:t(`activity:office.terminal`)})]}),(0,J.jsx)(mn,{data:e})]})}function _n({data:e}){let{t}=o(),n=e.status===`active`||e.status===`streaming`,r=e.color||X.warning;return(0,J.jsxs)(`div`,{className:V(`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,J.jsx)(Q,{}),(0,J.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,J.jsx)(`div`,{className:V(`flex items-center justify-center w-10 h-10 rounded-lg`,n?`bg-warning/15`:`bg-warning/10`),children:(0,J.jsx)(d,{className:`h-5 w-5`,style:{color:r}})}),(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsx)(`div`,{className:`text-xs font-bold truncate`,style:{color:r},children:e.label}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:t(`activity:office.repl`)})]}),(0,J.jsx)(Z,{status:e.status,activity:e.vizActivity??0})]}),e.sublabel&&(0,J.jsx)(`div`,{className:`mb-1 truncate text-[10px] text-muted-foreground`,children:e.sublabel}),(0,J.jsx)(mn,{data:e})]})}function vn({data:e}){let{t}=o(),n=e.status===`active`||e.status===`streaming`,r=e.color||X.primary;return(0,J.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,J.jsx)(Q,{}),(0,J.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,J.jsxs)(`div`,{className:`flex items-center gap-3 mb-3 mt-2`,children:[(0,J.jsx)(`div`,{className:V(`flex items-center justify-center w-12 h-12 rounded-xl`,n?`bg-primary/15`:`bg-primary/10`),children:(0,J.jsx)(ye,{className:`h-6 w-6`,style:{color:r}})}),(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsx)(`div`,{className:`text-sm font-bold truncate`,style:{color:r},children:e.label}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:e.sublabel||t(`activity:office.fleetSummary`)})]}),(0,J.jsx)(Z,{status:e.status,activity:e.vizActivity??0})]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-[10px] mb-2`,children:[(0,J.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,J.jsxs)(`div`,{className:`font-mono`,children:[(0,J.jsx)(`span`,{className:`text-success`,children:e.agentsActive||0}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:` / `}),(0,J.jsx)(`span`,{className:`text-primary`,children:e.agentsTotal||0})]}),(0,J.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:officeMap.agents`)})]}),(0,J.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,J.jsx)(`div`,{className:`font-mono text-warning`,children:(e.toolCalls||0).toLocaleString()}),(0,J.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:office.toolCallsLabel`)})]}),(0,J.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,J.jsx)(`div`,{className:`font-mono text-foreground`,children:pt(e.tokensIn)}),(0,J.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:office.tokensLabel`)})]}),(0,J.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,J.jsxs)(`div`,{className:`font-mono text-success`,children:[`$`,(e.costUsd||0).toFixed(3)]}),(0,J.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:office.cost`)})]})]}),n&&(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-primary`,children:[(0,J.jsx)(`span`,{className:`h-2 w-2 animate-pulse rounded-full bg-primary`}),t(`activity:office.coordinatingFleet`)]})]})}function yn({data:e}){let{t}=o(),n=e.status===`active`||e.status===`streaming`,r=e.status===`error`,i=e.status===`completed`,a=e.color||X.primary,s=pn(e.ctxPct);return(0,J.jsxs)(`div`,{className:V(`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,J.jsx)(Q,{}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[(0,J.jsx)(D,{className:`h-4 w-4 shrink-0`,style:{color:a}}),(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsx)(`div`,{className:`text-[11px] font-bold truncate`,style:{color:a},children:e.label}),e.model&&(0,J.jsx)(`div`,{className:`truncate text-[10px] text-muted-foreground`,children:gt(e.model)})]}),(0,J.jsx)(Z,{status:e.status,small:!0,activity:e.vizActivity??0})]}),e.currentTask&&(0,J.jsxs)(`div`,{className:`mb-1.5 flex min-w-0 items-center gap-1 overflow-hidden text-[11px] text-primary`,children:[(0,J.jsx)(`span`,{className:V(`h-1.5 w-1.5 shrink-0 rounded-full bg-primary`,n&&`animate-pulse`)}),(0,J.jsx)(`span`,{className:`min-w-0 truncate font-mono`,title:e.currentTask,children:_t(e.currentTask,72)})]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-2 gap-y-0.5 text-[11px] mb-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex justify-between`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`iter`}),(0,J.jsx)(`span`,{className:`font-mono text-foreground`,children:e.iteration||0})]}),(0,J.jsxs)(`div`,{className:`flex justify-between`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`tools`}),(0,J.jsx)(`span`,{className:`font-mono text-warning`,children:e.toolCalls||0})]}),(0,J.jsxs)(`div`,{className:`flex justify-between`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`tok`}),(0,J.jsx)(`span`,{className:`font-mono text-foreground`,children:pt((e.tokensIn||0)+(e.tokensOut||0))})]}),(0,J.jsxs)(`div`,{className:`flex justify-between`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`cost`}),(0,J.jsxs)(`span`,{className:`font-mono text-success`,children:[`$`,(e.costUsd||0).toFixed(3)]})]})]}),s>0&&(0,J.jsxs)(`div`,{className:`mb-1`,children:[(0,J.jsxs)(`div`,{className:`mb-0.5 flex justify-between text-[10px] text-muted-foreground`,children:[(0,J.jsx)(`span`,{children:`ctx`}),(0,J.jsxs)(`span`,{className:V(`font-mono`,s>=90?`text-destructive`:s>=70?`text-warning`:`text-muted-foreground`),children:[s,`%`]})]}),(0,J.jsx)(`div`,{className:`h-1 overflow-hidden rounded-full bg-muted`,children:(0,J.jsx)(`div`,{className:V(`h-full`,s>=90?`bg-destructive`:s>=70?`bg-warning`:`bg-primary`),style:{width:`${s}%`}})})]}),e.lastActivityAt&&(0,J.jsxs)(`div`,{className:V(`flex items-center gap-1 text-[10px]`,n?`text-muted-foreground/70`:`text-muted-foreground`),children:[i&&(0,J.jsx)(`span`,{className:`text-success`,children:t(`activity:office.donePrefix`)}),r&&(0,J.jsx)(`span`,{className:`text-destructive`,children:t(`activity:office.failedPrefix`)}),(0,J.jsx)(`span`,{children:t(`activity:office.seenPrefix`,{time:mt(e.lastActivityAt,Date.now())})})]})]})}function bn({data:e}){let{t}=o();return(0,J.jsxs)(`div`,{className:V(`rounded-lg border border-dashed p-3 min-w-[120px] transition-all opacity-40`,`border-border/70 bg-muted/30`),children:[(0,J.jsx)(Q,{}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,J.jsx)(i,{className:`h-4 w-4 text-muted-foreground`}),(0,J.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,J.jsx)(`div`,{className:`truncate text-[10px] text-muted-foreground`,children:e.label})}),(0,J.jsx)(Z,{status:e.status,small:!0,activity:e.vizActivity??0})]}),(0,J.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:t(`activity:office.availableDesk`)})]})}function xn({data:e}){let{t:n}=o(),r=e.color||X.warning,i=(e.unreadCount||0)>0;return(0,J.jsxs)(`div`,{className:V(`rounded-xl border-2 p-4 min-w-[160px] transition-all backdrop-blur-sm`,i&&`border-warning/50 bg-warning/10 shadow-lg shadow-warning/10`,!i&&`border-warning/30 bg-warning/6`),children:[(0,J.jsx)(Q,{}),(0,J.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,J.jsx)(`div`,{className:V(`flex items-center justify-center w-10 h-10 rounded-lg`,i?`bg-warning/18`:`bg-warning/10`),children:(0,J.jsx)(t,{className:`h-5 w-5`,style:{color:r}})}),(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsx)(`div`,{className:`text-xs font-bold`,style:{color:r},children:n(`activity:office.mailboxHub`)}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:i?n(`activity:office.unreadSuffix`,{count:e.unreadCount||0}):n(`activity:office.allClear`)})]}),i&&(0,J.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,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-[10px]`,children:[(0,J.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-warning`,children:[(0,J.jsx)(M,{className:`h-3 w-3`}),(0,J.jsx)(`span`,{children:e.messageCount||0})]}),(0,J.jsx)(`div`,{className:`text-muted-foreground`,children:n(`activity:office.total`)})]}),(0,J.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-success`,children:[(0,J.jsx)(h,{className:`h-3 w-3`}),(0,J.jsx)(`span`,{children:e.unreadCount||0})]}),(0,J.jsx)(`div`,{className:`text-muted-foreground`,children:n(`activity:office.unreadLabel`)})]})]}),e.sublabel&&(0,J.jsxs)(`div`,{className:`mt-2 truncate border-t border-border/60 pt-1.5 text-[11px] text-muted-foreground`,children:[`✉ `,e.sublabel]})]})}var Sn={webui:hn,tui:gn,repl:_n,coordinator:vn,agent:yn,mailbox:xn,desk:bn};function Cn({broadcastOpen:e,labels:t,onArrange:n,onBroadcastToggle:r,onFeedToggle:i,showFeed:a}){return(0,J.jsxs)(se,{position:`top-right`,className:`flex items-center gap-2`,children:[(0,J.jsxs)(`button`,{type:`button`,onClick:n,title:t.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,J.jsx)(j,{className:`h-3.5 w-3.5`}),t.arrange]}),(0,J.jsxs)(`button`,{type:`button`,onClick:i,title:t.feedTitle,className:V(`flex items-center gap-1.5 px-2.5 py-1.5 rounded-md border text-xs transition-colors`,a?`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,J.jsx)(F,{className:`h-3.5 w-3.5`}),t.feed]}),(0,J.jsxs)(`button`,{type:`button`,onClick:r,title:t.broadcastTitle,className:V(`flex items-center gap-1.5 px-2.5 py-1.5 rounded-md border text-xs transition-colors`,e?`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,J.jsx)(M,{className:`h-3.5 w-3.5`}),t.broadcast]})]})}function wn(){return(0,J.jsx)(E,{className:`rounded-lg border border-border/70 bg-card/90`,nodeColor:e=>{switch(e.data.kind){case`coordinator`:return X.primary;case`webui`:return X.info;case`tui`:return X.success;case`repl`:case`mailbox`:return X.warning;default:return X.primary}},maskColor:`hsl(var(--background) / 0.72)`})}function Tn({closeTitle:e,label:t,onClose:n,sessionId:r,streamTitle:i}){return(0,J.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,J.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border px-4 py-2.5 shrink-0 bg-card`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,J.jsx)(D,{className:`h-4 w-4 text-primary shrink-0`}),(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`div`,{className:`truncate text-sm font-bold text-foreground`,children:t}),(0,J.jsx)(`div`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:i})]})]}),(0,J.jsx)(`button`,{type:`button`,onClick:n,title:e,className:`text-muted-foreground hover:text-foreground text-xl leading-none shrink-0`,children:`×`})]}),(0,J.jsx)(`div`,{className:`flex-1 min-h-0 p-4`,children:(0,J.jsx)(dn,{sessionId:r,limit:500})})]})}var En={wire:({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:i,targetPosition:a,data:o,selected:s})=>{let c=o?.color||X.primary,l=H(e=>e.animateEdges),u=o?.animated&&l?Math.max(.15,o?.intensity??.6):0,[d,f,p]=z({sourceX:e,sourceY:t,sourcePosition:i??C.Bottom,targetX:n,targetY:r,targetPosition:a??C.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,J.jsxs)(J.Fragment,{children:[(0,J.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,J.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,J.jsx)(`animate`,{attributeName:`stroke-dashoffset`,from:g,to:`0`,dur:_,repeatCount:`indefinite`})}),o?.label&&u>.1&&(0,J.jsx)(de,{children:(0,J.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 Dn(){let{t:e}=o(),{clientCounts:t,currentSession:r,totalAgents:i,activeAgents:a,aggregate:s}=Te(u(e=>({clientCounts:e.clientCounts,currentSession:e.currentSession,totalAgents:e.totalAgents,activeAgents:e.activeAgents,aggregate:e.aggregate}))),c=t.tui+t.webui+t.repl,l=e=>e?.toLocaleString()??`0`;return(0,J.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,J.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,J.jsx)(n,{className:`h-3.5 w-3.5 text-success`}),(0,J.jsx)(`span`,{className:`text-[10px] font-bold uppercase text-muted-foreground`,children:e(`activity:office.sessionStats`)})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5 text-[10px]`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(xe,{className:`h-3 w-3 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.clients`)})]}),(0,J.jsxs)(`span`,{className:`font-mono text-foreground`,children:[a,` `,(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`/`}),` `,(0,J.jsx)(`span`,{className:`text-success`,children:c})]})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-3 pl-4 text-[9px]`,children:[t.tui>0&&(0,J.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(d,{className:`h-2.5 w-2.5 text-success`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:hud.tui`)}),(0,J.jsx)(`span`,{className:`font-mono text-success`,children:t.tui})]}),t.webui>0&&(0,J.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(v,{className:`h-2.5 w-2.5 text-primary`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:hud.webui`)}),(0,J.jsx)(`span`,{className:`font-mono text-primary`,children:t.webui})]}),t.repl>0&&(0,J.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(d,{className:`h-2.5 w-2.5 text-warning`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:hud.repl`)}),(0,J.jsx)(`span`,{className:`font-mono text-warning`,children:t.repl})]})]}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(D,{className:`h-3 w-3 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:officeMap.agents`)})]}),(0,J.jsxs)(`span`,{className:`font-mono text-foreground`,children:[a,` `,(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`/`}),` `,(0,J.jsx)(`span`,{className:`text-primary`,children:i})]})]}),r.model&&(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(ye,{className:`h-3 w-3 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:officeMap.model`)})]}),(0,J.jsx)(`span`,{className:`max-w-[120px] truncate font-mono text-primary`,title:r.model,children:r.model.split(`/`).pop()?.slice(0,16)})]}),r.mode&&(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(_e,{className:`h-3 w-3 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:officeMap.mode`)})]}),(0,J.jsx)(`span`,{className:V(`font-mono uppercase text-[9px] px-1.5 py-0.5 rounded`,r.mode===`auto`&&`bg-primary/10 text-primary`,r.mode===`suggest`&&`bg-success/10 text-success`,r.mode===`off`&&`bg-muted text-muted-foreground`,![`auto`,`suggest`,`off`].includes(r.mode||``)&&`bg-muted text-muted-foreground`),children:r.mode})]}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(p,{className:`h-3 w-3 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.toolCallsLabel`)})]}),(0,J.jsx)(`span`,{className:`font-mono text-warning`,children:l(s.toolCalls)})]}),(0,J.jsxs)(`div`,{className:`mt-1.5 space-y-1 border-t border-border/70 pt-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(`span`,{className:`text-[8px] text-muted-foreground`,children:`IN`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.input`)})]}),(0,J.jsx)(`span`,{className:`font-mono text-[9px] text-foreground`,children:l(s.tokensIn)})]}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(`span`,{className:`text-[8px] text-muted-foreground`,children:e(`activity:hud.out`)}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.output`)})]}),(0,J.jsx)(`span`,{className:`font-mono text-[9px] text-foreground`,children:l(s.tokensOut)})]})]}),(0,J.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-between gap-4 border-t border-border/70 pt-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(ve,{className:`h-3 w-3 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.cost`)})]}),(0,J.jsx)(`span`,{className:`font-mono font-medium text-success`,children:(e=>e==null?`$0.0000`:`$${e.toFixed(4)}`)(s.costUsd)})]})]})]})}function On({events:e,now:t}){let{t:r}=o(),i=e.slice(0,14);return(0,J.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 z-10 pointer-events-none px-3 pb-3`,children:(0,J.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,J.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-1.5 text-[10px] uppercase text-primary`,children:[(0,J.jsx)(n,{className:`h-3 w-3`}),r(`activity:office.liveActivity`)]}),i.length===0?(0,J.jsx)(`div`,{className:`text-[11px] italic text-muted-foreground`,children:r(`activity:office.waitingActivity`)}):(0,J.jsx)(`div`,{className:`flex flex-col gap-0.5 max-h-32 overflow-hidden`,children:i.map(e=>{let n=Math.max(0,Math.round((t-e.timestamp)/1e3));return(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] leading-tight`,children:[(0,J.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0`,style:{backgroundColor:kt(e.kind)}}),(0,J.jsx)(`span`,{className:`flex-1 truncate text-foreground`,children:e.label}),(0,J.jsx)(`span`,{className:`shrink-0 tabular-nums text-muted-foreground`,children:n<1?r(`activity:office.now`):`${n}s`})]},e.id)})})]})})}function kn(){let{t:e}=o();return(0,J.jsxs)(J.Fragment,{children:[(0,J.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,J.jsx)(`div`,{className:`mb-2 font-bold text-foreground`,children:e(`activity:office.legendStatus`)}),(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`h-2 w-2 animate-pulse rounded-full bg-success`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.legendActive`)})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`h-2 w-2 rounded-full bg-muted-foreground`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.legendIdle`)})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`h-2 w-2 animate-pulse rounded-full bg-destructive`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.legendError`)})]})]})]}),(0,J.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,J.jsx)(`div`,{className:`mb-2 font-bold text-foreground`,children:e(`activity:office.legendConnections`)}),(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`text-warning`,children:`✉`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.legendMail`)})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`text-primary`,children:`→`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.legendTask`)})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`text-success`,children:`●`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.legendStatusConn`)})]})]})]})]})}function An({draft:e,isSending:t,result:n,onClose:r,onDraftChange:i,onSend:a}){let{t:s}=o();return(0,J.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,J.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] font-semibold text-warning`,children:[(0,J.jsx)(M,{className:`h-3.5 w-3.5`}),` `,s(`activity:office.broadcastToAll`)]}),(0,J.jsx)(`button`,{type:`button`,onClick:r,className:`text-base leading-none text-muted-foreground hover:text-foreground`,children:`×`})]}),(0,J.jsx)(`textarea`,{value:e,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),a())},rows:3,placeholder:s(`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,J.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-between`,children:[(0,J.jsx)(`span`,{className:`text-[9px] text-muted-foreground`,children:s(`activity:office.broadcastSendHint`)}),(0,J.jsx)(`button`,{type:`button`,onClick:a,disabled:t||!e.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:t?`…`:s(`activity:office.broadcast`)})]}),n&&(0,J.jsx)(`div`,{className:`mt-1 text-[10px] text-muted-foreground`,children:n})]})}function $({k:e,v:t,accent:n}){return(0,J.jsxs)(`div`,{className:`flex justify-between gap-3`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:e}),(0,J.jsx)(`span`,{className:V(`font-mono truncate text-right`,n??`text-foreground/80`),children:t})]})}function jn({selectedNode:e,selectedAgentTranscript:n,mailboxMessages:r,onClose:i,onOpenWatch:a}){let{t:s}=o(),c=e.data,l=Date.now(),u=c.kind===`agent`,f=c.kind===`webui`||c.kind===`tui`||c.kind===`repl`,p=(c.tokensIn||0)+(c.tokensOut||0),h=pn(c.ctxPct);return(0,J.jsxs)(`div`,{className:V(`absolute top-20 right-4 bg-background border border-border rounded-lg p-4 shadow-xl z-20`,c.kind===`agent`?`w-[28rem] max-w-[calc(100%-2rem)]`:c.sessionId?`w-80`:`w-64`),children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[c.kind===`webui`&&(0,J.jsx)(v,{className:`h-4 w-4 text-info`}),c.kind===`tui`&&(0,J.jsx)(d,{className:`h-4 w-4 text-success`}),c.kind===`coordinator`&&(0,J.jsx)(ye,{className:`h-4 w-4 text-primary`}),c.kind===`agent`&&(0,J.jsx)(D,{className:`h-4 w-4 text-primary`}),c.kind===`mailbox`&&(0,J.jsx)(t,{className:`h-4 w-4 text-warning`}),(0,J.jsx)(`span`,{className:`text-sm font-bold text-foreground`,children:c.label})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[c.sessionId&&(0,J.jsx)(`button`,{type:`button`,title:s(`activity:office.openFullView`),onClick:()=>a({sessionId:c.sessionId,label:c.label}),className:`text-muted-foreground hover:text-primary`,children:(0,J.jsx)(m,{className:`h-3.5 w-3.5`})}),(0,J.jsx)(`button`,{type:`button`,onClick:i,className:`text-muted-foreground hover:text-foreground text-lg leading-none`,children:`×`})]})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5 text-xs`,children:[(0,J.jsx)($,{k:`Status`,v:String(c.status).toUpperCase(),accent:V(c.status===`active`&&`text-success`,c.status===`streaming`&&`text-primary`,c.status===`error`&&`text-destructive`,c.status===`idle`&&`text-muted-foreground`,c.status===`offline`&&`text-muted-foreground/70`)}),u&&(0,J.jsxs)(J.Fragment,{children:[c.model&&(0,J.jsx)($,{k:`Model`,v:gt(c.model),accent:`text-primary`}),c.currentTask&&(0,J.jsxs)(`div`,{className:`pt-1`,children:[(0,J.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:s(`activity:agentOffice.currentTask`)}),(0,J.jsx)(`div`,{className:`mt-1 max-h-32 overflow-y-auto whitespace-pre-wrap break-words font-mono text-[10px] text-primary`,children:c.currentTask})]}),(0,J.jsx)($,{k:`Iterations`,v:c.iteration||0,accent:`text-primary`}),(0,J.jsx)($,{k:`Tool calls`,v:c.toolCalls||0,accent:`text-warning`}),(0,J.jsx)($,{k:`Tokens in`,v:pt(c.tokensIn)}),(0,J.jsx)($,{k:`Tokens out`,v:pt(c.tokensOut)}),(0,J.jsx)($,{k:`Tokens total`,v:pt(p)}),h>0&&(0,J.jsx)($,{k:`Context`,v:`${h}%`,accent:h>=90?`text-destructive`:h>=70?`text-warning`:`text-foreground/70`}),(0,J.jsx)($,{k:`Cost`,v:`$${(c.costUsd||0).toFixed(4)}`,accent:`text-success`}),c.lastActivityAt&&(0,J.jsx)($,{k:`Last seen`,v:mt(c.lastActivityAt,l),accent:`text-muted-foreground`}),(0,J.jsx)(`div`,{className:`pt-2`,children:(0,J.jsx)(ke,{entries:n,agentName:c.label,compact:!0,maxHeightClassName:`max-h-64`})})]}),f&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)($,{k:`Surface`,v:xt(c.kind),accent:`text-foreground/80`}),c.branch&&(0,J.jsx)($,{k:`Branch`,v:`⎇ ${c.branch}`,accent:`text-foreground/70`}),c.pid!=null&&(0,J.jsx)($,{k:`PID`,v:c.pid}),c.workingDir&&(0,J.jsx)($,{k:`Dir`,v:c.workingDir,accent:`text-muted-foreground`}),(0,J.jsx)($,{k:`Agents`,v:c.agentCount??0,accent:`text-primary`}),c.startedAt&&(0,J.jsx)($,{k:`Uptime`,v:ht(c.startedAt,l),accent:`text-foreground/70`})]}),c.kind===`mailbox`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)($,{k:`Total messages`,v:c.messageCount||0,accent:`text-warning`}),(0,J.jsx)($,{k:`Unread`,v:c.unreadCount||0,accent:`text-warning`}),r.length>0&&(0,J.jsxs)(`div`,{className:`mt-1 space-y-1 border-t border-border pt-2`,children:[(0,J.jsx)(`div`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:s(`activity:office.recent`)}),[...r].sort((e,t)=>Date.parse(t.timestamp)-Date.parse(e.timestamp)).slice(0,6).map(e=>(0,J.jsxs)(`div`,{className:`flex items-start gap-1.5 text-[10px]`,children:[(0,J.jsx)(`span`,{className:V(`mt-1 h-1.5 w-1.5 shrink-0 rounded-full`,!e.completed&&(e.readByCount??0)===0?`bg-warning`:e.completed?`bg-success`:`bg-muted`)}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`div`,{className:`truncate text-foreground/80`,children:e.subject||s(`activity:office.noSubject`)}),(0,J.jsxs)(`div`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:[e.from,` → `,e.to,` · `,mt(e.timestamp,l),e.audience===`leaders`?` · ${s(`activity:mailbox.audienceLeaders`)}`:``]})]})]},e.id))]})]}),c.kind===`coordinator`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)($,{k:`Connections`,v:c.connections||0,accent:`text-primary`}),(0,J.jsx)($,{k:`Iterations`,v:c.iteration||0,accent:`text-primary`})]}),(u||f)&&c.sessionId&&(0,J.jsx)(`div`,{className:`mt-2 border-t border-border pt-2 h-72`,children:(0,J.jsx)(dn,{sessionId:c.sessionId})})]})]})}function Mn(){let{t:e}=o(),{fitView:t}=ne(),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 a=Se(e=>e.events),s=we(e=>e.agents),c=we(e=>e.agentTranscripts),l=we(e=>e.leaderId),u=Te(e=>e.liveSessions),d=De(e=>e.messages),f=De(e=>e.agents),p=Ce(e=>e.session),m=jt(s),h=(0,U.useMemo)(()=>Ot(u,s,f,m.map,m.now),[u,s,f,m]),g=H(e=>e.showHud),_=H(e=>e.showLegend),v=H(e=>e.showMinimap),y=H(e=>e.showControls),b=H(e=>e.showFeed),x=H(e=>e.setShowFeed),S=H(e=>e.background),[C,T,E]=le([]),[D,O,k]=pe([]),[A,j]=(0,U.useState)(null),[M,N]=(0,U.useState)(null),[ie,ae]=(0,U.useState)(!1),[oe,se]=(0,U.useState)(``),[ce,ue]=(0,U.useState)(!1),[de,P]=(0,U.useState)(null),he=(0,U.useMemo)(()=>{if(A?.data.kind!==`agent`)return Ee;let e=A.data.serverId??(A.id.includes(`__agent-`)?A.id.split(`__agent-`).pop():A.id.replace(/^agent-/,``));return e?c.get(e)??Ee:Ee},[c,A]),ge=(0,U.useCallback)(async()=>{let e=oe.trim();if(!(!e||ce)){ue(!0),P(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();se(``),P(`Delivered to ${n.delivered??0}/${n.targets??0} session(s)`)}catch(e){P(`Failed: ${e instanceof Error?e.message:String(e)}`)}finally{ue(!1)}}},[oe,ce]),F=(0,U.useRef)(new Map),I=4e3,L=(0,U.useRef)(new Map),R=(0,U.useRef)(new Map),_e=(0,U.useRef)(new Map),z=(0,U.useRef)(new Map),ve=(0,U.useRef)(``);(0,U.useEffect)(()=>{let n=[],i=[],a=Date.now(),o=vt(h.map(e=>({id:e.id,agentCount:e.agents.length})),r),c=d.filter(e=>!e.completed&&(e.readByCount??0)===0).length,u=d.length?[...d].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:c>0?`active`:`idle`,unreadCount:c,messageCount:d.length,sublabel:u?`${u.from} → ${u.to}: ${u.subject}`:void 0,color:X.warning}});let f=0,p=0,m=0,g=0,_=0;for(let e of h)for(let t of e.agents)p+=1,(t.status===`active`||t.status===`streaming`)&&(f+=1),m+=t.toolCalls,g+=t.costUsd,_+=t.tokensIn+t.tokensOut;let v=l?s.get(l):null,y=f>0;n.push({id:`coordinator`,type:`coordinator`,position:{x:370,y:50},data:{label:e(`activity:office.fleetHqLabel`),sublabel:e(`activity:office.clientsSuffix`,{count:h.length}),kind:`coordinator`,status:v?.status===`failed`?`error`:y?`active`:`idle`,connections:h.length,agentsActive:f,agentsTotal:p,toolCalls:m,costUsd:g,tokensIn:_,color:X.primary}});let b={tui:X.success,webui:X.info,repl:X.warning};for(let t of h){let r=o.positions.get(t.id)??{x:600,y:370},s=r.x,l=r.y,u=b[t.type],d=t.status===`active`;if(n.push({id:t.id,type:t.type,position:{x:s,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:c>0,data:{color:X.warning,animated:c>0,label:c>0?`${c}`:void 0,flowType:`mail`}}),t.agents.length===0){n.push({id:`desk-${t.id}`,type:`desk`,position:{x:s,y:l+270},data:{label:e(`activity:office.idleDesk`),kind:`agent`,status:`idle`,color:X.muted}});continue}t.agents.forEach((r,o)=>{let c=r.status===`active`||r.status===`streaming`,u=z.current.get(r.serverId);if(u&&(r.toolCalls>u.toolCalls||r.iteration>u.iteration)||c){F.current.set(r.officeId,a+I);let e=R.current.get(r.officeId)??0;R.current.set(r.officeId,Math.min(1,e+(1-e)*.5));for(let e of[`${t.id}->${r.officeId}`,`${t.id}->coordinator`]){let t=L.current.get(e)??0;L.current.set(e,Math.min(1,t+.5))}}z.current.set(r.serverId,{toolCalls:r.toolCalls,iteration:r.iteration}),n.push({id:r.officeId,type:`agent`,position:yt(s,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:X.primary}}),i.push({id:`${t.id}->${r.officeId}`,source:t.id,target:r.officeId,type:`wire`,animated:c,data:{color:X.primary,animated:c,label:c?_t(r.currentTask,48)??e(`activity:office.taskFallback`):void 0,flowType:`task`}})})}let x=new Set(h.flatMap(e=>e.agents.map(e=>e.serverId)));for(let e of[...z.current.keys()])x.has(e)||z.current.delete(e);for(let[e,t]of[...F.current])t<=a&&F.current.delete(e);let S=n.map(e=>{let t=F.current.get(e.id),n=R.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}}}),C=i.map(e=>{let t=L.current.get(e.id)??0;return t>.05?{...e,animated:!0,data:{...e.data,animated:!0,intensity:t}}:e}),w=new Map;for(let e of S)w.set(e.id,{...e.position});_e.current=w,T(S),O(C);let E=[`${Math.round(r.width)}x${Math.round(r.height)}`,`${o.columns}x${o.rows}`,h.map(e=>`${e.id}:${e.agents.length}`).join(`|`),S.map(e=>e.id).sort().join(`|`)].join(`:`);if(E!==ve.current){ve.current=E;let e=setTimeout(()=>t({padding:fn,duration:300}),50);return()=>clearTimeout(e)}},[h,l,s,d,p,r,I,T,O,t]);let ye=h.flatMap(e=>e.agents.map(t=>({clientId:e.id,clientType:e.type,officeId:t.officeId,serverId:t.serverId}))),be=h.map(e=>e.id),xe=new Map;for(let e of ye)(!xe.has(e.serverId)||e.clientType===`webui`)&&xe.set(e.serverId,e.officeId);function B(e){return xe.get(e)??`agent-${e}`}function V(e){let t=e.split(`__agent-`)[0];return t&&t!==e?`${t}->${e}`:`coordinator->${e}`}function Oe(e){switch(e.kind){case`mailbox:send`:case`mailbox:deliver`:return{nodes:[`mailbox`],edges:e.kind===`mailbox:send`?be.map(e=>`mailbox->${e}`):[],status:`active`};case`agent:spawned`:{let t=B(e.source);return{nodes:[`coordinator`,t],edges:[V(t)],status:`active`}}case`agent:tool`:case`tool:started`:case`tool:progress`:{let t=B(e.source);return{nodes:[`coordinator`,t],edges:[V(t)],status:e.kind===`tool:progress`||e.kind===`tool:started`?`streaming`:`active`}}case`tool:executed`:{let t=B(e.target??e.source);return{nodes:[t],edges:[V(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:ye.map(e=>V(e.officeId)),status:e.kind===`iteration:start`?`streaming`:`active`};case`agent:text`:{let t=B(e.source);return{nodes:[t],edges:[V(t)],status:`streaming`}}case`agent:status`:{let t=B(e.source);return{nodes:[`coordinator`,t],edges:[V(t)],status:e.data&&typeof e.data==`object`&&`status`in e.data&&String(e.data.status)===`failed`?`error`:`completed`}}case`agent:ctx`:return{nodes:[B(e.source)],edges:[],status:`active`};case`budget:extended`:return{nodes:[`coordinator`,B(e.source)],edges:[],status:`active`};case`context:compacted`:case`context:repaired`:return{nodes:[`coordinator`],edges:[],status:`active`};case`error`:return{nodes:e.source?[B(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=B(t.id);n.includes(e)||n.push(e)}return{nodes:n,edges:[],status:`active`}}default:return{nodes:[],edges:[],status:`idle`}}}(0,U.useEffect)(()=>{if(a.length===0)return;let e=a[0];if(!e)return;let{nodes:t,edges:n,status:r}=Oe(e),i=Date.now();t.length>0&&(t.forEach(e=>{F.current.set(e,i+I);let t=R.current.get(e)??0;R.current.set(e,Math.min(1,t+(1-t)*.5))}),T(e=>e.map(e=>t.includes(e.id)?{...e,data:{...e.data,status:r,vizActivity:R.current.get(e.id)??0}}:e))),n.length>0&&(n.forEach(e=>{let t=L.current.get(e)??0;L.current.set(e,Math.min(1,t+.5))}),O(e=>e.map(e=>n.includes(e.id)?{...e,animated:!0,data:{...e.data,animated:!0,intensity:L.current.get(e.id)??1}}:e)))},[a,T,O,I,s]),(0,U.useEffect)(()=>{let e=setInterval(()=>{let e=new Map,t=!1;for(let[n,r]of L.current){let i=r*.85;i<.05?(L.current.delete(n),e.set(n,{intensity:0,animated:!1}),t=!0):(L.current.set(n,i),e.set(n,{intensity:i,animated:!0}),t=!0)}t&&O(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 R.current){let i=t*.9;i<.03?(R.current.delete(e),n.set(e,0),r=!0):(R.current.set(e,i),n.set(e,i),r=!0)}r&&T(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)},[O,T]);let ke=(0,U.useCallback)(e=>O(t=>ee({...e,type:`wire`},t)),[O]),Ae=(0,U.useCallback)((e,t)=>{j(t)},[]),je=(0,U.useCallback)(()=>{j(null)},[]);(0,U.useEffect)(()=>{if(!M)return;let e=e=>{e.key===`Escape`&&N(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[M]);let Me=(0,U.useCallback)(()=>{T(e=>e.map(e=>{let t=_e.current.get(e.id);return t?{...e,position:{...t}}:e})),setTimeout(()=>t({padding:fn,duration:300}),50)},[T,t]),[,Ne]=(0,U.useState)(0);return(0,U.useEffect)(()=>{let e=setInterval(()=>{document.hidden||Ne(e=>e+1)},2e3);return()=>clearInterval(e)},[]),(0,J.jsxs)(`div`,{ref:n,className:`relative h-full w-full overflow-hidden bg-[hsl(var(--surface-2)/0.55)]`,children:[(0,J.jsx)(`div`,{className:`absolute inset-0 opacity-[0.03]`,style:{backgroundImage:`
|
|
2
|
-
linear-gradient(hsl(var(--foreground) / 0.1) 1px, transparent 1px),
|
|
3
|
-
linear-gradient(90deg, hsl(var(--foreground) / 0.1) 1px, transparent 1px)
|
|
4
|
-
`,backgroundSize:`40px 40px`}}),g&&(0,J.jsx)(Dn,{}),(0,J.jsx)(`div`,{className:`absolute top-3 left-1/2 -translate-x-1/2 z-10`,children:(0,J.jsx)(`div`,{className:`rounded-lg border border-border/70 bg-card/90 px-4 py-2 shadow-xl backdrop-blur`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-bold text-foreground`,children:[(0,J.jsx)(fe,{className:`h-4 w-4 text-primary`}),e(`activity:office.fleetHq`),(0,J.jsx)(`span`,{className:`ml-2 h-2 w-2 animate-pulse rounded-full bg-success`}),(0,J.jsx)(`span`,{className:`text-[10px] font-normal text-muted-foreground`,children:e(`activity:office.live`)})]})})}),_&&(0,J.jsx)(kn,{}),(0,J.jsxs)(te,{nodes:C,edges:D,onNodesChange:E,onEdgesChange:k,onConnect:ke,onNodeClick:Ae,onPaneClick:je,nodeTypes:Sn,edgeTypes:En,fitView:!0,fitViewOptions:{padding:fn},minZoom:.15,maxZoom:1.5,defaultEdgeOptions:{type:`wire`},proOptions:{hideAttribution:!0},children:[(0,J.jsx)(Cn,{broadcastOpen:ie,labels:{arrange:e(`activity:office.arrange`),arrangeTitle:e(`activity:office.arrangeTitle`),broadcast:e(`activity:office.broadcast`),broadcastTitle:e(`activity:office.broadcastTitle`),feed:e(`activity:office.feed`),feedTitle:e(`activity:office.feedTitle`)},onArrange:Me,onBroadcastToggle:()=>ae(e=>!e),onFeedToggle:()=>x(!b),showFeed:b}),S!==`none`&&(0,J.jsx)(me,{variant:S===`lines`?re.Lines:S===`cross`?re.Cross:re.Dots,gap:20,size:1,color:`hsl(var(--border) / 0.35)`}),y&&(0,J.jsx)(w,{className:`rounded-lg border border-border/70 bg-card/90 [&>button]:bg-card [&>button]:text-foreground`}),v&&(0,J.jsx)(wn,{})]}),b&&(0,J.jsx)(On,{events:a,now:Date.now()}),ie&&(0,J.jsx)(An,{draft:oe,isSending:ce,result:de,onClose:()=>ae(!1),onDraftChange:se,onSend:()=>void ge()}),A&&(0,J.jsx)(jn,{selectedNode:A,selectedAgentTranscript:he,mailboxMessages:d,onClose:je,onOpenWatch:N}),M&&(0,J.jsx)(Tn,{closeTitle:e(`activity:office.closeEsc`),label:M.label,onClose:()=>N(null),sessionId:M.sessionId,streamTitle:e(`activity:office.fullOperationStream`)})]})}function Nn(){let{t:e}=o(),t=H(e=>e.viewMode),n=H(e=>e.setViewMode),i=[{id:`office`,label:e(`activity:agentOffice.office`),description:e(`activity:agentOffice.officeDescription`),icon:ie},{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,J.jsxs)(`div`,{className:`flex h-full min-h-0 w-full flex-col bg-background`,children:[(0,J.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,J.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,J.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:V(`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,J.jsx)(`span`,{className:V(`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,J.jsx)(i,{className:`h-4 w-4`,"aria-hidden":`true`})}),(0,J.jsxs)(`span`,{className:`min-w-0`,children:[(0,J.jsx)(`strong`,{className:`block truncate font-display text-xs font-semibold sm:text-sm`,children:e.label}),(0,J.jsx)(`small`,{className:`hidden truncate font-mono text-[9px] font-normal text-muted-foreground sm:block`,children:e.description})]}),(0,J.jsx)(`span`,{"aria-hidden":`true`,className:V(`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,J.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,J.jsx)(rn,{}):(0,J.jsx)(R,{children:(0,J.jsx)(Mn,{})})})]})}export{Nn as OfficeMapPanel};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Ia as t,Va as n,lt as r}from"./vendor-AeHpGMaG.js";import"./i18n-nlW2iAya.js";import{t as i}from"./utils-D1fGupR8.js";import{t as a}from"./button-DvHe5h9X.js";import{t as o}from"./input-oJ0Gehqp.js";import{o as s}from"./index-eK0iH6jY.js";var c=e(n(),1),l=r(),u=[`feature`,`bug_fix`,`refactor`,`performance`,`security`,`ui_change`,`api_change`,`infrastructure`,`migration`,`testing`,`documentation`,`maintenance`,`other`,`unspecified`],d=[`unspecified`,`low`,`medium`,`high`,`critical`],f={draft:`bg-muted text-muted-foreground`,collecting_information:`bg-warning/15 text-warning`,submitted:`bg-success/15 text-success`,cancelled:`bg-destructive/15 text-destructive`,archived:`bg-muted text-muted-foreground`};function p(e){let t=Date.now()-e;if(t<6e4)return`just now`;let n=Math.floor(t/6e4);if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function m(){let{t:e}=t(),[n,r]=(0,c.useState)(null),[m,h]=(0,c.useState)([]),[g,_]=(0,c.useState)(!0),[v,y]=(0,c.useState)(null),[b,x]=(0,c.useState)(``),[S,C]=(0,c.useState)(``),[w,T]=(0,c.useState)(`unspecified`),[E,D]=(0,c.useState)(`unspecified`),[O,k]=(0,c.useState)(!1),[A,j]=(0,c.useState)(null),[M,N]=(0,c.useState)(null),P=(0,c.useCallback)(async()=>{_(!0),y(null);try{let e=await fetch(`/api/requirement-intakes`);if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error?.message??`List failed (HTTP ${e.status})`)}let t=await e.json();r(t.projectId),h(t.intakes)}catch(e){y(e instanceof Error?e.message:String(e))}finally{_(!1)}},[]);(0,c.useEffect)(()=>{P()},[P]);let F=(0,c.useCallback)(async()=>{let e=b.trim();if(!e){j(`Describe the request first — it is preserved verbatim.`);return}if(!n){j(`No project identity available yet.`);return}k(!0),j(null),N(null);try{let t=await fetch(`/api/projects/${encodeURIComponent(n)}/requirement-intakes`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({projectId:n,requestedBy:`webui`,originalRequest:e,...S.trim()?{title:S.trim()}:{},...w===`unspecified`?{}:{requestType:w},...E===`unspecified`?{}:{priority:E}})}),r=await t.json().catch(()=>null);if(!t.ok||!r?.record)throw Error(r?.error?.message??`Create failed (HTTP ${t.status})`);let i=await fetch(`/api/requirement-intakes/${r.record.id}/submit`,{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`});if(!i.ok){let e=await i.json().catch(()=>null);throw Error(e?.error?.message??`Submit failed (HTTP ${i.status})`)}N(`Intake recorded and submitted (${r.record.id}).`),x(``),C(``),T(`unspecified`),D(`unspecified`),await P()}catch(e){j(e instanceof Error?e.message:String(e))}finally{k(!1)}},[b,S,w,E,n,P]);return(0,l.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden`,children:[(0,l.jsxs)(`header`,{className:`border-b border-border/70 px-5 py-3`,children:[(0,l.jsx)(`div`,{className:`text-sm font-semibold text-foreground`,children:e(`activity:reqIntake.requirementsIntake`)}),(0,l.jsx)(`div`,{className:`mt-0.5 text-[11px] text-muted-foreground`,children:e(`activity:reqIntake.collectAndPreserveSoftwareDevelopmentRequests`)})]}),(0,l.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-5`,children:[v?(0,l.jsxs)(`div`,{role:`alert`,className:`mb-4 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:[v,(0,l.jsx)(`button`,{type:`button`,className:`ml-2 underline underline-offset-2`,onClick:()=>void P(),children:e(`activity:reqIntake.retry`)})]}):null,(0,l.jsxs)(`section`,{"aria-label":e(`activity:reqIntake.fileANewIntake`),className:`mb-6 rounded-lg border border-border/70 bg-card/60 p-4`,children:[(0,l.jsx)(`div`,{className:`mb-3 text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:e(`activity:reqIntake.fileANewRequest`)}),(0,l.jsxs)(`div`,{className:`space-y-3`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsxs)(`label`,{htmlFor:`intake-request`,className:`mb-1 block text-xs text-foreground`,children:[e(`activity:reqIntake.requestText`),` `,(0,l.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,l.jsx)(`textarea`,{id:`intake-request`,value:b,onChange:e=>x(e.target.value),placeholder:e(`activity:reqIntake.describeTheFeatureBugFixRefactorOrChange`),rows:4,className:i(`w-full resize-y rounded-md border border-border/70 bg-background px-3 py-2`,`text-sm text-foreground placeholder:text-muted-foreground/70`,`focus:outline-none focus:ring-2 focus:ring-ring`)}),(0,l.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:e(`activity:reqIntake.storedVerbatimAsTheRecordApos`)})]}),(0,l.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-3`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{htmlFor:`intake-title`,className:`mb-1 block text-xs text-foreground`,children:e(`activity:reqIntake.titleOptional`)}),(0,l.jsx)(o,{id:`intake-title`,value:S,onChange:e=>C(e.target.value),placeholder:e(`activity:reqIntake.shortDisplayTitle`)})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{htmlFor:`intake-type`,className:`mb-1 block text-xs text-foreground`,children:e(`activity:reqIntake.type`)}),(0,l.jsx)(`select`,{id:`intake-type`,value:w,onChange:e=>T(e.target.value),className:i(`w-full rounded-md border border-border/70 bg-background px-2 py-2`,`text-sm text-foreground focus:outline-none focus:ring-2 focus:ring-ring`),children:u.map(e=>(0,l.jsx)(`option`,{value:e,children:e},e))})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{htmlFor:`intake-priority`,className:`mb-1 block text-xs text-foreground`,children:e(`activity:reqIntake.priority`)}),(0,l.jsx)(`select`,{id:`intake-priority`,value:E,onChange:e=>D(e.target.value),className:i(`w-full rounded-md border border-border/70 bg-background px-2 py-2`,`text-sm text-foreground focus:outline-none focus:ring-2 focus:ring-ring`),children:d.map(e=>(0,l.jsx)(`option`,{value:e,children:e},e))})]})]}),A?(0,l.jsx)(`div`,{role:`alert`,className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:A}):null,M?(0,l.jsx)(`div`,{role:`status`,className:`rounded-md border border-success/30 bg-success/10 px-3 py-2 text-xs text-success`,children:M}):null,(0,l.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,l.jsx)(a,{variant:`secondary`,size:`sm`,disabled:O,onClick:()=>{x(``),j(null),N(null)},children:e(`activity:reqIntake.clear`)}),(0,l.jsx)(a,{size:`sm`,disabled:O||!b.trim(),onClick:()=>void F(),children:O?`Filing…`:`File + submit`})]})]})]}),(0,l.jsxs)(`section`,{"aria-label":e(`activity:reqIntake.intakeRecords`),className:`space-y-2`,children:[(0,l.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,l.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:e(`activity:reqIntake.records`)}),(0,l.jsxs)(`div`,{className:`text-[11px] text-muted-foreground`,children:[m.length,` total`]})]}),g?(0,l.jsx)(`div`,{className:`py-8 text-center text-xs text-muted-foreground`,children:e(`activity:reqIntake.loading`)}):m.length===0?(0,l.jsx)(`div`,{className:`rounded-md border border-dashed border-border/70 py-10 text-center text-xs text-muted-foreground`,children:e(`activity:reqIntake.noIntakeRecordsYetFileThe`)}):(0,l.jsx)(`ul`,{className:`space-y-2`,children:m.map(e=>(0,l.jsxs)(`li`,{className:`rounded-md border border-border/70 bg-card/60 p-3`,children:[(0,l.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,l.jsxs)(`div`,{className:`min-w-0`,children:[(0,l.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,title:e.title,children:e.title}),(0,l.jsx)(`div`,{className:`mt-0.5 font-mono text-[10px] text-muted-foreground`,children:e.id})]}),(0,l.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1.5`,children:[(0,l.jsx)(s,{variant:`secondary`,className:`text-[10px]`,children:e.requestType}),(0,l.jsx)(s,{className:i(`text-[10px]`,f[e.status]??`bg-muted text-muted-foreground`),children:e.status})]})]}),(0,l.jsxs)(`div`,{className:`mt-1.5 text-[11px] text-muted-foreground`,children:[e.priority,` · updated `,p(e.updatedAt)]})]},e.id))})]})]})]})}export{m as RequirementIntakeView};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Gi as t,Ia as n,Mr as r,Ot as i,Pr as a,Qt as o,Tn as s,Ut as c,Va as l,_ as u,_r as d,a as f,ar as p,c as m,dt as h,f as g,ga as _,h as v,i as y,lt as b,mn as x,r as S,s as C,sa as w,ta as T,u as E}from"./vendor-AeHpGMaG.js";import"./i18n-nlW2iAya.js";import{t as D}from"./utils-D1fGupR8.js";var O=e(l(),1),k=b();function A({pct:e}){let{t}=n(),r=(0,O.useId)(),i=2*Math.PI*26,a=i-Math.max(0,Math.min(100,e))/100*i;return(0,k.jsxs)(`div`,{className:`relative h-16 w-16 shrink-0`,children:[(0,k.jsxs)(`svg`,{viewBox:`0 0 64 64`,className:`h-16 w-16 -rotate-90`,role:`img`,"aria-label":t(`activity:progressring.progress`),children:[(0,k.jsx)(`circle`,{cx:`32`,cy:`32`,r:26,fill:`none`,stroke:`hsl(var(--muted))`,strokeWidth:`6`}),(0,k.jsx)(`circle`,{cx:`32`,cy:`32`,r:26,fill:`none`,stroke:`url(#${r})`,strokeWidth:`6`,strokeLinecap:`round`,strokeDasharray:i,strokeDashoffset:a,style:{transition:`stroke-dashoffset 0.6s cubic-bezier(0.16,1,0.3,1)`}}),(0,k.jsx)(`defs`,{children:(0,k.jsxs)(`linearGradient`,{id:r,x1:`0`,y1:`0`,x2:`1`,y2:`1`,children:[(0,k.jsx)(`stop`,{offset:`0%`,stopColor:`hsl(var(--primary))`}),(0,k.jsx)(`stop`,{offset:`100%`,stopColor:`hsl(var(--info))`})]})})]}),(0,k.jsxs)(`div`,{className:`absolute inset-0 flex items-center justify-center text-sm font-bold text-foreground`,children:[Math.round(e),`%`]})]})}var j={pending:{label:`Pending`,icon:t,text:`text-muted-foreground`,ring:`border-border/70 bg-muted/45`,dot:`bg-muted-foreground`,hex:`hsl(var(--muted-foreground))`},queued:{label:`Ready`,icon:t,text:`text-primary`,ring:`border-primary/35 bg-primary/10`,dot:`bg-primary`,hex:`hsl(var(--primary))`},in_progress:{label:`Running`,icon:p,spin:!0,text:`text-warning`,ring:`border-warning/45 bg-warning/10`,dot:`bg-warning`,hex:`hsl(var(--warning))`},blocked:{label:`Blocked`,icon:t,text:`text-destructive`,ring:`border-destructive/30 bg-destructive/10`,dot:`bg-destructive`,hex:`hsl(var(--destructive))`},review:{label:`Review`,icon:t,text:`text-primary`,ring:`border-primary/35 bg-primary/10`,dot:`bg-primary`,hex:`hsl(var(--info))`},failed:{label:`Failed`,icon:h,text:`text-destructive`,ring:`border-destructive/45 bg-destructive/10`,dot:`bg-destructive`,hex:`hsl(var(--destructive))`},completed:{label:`Done`,icon:T,text:`text-success`,ring:`border-success/35 bg-success/10`,dot:`bg-success`,hex:`hsl(var(--success))`},cancelled:{label:`Cancelled`,icon:_,text:`text-muted-foreground`,ring:`border-border/70 bg-muted/45`,dot:`bg-muted-foreground`,hex:`hsl(var(--muted-foreground))`}};function M(e){return j[e]??j.pending}var N={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 P(e){return N[e]??N.medium}var F={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`},I=[`bg-warning`,`bg-primary`,`bg-success`,`bg-destructive`,`bg-secondary`,`bg-muted-foreground`,`bg-accent`],L={started:{icon:s,color:`text-warning`},completed:{icon:T,color:`text-success`},failed:{icon:h,color:`text-destructive`},retrying:{icon:x,color:`text-warning`},wave:{icon:d,color:`text-primary`},deadlock:{icon:i,color:`text-destructive`},verification_failed:{icon:o,color:`text-destructive`},conflict:{icon:r,color:`text-warning`},split:{icon:c,color:`text-primary`},supervisor:{icon:w,color:`text-primary`}};function R(e){let t=e.trim().split(/\s+/);return((t[0]?.[0]??``)+(t[1]?.[0]??``)).toUpperCase()||`·`}function z(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 B(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 V=300,H=128,U=240,W={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 G({data:e}){let r=e.task,{t:i}=n(),o=W[r.displayStatus],s=r.displayStatus===`in_progress`,c=r.displayStatus===`completed`?T:r.displayStatus===`failed`?h:s?p:t;return(0,k.jsxs)(`div`,{className:D(`sdd-node-enter group relative rounded-lg border bg-card/95 px-2.5 py-2 text-left shadow-lg backdrop-blur`,o.ring,s&&`sdd-node-running`,r.displayStatus===`completed`&&`sdd-node-complete`,r.displayStatus===`failed`&&`sdd-node-failed`,e.onTaskClick&&`hover:brightness-125`),style:{width:U,animationDelay:`${Math.min(e.index*45,600)}ms`},children:[e.onTaskClick&&(0,k.jsx)(`button`,{type:`button`,"aria-label":i(`activity:sdd.openTask`,{title:r.title,defaultValue:`Open task: ${r.title}`}),className:`absolute inset-0 z-10 cursor-pointer rounded-lg`,onClick:()=>e.onTaskClick?.(r.id)}),(0,k.jsx)(C,{type:`target`,position:u.Left,isConnectable:!1,className:`!h-1.5 !w-1.5 !border-0 !bg-border`}),(0,k.jsx)(C,{type:`source`,position:u.Right,isConnectable:!1,className:`!h-1.5 !w-1.5 !border-0 !bg-border`}),(0,k.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,k.jsx)(c,{className:D(`h-3.5 w-3.5`,s&&`animate-spin`,o.chip.split(` `).find(e=>e.startsWith(`text`)))}),(0,k.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:r.shortId}),(0,k.jsx)(`span`,{className:D(`font-mono text-[10px] font-bold uppercase`,P(r.priority).text),children:r.priority[0]}),(0,k.jsx)(`span`,{className:D(`ml-auto rounded px-1.5 py-px text-[9px] font-medium`,o.chip),children:i(`activity:sdd.status.${r.displayStatus}`)})]}),(0,k.jsx)(`p`,{className:`mt-1 line-clamp-2 text-[11px] leading-snug text-foreground`,children:r.title}),(r.agentName||r.worktreeBranch)&&(0,k.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5`,children:[r.agentName&&(0,k.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,k.jsx)(`span`,{className:D(`flex h-4 w-4 items-center justify-center rounded-full text-[8px] font-bold text-white`,s?`bg-warning sdd-agent-live`:`bg-muted-foreground`),children:R(r.agentName)}),(0,k.jsx)(`span`,{className:`max-w-[88px] truncate text-[10px] text-muted-foreground`,children:r.agentName})]}),r.retries?(0,k.jsxs)(`span`,{className:`flex items-center gap-0.5 text-[9px] text-destructive`,children:[(0,k.jsx)(x,{className:`h-2.5 w-2.5`}),r.retries]}):null,r.worktreeBranch&&(0,k.jsxs)(`span`,{className:`ml-auto flex items-center gap-0.5 text-[9px] text-muted-foreground`,title:r.worktreeBranch,children:[(0,k.jsx)(a,{className:`h-2.5 w-2.5`}),(0,k.jsx)(`span`,{className:`max-w-[70px] truncate`,children:r.worktreeBranch.replace(/^.*\//,``)})]})]})]})}function K({data:e}){return(0,k.jsx)(`div`,{className:`whitespace-nowrap text-[11px] font-bold uppercase text-muted-foreground`,children:e.label})}var q={task:G,colLabel:K};function J(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*V,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*V,y:o*H},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:M(t.displayStatus).hex,strokeWidth:i?2.2:1.4,opacity:t.displayStatus===`pending`?.4:.85}})}return{nodes:i,edges:o}}function Y({tasks:e,columns:t,onTaskClick:n}){let{fitView:r}=v(),{nodes:i,edges:a}=(0,O.useMemo)(()=>J(e,t,n),[e,t,n]),o=e.length;return(0,O.useEffect)(()=>{let e=setTimeout(()=>r({padding:.18,duration:400}),60);return()=>clearTimeout(e)},[o,r]),(0,k.jsxs)(g,{nodes:i,edges:a,nodeTypes:q,fitView:!0,fitViewOptions:{padding:.18},minZoom:.2,maxZoom:1.6,proOptions:{hideAttribution:!0},nodesConnectable:!1,elementsSelectable:!!n,children:[(0,k.jsx)(S,{variant:y.Dots,gap:22,size:1,color:`hsl(var(--border))`}),(0,k.jsx)(f,{showInteractive:!1,className:`!bottom-2 !left-2`}),(0,k.jsx)(m,{pannable:!0,zoomable:!0,nodeStrokeWidth:2,maskColor:`hsl(var(--background) / 0.65)`,nodeColor:e=>{let t=e.data?.task?.displayStatus;return t?M(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 X({tasks:e,columns:t,onTaskClick:n}){return(0,k.jsx)(E,{children:(0,k.jsx)(Y,{tasks:e,columns:t,onTaskClick:n})})}export{R as a,P as c,F as i,M as l,I as n,B as o,L as r,z as s,X as t,A as u};
|