@wrongstack/webui 0.292.0 → 0.293.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/dist/assets/AnalyticsDashboard--x-f8QI-.js +1 -0
  2. package/dist/assets/AudienceMemoryPanel-j9I0RvhP.js +3 -0
  3. package/dist/assets/{ChangesView-DPfs8VeV.js → ChangesView-Bb5LXWiI.js} +1 -1
  4. package/dist/assets/ChronicleDashboard-D34oKMQ_.js +1 -0
  5. package/dist/assets/{CodeEditor-iYG6Q0ag.js → CodeEditor-BkIIR8EU.js} +1 -1
  6. package/dist/assets/CodeMap-Ej4UNFUm.js +1 -0
  7. package/dist/assets/{ConfirmModal-Bm9f2Pg9.js → ConfirmModal-4l0Tyazp.js} +1 -1
  8. package/dist/assets/{CronJobsPanel-CKQw0vat.js → CronJobsPanel-ByJqIjCv.js} +1 -1
  9. package/dist/assets/{DebugDashboard-BeDOPYmE.js → DebugDashboard-B0pikasm.js} +1 -1
  10. package/dist/assets/{DesignGalleryView-DY3atfBB.js → DesignGalleryView-CgLsdzTx.js} +1 -1
  11. package/dist/assets/{GoalView-Dh27cG1z.js → GoalView-DXO9txQs.js} +1 -1
  12. package/dist/assets/KanbanView--bFrj9Xa.js +2 -0
  13. package/dist/assets/{LazyMarkdown-C1a0wbAZ.js → LazyMarkdown-BHoUIDge.js} +3 -3
  14. package/dist/assets/{MailboxDetailView-DQpxIh_A.js → MailboxDetailView-C-Vf3h1d.js} +1 -1
  15. package/dist/assets/MemoryManager-DoHNBnKd.js +1 -0
  16. package/dist/assets/{ModelPicker-Cwa4UKNc.js → ModelPicker-CEZN673P.js} +1 -1
  17. package/dist/assets/OfficeMapPanel-BMf4PTWo.js +4 -0
  18. package/dist/assets/{ProcessMonitor-DjO7eNsN.js → ProcessMonitor-BtfARuHq.js} +1 -1
  19. package/dist/assets/{QueuePanel-lUChp6xi.js → QueuePanel-DMXksqFS.js} +1 -1
  20. package/dist/assets/{RefreshDebugView-BNa6ehdH.js → RefreshDebugView-D08bCHA4.js} +1 -1
  21. package/dist/assets/SddHub-QgMFn_rC.js +2 -0
  22. package/dist/assets/SessionsDashboard-BY77vax1.js +1 -0
  23. package/dist/assets/SetupScreen-CU7Mq-5T.js +1 -0
  24. package/dist/assets/SkillDetailView-6ZIVx1BG.js +3 -0
  25. package/dist/assets/{SpecsView-CNqNOKqo.js → SpecsView-CZg7e2ml.js} +1 -1
  26. package/dist/assets/TechStackView-9hfnNKx-.js +1 -0
  27. package/dist/assets/{TerminalPanel-KysALyRz.js → TerminalPanel-SnRvUh6N.js} +1 -1
  28. package/dist/assets/{Toaster-B1idXZ-O.js → Toaster-BNdKxZ1U.js} +1 -1
  29. package/dist/assets/{button-99L74zdE.js → button-Dy0bAtEY.js} +1 -1
  30. package/dist/assets/{chat-store-Cunk1nDr.js → chat-store-CUODHW6c.js} +2 -2
  31. package/dist/assets/{codemap-activity-store-BIW6YPvC.js → codemap-activity-store-CgtLR4PV.js} +1 -1
  32. package/dist/assets/{dialog-CNwwBFw3.js → dialog-CBgO-uqz.js} +1 -1
  33. package/dist/assets/{i18n-DaR2GB_4.js → i18n-Dk35g-uV.js} +2 -2
  34. package/dist/assets/index-DGX8tPCe.css +1 -0
  35. package/dist/assets/index-OmSX-BAb.js +124 -0
  36. package/dist/assets/{input-DXjUO_X9.js → input-B6FY_vtB.js} +1 -1
  37. package/dist/assets/{mailbox-store-Dq1wxCRt.js → mailbox-store-BY2SVw-s.js} +1 -1
  38. package/dist/assets/{session-store-B8icONBU.js → session-store-Coiik-Ib.js} +1 -1
  39. package/dist/assets/settings-B9dVH8oJ.js +1 -0
  40. package/dist/assets/settings-BBR9xBqW.js +1 -0
  41. package/dist/assets/settings-BK1-R1dO.js +1 -0
  42. package/dist/assets/{settings-CyzkAhwD.js → settings-BXWyZpz5.js} +1 -1
  43. package/dist/assets/settings-BaZcBGA7.js +1 -0
  44. package/dist/assets/{settings-llUXRsji.js → settings-C65WW7Jn.js} +1 -1
  45. package/dist/assets/settings-Dp5NIt-h.js +1 -0
  46. package/dist/assets/{shared-aSCYBzAV.js → shared-CpXz-tzA.js} +1 -1
  47. package/dist/assets/{stores-JSLvWOQY.js → stores-CUp_ut8r.js} +2 -2
  48. package/dist/assets/ui-store-CwOvhFZG.js +1 -0
  49. package/dist/assets/{useWebSocket-CRYUFxmO.js → useWebSocket-BJorYmOi.js} +1 -1
  50. package/dist/assets/{utils-C4qVQ63O.js → utils-DEzFewqr.js} +1 -1
  51. package/dist/assets/{vendor-Di1mdAi5.js → vendor-DffL_bim.js} +30 -30
  52. package/dist/assets/{view-navigation-BbHlzAQz.js → view-navigation-BjlXpDXc.js} +1 -1
  53. package/dist/assets/{ws-client-BWO_PH_X.js → ws-client-Fnmzo7vN.js} +1 -1
  54. package/dist/components/ContextBreakdownModal.d.ts.map +1 -1
  55. package/dist/components/ContextDashboard.d.ts.map +1 -1
  56. package/dist/components/InspectorPanel.d.ts.map +1 -1
  57. package/dist/components/MemoryManager/MemoryGraph.d.ts.map +1 -1
  58. package/dist/components/MessageBubble/index.d.ts +1 -1
  59. package/dist/components/MessageBubble/index.d.ts.map +1 -1
  60. package/dist/components/SettingsPanel/OAuthLoginSection.d.ts +13 -7
  61. package/dist/components/SettingsPanel/OAuthLoginSection.d.ts.map +1 -1
  62. package/dist/components/SettingsPanel/ProviderSection.d.ts.map +1 -1
  63. package/dist/index.html +22 -23
  64. package/dist/index.js +2688 -2013
  65. package/dist/index.js.map +4 -4
  66. package/dist/lib/view-navigation.d.ts.map +1 -1
  67. package/dist/lib/ws-client.d.ts +1 -1
  68. package/dist/lib/ws-client.d.ts.map +1 -1
  69. package/dist/providers.json +10 -0
  70. package/dist/stores/local-prefs.d.ts +3 -2
  71. package/dist/stores/local-prefs.d.ts.map +1 -1
  72. package/dist/types.d.ts +1 -0
  73. package/dist/types.d.ts.map +1 -1
  74. package/package.json +6 -6
  75. package/dist/assets/AnalyticsDashboard-DausPJOP.js +0 -1
  76. package/dist/assets/AudienceMemoryPanel-di7dxMBb.js +0 -3
  77. package/dist/assets/ChronicleDashboard-CMkQ7EBt.js +0 -1
  78. package/dist/assets/CodeMap-T1dsXVRH.js +0 -1
  79. package/dist/assets/KanbanView-DYa0iSlV.js +0 -2
  80. package/dist/assets/MemoryManager-D1_0SW_m.js +0 -1
  81. package/dist/assets/OfficeMapPanel-DTQPdV7a.js +0 -4
  82. package/dist/assets/SddHub-BW7ExYNe.js +0 -2
  83. package/dist/assets/SessionsDashboard-Cf_67b9g.js +0 -1
  84. package/dist/assets/SetupScreen-fu9Qr5Qj.js +0 -1
  85. package/dist/assets/SkillDetailView-DHcDX_1A.js +0 -3
  86. package/dist/assets/TechStackView-CXE80hAc.js +0 -1
  87. package/dist/assets/index-BLAy5CKD.js +0 -119
  88. package/dist/assets/index-BlCmdyyZ.css +0 -1
  89. package/dist/assets/pagination-Ktuov5iD.js +0 -1
  90. package/dist/assets/settings-4BR882HN.js +0 -1
  91. package/dist/assets/settings-B5P4V9M6.js +0 -1
  92. package/dist/assets/settings-Cjxo5UVP.js +0 -1
  93. package/dist/assets/settings-CnViO4_M.js +0 -1
  94. package/dist/assets/settings-jrfJX8W2.js +0 -1
  95. package/dist/assets/ui-store-BepZz9CZ.js +0 -1
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Bn as t,Bt as n,Cn as r,Ct as i,Dt as a,Ft as o,Gi as s,Hr as c,Ii as l,Nt as u,Or as d,Qi as f,Rr as p,Si as m,Ti as h,Vr as g,Wr as _,Xi as ee,Xr as v,Yt as y,_ as b,_n as te,_r as x,a as S,bt as ne,cn as C,dn as w,dr as re,f as T,fn as E,gi as D,gn as ie,i as O,ji as k,n as A,oa as ae,ot as oe,pr as se,qn as ce,qt as le,r as ue,rn as de,s as fe,si as pe,tt as me,ui as j}from"./vendor-DffL_bim.js";import{n as he}from"./ui-store-CwOvhFZG.js";import{i as M,t as ge}from"./useWebSocket-BJorYmOi.js";import{t as _e}from"./ws-client-Fnmzo7vN.js";import{t as N}from"./utils-DEzFewqr.js";import{j as ve}from"./stores-CUp_ut8r.js";import{a as ye,i as be,n as xe,o as Se,r as Ce,t as we}from"./dialog-CBgO-uqz.js";import{t as P}from"./button-Dy0bAtEY.js";import{t as F}from"./input-B6FY_vtB.js";import{d as Te,u as Ee,v as De}from"./index-OmSX-BAb.js";import{_ as Oe,a as ke,b as I,c as L,d as Ae,f as je,g as Me,h as R,i as Ne,l as z,m as Pe,n as Fe,o as Ie,p as B,r as V,s as Le,t as Re,u as ze,v as H,y as U}from"./shared-CpXz-tzA.js";var W=e(ae(),1),G=me(),K=212,q=188;function Be(e){return e.length>14?`${e.slice(0,11)}…`:e}function Ve(e,t=58){let n=e.replace(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t-1)}…`:n}function He(e){return e.type===`symbol`?[e.path,e.symbol?`#${e.symbol}`:``].filter(Boolean).join(``):e.path??e.command??e.symbol??e.type}function Ue(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 We({data:e}){let{entry:t,center:n}=e;return(0,G.jsxs)(`div`,{className:n?`border border-primary/70 bg-card px-3 py-2.5 text-card-foreground shadow-[0_0_0_1px_hsl(var(--primary)/0.2),0_0_24px_hsl(var(--primary)/0.12)]`:`border border-border/80 bg-card/95 px-3 py-2.5 text-card-foreground shadow-lg`,style:{width:K},title:t.text,children:[(0,G.jsx)(fe,{type:`target`,position:b.Top,className:`!border-background !bg-muted-foreground`}),(0,G.jsx)(fe,{type:`source`,position:b.Bottom,className:`!border-background !bg-primary`}),(0,G.jsx)(fe,{type:`source`,position:b.Right,className:`!border-background !bg-primary`}),(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`border px-1.5 py-0.5 text-[9px] font-bold uppercase ${Ue(t.status)}`,children:t.status}),(0,G.jsx)(`span`,{className:`ml-auto truncate font-mono text-[9px] text-muted-foreground`,children:Be(t.id)})]}),(0,G.jsx)(`p`,{className:`mt-2 line-clamp-2 text-[11px] leading-4 text-foreground/90`,children:Ve(t.text)}),(0,G.jsx)(`p`,{className:`mt-1 font-mono text-[9px] uppercase text-muted-foreground`,children:t.kind})]})}function Ge({data:e}){return(0,G.jsxs)(`div`,{className:`border border-info/40 bg-info/8 px-2.5 py-2 text-card-foreground shadow-lg`,style:{width:q},title:e.label,children:[(0,G.jsx)(fe,{type:`target`,position:b.Left,className:`!border-background !bg-info`}),(0,G.jsx)(`p`,{className:`font-mono text-[9px] font-bold uppercase text-info`,children:e.anchor.type}),(0,G.jsx)(`p`,{className:`mt-1 truncate font-mono text-[10px] text-foreground/85`,children:e.label})]})}var Ke={memoryNode:We,anchorNode:Ge};function qe(e){return{id:e,revision:0,scope:`project`,kind:`fact`,status:`deleted`,text:`Memory is unavailable or has been removed.`,importance:0,confidence:0,freshness:0,tags:[],anchors:[],createdAt:``,updatedAt:``}}function Je({nodes:e,edges:t,className:n}){return(0,G.jsx)(`div`,{className:N(`w-full`,n),children:(0,G.jsxs)(T,{nodes:e,edges:t,nodeTypes:Ke,fitView:!0,fitViewOptions:{padding:.24,maxZoom:1.05},minZoom:.4,maxZoom:1.5,nodesConnectable:!1,elementsSelectable:!1,panOnScroll:!1,zoomOnScroll:!1,proOptions:{hideAttribution:!0},children:[(0,G.jsx)(ue,{variant:O.Dots,gap:18,size:1,color:`hsl(var(--muted-foreground) / 0.18)`}),(0,G.jsx)(S,{showInteractive:!1,className:`!border-border !bg-card !shadow-lg`})]})})}function Ye({centerMemory:e,allMemories:t,graphEdges:n,loading:r=!1,error:i=null}){let[a,o]=(0,W.useState)(!1),s=`mem:${e.id}`,c=(0,W.useMemo)(()=>n.filter(e=>e.from===s&&e.to.startsWith(`mem:`)||e.to===s&&e.from.startsWith(`mem:`)).slice(0,24),[s,n]),{nodes:l,edges:u}=(0,W.useMemo)(()=>{let n=[],r=[],i=new Map(t.map(e=>[e.id,e]));n.push({id:e.id,type:`memoryNode`,position:{x:320-K/2,y:120},data:{entry:e,center:!0}});let a=[...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 c){let t=(e.from===s?e.to:e.from).slice(4);a.some(n=>n.id===t&&n.relation===e.relation)||a.push({id:t,relation:e.relation,weight:e.weight,evidence:e.evidence})}let o=320-(a.length-1)*220/2;return a.forEach((t,a)=>{let s=i.get(t.id)??qe(t.id),c=t.relation===`superseded by`,l=c?0:280+Math.floor(a/3)*130,u=c?320-K/2:o+a*220-K/2;n.push({id:`memory:${t.id}:${a}`,type:`memoryNode`,position:{x:u,y:l},data:{entry:s,center:!1}});let d=t.relation===`contradicts`,f=c?`memory:${t.id}:${a}`:e.id,p=c?e.id:`memory:${t.id}:${a}`;r.push({id:`relation:${t.relation}:${t.id}:${a}`,source:f,target:p,type:`smoothstep`,animated:!d,label:t.weight===void 0?t.relation:`${t.relation} ${t.weight.toFixed(2)}`,data:{evidence:t.evidence??[]},style:{stroke:d?`hsl(var(--destructive))`:`hsl(var(--primary))`,strokeWidth:1.7,...d?{strokeDasharray:`5 4`}:{}},labelStyle:{fill:d?`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:He(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,s,c]);return l.length<=1&&!r&&!i?null:(0,G.jsxs)(`section`,{className:`overflow-hidden border border-border/75 bg-background/35`,"aria-label":`Memory relationship graph`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/70 bg-card/55 px-3 py-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-muted-foreground`,children:`Relationship map`}),l.length>1&&(0,G.jsxs)(P,{variant:`ghost`,size:`sm`,onClick:()=>o(!0),className:`h-6 gap-1 px-2 text-[9px] font-bold uppercase tracking-[0.12em]`,"aria-label":`Open full screen graph`,children:[(0,G.jsx)(_,{className:`size-3`}),`Open full screen`]})]}),(0,G.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:r?`loading real graph…`:`${l.length} nodes · ${u.length} edges`})]}),i&&(0,G.jsx)(`p`,{className:`border-b border-destructive/25 bg-destructive/5 px-3 py-2 text-[10px] text-destructive`,children:i}),l.length>1&&(0,G.jsx)(Je,{nodes:l,edges:u,className:`h-[320px]`}),c.some(e=>e.evidence?.length)&&(0,G.jsx)(`div`,{className:`grid gap-1 border-t border-border/70 bg-card/35 px-3 py-2`,children:c.filter(e=>e.evidence?.length).slice(0,12).map(e=>{let t=(e.from===s?e.to:e.from).slice(4);return(0,G.jsxs)(`p`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:[(0,G.jsx)(`span`,{className:`text-info`,children:e.relation}),` `,Be(t),` · why:`,` `,e.evidence?.join(`, `)]},e.id)})}),a&&(0,G.jsx)(we,{open:a,onOpenChange:o,children:(0,G.jsxs)(xe,{className:`flex max-h-[90dvh] max-w-[90vw] flex-col p-0`,showCloseButton:!1,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/70 bg-card/55 px-4 py-3`,children:[(0,G.jsxs)(`p`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-muted-foreground`,children:[`Relationship map — `,e.id]}),(0,G.jsx)(P,{variant:`ghost`,size:`sm`,onClick:()=>o(!1),className:`h-7 gap-1 px-2 text-[10px]`,children:`Close`})]}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1 px-4 pb-4`,children:(0,G.jsx)(Je,{nodes:l,edges:u,className:`h-[65vh]`})})]})})]})}function Xe({memory:e,allMemories:t,relatedMemories:n,graphEdges:r,graphLoading:a,graphError:o,onClose:c,onOpenMemory:l,onEdit:u,onDelete:d,onTagSelect:f,onNotice:p}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-border/70 bg-card/65 px-4 py-3 backdrop-blur-xl`,children:[(0,G.jsx)(P,{variant:`ghost`,size:`icon`,className:`md:hidden`,onClick:c,"aria-label":`Back to memory list`,children:(0,G.jsx)(s,{className:`size-4`})}),(0,G.jsx)(`span`,{className:N(`text-[10px] font-bold uppercase tracking-[0.14em]`,R(e.kind)),children:V[e.kind]??e.kind}),(0,G.jsx)(z,{status:e.status}),(0,G.jsx)(`span`,{className:`border border-border/70 px-2 py-0.5 font-mono text-[9px] uppercase text-muted-foreground`,children:e.scope}),e.audience&&(0,G.jsxs)(`span`,{className:`flex items-center gap-1 border border-primary/30 bg-primary/10 px-2 py-0.5 font-mono text-[9px] text-primary`,title:B(e.audience),children:[(0,G.jsx)(k,{className:`size-3`}),B(e.audience)]}),(0,G.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,G.jsx)(P,{variant:`ghost`,size:`icon`,"aria-label":`Copy memory ID`,title:`Copy memory ID`,onClick:()=>{navigator.clipboard?.writeText(e.id),p(`Memory ID copied.`)},children:(0,G.jsx)(pe,{className:`size-4`})}),(0,G.jsxs)(P,{variant:`outline`,size:`sm`,onClick:u,disabled:e.status===`deleted`,children:[(0,G.jsx)(E,{className:`size-3.5`}),` Edit`]}),(0,G.jsxs)(P,{variant:`destructive`,size:`sm`,onClick:d,disabled:e.status===`deleted`,children:[(0,G.jsx)(i,{className:`size-3.5`}),` Delete`]})]})]}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-4 md:p-5`,children:(0,G.jsxs)(`div`,{className:`mx-auto max-w-5xl space-y-5`,children:[(0,G.jsx)(Ze,{memory:e}),(0,G.jsx)(Qe,{memory:e}),e.tags.length>0&&(0,G.jsx)($e,{tags:e.tags,onTagSelect:f}),e.anchors.length>0&&(0,G.jsx)(et,{anchors:e.anchors}),n.length>0&&(0,G.jsx)(tt,{relatedMemories:n,allMemories:t,onOpenMemory:l}),(0,G.jsx)(Ye,{centerMemory:e,allMemories:t,graphEdges:r,loading:a,error:o}),(0,G.jsx)(nt,{memory:e}),e.status===`deleted`&&(0,G.jsx)(rt,{contextPolicy:e.contextPolicy})]})})]})}function Ze({memory:e}){return(0,G.jsxs)(`div`,{className:`relative overflow-hidden border border-border/75 bg-card/55 p-5 shadow-[inset_0_1px_0_hsl(var(--foreground)/0.04)]`,children:[(0,G.jsx)(`div`,{className:`pointer-events-none absolute -right-10 -top-10 size-36 bg-[radial-gradient(circle,hsl(var(--info)/0.13),transparent_68%)]`}),(0,G.jsx)(`p`,{className:`relative whitespace-pre-wrap text-sm leading-7 text-foreground md:text-[15px]`,children:e.text}),e.summary&&(0,G.jsx)(`p`,{className:`relative mt-4 border-l-2 border-info/50 pl-3 text-xs italic leading-5 text-muted-foreground`,children:e.summary}),(0,G.jsxs)(`div`,{className:`relative mt-5 flex flex-wrap items-center gap-2 border-t border-border/60 pt-3`,children:[(0,G.jsx)(`code`,{className:`min-w-0 break-all font-mono text-[10px] text-muted-foreground`,children:e.id}),(0,G.jsxs)(`span`,{className:`ml-auto font-mono text-[10px] text-muted-foreground`,children:[`revision `,e.revision]})]})]})}function Qe({memory:e}){return(0,G.jsx)(`div`,{className:`grid gap-px bg-border/60 sm:grid-cols-3`,children:[[`Importance`,e.importance,n],[`Confidence`,e.confidence,D],[`Freshness`,e.freshness,de]].map(([e,t,n])=>(0,G.jsxs)(`div`,{className:`bg-card/60 p-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(n,{className:`size-3.5 text-info`}),(0,G.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.13em] text-muted-foreground`,children:e}),(0,G.jsxs)(`span`,{className:`ml-auto font-mono text-xs font-bold tabular-nums`,children:[Math.round(t*100),`%`]})]}),(0,G.jsx)(`div`,{className:`mt-2 h-1 bg-muted`,children:(0,G.jsx)(`div`,{className:`h-full bg-info shadow-[0_0_8px_hsl(var(--info)/0.45)]`,style:{width:`${Math.round(t*100)}%`}})})]},e))})}function $e({tags:e,onTagSelect:t}){return(0,G.jsxs)(`section`,{children:[(0,G.jsxs)(`h3`,{className:`mb-2 flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:[(0,G.jsx)(a,{className:`size-3.5 text-info`}),` Tags`]}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>t(e),className:`border border-info/25 bg-info/5 px-2 py-1 font-mono text-[10px] text-info hover:border-info/55 hover:bg-info/10`,children:[`#`,e]},e))})]})}function et({anchors:e}){return(0,G.jsxs)(`section`,{className:`border border-border/75 bg-card/40`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/65 px-3 py-2.5`,children:[(0,G.jsxs)(`h3`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:[(0,G.jsx)(p,{className:`size-3.5 text-info`}),` Anchors`]}),(0,G.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.length})]}),(0,G.jsx)(`ul`,{className:`divide-y divide-border/55`,children:e.map((e,t)=>(0,G.jsxs)(`li`,{className:`flex min-w-0 items-start gap-3 px-3 py-2.5`,children:[(0,G.jsx)(`span`,{className:`mt-0.5 flex size-7 shrink-0 items-center justify-center border border-info/25 bg-info/5 text-info`,children:e.type===`command`?(0,G.jsx)(u,{className:`size-3.5`}):(0,G.jsx)(p,{className:`size-3.5`})}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`p`,{className:`text-[9px] font-bold uppercase text-muted-foreground`,children:e.type}),(0,G.jsxs)(`p`,{className:`mt-0.5 break-all font-mono text-[10px] leading-4 text-foreground/85`,children:[e.path??e.command??`—`,e.symbol?`#${e.symbol}`:``]})]}),(e.lineStart||e.lineEnd)&&(0,G.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono text-[9px] text-muted-foreground`,children:[`L`,e.lineStart??`?`,`–`,e.lineEnd??`?`]})]},`${e.type}:${e.path??e.command??e.symbol}:${t}`))})]})}function tt({relatedMemories:e,allMemories:t,onOpenMemory:n}){return(0,G.jsxs)(`section`,{className:`border border-border/75 bg-card/40`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/65 px-3 py-2.5`,children:[(0,G.jsxs)(`h3`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:[(0,G.jsx)(se,{className:`size-3.5 text-info`}),` Memory relationships`]}),(0,G.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.length})]}),(0,G.jsx)(`ul`,{className:`divide-y divide-border/55`,children:e.map(e=>{let r=t.find(t=>t.id===e.id);return(0,G.jsx)(`li`,{children:(0,G.jsxs)(`button`,{type:`button`,disabled:!r,onClick:()=>r&&n(r.id),className:`group flex w-full min-w-0 items-center gap-3 px-3 py-2.5 text-left hover:bg-info/5 disabled:cursor-not-allowed disabled:opacity-55`,children:[(0,G.jsx)(`span`,{className:N(`w-24 shrink-0 text-[9px] font-bold uppercase`,e.relation===`Contradicts`?`text-destructive`:`text-info`),children:e.relation}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs`,children:r?Me(r.text,95):`Referenced memory is unavailable`}),(0,G.jsx)(`code`,{className:`hidden max-w-32 truncate font-mono text-[9px] text-muted-foreground sm:block`,children:e.id}),r&&(0,G.jsx)(m,{className:`size-3.5 shrink-0 text-muted-foreground group-hover:text-info`})]})},`${e.relation}:${e.id}`)})})]})}function nt({memory:e}){return(0,G.jsx)(`section`,{className:`grid gap-px bg-border/60 sm:grid-cols-2 lg:grid-cols-4`,children:[[`Created`,Pe(e.createdAt),l],[`Updated`,Pe(e.updatedAt),de],[`Last accessed`,Pe(e.lastAccessedAt),r],[`Last verified`,Pe(e.lastVerifiedAt),n]].map(([e,t,n])=>(0,G.jsxs)(`div`,{className:`bg-card/50 p-3`,children:[(0,G.jsx)(n,{className:`size-3.5 text-muted-foreground`}),(0,G.jsx)(`p`,{className:`mt-2 text-[9px] font-bold uppercase tracking-[0.12em] text-muted-foreground`,children:e}),(0,G.jsx)(`p`,{className:`mt-1 text-[10px] leading-4 text-foreground/85`,children:t})]},e))})}function rt({contextPolicy:e}){return(0,G.jsxs)(`div`,{className:`flex items-start gap-3 border border-border bg-muted/50 p-4 text-xs text-muted-foreground`,children:[(0,G.jsx)(ee,{className:`mt-0.5 size-4 shrink-0`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-bold text-foreground`,children:`Deleted memory`}),(0,G.jsx)(`p`,{className:`mt-1 leading-5`,children:e===`never`?`This record is audit-only and carries an absolute ban: it can never enter LLM context.`:`The record is inactive and cannot be edited, but remains eligible as historical evidence when retrieval finds it relevant.`})]})]})}var it={filePath:``,primaryMatches:[],symbolMatches:[],relatedMatches:[],totalCount:0,activeCount:0,supersededCount:0,reviewPendingCount:0};function J(e){let{filePath:t,lineStart:n,lineEnd:r,limit:i=50,showSuperseded:a=!0,showDeleted:o=!1,autoFetch:s=!0,sendOptions:c}=e,l=c?JSON.stringify(c):``,[u,d]=(0,W.useState)(null),[f,p]=(0,W.useState)(!1),[m,h]=(0,W.useState)(null),g=(0,W.useRef)(0),_=(0,W.useRef)(null),ee=(0,W.useRef)(c);ee.current=c;let v=(0,W.useCallback)(()=>{if(!t){d(null),h(null),p(!1);return}let e=++g.current;p(!0),h(null);let s=_e();if(!s){h(`WebSocket client unavailable`),p(!1);return}_.current?.(),_.current=null;let c=t,l=s.on(`memory.super.forFile`,t=>{if(e!==g.current)return;let n=t.payload.response;n&&n.filePath!==c||(t.payload.error?(h(t.payload.error),d(null)):(d(n??it),h(null)),p(!1))});_.current=l;let u={filePath:t,limit:i,showSuperseded:a,showDeleted:o,...n===void 0?{}:{lineStart:n},...r===void 0?{}:{lineEnd:r}};try{s.findMemoriesForFile(u,ee.current??void 0)}catch(t){l(),_.current===l&&(_.current=null),e===g.current&&(h(t instanceof Error?t.message:String(t)),p(!1))}},[t,n,r,i,a,o]);(0,W.useEffect)(()=>{if(s)return v(),()=>{g.current++,_.current?.(),_.current=null}},[s,v,l]);let y=(0,W.useCallback)(()=>{v()},[v]);return(0,W.useEffect)(()=>()=>{_.current?.(),_.current=null},[]),{data:u,loading:f,error:m,refetch:y}}function at(e){return e>=.9?`bg-success/15 border-success/40`:e>=.7?`bg-info/15 border-info/40`:e>=.4?`bg-warning/10 border-warning/30`:`bg-muted/30 border-border/40`}function Y(e){switch(e){case`scope_file`:return`scope: file`;case`scope_symbol`:return`scope: symbol`;case`anchor_file`:return`anchor: file`;case`anchor_symbol`:return`anchor: symbol`;case`anchor_directory`:return`anchor: directory`;case`mention`:return`text mention`}}function ot({match:e,cursorBoosted:n,onShowMemory:r,onAcceptDeletion:i,onKeep:a,onUpdate:s,onMarkPermanent:c,onRecover:l,pendingAction:u}){let d=e.memory.status===`deleted`,f=e.memory.status===`superseded`,p=e.pendingReview,m=u!==void 0,_=n===!0;return(0,G.jsxs)(`article`,{className:N(`group relative rounded-md border px-3 py-2 text-sm transition-colors`,at(e.matchStrength),_&&`ring-1 ring-primary/40 ring-offset-0`,d&&`opacity-70`),"data-match-via":e.matchedVia,"data-memory-id":e.memory.id,children:[(0,G.jsx)(`header`,{className:`flex items-start justify-between gap-2`,children:(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] uppercase tracking-wide`,children:[(0,G.jsx)(`span`,{className:N(`font-mono`,R(e.memory.kind)),children:V[e.memory.kind]??e.memory.kind}),(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`·`}),(0,G.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:Y(e.matchedVia)}),_&&(0,G.jsxs)(`span`,{className:`flex items-center gap-0.5 rounded-sm bg-primary/15 px-1 py-0.5 font-mono text-primary`,title:`Cursor line range matches this memory's anchor`,children:[(0,G.jsx)(w,{className:`size-2.5`}),` cursor`]}),p&&(0,G.jsxs)(`span`,{className:`flex items-center gap-0.5 rounded-sm bg-warning/15 px-1 py-0.5 font-mono text-warning`,title:`Hygiene review: ${p.reason} (${p.ageDays}d old)`,children:[(0,G.jsx)(ne,{className:`size-2.5`}),` review`]}),d&&(0,G.jsx)(`span`,{className:`font-mono text-destructive`,children:`deleted`}),f&&!d&&(0,G.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:`superseded`})]}),(0,G.jsx)(`p`,{className:`mt-1 text-foreground/90`,children:Me(e.memory.text,200)}),(0,G.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,G.jsx)(z,{status:e.memory.status}),(0,G.jsxs)(`span`,{children:[`updated `,H(e.memory.updatedAt)]})]})]})}),(0,G.jsxs)(`footer`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,children:[d&&l&&(0,G.jsxs)(P,{type:`button`,size:`sm`,variant:`outline`,disabled:m,onClick:()=>l(e.memory.id),className:`h-7 gap-1 border-primary/40 px-2 text-[11px] text-primary hover:bg-primary/10`,title:`Restore this memory to active status (PR #1: memory_recover)`,children:[(0,G.jsx)(de,{className:`size-3`}),` Recover`]}),f&&e.supersededByActiveId&&r&&(0,G.jsxs)(P,{type:`button`,size:`sm`,variant:`outline`,disabled:m,onClick:()=>r(e.supersededByActiveId),className:`h-7 gap-1 px-2 text-[11px]`,title:`This version is superseded — jump to the active version`,children:[(0,G.jsx)(re,{className:`size-3`}),` Go to active`]}),p&&(0,G.jsxs)(G.Fragment,{children:[p.suggestedAction===`delete`&&(0,G.jsxs)(P,{type:`button`,size:`sm`,variant:`destructive`,disabled:m,onClick:()=>i?.(p.candidateId,e.memory.id),className:`h-7 gap-1 px-2 text-[11px]`,title:`Accept hygiene's deletion suggestion — memory will be forgotten`,children:[(0,G.jsx)(h,{className:`size-3`}),` Accept Deletion`]}),(0,G.jsxs)(P,{type:`button`,size:`sm`,variant:`outline`,disabled:m,onClick:()=>a?.(p.candidateId,e.memory.id),className:`h-7 gap-1 px-2 text-[11px]`,title:`Reject the suggestion — memory stays as-is and may be re-suggested later`,children:[(0,G.jsx)(oe,{className:`size-3`}),` Keep`]}),(0,G.jsxs)(P,{type:`button`,size:`sm`,variant:`outline`,disabled:m,onClick:()=>s?.(e.memory.id),className:`h-7 gap-1 px-2 text-[11px]`,title:`Update the memory's content — versioning creates a new active record`,children:[(0,G.jsx)(o,{className:`size-3`}),` Update`]}),c&&(0,G.jsxs)(P,{type:`button`,size:`sm`,variant:`outline`,disabled:m,onClick:()=>c(e.memory.id),className:`h-7 gap-1 border-warning/40 px-2 text-[11px] text-warning hover:bg-warning/10`,title:"Promote to `permanent` — hygiene will never surface this again",children:[(0,G.jsx)(w,{className:`size-3`}),` Mark as Permanent`]})]}),r&&!d&&(0,G.jsxs)(P,{type:`button`,size:`sm`,variant:`ghost`,disabled:m,onClick:()=>r(e.memory.id),className:`h-7 gap-1 px-2 text-[11px] text-muted-foreground hover:text-foreground`,title:`Open the full record in MemoryManager`,children:[(0,G.jsx)(g,{className:`size-3`}),` Show full`]}),u&&(0,G.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 text-[10px] text-muted-foreground`,children:[(0,G.jsx)(t,{className:`size-3 animate-spin`}),` `,u]})]})]})}function X({icon:e,title:t,count:n,matches:r,cursorBoosted:i=!1,...a}){let o=Te(r,10);return r.length===0?null:(0,G.jsxs)(`section`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsxs)(`h3`,{className:`flex items-center gap-1.5 px-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[(0,G.jsx)(e,{className:`size-3`}),(0,G.jsx)(`span`,{children:t}),(0,G.jsxs)(`span`,{className:`font-mono`,children:[`(`,n,`)`]}),i&&(0,G.jsxs)(`span`,{className:`ml-auto flex items-center gap-0.5 font-mono text-[9px] text-primary`,children:[(0,G.jsx)(w,{className:`size-2.5`}),` cursor boost`]})]}),(0,G.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:o.pageItems.map(e=>(0,G.jsx)(ot,{match:e,cursorBoosted:i&&(e.matchedVia===`anchor_symbol`||e.matchedVia===`scope_symbol`),pendingAction:a.pendingActionById.get(e.memory.id),...a},e.memory.id))}),(0,G.jsx)(Ee,{page:o.page,pageSize:o.pageSize,totalItems:o.totalItems,onPageChange:o.setPage,compact:!0,itemLabel:`memories`})]})}function st({filePath:e,lineStart:t,lineEnd:n,open:r,onClose:i,onShowMemory:a,onAcceptDeletion:o,onKeep:s,onUpdate:l,onMarkPermanent:u,onRecover:f}){let[p,m]=(0,W.useState)(!1),[h,_]=(0,W.useState)(new Map),{data:ee,loading:v,error:y,refetch:b}=J({filePath:e,lineStart:t,lineEnd:n,showDeleted:p,autoFetch:r}),te=t!==void 0&&n!==void 0,x=(0,W.useCallback)(async(e,t,n)=>{if(n){_(n=>new Map(n).set(e,t));try{await n(e)}finally{_(t=>{let n=new Map(t);return n.delete(e),n})}}},[]);if((0,W.useEffect)(()=>{m(!1)},[e]),!r)return null;let S=ee,C=S?.totalCount??0;return(0,G.jsxs)(`aside`,{className:`flex h-full min-h-0 w-full flex-col border-l border-border/70 bg-card/15`,"aria-label":`File memory drawer`,"data-file-path":e??``,children:[(0,G.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-border/60 px-3 py-2`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] uppercase tracking-wide text-muted-foreground`,children:[(0,G.jsx)(d,{className:`size-3`}),(0,G.jsx)(`span`,{className:`truncate font-mono`,title:e??``,children:e??`(no file)`})]}),(0,G.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,G.jsxs)(`span`,{className:`font-mono`,children:[C,` memories`]}),S&&S.reviewPendingCount>0&&(0,G.jsxs)(`span`,{className:`flex items-center gap-0.5 font-mono text-warning`,children:[(0,G.jsx)(ne,{className:`size-3`}),S.reviewPendingCount,` pending review`]}),S&&S.supersededCount>0&&(0,G.jsxs)(`span`,{className:`font-mono`,children:[S.supersededCount,` superseded`]})]})]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,G.jsx)(P,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>b(),disabled:v||!e,className:`h-7 w-7 p-0`,"aria-label":`Refresh`,title:`Re-query for this file`,children:(0,G.jsx)(de,{className:N(`size-3.5`,v&&`animate-spin`)})}),(0,G.jsx)(P,{type:`button`,size:`sm`,variant:`ghost`,onClick:i,className:`h-7 w-7 p-0`,"aria-label":`Close drawer`,title:`Close memory drawer`,children:(0,G.jsx)(j,{className:`size-3.5`})})]})]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-border/40 bg-background/40 px-3 py-1.5 text-[10px] text-muted-foreground`,children:[(0,G.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:p,onChange:e=>m(e.target.checked),className:`size-3 accent-primary`,disabled:!e,"data-testid":`memory-drawer-show-deleted`}),p?(0,G.jsx)(g,{className:`size-3`}):(0,G.jsx)(c,{className:`size-3`}),(0,G.jsx)(`span`,{children:`Show recoverable (deleted)`})]}),te&&(0,G.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 font-mono text-[10px] text-primary`,children:[(0,G.jsx)(w,{className:`size-3`}),` lines `,t,`–`,n]})]}),(0,G.jsx)(`div`,{className:`flex-1 overflow-y-auto px-3 py-3`,children:e?v&&!S?(0,G.jsx)(ct,{loading:!0,message:`Loading memories…`}):y?(0,G.jsx)(ct,{tone:`error`,message:`Error: ${y}`}):!S||C===0?(0,G.jsx)(ct,{message:`No memories attached to ${e} yet.`}):(0,G.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,G.jsx)(X,{icon:w,title:`Cursor boost`,count:S.symbolMatches.length,cursorBoosted:te,matches:S.symbolMatches,pendingActionById:h,onShowMemory:a,onAcceptDeletion:(e,t)=>x(t,`accepting…`,()=>o?.(e,t)),onKeep:(e,t)=>x(t,`keeping…`,()=>s?.(e,t)),onUpdate:e=>x(e,`updating…`,()=>l?.(e)),onMarkPermanent:e=>x(e,`marking…`,()=>u?.(e)),onRecover:e=>x(e,`recovering…`,()=>f?.(e))}),(0,G.jsx)(X,{icon:d,title:`File-scoped`,count:S.primaryMatches.length,matches:S.primaryMatches,pendingActionById:h,onShowMemory:a,onAcceptDeletion:(e,t)=>x(t,`accepting…`,()=>o?.(e,t)),onKeep:(e,t)=>x(t,`keeping…`,()=>s?.(e,t)),onUpdate:e=>x(e,`updating…`,()=>l?.(e)),onMarkPermanent:e=>x(e,`marking…`,()=>u?.(e)),onRecover:e=>x(e,`recovering…`,()=>f?.(e))}),(0,G.jsx)(X,{icon:g,title:`Mentioned in`,count:S.relatedMatches.length,matches:S.relatedMatches,pendingActionById:h,onShowMemory:a,onAcceptDeletion:(e,t)=>x(t,`accepting…`,()=>o?.(e,t)),onKeep:(e,t)=>x(t,`keeping…`,()=>s?.(e,t)),onUpdate:e=>x(e,`updating…`,()=>l?.(e)),onMarkPermanent:e=>x(e,`marking…`,()=>u?.(e)),onRecover:e=>x(e,`recovering…`,()=>f?.(e))})]}):(0,G.jsx)(ct,{message:`Open a file to see its memories.`})})]})}function ct({message:e,loading:n=!1,tone:r=`default`}){return(0,G.jsxs)(`div`,{className:N(`flex min-h-[120px] flex-col items-center justify-center gap-2 rounded-md border border-dashed border-border/60 px-4 py-6 text-center text-[11px]`,r===`error`?`text-destructive`:`text-muted-foreground`),children:[n&&(0,G.jsx)(t,{className:`size-4 animate-spin`}),(0,G.jsx)(`p`,{children:e})]})}function lt({mode:e,draft:n,busy:r,error:a,onChange:s,onCancel:c,onSubmit:l}){let u=(0,W.useRef)(null);(0,W.useEffect)(()=>{u.current?.focus()},[]);let d=(e,t)=>{s({...n,[e]:t})},f=()=>{d(`anchors`,[...n.anchors,{type:`file`,path:``}])};return(0,G.jsxs)(`form`,{className:`flex min-h-0 flex-1 flex-col`,onSubmit:e=>{e.preventDefault(),l()},"aria-busy":r,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-border/70 bg-card/70 px-4 py-3 backdrop-blur-xl`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`flex size-8 items-center justify-center border border-info/35 bg-info/10 text-info`,children:e===`create`?(0,G.jsx)(o,{className:`size-4`}):(0,G.jsx)(E,{className:`size-4`})}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`p`,{className:`truncate text-sm font-bold`,children:e===`create`?`Capture a memory`:`Edit memory`}),(0,G.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:e===`create`?`Add durable knowledge with retrieval metadata.`:`Update content without losing provenance.`})]})]}),(0,G.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,G.jsxs)(P,{type:`button`,variant:`ghost`,size:`sm`,onClick:c,disabled:r,children:[(0,G.jsx)(oe,{className:`size-3.5`}),` Cancel`]}),(0,G.jsxs)(P,{type:`submit`,size:`sm`,disabled:r||!n.text.trim(),children:[r?(0,G.jsx)(t,{className:`size-3.5 animate-spin`}):e===`create`?(0,G.jsx)(C,{className:`size-3.5`}):(0,G.jsx)(y,{className:`size-3.5`}),r?`Saving…`:e===`create`?`Create memory`:`Save changes`]})]})]}),(0,G.jsx)(`div`,{className:`flex-1 overflow-y-auto overscroll-contain p-4 md:p-5`,children:(0,G.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-5`,children:[a&&(0,G.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-2 border border-destructive/40 bg-destructive/10 px-3 py-2.5 text-sm text-destructive`,children:[(0,G.jsx)(ne,{className:`mt-0.5 size-4 shrink-0`}),(0,G.jsx)(`span`,{children:a})]}),(0,G.jsxs)(`section`,{className:`border border-border/75 bg-card/45 p-4`,children:[(0,G.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-xs font-bold uppercase tracking-[0.14em]`,children:`Knowledge`}),(0,G.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:`Write the durable fact or decision in complete, searchable language.`})]}),(0,G.jsxs)(`span`,{className:`font-mono text-[10px] text-muted-foreground tabular-nums`,children:[n.text.length,` chars`]})]}),(0,G.jsx)(`label`,{htmlFor:`memory-text`,className:`sr-only`,children:`Memory content`}),(0,G.jsx)(`textarea`,{ref:u,id:`memory-text`,value:n.text,onChange:e=>d(`text`,e.target.value),rows:7,required:!0,placeholder:`Example: WebUI state is owned by Zustand stores; server messages update those stores through singleton WebSocket handlers.`,className:`min-h-36 w-full resize-y border border-input bg-background/75 px-3 py-3 text-sm leading-6 text-foreground shadow-inner placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`})]}),(0,G.jsxs)(`section`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`label`,{htmlFor:`memory-kind`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Kind`}),(0,G.jsx)(`select`,{id:`memory-kind`,value:n.kind,onChange:e=>d(`kind`,e.target.value),className:`h-10 w-full border border-input bg-background px-3 text-sm`,children:Ne.map(e=>(0,G.jsx)(`option`,{value:e,children:V[e]},e))})]}),e===`create`?(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`label`,{htmlFor:`memory-scope`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Scope`}),(0,G.jsx)(`select`,{id:`memory-scope`,value:n.scope,onChange:e=>d(`scope`,e.target.value),className:`h-10 w-full border border-input bg-background px-3 text-sm`,children:ke.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))})]}):(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`label`,{htmlFor:`memory-status`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Lifecycle status`}),(0,G.jsx)(`select`,{id:`memory-status`,value:n.status,onChange:e=>d(`status`,e.target.value),className:`h-10 w-full border border-input bg-background px-3 text-sm`,children:Fe.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))})]}),(0,G.jsxs)(`div`,{className:N(`min-w-0`,e===`create`?`sm:col-span-2 lg:col-span-1`:``),children:[(0,G.jsx)(`label`,{htmlFor:`memory-tags`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Tags`}),(0,G.jsx)(F,{id:`memory-tags`,value:n.tags,onChange:e=>d(`tags`,e.target.value),placeholder:`architecture, webui, workflow`,className:`h-10 bg-background`})]})]}),(0,G.jsxs)(`section`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,G.jsx)(L,{id:`memory-importance`,label:`Importance`,value:n.importance,onChange:e=>d(`importance`,e)}),(0,G.jsx)(L,{id:`memory-confidence`,label:`Confidence`,value:n.confidence,onChange:e=>d(`confidence`,e)}),(0,G.jsx)(L,{id:`memory-freshness`,label:`Freshness`,value:n.freshness,onChange:e=>d(`freshness`,e)})]}),(0,G.jsxs)(`section`,{className:`border border-border/75 bg-card/45 p-4`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-xs font-bold uppercase tracking-[0.14em]`,children:`Anchors`}),(0,G.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:`Bind knowledge to files, symbols, packages, tests, Git paths, or commands.`})]}),(0,G.jsxs)(P,{type:`button`,variant:`outline`,size:`sm`,onClick:f,children:[(0,G.jsx)(C,{className:`size-3.5`}),` Add anchor`]})]}),n.anchors.length===0?(0,G.jsxs)(`button`,{type:`button`,onClick:f,className:`mt-4 flex w-full items-center justify-center gap-2 border border-dashed border-border px-4 py-7 text-xs text-muted-foreground transition-colors hover:border-info/50 hover:bg-info/5 hover:text-info`,children:[(0,G.jsx)(ce,{className:`size-4`}),` No anchors yet — add one to improve retrieval precision`]}):(0,G.jsx)(`div`,{className:`mt-4 space-y-2`,children:n.anchors.map((e,t)=>(0,G.jsxs)(`div`,{className:`grid gap-2 border border-border/65 bg-background/40 p-2 sm:grid-cols-[9rem_minmax(0,1fr)_auto]`,children:[(0,G.jsxs)(`label`,{className:`sr-only`,htmlFor:`anchor-type-${t}`,children:[`Anchor `,t+1,` type`]}),(0,G.jsx)(`select`,{id:`anchor-type-${t}`,value:e.type,onChange:e=>{let r=e.target.value,i=r===`command`?{type:r,command:``}:{type:r,path:``},a=n.anchors.map((e,n)=>n===t?i:e);d(`anchors`,a)},className:`h-10 border border-input bg-background px-2 text-xs`,children:Re.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))}),(0,G.jsxs)(`div`,{className:N(`grid min-w-0 gap-2`,e.type===`symbol`&&`sm:grid-cols-[minmax(0,1fr)_11rem]`),children:[(0,G.jsxs)(`label`,{className:`sr-only`,htmlFor:`anchor-value-${t}`,children:[`Anchor `,t+1,` value`]}),(0,G.jsx)(F,{id:`anchor-value-${t}`,value:ze(e),onChange:e=>{let r=n.anchors.map((n,r)=>r===t?I(n,e.target.value):n);d(`anchors`,r)},placeholder:e.type===`command`?`pnpm test --filter webui`:`packages/webui/src/App.tsx`,className:`h-10 min-w-0 bg-background font-mono text-xs`}),e.type===`symbol`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`label`,{className:`sr-only`,htmlFor:`anchor-symbol-${t}`,children:[`Anchor `,t+1,` symbol`]}),(0,G.jsx)(F,{id:`anchor-symbol-${t}`,value:e.symbol??``,onChange:e=>{let r=n.anchors.map((n,r)=>r===t?{...n,symbol:e.target.value}:n);d(`anchors`,r)},placeholder:`Symbol name`,className:`h-10 bg-background font-mono text-xs`})]})]}),(0,G.jsx)(P,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Remove anchor ${t+1}`,onClick:()=>d(`anchors`,n.anchors.filter((e,n)=>n!==t)),children:(0,G.jsx)(i,{className:`size-4 text-destructive`})})]},`${e.type}:${t}`))})]}),(0,G.jsxs)(`section`,{className:`grid gap-3 border border-border/75 bg-card/45 p-4 sm:grid-cols-2`,children:[(0,G.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,G.jsx)(`h3`,{className:`text-xs font-bold uppercase tracking-[0.14em]`,children:`Relationships`}),(0,G.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:`Reference exact memory IDs. Relationships are validated and graph edges are rebuilt by Super Memory.`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{htmlFor:`memory-supersedes`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Supersedes`}),(0,G.jsx)(F,{id:`memory-supersedes`,value:n.supersedes,onChange:e=>d(`supersedes`,e.target.value),placeholder:`mem_id, mem_id`,className:`h-10 bg-background font-mono text-xs`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{htmlFor:`memory-contradicts`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Contradicts`}),(0,G.jsx)(F,{id:`memory-contradicts`,value:n.contradicts,onChange:e=>d(`contradicts`,e.target.value),placeholder:`mem_id, mem_id`,className:`h-10 bg-background font-mono text-xs`})]})]}),(0,G.jsxs)(`section`,{className:`space-y-2`,children:[(0,G.jsx)(`h3`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Audience (Optional)`}),(0,G.jsx)(`p`,{className:`text-[10px] text-muted-foreground/70`,children:`Target this memory to specific agent types. Leave empty for general project memory.`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{htmlFor:`memory-audience-roles`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Roles`}),(0,G.jsx)(F,{id:`memory-audience-roles`,value:n.audienceRoles,onChange:e=>d(`audienceRoles`,e.target.value),placeholder:`reviewer, refactor-planner`,className:`h-9 bg-background font-mono text-xs`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{htmlFor:`memory-audience-task-types`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Task types`}),(0,G.jsx)(F,{id:`memory-audience-task-types`,value:n.audienceTaskTypes,onChange:e=>d(`audienceTaskTypes`,e.target.value),placeholder:`review, refactor, bugfix`,className:`h-9 bg-background font-mono text-xs`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{htmlFor:`memory-audience-modes`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Modes`}),(0,G.jsx)(F,{id:`memory-audience-modes`,value:n.audienceModes,onChange:e=>d(`audienceModes`,e.target.value),placeholder:`teach, code-review`,className:`h-9 bg-background font-mono text-xs`})]})]})]})})]})}function ut({searchQuery:e,statusFilter:t,kindFilter:n,audienceOnly:r,tagFilter:i,hasFilters:o,allTags:s,stats:c,onSearchChange:l,onStatusFilterChange:u,onKindFilterChange:d,onToggleAudienceOnly:f,onTagFilterChange:p,onClearFilters:m}){return(0,G.jsxs)(`div`,{className:`shrink-0 space-y-2 overflow-hidden border-b border-border/70 bg-card/45 p-3`,children:[(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,G.jsx)(le,{className:`pointer-events-none absolute left-3 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,G.jsx)(F,{"aria-label":`Search memories`,value:e,onChange:e=>l(e.target.value),placeholder:`Search content, IDs, tags, anchors…`,className:`h-10 min-w-0 bg-background pl-9 pr-8 text-xs`}),e&&(0,G.jsx)(`button`,{type:`button`,"aria-label":`Clear search`,onClick:()=>l(``),className:`absolute right-2 top-1/2 -translate-y-1/2 p-1 text-muted-foreground hover:text-foreground`,children:(0,G.jsx)(oe,{className:`size-3.5`})})]}),(0,G.jsx)(P,{variant:r?`default`:`ghost`,size:`icon`,onClick:f,"aria-label":`Filter audience-scoped only`,title:`Show only audience-scoped memories`,className:`shrink-0`,children:(0,G.jsx)(k,{className:`size-4`})}),o&&(0,G.jsx)(P,{variant:`ghost`,size:`icon`,onClick:m,"aria-label":`Clear all filters`,title:`Clear all filters`,children:(0,G.jsx)(x,{className:`size-4`})})]}),(0,G.jsxs)(`div`,{className:`grid gap-2`,children:[(0,G.jsx)(`label`,{className:`sr-only`,htmlFor:`memory-status-filter`,children:`Filter by status`}),(0,G.jsxs)(`select`,{id:`memory-status-filter`,value:t,onChange:e=>u(e.target.value),className:`h-9 min-w-0 border border-input bg-background px-2 text-xs`,children:[(0,G.jsx)(`option`,{value:`all`,children:`All statuses`}),Ie.map(e=>(0,G.jsxs)(`option`,{value:e,children:[e,` · `,c?.byStatus[e]??0]},e))]}),(0,G.jsx)(`label`,{className:`sr-only`,htmlFor:`memory-kind-filter`,children:`Filter by kind`}),(0,G.jsxs)(`select`,{id:`memory-kind-filter`,value:n,onChange:e=>d(e.target.value),className:`h-9 min-w-0 border border-input bg-background px-2 text-xs`,children:[(0,G.jsx)(`option`,{value:`all`,children:`All kinds`}),Ne.map(e=>(0,G.jsxs)(`option`,{value:e,children:[V[e],` · `,c?.byKind[e]??0]},e))]})]}),s.length>0&&(0,G.jsxs)(`fieldset`,{className:`min-w-0 border-0 p-0`,children:[(0,G.jsx)(`legend`,{className:`sr-only`,children:`Popular tags`}),(0,G.jsx)(`div`,{className:`no-scrollbar flex gap-1.5 overflow-x-auto pb-0.5`,children:s.slice(0,18).map(([e,t])=>(0,G.jsxs)(`button`,{type:`button`,"aria-pressed":i===e,onClick:()=>p(i===e?null:e),className:N(`flex shrink-0 items-center gap-1 border px-2 py-1 text-[10px] transition-colors`,i===e?`border-info/55 bg-info/10 text-info`:`border-border/70 bg-background/45 text-muted-foreground hover:border-info/35 hover:text-foreground`),children:[(0,G.jsx)(a,{className:`size-2.5`}),` `,e,(0,G.jsx)(`span`,{className:`font-mono opacity-60`,children:t})]},e))})]})]})}function dt(){let e=M(e=>e.traces[0]),t=M(e=>e.contextMemories),n=M(e=>e.clear),r=Object.values(t),a=r.filter(e=>e.state!==`exited`).length,o=r.filter(e=>e.state===`exited`).length,s=e?Object.values(e.rejected).reduce((e,t)=>e+t,0):0;return(0,G.jsx)(`section`,{className:`shrink-0 border-b border-border/70 bg-violet-500/[0.035]`,"aria-label":`Memory Injector summary`,children:(0,G.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-4 text-[10px]`,children:[(0,G.jsx)(f,{className:`size-3.5 text-violet-400`}),(0,G.jsx)(`span`,{className:`font-bold uppercase tracking-wide text-violet-300`,children:`Memory context`}),e?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`span`,{className:`font-mono text-foreground`,children:[e.candidates,` matched`]}),(0,G.jsxs)(`span`,{className:`font-mono text-success`,children:[e.injected.length,` injected`]}),(0,G.jsxs)(`span`,{className:`font-mono text-warning`,children:[s,` filtered`]}),(0,G.jsxs)(`span`,{className:`font-mono text-sky-300`,children:[a,` active`]}),o>0&&(0,G.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[o,` left`]}),(0,G.jsxs)(`span`,{className:`ml-auto text-muted-foreground`,children:[e.trigger,` · ctx `,Math.round(e.contextPressure*100),`% · details in Context`]}),(0,G.jsxs)(P,{type:`button`,variant:`ghost`,size:`sm`,className:`h-6 px-2 text-[10px]`,onClick:n,children:[(0,G.jsx)(i,{className:`size-3`}),` Clear`]})]}):(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`waiting · details in Context`})]})})}var Z=100;function ft({memoryListRef:e,memories:t,filteredMemories:n,selectedId:r,onSelectMemory:i,onOpenCreate:a,onClearFilters:o}){let s=n.length>Z,c=A({count:n.length,getScrollElement:()=>e.current,estimateSize:()=>100,overscan:8,enabled:s});return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-border/60 px-3 py-2 text-[10px] text-muted-foreground`,children:[(0,G.jsxs)(`span`,{children:[n.length,` of `,t.length,` memories`]}),(0,G.jsx)(`span`,{className:`font-mono uppercase`,children:`updated ↓`})]}),(0,G.jsx)(`section`,{ref:e,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,"aria-label":`Memories`,children:n.length===0?(0,G.jsx)(pt,{hasMemories:t.length>0,onOpenCreate:a,onClearFilters:o}):s?(0,G.jsx)(`div`,{style:{height:`${c.getTotalSize()}px`,width:`100%`,position:`relative`},children:c.getVirtualItems().map(e=>{let t=n[e.index];return t?(0,G.jsx)(`div`,{"data-index":e.index,ref:c.measureElement,style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${e.start}px)`},children:(0,G.jsx)(Q,{memory:t,isSelected:r===t.id,onClick:()=>i(t.id)})},t.id):null})}):n.map(e=>(0,G.jsx)(Q,{memory:e,isSelected:r===e.id,onClick:()=>i(e.id)},e.id))})]})}function pt({hasMemories:e,onOpenCreate:t,onClearFilters:n}){return(0,G.jsxs)(`div`,{className:`flex min-h-64 flex-col items-center justify-center px-6 text-center`,children:[(0,G.jsx)(`span`,{className:`flex size-12 items-center justify-center border border-dashed border-border text-muted-foreground`,children:(0,G.jsx)(v,{className:`size-5`})}),(0,G.jsx)(`h2`,{className:`mt-4 text-sm font-bold`,children:e?`No matching memories`:`Build your memory graph`}),(0,G.jsx)(`p`,{className:`mt-1 max-w-xs text-xs leading-5 text-muted-foreground`,children:e?`Change the filters or clear the search query.`:`Capture durable facts, decisions, conventions, and file-bound notes for every agent.`}),(0,G.jsxs)(P,{className:`mt-4`,variant:`outline`,size:`sm`,onClick:e?n:t,children:[e?(0,G.jsx)(x,{className:`size-3.5`}):(0,G.jsx)(C,{className:`size-3.5`}),e?`Clear filters`:`Create first memory`]})]})}function Q({memory:e,isSelected:t,onClick:n}){return(0,G.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,G.jsx)(`span`,{className:`absolute inset-y-0 left-0 w-0.5 bg-info shadow-[0_0_10px_hsl(var(--info)/0.7)]`}),(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:N(`truncate text-[10px] font-bold uppercase tracking-[0.1em]`,R(e.kind)),children:V[e.kind]??e.kind}),(0,G.jsx)(z,{status:e.status}),(0,G.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono text-[9px] text-muted-foreground`,children:[`r`,e.revision]})]}),(0,G.jsx)(`p`,{className:N(`mt-2 line-clamp-2 text-xs leading-5 text-foreground/90`,e.status===`deleted`&&`line-through opacity-60`),children:Me(e.text)}),(0,G.jsxs)(`div`,{className:`mt-2 flex min-w-0 items-center gap-1.5`,children:[(0,G.jsx)(`span`,{className:`border border-border/60 bg-background/50 px-1.5 py-0.5 font-mono text-[9px] uppercase text-muted-foreground`,children:e.scope}),e.audience&&(0,G.jsxs)(`span`,{className:`flex items-center gap-0.5 border border-primary/30 bg-primary/10 px-1.5 py-0.5 font-mono text-[9px] text-primary`,children:[(0,G.jsx)(k,{className:`size-2.5`}),(e.audience.roles??e.audience.taskTypes??e.audience.modes??[]).slice(0,1)[0]??`scoped`]}),e.tags.slice(0,2).map(e=>(0,G.jsxs)(`span`,{className:`max-w-24 truncate border border-border/60 px-1.5 py-0.5 font-mono text-[9px] text-muted-foreground`,children:[`#`,e]},e)),e.tags.length>2&&(0,G.jsxs)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:[`+`,e.tags.length-2]}),(0,G.jsx)(`span`,{className:`ml-auto shrink-0 text-[9px] text-muted-foreground`,children:H(e.updatedAt)}),(0,G.jsx)(m,{className:`size-3 shrink-0 text-muted-foreground transition-transform group-hover:translate-x-0.5 group-hover:text-info`})]})]})}function mt(){let{client:e,listSuperMemoriesPage:n,rememberSuperMemory:r,updateSuperMemory:a,deleteSuperMemory:o,getSuperMemoryGraph:c,recoverSuperMemory:l,resolveMemoryCandidate:u}=ge(),d=ve(e=>e.wsConnected),f=he(e=>e.setCurrentView),p=De(`memory`),[m,g]=(0,W.useState)([]),[_,ee]=(0,W.useState)(null),[v,y]=(0,W.useState)(!0),[b,x]=(0,W.useState)(!1),[S,w]=(0,W.useState)(null),[re,T]=(0,W.useState)(null),[E,D]=(0,W.useState)(null),[O,A]=(0,W.useState)(null),[ae,oe]=(0,W.useState)([]),[se,ce]=(0,W.useState)([]),[le,ue]=(0,W.useState)(null),[fe,pe]=(0,W.useState)(!1),[me,j]=(0,W.useState)(!1),[M,_e]=(0,W.useState)(!1),[F,Te]=(0,W.useState)(je),[Ee,ke]=(0,W.useState)(je),[I,L]=(0,W.useState)(null),[R,Ne]=(0,W.useState)(null),[z,Pe]=(0,W.useState)(``),[Fe,Ie]=(0,W.useState)(`all`),[B,V]=(0,W.useState)(`all`),[Re,ze]=(0,W.useState)(!1),[H,K]=(0,W.useState)(null),[q,Be]=(0,W.useState)(!1),[Ve,He]=(0,W.useState)(null),[Ue,We]=(0,W.useState)(!1),[Ge,Ke]=(0,W.useState)(!1),[qe,Je]=(0,W.useState)({}),[Ye,Ze]=(0,W.useState)(!1),[Qe,$e]=(0,W.useState)(null),[et,tt]=(0,W.useState)(void 0),[nt,rt]=(0,W.useState)(void 0),it=(0,W.useRef)(!1),J=(0,W.useRef)(!0),at=(0,W.useRef)(0),Y=(0,W.useRef)(0),ot=(0,W.useRef)(null),X=(0,W.useRef)(null),ct=(0,W.useMemo)(()=>JSON.stringify(F)!==JSON.stringify(Ee),[Ee,F]),Z=(0,W.useMemo)(()=>m.find(e=>e.id===O)??null,[m,O]),pt=(0,W.useCallback)(t=>{let r=t!==null,i=++at.current;ot.current?.(),w(null),r?Ke(!0):(x(!0),it.current||y(!0));let a=()=>{},o=null,s=!1,c=()=>{s||(s=!0,o!==null&&clearTimeout(o),a(),ot.current===c&&(ot.current=null))};a=e.on(`memory.super.listPage`,e=>{if(i!==at.current||!J.current){c();return}if(c(),e.payload.error)w(e.payload.error);else{let t=e.payload.memories??[];g(e=>r?[...e,...t]:t),He(e.payload.nextCursor??null),We(!!e.payload.nextCursor);let n=e.payload.statusCounts??{};Je(n);let i=Object.values(n).reduce((e,t)=>e+t,0);e.payload.stats?ee(e.payload.stats):ee(e=>({total:i,byStatus:n,byKind:e?.byKind??{},edges:e?.edges??0})),it.current=!0,r||A(e=>e&&t.some(t=>t.id===e)?e:null)}y(!1),x(!1),Ke(!1)}),o=setTimeout(()=>{i!==at.current||!J.current||(c(),w(`The memory store did not respond. Check the WebSocket connection and try again.`),y(!1),x(!1),Ke(!1))},2e4),ot.current=c,n({limit:100,...q?{statuses:[`deleted`]}:{},...t?{cursor:t}:{}},{echoToChat:!1})},[e,n,q]),Q=(0,W.useCallback)(()=>{He(null),We(!1),pt(null)},[pt]),mt=(0,W.useCallback)(()=>{Ge||!Ve||pt(Ve)},[pt,Ge,Ve]);(0,W.useEffect)(()=>(J.current=!0,Q(),()=>{J.current=!1,at.current+=1,Y.current+=1,ot.current?.(),X.current?.()}),[Q]),(0,W.useEffect)(()=>{if(oe([]),ce([]),ue(null),!O){pe(!1);return}let t=O;pe(!0);let n=null,r=e.on(`memory.super.graph`,e=>{e.payload.query===t&&(n!==null&&clearTimeout(n),oe(e.payload.edges??[]),ce(e.payload.memories??[]),ue(e.payload.error??null),pe(!1))});return n=setTimeout(()=>{ue(`Relationship graph did not respond in time.`),pe(!1)},15e3),c(t,{maxDepth:1,limit:120},{echoToChat:!1}),()=>{n!==null&&clearTimeout(n),r()}},[e,c,O]);let gt=(0,W.useRef)(d);(0,W.useEffect)(()=>{d&&!gt.current&&it.current&&Q(),gt.current=d},[Q,d]),(0,W.useEffect)(()=>{if(!E)return;let e=setTimeout(()=>D(null),4e3);return()=>clearTimeout(e)},[E]);let _t=(0,W.useCallback)(()=>!ct||!me&&!M||window.confirm(`Discard the unsaved memory changes?`),[M,ct,me]),vt=(0,W.useCallback)(()=>{if(!_t())return;let e=je();Te(e),ke(e),_e(!0),j(!1),A(null),T(null)},[_t]),yt=(0,W.useCallback)(e=>{_t()&&(A(e),_e(!1),j(!1),T(null))},[_t]),bt=(0,W.useCallback)(()=>{if(!Z||Z.status===`deleted`)return;let e=Ae(Z);Te(e),ke(e),j(!0),_e(!1),T(null)},[Z]),xt=(0,W.useCallback)(()=>{_t()&&(j(!1),_e(!1),T(null))},[_t]),St=(0,W.useCallback)((t,n,r)=>{if(!F.text.trim()){T(`Memory content is required.`);return}let i=++Y.current;X.current?.(),L(r),T(null),D(null);let a=()=>{},o=null,s=!1,c=()=>{s||(s=!0,o!==null&&clearTimeout(o),a(),X.current===c&&(X.current=null))},l=e=>{if(i!==Y.current||!J.current){c();return}if(c(),L(null),e.payload.error||!e.payload.memory){T(e.payload.error??`The server returned no memory record.`);return}let t=e.payload.memory;g(e=>{let n=e.filter(e=>e.id!==t.id);return[t,...n]}),A(t.id),_e(!1),j(!1),D(r===`create`?`Memory captured.`:`Memory updated.`),Q()};a=t===`memory.super.remember`?e.on(`memory.super.remember`,l):e.on(`memory.super.update`,l),o=setTimeout(()=>{i!==Y.current||!J.current||(c(),L(null),T(`${r===`create`?`Create`:`Save`} timed out. Your draft is still here.`))},2e4),X.current=c,n()},[e,F.text,Q]),Ct=(0,W.useCallback)(()=>{St(`memory.super.remember`,()=>r({text:F.text.trim(),kind:F.kind,scope:F.scope,tags:U(F.tags),importance:F.importance,confidence:F.confidence,freshness:F.freshness,anchors:Oe(F.anchors),...U(F.audienceRoles).length||U(F.audienceTaskTypes).length||U(F.audienceModes).length?{audience:{roles:U(F.audienceRoles),taskTypes:U(F.audienceTaskTypes),modes:U(F.audienceModes)}}:{},supersedes:U(F.supersedes),contradicts:U(F.contradicts)},{echoToChat:!1}),`create`)},[F,r,St]),wt=(0,W.useCallback)(()=>{Z&&St(`memory.super.update`,()=>a(Z.id,{text:F.text.trim(),kind:F.kind,status:F.status,tags:U(F.tags),importance:F.importance,confidence:F.confidence,freshness:F.freshness,anchors:Oe(F.anchors),...U(F.audienceRoles).length||U(F.audienceTaskTypes).length||U(F.audienceModes).length?{audience:{roles:U(F.audienceRoles),taskTypes:U(F.audienceTaskTypes),modes:U(F.audienceModes)}}:{},supersedes:U(F.supersedes),contradicts:U(F.contradicts)},{echoToChat:!1}),`update`)},[F,St,Z,a]),Tt=(0,W.useCallback)(()=>{if(!R)return;let t=++Y.current;X.current?.(),L(`delete`),T(null);let n=()=>{},r=null,i=!1,a=()=>{i||(i=!0,r!==null&&clearTimeout(r),n(),X.current===a&&(X.current=null))};n=e.on(`memory.super.delete`,e=>{if(t!==Y.current||!J.current){a();return}if(a(),L(null),!e.payload.success){T(e.payload.message||`Delete failed.`);return}Ne(null),A(null),j(!1),D(`Memory deleted and relationship edges cleaned up.`),Q()}),r=setTimeout(()=>{t!==Y.current||!J.current||(a(),L(null),T(`Delete timed out. The memory may still exist; refresh to confirm.`))},2e4),X.current=a,o(R,`Deleted from the WebUI Memory Manager.`)},[e,o,R,Q]),Et=(0,W.useMemo)(()=>{let e=z.trim().toLowerCase();return m.filter(t=>{if(Fe!==`all`&&t.status!==Fe||B!==`all`&&t.kind!==B||H&&!t.tags.includes(H)||Re&&!t.audience)return!1;if(!e)return!0;let n=t.anchors.map(e=>[e.path,e.symbol,e.command].filter(Boolean).join(` `)).join(` `),r=t.audience?[t.audience.roles?.join(` `)??``,t.audience.taskTypes?.join(` `)??``,t.audience.modes?.join(` `)??``].join(` `):``;return[t.id,t.text,t.summary??``,t.kind,t.scope,t.tags.join(` `),n,r].join(` `).toLowerCase().includes(e)})},[Re,B,m,z,Fe,H]),Dt=(0,W.useMemo)(()=>{let e=new Map;for(let t of m)for(let n of t.tags)e.set(n,(e.get(n)??0)+1);return[...e.entries()].sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0]))},[m]),Ot=(0,W.useMemo)(()=>{if(!Z)return[];let e=[];Z.supersededBy&&e.push({relation:`Superseded by`,id:Z.supersededBy});for(let t of Z.supersedes??[])e.push({relation:`Supersedes`,id:t});for(let t of Z.contradicts??[])e.push({relation:`Contradicts`,id:t});return e},[Z]),kt=(0,W.useCallback)(()=>{Pe(``),Ie(`all`),V(`all`),ze(!1),K(null)},[]),At=!!(z||Fe!==`all`||B!==`all`||H||Re),jt=M||!!Z,$=Ye&&!!Qe;return v&&m.length===0?(0,G.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-background`,"aria-busy":`true`,children:[(0,G.jsxs)(`div`,{className:`border-b border-border/70 bg-card/70 px-5 py-4`,children:[(0,G.jsx)(`div`,{className:`h-3 w-28 animate-pulse bg-muted`}),(0,G.jsx)(`div`,{className:`mt-3 h-7 w-56 animate-pulse bg-muted`})]}),(0,G.jsxs)(`div`,{className:`grid flex-1 gap-px bg-border/60 md:grid-cols-[minmax(300px,0.82fr)_minmax(0,1.35fr)]`,children:[(0,G.jsx)(`div`,{className:`space-y-px bg-background p-4`,children:Array.from({length:7},(e,t)=>(0,G.jsx)(`div`,{className:`h-24 animate-pulse border border-border/60 bg-card/45`},t))}),(0,G.jsx)(`div`,{className:`hidden bg-background p-6 md:block`,children:(0,G.jsx)(`div`,{className:`h-full animate-pulse border border-border/60 bg-card/35`})})]}),(0,G.jsx)(`span`,{className:`sr-only`,role:`status`,children:`Loading Super Memory content`})]}):S&&m.length===0?(0,G.jsx)(`div`,{className:`flex h-full min-h-0 items-center justify-center bg-background p-6`,children:(0,G.jsxs)(`div`,{className:`max-w-md border border-destructive/35 bg-card p-6 shadow-2xl`,children:[(0,G.jsx)(`span`,{className:`flex size-11 items-center justify-center border border-destructive/35 bg-destructive/10 text-destructive`,children:(0,G.jsx)(ne,{className:`size-5`})}),(0,G.jsx)(`h2`,{className:`mt-4 text-lg font-bold`,children:`Memory store unavailable`}),(0,G.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-muted-foreground`,children:S}),(0,G.jsxs)(`div`,{className:`mt-5 flex gap-2`,children:[(0,G.jsxs)(P,{onClick:Q,children:[(0,G.jsx)(de,{className:`size-4`}),` Retry`]}),(0,G.jsxs)(P,{variant:`outline`,onClick:()=>f(`chat`),children:[(0,G.jsx)(s,{className:`size-4`}),` Back to chat`]})]})]})}):(0,G.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-background`,children:[(0,G.jsxs)(`header`,{className:`relative shrink-0 overflow-hidden border-b border-border/70 bg-card/72 px-4 py-3 backdrop-blur-xl sm:px-5`,children:[(0,G.jsx)(`div`,{className:`pointer-events-none absolute inset-y-0 right-0 w-1/2 bg-[radial-gradient(circle_at_right,hsl(var(--info)/0.11),transparent_68%)]`}),(0,G.jsxs)(`div`,{className:`relative flex flex-wrap items-center gap-3`,children:[(0,G.jsx)(P,{variant:`ghost`,size:`icon`,onClick:()=>f(`chat`),"aria-label":`Back to chat`,title:`Back to chat`,children:(0,G.jsx)(s,{className:`size-4`})}),(0,G.jsx)(`span`,{className:`flex size-10 items-center justify-center border border-info/40 bg-info/10 text-info shadow-[0_0_20px_hsl(var(--info)/0.12)]`,children:(0,G.jsx)(k,{className:`size-5`})}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`h1`,{className:`text-base font-bold sm:text-lg`,children:`Super Memory`}),(0,G.jsx)(`span`,{className:`border border-success/35 bg-success/10 px-2 py-0.5 font-mono text-[9px] font-bold uppercase text-success`,children:`project knowledge`})]}),(0,G.jsx)(`p`,{className:`mt-0.5 max-w-2xl text-[10px] text-muted-foreground sm:text-xs`,children:`Inspect, connect, curate, and retire durable context used across agent sessions.`})]}),(0,G.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,G.jsxs)(`span`,{className:N(`hidden items-center gap-1.5 border px-2 py-1 font-mono text-[9px] uppercase sm:flex`,d?`border-success/30 text-success`:`border-warning/30 text-warning`),children:[(0,G.jsx)(`span`,{className:`size-1.5 bg-current`}),` `,d?`live store`:`reconnecting`]}),(0,G.jsxs)(P,{variant:`outline`,size:`sm`,onClick:Q,disabled:b,"aria-label":`Refresh memories`,children:[(0,G.jsx)(de,{className:N(`size-3.5`,b&&`animate-spin`)}),(0,G.jsx)(`span`,{className:`hidden sm:inline`,children:`Refresh`})]}),(0,G.jsxs)(P,{size:`sm`,onClick:vt,children:[(0,G.jsx)(C,{className:`size-3.5`}),` New memory`]})]})]})]}),(0,G.jsxs)(`div`,{className:`grid shrink-0 grid-cols-2 gap-px border-b border-border/70 bg-border/60 sm:grid-cols-4`,children:[(0,G.jsx)(Le,{label:`Memories`,value:_?.total??m.length,hint:`${Et.length} visible`}),(0,G.jsx)(Le,{label:`Active`,value:_?.byStatus.active??m.filter(e=>e.status===`active`).length,hint:`retrievable`,tone:`success`}),(0,G.jsx)(Le,{label:`Needs review`,value:(_?.byStatus.stale??0)+(_?.byStatus.contradicted??0),hint:`stale + conflicts`,tone:`warning`}),(0,G.jsx)(`div`,{className:`hidden sm:block`,children:(0,G.jsx)(Le,{label:`Graph edges`,value:_?.edges??0,hint:`${Dt.length} tags`,tone:`info`})})]}),(0,G.jsx)(dt,{}),(()=>{let e=m.filter(e=>e.audience).length;if(e===0)return null;let t=new Set;for(let e of m)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,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-border/70 bg-primary/5 px-4 py-1.5`,children:[(0,G.jsx)(k,{className:`size-3.5 text-primary`}),(0,G.jsxs)(`span`,{className:`text-[11px] font-medium text-primary`,children:[e,` audience-scoped memory`,e===1?``:`ies`]}),t.size>0&&(0,G.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`(`,[...t].sort().join(`, `),`)`]})]})})(),(E||S||re)&&(0,G.jsxs)(`div`,{className:`shrink-0 border-b border-border/70 px-4 py-2`,"aria-live":`polite`,children:[E&&(0,G.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2 text-xs text-success`,children:[(0,G.jsx)(h,{className:`size-3.5`}),` `,E]}),S&&(0,G.jsxs)(`div`,{role:`alert`,className:`flex items-center gap-2 text-xs text-warning`,children:[(0,G.jsx)(ne,{className:`size-3.5`}),` `,S,` Existing content remains available.`]}),re&&!me&&!M&&(0,G.jsxs)(`div`,{role:`alert`,className:`flex items-center gap-2 text-xs text-destructive`,children:[(0,G.jsx)(ne,{className:`size-3.5`}),` `,re]})]}),(0,G.jsxs)(`div`,{className:`grid min-h-0 flex-1 md:grid-cols-[minmax(320px,0.82fr)_minmax(0,1.35fr)]`,children:[(0,G.jsxs)(`section`,{className:N(`min-h-0 border-r border-border/70 bg-card/25`,jt?`hidden md:flex md:flex-col`:`flex flex-col`),"aria-label":`Memory library`,children:[(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-border/60 px-3 py-1.5`,children:[(0,G.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:`File drawer`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(`select`,{value:Qe??``,onChange:e=>{let t=e.target.value||null;$e(t),t&&Ze(!0)},className:`max-w-[180px] truncate rounded-sm border border-border/60 bg-background px-1.5 py-0.5 text-[10px] font-mono`,"aria-label":`File for memory drawer`,"data-testid":`memory-drawer-file-select`,children:[(0,G.jsx)(`option`,{value:``,children:`— select a file —`}),m.flatMap(e=>e.anchors??[]).filter(e=>e.type===`file`&&e.path).map((e,t)=>(0,G.jsx)(`option`,{value:e.path,children:e.path},`${e.path}-${t}`))]}),(0,G.jsxs)(P,{type:`button`,size:`sm`,variant:$?`default`:`outline`,onClick:()=>{Qe&&Ze(e=>!e)},disabled:!Qe,className:`h-7 gap-1 px-2 text-[11px]`,"aria-pressed":$,title:$?`Hide file memory drawer`:`Show file memory drawer`,children:[$?(0,G.jsx)(ie,{className:`size-3`}):(0,G.jsx)(te,{className:`size-3`}),$?`Hide`:`Show`,` drawer`]})]})]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 border-b border-border/60 px-3 pt-1`,role:`tablist`,"aria-label":`Memory view`,children:[(0,G.jsx)(P,{type:`button`,variant:`ghost`,size:`sm`,role:`tab`,"aria-selected":!q,onClick:()=>{q&&Be(!1)},className:N(`h-7 rounded-b-none border-b-2 px-3 text-[11px]`,q?`border-transparent text-muted-foreground`:`border-primary text-foreground`),children:`Active`}),(0,G.jsxs)(P,{type:`button`,variant:`ghost`,size:`sm`,role:`tab`,"aria-selected":q,onClick:()=>{q||Be(!0)},className:N(`h-7 rounded-b-none border-b-2 px-3 text-[11px]`,q?`border-primary text-foreground`:`border-transparent text-muted-foreground`),children:[`Deleted`,typeof qe.deleted==`number`?` (${qe.deleted})`:``]})]}),(0,G.jsx)(ut,{searchQuery:z,statusFilter:Fe,kindFilter:B,audienceOnly:Re,tagFilter:H,hasFilters:At,allTags:Dt,stats:_,onSearchChange:Pe,onStatusFilterChange:Ie,onKindFilterChange:V,onToggleAudienceOnly:()=>ze(e=>!e),onTagFilterChange:K,onClearFilters:kt}),(0,G.jsx)(ft,{memoryListRef:p,memories:m,filteredMemories:Et,selectedId:O,onSelectMemory:yt,onOpenCreate:vt,onClearFilters:kt}),Ue?(0,G.jsx)(`div`,{className:`shrink-0 border-t border-border/60 p-2`,children:(0,G.jsx)(P,{type:`button`,variant:`outline`,size:`sm`,onClick:mt,disabled:Ge,className:`h-7 w-full text-[11px]`,children:Ge?`Loading…`:`Load more (${m.length} loaded)`})}):null]}),(0,G.jsx)(`section`,{className:N(`min-h-0 bg-background`,jt?`flex flex-col`:`hidden md:flex md:flex-col`),"aria-label":`Memory detail`,children:M?(0,G.jsx)(lt,{mode:`create`,draft:F,busy:I===`create`,error:re,onChange:Te,onCancel:xt,onSubmit:Ct}):Z?me?(0,G.jsx)(lt,{mode:`edit`,draft:F,busy:I===`update`,error:re,onChange:Te,onCancel:xt,onSubmit:wt}):$?(0,G.jsx)(st,{filePath:Qe,lineStart:et,lineEnd:nt,open:$,onClose:()=>Ze(!1),onShowMemory:e=>A(e),onAcceptDeletion:async(e,t)=>{u({candidateId:e,action:`accept`}),D(`Accepted hygiene review for ${t.slice(0,12)}… (candidate ${e.slice(0,12)}…).`),setTimeout(()=>{Q()},500)},onKeep:async(e,t)=>{u({candidateId:e,action:`reject`}),D(`Kept ${t.slice(0,12)}… (candidate ${e.slice(0,12)}… rejected).`)},onUpdate:e=>{A(e),bt()},onMarkPermanent:async e=>{L(`update`);try{await a(e,{persistence:`permanent`}),D(`Memory ${e.slice(0,12)}… promoted to permanent.`),await Q()}catch(e){T(e instanceof Error?e.message:String(e))}finally{L(null)}},onRecover:async e=>{l({id:e,reason:`recovered via file drawer`}),D(`Recovered ${e.slice(0,12)}…`),setTimeout(()=>{Q()},500)}}):(0,G.jsx)(Xe,{memory:Z,allMemories:[...m,...se],relatedMemories:Ot,graphEdges:ae,graphLoading:fe,graphError:le,onClose:()=>A(null),onOpenMemory:yt,onEdit:bt,onDelete:()=>Ne(Z.id),onTagSelect:e=>{K(e),A(null)},onNotice:D}):(0,G.jsx)(ht,{onCapture:vt})})]}),(0,G.jsx)(we,{open:!!R,onOpenChange:e=>{!e&&I!==`delete`&&Ne(null)},children:(0,G.jsxs)(xe,{className:`max-w-md`,children:[(0,G.jsxs)(ye,{children:[(0,G.jsx)(`span`,{className:`mb-2 flex size-10 items-center justify-center border border-destructive/35 bg-destructive/10 text-destructive`,children:(0,G.jsx)(i,{className:`size-4`})}),(0,G.jsx)(Se,{children:`Delete this memory?`}),(0,G.jsx)(Ce,{className:`leading-6`,children:`Super Memory will mark the record deleted, remove graph edges, and clean references from related memories. The record remains in the audit trail but cannot be restored from this page.`})]}),(0,G.jsx)(`div`,{className:`border border-border/70 bg-background/45 p-3 text-xs text-muted-foreground`,children:Me(m.find(e=>e.id===R)?.text??``,180)}),(0,G.jsxs)(be,{children:[(0,G.jsx)(P,{variant:`outline`,onClick:()=>Ne(null),disabled:I===`delete`,children:`Cancel`}),(0,G.jsxs)(P,{variant:`destructive`,onClick:Tt,disabled:I===`delete`,children:[I===`delete`?(0,G.jsx)(t,{className:`size-4 animate-spin`}):(0,G.jsx)(i,{className:`size-4`}),I===`delete`?`Deleting…`:`Delete memory`]})]})]})})]})}function ht({onCapture:e}){return(0,G.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center p-8 text-center`,children:[(0,G.jsxs)(`div`,{className:`relative flex size-20 items-center justify-center border border-info/25 bg-info/5 text-info`,children:[(0,G.jsx)(k,{className:`size-8`}),(0,G.jsx)(`span`,{className:`absolute inset-2 border border-info/10`})]}),(0,G.jsx)(`h2`,{className:`mt-5 text-lg font-bold`,children:`Your project’s long-term context`}),(0,G.jsx)(`p`,{className:`mt-2 max-w-md text-sm leading-6 text-muted-foreground`,children:`Select a memory to inspect its metadata and relationship graph, or capture knowledge that future agents should retrieve automatically.`}),(0,G.jsxs)(`div`,{className:`mt-6 grid w-full max-w-lg gap-2 sm:grid-cols-3`,children:[(0,G.jsxs)(`div`,{className:`border border-border/70 bg-card/45 p-3`,children:[(0,G.jsx)(h,{className:`mx-auto size-4 text-success`}),(0,G.jsx)(`p`,{className:`mt-2 text-[10px] font-bold uppercase`,children:`Verified anchors`})]}),(0,G.jsxs)(`div`,{className:`border border-border/70 bg-card/45 p-3`,children:[(0,G.jsx)(k,{className:`mx-auto size-4 text-info`}),(0,G.jsx)(`p`,{className:`mt-2 text-[10px] font-bold uppercase`,children:`Typed relations`})]}),(0,G.jsxs)(`div`,{className:`border border-border/70 bg-card/45 p-3`,children:[(0,G.jsx)(C,{className:`mx-auto size-4 text-warning`}),(0,G.jsx)(`p`,{className:`mt-2 text-[10px] font-bold uppercase`,children:`Agent recall`})]})]}),(0,G.jsxs)(P,{onClick:e,children:[(0,G.jsx)(C,{className:`size-4`}),` Capture memory`]})]})}export{mt as MemoryManager};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{$t as t,Ci as n,Zr as r,aa as i,ea as a,ot as o,tt as s,wi as c}from"./vendor-Di1mdAi5.js";import"./i18n-DaR2GB_4.js";import{t as l}from"./useWebSocket-CRYUFxmO.js";import{t as u}from"./ws-client-BWO_PH_X.js";import{t as d}from"./utils-C4qVQ63O.js";import{j as f}from"./stores-JSLvWOQY.js";var p=e(i(),1);function m(e){let t=f(e=>e.wsUrl),{listSavedProviders:n,listProviderModels:r}=l(),[i,a]=(0,p.useState)([]),[o,s]=(0,p.useState)({});return(0,p.useEffect)(()=>{let e=u(t),n=e.on(`providers.saved`,e=>{let t=e.payload;a((t.providers??[]).map(e=>e.id))}),r=e.on(`provider.models`,e=>{let t=e.payload;s(e=>({...e,[t.provider]:t.models??[]}))});return()=>{n(),r()}},[t]),(0,p.useEffect)(()=>{e&&n()},[e,n]),(0,p.useEffect)(()=>{if(e)for(let e of i)o[e]||r(e)},[e,i,o,r]),(0,p.useMemo)(()=>{let e=[];for(let t of i)for(let n of o[t]??[])e.push({provider:t,model:n.id,label:n.name??n.id,description:n.description,contextWindow:n.contextWindow});return e},[i,o])}var h=s();function g({value:e,provider:i,candidates:s,placeholder:l,resetLabel:u,onPick:f,onReset:m,className:g}){let{t:_}=a(),[v,y]=(0,p.useState)(!1),[b,x]=(0,p.useState)(``),S=(0,p.useRef)(null);(0,p.useEffect)(()=>{if(!v)return;let e=e=>{S.current&&!S.current.contains(e.target)&&y(!1)};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[v]);let C=(0,p.useMemo)(()=>{let e=b.trim().toLowerCase();return(e?s.filter(t=>`${t.provider}/${t.model} ${t.label}`.toLowerCase().includes(e)):s).slice(0,60)},[s,b]);return(0,h.jsxs)(`div`,{ref:S,className:d(`relative`,g),children:[(0,h.jsxs)(`button`,{type:`button`,onClick:()=>y(e=>!e),className:`flex w-full items-center gap-1.5 rounded-md border border-border bg-muted px-2 py-1.5 text-left text-xs transition-colors hover:border-primary/45 hover:bg-muted/80`,children:[(0,h.jsx)(r,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,h.jsx)(`span`,{className:d(`min-w-0 flex-1 truncate`,e?`text-foreground`:`text-muted-foreground`),children:e?i?`${i}/${e}`:e:l??_(`activity:model.runDefault`)}),(0,h.jsx)(n,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`})]}),v&&(0,h.jsxs)(`div`,{className:`sdd-rise absolute z-50 mt-1 max-h-72 w-full min-w-[240px] overflow-hidden rounded-md border border-border/80 bg-popover shadow-xl`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-border/70 bg-muted/20 px-2 py-1.5`,children:[(0,h.jsx)(`input`,{value:b,onChange:e=>x(e.target.value),placeholder:_(`activity:model.filterPlaceholder`),className:`min-w-0 flex-1 bg-transparent text-xs outline-none placeholder:text-muted-foreground`}),b&&(0,h.jsx)(`button`,{type:`button`,onClick:()=>x(``),className:`text-muted-foreground hover:text-foreground`,children:(0,h.jsx)(o,{className:`h-3 w-3`})})]}),(0,h.jsxs)(`div`,{className:`max-h-60 overflow-y-auto py-1`,children:[m&&(0,h.jsxs)(`button`,{type:`button`,onClick:()=>{m(),y(!1)},className:`flex w-full items-center gap-1.5 px-2 py-1.5 text-left text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:[(0,h.jsx)(t,{className:`h-3 w-3`}),` `,u??_(`activity:model.useRunDefault`)]}),C.map(t=>{let n=t.model===e&&(!i||t.provider===i);return(0,h.jsxs)(`button`,{type:`button`,onClick:()=>{f(t.model,t.provider),y(!1)},className:d(`flex w-full items-start gap-1.5 px-2 py-1.5 text-left text-xs transition-colors hover:bg-muted`,n?`bg-primary/8 text-primary`:`text-foreground`),children:[n?(0,h.jsx)(c,{className:`mt-0.5 h-3 w-3 shrink-0 text-primary`}):(0,h.jsx)(`span`,{className:`w-3 shrink-0`}),(0,h.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,h.jsx)(`span`,{className:`block truncate`,children:t.label}),t.description&&(0,h.jsx)(`span`,{className:`mt-0.5 block truncate text-[10px] text-muted-foreground`,children:t.description})]}),(0,h.jsx)(`span`,{className:`mt-0.5 shrink-0 font-mono text-[9px] text-muted-foreground`,children:t.provider})]},`${t.provider}/${t.model}`)}),C.length===0&&(0,h.jsx)(`div`,{className:`px-2 py-3 text-center text-[11px] text-muted-foreground`,children:s.length===0?_(`activity:model.loading`):_(`activity:model.noMatch`)})]})]})]})}export{m as n,g as t};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{$t as t,Qr as n,Ti as r,oa as i,ot as a,ta as o,tt as s,wi as c}from"./vendor-DffL_bim.js";import"./i18n-Dk35g-uV.js";import{t as l}from"./useWebSocket-BJorYmOi.js";import{t as u}from"./ws-client-Fnmzo7vN.js";import{t as d}from"./utils-DEzFewqr.js";import{j as f}from"./stores-CUp_ut8r.js";var p=e(i(),1);function m(e){let t=f(e=>e.wsUrl),{listSavedProviders:n,listProviderModels:r}=l(),[i,a]=(0,p.useState)([]),[o,s]=(0,p.useState)({});return(0,p.useEffect)(()=>{let e=u(t),n=e.on(`providers.saved`,e=>{let t=e.payload;a((t.providers??[]).map(e=>e.id))}),r=e.on(`provider.models`,e=>{let t=e.payload;s(e=>({...e,[t.provider]:t.models??[]}))});return()=>{n(),r()}},[t]),(0,p.useEffect)(()=>{e&&n()},[e,n]),(0,p.useEffect)(()=>{if(e)for(let e of i)o[e]||r(e)},[e,i,o,r]),(0,p.useMemo)(()=>{let e=[];for(let t of i)for(let n of o[t]??[])e.push({provider:t,model:n.id,label:n.name??n.id,description:n.description,contextWindow:n.contextWindow});return e},[i,o])}var h=s();function g({value:e,provider:i,candidates:s,placeholder:l,resetLabel:u,onPick:f,onReset:m,className:g}){let{t:_}=o(),[v,y]=(0,p.useState)(!1),[b,x]=(0,p.useState)(``),S=(0,p.useRef)(null);(0,p.useEffect)(()=>{if(!v)return;let e=e=>{S.current&&!S.current.contains(e.target)&&y(!1)};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[v]);let C=(0,p.useMemo)(()=>{let e=b.trim().toLowerCase();return(e?s.filter(t=>`${t.provider}/${t.model} ${t.label}`.toLowerCase().includes(e)):s).slice(0,60)},[s,b]);return(0,h.jsxs)(`div`,{ref:S,className:d(`relative`,g),children:[(0,h.jsxs)(`button`,{type:`button`,onClick:()=>y(e=>!e),className:`flex w-full items-center gap-1.5 rounded-md border border-border bg-muted px-2 py-1.5 text-left text-xs transition-colors hover:border-primary/45 hover:bg-muted/80`,children:[(0,h.jsx)(n,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,h.jsx)(`span`,{className:d(`min-w-0 flex-1 truncate`,e?`text-foreground`:`text-muted-foreground`),children:e?i?`${i}/${e}`:e:l??_(`activity:model.runDefault`)}),(0,h.jsx)(c,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`})]}),v&&(0,h.jsxs)(`div`,{className:`sdd-rise absolute z-50 mt-1 max-h-72 w-full min-w-[240px] overflow-hidden rounded-md border border-border/80 bg-popover shadow-xl`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-border/70 bg-muted/20 px-2 py-1.5`,children:[(0,h.jsx)(`input`,{value:b,onChange:e=>x(e.target.value),placeholder:_(`activity:model.filterPlaceholder`),className:`min-w-0 flex-1 bg-transparent text-xs outline-none placeholder:text-muted-foreground`}),b&&(0,h.jsx)(`button`,{type:`button`,onClick:()=>x(``),className:`text-muted-foreground hover:text-foreground`,children:(0,h.jsx)(a,{className:`h-3 w-3`})})]}),(0,h.jsxs)(`div`,{className:`max-h-60 overflow-y-auto py-1`,children:[m&&(0,h.jsxs)(`button`,{type:`button`,onClick:()=>{m(),y(!1)},className:`flex w-full items-center gap-1.5 px-2 py-1.5 text-left text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:[(0,h.jsx)(t,{className:`h-3 w-3`}),` `,u??_(`activity:model.useRunDefault`)]}),C.map(t=>{let n=t.model===e&&(!i||t.provider===i);return(0,h.jsxs)(`button`,{type:`button`,onClick:()=>{f(t.model,t.provider),y(!1)},className:d(`flex w-full items-start gap-1.5 px-2 py-1.5 text-left text-xs transition-colors hover:bg-muted`,n?`bg-primary/8 text-primary`:`text-foreground`),children:[n?(0,h.jsx)(r,{className:`mt-0.5 h-3 w-3 shrink-0 text-primary`}):(0,h.jsx)(`span`,{className:`w-3 shrink-0`}),(0,h.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,h.jsx)(`span`,{className:`block truncate`,children:t.label}),t.description&&(0,h.jsx)(`span`,{className:`mt-0.5 block truncate text-[10px] text-muted-foreground`,children:t.description})]}),(0,h.jsx)(`span`,{className:`mt-0.5 shrink-0 font-mono text-[9px] text-muted-foreground`,children:t.provider})]},`${t.provider}/${t.model}`)}),C.length===0&&(0,h.jsx)(`div`,{className:`px-2 py-3 text-center text-[11px] text-muted-foreground`,children:s.length===0?_(`activity:model.loading`):_(`activity:model.noMatch`)})]})]})]})}export{m as n,g as t};
@@ -0,0 +1,4 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Cn as t,Dn as n,Er as r,Fn as i,Hn as a,Jt as o,Kt as s,Mn as c,Nn as l,Nt as u,Oi as d,Pi as f,Pn as p,Qi as m,Qr as h,Sr as g,Ti as _,Tt as v,Xn as ee,Yi as y,Yr as b,_ as x,_i as S,a as C,ai as w,at as T,c as te,cr as ne,ct as E,d as re,f as ie,h as D,hn as ae,i as oe,ia as O,ii as k,it as se,jr as A,l as ce,lt as le,m as ue,mt as de,nr as j,o as fe,oa as M,oi as pe,ot as N,p as me,pt as he,qr as ge,qt as _e,r as ve,s as P,sr as ye,ta as F,tt as be,u as xe,v as Se,vi as Ce,xr as we}from"./vendor-DffL_bim.js";import"./i18n-Dk35g-uV.js";import{s as Te}from"./ws-client-Fnmzo7vN.js";import{t as I}from"./utils-DEzFewqr.js";import{t as Ee}from"./session-store-Coiik-Ib.js";import{b as De,c as L,g as Oe,l as ke}from"./stores-CUp_ut8r.js";import{r as Ae}from"./mailbox-store-BY2SVw-s.js";import{f as je}from"./markdown-L6DLSM7f.js";import{c as R,s as z,t as B}from"./LazyMarkdown-BHoUIDge.js";import{C as V,S as Me,f as Ne,y as Pe}from"./index-OmSX-BAb.js";var H=e(M(),1);function Fe(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function U(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=U(e[n]);if(t!==void 0)return t}}function q(e){return e.split(/[\\/]/).filter(Boolean).pop()??e}function Ie(e){return e?e.split(/\r?\n/).length:0}function Le(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 Re(e){let t=e.split(/\r?\n/,1)[0]?.trim()??e;return t.length>72?`${t.slice(0,69)}…`:t}function ze(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 Be(e,t){let n=(Array.isArray(e.fileTargets)?e.fileTargets:[]).flatMap(e=>{let t=Fe(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 Ve(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 He(e,t,n,r,i,a){let o=Ve(a,n),s=a?.filePath??G(n,[`file_path`,`filePath`,`path`,`filename`]),c=s?q(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?Ie(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?Le(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?Ie(i):u??0} → ${a?Ie(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:Re(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 Ue(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 We(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 Ge(e){return W(e.parentSessionId)??W(e.sessionId)}function Ke(e,t){return e.kind===`tool:started`||e.kind===`tool:progress`?`running`:t.ok===!1?`failed`:`succeeded`}function qe(e){if(![`tool:started`,`tool:progress`,`tool:executed`,`agent:tool`].includes(e.kind))return null;let t=Fe(e.data),n=Ue(e,t);if(!n)return null;let r=We(e,t,n),i=t.input,a=Fe(i),o=Be(t,a),s=U(t.outputLines),c=ze(n),l=He(c,n,a,t,s,o[0]),u=W(t.id),d=Math.floor(e.timestamp/2e3),f=Ke(e,t),p=U(t.durationMs);return{id:u?`${r}:${u}`:`${r}:${n}:${d}`,agentId:r,agentName:W(t.agentName),sessionId:Ge(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:U(t.outputBytes),outputTokens:U(t.outputTokens),input:i,output:W(t.output),fileTargets:o,raw:e.raw??t}}function Je(e,t,n){return e?.length?Qe(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 Ye(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 Xe(e,t){return e.toLowerCase()===t.toLowerCase()}function J(e){return e?.trim().toLowerCase()??``}function Ze(e,t,n){let r=new Set([t.serverId,t.mailboxId,t.name].map(J).filter(e=>e.length>0)),i=n?`@session:${J(n)}`:``,a=J(t.role),o=J(t.serverId)===`leader`||J(t.serverId).startsWith(`leader@`)||a===`lead`||a===`leader`;return e.flatMap(e=>{let t=J(e.from),n=J(e.to),a=r.has(t),s=n===`*`||n===`all`||i.length>0&&n===i,c=r.has(n)||o&&s;if(!c&&!a)return[];let l=Date.parse(e.timestamp);return[{...e,direction:c?`incoming`:`outgoing`,timestampMs:Number.isFinite(l)?l:0,unread:c&&!Object.keys(e.readBy??{}).some(e=>r.has(J(e)))}]}).sort((e,t)=>t.timestampMs-e.timestampMs).slice(0,8)}function Qe(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=qe(a);if(!o||!Xe(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 $e(e,t,n){let r=ze(t),i={read:`Reading a file`,write:`Writing a file`,edit:`Updating code`,terminal:`Running a command`,web:`Working online`,search:`Searching project`,memory:`Checking memory`,other:t};return{id:`${e}:live:${t}`,agentId:e,sessionId:n,toolName:t,kind:r,status:`running`,startedAt:Date.now(),summary:i[r],fileTargets:[]}}function et(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 tt(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 nt(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 rt(e){if(!e)return;let t=e.split(`/`);return t[t.length-1]?.slice(0,18)}function it(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 at(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 ot(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 st(e){return e===`tui`?`tui`:e===`repl`||e===`cli`?`repl`:`webui`}function ct(e){return e===`tui`?`TUI`:e===`repl`?`REPL`:`WebUI`}function lt(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 ut(e){let t=e.split(`/`).filter(Boolean).pop()??e;return t.length>10?`…${t.slice(-8)}`:t}function dt(e,t){return e===`cli`?`CLI`:e===`repl`?`REPL`:ct(t)}function ft(e,t,n=[]){let r=new Set,i=[];for(let n of e){let e=st(n.clientType),a=dt(n.clientType,e),o=`client-${n.pid??n.sessionId}`,s=[],c=!1;for(let e of n.agents){r.add(e.id);let n=t.get(e.id),i=lt(n?.status??e.status);(i===`active`||i===`streaming`)&&(c=!0),s.push({officeId:`${o}__agent-${e.id}`,serverId:e.id,name:n?.name??e.name??e.id,status:i,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`);i.push({id:o,type:e,label:`${a} · ${n.pid?`PID ${n.pid}`:ut(n.sessionId)}`,sublabel:[`session ${ut(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=i.find(t=>t.sessionId===e.sessionId);if(!t)continue;let n=e.name.trim().toLowerCase(),a=t.agents.find(t=>t.serverId===e.agentId||t.name.trim().toLowerCase()===n);a&&(r.add(e.agentId),a.mailboxId=e.agentId,a.role=e.role,a.currentTask=a.currentTask??e.currentTask,a.currentTool=a.currentTool??e.currentTool)}let a=[...t.values()].filter(e=>!r.has(e.id));if(a.length>0){let e=i.find(e=>e.type===`webui`);e||(e={id:`client-self`,type:`webui`,label:`This WebUI`,sublabel:`Web UI`,status:`idle`,agents:[]},i.push(e));for(let t of a){let n=lt(t.status);(n===`active`||n===`streaming`)&&(e.status=`active`),e.agents.push({officeId:`${e.id}__agent-${t.id}`,serverId:t.id,name:t.name,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`})}}return i.length===0&&i.push({id:`client-self`,type:`webui`,label:`This WebUI`,sublabel:`Web UI · connecting…`,status:`idle`,agents:[]}),i}function pt(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 Y=be(),mt=[`amber`,`mint`,`ocean`,`plum`,`rose`,`graphite`],ht=[`bot`,`cactus`,`duck`,`radio`],gt={read:_e,write:A,edit:A,terminal:u,web:ge,search:we,memory:l,other:k},_t={leader:d,builder:k,researcher:_e,reviewer:_,planner:a,operator:u};function vt(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 yt(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);let n=t>>>0;return{palette:mt[n%mt.length]??`amber`,layout:Math.floor(n/mt.length)%4,clutter:Math.floor(n/(mt.length*4))%3,avatar:Math.floor(n/17)%5,motion:Math.floor(n/31)%4,charm:ht[Math.floor(n/47)%ht.length]??`bot`}}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 xt(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 St(e){return e===void 0?`—`:e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(+(e<1e4))} s`}function Ct(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 wt(e){if(e===void 0)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Tt(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 Et(e,t,n){return n.map((n,r)=>({...$e(e.serverId,n.name,t.sessionId),id:`${e.serverId}:log:${n.at}:${r}`,kind:ze(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 Dt(...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 Ot(...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 kt({kind:e,active:t}){let n=gt[e];return(0,Y.jsxs)(`span`,{className:I(`agent-office__tool-glyph`,`is-${e}`,t&&`is-active`),children:[e===`read`&&(0,Y.jsx)(r,{className:`agent-office__file-underlay`,"aria-hidden":`true`}),(0,Y.jsx)(n,{"aria-hidden":`true`})]})}function At({active:e,failed:t,role:n,variant:r,motion:i}){let a=_t[n];return(0,Y.jsxs)(`div`,{className:I(`agent-office__avatar`,`is-${n}`,`is-avatar-${r}`,`is-motion-${i}`,e&&`is-active`,!e&&!t&&`is-idle`,t&&`is-failed`),"aria-hidden":`true`,children:[(0,Y.jsx)(`span`,{className:`agent-office__avatar-chair`}),(0,Y.jsx)(`span`,{className:`agent-office__avatar-body`}),(0,Y.jsxs)(`span`,{className:`agent-office__avatar-head`,children:[(0,Y.jsx)(`span`,{className:`agent-office__avatar-hair`}),(0,Y.jsx)(`span`,{className:`agent-office__avatar-face`}),(0,Y.jsx)(`span`,{className:`agent-office__avatar-mouth`}),(0,Y.jsx)(`span`,{className:`agent-office__avatar-headset`})]}),(0,Y.jsx)(`span`,{className:`agent-office__avatar-arm`}),(0,Y.jsx)(`span`,{className:`agent-office__avatar-prop`}),(0,Y.jsx)(`span`,{className:`agent-office__avatar-role-badge`,children:(0,Y.jsx)(a,{})})]})}function jt({call:e,compact:t=!1,onSelect:n}){let r=e.status===`running`;return(0,Y.jsxs)(`button`,{type:`button`,className:I(`agent-office__parcel`,`is-${e.kind}`,t&&`is-compact`,r&&`is-running`,e.status===`failed`&&`is-failed`),onClick:n,"aria-label":`${e.toolName}: ${e.summary}`,children:[(0,Y.jsx)(kt,{kind:e.kind,active:r}),(0,Y.jsxs)(`span`,{className:`agent-office__parcel-copy`,children:[(0,Y.jsxs)(`span`,{className:`agent-office__parcel-topline`,children:[(0,Y.jsx)(`strong`,{children:e.toolName}),e.lineLabel&&(0,Y.jsx)(`span`,{className:`agent-office__line-chip`,children:e.lineLabel})]}),!t&&e.target&&(0,Y.jsx)(`span`,{className:`agent-office__parcel-target`,children:bt(e.target)}),(0,Y.jsx)(`span`,{className:`agent-office__parcel-summary`,children:e.summary})]}),(0,Y.jsx)(`span`,{className:`agent-office__parcel-state`,"aria-hidden":`true`,children:r?(0,Y.jsx)(`span`,{className:`agent-office__pulse-dot`}):e.status===`failed`?(0,Y.jsx)(N,{}):(0,Y.jsx)(_,{})})]})}function Mt({mail:e,compact:t=!1,onSelect:n}){let r=e.direction===`incoming`;return(0,Y.jsxs)(`button`,{type:`button`,className:I(`agent-office__mail-parcel`,t&&`is-compact`,r?`is-incoming`:`is-outgoing`,e.unread&&`is-unread`),onClick:n,"aria-label":`${r?`Incoming`:`Outgoing`} mail: ${e.subject}`,children:[(0,Y.jsx)(`span`,{className:`agent-office__mail-icon`,children:r?(0,Y.jsx)(j,{"aria-hidden":`true`}):(0,Y.jsx)(s,{"aria-hidden":`true`})}),(0,Y.jsxs)(`span`,{className:`agent-office__parcel-copy`,children:[(0,Y.jsx)(`strong`,{children:r?`${e.from} →`:`→ ${e.to}`}),(0,Y.jsx)(`span`,{className:`agent-office__parcel-summary`,children:e.subject})]}),(0,Y.jsx)(i,{"aria-hidden":`true`})]})}function Nt({office:e,now:t}){let{t:n}=F(),{client:r,agents:a,stats:o}=e,s=r.lastHeartbeatAt?Date.parse(r.lastHeartbeatAt):NaN,c=Number.isFinite(s)&&t-s<2e4,l=Number.isFinite(s)&&!c,f=a.some(({agent:e})=>e.presenceSource===`registry`),p=c?`VERIFIED`:l?`DELAYED`:f?`REGISTRY`:`LOCAL`,h=a.some(({agent:e})=>e.recentTools!==void 0||e.activity!==void 0),_=a.some(({agent:e})=>e.toolCalls>0&&e.recentTools===void 0&&e.activity===void 0);return(0,Y.jsxs)(`header`,{className:`agent-office__client-header`,children:[(0,Y.jsxs)(`div`,{className:`agent-office__client-title`,children:[(0,Y.jsx)(`span`,{className:`agent-office__client-icon`,children:(0,Y.jsx)(d,{"aria-hidden":`true`})}),(0,Y.jsxs)(`div`,{className:`agent-office__client-copy`,children:[(0,Y.jsx)(`strong`,{children:r.label}),(0,Y.jsx)(`span`,{children:r.sublabel||r.sessionId})]}),(0,Y.jsxs)(`div`,{className:`agent-office__client-presence`,children:[(0,Y.jsxs)(`span`,{className:`agent-office__client-agent-count`,children:[a.length,` `,n(`activity:agentOffice.agents`)]}),(0,Y.jsxs)(`span`,{className:I(`agent-office__presence-chip`,!l&&`is-live`,l&&`is-legacy`),children:[(0,Y.jsx)(E,{"aria-hidden":`true`}),` `,p]}),(0,Y.jsxs)(`span`,{className:`agent-office__presence-chip`,children:[(0,Y.jsx)(pe,{"aria-hidden":`true`}),` `,Ct(r.startedAt,t),` UP`]}),(0,Y.jsxs)(`span`,{className:I(`agent-office__presence-chip`,_?`is-legacy`:h&&`is-telemetry`),children:[(0,Y.jsx)(m,{"aria-hidden":`true`}),_?`RECONNECT`:h?`TOOLS LIVE`:`READY`]})]})]}),(0,Y.jsxs)(`fieldset`,{className:`agent-office__client-stats`,"aria-label":`Session activity totals`,children:[(0,Y.jsxs)(`span`,{title:`Unique files touched`,children:[(0,Y.jsx)(g,{}),` `,(0,Y.jsx)(`strong`,{children:o.files}),` FILES`]}),(0,Y.jsxs)(`span`,{title:`File reads`,children:[(0,Y.jsx)(_e,{}),` `,(0,Y.jsx)(`strong`,{children:o.reads}),` READ`]}),(0,Y.jsxs)(`span`,{title:`Files written`,children:[(0,Y.jsx)(A,{}),` `,(0,Y.jsx)(`strong`,{children:o.writes}),` WRITE`]}),(0,Y.jsxs)(`span`,{title:`Files edited`,children:[(0,Y.jsx)(A,{}),` `,(0,Y.jsx)(`strong`,{children:o.edits}),` EDIT`]}),(0,Y.jsxs)(`span`,{className:`agent-office__client-delta`,title:`Lines added and removed`,children:[(0,Y.jsxs)(`strong`,{children:[`+`,o.linesAdded]}),` / `,(0,Y.jsxs)(`b`,{children:[`−`,o.linesRemoved]})]}),(0,Y.jsxs)(`span`,{title:`Terminal commands`,children:[(0,Y.jsx)(u,{}),` `,(0,Y.jsx)(`strong`,{children:o.terminalCalls}),` TERM`]}),(0,Y.jsxs)(`span`,{title:`Incoming and outgoing mail`,children:[(0,Y.jsx)(i,{}),` `,(0,Y.jsx)(`strong`,{children:o.incomingMail}),`↓ `,(0,Y.jsx)(`strong`,{children:o.outgoingMail}),`↑`]})]})]})}function Pt({office:e,now:t,onSelect:n}){let{t:r}=F(),{client:i}=e,o=i.todos!==void 0,s=i.todos??[],l=s.filter(e=>e.status!==`completed`),u=s.length-l.length,d=!!i.activeInstruction,f=i.activeInstruction??i.latestPrompt,p=i.latestPromptAt!==void 0&&t-i.latestPromptAt<3e4,h=()=>n({kind:`briefing`,officeLabel:i.label,prompt:f,promptAt:i.latestPromptAt,instructionActive:d,telemetryConnected:o,todos:s});return(0,Y.jsxs)(`section`,{className:`agent-office__briefing`,"aria-label":r(`activity:agentOffice.officeBriefing`),children:[(0,Y.jsxs)(`button`,{type:`button`,className:I(`agent-office__prompt-card`,d&&`is-active`,p&&`is-fresh`,!o&&`is-waiting`),onClick:h,children:[(0,Y.jsx)(`span`,{className:`agent-office__briefing-icon is-prompt`,children:(0,Y.jsx)(c,{"aria-hidden":`true`})}),(0,Y.jsxs)(`span`,{className:`agent-office__briefing-copy`,children:[(0,Y.jsx)(`span`,{children:r(d?`activity:agentOffice.activeInstruction`:`activity:agentOffice.leaderPrompt`)}),(0,Y.jsx)(`strong`,{children:f??r(o?`activity:agentOffice.noPrompt`:`activity:agentOffice.telemetryWaiting`)})]}),d&&(0,Y.jsxs)(`span`,{className:`agent-office__instruction-live`,children:[(0,Y.jsx)(`i`,{"aria-hidden":`true`}),` LIVE`]}),i.latestPromptAt!==void 0&&(0,Y.jsx)(`time`,{dateTime:new Date(i.latestPromptAt).toISOString(),children:xt(i.latestPromptAt,t)})]}),(0,Y.jsxs)(`button`,{type:`button`,className:I(`agent-office__todo-board`,l.length>0&&`has-active`,!o&&`is-waiting`),onClick:h,children:[(0,Y.jsxs)(`span`,{className:`agent-office__todo-heading`,children:[(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(a,{"aria-hidden":`true`}),` `,r(`activity:agentOffice.activeTodos`)]}),(0,Y.jsx)(`strong`,{children:o?r(`activity:agentOffice.todoProgress`,{done:u,total:s.length}):r(`activity:agentOffice.syncWaiting`)})]}),(0,Y.jsxs)(`span`,{className:`agent-office__todo-preview`,children:[o?l.length>0?l.slice(0,3).map(e=>(0,Y.jsxs)(`span`,{className:I(`agent-office__todo-line`,`is-${e.status}`),children:[(0,Y.jsx)(`i`,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{children:e.activeForm||e.content})]},e.id)):(0,Y.jsxs)(`span`,{className:`agent-office__todo-empty`,children:[(0,Y.jsx)(S,{"aria-hidden":`true`}),s.length>0?r(`activity:agentOffice.allTodosDone`):r(`activity:agentOffice.noActiveTodos`)]}):(0,Y.jsxs)(`span`,{className:`agent-office__todo-empty is-waiting`,children:[(0,Y.jsx)(m,{"aria-hidden":`true`}),r(`activity:agentOffice.todoTelemetryWaiting`)]}),l.length>3&&(0,Y.jsx)(`span`,{className:`agent-office__todo-more`,children:r(`activity:agentOffice.moreTodos`,{count:l.length-3})})]})]})]})}function Ft({active:e}){let{t}=F();return(0,Y.jsxs)(`div`,{className:`agent-office__parcel agent-office__parcel--empty`,children:[(0,Y.jsx)(`span`,{className:`agent-office__tool-glyph`,children:(0,Y.jsx)(f,{"aria-hidden":`true`})}),(0,Y.jsxs)(`span`,{className:`agent-office__parcel-copy`,children:[(0,Y.jsx)(`strong`,{children:t(e?`activity:agentOffice.thinking`:`activity:agentOffice.waiting`)}),(0,Y.jsx)(`span`,{children:t(e?`activity:agentOffice.preparing`:`activity:agentOffice.deskReady`)})]})]})}function It({model:e,now:t,onSelect:n}){let{t:r}=F(),{agent:o,client:s,current:c,display:l,history:u,mail:d}=e,f=o.status===`active`||o.status===`streaming`,p=o.status===`error`,h=d[0],g=vt(o),v=yt(`${s.sessionId}:${o.serverId}:${o.name}`),ee=h&&t-h.timestampMs<3e4,y=u.slice(0,6),b=y[0]?.completedAt??y[0]?.startedAt??l?.completedAt??l?.startedAt,x=c?`is-tool-${c.kind}`:void 0;return(0,Y.jsxs)(`article`,{className:I(`agent-office__lane`,`is-desk-${v.palette}`,`is-layout-${v.layout}`,`is-clutter-${v.clutter}`,f&&`is-active`,p&&`is-failed`),children:[(0,Y.jsxs)(`div`,{className:`agent-office__identity`,children:[(0,Y.jsxs)(`div`,{className:`agent-office__identity-line`,children:[(0,Y.jsx)(`span`,{className:I(`agent-office__status-dot`,f&&`is-active`,p&&`is-failed`)}),(0,Y.jsx)(`strong`,{title:o.name,children:o.name}),(0,Y.jsxs)(`span`,{className:`agent-office__agent-verified`,title:o.presenceSource===`registry`?`Verified by live session registry`:`Verified by local fleet state`,children:[(0,Y.jsx)(_,{"aria-hidden":`true`}),o.presenceSource===`registry`?`LIVE`:`LOCAL`]})]}),(0,Y.jsx)(`span`,{className:`agent-office__role`,children:o.role??(o.serverId===`leader`||o.serverId.startsWith(`leader@`)?r(`activity:agentOffice.leadAgent`):r(`activity:agentOffice.agent`))}),(0,Y.jsxs)(`div`,{className:`agent-office__agent-meta`,children:[(0,Y.jsx)(`span`,{children:s.branch?`⎇ ${s.branch}`:s.type.toUpperCase()}),(0,Y.jsx)(`span`,{children:r(`activity:agentOffice.callsCount`,{count:o.toolCalls})})]}),o.currentTask&&(0,Y.jsxs)(`button`,{type:`button`,className:`agent-office__agent-task`,onClick:()=>n({kind:`task`,task:o.currentTask??``,taskId:o.taskId,agentName:o.name}),children:[(0,Y.jsx)(a,{"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`strong`,{children:r(`activity:agentOffice.currentTask`)}),(0,Y.jsx)(`small`,{children:o.currentTask})]})]}),!o.currentTask&&f&&(0,Y.jsxs)(`div`,{className:`agent-office__agent-task is-missing`,children:[(0,Y.jsx)(m,{"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`strong`,{children:r(`activity:agentOffice.currentTask`)}),(0,Y.jsx)(`small`,{children:s.todos===void 0?r(`activity:agentOffice.telemetryWaiting`):r(`activity:agentOffice.taskNotReported`)})]})]}),h&&(0,Y.jsxs)(`button`,{type:`button`,className:I(`agent-office__identity-mail`,h.unread&&`is-unread`),onClick:()=>n({kind:`mail`,mail:h,agentName:o.name}),"aria-label":`${d.length} mail messages. Latest: ${h.subject}`,children:[(0,Y.jsx)(i,{"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsxs)(`strong`,{children:[d.length,` MAIL`]}),(0,Y.jsx)(`small`,{children:h.subject})]})]})]}),(0,Y.jsxs)(`div`,{className:I(`agent-office__scene`,x),children:[(0,Y.jsxs)(`div`,{className:`agent-office__window`,"aria-hidden":`true`,children:[(0,Y.jsx)(`span`,{}),(0,Y.jsx)(`span`,{}),(0,Y.jsx)(`span`,{})]}),(0,Y.jsxs)(`div`,{className:`agent-office__plant`,"aria-hidden":`true`,children:[(0,Y.jsx)(`span`,{}),(0,Y.jsx)(`i`,{}),(0,Y.jsx)(`b`,{})]}),(0,Y.jsxs)(`div`,{className:`agent-office__desk-zone`,"aria-hidden":`true`,children:[(0,Y.jsx)(At,{active:f,failed:p,role:g,variant:v.avatar,motion:v.motion}),(0,Y.jsx)(`span`,{className:`agent-office__monitor`,children:l?(0,Y.jsx)(kt,{kind:l.kind,active:c!==void 0}):(0,Y.jsx)(k,{})}),(0,Y.jsxs)(`span`,{className:`agent-office__activity-fx`,children:[(0,Y.jsx)(`span`,{}),(0,Y.jsx)(`i`,{}),(0,Y.jsx)(`b`,{})]}),(0,Y.jsx)(`span`,{className:`agent-office__desk`}),(0,Y.jsx)(`span`,{className:`agent-office__desk-lamp`}),(0,Y.jsxs)(`span`,{className:`agent-office__desk-clutter`,children:[(0,Y.jsx)(`i`,{}),(0,Y.jsx)(`b`,{})]}),(0,Y.jsxs)(`span`,{className:I(`agent-office__desk-charm`,`is-${v.charm}`),children:[(0,Y.jsx)(`i`,{}),(0,Y.jsx)(`b`,{})]}),(0,Y.jsxs)(`span`,{className:I(`agent-office__mug`,`is-${g}`),children:[(0,Y.jsx)(`i`,{"aria-hidden":`true`}),(0,Y.jsx)(`b`,{"aria-hidden":`true`})]})]}),ee&&(0,Y.jsx)(`div`,{className:I(`agent-office__mail-flyby`,`is-${h.direction}`),children:(0,Y.jsx)(Mt,{mail:h,compact:!0,onSelect:()=>n({kind:`mail`,mail:h,agentName:o.name})},h.id)}),(0,Y.jsxs)(`div`,{className:I(`agent-office__conveyor`,c&&`is-moving`),children:[(0,Y.jsxs)(`div`,{className:`agent-office__belt`,"aria-hidden":`true`,children:[(0,Y.jsx)(`span`,{}),(0,Y.jsx)(`span`,{}),(0,Y.jsx)(`span`,{}),(0,Y.jsx)(`span`,{}),(0,Y.jsx)(`span`,{}),(0,Y.jsx)(`span`,{})]}),(0,Y.jsx)(`div`,{className:`agent-office__current-action`,children:l?(0,Y.jsx)(jt,{call:l,onSelect:()=>n({kind:`tool`,call:l,agentName:o.name})},l.id):(0,Y.jsx)(Ft,{active:f})})]})]}),(0,Y.jsxs)(`div`,{className:`agent-office__history`,children:[(0,Y.jsxs)(`div`,{className:`agent-office__history-heading`,children:[(0,Y.jsx)(`span`,{children:r(`activity:agentOffice.recent`)}),b!==void 0&&(0,Y.jsx)(`span`,{children:xt(b,t)})]}),(0,Y.jsx)(`div`,{className:`agent-office__history-list`,children:y.length>0?y.map(e=>(0,Y.jsx)(jt,{call:e,compact:!0,onSelect:()=>n({kind:`tool`,call:e,agentName:o.name})},`tool:${e.id}`)):(0,Y.jsx)(`span`,{className:`agent-office__history-empty`,children:o.toolCalls>0&&o.recentTools===void 0&&o.activity===void 0?r(`activity:agentOffice.telemetryReconnect`):r(`activity:agentOffice.noCalls`)})})]})]})}function X({label:e,value:t}){return(0,Y.jsxs)(`div`,{className:`agent-office__detail-row`,children:[(0,Y.jsx)(`span`,{children:e}),(0,Y.jsx)(`strong`,{children:t})]})}function Lt({selected:e,onClose:t}){let{t:n}=F(),{call:i,agentName:a}=e,o=gt[i.kind],s=wt(i.input),c=wt(i.output);return(0,Y.jsxs)(`aside`,{className:`agent-office__detail`,"aria-label":`${i.toolName} details`,children:[(0,Y.jsxs)(`div`,{className:`agent-office__detail-header`,children:[(0,Y.jsx)(`div`,{className:I(`agent-office__detail-icon`,`is-${i.kind}`),children:(0,Y.jsx)(o,{"aria-hidden":`true`})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:n(`activity:agentOffice.toolCall`)}),(0,Y.jsx)(`h2`,{children:i.toolName})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`Close details`,children:(0,Y.jsx)(N,{})})]}),(0,Y.jsxs)(`div`,{className:`agent-office__detail-status`,children:[(0,Y.jsx)(`span`,{className:I(`agent-office__status-dot`,i.status===`running`&&`is-active`,i.status===`failed`&&`is-failed`)}),(0,Y.jsx)(`strong`,{children:i.summary}),(0,Y.jsx)(`span`,{children:i.status})]}),(0,Y.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,Y.jsx)(`h3`,{children:n(`activity:agentOffice.execution`)}),(0,Y.jsx)(X,{label:n(`activity:agentOffice.agent`),value:a}),(0,Y.jsx)(X,{label:n(`activity:agentOffice.started`),value:new Date(i.startedAt).toLocaleTimeString()}),(0,Y.jsx)(X,{label:n(`activity:agentOffice.duration`),value:St(i.durationMs)}),i.sessionId&&(0,Y.jsx)(X,{label:n(`activity:agentOffice.session`),value:bt(i.sessionId,28)})]}),(i.target||i.fileTargets.length>0)&&(0,Y.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,Y.jsx)(`h3`,{children:n(`activity:agentOffice.target`)}),i.target&&(0,Y.jsx)(`code`,{className:`agent-office__target-code`,children:i.target}),i.fileTargets.map((e,t)=>(0,Y.jsxs)(`div`,{className:`agent-office__file-target`,children:[(0,Y.jsx)(r,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{children:e.filePath}),(e.line||e.endLine)&&(0,Y.jsxs)(`strong`,{children:[`L`,e.line??1,e.endLine?`–${e.endLine}`:``]})]},`${e.filePath}:${t}`))]}),(i.outputLines!==void 0||i.outputBytes!==void 0||i.outputTokens!==void 0)&&(0,Y.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,Y.jsx)(`h3`,{children:n(`activity:agentOffice.resultSize`)}),(0,Y.jsxs)(`div`,{className:`agent-office__metric-grid`,children:[i.outputLines!==void 0&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`strong`,{children:i.outputLines.toLocaleString()}),(0,Y.jsx)(`span`,{children:n(`activity:agentOffice.lines`)})]}),i.outputBytes!==void 0&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`strong`,{children:i.outputBytes.toLocaleString()}),(0,Y.jsx)(`span`,{children:n(`activity:agentOffice.bytes`)})]}),i.outputTokens!==void 0&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`strong`,{children:[`≈`,i.outputTokens.toLocaleString()]}),(0,Y.jsx)(`span`,{children:n(`activity:agentOffice.tokens`)})]})]})]}),s&&(0,Y.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,Y.jsx)(`h3`,{children:n(`activity:agentOffice.input`)}),(0,Y.jsx)(`pre`,{children:(0,Y.jsx)(`code`,{children:s})})]}),c&&(0,Y.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,Y.jsx)(`h3`,{children:n(`activity:agentOffice.outputPreview`)}),(0,Y.jsx)(`pre`,{children:(0,Y.jsx)(`code`,{children:c})})]})]})}function Rt({selected:e,onClose:t}){let{t:n}=F(),{mail:r,agentName:a}=e;return(0,Y.jsxs)(`aside`,{className:`agent-office__detail`,"aria-label":`${r.subject} details`,children:[(0,Y.jsxs)(`div`,{className:`agent-office__detail-header`,children:[(0,Y.jsx)(`div`,{className:`agent-office__detail-icon is-mail`,children:(0,Y.jsx)(i,{"aria-hidden":`true`})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:r.direction===`incoming`?`INCOMING MAIL`:`OUTGOING MAIL`}),(0,Y.jsx)(`h2`,{children:r.subject})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`Close mail details`,children:(0,Y.jsx)(N,{})})]}),(0,Y.jsxs)(`div`,{className:`agent-office__detail-status`,children:[(0,Y.jsx)(`span`,{className:I(`agent-office__status-dot`,r.unread&&`is-active`)}),(0,Y.jsxs)(`strong`,{children:[r.from,` → `,r.to]}),(0,Y.jsx)(`span`,{children:r.type})]}),(0,Y.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,Y.jsx)(`h3`,{children:n(`activity:mailbox.messages`)}),(0,Y.jsx)(X,{label:n(`activity:agentOffice.agent`),value:a}),(0,Y.jsx)(X,{label:n(`activity:agentOffice.started`),value:new Date(r.timestampMs).toLocaleTimeString()}),(0,Y.jsx)(X,{label:`Priority`,value:r.priority}),(0,Y.jsx)(X,{label:`Route`,value:`${r.from} → ${r.to}`})]}),(0,Y.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,Y.jsx)(`h3`,{children:r.subject}),(0,Y.jsx)(`div`,{className:`agent-office__mail-body`,children:r.body})]})]})}function zt({selected:e,onClose:t}){let{t:n}=F();return(0,Y.jsxs)(`aside`,{className:`agent-office__detail`,"aria-label":`${e.agentName} task details`,children:[(0,Y.jsxs)(`div`,{className:`agent-office__detail-header`,children:[(0,Y.jsx)(`div`,{className:`agent-office__detail-icon is-task`,children:(0,Y.jsx)(a,{"aria-hidden":`true`})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:n(`activity:agentOffice.currentTask`)}),(0,Y.jsx)(`h2`,{children:e.agentName})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`Close task details`,children:(0,Y.jsx)(N,{})})]}),(0,Y.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,Y.jsx)(`h3`,{children:n(`activity:agentOffice.task`)}),e.taskId&&(0,Y.jsx)(X,{label:`ID`,value:e.taskId}),(0,Y.jsx)(`div`,{className:`agent-office__task-body`,children:e.task})]})]})}function Bt({selected:e,onClose:t}){let{t:n}=F(),r=e.todos.filter(e=>e.status!==`completed`).length;return(0,Y.jsxs)(`aside`,{className:`agent-office__detail`,"aria-label":`${e.officeLabel} briefing`,children:[(0,Y.jsxs)(`div`,{className:`agent-office__detail-header`,children:[(0,Y.jsx)(`div`,{className:`agent-office__detail-icon is-briefing`,children:(0,Y.jsx)(c,{"aria-hidden":`true`})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:e.instructionActive?n(`activity:agentOffice.activeInstruction`):n(`activity:agentOffice.officeBriefing`)}),(0,Y.jsx)(`h2`,{children:e.officeLabel})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`Close office briefing`,children:(0,Y.jsx)(N,{})})]}),(0,Y.jsxs)(`div`,{className:`agent-office__detail-status`,children:[(0,Y.jsx)(`span`,{className:I(`agent-office__status-dot`,(e.instructionActive||r>0)&&`is-active`)}),(0,Y.jsx)(`strong`,{children:e.telemetryConnected?n(`activity:agentOffice.activeTodos`):n(`activity:agentOffice.telemetryWaiting`)}),(0,Y.jsx)(`span`,{children:e.telemetryConnected?r:`—`})]}),(0,Y.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,Y.jsx)(`h3`,{children:e.instructionActive?n(`activity:agentOffice.activeInstruction`):n(`activity:agentOffice.leaderPrompt`)}),e.promptAt!==void 0&&(0,Y.jsx)(X,{label:n(`activity:agentOffice.promptReceived`),value:new Date(e.promptAt).toLocaleString()}),(0,Y.jsx)(`div`,{className:`agent-office__task-body`,children:e.prompt??(e.telemetryConnected?n(`activity:agentOffice.noPrompt`):n(`activity:agentOffice.telemetryWaiting`))})]}),(0,Y.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,Y.jsx)(`h3`,{children:n(`activity:agentOffice.todos`)}),(0,Y.jsx)(`div`,{className:`agent-office__todo-detail-list`,children:e.telemetryConnected?e.todos.length>0?e.todos.map(e=>(0,Y.jsxs)(`div`,{className:I(`agent-office__todo-detail`,`is-${e.status}`),children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`strong`,{children:e.content}),(0,Y.jsx)(`small`,{children:n(`activity:agentOffice.todoStatus.${e.status}`)})]})]},e.id)):(0,Y.jsx)(`span`,{className:`agent-office__history-empty`,children:n(`activity:agentOffice.noActiveTodos`)}):(0,Y.jsx)(`span`,{className:`agent-office__history-empty`,children:n(`activity:agentOffice.todoTelemetryWaiting`)})})]})]})}function Vt({selected:e,onClose:t}){return e.kind===`tool`?(0,Y.jsx)(Lt,{selected:e,onClose:t}):e.kind===`mail`?(0,Y.jsx)(Rt,{selected:e,onClose:t}):e.kind===`task`?(0,Y.jsx)(zt,{selected:e,onClose:t}):(0,Y.jsx)(Bt,{selected:e,onClose:t})}function Ht(){let{t:e}=F(),t=ke(e=>e.liveSessions),n=ke(e=>e.aggregate),r=De(e=>e.agents),i=Ae(e=>e.agents),a=Ae(e=>e.messages),o=Te(e=>e.toolEvents),s=Ee(e=>e.projectName),[c,l]=(0,H.useState)(null),u=(0,H.useMemo)(()=>ft(t,r,i),[t,r,i]),p=(0,H.useMemo)(()=>u.flatMap(e=>e.agents.map(t=>{let n=Dt(Qe(o,t.serverId,e.sessionId),Je(t.recentTools,t.serverId,e.sessionId),Et(t,e,r.get(t.serverId)?.toolLog??[])),i=t.status===`active`||t.status===`streaming`,s=n.find(e=>e.status===`running`);!s&&i&&t.currentTool&&(s=$e(t.serverId,t.currentTool,e.sessionId));let c=s??n[0],l=n.filter(e=>e.status!==`running`).slice(0,6),u=Ot(Ye(t.recentMail),Ze(a,t,e.sessionId));return{key:t.officeId,client:e,agent:t,calls:n,current:s,display:c,history:l,mail:u}})),[u,r,a,o]),h=(0,H.useMemo)(()=>u.map(e=>{let t=p.filter(t=>t.client.id===e.id);return{client:e,agents:t,stats:Tt(t)}}).filter(e=>e.agents.length>0),[u,p]),g=p.filter(({agent:e})=>e.status===`active`||e.status===`streaming`).length,_=s||t.find(e=>e.projectName)?.projectName||e(`activity:office.fleetHq`),v=Date.now();return(0,Y.jsxs)(`div`,{className:`agent-office`,children:[(0,Y.jsxs)(`header`,{className:`agent-office__header`,children:[(0,Y.jsxs)(`div`,{className:`agent-office__title`,children:[(0,Y.jsx)(`span`,{className:`agent-office__brand-mark`,children:(0,Y.jsx)(d,{"aria-hidden":`true`})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:e(`activity:agentOffice.liveProjectOffice`)}),(0,Y.jsx)(`h1`,{children:_})]})]}),(0,Y.jsxs)(`div`,{className:`agent-office__live-pill`,children:[(0,Y.jsx)(`span`,{}),` LIVE`]}),(0,Y.jsxs)(`div`,{className:`agent-office__summary`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(f,{}),(0,Y.jsx)(`strong`,{children:p.length}),(0,Y.jsx)(`span`,{children:e(`activity:agentOffice.agents`)})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(T,{}),(0,Y.jsx)(`strong`,{children:g}),(0,Y.jsx)(`span`,{children:e(`activity:agentOffice.working`)})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(m,{}),(0,Y.jsx)(`strong`,{children:n.toolCalls.toLocaleString()}),(0,Y.jsx)(`span`,{children:e(`activity:agentOffice.toolCalls`)})]})]})]}),(0,Y.jsx)(`main`,{className:`agent-office__floor`,children:p.length>0?h.map(t=>(0,Y.jsxs)(`section`,{className:`agent-office__client-office`,children:[(0,Y.jsx)(Nt,{office:t,now:v}),(0,Y.jsx)(Pt,{office:t,now:v,onSelect:l}),(0,Y.jsxs)(`div`,{className:`agent-office__column-headings`,"aria-hidden":`true`,children:[(0,Y.jsx)(`span`,{children:e(`activity:agentOffice.team`)}),(0,Y.jsx)(`span`,{children:e(`activity:agentOffice.liveDesk`)}),(0,Y.jsx)(`span`,{children:e(`activity:agentOffice.lastActions`)})]}),(0,Y.jsx)(`div`,{className:`agent-office__client-desks`,children:t.agents.map(e=>(0,Y.jsx)(It,{model:e,now:v,onSelect:l},e.key))})]},t.client.id)):(0,Y.jsxs)(`div`,{className:`agent-office__empty-state`,children:[(0,Y.jsx)(`span`,{children:(0,Y.jsx)(E,{"aria-hidden":`true`})}),(0,Y.jsx)(`h2`,{children:e(`activity:agentOffice.readyTitle`)}),(0,Y.jsx)(`p`,{children:e(`activity:agentOffice.readyBody`)})]})}),(0,Y.jsxs)(`footer`,{className:`agent-office__footer`,children:[(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`span`,{className:`agent-office__status-dot is-active`}),` `,e(`activity:agentOffice.liveEvent`)]}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(ne,{}),` `,e(`activity:agentOffice.connectedSessions`,{count:t.length})]}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(pe,{}),` `,e(`activity:agentOffice.detailHint`)]})]}),c&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`button`,{type:`button`,className:`agent-office__detail-backdrop`,onClick:()=>l(null),"aria-label":`Close tool details`}),(0,Y.jsx)(Vt,{selected:c,onClose:()=>l(null)})]})]})}function Ut(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 Wt={user:{Icon:de,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:f,labelKey:`activity:message.roleAssistant`,avatarBg:`bg-accent`,avatarColor:`text-accent-foreground`,avatarRing:`ring-2 ring-offset-2 ring-offset-background ring-accent/20`,bubbleBg:`bg-card`,bubbleBorder:`border-border`,textColor:`text-foreground`},tool:{Icon:v,labelKey:`activity:message.roleTool`,avatarBg:`bg-secondary`,avatarColor:`text-secondary-foreground`,avatarRing:`ring-2 ring-offset-2 ring-offset-background ring-secondary/20`,bubbleBg:`bg-muted/80`,bubbleBorder:`border-border`,textColor:`text-foreground`},system:{Icon:f,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:Ce,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 Gt({entry:e}){let{t}=F();return e.role===`error`?(0,Y.jsx)(Me,{text:e.text}):e.role===`tool`?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5 tool-details`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-foreground`,children:[(0,Y.jsx)(v,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{className:`font-mono`,children:e.tool??t(`activity:watch.toolFallback`)}),e.durationMs!==void 0&&(0,Y.jsxs)(`span`,{className:`ml-auto text-[10px] text-muted-foreground font-normal tabular-nums`,children:[(0,Y.jsx)(w,{className:`h-3 w-3 inline mr-0.5 align-text-bottom`}),Ut(e.durationMs)]})]}),e.input!==void 0&&e.input!==null&&(0,Y.jsx)(`div`,{className:`p-3 bg-muted/50 rounded-lg overflow-x-auto`,children:(0,Y.jsx)(Pe,{input:e.input})}),e.output!==void 0&&e.output!==null?(0,Y.jsx)(`div`,{className:`text-sm leading-relaxed markdown-content`,children:typeof e.output==`string`?(0,Y.jsx)(B,{remarkPlugins:[je],rehypePlugins:R,components:z,children:e.output}):(0,Y.jsx)(`pre`,{className:`whitespace-pre-wrap font-mono text-xs bg-card rounded-lg p-2 border border-border overflow-x-auto`,children:JSON.stringify(e.output,null,2)})}):e.text?(0,Y.jsx)(`div`,{className:`text-sm leading-relaxed markdown-content`,children:(0,Y.jsx)(B,{remarkPlugins:[je],rehypePlugins:R,components:z,children:e.text})}):null,e.isError&&(0,Y.jsxs)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/5 px-3 py-2`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-destructive`,children:t(`activity:watch.toolFailed`)}),e.text&&(0,Y.jsx)(`pre`,{className:`mt-1 text-xs whitespace-pre-wrap text-destructive/80`,children:e.text})]})]}):(0,Y.jsx)(`div`,{className:`text-sm leading-relaxed markdown-content`,children:(0,Y.jsx)(B,{remarkPlugins:[je],rehypePlugins:R,components:z,children:e.text})})}function Kt({entry:e,isContinuation:t=!1}){let{t:n}=F(),r=Wt[e.role],i=r.Icon;return(0,Y.jsxs)(`div`,{className:`group flex gap-3 animate-message msg-bubble rounded-lg transition-shadow`,children:[t?(0,Y.jsx)(`div`,{className:`flex-shrink-0 w-8`}):(0,Y.jsx)(`div`,{className:I(`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center`,r.avatarBg,r.avatarColor,r.avatarRing),children:(0,Y.jsx)(i,{className:`h-4 w-4`})}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5 min-w-0 flex-1`,children:[!t&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:I(`text-xs font-medium`,r.textColor),children:e.role===`tool`&&e.tool?e.tool:n(r.labelKey)}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:new Date(e.ts).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}),e.role===`tool`&&e.durationMs!==void 0&&(0,Y.jsxs)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[`· `,Ut(e.durationMs)]})]}),(0,Y.jsx)(`div`,{className:I(`rounded-2xl px-4 py-3 border`,e.role===`user`&&`rounded-br-md`,e.role===`assistant`&&`rounded-bl-md`,e.role===`tool`&&`rounded-bl-sm`,e.role===`system`&&`rounded-bl-sm opacity-70`,e.role===`error`&&`rounded-bl-sm`,r.bubbleBg,r.bubbleBorder),children:(0,Y.jsx)(`div`,{className:I(`text-sm leading-relaxed markdown-content`,r.textColor),children:(0,Y.jsx)(Gt,{entry:e})})}),e.text&&e.role!==`error`&&(0,Y.jsx)(`div`,{className:`opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,Y.jsx)(V,{text:e.text,label:n(`common:action.copy`)})})]})]})}var qt=[`steer`,`ask`,`assign`,`note`],Jt=2500;function Yt({sessionId:e,limit:t=200}){let[n,r]=(0,H.useState)(null),{t:i}=F(),[a,o]=(0,H.useState)(null),[s,c]=(0,H.useState)(``),[l,u]=(0,H.useState)(!1),[d,p]=(0,H.useState)(null),[m,h]=(0,H.useState)(`steer`),[g,_]=(0,H.useState)(`high`),[v,ee]=(0,H.useState)([]),[y,b]=(0,H.useState)(!1),x=(0,H.useRef)(null),S=(0,H.useRef)(!0),C=(0,H.useRef)(!0),w=ke(e=>e.liveSessions),T=(0,H.useMemo)(()=>w.find(t=>t.sessionId===e),[w,e]),te=(0,H.useMemo)(()=>{let e=T;return e?`${e.status}|${e.agents.map(e=>`${e.id}:${e.status}:${e.toolCalls??0}:${e.iterations??0}`).join(`,`)}`:``},[T]),ne=T?.status===`active`||(T?.agents.some(e=>e.status===`running`||e.status===`streaming`)??!1),E=(0,H.useMemo)(()=>{if(!T)return null;let e=T.agents.find(e=>e.status===`running`||e.status===`streaming`);return e?.currentTool?`🔧 ${e.currentTool}`:e?i(`activity:sessionWatch.working`,{name:e.name??e.id}):null},[T,i]),re=(0,H.useMemo)(()=>{if(!T)return null;let e=T.agents.find(e=>e.partialText&&(e.status===`streaming`||e.status===`running`))??T.agents.find(e=>e.partialText);return e?.partialText?{label:e.id===`leader`?i(`activity:sessionWatch.claude`):e.name||e.id,text:e.partialText}:null},[T,i]),ie=(0,H.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();C.current&&(r(i),o(null))}catch(e){C.current&&o(e instanceof Error?e.message:String(e))}},[e,t]),D=(0,H.useCallback)(async()=>{try{let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/mailbox`);if(!t.ok)return;let n=await t.json();C.current&&Array.isArray(n.thread)&&ee(n.thread)}catch{}},[e]);(0,H.useEffect)(()=>{C.current=!0,r(null),o(null),ee([]),ie(),D();let e=setInterval(()=>{document.hidden||(ie(),D())},Jt);return()=>{C.current=!1,clearInterval(e)}},[ie,D]),(0,H.useEffect)(()=>{te&&ie()},[te,ie]),(0,H.useEffect)(()=>{S.current&&x.current&&(x.current.scrollTop=x.current.scrollHeight)},[n,re]);let ae=()=>{let e=x.current;e&&(S.current=e.scrollHeight-e.scrollTop-e.clientHeight<40)},oe=async()=>{let t=s.trim();if(!(!t||l)){u(!0),p(null);try{let n=await fetch(`/api/sessions/${encodeURIComponent(e)}/message`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:t,type:m,priority:g})});if(!n.ok)throw Error(`HTTP ${n.status}`);c(``),p(ne?O.t(`activity:sessionWatch.sentRunning`):O.t(`activity:sessionWatch.sentIdle`)),D()}catch(e){p(O.t(`activity:sessionWatch.sentFailed`,{error:e instanceof Error?e.message:String(e)}))}finally{u(!1)}}},k=async()=>{if(!y){b(!0),p(null);try{let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/interrupt`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({reason:O.t(`activity:sessionWatch.interruptReason`)})});if(!t.ok)throw Error(`HTTP ${t.status}`);p(O.t(`activity:sessionWatch.interruptSent`)),D()}catch(e){p(O.t(`activity:sessionWatch.interruptFailed`,{error:e instanceof Error?e.message:String(e)}))}finally{b(!1)}}},se=n?.entries??[];return(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5 shrink-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] uppercase tracking-wide text-muted-foreground`,children:[(0,Y.jsx)(`span`,{className:I(`h-1.5 w-1.5 rounded-full`,ne?`bg-success animate-pulse`:`bg-muted-foreground`)}),i(`activity:sessionWatch.liveStream`)]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n&&(0,Y.jsxs)(`div`,{className:`text-[10px] text-muted-foreground`,children:[i(`activity:sessionWatch.events`,{count:n.total}),` · `,n.status]}),ne&&(0,Y.jsx)(`button`,{type:`button`,onClick:()=>void k(),disabled:y,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(y?`activity:sessionWatch.interrupting`:`activity:sessionWatch.interrupt`)})]})]}),E&&(0,Y.jsxs)(`div`,{className:`mb-1.5 shrink-0 text-[10px] text-foreground truncate`,children:[`▶ `,E]}),a&&(0,Y.jsxs)(`div`,{className:`text-[11px] text-destructive mb-1 shrink-0`,children:[`· `,a]}),(0,Y.jsxs)(`div`,{ref:x,onScroll:ae,className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain space-y-1.5 pr-1`,children:[se.length===0&&!a&&(0,Y.jsx)(`div`,{className:`text-[11px] text-muted-foreground italic`,children:i(`activity:sessionWatch.loading`)}),se.map((e,t)=>(0,Y.jsx)(Kt,{entry:e,isContinuation:t>0&&se[t-1].role===e.role},`${e.ts}-${t}`)),re&&(0,Y.jsxs)(`div`,{className:`flex gap-3 animate-message`,children:[(0,Y.jsx)(`div`,{className:`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center bg-accent text-accent-foreground ring-2 ring-offset-2 ring-offset-background ring-accent/20`,children:(0,Y.jsx)(f,{className:`h-4 w-4 animate-pulse`})}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5 max-w-[85%] min-w-0`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground px-1`,children:re.label}),(0,Y.jsx)(`div`,{className:`rounded-2xl rounded-bl-md px-4 py-3 bg-card border border-border`,children:(0,Y.jsxs)(`span`,{className:`text-sm leading-relaxed text-foreground whitespace-pre-wrap break-words`,children:[re.text,(0,Y.jsx)(`span`,{className:`animate-pulse text-primary`,children:`▋`})]})})]})]})]}),v.length>0&&(0,Y.jsxs)(`div`,{className:`mt-2 pt-2 border-t border-border shrink-0 max-h-28 overflow-y-auto space-y-1`,children:[(0,Y.jsx)(`div`,{className:`text-[9px] uppercase tracking-wide text-muted-foreground`,children:i(`activity:mailbox.messages`)}),v.slice(-6).map(e=>{let t=e.completed?i(`activity:sessionWatch.done`):e.readByLeader?i(`activity:sessionWatch.read`):i(`activity:sessionWatch.delivered`);return(0,Y.jsxs)(`div`,{className:`text-[10px] leading-snug`,children:[(0,Y.jsx)(`span`,{className:I(`font-semibold mr-1.5`,e.fromLeader?`text-accent`:`text-primary`),children:e.fromLeader?i(`activity:sessionWatch.agent`):i(`activity:sessionWatch.you`)}),(0,Y.jsx)(`span`,{className:`text-foreground whitespace-pre-wrap break-words`,children:e.body}),!e.fromLeader&&(0,Y.jsx)(`span`,{className:I(`ml-1.5 text-[9px]`,e.completed?`text-success`:e.readByLeader?`text-primary`:`text-muted-foreground`),children:t})]},e.id)})]}),(0,Y.jsxs)(`div`,{className:`mt-2 pt-2 border-t border-border shrink-0`,children:[(0,Y.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5`,children:[(0,Y.jsx)(`select`,{value:m,onChange:e=>h(e.target.value),title:i(`activity:sessionWatch.msgType.${m}Hint`),className:`rounded bg-muted border border-border px-1.5 py-0.5 text-[10px] text-foreground focus:outline-none focus:ring-1 focus:ring-ring`,children:qt.map(e=>(0,Y.jsx)(`option`,{value:e,children:i(`activity:sessionWatch.msgType.${e}Label`)},e))}),(0,Y.jsxs)(`select`,{value:g,onChange:e=>_(e.target.value),title:i(`activity:sessionWatch.priority`),className:`rounded bg-muted border border-border px-1.5 py-0.5 text-[10px] text-foreground focus:outline-none focus:ring-1 focus:ring-ring`,children:[(0,Y.jsx)(`option`,{value:`high`,children:`high`}),(0,Y.jsx)(`option`,{value:`normal`,children:`normal`}),(0,Y.jsx)(`option`,{value:`low`,children:`low`})]})]}),(0,Y.jsxs)(`div`,{className:`flex items-end gap-1.5`,children:[(0,Y.jsx)(`textarea`,{value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),oe())},rows:2,placeholder:i(`activity:sessionWatch.placeholder`,{label:i(`activity:sessionWatch.msgType.${m}Label`)}),className:`flex-1 resize-none rounded-md bg-muted border border-border px-2 py-1 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring`}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>void oe(),disabled:l||!s.trim(),className:`shrink-0 rounded-md bg-primary text-primary-foreground px-2.5 py-1.5 text-xs hover:bg-primary/90 disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,children:l?`…`:i(`activity:sessionWatch.send`)})]}),d&&(0,Y.jsx)(`div`,{className:`mt-1 text-[10px] text-muted-foreground`,children:d}),(0,Y.jsx)(`div`,{className:`mt-0.5 text-[9px] text-muted-foreground`,children:i(`activity:sessionWatch.sendHint`)})]})]})}var Z={primary:`hsl(var(--primary))`,info:`hsl(var(--info))`,success:`hsl(var(--success))`,warning:`hsl(var(--warning))`,destructive:`hsl(var(--destructive))`,muted:`hsl(var(--muted-foreground))`},Xt=.12;function Zt(e){return Math.min(100,Math.max(0,e??0))}function Q({status:e,small:t,activity:n=0}){let r=t?`w-2 h-2`:`w-3 h-3`,i=t?4+n*4:6+n*6,a={idle:`bg-muted-foreground`,active:`bg-success`,streaming:`bg-primary`,completed:`bg-primary`,error:`bg-destructive`,offline:`bg-muted-foreground/60`},o={idle:Z.muted,active:Z.success,streaming:Z.primary,completed:Z.primary,error:Z.destructive,offline:Z.muted};return(0,Y.jsx)(`span`,{className:I(`rounded-full`,r,n>0&&`animate-pulse`,a[e]),style:{boxShadow:n>0?`0 0 ${i}px ${o[e]}`:void 0}})}function $(){let e={opacity:0,width:1,height:1,minWidth:0,border:`none`,background:`transparent`};return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(P,{type:`target`,position:x.Top,style:e,isConnectable:!1}),(0,Y.jsx)(P,{type:`source`,position:x.Bottom,style:e,isConnectable:!1})]})}function Qt({data:e}){let{t}=F();return(0,Y.jsxs)(`div`,{className:`mt-2 flex items-center justify-between border-t border-border/60 pt-1.5 text-[10px] text-muted-foreground`,children:[(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`span`,{className:`font-mono text-foreground`,children:e.agentCount??0}),` `,t(`activity:office.agentsSuffix`)]}),e.startedAt&&(0,Y.jsx)(`span`,{children:t(`activity:office.upPrefix`,{time:nt(e.startedAt,Date.now())})})]})}function $t({data:e}){let{t}=F(),r=e.status===`active`||e.status===`streaming`,i=e.status===`error`,a=e.status===`offline`,o=e.color||Z.info;return(0,Y.jsxs)(`div`,{className:I(`rounded-xl border-2 p-4 min-w-[180px] transition-all backdrop-blur-sm`,r&&`shadow-lg shadow-primary/15`,i&&`border-destructive/50 bg-destructive/10`,a&&`border-border/70 bg-muted/35 opacity-60`,!r&&!i&&!a&&`border-primary/30 bg-primary/10`),children:[(0,Y.jsx)($,{}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,Y.jsx)(`div`,{className:I(`flex items-center justify-center w-10 h-10 rounded-lg`,r?`bg-primary/15`:`bg-primary/10`),children:(0,Y.jsx)(n,{className:`h-5 w-5`,style:{color:o}})}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold truncate`,style:{color:o},children:e.label}),(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:t(`activity:office.webuiClient`)})]}),(0,Y.jsx)(Q,{status:e.status,activity:e.vizActivity??0})]}),e.sublabel&&(0,Y.jsx)(`div`,{className:`mb-2 truncate text-[10px] text-muted-foreground`,children:e.sublabel}),(0,Y.jsx)(`div`,{className:`flex items-center gap-2 text-[10px] text-muted-foreground`,children:a?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(le,{className:`h-3 w-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{children:t(`activity:office.disconnected`)})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(E,{className:`h-3 w-3 text-success`}),(0,Y.jsx)(`span`,{children:t(`activity:office.connected`)})]})}),r&&(0,Y.jsx)(`div`,{className:`mt-2 h-1 overflow-hidden rounded-full bg-primary/20`,children:(0,Y.jsx)(`div`,{className:`h-full animate-pulse bg-primary`,style:{width:`60%`}})}),(0,Y.jsx)(Qt,{data:e})]})}function en({data:e}){let{t}=F(),n=e.status===`active`||e.status===`streaming`,r=e.status===`error`,i=e.color||Z.success;return(0,Y.jsxs)(`div`,{className:I(`rounded-xl border-2 p-4 min-w-[180px] transition-all backdrop-blur-sm`,n&&`shadow-lg shadow-success/15`,r&&`border-destructive/50 bg-destructive/10`,!n&&!r&&`border-success/30 bg-success/10`),children:[(0,Y.jsx)($,{}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,Y.jsx)(`div`,{className:I(`flex items-center justify-center w-10 h-10 rounded-lg`,n?`bg-success/15`:`bg-success/10`),children:(0,Y.jsx)(v,{className:`h-5 w-5`,style:{color:i}})}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold truncate`,style:{color:i},children:e.label}),(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:t(`activity:office.tuiClient`)})]}),(0,Y.jsx)(Q,{status:e.status,activity:e.vizActivity??0})]}),e.sublabel&&(0,Y.jsx)(`div`,{className:`mb-2 truncate text-[10px] text-muted-foreground`,children:e.sublabel}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,Y.jsx)(v,{className:`h-3 w-3 text-success`}),(0,Y.jsx)(`span`,{children:t(`activity:office.terminal`)})]}),(0,Y.jsx)(Qt,{data:e})]})}function tn({data:e}){let{t}=F(),n=e.status===`active`||e.status===`streaming`,r=e.color||Z.warning;return(0,Y.jsxs)(`div`,{className:I(`rounded-xl border-2 p-4 min-w-[160px] transition-all backdrop-blur-sm`,n&&`shadow-lg shadow-warning/15`,!n&&`border-warning/30 bg-warning/10`),children:[(0,Y.jsx)($,{}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,Y.jsx)(`div`,{className:I(`flex items-center justify-center w-10 h-10 rounded-lg`,n?`bg-warning/15`:`bg-warning/10`),children:(0,Y.jsx)(v,{className:`h-5 w-5`,style:{color:r}})}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold truncate`,style:{color:r},children:e.label}),(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:t(`activity:office.repl`)})]}),(0,Y.jsx)(Q,{status:e.status,activity:e.vizActivity??0})]}),e.sublabel&&(0,Y.jsx)(`div`,{className:`mb-1 truncate text-[10px] text-muted-foreground`,children:e.sublabel}),(0,Y.jsx)(Qt,{data:e})]})}function nn({data:e}){let{t}=F(),n=e.status===`active`||e.status===`streaming`,r=e.color||Z.primary;return(0,Y.jsxs)(`div`,{className:`relative min-w-[200px] rounded-xl border-2 border-border/70 bg-card/90 p-4 shadow-lg backdrop-blur-sm transition-all`,children:[(0,Y.jsx)($,{}),(0,Y.jsx)(`div`,{className:`absolute -top-3 left-1/2 -translate-x-1/2 rounded-full bg-primary px-2 py-0.5 text-[11px] font-bold text-primary-foreground`,children:t(`activity:office.coordinator`)}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 mb-3 mt-2`,children:[(0,Y.jsx)(`div`,{className:I(`flex items-center justify-center w-12 h-12 rounded-xl`,n?`bg-primary/15`:`bg-primary/10`),children:(0,Y.jsx)(h,{className:`h-6 w-6`,style:{color:r}})}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-sm font-bold truncate`,style:{color:r},children:e.label}),(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:e.sublabel||t(`activity:office.fleetSummary`)})]}),(0,Y.jsx)(Q,{status:e.status,activity:e.vizActivity??0})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-[10px] mb-2`,children:[(0,Y.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,Y.jsxs)(`div`,{className:`font-mono`,children:[(0,Y.jsx)(`span`,{className:`text-success`,children:e.agentsActive||0}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:` / `}),(0,Y.jsx)(`span`,{className:`text-primary`,children:e.agentsTotal||0})]}),(0,Y.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:officeMap.agents`)})]}),(0,Y.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,Y.jsx)(`div`,{className:`font-mono text-warning`,children:(e.toolCalls||0).toLocaleString()}),(0,Y.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:office.toolCallsLabel`)})]}),(0,Y.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,Y.jsx)(`div`,{className:`font-mono text-foreground`,children:et(e.tokensIn)}),(0,Y.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:office.tokensLabel`)})]}),(0,Y.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,Y.jsxs)(`div`,{className:`font-mono text-success`,children:[`$`,(e.costUsd||0).toFixed(3)]}),(0,Y.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:office.cost`)})]})]}),n&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-primary`,children:[(0,Y.jsx)(`span`,{className:`h-2 w-2 animate-pulse rounded-full bg-primary`}),t(`activity:office.coordinatingFleet`)]})]})}function rn({data:e}){let{t}=F(),n=e.status===`active`||e.status===`streaming`,r=e.status===`error`,i=e.status===`completed`,a=e.color||Z.primary,o=Zt(e.ctxPct);return(0,Y.jsxs)(`div`,{className:I(`w-[170px] min-w-0 max-w-[170px] overflow-hidden rounded-lg border p-3 transition-all backdrop-blur-sm`,n&&`border-primary/50 bg-primary/10 shadow-lg shadow-primary/10`,r&&`border-destructive/50 bg-destructive/10`,i&&`border-border/70 bg-muted/35`,!n&&!r&&!i&&`border-primary/30 bg-primary/10`),children:[(0,Y.jsx)($,{}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[(0,Y.jsx)(f,{className:`h-4 w-4 shrink-0`,style:{color:a}}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-[11px] font-bold truncate`,style:{color:a},children:e.label}),e.model&&(0,Y.jsx)(`div`,{className:`truncate text-[10px] text-muted-foreground`,children:rt(e.model)})]}),(0,Y.jsx)(Q,{status:e.status,small:!0,activity:e.vizActivity??0})]}),e.currentTask&&(0,Y.jsxs)(`div`,{className:`mb-1.5 flex min-w-0 items-center gap-1 overflow-hidden text-[11px] text-primary`,children:[(0,Y.jsx)(`span`,{className:I(`h-1.5 w-1.5 shrink-0 rounded-full bg-primary`,n&&`animate-pulse`)}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate font-mono`,title:e.currentTask,children:it(e.currentTask,72)})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-2 gap-y-0.5 text-[11px] mb-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex justify-between`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`iter`}),(0,Y.jsx)(`span`,{className:`font-mono text-foreground`,children:e.iteration||0})]}),(0,Y.jsxs)(`div`,{className:`flex justify-between`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`tools`}),(0,Y.jsx)(`span`,{className:`font-mono text-warning`,children:e.toolCalls||0})]}),(0,Y.jsxs)(`div`,{className:`flex justify-between`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`tok`}),(0,Y.jsx)(`span`,{className:`font-mono text-foreground`,children:et((e.tokensIn||0)+(e.tokensOut||0))})]}),(0,Y.jsxs)(`div`,{className:`flex justify-between`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`cost`}),(0,Y.jsxs)(`span`,{className:`font-mono text-success`,children:[`$`,(e.costUsd||0).toFixed(3)]})]})]}),o>0&&(0,Y.jsxs)(`div`,{className:`mb-1`,children:[(0,Y.jsxs)(`div`,{className:`mb-0.5 flex justify-between text-[10px] text-muted-foreground`,children:[(0,Y.jsx)(`span`,{children:`ctx`}),(0,Y.jsxs)(`span`,{className:I(`font-mono`,o>=90?`text-destructive`:o>=70?`text-warning`:`text-muted-foreground`),children:[o,`%`]})]}),(0,Y.jsx)(`div`,{className:`h-1 overflow-hidden rounded-full bg-muted`,children:(0,Y.jsx)(`div`,{className:I(`h-full`,o>=90?`bg-destructive`:o>=70?`bg-warning`:`bg-primary`),style:{width:`${o}%`}})})]}),e.lastActivityAt&&(0,Y.jsxs)(`div`,{className:I(`flex items-center gap-1 text-[10px]`,n?`text-muted-foreground/70`:`text-muted-foreground`),children:[i&&(0,Y.jsx)(`span`,{className:`text-success`,children:t(`activity:office.donePrefix`)}),r&&(0,Y.jsx)(`span`,{className:`text-destructive`,children:t(`activity:office.failedPrefix`)}),(0,Y.jsx)(`span`,{children:t(`activity:office.seenPrefix`,{time:tt(e.lastActivityAt,Date.now())})})]})]})}function an({data:e}){let{t}=F();return(0,Y.jsxs)(`div`,{className:I(`rounded-lg border border-dashed p-3 min-w-[120px] transition-all opacity-40`,`border-border/70 bg-muted/30`),children:[(0,Y.jsx)($,{}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,Y.jsx)(y,{className:`h-4 w-4 text-muted-foreground`}),(0,Y.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,Y.jsx)(`div`,{className:`truncate text-[10px] text-muted-foreground`,children:e.label})}),(0,Y.jsx)(Q,{status:e.status,small:!0,activity:e.vizActivity??0})]}),(0,Y.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:t(`activity:office.availableDesk`)})]})}function on({data:e}){let{t}=F(),n=e.color||Z.warning,r=(e.unreadCount||0)>0;return(0,Y.jsxs)(`div`,{className:I(`rounded-xl border-2 p-4 min-w-[160px] transition-all backdrop-blur-sm`,r&&`border-warning/50 bg-warning/10 shadow-lg shadow-warning/10`,!r&&`border-warning/30 bg-warning/6`),children:[(0,Y.jsx)($,{}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,Y.jsx)(`div`,{className:I(`flex items-center justify-center w-10 h-10 rounded-lg`,r?`bg-warning/18`:`bg-warning/10`),children:(0,Y.jsx)(i,{className:`h-5 w-5`,style:{color:n}})}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold`,style:{color:n},children:t(`activity:office.mailboxHub`)}),(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:r?t(`activity:office.unreadSuffix`,{count:e.unreadCount||0}):t(`activity:office.allClear`)})]}),r&&(0,Y.jsx)(`div`,{className:`flex h-5 w-5 items-center justify-center rounded-full bg-warning text-[10px] font-bold text-background`,children:e.unreadCount})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-[10px]`,children:[(0,Y.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-warning`,children:[(0,Y.jsx)(s,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{children:e.messageCount||0})]}),(0,Y.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:office.total`)})]}),(0,Y.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-success`,children:[(0,Y.jsx)(j,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{children:e.unreadCount||0})]}),(0,Y.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:office.unreadLabel`)})]})]}),e.sublabel&&(0,Y.jsxs)(`div`,{className:`mt-2 truncate border-t border-border/60 pt-1.5 text-[11px] text-muted-foreground`,children:[`✉ `,e.sublabel]})]})}var sn={webui:$t,tui:en,repl:tn,coordinator:nn,agent:rn,mailbox:on,desk:an},cn={wire:({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:i,targetPosition:a,data:o,selected:s})=>{let c=o?.color||Z.primary,l=L(e=>e.animateEdges),u=o?.animated&&l?Math.max(.15,o?.intensity??.6):0,[d,f,p]=Se({sourceX:e,sourceY:t,sourcePosition:i??x.Bottom,targetX:n,targetY:r,targetPosition:a??x.Top,curvature:.28}),m=5+u*7,h=5+u*4,g=m+h,_=`${Math.max(.5,1.6-u).toFixed(2)}s`;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`path`,{d,fill:`none`,stroke:c,strokeWidth:s?2.5:1.4,strokeOpacity:s?.9:.28,className:`react-flow__edge-path`}),u>.05&&(0,Y.jsx)(`path`,{d,fill:`none`,stroke:c,strokeWidth:2.2,strokeOpacity:.45+u*.5,strokeDasharray:`${m} ${h}`,strokeLinecap:`round`,style:{filter:`drop-shadow(0 0 ${2+u*4}px ${c})`},children:(0,Y.jsx)(`animate`,{attributeName:`stroke-dashoffset`,from:g,to:`0`,dur:_,repeatCount:`indefinite`})}),o?.label&&u>.1&&(0,Y.jsx)(fe,{children:(0,Y.jsx)(`div`,{style:{position:`absolute`,transform:`translate(-50%, -50%) translate(${f}px, ${p}px)`},className:`pointer-events-none max-w-[220px] truncate whitespace-nowrap rounded-full border border-border/70 bg-card/90 px-1.5 py-0.5 text-[8px] font-medium text-foreground backdrop-blur-sm`,children:o.label})})]})}};function ln(){let{t:e}=F(),{clientCounts:t,currentSession:r,totalAgents:i,activeAgents:a,aggregate:o}=ke(se(e=>({clientCounts:e.clientCounts,currentSession:e.currentSession,totalAgents:e.totalAgents,activeAgents:e.activeAgents,aggregate:e.aggregate}))),s=t.tui+t.webui+t.repl,c=e=>e?.toLocaleString()??`0`;return(0,Y.jsxs)(`div`,{className:`absolute left-4 top-20 z-10 rounded-xl border border-border/70 bg-card/90 p-3 text-foreground shadow-xl backdrop-blur`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,Y.jsx)(m,{className:`h-3.5 w-3.5 text-success`}),(0,Y.jsx)(`span`,{className:`text-[10px] font-bold uppercase text-muted-foreground`,children:e(`activity:office.sessionStats`)})]}),(0,Y.jsxs)(`div`,{className:`space-y-1.5 text-[10px]`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(he,{className:`h-3 w-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.clients`)})]}),(0,Y.jsxs)(`span`,{className:`font-mono text-foreground`,children:[a,` `,(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`/`}),` `,(0,Y.jsx)(`span`,{className:`text-success`,children:s})]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 pl-4 text-[9px]`,children:[t.tui>0&&(0,Y.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(v,{className:`h-2.5 w-2.5 text-success`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`TUI`}),(0,Y.jsx)(`span`,{className:`font-mono text-success`,children:t.tui})]}),t.webui>0&&(0,Y.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(n,{className:`h-2.5 w-2.5 text-primary`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`WebUI`}),(0,Y.jsx)(`span`,{className:`font-mono text-primary`,children:t.webui})]}),t.repl>0&&(0,Y.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(v,{className:`h-2.5 w-2.5 text-warning`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`REPL`}),(0,Y.jsx)(`span`,{className:`font-mono text-warning`,children:t.repl})]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(f,{className:`h-3 w-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:officeMap.agents`)})]}),(0,Y.jsxs)(`span`,{className:`font-mono text-foreground`,children:[a,` `,(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`/`}),` `,(0,Y.jsx)(`span`,{className:`text-primary`,children:i})]})]}),r.model&&(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(h,{className:`h-3 w-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:officeMap.model`)})]}),(0,Y.jsx)(`span`,{className:`max-w-[120px] truncate font-mono text-primary`,title:r.model,children:r.model.split(`/`).pop()?.slice(0,16)})]}),r.mode&&(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(T,{className:`h-3 w-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:officeMap.mode`)})]}),(0,Y.jsx)(`span`,{className:I(`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,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(ye,{className:`h-3 w-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.toolCallsLabel`)})]}),(0,Y.jsx)(`span`,{className:`font-mono text-warning`,children:c(o.toolCalls)})]}),(0,Y.jsxs)(`div`,{className:`mt-1.5 space-y-1 border-t border-border/70 pt-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(`span`,{className:`text-[8px] text-muted-foreground`,children:`IN`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.input`)})]}),(0,Y.jsx)(`span`,{className:`font-mono text-[9px] text-foreground`,children:c(o.tokensIn)})]}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(`span`,{className:`text-[8px] text-muted-foreground`,children:`OUT`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.output`)})]}),(0,Y.jsx)(`span`,{className:`font-mono text-[9px] text-foreground`,children:c(o.tokensOut)})]})]}),(0,Y.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-between gap-4 border-t border-border/70 pt-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(b,{className:`h-3 w-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.cost`)})]}),(0,Y.jsx)(`span`,{className:`font-mono font-medium text-success`,children:(e=>e==null?`$0.0000`:`$${e.toFixed(4)}`)(o.costUsd)})]})]})]})}function un({events:e,now:t}){let{t:n}=F(),r=e.slice(0,14);return(0,Y.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 z-10 pointer-events-none px-3 pb-3`,children:(0,Y.jsxs)(`div`,{className:`pointer-events-auto mx-auto max-w-3xl rounded-lg border border-border/70 bg-card/90 px-3 py-2 shadow-xl backdrop-blur`,children:[(0,Y.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-1.5 text-[10px] uppercase text-primary`,children:[(0,Y.jsx)(m,{className:`h-3 w-3`}),n(`activity:office.liveActivity`)]}),r.length===0?(0,Y.jsx)(`div`,{className:`text-[11px] italic text-muted-foreground`,children:n(`activity:office.waitingActivity`)}):(0,Y.jsx)(`div`,{className:`flex flex-col gap-0.5 max-h-32 overflow-hidden`,children:r.map(e=>{let r=Math.max(0,Math.round((t-e.timestamp)/1e3));return(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] leading-tight`,children:[(0,Y.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0`,style:{backgroundColor:pt(e.kind)}}),(0,Y.jsx)(`span`,{className:`flex-1 truncate text-foreground`,children:e.label}),(0,Y.jsx)(`span`,{className:`shrink-0 tabular-nums text-muted-foreground`,children:r<1?n(`activity:office.now`):`${r}s`})]},e.id)})})]})})}function dn(){let{t:e}=F(),{fitView:t}=D(),r=(0,H.useRef)(null),[a,c]=(0,H.useState)({width:1280,height:720});(0,H.useEffect)(()=>{let e=r.current;if(!e)return;let t=()=>{let{width:t,height:n}=e.getBoundingClientRect();t<1||n<1||c(e=>Math.abs(e.width-t)<2&&Math.abs(e.height-n)<2?e:{width:t,height:n})};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let l=Te(e=>e.events),u=De(e=>e.agents),m=De(e=>e.agentTranscripts),g=De(e=>e.leaderId),_=ke(e=>e.liveSessions),y=Ae(e=>e.messages),b=Ae(e=>e.agents),x=Ee(e=>e.session),S=(0,H.useMemo)(()=>ft(_,u,b),[_,u,b]),w=L(e=>e.showHud),T=L(e=>e.showLegend),ne=L(e=>e.showMinimap),E=L(e=>e.showControls),ae=L(e=>e.showFeed),O=L(e=>e.setShowFeed),k=L(e=>e.background),[se,A,le]=ue([]),[de,j,fe]=me([]),[M,pe]=(0,H.useState)(null),[N,he]=(0,H.useState)(null),[ge,_e]=(0,H.useState)(!1),[P,ye]=(0,H.useState)(``),[be,xe]=(0,H.useState)(!1),[Se,Ce]=(0,H.useState)(null),we=(0,H.useMemo)(()=>{if(M?.data.kind!==`agent`)return Oe;let e=M.data.serverId??(M.id.includes(`__agent-`)?M.id.split(`__agent-`).pop():M.id.replace(/^agent-/,``));return e?m.get(e)??Oe:Oe},[m,M]),je=(0,H.useCallback)(async()=>{let e=P.trim();if(!(!e||be)){xe(!0),Ce(null);try{let t=await fetch(`/api/fleet/broadcast`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:e})});if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();ye(``),Ce(`Delivered to ${n.delivered??0}/${n.targets??0} session(s)`)}catch(e){Ce(`Failed: ${e instanceof Error?e.message:String(e)}`)}finally{xe(!1)}}},[P,be]),R=(0,H.useRef)(new Map),z=4e3,B=(0,H.useRef)(new Map),V=(0,H.useRef)(new Map),Me=(0,H.useRef)(new Map),Pe=(0,H.useRef)(new Map),Fe=(0,H.useRef)(``);(0,H.useEffect)(()=>{let n=[],r=[],i=Date.now(),o=at(S.map(e=>({id:e.id,agentCount:e.agents.length})),a),s=y.filter(e=>!e.completed&&(e.readByCount??0)===0).length,c=y.length?[...y].sort((e,t)=>Date.parse(t.timestamp)-Date.parse(e.timestamp))[0]:void 0;n.push({id:`mailbox`,type:`mailbox`,position:{x:830,y:50},data:{label:e(`activity:office.mailboxHub`),kind:`mailbox`,status:s>0?`active`:`idle`,unreadCount:s,messageCount:y.length,sublabel:c?`${c.from} → ${c.to}: ${c.subject}`:void 0,color:Z.warning}});let l=0,d=0,f=0,p=0,m=0;for(let e of S)for(let t of e.agents)d+=1,(t.status===`active`||t.status===`streaming`)&&(l+=1),f+=t.toolCalls,p+=t.costUsd,m+=t.tokensIn+t.tokensOut;let h=g?u.get(g):null,_=l>0;n.push({id:`coordinator`,type:`coordinator`,position:{x:370,y:50},data:{label:e(`activity:office.fleetHqLabel`),sublabel:e(`activity:office.clientsSuffix`,{count:S.length}),kind:`coordinator`,status:h?.status===`failed`?`error`:_?`active`:`idle`,connections:S.length,agentsActive:l,agentsTotal:d,toolCalls:f,costUsd:p,tokensIn:m,color:Z.primary}});let v={tui:Z.success,webui:Z.info,repl:Z.warning};for(let t of S){let a=o.positions.get(t.id)??{x:600,y:370},c=a.x,l=a.y,u=v[t.type],d=t.status===`active`;if(n.push({id:t.id,type:t.type,position:{x:c,y:l},data:{label:t.label,sublabel:t.sublabel,kind:t.type,status:t.status,sessionId:t.sessionId,pid:t.pid,branch:t.branch,workingDir:t.workingDir,startedAt:t.startedAt,agentCount:t.agents.length,color:u}}),r.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`}}),r.push({id:`mailbox->${t.id}`,source:`mailbox`,target:t.id,type:`wire`,animated:s>0,data:{color:Z.warning,animated:s>0,label:s>0?`${s}`:void 0,flowType:`mail`}}),t.agents.length===0){n.push({id:`desk-${t.id}`,type:`desk`,position:{x:c,y:l+270},data:{label:e(`activity:office.idleDesk`),kind:`agent`,status:`idle`,color:Z.muted}});continue}t.agents.forEach((a,o)=>{let s=a.status===`active`||a.status===`streaming`,u=Pe.current.get(a.serverId);if(u&&(a.toolCalls>u.toolCalls||a.iteration>u.iteration)||s){R.current.set(a.officeId,i+z);let e=V.current.get(a.officeId)??0;V.current.set(a.officeId,Math.min(1,e+(1-e)*.5));for(let e of[`${t.id}->${a.officeId}`,`${t.id}->coordinator`]){let t=B.current.get(e)??0;B.current.set(e,Math.min(1,t+.5))}}Pe.current.set(a.serverId,{toolCalls:a.toolCalls,iteration:a.iteration}),n.push({id:a.officeId,type:`agent`,position:ot(c,o,t.agents.length,l+270),data:{label:a.name,kind:`agent`,status:a.status,serverId:a.serverId,sessionId:t.sessionId,currentTask:a.currentTask,iteration:a.iteration,toolCalls:a.toolCalls,costUsd:a.costUsd,tokensIn:a.tokensIn,tokensOut:a.tokensOut,ctxPct:a.ctxPct,model:a.model,lastActivityAt:a.lastActivityAt,color:Z.primary}}),r.push({id:`${t.id}->${a.officeId}`,source:t.id,target:a.officeId,type:`wire`,animated:s,data:{color:Z.primary,animated:s,label:s?it(a.currentTask,48)??e(`activity:office.taskFallback`):void 0,flowType:`task`}})})}let ee=new Set(S.flatMap(e=>e.agents.map(e=>e.serverId)));for(let e of[...Pe.current.keys()])ee.has(e)||Pe.current.delete(e);let b=n.map(e=>{let t=R.current.get(e.id),n=V.current.get(e.id)??0;return t&&t>i&&e.data.status!==`error`&&e.data.status!==`offline`?{...e,data:{...e.data,status:`active`,vizActivity:n}}:{...e,data:{...e.data,vizActivity:n}}}),x=r.map(e=>{let t=B.current.get(e.id)??0;return t>.05?{...e,animated:!0,data:{...e.data,animated:!0,intensity:t}}:e}),C=new Map;for(let e of b)C.set(e.id,{...e.position});Me.current=C,A(b),j(x);let w=[`${Math.round(a.width)}x${Math.round(a.height)}`,`${o.columns}x${o.rows}`,S.map(e=>`${e.id}:${e.agents.length}`).join(`|`),b.map(e=>e.id).sort().join(`|`)].join(`:`);if(w!==Fe.current){Fe.current=w;let e=setTimeout(()=>t({padding:Xt,duration:300}),50);return()=>clearTimeout(e)}},[S,g,u,y,x,a,z,A,j,t]);let U=S.flatMap(e=>e.agents.map(t=>({clientId:e.id,clientType:e.type,officeId:t.officeId,serverId:t.serverId}))),W=S.map(e=>e.id),G=new Map;for(let e of U)(!G.has(e.serverId)||e.clientType===`webui`)&&G.set(e.serverId,e.officeId);function K(e){return G.get(e)??`agent-${e}`}function q(e){let t=e.split(`__agent-`)[0];return t&&t!==e?`${t}->${e}`:`coordinator->${e}`}function Ie(e){switch(e.kind){case`mailbox:send`:case`mailbox:deliver`:return{nodes:[`mailbox`],edges:e.kind===`mailbox:send`?W.map(e=>`mailbox->${e}`):[],status:`active`};case`agent:spawned`:{let t=K(e.source);return{nodes:[`coordinator`,t],edges:[q(t)],status:`active`}}case`agent:tool`:case`tool:started`:case`tool:progress`:{let t=K(e.source);return{nodes:[`coordinator`,t],edges:[q(t)],status:e.kind===`tool:progress`||e.kind===`tool:started`?`streaming`:`active`}}case`tool:executed`:{let t=K(e.target??e.source);return{nodes:[t],edges:[q(t)],status:`active`}}case`provider:call`:case`provider:delta`:case`provider:response`:return{nodes:[`coordinator`],edges:[],status:e.kind===`provider:delta`?`streaming`:`active`};case`iteration:start`:case`iteration:end`:return{nodes:[`coordinator`],edges:U.map(e=>q(e.officeId)),status:e.kind===`iteration:start`?`streaming`:`active`};case`agent:text`:{let t=K(e.source);return{nodes:[t],edges:[q(t)],status:`streaming`}}case`agent:status`:{let t=K(e.source);return{nodes:[`coordinator`,t],edges:[q(t)],status:e.data&&typeof e.data==`object`&&`status`in e.data&&String(e.data.status)===`failed`?`error`:`completed`}}case`agent:ctx`:return{nodes:[K(e.source)],edges:[],status:`active`};case`budget:extended`:return{nodes:[`coordinator`,K(e.source)],edges:[],status:`active`};case`context:compacted`:case`context:repaired`:return{nodes:[`coordinator`],edges:[],status:`active`};case`error`:return{nodes:e.source?[K(e.source)]:[],edges:[],status:`error`};case`cost:update`:return{nodes:[`coordinator`],edges:[],status:`active`};case`fleet:snapshot`:{let t=e.data?.sessions??[],n=[`coordinator`];for(let e of t)if(e.agents)for(let t of e.agents){let e=K(t.id);n.includes(e)||n.push(e)}return{nodes:n,edges:[],status:`active`}}default:return{nodes:[],edges:[],status:`idle`}}}(0,H.useEffect)(()=>{if(l.length===0)return;let e=l[0];if(!e)return;let{nodes:t,edges:n,status:r}=Ie(e),i=Date.now();t.length>0&&(t.forEach(e=>{R.current.set(e,i+z);let t=V.current.get(e)??0;V.current.set(e,Math.min(1,t+(1-t)*.5))}),A(e=>e.map(e=>t.includes(e.id)?{...e,data:{...e.data,status:r,vizActivity:V.current.get(e.id)??0}}:e))),n.length>0&&(n.forEach(e=>{let t=B.current.get(e)??0;B.current.set(e,Math.min(1,t+.5))}),j(e=>e.map(e=>n.includes(e.id)?{...e,animated:!0,data:{...e.data,animated:!0,intensity:B.current.get(e.id)??1}}:e)))},[l,A,j,z,u]),(0,H.useEffect)(()=>{let e=setInterval(()=>{let e=new Map,t=!1;for(let[n,r]of B.current){let i=r*.85;i<.05?(B.current.delete(n),e.set(n,{intensity:0,animated:!1}),t=!0):(B.current.set(n,i),e.set(n,{intensity:i,animated:!0}),t=!0)}t&&j(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 V.current){let i=t*.9;i<.03?(V.current.delete(e),n.set(e,0),r=!0):(V.current.set(e,i),n.set(e,i),r=!0)}r&&A(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)},[j,A]);let Le=(0,H.useCallback)(e=>j(t=>re({...e,type:`wire`},t)),[j]),Re=(0,H.useCallback)((e,t)=>{pe(t)},[]),ze=(0,H.useCallback)(()=>{pe(null)},[]);(0,H.useEffect)(()=>{if(!N)return;let e=e=>{e.key===`Escape`&&he(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[N]);let Be=(0,H.useCallback)(()=>{A(e=>e.map(e=>{let t=Me.current.get(e.id);return t?{...e,position:{...t}}:e})),setTimeout(()=>t({padding:Xt,duration:300}),50)},[A,t]),[,Ve]=(0,H.useState)(0);return(0,H.useEffect)(()=>{let e=setInterval(()=>{document.hidden||Ve(e=>e+1)},2e3);return()=>clearInterval(e)},[]),(0,Y.jsxs)(`div`,{ref:r,className:`relative h-full w-full overflow-hidden bg-[hsl(var(--surface-2)/0.55)]`,children:[(0,Y.jsx)(`div`,{className:`absolute inset-0 opacity-[0.03]`,style:{backgroundImage:`
2
+ linear-gradient(rgba(255,255,255,0.1) 1px, transparent 1px),
3
+ linear-gradient(90deg, rgba(255,255,255,0.1) 1px, transparent 1px)
4
+ `,backgroundSize:`40px 40px`}}),w&&(0,Y.jsx)(ln,{}),(0,Y.jsx)(`div`,{className:`absolute top-3 left-1/2 -translate-x-1/2 z-10`,children:(0,Y.jsx)(`div`,{className:`rounded-lg border border-border/70 bg-card/90 px-4 py-2 shadow-xl backdrop-blur`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-bold text-foreground`,children:[(0,Y.jsx)(d,{className:`h-4 w-4 text-primary`}),e(`activity:office.fleetHq`),(0,Y.jsx)(`span`,{className:`ml-2 h-2 w-2 animate-pulse rounded-full bg-success`}),(0,Y.jsx)(`span`,{className:`text-[10px] font-normal text-muted-foreground`,children:e(`activity:office.live`)})]})})}),T&&(0,Y.jsxs)(`div`,{className:`absolute bottom-4 left-4 z-10 rounded-lg border border-border/70 bg-card/90 p-3 text-[10px] shadow-xl backdrop-blur`,children:[(0,Y.jsx)(`div`,{className:`mb-2 font-bold text-foreground`,children:e(`activity:office.legendStatus`)}),(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`h-2 w-2 animate-pulse rounded-full bg-success`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.legendActive`)})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`h-2 w-2 rounded-full bg-muted-foreground`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.legendIdle`)})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`h-2 w-2 animate-pulse rounded-full bg-destructive`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.legendError`)})]})]})]}),T&&(0,Y.jsxs)(`div`,{className:`absolute bottom-4 right-4 z-10 rounded-lg border border-border/70 bg-card/90 p-3 text-[10px] shadow-xl backdrop-blur`,children:[(0,Y.jsx)(`div`,{className:`mb-2 font-bold text-foreground`,children:e(`activity:office.legendConnections`)}),(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-warning`,children:`✉`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.legendMail`)})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-primary`,children:`→`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.legendTask`)})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-success`,children:`●`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.legendStatusConn`)})]})]})]}),(0,Y.jsxs)(ie,{nodes:se,edges:de,onNodesChange:le,onEdgesChange:fe,onConnect:Le,onNodeClick:Re,onPaneClick:ze,nodeTypes:sn,edgeTypes:cn,fitView:!0,fitViewOptions:{padding:Xt},minZoom:.15,maxZoom:1.5,defaultEdgeOptions:{type:`wire`},proOptions:{hideAttribution:!0},children:[(0,Y.jsxs)(ce,{position:`top-right`,className:`flex items-center gap-2`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:Be,title:e(`activity:office.arrangeTitle`),className:`flex items-center gap-1.5 rounded-md border border-border/70 bg-card/90 px-2.5 py-1.5 text-xs text-foreground shadow-sm transition-colors hover:bg-accent`,children:[(0,Y.jsx)(ee,{className:`h-3.5 w-3.5`}),e(`activity:office.arrange`)]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>O(!ae),title:e(`activity:office.feedTitle`),className:I(`flex items-center gap-1.5 px-2.5 py-1.5 rounded-md border text-xs transition-colors`,ae?`border-primary/35 bg-primary/10 text-primary`:`border-border/70 bg-card/90 text-muted-foreground hover:bg-accent hover:text-foreground`),children:[(0,Y.jsx)(o,{className:`h-3.5 w-3.5`}),e(`activity:office.feed`)]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>_e(e=>!e),title:e(`activity:office.broadcastTitle`),className:I(`flex items-center gap-1.5 px-2.5 py-1.5 rounded-md border text-xs transition-colors`,ge?`border-warning/35 bg-warning/10 text-warning`:`border-border/70 bg-card/90 text-muted-foreground hover:bg-accent hover:text-foreground`),children:[(0,Y.jsx)(s,{className:`h-3.5 w-3.5`}),e(`activity:office.broadcast`)]})]}),k!==`none`&&(0,Y.jsx)(ve,{variant:k===`lines`?oe.Lines:k===`cross`?oe.Cross:oe.Dots,gap:20,size:1,color:`hsl(var(--border) / 0.35)`}),E&&(0,Y.jsx)(C,{className:`rounded-lg border border-border/70 bg-card/90 [&>button]:bg-card [&>button]:text-foreground`}),ne&&(0,Y.jsx)(te,{className:`rounded-lg border border-border/70 bg-card/90`,nodeColor:e=>{switch(e.data.kind){case`coordinator`:return Z.primary;case`webui`:return Z.info;case`tui`:return Z.success;case`repl`:return Z.warning;case`mailbox`:return Z.warning;case`agent`:return Z.primary;default:return Z.primary}},maskColor:`hsl(var(--background) / 0.72)`})]}),ae&&(0,Y.jsx)(un,{events:l,now:Date.now()}),ge&&(0,Y.jsxs)(`div`,{className:`absolute right-4 top-16 z-30 w-80 rounded-xl border border-warning/35 bg-card/95 p-3 shadow-2xl backdrop-blur`,children:[(0,Y.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] font-semibold text-warning`,children:[(0,Y.jsx)(s,{className:`h-3.5 w-3.5`}),` `,e(`activity:office.broadcastToAll`)]}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>_e(!1),className:`text-base leading-none text-muted-foreground hover:text-foreground`,children:`×`})]}),(0,Y.jsx)(`textarea`,{value:P,onChange:e=>ye(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),je())},rows:3,placeholder:e(`activity:office.broadcastPlaceholder`),className:`w-full resize-none rounded-md border border-border/70 bg-background/70 px-2 py-1 text-[11px] text-foreground placeholder:text-muted-foreground focus:border-warning/45 focus:outline-none`}),(0,Y.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-between`,children:[(0,Y.jsx)(`span`,{className:`text-[9px] text-muted-foreground`,children:e(`activity:office.broadcastSendHint`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>void je(),disabled:be||!P.trim(),className:`rounded-md border border-warning/35 bg-warning/12 px-2.5 py-1 text-[11px] text-warning transition-colors hover:bg-warning/18 disabled:cursor-not-allowed disabled:opacity-40`,children:be?`…`:e(`activity:office.broadcast`)})]}),Se&&(0,Y.jsx)(`div`,{className:`mt-1 text-[10px] text-muted-foreground`,children:Se})]}),M&&(0,Y.jsxs)(`div`,{className:I(`absolute top-20 right-4 bg-background border border-border rounded-lg p-4 shadow-xl z-20`,M.data.kind===`agent`?`w-[28rem] max-w-[calc(100%-2rem)]`:M.data.sessionId?`w-80`:`w-64`),children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[M.data.kind===`webui`&&(0,Y.jsx)(n,{className:`h-4 w-4 text-info`}),M.data.kind===`tui`&&(0,Y.jsx)(v,{className:`h-4 w-4 text-success`}),M.data.kind===`coordinator`&&(0,Y.jsx)(h,{className:`h-4 w-4 text-primary`}),M.data.kind===`agent`&&(0,Y.jsx)(f,{className:`h-4 w-4 text-primary`}),M.data.kind===`mailbox`&&(0,Y.jsx)(i,{className:`h-4 w-4 text-warning`}),(0,Y.jsx)(`span`,{className:`text-sm font-bold text-foreground`,children:M.data.label})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[M.data.sessionId&&(0,Y.jsx)(`button`,{type:`button`,title:e(`activity:office.openFullView`),onClick:()=>he({sessionId:M.data.sessionId,label:M.data.label}),className:`text-muted-foreground hover:text-primary`,children:(0,Y.jsx)(p,{className:`h-3.5 w-3.5`})}),(0,Y.jsx)(`button`,{type:`button`,onClick:ze,className:`text-muted-foreground hover:text-foreground text-lg leading-none`,children:`×`})]})]}),(()=>{let t=M.data,n=Date.now(),r=({k:e,v:t,accent:n})=>(0,Y.jsxs)(`div`,{className:`flex justify-between gap-3`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:e}),(0,Y.jsx)(`span`,{className:I(`font-mono truncate text-right`,n??`text-foreground/80`),children:t})]}),i=t.kind===`agent`,a=t.kind===`webui`||t.kind===`tui`||t.kind===`repl`,o=(t.tokensIn||0)+(t.tokensOut||0),s=Zt(t.ctxPct);return(0,Y.jsxs)(`div`,{className:`space-y-1.5 text-xs`,children:[(0,Y.jsx)(r,{k:`Status`,v:String(t.status).toUpperCase(),accent:I(t.status===`active`&&`text-success`,t.status===`streaming`&&`text-primary`,t.status===`error`&&`text-destructive`,t.status===`idle`&&`text-muted-foreground`,t.status===`offline`&&`text-muted-foreground/70`)}),i&&(0,Y.jsxs)(Y.Fragment,{children:[t.model&&(0,Y.jsx)(r,{k:`Model`,v:rt(t.model),accent:`text-primary`}),t.currentTask&&(0,Y.jsxs)(`div`,{className:`pt-1`,children:[(0,Y.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:e(`activity:agentOffice.currentTask`)}),(0,Y.jsx)(`div`,{className:`mt-1 max-h-32 overflow-y-auto whitespace-pre-wrap break-words font-mono text-[10px] text-primary`,children:t.currentTask})]}),(0,Y.jsx)(r,{k:`Iterations`,v:t.iteration||0,accent:`text-primary`}),(0,Y.jsx)(r,{k:`Tool calls`,v:t.toolCalls||0,accent:`text-warning`}),(0,Y.jsx)(r,{k:`Tokens in`,v:et(t.tokensIn)}),(0,Y.jsx)(r,{k:`Tokens out`,v:et(t.tokensOut)}),(0,Y.jsx)(r,{k:`Tokens total`,v:et(o)}),s>0&&(0,Y.jsx)(r,{k:`Context`,v:`${s}%`,accent:s>=90?`text-destructive`:s>=70?`text-warning`:`text-foreground/70`}),(0,Y.jsx)(r,{k:`Cost`,v:`$${(t.costUsd||0).toFixed(4)}`,accent:`text-success`}),t.lastActivityAt&&(0,Y.jsx)(r,{k:`Last seen`,v:tt(t.lastActivityAt,n),accent:`text-muted-foreground`}),(0,Y.jsx)(`div`,{className:`pt-2`,children:(0,Y.jsx)(Ne,{entries:we,agentName:t.label,compact:!0,maxHeightClassName:`max-h-64`})})]}),a&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(r,{k:`Surface`,v:ct(t.kind),accent:`text-foreground/80`}),t.branch&&(0,Y.jsx)(r,{k:`Branch`,v:`⎇ ${t.branch}`,accent:`text-foreground/70`}),t.pid!=null&&(0,Y.jsx)(r,{k:`PID`,v:t.pid}),t.workingDir&&(0,Y.jsx)(r,{k:`Dir`,v:t.workingDir,accent:`text-muted-foreground`}),(0,Y.jsx)(r,{k:`Agents`,v:t.agentCount??0,accent:`text-primary`}),t.startedAt&&(0,Y.jsx)(r,{k:`Uptime`,v:nt(t.startedAt,n),accent:`text-foreground/70`})]}),t.kind===`mailbox`&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(r,{k:`Total messages`,v:t.messageCount||0,accent:`text-warning`}),(0,Y.jsx)(r,{k:`Unread`,v:t.unreadCount||0,accent:`text-warning`}),y.length>0&&(0,Y.jsxs)(`div`,{className:`mt-1 space-y-1 border-t border-border pt-2`,children:[(0,Y.jsx)(`div`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:e(`activity:office.recent`)}),[...y].sort((e,t)=>Date.parse(t.timestamp)-Date.parse(e.timestamp)).slice(0,6).map(t=>(0,Y.jsxs)(`div`,{className:`flex items-start gap-1.5 text-[10px]`,children:[(0,Y.jsx)(`span`,{className:I(`mt-1 h-1.5 w-1.5 shrink-0 rounded-full`,!t.completed&&(t.readByCount??0)===0?`bg-warning`:t.completed?`bg-success`:`bg-muted`)}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`div`,{className:`truncate text-foreground/80`,children:t.subject||e(`activity:office.noSubject`)}),(0,Y.jsxs)(`div`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:[t.from,` → `,t.to,` · `,tt(t.timestamp,n)]})]})]},t.id))]})]}),t.kind===`coordinator`&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(r,{k:`Connections`,v:t.connections||0,accent:`text-primary`}),(0,Y.jsx)(r,{k:`Iterations`,v:t.iteration||0,accent:`text-primary`})]}),(i||a)&&t.sessionId&&(0,Y.jsx)(`div`,{className:`mt-2 border-t border-border pt-2 h-72`,children:(0,Y.jsx)(Yt,{sessionId:t.sessionId})})]})})()]}),N&&(0,Y.jsxs)(`div`,{className:`absolute inset-y-0 right-0 z-30 flex w-[min(680px,92%)] flex-col border-l border-border bg-background shadow-2xl`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border px-4 py-2.5 shrink-0 bg-card`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,Y.jsx)(f,{className:`h-4 w-4 text-primary shrink-0`}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`div`,{className:`truncate text-sm font-bold text-foreground`,children:N.label}),(0,Y.jsx)(`div`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:e(`activity:office.fullOperationStream`)})]})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>he(null),title:e(`activity:office.closeEsc`),className:`text-muted-foreground hover:text-foreground text-xl leading-none shrink-0`,children:`×`})]}),(0,Y.jsx)(`div`,{className:`flex-1 min-h-0 p-4`,children:(0,Y.jsx)(Yt,{sessionId:N.sessionId,limit:500})})]})]})}function fn(){let{t:e}=F(),n=L(e=>e.viewMode),r=L(e=>e.setViewMode),i=[{id:`office`,label:e(`activity:agentOffice.office`),description:e(`activity:agentOffice.officeDescription`),icon:ae},{id:`topology`,label:e(`activity:agentOffice.topology`),description:e(`activity:agentOffice.topologyDescription`),icon:t}],a=(e,t)=>{let n;if(e.key===`ArrowLeft`&&(n=(t-1+i.length)%i.length),e.key===`ArrowRight`&&(n=(t+1)%i.length),e.key===`Home`&&(n=0),e.key===`End`&&(n=i.length-1),n===void 0)return;e.preventDefault();let a=i[n];a&&(r(a.id),e.currentTarget.parentElement?.querySelectorAll(`[role="tab"]`)[n]?.focus())};return(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 w-full flex-col bg-background`,children:[(0,Y.jsx)(`nav`,{"aria-label":`${e(`activity:agentOffice.office`)} / ${e(`activity:agentOffice.topology`)}`,className:`relative z-[60] shrink-0 border-b border-border bg-card/95 px-3 pt-2 shadow-[0_8px_28px_hsl(var(--shadow-color)/0.1)] backdrop-blur-xl sm:px-5`,children:(0,Y.jsx)(`div`,{role:`tablist`,"aria-orientation":`horizontal`,className:`mx-auto grid w-full max-w-3xl grid-cols-2 gap-1`,children:i.map((e,t)=>{let i=e.icon,o=n===e.id;return(0,Y.jsxs)(`button`,{id:`office-map-tab-${e.id}`,type:`button`,role:`tab`,"aria-selected":o,"aria-controls":`office-map-view-panel`,tabIndex:o?0:-1,onClick:()=>r(e.id),onKeyDown:e=>a(e,t),className:I(`group relative flex min-w-0 items-center gap-2.5 border-b-2 px-3 py-2.5 text-left transition-all duration-200 sm:gap-3 sm:px-5`,o?`border-primary bg-primary/[0.07] text-foreground`:`border-transparent text-muted-foreground hover:border-border hover:bg-accent/60 hover:text-foreground`),children:[(0,Y.jsx)(`span`,{className:I(`grid h-8 w-8 shrink-0 place-items-center rounded-lg border transition-colors`,o?`border-primary/35 bg-primary/15 text-primary`:`border-border bg-background/70 text-muted-foreground group-hover:text-foreground`),children:(0,Y.jsx)(i,{className:`h-4 w-4`,"aria-hidden":`true`})}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`strong`,{className:`block truncate font-display text-xs font-semibold sm:text-sm`,children:e.label}),(0,Y.jsx)(`small`,{className:`hidden truncate font-mono text-[9px] font-normal text-muted-foreground sm:block`,children:e.description})]}),(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:I(`ml-auto h-1.5 w-1.5 shrink-0 rounded-full transition-all`,o?`bg-primary shadow-[0_0_0_4px_hsl(var(--primary)/0.12)]`:`bg-border`)})]},e.id)})})}),(0,Y.jsx)(`div`,{id:`office-map-view-panel`,role:`tabpanel`,"aria-labelledby":`office-map-tab-${n}`,className:`relative min-h-0 flex-1`,children:n===`office`?(0,Y.jsx)(Ht,{}):(0,Y.jsx)(xe,{children:(0,Y.jsx)(dn,{})})})]})}export{fn as OfficeMapPanel};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Mt as t,Rt as n,Tt as r,aa as i,ea as a,tt as o}from"./vendor-Di1mdAi5.js";import"./i18n-DaR2GB_4.js";import{t as s}from"./useWebSocket-CRYUFxmO.js";import{t as c}from"./utils-C4qVQ63O.js";import{j as l}from"./stores-JSLvWOQY.js";import{n as u,o as d,r as f,t as p}from"./dialog-CNwwBFw3.js";var m=e(i(),1),h=o();function g({open:e,onClose:i,className:o}){let{t:g}=a(),[_,v]=(0,m.useState)([]),y=s(),b=l(e=>e.wsConnected),x=(0,m.useRef)(null),S=(0,m.useRef)(null);(0,m.useEffect)(()=>{if(!(!e||!b||!y.client?.isConnected))return y.client.send?.({type:`process.list`}),x.current=y.client.on?.(`process.list`,e=>{let t=e?.payload;t?.processes&&v(t.processes)})??null,S.current=setInterval(()=>{y.client.send?.({type:`process.list`})},3e3),()=>{x.current?.(),S.current&&clearInterval(S.current)}},[e,b,y.client]);let C=(0,m.useCallback)(e=>{y.client.send?.({type:`process.kill`,payload:{pid:e}})},[y.client]),w=(0,m.useCallback)(()=>{y.client.send?.({type:`process.killAll`})},[y.client]),T=_.filter(e=>e.status===`running`);return(0,h.jsx)(p,{open:e,onOpenChange:e=>{e||i()},children:(0,h.jsxs)(u,{className:c(`max-w-lg gap-0 p-0 overflow-hidden flex flex-col max-h-[75dvh] pt-[10dvh]`,o),showCloseButton:!1,children:[(0,h.jsx)(d,{className:`sr-only`,children:g(`activity:process.heading`)}),(0,h.jsx)(f,{className:`sr-only`,children:g(`activity:process.subtitle`,{active:T.length,total:_.length})}),(0,h.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b shrink-0`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,h.jsx)(`span`,{className:`flex items-center justify-center w-8 h-8 rounded-lg bg-warning/10 text-warning`,children:(0,h.jsx)(r,{className:`h-4 w-4`})}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h2`,{className:`text-sm font-semibold`,children:g(`activity:process.heading`)}),(0,h.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:g(`activity:process.subtitle`,{active:T.length,total:_.length})})]})]}),(0,h.jsx)(`div`,{className:`flex items-center gap-1`,children:T.length>0&&(0,h.jsxs)(`button`,{type:`button`,onClick:w,className:`flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-xs text-destructive hover:bg-destructive/10 transition-colors font-medium`,children:[(0,h.jsx)(t,{className:`h-3 w-3 fill-current`}),g(`activity:process.killAll`)]})})]}),(0,h.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:_.length===0?(0,h.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16 gap-3 text-muted-foreground`,children:[(0,h.jsx)(r,{className:`h-10 w-10 opacity-15`}),(0,h.jsx)(`p`,{className:`text-sm font-medium`,children:g(`activity:process.emptyTitle`)}),(0,h.jsx)(`p`,{className:`text-xs text-center max-w-xs`,children:g(`activity:process.emptyBody`)})]}):(0,h.jsx)(`div`,{className:`divide-y`,children:_.map(e=>{let r=e.status===`running`?Math.floor((Date.now()-e.startedAt)/1e3):null,i=r?r<60?`${r}s`:`${Math.floor(r/60)}m ${r%60}s`:null,a=e.protected===!0;return(0,h.jsxs)(`div`,{className:c(`flex items-center justify-between px-4 py-3 text-xs transition-colors`,e.status===`running`?`bg-background hover:bg-muted/30`:`bg-muted/20 text-muted-foreground`),children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:[(0,h.jsx)(`span`,{className:c(`led shrink-0`,e.status===`running`?a?`text-info`:`text-success led-pulse`:`text-muted-foreground`)}),(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground shrink-0`,children:g(`activity:process.pidLabel`,{pid:e.pid})}),(0,h.jsx)(`span`,{className:`font-medium truncate`,children:e.tool}),a&&(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 px-1 py-0.5 rounded text-[9px] bg-info/10 text-info font-medium shrink-0`,title:g(`activity:process.protectedTitle`),children:[(0,h.jsx)(n,{className:`h-2.5 w-2.5`}),g(`activity:process.protected`)]})]}),(0,h.jsx)(`code`,{className:`text-[10px] text-muted-foreground/70 truncate block mt-0.5 font-mono`,children:e.command})]})]}),(0,h.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0 ml-3`,children:[i&&(0,h.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:i}),e.status===`running`&&!a&&(0,h.jsx)(`button`,{type:`button`,onClick:()=>C(e.pid),className:`p-1.5 rounded-md hover:bg-destructive/10 hover:text-destructive transition-colors`,title:g(`activity:process.killTitle`,{pid:e.pid}),children:(0,h.jsx)(t,{className:`h-3.5 w-3.5 fill-current`})})]})]},e.pid)})})})]})})}export{g as ProcessMonitor};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Mt as t,Rt as n,Tt as r,oa as i,ta as a,tt as o}from"./vendor-DffL_bim.js";import"./i18n-Dk35g-uV.js";import{t as s}from"./useWebSocket-BJorYmOi.js";import{t as c}from"./utils-DEzFewqr.js";import{j as l}from"./stores-CUp_ut8r.js";import{n as u,o as d,r as f,t as p}from"./dialog-CBgO-uqz.js";var m=e(i(),1),h=o();function g({open:e,onClose:i,className:o}){let{t:g}=a(),[_,v]=(0,m.useState)([]),y=s(),b=l(e=>e.wsConnected),x=(0,m.useRef)(null),S=(0,m.useRef)(null);(0,m.useEffect)(()=>{if(!(!e||!b||!y.client?.isConnected))return y.client.send?.({type:`process.list`}),x.current=y.client.on?.(`process.list`,e=>{let t=e?.payload;t?.processes&&v(t.processes)})??null,S.current=setInterval(()=>{y.client.send?.({type:`process.list`})},3e3),()=>{x.current?.(),S.current&&clearInterval(S.current)}},[e,b,y.client]);let C=(0,m.useCallback)(e=>{y.client.send?.({type:`process.kill`,payload:{pid:e}})},[y.client]),w=(0,m.useCallback)(()=>{y.client.send?.({type:`process.killAll`})},[y.client]),T=_.filter(e=>e.status===`running`);return(0,h.jsx)(p,{open:e,onOpenChange:e=>{e||i()},children:(0,h.jsxs)(u,{className:c(`max-w-lg gap-0 p-0 overflow-hidden flex flex-col max-h-[75dvh] pt-[10dvh]`,o),showCloseButton:!1,children:[(0,h.jsx)(d,{className:`sr-only`,children:g(`activity:process.heading`)}),(0,h.jsx)(f,{className:`sr-only`,children:g(`activity:process.subtitle`,{active:T.length,total:_.length})}),(0,h.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b shrink-0`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,h.jsx)(`span`,{className:`flex items-center justify-center w-8 h-8 rounded-lg bg-warning/10 text-warning`,children:(0,h.jsx)(r,{className:`h-4 w-4`})}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h2`,{className:`text-sm font-semibold`,children:g(`activity:process.heading`)}),(0,h.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:g(`activity:process.subtitle`,{active:T.length,total:_.length})})]})]}),(0,h.jsx)(`div`,{className:`flex items-center gap-1`,children:T.length>0&&(0,h.jsxs)(`button`,{type:`button`,onClick:w,className:`flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-xs text-destructive hover:bg-destructive/10 transition-colors font-medium`,children:[(0,h.jsx)(t,{className:`h-3 w-3 fill-current`}),g(`activity:process.killAll`)]})})]}),(0,h.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:_.length===0?(0,h.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16 gap-3 text-muted-foreground`,children:[(0,h.jsx)(r,{className:`h-10 w-10 opacity-15`}),(0,h.jsx)(`p`,{className:`text-sm font-medium`,children:g(`activity:process.emptyTitle`)}),(0,h.jsx)(`p`,{className:`text-xs text-center max-w-xs`,children:g(`activity:process.emptyBody`)})]}):(0,h.jsx)(`div`,{className:`divide-y`,children:_.map(e=>{let r=e.status===`running`?Math.floor((Date.now()-e.startedAt)/1e3):null,i=r?r<60?`${r}s`:`${Math.floor(r/60)}m ${r%60}s`:null,a=e.protected===!0;return(0,h.jsxs)(`div`,{className:c(`flex items-center justify-between px-4 py-3 text-xs transition-colors`,e.status===`running`?`bg-background hover:bg-muted/30`:`bg-muted/20 text-muted-foreground`),children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:[(0,h.jsx)(`span`,{className:c(`led shrink-0`,e.status===`running`?a?`text-info`:`text-success led-pulse`:`text-muted-foreground`)}),(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground shrink-0`,children:g(`activity:process.pidLabel`,{pid:e.pid})}),(0,h.jsx)(`span`,{className:`font-medium truncate`,children:e.tool}),a&&(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 px-1 py-0.5 rounded text-[9px] bg-info/10 text-info font-medium shrink-0`,title:g(`activity:process.protectedTitle`),children:[(0,h.jsx)(n,{className:`h-2.5 w-2.5`}),g(`activity:process.protected`)]})]}),(0,h.jsx)(`code`,{className:`text-[10px] text-muted-foreground/70 truncate block mt-0.5 font-mono`,children:e.command})]})]}),(0,h.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0 ml-3`,children:[i&&(0,h.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:i}),e.status===`running`&&!a&&(0,h.jsx)(`button`,{type:`button`,onClick:()=>C(e.pid),className:`p-1.5 rounded-md hover:bg-destructive/10 hover:text-destructive transition-colors`,title:g(`activity:process.killTitle`,{pid:e.pid}),children:(0,h.jsx)(t,{className:`h-3.5 w-3.5 fill-current`})})]})]},e.pid)})})})]})})}export{g as ProcessMonitor};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./chat-store-Cunk1nDr.js";import{Ct as n,Vi as r,Wn as i,aa as a,ea as o,ot as s,qi as c,tt as l}from"./vendor-Di1mdAi5.js";import"./i18n-DaR2GB_4.js";import{t as u}from"./utils-C4qVQ63O.js";import"./stores-JSLvWOQY.js";import{n as d,o as f,r as p,t as m}from"./dialog-CNwwBFw3.js";var h=e(a(),1),g=l(),_={btw:{label:`btw`,titleKey:`btwTitle`,tone:`bg-primary/10 text-primary border-primary/30`},steer:{label:`steer`,titleKey:`steerTitle`,tone:`bg-warning/10 text-warning border-warning/35`},queue:{label:`queue`,titleKey:`queueTitle`,tone:`bg-info/10 text-info border-info/30`}};function v({open:e,onClose:a,className:l}){let{t:v}=o(),y=t(e=>e.queue),b=t(e=>e.removeQueued),x=t(e=>e.clearQueue),[S,C]=(0,h.useState)(`oldest`),w=(0,h.useCallback)(e=>{b(e)},[b]),T=(0,h.useMemo)(()=>{let e=y.map((e,t)=>({item:e,sourceIdx:t}));return e.sort((e,t)=>S===`newest`?t.item.addedAt-e.item.addedAt:e.item.addedAt-t.item.addedAt),e},[y,S]);return(0,g.jsx)(m,{open:e,onOpenChange:e=>{e||a()},children:(0,g.jsxs)(d,{className:u(`max-w-lg gap-0 overflow-hidden border-border/80 bg-card p-0 pt-[10dvh] flex flex-col max-h-[70dvh]`,l),showCloseButton:!1,children:[(0,g.jsx)(f,{className:`sr-only`,children:v(`activity:queue.heading`)}),(0,g.jsx)(p,{className:`sr-only`,children:v(`activity:queue.subtitle`,{count:y.length})}),(0,g.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/70 bg-card/95 px-4 py-3 shrink-0`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,g.jsx)(`span`,{className:`flex items-center justify-center w-8 h-8 rounded-md border border-primary/20 bg-primary/10 text-primary`,children:(0,g.jsx)(i,{className:`h-4 w-4`})}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`h2`,{className:`text-sm font-semibold`,children:v(`activity:queue.heading`)}),(0,g.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:v(`activity:queue.subtitle`,{count:y.length})})]})]}),(0,g.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,g.jsxs)(`button`,{type:`button`,onClick:()=>C(e=>e===`newest`?`oldest`:`newest`),className:u(`flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-xs transition-colors font-medium`,`text-muted-foreground hover:bg-muted hover:text-foreground`),title:v(S===`newest`?`activity:queue.sortNewestTitle`:`activity:queue.sortOldestTitle`),"data-testid":`queue-sort-toggle`,children:[S===`newest`?(0,g.jsx)(c,{className:`h-3 w-3`}):(0,g.jsx)(r,{className:`h-3 w-3`}),v(S===`newest`?`activity:queue.newest`:`activity:queue.oldest`)]}),y.length>0&&(0,g.jsxs)(`button`,{type:`button`,onClick:()=>x(),className:`flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-xs text-destructive hover:bg-destructive/10 transition-colors font-medium`,title:v(`activity:queue.clearTitle`),"data-testid":`queue-clear-all`,children:[(0,g.jsx)(n,{className:`h-3 w-3`}),v(`activity:queue.clear`)]})]})]}),(0,g.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:y.length===0?(0,g.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16 gap-3 text-muted-foreground`,children:[(0,g.jsx)(i,{className:`h-10 w-10 opacity-15`}),(0,g.jsx)(`p`,{className:`text-sm font-medium`,children:v(`activity:queue.emptyTitle`)}),(0,g.jsx)(`p`,{className:`text-xs text-center max-w-xs`,children:v(`activity:queue.emptyBody`)})]}):(0,g.jsx)(g.Fragment,{children:(0,g.jsx)(`ul`,{className:`divide-y divide-border/60`,"data-testid":`queue-list`,children:T.map(({item:e,sourceIdx:t},n)=>{let r=_[e.mode];return(0,g.jsxs)(`li`,{className:`flex items-start justify-between gap-3 px-4 py-3 text-xs transition-colors hover:bg-muted/35`,"data-testid":`queue-item`,children:[(0,g.jsxs)(`div`,{className:`flex items-start gap-3 min-w-0 flex-1`,children:[(0,g.jsxs)(`span`,{className:`mt-1 text-[10px] font-mono text-muted-foreground shrink-0 w-5 text-right tabular-nums`,children:[n+1,`.`]}),(0,g.jsx)(`span`,{className:u(`shrink-0 inline-flex items-center justify-center rounded border px-1.5 py-0.5 text-[10px] font-semibold uppercase`,r.tone),title:v(`activity:queue.${r.titleKey}`),"data-testid":`queue-mode-${e.mode}`,children:r.label}),(0,g.jsx)(`p`,{className:`text-sm text-foreground leading-relaxed min-w-0 break-words`,children:e.text.length>120?`${e.text.slice(0,117)}…`:e.text})]}),(0,g.jsx)(`button`,{type:`button`,onClick:()=>w(t),className:`ml-1 p-1.5 rounded-md shrink-0 hover:bg-destructive/10 hover:text-destructive transition-colors`,title:v(`activity:queue.removeTitle`),"data-testid":`queue-remove-${t}`,children:(0,g.jsx)(s,{className:`h-3.5 w-3.5`})})]},`${e.addedAt}-${t}`)})})})}),y.length>0&&(0,g.jsx)(`div`,{className:`border-t border-border/70 bg-muted/20 px-4 py-2.5 shrink-0`,children:(0,g.jsx)(`p`,{className:`text-[10px] text-muted-foreground text-center`,children:v(`activity:queue.footer`)})})]})})}export{v as QueuePanel};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./chat-store-CUODHW6c.js";import{Ct as n,Hi as r,Ji as i,Wn as a,oa as o,ot as s,ta as c,tt as l}from"./vendor-DffL_bim.js";import"./i18n-Dk35g-uV.js";import{t as u}from"./utils-DEzFewqr.js";import"./stores-CUp_ut8r.js";import{n as d,o as f,r as p,t as m}from"./dialog-CBgO-uqz.js";var h=e(o(),1),g=l(),_={btw:{label:`btw`,titleKey:`btwTitle`,tone:`bg-primary/10 text-primary border-primary/30`},steer:{label:`steer`,titleKey:`steerTitle`,tone:`bg-warning/10 text-warning border-warning/35`},queue:{label:`queue`,titleKey:`queueTitle`,tone:`bg-info/10 text-info border-info/30`}};function v({open:e,onClose:o,className:l}){let{t:v}=c(),y=t(e=>e.queue),b=t(e=>e.removeQueued),x=t(e=>e.clearQueue),[S,C]=(0,h.useState)(`oldest`),w=(0,h.useCallback)(e=>{b(e)},[b]),T=(0,h.useMemo)(()=>{let e=y.map((e,t)=>({item:e,sourceIdx:t}));return e.sort((e,t)=>S===`newest`?t.item.addedAt-e.item.addedAt:e.item.addedAt-t.item.addedAt),e},[y,S]);return(0,g.jsx)(m,{open:e,onOpenChange:e=>{e||o()},children:(0,g.jsxs)(d,{className:u(`max-w-lg gap-0 overflow-hidden border-border/80 bg-card p-0 pt-[10dvh] flex flex-col max-h-[70dvh]`,l),showCloseButton:!1,children:[(0,g.jsx)(f,{className:`sr-only`,children:v(`activity:queue.heading`)}),(0,g.jsx)(p,{className:`sr-only`,children:v(`activity:queue.subtitle`,{count:y.length})}),(0,g.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/70 bg-card/95 px-4 py-3 shrink-0`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,g.jsx)(`span`,{className:`flex items-center justify-center w-8 h-8 rounded-md border border-primary/20 bg-primary/10 text-primary`,children:(0,g.jsx)(a,{className:`h-4 w-4`})}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`h2`,{className:`text-sm font-semibold`,children:v(`activity:queue.heading`)}),(0,g.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:v(`activity:queue.subtitle`,{count:y.length})})]})]}),(0,g.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,g.jsxs)(`button`,{type:`button`,onClick:()=>C(e=>e===`newest`?`oldest`:`newest`),className:u(`flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-xs transition-colors font-medium`,`text-muted-foreground hover:bg-muted hover:text-foreground`),title:v(S===`newest`?`activity:queue.sortNewestTitle`:`activity:queue.sortOldestTitle`),"data-testid":`queue-sort-toggle`,children:[S===`newest`?(0,g.jsx)(i,{className:`h-3 w-3`}):(0,g.jsx)(r,{className:`h-3 w-3`}),v(S===`newest`?`activity:queue.newest`:`activity:queue.oldest`)]}),y.length>0&&(0,g.jsxs)(`button`,{type:`button`,onClick:()=>x(),className:`flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-xs text-destructive hover:bg-destructive/10 transition-colors font-medium`,title:v(`activity:queue.clearTitle`),"data-testid":`queue-clear-all`,children:[(0,g.jsx)(n,{className:`h-3 w-3`}),v(`activity:queue.clear`)]})]})]}),(0,g.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:y.length===0?(0,g.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16 gap-3 text-muted-foreground`,children:[(0,g.jsx)(a,{className:`h-10 w-10 opacity-15`}),(0,g.jsx)(`p`,{className:`text-sm font-medium`,children:v(`activity:queue.emptyTitle`)}),(0,g.jsx)(`p`,{className:`text-xs text-center max-w-xs`,children:v(`activity:queue.emptyBody`)})]}):(0,g.jsx)(g.Fragment,{children:(0,g.jsx)(`ul`,{className:`divide-y divide-border/60`,"data-testid":`queue-list`,children:T.map(({item:e,sourceIdx:t},n)=>{let r=_[e.mode];return(0,g.jsxs)(`li`,{className:`flex items-start justify-between gap-3 px-4 py-3 text-xs transition-colors hover:bg-muted/35`,"data-testid":`queue-item`,children:[(0,g.jsxs)(`div`,{className:`flex items-start gap-3 min-w-0 flex-1`,children:[(0,g.jsxs)(`span`,{className:`mt-1 text-[10px] font-mono text-muted-foreground shrink-0 w-5 text-right tabular-nums`,children:[n+1,`.`]}),(0,g.jsx)(`span`,{className:u(`shrink-0 inline-flex items-center justify-center rounded border px-1.5 py-0.5 text-[10px] font-semibold uppercase`,r.tone),title:v(`activity:queue.${r.titleKey}`),"data-testid":`queue-mode-${e.mode}`,children:r.label}),(0,g.jsx)(`p`,{className:`text-sm text-foreground leading-relaxed min-w-0 break-words`,children:e.text.length>120?`${e.text.slice(0,117)}…`:e.text})]}),(0,g.jsx)(`button`,{type:`button`,onClick:()=>w(t),className:`ml-1 p-1.5 rounded-md shrink-0 hover:bg-destructive/10 hover:text-destructive transition-colors`,title:v(`activity:queue.removeTitle`),"data-testid":`queue-remove-${t}`,children:(0,g.jsx)(s,{className:`h-3.5 w-3.5`})})]},`${e.addedAt}-${t}`)})})})}),y.length>0&&(0,g.jsx)(`div`,{className:`border-t border-border/70 bg-muted/20 px-4 py-2.5 shrink-0`,children:(0,g.jsx)(`p`,{className:`text-[10px] text-muted-foreground text-center`,children:v(`activity:queue.footer`)})})]})})}export{v as QueuePanel};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./chat-store-Cunk1nDr.js";import{Gt as n,Qt as r,Yr as i,Zi as a,aa as o,bt as s,ea as c,gi as l,or as u,tt as d}from"./vendor-Di1mdAi5.js";import"./i18n-DaR2GB_4.js";import{n as f}from"./ui-store-BepZz9CZ.js";import{t as p}from"./session-store-B8icONBU.js";var m=e(o(),1),h=d();function g(){let e=p(e=>e.session),{t:o}=c(),d=p.getState().session?.id,g=p(e=>e.projectName),x=p(e=>e.cwd),S=p(e=>e.mode),C=p(e=>e.contextMode),w=p(e=>e.lastVisitedAt),T=t(e=>e.messages),E=t(e=>e.queue.length),D=t(e=>e.boundSessionId),O=f(e=>e.currentView),k=f(e=>e.dockSection),[A,j]=(0,m.useState)([]),M=(0,m.useMemo)(()=>{if(typeof window>`u`)return 0;let e=0;for(let t of[`wrongstack-session`,`wrongstack-chat`,`wrongstack-ui`,`wrongstack-config`]){let n=window.localStorage.getItem(t);typeof n==`string`&&(e+=n.length)}return e},[T.length]),N=typeof window<`u`&&!!window.__wrongstackSessionRehydrated,P=typeof window<`u`&&!!window.__wrongstackChatRehydrated;function F(e,t){j(n=>[{ts:Date.now(),note:e,ok:t},...n].slice(0,20))}function I(){F(o(`activity:refresh.simulatedF5`),!0)}let L=D!==null&&d!==void 0&&D!==d;return(0,h.jsx)(`div`,{className:`h-full min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain bg-[hsl(var(--surface-2)/0.45)] p-4 sm:p-6`,children:(0,h.jsxs)(`div`,{className:`mx-auto max-w-5xl space-y-5 sm:space-y-6`,children:[(0,h.jsx)(`header`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:(0,h.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsxs)(`h1`,{className:`flex min-w-0 items-center gap-2 text-xl font-bold sm:text-2xl`,children:[(0,h.jsx)(r,{className:`h-6 w-6 shrink-0 text-primary sm:h-7 sm:w-7`}),o(`activity:refresh.heading`)]}),(0,h.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:o(`activity:refresh.subtitle`)})]}),(0,h.jsx)(`button`,{type:`button`,onClick:I,className:`inline-flex h-9 w-full items-center justify-center rounded-md bg-primary px-3 text-sm font-medium text-primary-foreground shadow-sm shadow-primary/15 hover:bg-primary/90 sm:w-auto`,children:o(`activity:refresh.recordProbe`)})]})}),(0,h.jsxs)(`section`,{className:`space-y-3`,children:[(0,h.jsxs)(`h2`,{className:`text-lg font-semibold flex items-center gap-2`,children:[(0,h.jsx)(a,{className:`w-5 h-5`}),o(`activity:refresh.latestSession`)]}),(0,h.jsx)(_,{label:o(`activity:refresh.restoredLocal`),ok:N,extra:d?o(`activity:refresh.sessionIdExtra`,{id:d}):o(`activity:refresh.noSessionYet`)}),(0,h.jsx)(_,{label:o(`activity:refresh.activePointer`),ok:!!e?.id,extra:e?y(e):`null`}),(0,h.jsx)(_,{label:o(`activity:refresh.lastVisited`),ok:w>0,extra:w>0?new Date(w).toISOString():o(`activity:refresh.never`)})]}),(0,h.jsxs)(`section`,{className:`space-y-3`,children:[(0,h.jsxs)(`h2`,{className:`text-lg font-semibold flex items-center gap-2`,children:[(0,h.jsx)(i,{className:`w-5 h-5`}),o(`activity:refresh.persistedEnv`)]}),(0,h.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,h.jsx)(v,{label:`projectName`,value:g||`∅`}),(0,h.jsx)(v,{label:`cwd`,value:x||`∅`,mono:!0}),(0,h.jsx)(v,{label:`mode`,value:S,mono:!0}),(0,h.jsx)(v,{label:`contextMode`,value:C,mono:!0})]})]}),(0,h.jsxs)(`section`,{className:`space-y-3`,children:[(0,h.jsxs)(`h2`,{className:`text-lg font-semibold flex items-center gap-2`,children:[(0,h.jsx)(u,{className:`w-5 h-5`}),o(`activity:refresh.transcriptRehydrate`)]}),(0,h.jsx)(_,{label:o(`activity:refresh.localTranscript`),ok:P&&(T.length>0||D===null),extra:T.length===0?o(`activity:refresh.noMessages`):o(`activity:refresh.messagesExtra`,{count:T.length,queued:E})}),(0,h.jsx)(_,{label:o(`activity:refresh.noBleed`),ok:!L,extra:L?o(`activity:refresh.bleedExtra`,{bound:D??`∅`,active:d??`∅`}):o(`activity:refresh.transcriptBinds`),warn:L}),T.length>0&&(0,h.jsxs)(`div`,{className:`space-y-1 rounded-lg border border-border/70 bg-card/65 p-3 text-xs font-mono`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`span`,{className:`text-muted-foreground`,children:`first:`}),` `,b(T[0])]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`span`,{className:`text-muted-foreground`,children:`last:`}),` `,b(T[T.length-1]??T[0])]})]})]}),(0,h.jsxs)(`section`,{className:`space-y-3`,children:[(0,h.jsxs)(`h2`,{className:`text-lg font-semibold flex items-center gap-2`,children:[(0,h.jsx)(n,{className:`w-5 h-5`}),o(`activity:refresh.uiWorkspace`)]}),(0,h.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,h.jsx)(v,{label:`currentView`,value:O,mono:!0}),(0,h.jsx)(v,{label:`dockSection`,value:k??o(`activity:refresh.noneValue`),mono:!0})]}),(0,h.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o(`activity:refresh.payloadSize`,{count:M})})]}),(0,h.jsxs)(`section`,{className:`space-y-2`,children:[(0,h.jsx)(`h2`,{className:`text-lg font-semibold`,children:o(`activity:refresh.probeLog`)}),A.length===0?(0,h.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o(`activity:refresh.noProbes`)}):(0,h.jsx)(`ul`,{className:`space-y-1 text-xs font-mono`,children:A.map((e,t)=>(0,h.jsxs)(`li`,{className:`flex items-center gap-2`,children:[e.ok?(0,h.jsx)(l,{className:`w-4 h-4 text-success shrink-0`}):(0,h.jsx)(s,{className:`w-4 h-4 text-warning shrink-0`}),(0,h.jsx)(`span`,{className:`text-muted-foreground`,children:new Date(e.ts).toLocaleTimeString()}),(0,h.jsx)(`span`,{children:e.note})]},`${e.ts}-${t}`))})]})]})})}function _({label:e,extra:t,ok:n,warn:r}){return(0,h.jsxs)(`div`,{className:`rounded-lg border px-3 py-2 ${r?`border-warning/40 bg-warning/10 text-warning`:n?`border-success/40 bg-success/10 text-success`:`border-border bg-muted/40 text-muted-foreground`}`,children:[(0,h.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-xs font-medium`,children:[n&&!r?(0,h.jsx)(l,{className:`h-4 w-4 shrink-0`}):(0,h.jsx)(s,{className:`h-4 w-4 shrink-0`}),(0,h.jsx)(`span`,{className:`min-w-0 break-words`,children:e})]}),(0,h.jsx)(`div`,{className:`text-xs font-mono mt-1 break-all`,children:t})]})}function v({label:e,value:t,mono:n}){return(0,h.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-border/70 bg-card/75 p-3 shadow-sm`,children:[(0,h.jsx)(`p`,{className:`text-xs uppercase tracking-wide text-muted-foreground`,children:e}),(0,h.jsx)(`p`,{className:`mt-1 text-sm break-all `+(n?`font-mono`:`font-medium`),children:t})]})}function y(e){let t=e.title?.trim();return t?`${e.id} — "${t}" (${e.provider}/${e.model})`:`${e.id} (${e.provider}/${e.model})`}function b(e){let t=(e.content??``).trim().replace(/\s+/g,` `);return`[${e.role}] ${t.length>100?`${t.slice(0,99)}…`:t}`}export{g as RefreshDebugView};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./chat-store-CUODHW6c.js";import{Gt as n,Qi as r,Qt as i,Xr as a,_i as o,bt as s,oa as c,or as l,ta as u,tt as d}from"./vendor-DffL_bim.js";import"./i18n-Dk35g-uV.js";import{n as f}from"./ui-store-CwOvhFZG.js";import{t as p}from"./session-store-Coiik-Ib.js";var m=e(c(),1),h=d();function g(){let e=p(e=>e.session),{t:c}=u(),d=p.getState().session?.id,g=p(e=>e.projectName),x=p(e=>e.cwd),S=p(e=>e.mode),C=p(e=>e.contextMode),w=p(e=>e.lastVisitedAt),T=t(e=>e.messages),E=t(e=>e.queue.length),D=t(e=>e.boundSessionId),O=f(e=>e.currentView),k=f(e=>e.dockSection),[A,j]=(0,m.useState)([]),M=(0,m.useMemo)(()=>{if(typeof window>`u`)return 0;let e=0;for(let t of[`wrongstack-session`,`wrongstack-chat`,`wrongstack-ui`,`wrongstack-config`]){let n=window.localStorage.getItem(t);typeof n==`string`&&(e+=n.length)}return e},[T.length]),N=typeof window<`u`&&!!window.__wrongstackSessionRehydrated,P=typeof window<`u`&&!!window.__wrongstackChatRehydrated;function F(e,t){j(n=>[{ts:Date.now(),note:e,ok:t},...n].slice(0,20))}function I(){F(c(`activity:refresh.simulatedF5`),!0)}let L=D!==null&&d!==void 0&&D!==d;return(0,h.jsx)(`div`,{className:`h-full min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain bg-[hsl(var(--surface-2)/0.45)] p-4 sm:p-6`,children:(0,h.jsxs)(`div`,{className:`mx-auto max-w-5xl space-y-5 sm:space-y-6`,children:[(0,h.jsx)(`header`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:(0,h.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsxs)(`h1`,{className:`flex min-w-0 items-center gap-2 text-xl font-bold sm:text-2xl`,children:[(0,h.jsx)(i,{className:`h-6 w-6 shrink-0 text-primary sm:h-7 sm:w-7`}),c(`activity:refresh.heading`)]}),(0,h.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:c(`activity:refresh.subtitle`)})]}),(0,h.jsx)(`button`,{type:`button`,onClick:I,className:`inline-flex h-9 w-full items-center justify-center rounded-md bg-primary px-3 text-sm font-medium text-primary-foreground shadow-sm shadow-primary/15 hover:bg-primary/90 sm:w-auto`,children:c(`activity:refresh.recordProbe`)})]})}),(0,h.jsxs)(`section`,{className:`space-y-3`,children:[(0,h.jsxs)(`h2`,{className:`text-lg font-semibold flex items-center gap-2`,children:[(0,h.jsx)(r,{className:`w-5 h-5`}),c(`activity:refresh.latestSession`)]}),(0,h.jsx)(_,{label:c(`activity:refresh.restoredLocal`),ok:N,extra:d?c(`activity:refresh.sessionIdExtra`,{id:d}):c(`activity:refresh.noSessionYet`)}),(0,h.jsx)(_,{label:c(`activity:refresh.activePointer`),ok:!!e?.id,extra:e?y(e):`null`}),(0,h.jsx)(_,{label:c(`activity:refresh.lastVisited`),ok:w>0,extra:w>0?new Date(w).toISOString():c(`activity:refresh.never`)})]}),(0,h.jsxs)(`section`,{className:`space-y-3`,children:[(0,h.jsxs)(`h2`,{className:`text-lg font-semibold flex items-center gap-2`,children:[(0,h.jsx)(a,{className:`w-5 h-5`}),c(`activity:refresh.persistedEnv`)]}),(0,h.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,h.jsx)(v,{label:`projectName`,value:g||`∅`}),(0,h.jsx)(v,{label:`cwd`,value:x||`∅`,mono:!0}),(0,h.jsx)(v,{label:`mode`,value:S,mono:!0}),(0,h.jsx)(v,{label:`contextMode`,value:C,mono:!0})]})]}),(0,h.jsxs)(`section`,{className:`space-y-3`,children:[(0,h.jsxs)(`h2`,{className:`text-lg font-semibold flex items-center gap-2`,children:[(0,h.jsx)(l,{className:`w-5 h-5`}),c(`activity:refresh.transcriptRehydrate`)]}),(0,h.jsx)(_,{label:c(`activity:refresh.localTranscript`),ok:P&&(T.length>0||D===null),extra:T.length===0?c(`activity:refresh.noMessages`):c(`activity:refresh.messagesExtra`,{count:T.length,queued:E})}),(0,h.jsx)(_,{label:c(`activity:refresh.noBleed`),ok:!L,extra:L?c(`activity:refresh.bleedExtra`,{bound:D??`∅`,active:d??`∅`}):c(`activity:refresh.transcriptBinds`),warn:L}),T.length>0&&(0,h.jsxs)(`div`,{className:`space-y-1 rounded-lg border border-border/70 bg-card/65 p-3 text-xs font-mono`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`span`,{className:`text-muted-foreground`,children:`first:`}),` `,b(T[0])]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`span`,{className:`text-muted-foreground`,children:`last:`}),` `,b(T[T.length-1]??T[0])]})]})]}),(0,h.jsxs)(`section`,{className:`space-y-3`,children:[(0,h.jsxs)(`h2`,{className:`text-lg font-semibold flex items-center gap-2`,children:[(0,h.jsx)(n,{className:`w-5 h-5`}),c(`activity:refresh.uiWorkspace`)]}),(0,h.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,h.jsx)(v,{label:`currentView`,value:O,mono:!0}),(0,h.jsx)(v,{label:`dockSection`,value:k??c(`activity:refresh.noneValue`),mono:!0})]}),(0,h.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:c(`activity:refresh.payloadSize`,{count:M})})]}),(0,h.jsxs)(`section`,{className:`space-y-2`,children:[(0,h.jsx)(`h2`,{className:`text-lg font-semibold`,children:c(`activity:refresh.probeLog`)}),A.length===0?(0,h.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:c(`activity:refresh.noProbes`)}):(0,h.jsx)(`ul`,{className:`space-y-1 text-xs font-mono`,children:A.map((e,t)=>(0,h.jsxs)(`li`,{className:`flex items-center gap-2`,children:[e.ok?(0,h.jsx)(o,{className:`w-4 h-4 text-success shrink-0`}):(0,h.jsx)(s,{className:`w-4 h-4 text-warning shrink-0`}),(0,h.jsx)(`span`,{className:`text-muted-foreground`,children:new Date(e.ts).toLocaleTimeString()}),(0,h.jsx)(`span`,{children:e.note})]},`${e.ts}-${t}`))})]})]})})}function _({label:e,extra:t,ok:n,warn:r}){return(0,h.jsxs)(`div`,{className:`rounded-lg border px-3 py-2 ${r?`border-warning/40 bg-warning/10 text-warning`:n?`border-success/40 bg-success/10 text-success`:`border-border bg-muted/40 text-muted-foreground`}`,children:[(0,h.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-xs font-medium`,children:[n&&!r?(0,h.jsx)(o,{className:`h-4 w-4 shrink-0`}):(0,h.jsx)(s,{className:`h-4 w-4 shrink-0`}),(0,h.jsx)(`span`,{className:`min-w-0 break-words`,children:e})]}),(0,h.jsx)(`div`,{className:`text-xs font-mono mt-1 break-all`,children:t})]})}function v({label:e,value:t,mono:n}){return(0,h.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-border/70 bg-card/75 p-3 shadow-sm`,children:[(0,h.jsx)(`p`,{className:`text-xs uppercase tracking-wide text-muted-foreground`,children:e}),(0,h.jsx)(`p`,{className:`mt-1 text-sm break-all `+(n?`font-mono`:`font-medium`),children:t})]})}function y(e){let t=e.title?.trim();return t?`${e.id} — "${t}" (${e.provider}/${e.model})`:`${e.id} (${e.provider}/${e.model})`}function b(e){let t=(e.content??``).trim().replace(/\s+/g,` `);return`[${e.role}] ${t.length>100?`${t.slice(0,99)}…`:t}`}export{g as RefreshDebugView};