@wrongstack/webui 0.292.0 → 0.292.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. package/dist/assets/{AnalyticsDashboard-DausPJOP.js → AnalyticsDashboard-DM8YmJuy.js} +1 -1
  2. package/dist/assets/{AudienceMemoryPanel-di7dxMBb.js → AudienceMemoryPanel-BN1qR1rz.js} +1 -1
  3. package/dist/assets/{ChangesView-DPfs8VeV.js → ChangesView-PgFw9vKk.js} +1 -1
  4. package/dist/assets/{ChronicleDashboard-CMkQ7EBt.js → ChronicleDashboard-CtOiFCYV.js} +1 -1
  5. package/dist/assets/{CodeEditor-iYG6Q0ag.js → CodeEditor-B_KwrAhN.js} +1 -1
  6. package/dist/assets/{CronJobsPanel-CKQw0vat.js → CronJobsPanel-CVXW2Y-n.js} +1 -1
  7. package/dist/assets/{DebugDashboard-BeDOPYmE.js → DebugDashboard-BldwPA32.js} +1 -1
  8. package/dist/assets/{DesignGalleryView-DY3atfBB.js → DesignGalleryView-CUi5RBHH.js} +1 -1
  9. package/dist/assets/{GoalView-Dh27cG1z.js → GoalView-p7f1544B.js} +1 -1
  10. package/dist/assets/{KanbanView-DYa0iSlV.js → KanbanView-CD_x5YND.js} +1 -1
  11. package/dist/assets/{MemoryManager-D1_0SW_m.js → MemoryManager-BrCVqIJK.js} +1 -1
  12. package/dist/assets/{OfficeMapPanel-DTQPdV7a.js → OfficeMapPanel-D01rqjLt.js} +1 -1
  13. package/dist/assets/{SddHub-BW7ExYNe.js → SddHub-DLVIXlN6.js} +1 -1
  14. package/dist/assets/{SessionsDashboard-Cf_67b9g.js → SessionsDashboard-DsAc_Sx2.js} +1 -1
  15. package/dist/assets/{SetupScreen-fu9Qr5Qj.js → SetupScreen-KqV61-Ir.js} +1 -1
  16. package/dist/assets/{SkillDetailView-DHcDX_1A.js → SkillDetailView-CK7MB8Uo.js} +1 -1
  17. package/dist/assets/{TechStackView-CXE80hAc.js → TechStackView-nVNj4kWJ.js} +1 -1
  18. package/dist/assets/{index-BlCmdyyZ.css → index-BwEOo8R-.css} +1 -1
  19. package/dist/assets/{index-BLAy5CKD.js → index-Du90vd1u.js} +3 -3
  20. package/dist/index.html +2 -2
  21. package/dist/index.js +5 -5
  22. package/dist/index.js.map +2 -2
  23. package/package.json +6 -6
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ProcessMonitor-DjO7eNsN.js","assets/rolldown-runtime-QTnfLwEv.js","assets/vendor-Di1mdAi5.js","assets/monaco-C7izDJhg.js","assets/monaco-Br_kD0ds.css","assets/markdown-L6DLSM7f.js","assets/vendor-BMdWcCR4.css","assets/i18n-DaR2GB_4.js","assets/ui-store-BepZz9CZ.js","assets/activity-Cyx4UukM.js","assets/chat-BJzPxfyr.js","assets/commandPalette-DpaemFux.js","assets/common-suUxW9sA.js","assets/settings-CyzkAhwD.js","assets/setup-Dr2UDb8s.js","assets/toasts-BL_8kH4B.js","assets/useWebSocket-CRYUFxmO.js","assets/chat-store-Cunk1nDr.js","assets/utils-C4qVQ63O.js","assets/ws-client-BWO_PH_X.js","assets/session-store-B8icONBU.js","assets/codemap-activity-store-BIW6YPvC.js","assets/stores-JSLvWOQY.js","assets/mailbox-store-Dq1wxCRt.js","assets/view-navigation-BbHlzAQz.js","assets/Toaster-B1idXZ-O.js","assets/dialog-CNwwBFw3.js","assets/AnalyticsDashboard-DausPJOP.js","assets/pagination-Ktuov5iD.js","assets/CodeMap-T1dsXVRH.js","assets/ChronicleDashboard-CMkQ7EBt.js","assets/GoalView-Dh27cG1z.js","assets/button-99L74zdE.js","assets/ConfirmModal-Bm9f2Pg9.js","assets/input-DXjUO_X9.js","assets/ChangesView-DPfs8VeV.js","assets/monaco-theme-BoNOJHQB.js","assets/CronJobsPanel-CKQw0vat.js","assets/CodeEditor-iYG6Q0ag.js","assets/DebugDashboard-BeDOPYmE.js","assets/DesignGalleryView-DY3atfBB.js","assets/MailboxDetailView-DQpxIh_A.js","assets/LazyMarkdown-C1a0wbAZ.js","assets/MemoryManager-D1_0SW_m.js","assets/shared-aSCYBzAV.js","assets/AudienceMemoryPanel-di7dxMBb.js","assets/KanbanView-DYa0iSlV.js","assets/ModelPicker-Cwa4UKNc.js","assets/OfficeMapPanel-DTQPdV7a.js","assets/OfficeMapPanel-B0j4e2O1.css","assets/QueuePanel-lUChp6xi.js","assets/RefreshDebugView-BNa6ehdH.js","assets/SddHub-BW7ExYNe.js","assets/SpecsView-CNqNOKqo.js","assets/SessionsDashboard-Cf_67b9g.js","assets/SetupScreen-fu9Qr5Qj.js","assets/SkillDetailView-DHcDX_1A.js","assets/TechStackView-CXE80hAc.js","assets/TerminalPanel-KysALyRz.js","assets/xterm-DUBp1lnG.js","assets/xterm-BrP-ENHg.css"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ProcessMonitor-DjO7eNsN.js","assets/rolldown-runtime-QTnfLwEv.js","assets/vendor-Di1mdAi5.js","assets/monaco-C7izDJhg.js","assets/monaco-Br_kD0ds.css","assets/markdown-L6DLSM7f.js","assets/vendor-BMdWcCR4.css","assets/i18n-DaR2GB_4.js","assets/ui-store-BepZz9CZ.js","assets/activity-Cyx4UukM.js","assets/chat-BJzPxfyr.js","assets/commandPalette-DpaemFux.js","assets/common-suUxW9sA.js","assets/settings-CyzkAhwD.js","assets/setup-Dr2UDb8s.js","assets/toasts-BL_8kH4B.js","assets/useWebSocket-CRYUFxmO.js","assets/chat-store-Cunk1nDr.js","assets/utils-C4qVQ63O.js","assets/ws-client-BWO_PH_X.js","assets/session-store-B8icONBU.js","assets/codemap-activity-store-BIW6YPvC.js","assets/stores-JSLvWOQY.js","assets/mailbox-store-Dq1wxCRt.js","assets/view-navigation-BbHlzAQz.js","assets/Toaster-B1idXZ-O.js","assets/dialog-CNwwBFw3.js","assets/AnalyticsDashboard-DM8YmJuy.js","assets/pagination-Ktuov5iD.js","assets/CodeMap-T1dsXVRH.js","assets/ChronicleDashboard-CtOiFCYV.js","assets/GoalView-p7f1544B.js","assets/button-99L74zdE.js","assets/ConfirmModal-Bm9f2Pg9.js","assets/input-DXjUO_X9.js","assets/ChangesView-PgFw9vKk.js","assets/monaco-theme-BoNOJHQB.js","assets/CronJobsPanel-CVXW2Y-n.js","assets/CodeEditor-B_KwrAhN.js","assets/DebugDashboard-BldwPA32.js","assets/DesignGalleryView-CUi5RBHH.js","assets/MailboxDetailView-DQpxIh_A.js","assets/LazyMarkdown-C1a0wbAZ.js","assets/MemoryManager-BrCVqIJK.js","assets/shared-aSCYBzAV.js","assets/AudienceMemoryPanel-BN1qR1rz.js","assets/KanbanView-CD_x5YND.js","assets/ModelPicker-Cwa4UKNc.js","assets/OfficeMapPanel-D01rqjLt.js","assets/OfficeMapPanel-B0j4e2O1.css","assets/QueuePanel-lUChp6xi.js","assets/RefreshDebugView-BNa6ehdH.js","assets/SddHub-DLVIXlN6.js","assets/SpecsView-CNqNOKqo.js","assets/SessionsDashboard-DsAc_Sx2.js","assets/SetupScreen-KqV61-Ir.js","assets/SkillDetailView-CK7MB8Uo.js","assets/TechStackView-nVNj4kWJ.js","assets/TerminalPanel-KysALyRz.js","assets/xterm-DUBp1lnG.js","assets/xterm-BrP-ENHg.css"])))=>i.map(i=>d[i]);
2
2
  import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,n,o as r,t as i}from"./chat-store-Cunk1nDr.js";import{$ as a,$n as o,$r as s,$t as c,A as l,Ai as u,An as d,Ar as f,At as p,B as m,Bi as h,Bn as g,Br as _,Bt as v,C as y,Ci as b,Cn as x,Cr as S,Ct as C,D as w,Di as T,Dn as E,Dr as D,E as O,Ei as k,En as A,Er as j,Et as M,F as N,Fn as P,Ft as ee,G as te,Gi as F,Gn as I,Gr as ne,Gt as re,H as L,Hi as ie,Hn as ae,Hr as R,Ht as z,I as oe,Ii as se,In as ce,Ir as le,It as ue,J as de,Jn as fe,Jt as pe,K as me,Ki as he,Kn as ge,Kt as _e,L as ve,Ln as ye,Lr as B,Lt as be,M as xe,Mn as Se,Mr as Ce,Mt as we,N as Te,Ni as Ee,Nr as De,O as Oe,Oi as ke,On as Ae,Or as je,Ot as Me,P as Ne,Pi as Pe,Pn as Fe,Q as Ie,Qn as Le,Qr as Re,Qt as ze,R as Be,Ri as Ve,Rn as He,Rr as Ue,Rt as We,Sr as Ge,St as Ke,T as qe,Ti as Je,Tn as Ye,Tr as Xe,Tt as Ze,U as Qe,Ui as $e,Un as et,Ur as tt,V as nt,Vi as rt,Vr as it,Vt as at,W as ot,Wi as st,Wr as ct,Wt as lt,X as ut,Xi as dt,Xn as ft,Xr as pt,Y as mt,Yr as ht,Z as gt,Zi as _t,Zn as vt,Zr as yt,_i as bt,_t as xt,aa as St,ai as Ct,an as wt,at as Tt,bi as Et,bn as Dt,br as Ot,bt as kt,ci as At,cn as jt,cr as Mt,ct as Nt,di as Pt,dn as Ft,dr as It,dt as Lt,ea as V,ei as Rt,en as zt,er as Bt,fi as Vt,fn as Ht,fr as Ut,ft as Wt,gi as Gt,gn as Kt,hi as qt,hr as Jt,ht as Yt,ia as Xt,ii as Zt,ir as Qt,it as $t,j as en,ji as tn,jn as nn,jt as rn,k as an,ki as on,kn as sn,kr as cn,kt as ln,li as un,ln as dn,lr as fn,lt as pn,mn,mt as hn,on as gn,or as _n,ot as vn,pn as yn,pr as bn,pt as xn,q as Sn,qi as Cn,qr as wn,qt as Tn,ra as H,ri as En,rn as Dn,rr as On,si as kn,sn as An,sr as jn,st as Mn,ti as Nn,tn as Pn,tr as Fn,tt as In,un as Ln,ur as Rn,ut as zn,vi as Bn,vn as Vn,vr as Hn,w as Un,wi as Wn,wt as Gn,xi as Kn,xn as qn,xt as Jn,yi as Yn,yn as Xn,yr as Zn,z as Qn,zn as $n}from"./vendor-Di1mdAi5.js";import"./i18n-DaR2GB_4.js";import{i as er,n as U,r as W,t as tr}from"./ui-store-BepZz9CZ.js";import{s as nr}from"./monaco-C7izDJhg.js";import{a as rr,c as ir,i as ar,l as or,n as sr,o as cr,r as lr,s as ur,t as dr}from"./useWebSocket-CRYUFxmO.js";import{l as fr,t as pr}from"./ws-client-BWO_PH_X.js";import{t as G}from"./utils-C4qVQ63O.js";import{t as K}from"./session-store-B8icONBU.js";import{C as mr,D as hr,E as gr,O as _r,S as vr,T as yr,_ as br,b as xr,c as Sr,d as Cr,f as wr,g as Tr,h as Er,i as Dr,j as q,k as Or,l as kr,m as Ar,p as jr,s as Mr,t as Nr,v as Pr,w as Fr,x as Ir,y as Lr}from"./stores-JSLvWOQY.js";import{n as Rr,r as zr,t as Br}from"./mailbox-store-Dq1wxCRt.js";import{a as Vr,i as Hr,n as Ur,o as Wr,r as Gr,s as J,t as Kr}from"./view-navigation-BbHlzAQz.js";import{n as Y,t as qr}from"./Toaster-B1idXZ-O.js";import{a as Jr,i as Yr,n as Xr,o as Zr,r as Qr,t as $r}from"./dialog-CNwwBFw3.js";import{n as ei,t as ti}from"./ModelPicker-Cwa4UKNc.js";import{t as X}from"./button-99L74zdE.js";import{t as ni}from"./pagination-Ktuov5iD.js";import{f as ri}from"./markdown-L6DLSM7f.js";import{a as ii,c as ai,i as oi,n as si,o as ci,r as li,s as ui,t as di}from"./LazyMarkdown-C1a0wbAZ.js";import{t as fi}from"./input-DXjUO_X9.js";import{n as pi,r as mi,t as hi}from"./ConfirmModal-Bm9f2Pg9.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Z=e(St(),1),gi=e(Xt(),1),_i=new Set([`chat`,`settings`,`goal`,`kanban`,`sddhub`,`files`,`changes`,`sessions`,`setup`,`skill`,`officemap`,`mailbox`,`debug`,`design-gallery`,`refresh-debug`,`analytics`]),vi=new Set([`goal`,`fleet`,`work`,`worktrees`,`collab`]),yi=new Set([`todos`,`tasks`,`plan`]);function bi(){if(typeof window>`u`)return;let e=window.wrongstackDesktopHost;if(!e?.setPrefs)return;let t=W.getState();e.setPrefs({yolo:t.yolo,nextPrediction:t.nextPrediction,contextAutoCompact:t.contextAutoCompact})}function xi(e){typeof window>`u`||window.wrongstackDesktopHost?.setReady?.(e)}function Si(e,t,n){typeof window>`u`||typeof e!=`string`||window.wrongstackDesktopHost?.ackCommand?.(e,t,n)}var Q=In(),Ci=(0,Z.createContext)(void 0);function wi({children:e,defaultTheme:t=`system`,storageKey:n=`wrongstack-theme`}){let r=q(e=>e.setTheme),[i,a]=(0,Z.useState)(()=>typeof window<`u`&&localStorage.getItem(n)||t);(0,Z.useEffect)(()=>{let e=window.document.documentElement;if(e.classList.remove(`light`,`dark`),i===`system`){let t=window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`;e.classList.add(t)}else e.classList.add(i)},[i]);let o={theme:i,setTheme:e=>{localStorage.setItem(n,e),a(e),r(e)}};return(0,Q.jsx)(Ci.Provider,{value:o,children:e})}function Ti(){let e=(0,Z.useContext)(Ci);if(e===void 0)throw Error(`useTheme must be used within a ThemeProvider`);return e}var Ei=mt,Di=a,Oi=Sn,ki=Z.forwardRef(({className:e,inset:t,children:n,...r},i)=>(0,Q.jsxs)(Ie,{ref:i,className:G(`flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent`,t&&`pl-8`,e),...r,children:[n,(0,Q.jsx)(Kn,{className:`ml-auto h-4 w-4`})]}));ki.displayName=Ie.displayName;var Ai=Z.forwardRef(({className:e,...t},n)=>(0,Q.jsx)(gt,{ref:n,className:G(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...t}));Ai.displayName=gt.displayName;var ji=Z.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,Q.jsx)(me,{children:(0,Q.jsx)(L,{ref:r,sideOffset:t,className:G(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...n})}));ji.displayName=L.displayName;var Mi=Z.forwardRef(({className:e,inset:t,...n},r)=>(0,Q.jsx)(Qe,{ref:r,className:G(`relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0`,t&&`pl-8`,e),...n}));Mi.displayName=Qe.displayName;var Ni=Z.forwardRef(({className:e,children:t,checked:n,...r},i)=>(0,Q.jsxs)(nt,{ref:i,className:G(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,e),checked:n,...r,children:[(0,Q.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,Q.jsx)(ot,{children:(0,Q.jsx)(Wn,{className:`h-4 w-4`})})}),t]}));Ni.displayName=nt.displayName;var Pi=Z.forwardRef(({className:e,children:t,...n},r)=>(0,Q.jsxs)(de,{ref:r,className:G(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,e),...n,children:[(0,Q.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,Q.jsx)(ot,{children:(0,Q.jsx)(At,{className:`h-2 w-2 fill-current`})})}),t]}));Pi.displayName=de.displayName;var Fi=Z.forwardRef(({className:e,inset:t,...n},r)=>(0,Q.jsx)(te,{ref:r,className:G(`px-2 py-1.5 text-sm font-semibold`,t&&`pl-8`,e),...n}));Fi.displayName=te.displayName;var Ii=Z.forwardRef(({className:e,...t},n)=>(0,Q.jsx)(ut,{ref:n,className:G(`-mx-1 my-1 h-px bg-muted`,e),...t}));Ii.displayName=ut.displayName;var Li=({className:e,...t})=>(0,Q.jsx)(`span`,{className:G(`ml-auto text-xs tracking-widest opacity-60`,e),...t});Li.displayName=`DropdownMenuShortcut`;var Ri=[{id:`chat`,icon:(0,Q.jsx)(d,{size:16}),label:`Session`},{id:`agents`,icon:(0,Q.jsx)(Ee,{size:16}),label:`Agents`},{id:`history`,icon:(0,Q.jsx)(Zt,{size:16}),label:`History`},{id:`files`,icon:(0,Q.jsx)(Ge,{size:16}),label:`Files`},{id:`changes`,icon:(0,Q.jsx)(Ut,{size:16}),label:`Changes`},{id:`mailbox`,icon:(0,Q.jsx)(P,{size:16}),label:`Mailbox`},{id:`skills`,icon:(0,Q.jsx)(ee,{size:16}),label:`Skills`},{id:`worktrees`,icon:(0,Q.jsx)(bn,{size:16}),label:`Worktrees`},{id:`design`,icon:(0,Q.jsx)(Dt,{size:16}),label:`Design Studio`},{id:`officemap`,icon:(0,Q.jsx)(T,{size:16}),label:`Office Map`}],zi=[{id:`sddhub`,icon:(0,Q.jsx)(zn,{size:16}),label:`SDD`},{id:`kanban`,icon:(0,Q.jsx)(Nn,{size:16}),label:`Kanban`},{id:`goal`,icon:(0,Q.jsx)(zt,{size:16}),label:`Goal`},{id:`codemap`,icon:(0,Q.jsx)(x,{size:16}),label:`CodeMap`},{id:`techstack`,icon:(0,Q.jsx)(tn,{size:16}),label:`TechStack`},{id:`chronicle`,icon:(0,Q.jsx)(Je,{size:16}),label:`Chronicle`},{id:`settings`,icon:(0,Q.jsx)(lt,{size:16}),label:`Settings`},{id:`memory`,icon:(0,Q.jsx)(u,{size:16}),label:`Memory`}],Bi=[`chat`,`agents`,`files`,`changes`,`mailbox`],Vi=[...Bi,`history`,`skills`,`worktrees`,`officemap`,`design`],Hi=132,Ui=38;function Wi(e){let t=Ri.length+zi.length,n=Math.floor(((Number.isFinite(e)?e:720)-Hi)/Ui);return Math.max(Bi.length,Math.min(t,n))}function Gi(e){let t=Ri.length+zi.length,n=Math.max(Bi.length,Math.min(t,Math.floor(e))),r=Math.min(Ri.length,n),i=new Set(Vi.slice(0,r)),a=Ri.map(e=>e.id).filter(e=>i.has(e)),o=Ri.map(e=>e.id).filter(e=>!i.has(e)),s=Math.max(0,n-a.length),c=zi.slice(0,s).map(e=>e.id),l=new Set(c);return{visiblePanelIds:a,overflowPanelIds:o,visibleViewIds:c,overflowViewIds:zi.map(e=>e.id).filter(e=>!l.has(e))}}var Ki=Ri.map(e=>e.id);function qi(){return typeof window>`u`?720:window.visualViewport?.height??window.innerHeight}function Ji(e){let[t,n]=(0,Z.useState)(qi);return(0,Z.useEffect)(()=>{if(!e||typeof window>`u`)return;let t=()=>n(qi());return t(),window.addEventListener(`resize`,t),window.visualViewport?.addEventListener(`resize`,t),()=>{window.removeEventListener(`resize`,t),window.visualViewport?.removeEventListener(`resize`,t)}},[e]),e?Wi(t):Ri.length+zi.length}function Yi({desktopShell:e=!1}){let t=U(e=>e.activeActivity),n=U(e=>e.sidebarOpen),r=U(e=>e.currentView),i=K(e=>e.projectName),a=K(e=>e.cwd),o=q(e=>e.wsConnected),{t:s}=V(),c=(e,t)=>s(`activity:nav.${e}`,t),l=xr(e=>Array.from(e.agents.values()).filter(e=>e.status===`running`).length),u=zr(Rr),d=U(e=>e.inspectorOpen);U(e=>e.inspectorTab);let f=Ji(e),p=(0,Z.useMemo)(()=>Gi(f),[f]),m=(0,Z.useMemo)(()=>new Set(p.visiblePanelIds),[p.visiblePanelIds]),h=(0,Z.useMemo)(()=>new Set(p.overflowPanelIds),[p.overflowPanelIds]),g=(0,Z.useMemo)(()=>new Set(p.visibleViewIds),[p.visibleViewIds]),_=(0,Z.useMemo)(()=>new Set(p.overflowViewIds),[p.overflowViewIds]),v=e?Ri.filter(e=>m.has(e.id)):Ri,y=e?Ri.filter(e=>h.has(e.id)):[],b=e?zi.filter(e=>g.has(e.id)):zi,x=e?zi.filter(e=>_.has(e.id)):[],S=e=>{if(e===`agents`)return l||void 0;if(e===`mailbox`)return u||void 0};return(0,Q.jsxs)(`div`,{className:G(`flex h-full min-h-0 shrink-0 flex-col border-r border-border/70 bg-card/75 backdrop-blur-xl`,e?`w-10`:`w-12`),children:[(0,Q.jsxs)(`div`,{className:G(`flex flex-col items-center border-b border-border/60 shrink-0`,e?`pt-2 pb-1.5`:`pt-2.5 pb-2`),children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{J(`chat`)},title:i?s(`activity:brand.returnToChat`,{name:i}):s(`activity:brand.returnToChatDefault`),className:G(`relative flex items-center justify-center overflow-hidden border border-border/70 bg-[#121210] shadow-[0_2px_8px_-2px_hsl(var(--shadow-color)/0.5)] transition-shadow hover:shadow-[0_3px_12px_-2px_hsl(var(--primary)/0.5)]`,e?`w-7 h-7`:`w-8 h-8`),children:(0,Q.jsx)(`img`,{src:`/wrongstack.svg`,alt:``,"aria-hidden":`true`,draggable:!1,className:`ws-brand-logo h-full w-full`})}),!e&&(0,Q.jsx)(`span`,{className:`mt-1.5 w-10 truncate text-center text-[8px] font-semibold leading-tight text-muted-foreground`,title:a||i||`WrongStack`,children:i||`WS`}),(0,Q.jsx)(`span`,{className:G(`inline-block w-1.5 h-1.5 rounded-full`,e?`mt-1.5`:`mt-1`,o?`bg-success shadow-[0_0_4px_hsl(var(--success)/0.6)]`:`bg-warning`),title:s(o?`activity:status.connected`:`activity:status.disconnected`)})]}),(0,Q.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto no-scrollbar flex flex-col items-center pt-2 pb-1`,children:[v.map(r=>(0,Q.jsx)(Zi,{compact:e,icon:r.icon,label:`${c(r.id,r.label)} (${Wr(r.id)})`,active:n&&t===r.id,badge:S(r.id),onClick:()=>Hr(r.id)},r.id)),b.length>0&&(0,Q.jsx)(`div`,{className:`my-1.5 h-px w-6 shrink-0 bg-border/70`}),b.map(t=>(0,Q.jsx)(Zi,{compact:e,icon:t.icon,label:c(t.id,t.label),active:r===t.id,onClick:()=>Gr(t.id)},t.id))]}),(0,Q.jsx)(`div`,{className:`flex flex-col items-center shrink-0 pt-1 pb-2 border-t border-border/60`,children:(0,Q.jsx)(Xi,{compact:e,monitorOpen:d,overflowPanels:y,overflowViews:x})})]})}function Xi({compact:e=!1,monitorOpen:t,overflowPanels:n,overflowViews:r}){let{theme:i,setTheme:a}=Ti(),{t:o}=V(),s=U(e=>e.activeActivity),c=U(e=>e.sidebarOpen),l=U(e=>e.currentView),u=U(e=>e.inspectorOpen),d=U(e=>e.inspectorTab),f=n.length+r.length,p=n.some(e=>c&&s===e.id),m=r.some(e=>l===e.id),h=p||m,g=e=>{let t=U.getState();t.inspectorOpen&&t.inspectorTab===e?t.setInspectorOpen(!1):(t.setInspectorTab(e),t.setInspectorOpen(!0))};return(0,Q.jsxs)(Ei,{children:[(0,Q.jsx)(Di,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"aria-label":f>0?o(`activity:menu.moreWithHidden`,{count:f}):o(`activity:menu.moreOptions`),title:e&&f>0?o(`activity:menu.moreCompactHidden`,{count:f}):o(e?`activity:menu.moreCompact`:`activity:menu.moreFull`),className:G(`ws-nav-button relative flex items-center justify-center rounded-md transition-colors`,e?`h-9 w-9`:`h-11 w-11`,`text-muted-foreground hover:border-border/70 hover:text-foreground hover:bg-muted/60`,`data-[state=open]:text-primary data-[state=open]:bg-primary/10 data-[state=open]:border-primary/30`,(t||h)&&`text-primary`),children:[(0,Q.jsx)(`span`,{className:`h-5 w-5 flex items-center justify-center`,children:(0,Q.jsx)(ne,{size:16})}),f>0&&(0,Q.jsx)(`span`,{className:G(`absolute -top-0.5 -right-0.5 min-w-[15px] h-[15px] flex items-center justify-center rounded px-1 text-[8px] font-bold leading-none tabular`,h?`bg-primary text-primary-foreground`:`bg-muted-foreground text-background`),children:f>9?`9+`:f}),t&&f===0&&(0,Q.jsx)(`span`,{className:`absolute top-1 right-1 w-1.5 h-1.5 rounded-full bg-primary`})]})}),(0,Q.jsxs)(ji,{side:`right`,align:`end`,sideOffset:8,className:`w-56`,children:[(0,Q.jsxs)(Mi,{onSelect:()=>U.getState().setPaletteOpen(!0),children:[(0,Q.jsx)(Rt,{size:16}),(0,Q.jsx)(`span`,{children:o(`activity:menu.commandPalette`)}),(0,Q.jsx)(Li,{children:`⌘K`})]}),(0,Q.jsxs)(Mi,{onSelect:()=>U.getState().setShortcutsOpen(!0),children:[(0,Q.jsx)(Le,{size:16}),(0,Q.jsx)(`span`,{children:o(`activity:menu.keyboardShortcuts`)}),(0,Q.jsx)(Li,{children:`?`})]}),n.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Ii,{}),(0,Q.jsx)(Fi,{className:`text-[11px] uppercase text-muted-foreground`,children:o(`activity:menu.panels`)}),n.map(e=>(0,Q.jsxs)(Mi,{onSelect:()=>J(e.id),children:[e.icon,(0,Q.jsx)(`span`,{children:o(`activity:nav.${e.id}`,e.label)}),c&&s===e.id?(0,Q.jsx)(`span`,{className:`ml-auto w-1.5 h-1.5 rounded-full bg-primary`}):(0,Q.jsx)(Li,{children:Wr(e.id)})]},e.id))]}),r.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Ii,{}),(0,Q.jsx)(Fi,{className:`text-[11px] uppercase text-muted-foreground`,children:o(`activity:menu.views`)}),r.map(e=>(0,Q.jsxs)(Mi,{onSelect:()=>Gr(e.id),children:[e.icon,(0,Q.jsx)(`span`,{children:o(`activity:nav.${e.id}`,e.label)}),l===e.id&&(0,Q.jsx)(`span`,{className:`ml-auto w-1.5 h-1.5 rounded-full bg-primary`})]},e.id))]}),(0,Q.jsx)(Ii,{}),(0,Q.jsx)(Fi,{className:`text-[11px] uppercase text-muted-foreground`,children:o(`activity:menu.theme`)}),(0,Q.jsxs)(Oi,{value:i,onValueChange:e=>a(e),children:[(0,Q.jsxs)(Pi,{value:`light`,children:[(0,Q.jsx)(ln,{size:16,className:`mr-2`}),o(`settings:appearance.themeLight`)]}),(0,Q.jsxs)(Pi,{value:`dark`,children:[(0,Q.jsx)(A,{size:16,className:`mr-2`}),o(`settings:appearance.themeDark`)]}),(0,Q.jsxs)(Pi,{value:`system`,children:[(0,Q.jsx)(E,{size:16,className:`mr-2`}),o(`settings:appearance.themeSystem`)]})]}),(0,Q.jsx)(Ii,{}),(0,Q.jsx)(Fi,{className:`text-[11px] uppercase text-muted-foreground`,children:o(`activity:menu.monitors`)}),(0,Q.jsxs)(Mi,{onSelect:()=>g(`fleet`),children:[(0,Q.jsx)(ft,{size:16}),(0,Q.jsx)(`span`,{children:o(`activity:menu.fleetMonitor`)}),u&&d===`fleet`?(0,Q.jsx)(`span`,{className:`ml-auto w-1.5 h-1.5 rounded-full bg-primary`}):(0,Q.jsx)(Li,{children:`⇧⌘M`})]}),(0,Q.jsxs)(Mi,{onSelect:()=>g(`sideEffects`),children:[(0,Q.jsx)(Tt,{size:16}),(0,Q.jsx)(`span`,{children:o(`activity:inspector.tabAudit`)}),u&&d===`sideEffects`?(0,Q.jsx)(`span`,{className:`ml-auto h-1.5 w-1.5 bg-primary`}):null]})]})]})}function Zi({compact:e=!1,icon:t,label:n,active:r,badge:i,onClick:a}){return(0,Q.jsxs)(`button`,{type:`button`,onClick:a,"aria-label":n,title:n,className:G(`ws-nav-button relative flex shrink-0 items-center justify-center rounded-md transition-colors`,e?`h-9 w-9`:`h-11 w-11`,`text-muted-foreground hover:border-border/70 hover:text-foreground hover:bg-muted/60`,r&&`ws-nav-button-active`),children:[r&&(0,Q.jsx)(`span`,{className:`absolute left-0 top-1/2 -translate-y-1/2 w-0.5 h-6 rounded-r-full bg-primary`}),(0,Q.jsx)(`span`,{className:`h-5 w-5 shrink-0`,children:t}),i!==void 0&&i>0&&(0,Q.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 min-w-[15px] h-[15px] flex items-center justify-center rounded bg-primary text-[8px] font-bold text-primary-foreground leading-none px-1 tabular`,children:i>99?`99+`:i})]})}var Qi=[{name:`/new`,category:`Session`,description:`Start a brand-new session (fresh on disk and in memory)`},{name:`/clear`,category:`Session`,description:`Wipe current context (keeps session id, disk record stays)`},{name:`/compact`,category:`Session`,description:`Shrink context — elide ancient tool output`},{name:`/compact!`,category:`Session`,description:`Aggressively shrink context now`},{name:`/repair`,category:`Session`,description:`Repair orphan tool-use / tool-result protocol blocks`},{name:`/save`,category:`Session`,description:`Force-flush the session (auto-saved already)`},{name:`/load`,category:`Session`,aliases:[`/resume`],description:`Resume a previous session from disk`},{name:`/export`,category:`Session`,description:`Download the current chat as markdown`},{name:`/debug`,category:`Inspect`,aliases:[`/context`],description:`Context size breakdown per section`},{name:`/tools`,category:`Inspect`,description:`List every registered tool the model can call`},{name:`/memory`,category:`Inspect`,description:`Manage memory: show, remember, forget, clear, stats`},{name:`/todos`,category:`Inspect`,description:`List current todos`},{name:`/stats`,category:`Inspect`,description:`Session stats: tokens, cost, elapsed`},{name:`/skill`,category:`Inspect`,aliases:[`/skills`],description:`List active skills`},{name:`/prompt`,category:`Inspect`,aliases:[`/prompts`],description:`Browse & insert prompts from the library`},{name:`/diag`,category:`Inspect`,description:`Runtime diagnostics (provider, tools, mode, usage)`},{name:`/agents`,category:`Inspect`,description:`Show status of spawned subagents`},{name:`/brain`,category:`Inspect`,description:`Brain status, risk ceiling (risk <level>), or decision support (ask <question>)`},{name:`/plan`,category:`Inspect`,description:`Strategic plan board: show, add, start, done, promote, clear`},{name:`/suggest`,category:`Inspect`,aliases:[`/next-steps`],description:`Ask the agent for concrete next steps`},{name:`/next`,category:`Inspect`,aliases:[`/enxt`],description:`Show or run numbered next-step suggestions`},{name:`/review`,category:`Agent`,aliases:[`/cr`],description:`Ask the agent to review the pending changes (optional focus)`},{name:`/fix`,category:`Agent`,description:`Diagnose and fix an error (paste it) or the latest failure`},{name:`/autonomy`,category:`Agent`,description:`Switch self-driving mode: off | suggest | auto | eternal | eternal-parallel`},{name:`/goal`,category:`Agent`,description:`Goal: start <title> | pause | resume | stop | status`},{name:`/goal-state`,category:`Agent`,description:`Show the current goal state (opens the Goal State dock chip)`},{name:`/fleet`,category:`Agent`,description:`Open the Fleet orchestration monitor`},{name:`/terminal`,category:`App`,aliases:[`/term`],description:"Open the integrated terminal (Ctrl+`)"},{name:`/collab`,category:`Agent`,description:`Open the live collaboration panel`},{name:`/worktree`,category:`Agent`,aliases:[`/worktrees`],description:`Open the worktree view`},{name:`/mode`,category:`Agent`,description:`Switch session mode (no arg lists available modes)`},{name:`/mcp`,category:`Agent`,description:`Open MCP server settings and refresh the server list`},{name:`/working-dir`,category:`Agent`,aliases:[`/cwd`],description:`Show or change the working directory`},{name:`/settings`,category:`Config`,aliases:[`/model`],description:`Open settings (provider/model/keys)`},{name:`/setup`,category:`Config`,description:`Open the provider setup screen to add or change API keys`},{name:`/enhance`,category:`Config`,description:`Toggle prompt refinement before sending`},{name:`/interrupt`,category:`Run`,aliases:[`/abort`,`/stop`,`/int`],description:`Stop the current run (abort the in-flight request)`},{name:`/help`,category:`App`,description:`Show every slash command and what it does`},{name:`/exit`,category:`App`,description:`Exit the session and close WebUI`},{name:`/f`,category:`App`,description:`Open F-key panels (F1–F12). Type /f for numbered options.`},{name:`/f1`,category:`App`,description:`Session panel`,hidden:!0},{name:`/f2`,category:`App`,description:`Fleet orchestration monitor`,hidden:!0},{name:`/f3`,category:`App`,description:`Agents live monitor`,hidden:!0},{name:`/f4`,category:`App`,description:`Worktree monitor`,hidden:!0},{name:`/f5`,category:`App`,description:`Plan panel`,hidden:!0},{name:`/f6`,category:`App`,description:`Todos monitor overlay`,hidden:!0},{name:`/f7`,category:`App`,description:`Queue panel`,hidden:!0},{name:`/f8`,category:`App`,description:`Process list overlay`,hidden:!0},{name:`/f9`,category:`App`,description:`Goal panel`,hidden:!0},{name:`/f10`,category:`App`,description:`Live sessions panel`,hidden:!0},{name:`/f11`,category:`App`,description:`Coordinator monitor`,hidden:!0},{name:`/f12`,category:`App`,description:`Status line picker`,hidden:!0}],$i=[`Run`,`Session`,`Inspect`,`Agent`,`Config`,`App`];function ea(e){let t=e.toLowerCase();return t===`/`||t===``?Qi.filter(e=>!e.hidden):Qi.filter(e=>e.name.startsWith(t)||(e.aliases?.some(e=>e.startsWith(t))??!1))}function ta(e,n){let r=n-1;for(;r>=0;){let i=t(e[r]);if(i===`@`){let t=r>0?e[r-1]:``;return r===0||/\s/.test(t??``)?{start:r,query:e.slice(r+1,n)}:null}if(/\s/.test(i))return null;r--}return null}function na(e){let{raw:t,addMessage:n,clearMessages:r,client:i,queue:a,sendAbort:o,sendMsg:s,setLoading:c,toggleRefineEnabled:l,setProcessMonitorOpen:u,setQueuePanelOpen:d,ws:f,onOpenBreakdown:p,handleNextList:m,handleNextSelect:h}=e,g=t.trim(),_=g.indexOf(` `),v=(_===-1?g:g.slice(0,_)).toLowerCase(),y=_===-1?``:g.slice(_+1).trim(),b=v,x=e=>{let t=U.getState();J(`chat`),t.setDockSection(`work`),t.setWorkDashboardTab(e)};switch(b){case`/help`:return n({role:`assistant`,content:[`📖 **Slash commands**`,``,...Qi.map(e=>`• \`${e.name}\`${e.aliases?.length?` (${e.aliases.map(e=>`\`${e}\``).join(`, `)})`:``} — ${e.description}`)].join(`
3
3
  `)}),!0;case`/clear`:return fr.dropAll(),r(),i?.clearContext?.(),!0;case`/new`:return i?.newSession?.(),J(`chat`),!0;case`/exit`:return i?.send?.({type:`webui.shutdown`}),n({role:`assistant`,content:`👋 Shutting down WebUI server…`}),!0;case`/compact`:case`/compact!`:return i?.compactContext?.(b===`/compact!`),!0;case`/repair`:return i?.repairContext?.(),!0;case`/debug`:case`/context`:return p?.(),!0;case`/tools`:return f.listTools(),!0;case`/memory`:return Gr(`memory`),!0;case`/skill`:case`/skills`:return f.listSkills(),!0;case`/prompt`:case`/prompts`:return U.getState().setPromptLibraryOpen(!0),!0;case`/diag`:return f.getDiag(),!0;case`/stats`:return f.getStats(),!0;case`/save`:return f.saveSession(),!0;case`/load`:case`/resume`:return f.listSessions(50),J(`history`),!0;case`/agents`:return U.getState().setAgentsMonitorOpen(!0),!0;case`/autonomy`:{let e=y.trim().toLowerCase(),t=[`off`,`suggest`,`auto`,`eternal`,`eternal-parallel`];return e?t.includes(e)?(i?.send?.({type:`autonomy.switch`,payload:{mode:e}}),n({role:`assistant`,content:`🤖 Autonomy mode → **${e}**.`}),!0):(n({role:`assistant`,content:`Unknown autonomy mode \`${e}\`. Try: ${t.join(`, `)}.`}),!0):(n({role:`assistant`,content:`Usage: \`/autonomy <mode>\` — one of: ${t.map(e=>`\`${e}\``).join(`, `)}.`}),!0)}case`/goal`:{let[e,...t]=y.split(/\s+/).filter(Boolean),r=(e??``).toLowerCase();if(r===`start`){let e=t.join(` `).trim();return e?(i?.send?.({type:`goal.start`,payload:{title:e}}),Gr(`goal`),!0):(n({role:`assistant`,content:"Usage: `/goal start <title>`"}),!0)}return r===`pause`?(i?.send?.({type:`goal.pause`,payload:{}}),!0):r===`resume`?(i?.send?.({type:`goal.resume`,payload:{}}),!0):r===`stop`?(i?.send?.({type:`goal.stop`,payload:{}}),!0):(Gr(`goal`),!0)}case`/fleet`:return U.getState().setFleetMonitorOpen(!0),!0;case`/terminal`:case`/term`:return U.getState().setTerminalOpen(!0),!0;case`/collab`:return J(`chat`),U.getState().setDockSection(`collab`),!0;case`/worktree`:case`/worktrees`:return J(`worktrees`),U.getState().setDockSection(`worktrees`),!0;case`/mode`:{let e=y.trim();return e?(i?.send?.({type:`mode.switch`,payload:{id:e}}),n({role:`assistant`,content:`Mode → **${e}**.`}),!0):(i?.send?.({type:`modes.list`}),n({role:`assistant`,content:"Fetching available modes… (or pass `/mode <name>` to switch)."}),!0)}case`/mcp`:{let e=y.trim().split(/\s+/).filter(Boolean),t=e[0],r=e[1];if((t===`resources`||t===`prompts`)&&r)return i?.send?.({type:t===`resources`?`mcp.resources`:`mcp.prompts`,payload:{name:r,refresh:e.includes(`--refresh`)}}),n({role:`assistant`,content:`Fetching MCP ${t} from **${r}**…`}),!0;if(t===`read`&&r&&e[2])return i?.send?.({type:`mcp.resource.read`,payload:{name:r,uri:e[2]}}),n({role:`assistant`,content:`Reading selected MCP resource from **${r}**…`}),!0;if(t===`get`&&r&&e[2]){let t={};for(let r of e.slice(3)){let e=r.indexOf(`=`);if(e<=0)return n({role:`assistant`,content:`Invalid MCP prompt argument \`${r}\`; expected \`key=value\`.`}),!0;t[r.slice(0,e)]=r.slice(e+1)}return i?.send?.({type:`mcp.prompt.get`,payload:{name:r,prompt:e[2],arguments:t}}),n({role:`assistant`,content:`Getting selected MCP prompt from **${r}**…`}),!0}return t?(n({role:`assistant`,content:"Usage: `/mcp resources <server>`, `/mcp prompts <server>`, `/mcp read <server> <uri>`, or `/mcp get <server> <prompt> [key=value...]`."}),!0):(i?.send?.({type:`mcp.list`}),Gr(`settings`),n({role:`assistant`,content:`🖥️ **MCP Servers** — settings opened to the MCP tab.
4
4
 
@@ -99,7 +99,7 @@ ${o.join(``)}
99
99
  `));return(0,Q.jsxs)(`div`,{className:G(`py-0.5`,n?`flex flex-col gap-0.5`:`flex items-baseline gap-2`),children:[(0,Q.jsxs)(`span`,{className:`text-muted-foreground shrink-0`,children:[e,`:`]}),(0,Q.jsx)(`span`,{className:G(`text-foreground`,n?`whitespace-pre-wrap break-all bg-muted/40 rounded px-1.5 py-1`:`truncate`,typeof i==`string`?``:`text-warning`),title:typeof i==`string`&&!n?t:void 0,children:t})]},e)}let a=!!n[e],o=Array.isArray(i)?`[${t(`activity:toolInput.itemCount`,{count:i.length})}]`:`{${t(`activity:toolInput.keyCount`,{count:Object.keys(i).length})}}`;return(0,Q.jsxs)(`div`,{className:`py-0.5`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>r(t=>({...t,[e]:!t[e]})),className:`flex items-baseline gap-2 hover:bg-muted/30 rounded px-1 -mx-1`,"aria-expanded":a,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/75 text-[10px]`,children:a?`▾`:`▸`}),(0,Q.jsxs)(`span`,{className:`text-muted-foreground`,children:[e,`:`]}),(0,Q.jsx)(`span`,{className:`text-primary`,children:o})]}),a&&(0,Q.jsx)(`pre`,{className:`ml-3 mt-1 whitespace-pre-wrap break-all text-[11px] bg-muted/40 rounded px-2 py-1.5`,children:JSON.stringify(i,null,2)})]},e)})})}function es(e){return e.toolResult===void 0?`running`:e.isError?`error`:`ok`}var ts={running:`text-warning`,error:`text-destructive`,ok:`text-success`},ns=(0,Z.memo)(function({message:e}){let{t}=V(),[n,r]=(0,Z.useState)(!1),i=es(e),a=e.toolName??``,{Icon:o,color:s}=Ao(a),c=Mo(a),l=e.toolInput===void 0?``:zo(a,e.toolInput),u=e.toolResult?e.toolResult.split(`
100
100
  `).length:0,d=oi(e.toolResult),f=e.toolResult!==void 0&&e.toolResult.length>0||e.toolInput!==void 0&&Object.keys(e.toolInput??{}).length>0,p=n?Vo(a,e.toolInput):null;return(0,Q.jsxs)(`div`,{className:G(`ws-ledger min-w-0 max-w-full overflow-hidden border border-l-2 border-border/50`,i===`ok`&&`ws-ledger--ok`,i===`error`&&`ws-ledger--error`,i===`running`&&`ws-ledger--running`),children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>f&&r(e=>!e),"aria-expanded":n,title:c,className:G(`flex w-full items-center gap-2 px-2.5 py-1.5 text-left font-mono text-xs select-none`,f?`cursor-pointer hover:bg-muted/40`:`cursor-default`,`transition-colors`),children:[(0,Q.jsx)(`span`,{className:G(`ws-ledger__dot`,ts[i],i===`running`&&`ws-ledger__dot--running`)}),(0,Q.jsx)(o,{className:`h-3.5 w-3.5 shrink-0`,style:{color:s}}),(0,Q.jsx)(`span`,{className:`font-semibold tracking-tight`,style:{color:s},children:e.toolName}),l&&(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-muted-foreground/80`,children:l}),!l&&(0,Q.jsx)(`span`,{className:`flex-1`}),(0,Q.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 tabular-nums text-muted-foreground/75`,children:[u>0&&!n&&(0,Q.jsx)(`span`,{className:`text-[10px]`,children:t(`activity:message.linesSuffix`,{count:u})}),d!==void 0&&(0,Q.jsxs)(`span`,{className:G(`px-1 text-[10px] font-semibold`,d===0?`text-success/90`:`text-destructive`),children:[`exit `,d]}),typeof e.toolDurationMs==`number`&&(0,Q.jsx)(`span`,{className:`text-[10px]`,children:ci(e.toolDurationMs)}),i===`running`?(0,Q.jsx)(g,{className:`h-3 w-3 animate-spin text-warning`}):f?n?(0,Q.jsx)(b,{className:`h-3.5 w-3.5`}):(0,Q.jsx)(Kn,{className:`h-3.5 w-3.5`}):null]})]}),e.toolResult===void 0&&e.progressLines&&e.progressLines.length>0&&(0,Q.jsx)(`div`,{className:`border-t border-border/40 bg-warning/[0.04] px-2.5 py-1.5 font-mono text-[11px] leading-snug`,children:(()=>{let t=new Map;return e.progressLines.slice(-6).map(e=>{let n=t.get(e)??0;return t.set(e,n+1),(0,Q.jsx)(`div`,{className:`truncate text-muted-foreground`,children:e},`${e}-${n}`)})})()}),!n&&i===`error`&&e.toolResult&&(0,Q.jsx)(`div`,{className:`truncate border-t border-destructive/20 px-2.5 py-1 font-mono text-[11px] text-destructive/90`,children:e.toolResult.split(`
101
101
  `)[0]}),n&&(0,Q.jsxs)(`div`,{className:`border-t border-border/40`,children:[e.toolInput!==void 0&&(p?(0,Q.jsx)(`div`,{className:`p-2`,children:(0,Q.jsx)(Go,{diff:p})}):(0,Q.jsxs)(`div`,{className:`overflow-x-auto bg-muted/30 p-2.5`,children:[(0,Q.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-1 font-mono text-[10px] uppercase tracking-wide text-muted-foreground/70`,children:[(0,Q.jsx)(Zt,{className:`h-3 w-3`}),(0,Q.jsx)(`span`,{children:t(`activity:message.inputLabel`)})]}),(0,Q.jsx)($o,{input:e.toolInput})]})),e.toolResult!==void 0&&e.toolResult.length>0&&(0,Q.jsx)(`div`,{className:`p-2`,children:(0,Q.jsx)(Xo,{toolName:e.toolName,result:e.toolResult,isError:e.isError})}),e.toolResult!==void 0&&e.toolResult.length===0&&(0,Q.jsx)(`div`,{className:`px-2.5 py-1.5 font-mono text-[11px] italic text-muted-foreground`,children:t(`activity:message.empty`)})]}),n&&e.toolResult!==void 0&&e.toolResult.length>0&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-border/40 px-2.5 py-1`,children:[(0,Q.jsx)(`span`,{className:`h-px flex-1 bg-border/30`,"aria-hidden":!0}),(0,Q.jsx)(bo,{text:e.toolResult,label:t(`common:action.copy`),className:`text-[10px] text-muted-foreground/70 hover:text-foreground`}),e.toolResult.split(`
102
- `).length>5&&(0,Q.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation();let n=ii(e.toolName);li(`${(e.toolName??`output`).replace(/[^a-z0-9_-]+/gi,`-`).toLowerCase()}-${new Date().toISOString().replace(/[:.]/g,`-`)}.${n}`,e.toolResult??``)},className:`inline-flex items-center gap-1 text-[10px] text-muted-foreground/70 transition-colors hover:text-foreground`,title:t(`activity:message.downloadTitle`),children:(0,Q.jsx)(wn,{className:`h-3 w-3`})})]})]})}),rs=(0,Z.memo)(function({message:e,isFirst:n=!1,isContinuation:r=!1}){let{t:a}=V(),[o,s]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(``),[p,m]=(0,Z.useState)(!1),h=e.role===`user`,g=e.role===`tool`,_=!!e.thinkingLog,v=e.role===`system`&&!_;e.role;let y=i(e=>e.truncateAfter),x=i(e=>e.addMessage),S=i(e=>e.setLoading),C=i(e=>e.isLoading),w=q(e=>e.wsUrl),T=U(e=>e.pinnedIds),E=U(e=>e.togglePin),D=U(e=>e.compactMode),O=U(e=>e.searchOpen),k=U(e=>e.searchActiveMessageId),A=T.includes(e.id),j=K(e=>e.inputCost),M=K(e=>e.outputCost),N=K(e=>e.cacheReadCost),P=W(),{autonomy:ee,yolo:te,showThinkingLogs:F}=P,I=!F&&!!e.thinkingLog&&!e.content&&!e.streaming,{canAutoSubmit:ne,recordAutoSubmit:re,recordPrompt:L,capWarned:ie}=xa(),ae=ne(),R=e=>{if(!ne()){ie||x({role:`assistant`,content:a(`activity:message.autoPaused`)});return}let t=pr(w);if(!t.isConnected){Y.error(a(`common:status.notConnectedRetry`));return}if(!L(e)){x({role:`assistant`,content:a(`activity:message.autoLoopHalted`)}),Ha(``);return}re(),x({role:`user`,content:e}),S(!0),t.sendMessage(e),Ha(``)},z=(()=>{if(e.role!==`assistant`||C)return!1;let n=i.getState().messages;for(let r=n.length-1;r>=0;r--){let i=t(n[r]);if(i.role===`assistant`)return i.id===e.id}return!1})(),oe=e.nextSteps?.steps??[];(0,Z.useEffect)(()=>{if(!e.thinkingLog||!O||k!==e.id)return;let t=U.getState().searchQuery.trim().toLowerCase();t&&e.thinkingLog.text.toLowerCase().includes(t)&&s(!0)},[e.id,e.thinkingLog,k,O]);let se=e=>(e.attachments??[]).flatMap(e=>e.dataUrl?[{id:e.id,dataUrl:e.dataUrl,mediaType:e.mediaType,bytes:e.bytes,name:e.name}]:[]),ce=()=>{let n=i.getState().messages,r=n.findIndex(t=>t.id===e.id);if(r===-1)return;let o=-1;for(let e=r-1;e>=0;e--)if(n[e]?.role===`user`){o=e;break}if(o===-1)return;let s=pr(w);if(!s.isConnected){Y.error(a(`common:status.notConnectedRetry`));return}let c=t(n[o]),l=se(c);y(c.id),x({role:`user`,content:c.content,...l.length>0?{attachments:l.map(e=>({...e,kind:`image`}))}:{}}),S(!0),s.sendMessage(c.content,l.length>0?ir(l):void 0)},le=()=>{f(e.content),u(!0)},ue=()=>{u(!1),f(``)},de=()=>{let t=d.trim();if(!t){ue();return}let n=pr(w);if(!n.isConnected){Y.error(a(`common:status.notConnectedRetry`));return}let r=se(e);y(e.id),x({role:`user`,content:t,...r.length>0?{attachments:r.map(e=>({...e,kind:`image`}))}:{}}),S(!0),n.sendMessage(t,r.length>0?ir(r):void 0),u(!1),f(``)};return(0,Q.jsxs)(`div`,{"data-message-id":e.id,"data-pinned":A?`1`:void 0,className:G(`group flex msg-bubble animate-message rounded-lg transition-shadow`,D?`gap-2`:`gap-3`,h?`flex-row-reverse`:`flex-row`,A&&`ring-1 ring-warning/30 bg-warning/[0.02] px-1 -mx-1`),children:[r?(0,Q.jsx)(`div`,{className:`flex-shrink-0 w-8 h-8`,"aria-hidden":!0}):(0,Q.jsx)(`div`,{className:G(`flex-shrink-0 w-8 h-8 rounded-lg flex items-center justify-center`,`ring-1 ring-offset-2 ring-offset-background`,h?`bg-primary text-primary-foreground ring-primary/20`:g?`bg-secondary text-secondary-foreground ring-secondary/20`:v?`bg-muted/60 text-muted-foreground ring-border/40`:_?`bg-primary/10 text-primary ring-primary/20`:`bg-accent text-accent-foreground ring-accent/20`),children:h?(0,Q.jsx)(hn,{className:`h-4 w-4`}):g?(0,Q.jsx)(Ze,{className:`h-4 w-4`}):v?(0,Q.jsx)(Fn,{className:`h-4 w-4`}):_?(0,Q.jsx)(on,{className:`h-4 w-4`}):(0,Q.jsx)(Ee,{className:`h-4 w-4`})}),(0,Q.jsxs)(`div`,{className:G(`flex min-w-0 flex-1 flex-col gap-1.5 sm:max-w-[52rem]`,h&&`items-end sm:max-w-[44rem]`),children:[n&&!r&&(0,Q.jsx)(`span`,{className:G(`text-xs font-medium px-1`,h?`text-primary`:v?`text-muted-foreground/60`:g?`text-secondary`:_?`text-primary`:`text-muted-foreground`),children:h?a(`activity:message.roleYou`):v?`System`:a(g?`activity:message.roleTool`:_?`activity:message.roleThinking`:`activity:message.roleAssistant`)}),g?(0,Q.jsx)(ns,{message:e}):(0,Q.jsx)(`div`,{className:G(`max-w-full rounded-lg shadow-sm`,D?`px-3 py-1.5`:`px-4 py-3`,h?`bg-primary text-primary-foreground rounded-br-sm msg-user-bubble`:v?`bg-muted/30 border border-border/30 text-muted-foreground text-xs italic py-2`:`bg-card border border-border/70 text-foreground`,e.isError&&`border-destructive/20`,h&&e.status===`failed`&&`opacity-60 ring-1 ring-destructive/30`),children:l&&h?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 min-w-[280px]`,children:[(0,Q.jsx)(`textarea`,{value:d,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Escape`?(e.preventDefault(),ue()):e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),de())},rows:Math.min(8,Math.max(2,d.split(`
102
+ `).length>5&&(0,Q.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation();let n=ii(e.toolName);li(`${(e.toolName??`output`).replace(/[^a-z0-9_-]+/gi,`-`).toLowerCase()}-${new Date().toISOString().replace(/[:.]/g,`-`)}.${n}`,e.toolResult??``)},className:`inline-flex items-center gap-1 text-[10px] text-muted-foreground/70 transition-colors hover:text-foreground`,title:t(`activity:message.downloadTitle`),children:(0,Q.jsx)(wn,{className:`h-3 w-3`})})]})]})}),rs=(0,Z.memo)(function({message:e,isFirst:n=!1,isContinuation:r=!1}){let{t:a}=V(),[o,s]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(``),[p,m]=(0,Z.useState)(!1),h=e.role===`user`,g=e.role===`tool`,_=!!e.thinkingLog,v=e.role===`system`&&!_;e.role;let y=i(e=>e.truncateAfter),x=i(e=>e.addMessage),S=i(e=>e.setLoading),C=i(e=>e.isLoading),w=q(e=>e.wsUrl),T=U(e=>e.pinnedIds),E=U(e=>e.togglePin),D=U(e=>e.compactMode),O=U(e=>e.searchOpen),k=U(e=>e.searchActiveMessageId),A=T.includes(e.id),j=K(e=>e.inputCost),M=K(e=>e.outputCost),N=K(e=>e.cacheReadCost),P=W(),{autonomy:ee,yolo:te,showThinkingLogs:F}=P,I=!F&&!!e.thinkingLog&&!e.content&&!e.streaming,{canAutoSubmit:ne,recordAutoSubmit:re,recordPrompt:L,capWarned:ie}=xa(),ae=ne(),R=e=>{if(!ne()){ie||x({role:`assistant`,content:a(`activity:message.autoPaused`)});return}let t=pr(w);if(!t.isConnected){Y.error(a(`common:status.notConnectedRetry`));return}if(!L(e)){x({role:`assistant`,content:a(`activity:message.autoLoopHalted`)}),Ha(``);return}re(),x({role:`user`,content:e}),S(!0),t.sendMessage(e),Ha(``)},z=(()=>{if(e.role!==`assistant`||C)return!1;let n=i.getState().messages;for(let r=n.length-1;r>=0;r--){let i=t(n[r]);if(i.role===`assistant`)return i.id===e.id}return!1})(),oe=e.nextSteps?.steps??[];(0,Z.useEffect)(()=>{if(!e.thinkingLog||!O||k!==e.id)return;let t=U.getState().searchQuery.trim().toLowerCase();t&&e.thinkingLog.text.toLowerCase().includes(t)&&s(!0)},[e.id,e.thinkingLog,k,O]);let se=e=>(e.attachments??[]).flatMap(e=>e.dataUrl?[{id:e.id,dataUrl:e.dataUrl,mediaType:e.mediaType,bytes:e.bytes,name:e.name}]:[]),ce=()=>{let n=i.getState().messages,r=n.findIndex(t=>t.id===e.id);if(r===-1)return;let o=-1;for(let e=r-1;e>=0;e--)if(n[e]?.role===`user`){o=e;break}if(o===-1)return;let s=pr(w);if(!s.isConnected){Y.error(a(`common:status.notConnectedRetry`));return}let c=t(n[o]),l=se(c);y(c.id),x({role:`user`,content:c.content,...l.length>0?{attachments:l.map(e=>({...e,kind:`image`}))}:{}}),S(!0),s.sendMessage(c.content,l.length>0?ir(l):void 0)},le=()=>{f(e.content),u(!0)},ue=()=>{u(!1),f(``)},de=()=>{let t=d.trim();if(!t){ue();return}let n=pr(w);if(!n.isConnected){Y.error(a(`common:status.notConnectedRetry`));return}let r=se(e);y(e.id),x({role:`user`,content:t,...r.length>0?{attachments:r.map(e=>({...e,kind:`image`}))}:{}}),S(!0),n.sendMessage(t,r.length>0?ir(r):void 0),u(!1),f(``)};return(0,Q.jsxs)(`div`,{"data-message-id":e.id,"data-pinned":A?`1`:void 0,className:G(`group flex msg-bubble animate-message rounded-lg transition-shadow`,D?`gap-2`:`gap-3`,h?`flex-row-reverse`:`flex-row`,A&&`ring-1 ring-warning/30 bg-warning/[0.02] px-1 -mx-1`),children:[r?(0,Q.jsx)(`div`,{className:`flex-shrink-0 w-8 h-8`,"aria-hidden":!0}):(0,Q.jsx)(`div`,{className:G(`flex-shrink-0 w-8 h-8 rounded-lg flex items-center justify-center`,`ring-1 ring-offset-2 ring-offset-background`,h?`bg-primary text-primary-foreground ring-primary/20`:g?`bg-secondary text-secondary-foreground ring-secondary/20`:v?`bg-muted/60 text-muted-foreground ring-border/40`:_?`bg-primary/10 text-primary ring-primary/20`:`bg-accent text-accent-foreground ring-accent/20`),children:h?(0,Q.jsx)(hn,{className:`h-4 w-4`}):g?(0,Q.jsx)(Ze,{className:`h-4 w-4`}):v?(0,Q.jsx)(Fn,{className:`h-4 w-4`}):_?(0,Q.jsx)(on,{className:`h-4 w-4`}):(0,Q.jsx)(Ee,{className:`h-4 w-4`})}),(0,Q.jsxs)(`div`,{className:G(`flex min-w-0 flex-1 flex-col gap-1.5 sm:max-w-[52rem]`,h&&`items-end sm:max-w-[44rem]`),children:[n&&!r&&(0,Q.jsx)(`span`,{className:G(`text-xs font-medium px-1`,h?`text-primary`:v?`text-muted-foreground/60`:g?`text-secondary`:_?`text-primary`:`text-muted-foreground`),children:h?a(`activity:message.roleYou`):v?`System`:a(g?`activity:message.roleTool`:_?`activity:message.roleThinking`:`activity:message.roleAssistant`)}),g?(0,Q.jsx)(ns,{message:e}):(0,Q.jsx)(`div`,{className:G(`max-w-full rounded-lg shadow-sm`,D?`px-3 py-1.5`:`px-4 py-3`,h?`bg-transparent text-foreground border border-primary/40 rounded-br-sm`:v?`bg-muted/30 border border-border/30 text-muted-foreground text-xs italic py-2`:`bg-card border border-border/70 text-foreground`,e.isError&&`border-destructive/20`,h&&e.status===`failed`&&`opacity-60 ring-1 ring-destructive/30`),children:l&&h?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 min-w-[280px]`,children:[(0,Q.jsx)(`textarea`,{value:d,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Escape`?(e.preventDefault(),ue()):e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),de())},rows:Math.min(8,Math.max(2,d.split(`
103
103
  `).length)),className:`w-full resize-none rounded-md border bg-background text-foreground px-2 py-1.5 text-sm font-mono focus:outline-none focus:ring-2 focus:ring-ring`}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] text-primary-foreground/60`,children:a(`activity:message.editHint`)}),(0,Q.jsxs)(`div`,{className:`flex gap-1`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:ue,className:`text-xs px-2 py-0.5 rounded border border-primary-foreground/30 hover:bg-primary-foreground/10`,children:a(`common:action.cancel`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:de,disabled:!d.trim(),className:`text-xs px-2 py-0.5 rounded bg-primary-foreground text-primary disabled:opacity-50`,children:a(`activity:message.saveResend`)})]})]})]}):e.thinkingLog&&F?(()=>{let t=e.thinkingLog,n=t.text.split(`
104
104
  `).length,r=Math.max(.1,t.durationMs/1e3),i=t.replayed?a(`activity:message.replay`):`${r.toFixed(+(r<10))}s`,c=t.text.split(`
105
105
  `).slice(-4).join(`
@@ -116,4 +116,4 @@ ${o.join(``)}
116
116
  `),n=new Blob([t],{type:`text/csv;charset=utf-8`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`side-effects-${new Date().toISOString().slice(0,19).replace(/[:.]/g,`-`)}.csv`,i.click(),URL.revokeObjectURL(r)}function Lc(){let e=Dr(e=>e.sideEffects),t=Dr(e=>e.loading),{t:n}=V(),[r,i]=(0,Z.useState)(`all`),[a,o]=(0,Z.useState)(`time`),[s,c]=(0,Z.useState)(`desc`);(0,Z.useEffect)(()=>{Dr.getState().setLoading(!0),nr(async()=>{let{getWSClient:e}=await import(`./ws-client-BWO_PH_X.js`).then(e=>e.n);return{getWSClient:e}},__vite__mapDeps([19,1,2,3,4,5,6,18,20])).then(({getWSClient:e})=>{e().send({type:`side_effects.list`})})},[]);let l=()=>{Dr.getState().setLoading(!0),nr(async()=>{let{getWSClient:e}=await import(`./ws-client-BWO_PH_X.js`).then(e=>e.n);return{getWSClient:e}},__vite__mapDeps([19,1,2,3,4,5,6,18,20])).then(({getWSClient:e})=>{e().send({type:`side_effects.list`})})},u=e=>{a===e?c(s===`asc`?`desc`:`asc`):(o(e),c(e===`time`?`desc`:`asc`))},d=(0,Z.useMemo)(()=>{let t=r===`all`?[...e]:e.filter(e=>e.risk===r);return t.sort((e,t)=>{let n=0;return a===`time`?n=e.ts.localeCompare(t.ts):a===`tool`?n=e.toolName.localeCompare(t.toolName):a===`risk`&&(n=e.risk.localeCompare(t.risk)),s===`asc`?n:-n}),t},[e,r,a,s]),f=ho(d,20,`${r}:${a}:${s}`);if(e.length===0&&!t)return(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 py-8 text-muted-foreground`,children:[(0,Q.jsx)(_t,{className:`h-8 w-8 opacity-40`}),(0,Q.jsx)(`p`,{className:`text-sm`,children:n(`activity:sideEffects.empty`)}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground/75`,children:n(`activity:sideEffects.emptyHint`)})]});let p=({column:e})=>a===e?s===`asc`?(0,Q.jsx)(Et,{className:`inline h-3 w-3`}):(0,Q.jsx)(b,{className:`inline h-3 w-3`}):(0,Q.jsx)(`span`,{className:`opacity-30`,children:`↕`});return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/70 bg-card/70 px-3 py-2`,children:[(0,Q.jsxs)(`h3`,{className:`text-xs font-semibold uppercase text-muted-foreground`,children:[n(`activity:sideEffects.heading`),` (`,d.length,r===`all`?``:`/${e.length}`,`)`]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>Ic(d),disabled:d.length===0,className:`flex items-center gap-1 rounded-md px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-30`,title:n(`activity:sideEffects.exportTitle`),children:[(0,Q.jsx)(wn,{className:`h-3 w-3`}),`CSV`]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:l,className:`flex items-center gap-1 rounded-md px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground`,children:[(0,Q.jsx)(Dn,{className:G(`h-3 w-3`,t&&`animate-spin`)}),n(`common:action.refresh`)]})]})]}),(0,Q.jsx)(`div`,{className:`flex items-center gap-1 border-b border-border/60 bg-muted/20 px-2 py-1`,children:Mc.map(e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>i(e),className:G(`rounded-md px-2 py-0.5 text-[10px] font-medium uppercase transition-colors`,r===e?`bg-primary/10 text-primary ring-1 ring-primary/20`:`text-muted-foreground hover:bg-muted/70 hover:text-foreground`),children:e===`all`?n(`activity:sideEffects.all`):e},e))}),(0,Q.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Q.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,Q.jsx)(`thead`,{className:`sticky top-0 bg-card/95 text-muted-foreground backdrop-blur`,children:(0,Q.jsxs)(`tr`,{children:[(0,Q.jsxs)(`th`,{className:`cursor-pointer select-none px-2 py-1 text-left font-medium hover:text-foreground`,onClick:()=>u(`time`),children:[n(`activity:sideEffects.colTime`),` `,(0,Q.jsx)(p,{column:`time`})]}),(0,Q.jsxs)(`th`,{className:`cursor-pointer select-none px-2 py-1 text-left font-medium hover:text-foreground`,onClick:()=>u(`tool`),children:[n(`activity:sideEffects.colTool`),` `,(0,Q.jsx)(p,{column:`tool`})]}),(0,Q.jsxs)(`th`,{className:`cursor-pointer select-none px-2 py-1 text-left font-medium hover:text-foreground`,onClick:()=>u(`risk`),children:[n(`activity:sideEffects.colRisk`),` `,(0,Q.jsx)(p,{column:`risk`})]}),(0,Q.jsx)(`th`,{className:`px-2 py-1 text-left font-medium`,children:n(`activity:sideEffects.colDetail`)}),(0,Q.jsx)(`th`,{className:`px-2 py-1 text-left font-medium`,children:n(`activity:sideEffects.colOutcome`)})]})}),(0,Q.jsx)(`tbody`,{children:f.pageItems.map((e,t)=>{let n=Ac[e.risk]??_t,r=jc[e.risk]??`text-muted-foreground`;return(0,Q.jsxs)(`tr`,{className:`border-b border-border/45 hover:bg-muted/45`,children:[(0,Q.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1.5 text-muted-foreground`,children:Nc(e.ts)}),(0,Q.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1.5 font-medium text-foreground`,children:e.toolName}),(0,Q.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1.5`,children:(0,Q.jsxs)(`span`,{className:G(`flex items-center gap-1`,r),children:[(0,Q.jsx)(n,{className:`h-3 w-3`}),e.risk]})}),(0,Q.jsx)(`td`,{className:`max-w-xs truncate px-2 py-1.5 font-mono text-muted-foreground`,children:Pc(e)}),(0,Q.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1.5 text-muted-foreground`,children:e.outcome??``})]},`${e.toolUseId}-${t}`)})})]})}),(0,Q.jsx)(ni,{page:f.page,pageSize:f.pageSize,totalItems:f.totalItems,onPageChange:f.setPage,itemLabel:`side effects`})]})}function Rc(e){return e<=0?`$0`:e>=.01?`$${e.toFixed(3)}`:`$${e.toFixed(5)}`.replace(/0+$/,``).replace(/\.$/,``)}function zc(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function Bc(e,t){let n=Array.from(e.values());return n.sort((e,n)=>{if(e.id===t)return-1;if(n.id===t)return 1;let r=e.status===`running`?0:1,i=n.status===`running`?0:1;return r===i?e.startedAt-n.startedAt:r-i}),n}function Vc(){let{t:e}=V(),t=U(e=>e.inspectorOpen),n=U(e=>e.setInspectorOpen),r=xr(e=>Array.from(e.agents.values()).filter(e=>e.status===`running`).length)+Dr(e=>e.sideEffects.length);return(0,Q.jsxs)(`button`,{type:`button`,"data-testid":`inspector-trigger`,"aria-expanded":t,"aria-controls":`workbench-inspector`,onClick:()=>n(!t),className:G(`relative inline-flex h-8 items-center gap-1.5 rounded-md border px-2 text-xs transition-colors`,t?`border-primary/40 bg-primary/10 text-primary`:`border-border/70 bg-background/60 text-muted-foreground hover:bg-accent/60 hover:text-foreground`),title:e(t?`activity:inspector.hidePanel`:`activity:inspector.showPanel`),children:[(0,Q.jsx)(Kt,{className:`h-3.5 w-3.5`}),(0,Q.jsx)(`span`,{className:`hidden lg:inline`,children:e(`activity:inspector.label`)}),r>0?(0,Q.jsx)(`span`,{className:`min-w-4 bg-primary/15 px-1 text-[10px] font-semibold tabular-nums text-primary`,children:r>99?`99+`:r}):null]})}function Hc(){let e=U(e=>e.inspectorOpen),t=U(e=>e.inspectorTab),n=U(e=>e.setInspectorOpen),r=U(e=>e.setInspectorTab),i=U(e=>e.inspectorFocusedAgentId),a=U(e=>e.setInspectorFocusedAgentId),{t:o}=V(),s=xr(e=>e.agents),c=xr(e=>e.leaderId),l=xr(e=>e.fleetTokensIn),u=xr(e=>e.fleetTokensOut),d=xr(e=>e.eventTimeline),f=(0,Z.useMemo)(()=>Bc(s,c),[s,c]),p=f.filter(e=>e.status===`running`).length,m=f.reduce((e,t)=>e+t.costUsd,0),h=f.length,[g,_]=(0,Z.useState)(null),v=(0,Z.useMemo)(()=>g?s.get(g)??f[0]??null:f[0]??null,[g,f,s]),y=Dr(e=>e.sideEffects.length);return(0,Z.useEffect)(()=>{i&&e&&(_(i),r(`agents`),a(null))},[i,e,r,a]),(0,Q.jsx)(dc,{open:e,onOpenChange:n,modal:!1,children:(0,Q.jsxs)(gc,{id:`workbench-inspector`,"data-testid":`inspector-drawer`,side:`right`,showOverlay:!1,showCloseButton:!1,onPointerDownOutside:e=>e.preventDefault(),onFocusOutside:e=>e.preventDefault(),onCloseAutoFocus:e=>{e.preventDefault(),document.querySelector(`[data-testid="inspector-trigger"]`)?.focus()},className:`flex w-[calc(100vw-3rem)] max-w-none flex-col gap-0 overflow-hidden border-l border-border/80 bg-card/96 p-0 shadow-[-24px_0_64px_-36px_hsl(var(--shadow-color)/0.65)] backdrop-blur-xl sm:w-[min(680px,48vw)] sm:max-w-[680px]`,children:[(0,Q.jsxs)(_c,{className:`relative gap-1 border-b border-border/70 bg-muted/20 px-4 py-3 pr-12`,children:[(0,Q.jsxs)(vc,{className:`flex items-center gap-2 text-sm`,children:[(0,Q.jsx)(Kt,{className:`h-4 w-4 text-primary`}),o(`activity:inspector.label`)]}),(0,Q.jsx)(yc,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px]`,children:h>0?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Q.jsx)(`span`,{className:G(`h-1.5 w-1.5 rounded-full`,p>0?`bg-success animate-pulse`:`bg-muted-foreground/50`)}),(0,Q.jsxs)(`span`,{className:`tabular-nums`,children:[p,`/`,h]})]}),(0,Q.jsxs)(`span`,{className:`font-mono tabular-nums`,children:[`↓`,zc(l),` ↑`,zc(u),` · `,Rc(m)]})]}):(0,Q.jsx)(`span`,{children:o(`activity:inspector.agentsAppearHint`)})}),(0,Q.jsx)(fc,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,"data-testid":`inspector-close`,className:`absolute right-3 top-3 inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,"aria-label":o(`activity:inspector.collapseAria`),title:o(`activity:inspector.collapseTitle`),children:(0,Q.jsx)(vn,{className:`h-4 w-4`})})})]}),(0,Q.jsxs)($s,{value:t,onValueChange:e=>r(e),className:`flex min-h-0 flex-1 flex-col`,children:[(0,Q.jsxs)(ec,{className:`flex h-10 min-h-10 shrink-0 justify-start gap-1 border-x-0 border-t-0 border-b border-border/70 bg-muted/30 p-2 shadow-none`,"aria-label":o(`activity:inspector.label`),children:[(0,Q.jsx)(Uc,{value:`fleet`,icon:(0,Q.jsx)(Ee,{className:`h-3.5 w-3.5`}),label:o(`activity:inspector.tabFleet`),count:h,running:p}),(0,Q.jsx)(Uc,{value:`agents`,icon:(0,Q.jsx)(xn,{className:`h-3.5 w-3.5`}),label:o(`activity:inspector.tabAgents`),count:h}),(0,Q.jsx)(Uc,{value:`sideEffects`,icon:(0,Q.jsx)(_t,{className:`h-3.5 w-3.5`}),label:o(`activity:inspector.tabAudit`),count:y})]}),(0,Q.jsx)(nc,{value:`fleet`,className:`mt-0 min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Q.jsx)(Wc,{fleetList:f,leaderId:c,selectedAgentId:g,eventTimeline:d,onSelectAgent:e=>{_(e.id),r(`agents`)}})}),(0,Q.jsx)(nc,{value:`agents`,className:`mt-0 min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Q.jsx)(Gc,{fleetList:f,selectedAgent:v,leaderId:c,selectedAgentId:v?.id??null,onSelectAgent:_})}),(0,Q.jsx)(nc,{value:`sideEffects`,className:`mt-0 min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Q.jsx)(Lc,{})})]})]})})}function Uc({value:e,icon:t,label:n,count:r,running:i}){return(0,Q.jsxs)(tc,{value:e,className:G(`flex h-6 items-center gap-1.5 rounded-md px-2.5 py-0 text-[11px] font-medium text-muted-foreground shadow-none transition-colors scroll-mt-12`,`hover:bg-background/60 hover:text-foreground data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm data-[state=active]:ring-1 data-[state=active]:ring-border`),children:[t,n,r>0&&(0,Q.jsx)(`span`,{className:G(`tabular-nums text-[10px] px-1 rounded-full`,i&&i>0?`bg-success/15 text-success`:`bg-muted text-muted-foreground`),children:i===void 0?r:`${i}/${r}`})]})}function Wc({fleetList:e,leaderId:t,selectedAgentId:n,eventTimeline:r,onSelectAgent:i}){let{t:a}=V();return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[e.length===0?(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground`,children:[(0,Q.jsx)(xn,{className:`h-8 w-8 mb-2 opacity-20`}),(0,Q.jsx)(`p`,{className:`text-xs font-medium`,children:a(`activity:inspector.noAgentsActive`)}),(0,Q.jsx)(`p`,{className:`text-[11px] mt-0.5`,children:a(`activity:inspector.agentsAppearHint`)})]}):(0,Q.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain p-1.5`,children:e.map(e=>(0,Q.jsx)(kc,{agent:e,isSelected:n===e.id,isLeader:e.id===t,onClick:()=>i(e)},e.id))}),r.length>0&&(0,Q.jsx)(`div`,{className:`border-t px-3 py-1.5 shrink-0`,children:(0,Q.jsx)(uc,{events:r,max:4})})]})}function Gc({fleetList:e,selectedAgent:t,leaderId:n,selectedAgentId:r,onSelectAgent:i}){let{t:a}=V();if(e.length===0)return(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground`,children:[(0,Q.jsx)(Ee,{className:`h-8 w-8 mb-2 opacity-20`}),(0,Q.jsx)(`p`,{className:`text-xs font-medium`,children:a(`activity:inspector.noAgentsActive`)})]});if(!t)return null;let o=Math.max(0,e.findIndex(e=>e.id===r));return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,Q.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain p-3`,children:(0,Q.jsx)(`div`,{className:`max-w-2xl mx-auto`,children:(0,Q.jsx)(Dc,{agent:t,isLeader:t.id===n})})}),(0,Q.jsx)(`div`,{className:`border-t px-2 py-1.5 shrink-0`,children:(0,Q.jsx)(`div`,{className:`flex items-center gap-1 overflow-x-auto pb-0.5`,children:e.map((e,n)=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>i(e.id),className:G(`shrink-0 flex items-center gap-1.5 px-2 py-1 rounded-md text-[10px] transition-colors`,e.id===t?.id?`bg-primary/15 text-primary ring-1 ring-primary/40`:`hover:bg-accent text-muted-foreground`),title:n===o?a(`activity:inspector.selected`,{name:e.name}):e.name,children:[(0,Q.jsx)(`span`,{className:G(`h-1.5 w-1.5 rounded-full shrink-0`,e.status===`running`?`bg-success animate-pulse`:e.status===`failed`?`bg-destructive`:`bg-muted-foreground/50`)}),(0,Q.jsx)(`span`,{className:`truncate max-w-[8rem]`,children:e.name})]},e.id))})})]})}function Kc(e,t,n,r,i){let a=[];for(let n of e){let e=t[n.id]??[];for(let t of e)a.push({provider:n.id,model:t.id,modelName:t.name||t.id,description:t.description,contextWindow:t.contextWindow,isCurrent:n.id===r&&t.id===i})}let o=n.toLowerCase().trim();return(o?a.filter(e=>e.provider.toLowerCase().includes(o)||e.model.toLowerCase().includes(o)||e.modelName.toLowerCase().includes(o)||e.description?.toLowerCase().includes(o)):a).sort((e,t)=>e.isCurrent===t.isCurrent?e.provider.localeCompare(t.provider)||e.model.localeCompare(t.model):e.isCurrent?-1:1)}function qc(){let{t:e}=V(),t=U(e=>e.modelSwitcherOpen),n=U(e=>e.setModelSwitcherOpen),[r,i]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(0),[s,c]=(0,Z.useState)([]),[l,u]=(0,Z.useState)({}),d=(0,Z.useRef)(null),f=q(e=>e.wsUrl),p=q(e=>e.provider),m=q(e=>e.model),h=U(e=>e.paletteOpen),{listSavedProviders:g,listProviderModels:_,switchModel:v}=dr();(0,Z.useEffect)(()=>{let e=e=>{if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`m`&&!e.shiftKey&&!e.altKey){if(h)return;e.preventDefault(),n(!t);return}e.key===`Escape`&&t&&(e.preventDefault(),n(!1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,h]),(0,Z.useEffect)(()=>{let e=pr(f),t=e.on(`providers.saved`,e=>{let t=e.payload;c(t.providers??[])}),n=e.on(`provider.models`,e=>{let t=e.payload;u(e=>({...e,[t.provider]:t.models}))});return()=>{t(),n()}},[f]),(0,Z.useEffect)(()=>{t&&(i(``),o(0),g(),requestAnimationFrame(()=>d.current?.focus()))},[t,g]),(0,Z.useEffect)(()=>{if(t)for(let e of s)l[e.id]||_(e.id)},[t,s,l,_]);let y=(0,Z.useMemo)(()=>Kc(s,l,r,p,m),[s,l,r,p,m]);(0,Z.useEffect)(()=>{a>=y.length&&o(0)},[y.length,a]);let b=e=>{let t=y[e];t&&(v(t.provider,t.model),n(!1))};return(0,Q.jsx)($r,{open:t,onOpenChange:e=>{e||n(!1)},children:(0,Q.jsxs)(Xr,{className:`max-w-xl gap-0 p-0 overflow-hidden pt-[15dvh]`,showCloseButton:!1,onOpenAutoFocus:e=>{e.preventDefault(),d.current?.focus()},children:[(0,Q.jsx)(Zr,{className:`sr-only`,children:e(`activity:modelSwitcher.heading`)}),(0,Q.jsx)(Qr,{className:`sr-only`,children:e(`activity:modelSwitcher.filterPlaceholder`)}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 border-b px-3 py-2`,children:[(0,Q.jsx)(Tn,{className:`h-4 w-4 text-muted-foreground`}),(0,Q.jsx)(`input`,{ref:d,value:r,onChange:e=>{i(e.target.value),o(0)},onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),o(e=>Math.min(y.length-1,e+1))):e.key===`ArrowUp`?(e.preventDefault(),o(e=>Math.max(0,e-1))):e.key===`Enter`&&(e.preventDefault(),b(a))},placeholder:e(`activity:modelSwitcher.filterPlaceholder`),"aria-label":e(`activity:modelSwitcher.filterPlaceholder`),className:`flex-1 bg-transparent outline-none text-sm placeholder:text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground font-mono`,children:`↑↓ · Enter · Esc`})]}),(0,Q.jsx)(`div`,{className:`max-h-[50dvh] overflow-y-auto py-1`,children:y.length===0?(0,Q.jsx)(`div`,{className:`px-4 py-8 text-center text-sm text-muted-foreground`,children:s.length===0?e(`activity:modelSwitcher.noSavedProviders`):e(`activity:model.loading`)}):y.map((t,n)=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>b(n),onMouseEnter:()=>o(n),className:G(`w-full flex items-center gap-3 px-3 py-2 text-left text-sm transition-colors`,n===a?`bg-accent text-accent-foreground`:`hover:bg-accent/40`,t.isCurrent&&`font-medium`),children:[(0,Q.jsx)(yt,{className:G(`h-4 w-4 shrink-0`,t.isCurrent?`text-primary`:`text-muted-foreground`)}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`truncate`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:t.provider}),(0,Q.jsx)(`span`,{className:`mx-1 text-muted-foreground/65`,children:`·`}),(0,Q.jsx)(`span`,{children:t.modelName})]}),t.contextWindow&&(0,Q.jsxs)(`div`,{className:`text-[10px] text-muted-foreground font-mono`,children:[t.model,` · ctx `,t.contextWindow.toLocaleString()]})]}),t.isCurrent?(0,Q.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-primary font-semibold`,children:e(`activity:modelSwitcher.active`)}):(0,Q.jsx)(ie,{className:`h-3.5 w-3.5 text-muted-foreground opacity-0 group-hover:opacity-100`})]},`${t.provider}:${t.model}`))})]})})}function Jc(e,t){if(e!==`omniroute`)return{providerId:e,model:t};let n=t.indexOf(`/`);return n>0?{providerId:t.slice(0,n),model:t.slice(n+1)}:{providerId:e,model:t}}function Yc({value:e,candidates:t,onChange:n}){let r=(0,Z.useMemo)(()=>{let e=t.map(e=>{let t=Jc(e.provider,e.model);return`${t.providerId}/${t.model}`});return[...new Set(e)].sort()},[t]),[i,a]=(0,Z.useState)(r[0]??``),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(`blackout`),[u,d]=(0,Z.useState)([0,1,2,3,4,5,6]),[f,p]=(0,Z.useState)(`00:00`),[m,h]=(0,Z.useState)(`08:00`),g=Intl.DateTimeFormat().resolvedOptions().timeZone;(0,Z.useEffect)(()=>{!i&&r[0]&&a(r[0])},[r,i]);let _=(t,r)=>n(e.map((e,n)=>n===t?{...e,...r}:e)),v=(t,n)=>{let r=e[t]?.days??[];_(t,{days:r.includes(n)?r.filter(e=>e!==n):[...r,n].sort()})};return(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[e.map((t,r)=>(0,Q.jsxs)(`div`,{className:`space-y-2 rounded-md border bg-muted/30 p-2 text-xs`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:t.enabled!==!1,onChange:e=>_(r,{enabled:e.target.checked})}),(0,Q.jsxs)(`code`,{className:`min-w-0 flex-1 truncate`,children:[t.provider,`/`,t.model??`*`]}),(0,Q.jsx)(`span`,{className:cs(t)?ss(t)?`text-sky-400`:`text-muted-foreground`:`text-destructive`,children:cs(t)?ss(t)?`window active`:`window inactive`:`invalid schedule`}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>n(e.filter((e,t)=>t!==r)),children:(0,Q.jsx)(C,{className:`h-3.5 w-3.5 text-muted-foreground hover:text-destructive`})})]}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:as.map((e,n)=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>v(r,n),className:`rounded px-2 py-1 ${t.days?.includes(n)?`bg-primary text-primary-foreground`:`bg-muted text-muted-foreground`}`,children:e},e))}),(0,Q.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[1fr_1fr_2fr]`,children:[(0,Q.jsx)(fi,{type:`time`,value:t.start,onChange:e=>_(r,{start:e.target.value})}),(0,Q.jsx)(fi,{type:`time`,value:t.end,onChange:e=>_(r,{end:e.target.value})}),(0,Q.jsx)(fi,{value:t.timezone??g,onChange:e=>_(r,{timezone:e.target.value}),placeholder:`Europe/Kiev`})]}),(0,Q.jsxs)(`select`,{value:t.mode??`blackout`,onChange:e=>_(r,{mode:e.target.value}),className:`h-8 rounded-md border bg-background px-2 text-xs`,children:[(0,Q.jsx)(`option`,{value:`blackout`,children:`Do not use inside this window`}),(0,Q.jsx)(`option`,{value:`allow_only`,children:`Use only inside this window`})]})]},t.id)),(0,Q.jsxs)(`div`,{className:`space-y-2 rounded-md border border-dashed p-2`,children:[(0,Q.jsx)(`select`,{value:i,onChange:e=>a(e.target.value),className:`h-9 w-full rounded-md border bg-background px-2 font-mono text-xs`,children:r.map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e))}),(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),`Apply this schedule to the whole provider`]}),(0,Q.jsxs)(`select`,{value:c,onChange:e=>l(e.target.value),className:`h-9 w-full rounded-md border bg-background px-2 text-xs`,children:[(0,Q.jsx)(`option`,{value:`blackout`,children:`Do not use during selected times`}),(0,Q.jsx)(`option`,{value:`allow_only`,children:`Use only during selected times`})]}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:as.map((e,t)=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>d(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t].sort()),className:`rounded px-2 py-1 text-xs ${u.includes(t)?`bg-primary text-primary-foreground`:`bg-muted text-muted-foreground`}`,children:e},e))}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(fi,{type:`time`,value:f,onChange:e=>p(e.target.value)}),(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`to`}),(0,Q.jsx)(fi,{type:`time`,value:m,onChange:e=>h(e.target.value)}),(0,Q.jsxs)(X,{type:`button`,variant:`outline`,onClick:()=>{let t=i.indexOf(`/`);if(t<=0)return;let r=i.slice(0,t),a=i.slice(t+1);n([...e,{id:`calendar-${Date.now().toString(36)}`,provider:r,...o?{}:{model:a},days:u,start:f,end:m,timezone:g,enabled:!0,mode:c,label:o?`${r} availability schedule`:`${i} availability schedule`}])},disabled:!i||u.length===0,children:[(0,Q.jsx)(jt,{className:`mr-1 h-3.5 w-3.5`}),` Add schedule`]})]}),(0,Q.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,children:[`Timezone: `,g,`. Overnight windows such as 22:00–07:00 are supported.`]})]})]})}function Xc({value:e,candidates:t,onChange:n,placeholder:r,emptyHint:i}){let{t:a}=V(),o=(t,r)=>{let i=t+r;if(i<0||i>=e.length)return;let a=[...e];[a[t],a[i]]=[a[i],a[t]],n(a)},s=t=>n(e.filter((e,n)=>n!==t));return(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[e.length>0&&(0,Q.jsx)(`ol`,{className:`space-y-1`,children:e.map((t,n)=>(0,Q.jsxs)(`li`,{className:`flex items-center gap-1.5 rounded-md border border-border bg-muted px-2 py-1 text-xs`,children:[(0,Q.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:n+1}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-foreground`,children:t}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>o(n,-1),disabled:n===0,className:`text-muted-foreground hover:text-foreground disabled:opacity-30`,title:a(`activity:fallback.moveUp`),children:(0,Q.jsx)(Ve,{className:`h-3 w-3`})}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>o(n,1),disabled:n===e.length-1,className:`text-muted-foreground hover:text-foreground disabled:opacity-30`,title:a(`activity:fallback.moveDown`),children:(0,Q.jsx)(F,{className:`h-3 w-3`})}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>s(n),className:`text-muted-foreground hover:text-destructive`,title:a(`common:action.remove`),children:(0,Q.jsx)(vn,{className:`h-3 w-3`})})]},`${t}-${n}`))}),(0,Q.jsx)(ti,{candidates:t,placeholder:r??a(`activity:fallback.placeholder`),onPick:(t,r)=>{let i=`${r}/${t}`;e.includes(i)||n([...e,i])}}),e.length===0&&(0,Q.jsxs)(`p`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground`,children:[(0,Q.jsx)(jt,{className:`h-2.5 w-2.5`}),` `,i??a(`activity:fallback.emptyHint`)]})]})}function Zc({options:e,selectedId:t,onSelect:n,className:r,showNone:i,noneLabel:a,emptyMessage:o}){return(0,Q.jsxs)(`div`,{className:G(`space-y-1`,r),children:[i&&(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>n(``),className:G(`w-full flex items-center justify-between p-3 rounded-lg border text-left transition-all`,t?`border-border hover:bg-muted`:`border-primary bg-primary/5 ring-2 ring-primary/20`),children:[(0,Q.jsx)(`span`,{className:`font-medium text-sm`,children:a??`None`}),!t&&(0,Q.jsx)(Gt,{className:`h-4 w-4 text-primary shrink-0`})]}),e.length===0&&o&&!i&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:o}),e.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>n(e.id),className:G(`w-full flex items-center justify-between p-3 rounded-lg border text-left transition-all`,t===e.id?`border-primary bg-primary/5 ring-2 ring-primary/20`:`border-border hover:bg-muted`),children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-sm`,children:e.label}),e.sublabel&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground ml-2`,children:e.sublabel}),e.badges&&e.badges.length>0&&(0,Q.jsx)(`div`,{className:`flex gap-2 mt-1 flex-wrap`,children:e.badges.map(e=>(0,Q.jsx)(`span`,{className:`text-xs bg-muted px-1.5 py-0.5 rounded`,children:e},e))})]}),(0,Q.jsxs)(`div`,{className:`text-right shrink-0 ml-2`,children:[e.detail&&(0,Q.jsx)(`div`,{className:G(`text-xs`,e.detailHighlight?`text-foreground font-medium`:`text-muted-foreground`),children:e.detail}),e.rightContent??(t===e.id&&(0,Q.jsx)(Gt,{className:`h-4 w-4 text-primary mt-1 ml-auto`}))]})]},e.id))]})}function Qc({open:e,mode:t,title:n,hint:r,fallbackProfiles:i,onPick:a,onClose:o,clearLabel:s=`Clear`}){let c=ei(e&&t!==`fallback`),[l,u]=(0,Z.useState)(``),[d,f]=(0,Z.useState)(0),[p,m]=(0,Z.useState)(`fallback`),h=(0,Z.useRef)(null);(t===`fallback`||t===`both`)&&i&&Object.keys(i).length;let g=t===`provider-model`||t===`both`;(0,Z.useEffect)(()=>{e&&(u(``),f(0),t===`both`||t===`fallback`?m(`fallback`):t===`provider-model`&&m(`models`))},[e,t]);let _=(0,Z.useMemo)(()=>{if(!g)return[];let e=l.trim().toLowerCase();return e?c.filter(t=>`${t.provider}/${t.model} ${t.label}`.toLowerCase().includes(e)):c},[c,l,g]);(0,Z.useEffect)(()=>{g&&f(e=>Math.min(e,Math.max(0,_.length-1)))},[_.length,g]),(0,Z.useEffect)(()=>{h.current?.querySelector(`[data-cursor="true"]`)?.scrollIntoView({block:`nearest`})},[d]);let v=e=>{e&&a({type:`provider-model`,provider:e.provider,model:e.model,label:`${e.provider}/${e.model}`})!==!0&&o()},y=e=>{e?a({type:`fallback-profile`,name:e})!==!0&&o():(a({type:`clear`}),o())},b=(0,Z.useMemo)(()=>i?Object.entries(i).map(([e,t])=>({id:e,label:e,sublabel:void 0,detail:t.length>0?`${t[0]}${t.length>1?` …`:``}`:void 0,detailHighlight:!0,badges:t.slice(0,3),rightContent:void 0})):[],[i]);return(0,Q.jsx)($r,{open:e,onOpenChange:e=>!e&&o(),children:(0,Q.jsxs)(Xr,{className:`max-w-md gap-3`,children:[(0,Q.jsxs)(Jr,{children:[(0,Q.jsx)(Zr,{className:`text-base`,children:n}),r&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r})]}),t===`both`&&(0,Q.jsxs)(`div`,{className:`flex gap-1 rounded-lg border border-border/70 bg-card/60 p-0.5`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{m(`fallback`),u(``)},className:G(`flex-1 rounded-md px-3 py-1.5 text-xs font-medium transition-all`,p===`fallback`?`bg-primary/10 text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`),children:[(0,Q.jsx)(vt,{className:`h-3 w-3 inline mr-1`}),`Fallback Profiles`]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{m(`models`),u(``)},className:G(`flex-1 rounded-md px-3 py-1.5 text-xs font-medium transition-all`,p===`models`?`bg-primary/10 text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`),children:[(0,Q.jsx)(Tn,{className:`h-3 w-3 inline mr-1`}),`Models`]})]}),(t===`fallback`||t===`both`&&p===`fallback`)&&(0,Q.jsxs)(`div`,{className:`max-h-80 space-y-1 overflow-y-auto`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>y(``),className:G(`w-full flex items-center justify-between p-3 rounded-lg border text-left transition-all`,`border-border hover:bg-muted`),children:(0,Q.jsx)(`span`,{className:`font-medium text-sm`,children:s})}),b.length>0?(0,Q.jsx)(Zc,{options:b,selectedId:``,onSelect:e=>y(e)}):(0,Q.jsx)(`p`,{className:`py-4 text-center text-xs text-muted-foreground`,children:`No fallback profiles configured.`})]}),(t===`provider-model`||t===`both`&&p===`models`)&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border bg-background px-2`,children:[(0,Q.jsx)(Tn,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,Q.jsx)(`input`,{autoFocus:t===`provider-model`,value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),f(e=>Math.min(e+1,Math.max(0,_.length-1)))):e.key===`ArrowUp`?(e.preventDefault(),f(e=>Math.max(e-1,0))):e.key===`Enter`&&(e.preventDefault(),v(_[d]))},placeholder:`Search ${c.length} models…`,className:`h-8 w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground`})]}),(0,Q.jsx)(`div`,{ref:h,className:`max-h-72 space-y-0.5 overflow-y-auto`,children:_.length===0?(0,Q.jsx)(`p`,{className:`py-4 text-center text-xs text-muted-foreground`,children:c.length===0?`Loading models…`:`No models match "${l}"`}):_.map((e,t)=>{let n=_[t-1]?.provider;return(0,Q.jsxs)(`div`,{children:[e.provider!==n&&(0,Q.jsx)(`div`,{className:`sticky top-0 bg-card px-1 pt-1.5 pb-0.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:e.provider}),(0,Q.jsxs)(`button`,{type:`button`,"data-cursor":t===d,onMouseEnter:()=>f(t),onClick:()=>v(e),className:G(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs`,t===d?`bg-primary/15 text-foreground`:`hover:bg-muted/60`),children:[(0,Q.jsx)(`span`,{className:`truncate font-mono`,children:e.model}),e.label!==e.model&&(0,Q.jsx)(`span`,{className:`truncate text-muted-foreground`,children:e.label})]})]},`${e.provider}/${e.model}`)})})]}),(0,Q.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:t===`fallback`?`Click a profile to select`:`↑/↓ navigate · Enter select · Esc close`})]})})}var $c=xe(`inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2`,{variants:{variant:{default:`border-transparent bg-primary text-primary-foreground hover:bg-primary/80`,secondary:`border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80`,destructive:`border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80`,outline:`text-foreground`}},defaultVariants:{variant:`default`}});function el({className:e,variant:t,...n}){return(0,Q.jsx)(`div`,{className:G($c({variant:t}),e),...n})}function tl({label:e,hint:t,value:n,min:r,max:i,step:a=1,onChange:o,unit:s}){let c=(0,Z.useId)();return(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3 py-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`label`,{htmlFor:c,className:`text-sm font-medium`,children:e}),t&&(0,Q.jsx)(`div`,{className:`text-xs text-muted-foreground mt-0.5`,children:t})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,Q.jsx)(`input`,{id:c,type:`range`,min:r,max:i,step:a,value:n,onChange:e=>o(Number(e.target.value)),className:`w-24 h-1.5 accent-primary`}),(0,Q.jsxs)(`span`,{className:`text-xs tabular-nums w-10 text-right text-muted-foreground`,"aria-hidden":!0,children:[n,s??``]})]})]})}function nl({label:e,hint:t,value:n,options:r,onChange:i}){let a=(0,Z.useId)();return(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3 py-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`label`,{htmlFor:a,className:`text-sm font-medium`,children:e}),t&&(0,Q.jsx)(`div`,{className:`text-xs text-muted-foreground mt-0.5`,children:t})]}),(0,Q.jsx)(`select`,{id:a,value:n,onChange:e=>i(e.target.value),className:`shrink-0 h-8 rounded-md border bg-background px-2 text-xs`,children:r.map(e=>(0,Q.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})}function $({label:e,hint:t,selector:n,onChange:r,configKey:i,value:a}){let o=typeof a==`boolean`,s=U(e=>n?n(e):!1),c=q(e=>i?e[i]:!1),l=o?a:n?s:c,u=()=>{if(o)r?.();else if(n)r?.();else if(i===`soundOnComplete`){let e=!q.getState().soundOnComplete;q.getState().setSoundOnComplete(e),e&&rr()}},d=(0,Z.useId)();return(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3 py-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`label`,{htmlFor:d,className:`text-sm font-medium`,children:e}),t&&(0,Q.jsx)(`div`,{className:`text-xs text-muted-foreground mt-0.5`,children:t})]}),(0,Q.jsx)(`button`,{type:`button`,id:d,role:`switch`,"aria-checked":l,"aria-label":e,onClick:u,className:G(`shrink-0 relative inline-flex h-5 w-9 rounded-full border transition-colors`,l?`bg-primary border-primary`:`bg-muted border-input hover:bg-muted/80`),children:(0,Q.jsx)(`span`,{className:G(`absolute top-0.5 left-0.5 h-3.5 w-3.5 rounded-full bg-background shadow transition-transform`,l&&`translate-x-4`)})})]})}var rl=[`off`,`low`,`medium`,`high`,`all`],il={off:`bg-muted-foreground`,low:`bg-success`,medium:`bg-warning`,high:`bg-warning ring-2 ring-warning/25`,all:`bg-destructive`},al={off:`Human decides everything`,low:`Auto-decide low risk only`,medium:`Auto-decide up to medium risk`,high:`Auto-decide up to high risk`,all:`Auto-decide everything`},ol=[`executor`,`skeptic`,`auditor`],sl=[{value:`default`,label:`Default (15s)`},{value:`5000`,label:`5s`},{value:`10000`,label:`10s`},{value:`20000`,label:`20s`},{value:`30000`,label:`30s`},{value:`60000`,label:`60s`}],cl=[{value:`off`,label:`Wait forever`},{value:`30000`,label:`30s`},{value:`60000`,label:`1m`},{value:`120000`,label:`2m`},{value:`300000`,label:`5m`}],ll=[{value:`default`,label:`Default (0.5)`},{value:`0.34`,label:`1/3`},{value:`0.5`,label:`1/2`},{value:`0.67`,label:`2/3`},{value:`0.75`,label:`3/4`},{value:`1`,label:`All`}];function ul({level:e}){return(0,Q.jsx)(`span`,{className:G(`inline-block h-2.5 w-2.5 rounded-full`,il[e])})}function dl(e){return e.provider?`${e.provider}/${e.model}`:e.model}var fl={pool:{title:`Add Brain pool model`,hint:`Ordered decision pool — first is primary.`},voter:{title:`Add council voter`,hint:`Dialog stays open — add ≥2 voters, then close.`},judge:{title:`Pick council judge`,hint:`Tie-breaker that sees every vote.`}};function pl(){let{client:e}=dr(),[t,n]=(0,Z.useState)(null),[r,i]=(0,Z.useState)([]),[a,o]=(0,Z.useState)(!0),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(null);(0,Z.useEffect)(()=>{e.send({type:`brain.status`}),e.send({type:`brain.config.get`})},[e]),(0,Z.useEffect)(()=>{let t=e.on(`brain.status`,e=>{let t=e.payload,n=Date.now();i(t.log.slice(-10).map(e=>{let t=Math.max(0,Math.round((n-e.at)/1e3)),r=t<60?`${t}s`:t<3600?`${Math.round(t/60)}m`:`${Math.round(t/3600)}h`;return{kind:e.kind,question:e.question,outcome:e.outcome,age:r}})),o(!1)}),r=e.on(`brain.config`,e=>{let t=e.payload;n(t.config),u(t.persisted?null:t.error??`Settings applied live but not saved.`),c(!1),o(!1)});return()=>{t(),r()}},[e]);let p=(0,Z.useCallback)(t=>{c(!0),e.send({type:`brain.config.set`,payload:{patch:t}})},[e]),m=(0,Z.useCallback)(e=>{n(t=>t&&{...t,maxAutoRisk:e}),p({maxAutoRisk:e})},[p]),h=(0,Z.useMemo)(()=>t?.council.voters??[],[t]),_=(0,Z.useCallback)(e=>{p({council:{voters:e.length>0?e:null}})},[p]),v=rl.includes(t?.maxAutoRisk??``)?t?.maxAutoRisk??`medium`:`medium`,y=(0,Z.useCallback)(e=>{if(!t||!d)return;let n=`${e.provider}/${e.model}`;if(d===`pool`){p({models:[...t.models.map(dl),n]});return}if(d===`judge`){p({council:{judge:n}});return}return _([...h,{provider:e.provider,model:e.model,persona:ol[h.length%ol.length]}]),!0},[t,d,p,_,h]);return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(Qc,{open:d!==null,mode:`provider-model`,title:d?fl[d].title:``,hint:d?fl[d].hint:void 0,onPick:e=>{if(e.type===`provider-model`)return y(e)},onClose:()=>f(null)}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(`span`,{className:`flex h-9 w-9 items-center justify-center rounded-md border border-primary/20 bg-primary/10 text-primary`,children:(0,Q.jsx)(on,{className:`h-5 w-5`})}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`h3`,{className:`text-base font-semibold`,children:`Brain`}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Decision models, council, escalation and risk ceiling — applied live, saved to the global config.`})]}),(a||s)&&(0,Q.jsx)(g,{className:`ml-auto h-4 w-4 animate-spin text-muted-foreground`})]}),l&&(0,Q.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:l}),(0,Q.jsxs)(`div`,{className:`space-y-2 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium`,children:`Autonomy ceiling`}),(0,Q.jsx)(`div`,{className:`flex gap-2 flex-wrap`,children:rl.map(e=>(0,Q.jsxs)(X,{variant:v===e?`default`:`outline`,size:`sm`,className:G(`gap-1.5 text-xs`,v===e&&`shadow-sm`),disabled:s,onClick:()=>m(e),children:[(0,Q.jsx)(ul,{level:e}),e.toUpperCase()]},e))}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:al[v]})]}),t&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium`,children:`Escalation`}),(0,Q.jsx)(nl,{label:`Mode`,hint:`Headless: the Brain never blocks on a human — unanswered escalations resolve via the safe terminal policy. Applies to CLI/TUI sessions; the standalone WebUI Brain is always headless.`,value:t.mode,options:[{value:`interactive`,label:`Interactive (ask me)`},{value:`headless`,label:`Headless (never ask)`}],onChange:e=>p({mode:e})}),(0,Q.jsx)(nl,{label:`Decision timeout`,hint:`Per-LLM-call time budget for one Brain decision.`,value:t.decisionTimeoutMs?String(t.decisionTimeoutMs):`default`,options:sl,onChange:e=>p({decisionTimeoutMs:e==="default"?null:Number(e)})}),(0,Q.jsx)(nl,{label:`Human answer timeout`,hint:`Interactive mode: how long an escalation prompt may wait before the terminal policy resolves it.`,value:t.humanTimeoutMs?String(t.humanTimeoutMs):`off`,options:cl,onChange:e=>p({humanTimeoutMs:e===`off`?null:Number(e)})})]}),(0,Q.jsxs)(`div`,{className:`space-y-2 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium`,children:`Decision models`}),(0,Q.jsx)(el,{variant:`outline`,className:`text-[10px]`,children:t.usingSessionModel?`session model`:`${t.poolLabels.length}/${t.models.length} resolved`})]}),(0,Q.jsx)($,{label:`Use session model`,hint:`Decide with whatever model the session is running. Turn off by adding models below.`,value:t.usingSessionModel,onChange:()=>{t.usingSessionModel||p({models:null})}}),t.models.length>0&&(0,Q.jsx)(`div`,{className:`space-y-1`,children:t.models.map((e,n)=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border/50 bg-background/40 px-2 py-1.5 text-xs`,children:[(0,Q.jsxs)(`span`,{className:`text-muted-foreground w-4 shrink-0`,children:[n+1,`.`]}),(0,Q.jsx)(`span`,{className:`flex-1 truncate font-mono`,children:dl(e)}),(0,Q.jsx)(X,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0`,disabled:s||n===0,onClick:()=>{let e=t.models.map(dl),r=e.splice(n,1)[0];r&&e.splice(n-1,0,r),p({models:e})},children:(0,Q.jsx)(Ve,{className:`h-3 w-3`})}),(0,Q.jsx)(X,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0`,disabled:s||n===t.models.length-1,onClick:()=>{let e=t.models.map(dl),r=e.splice(n,1)[0];r&&e.splice(n+1,0,r),p({models:e})},children:(0,Q.jsx)(F,{className:`h-3 w-3`})}),(0,Q.jsx)(X,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 text-destructive`,disabled:s,onClick:()=>{let e=t.models.map(dl).filter((e,t)=>t!==n);p({models:e.length>0?e:null})},children:(0,Q.jsx)(vn,{className:`h-3 w-3`})})]},`${dl(e)}-${n}`))}),(0,Q.jsxs)(X,{variant:`outline`,size:`sm`,className:`gap-1.5 text-xs`,disabled:s,onClick:()=>f(`pool`),children:[(0,Q.jsx)(jt,{className:`h-3.5 w-3.5`}),` Add model`]}),t.models.length>1&&(0,Q.jsx)(nl,{label:`Pool strategy`,hint:`Fallback: first model is primary, the rest are tried in order on failure. Round-robin: decisions rotate across the pool.`,value:t.strategy,options:[{value:`fallback`,label:`Fallback`},{value:`round-robin`,label:`Round-robin`}],onChange:e=>p({strategy:e})})]}),(0,Q.jsxs)(`div`,{className:`space-y-2 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium`,children:`Council`}),(0,Q.jsx)(el,{variant:t.council.enabled?`default`:`outline`,className:`text-[10px]`,children:t.council.enabled?`convened`:`disabled`})]}),(0,Q.jsx)($,{label:`Enable multi-LLM council`,hint:`High-stakes questions are voted on by independent seats (executor / skeptic-with-veto / auditor) instead of one model. Needs ≥2 resolvable voters (explicit seats below, or a ≥2-model pool).`,value:t.council.enabled,onChange:()=>p({council:{enabled:!t.council.enabled}})}),t.council.enabled&&t.councilLabels.length>0&&h.length===0&&(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Seats derived from the pool: `,t.councilLabels.join(`, `)]}),h.length>0&&(0,Q.jsx)(`div`,{className:`space-y-1`,children:h.map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border/50 bg-background/40 px-2 py-1.5 text-xs`,children:[(0,Q.jsx)(`span`,{className:`flex-1 truncate font-mono`,children:dl(e)}),(0,Q.jsxs)(`select`,{value:e.persona??ol[t%ol.length],onChange:e=>_(h.map((n,r)=>r===t?{...n,persona:e.target.value}:n)),className:`h-6 rounded border bg-background px-1 text-[10px]`,children:[ol.map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e)),e.persona&&!ol.includes(e.persona)&&(0,Q.jsx)(`option`,{value:e.persona,children:e.persona})]}),(0,Q.jsx)(X,{variant:e.veto?`default`:`outline`,size:`sm`,className:`h-6 px-1.5 text-[10px]`,disabled:s,onClick:()=>_(h.map((e,n)=>n===t?{...e,veto:!e.veto}:e)),children:`veto`}),(0,Q.jsx)(X,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 text-destructive`,disabled:s,onClick:()=>_(h.filter((e,n)=>n!==t)),children:(0,Q.jsx)(vn,{className:`h-3 w-3`})})]},`${dl(e)}-${t}`))}),(0,Q.jsxs)(X,{variant:`outline`,size:`sm`,className:`gap-1.5 text-xs`,disabled:s,onClick:()=>f(`voter`),children:[(0,Q.jsx)(jt,{className:`h-3.5 w-3.5`}),` Add voter`]}),(0,Q.jsx)(nl,{label:`Risk floor`,hint:`Minimum question risk that convenes the council instead of the single-model tier.`,value:t.council.minRisk,options:[{value:`medium`,label:`Medium+`},{value:`high`,label:`High+`},{value:`critical`,label:`Critical only`}],onChange:e=>p({council:{minRisk:e}})}),(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3 py-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-medium`,children:`Judge`}),(0,Q.jsx)(`div`,{className:`mt-0.5 text-xs text-muted-foreground`,children:`Tie-breaker model that sees every vote's rationale.`})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`max-w-[180px] truncate font-mono text-xs`,children:t.council.judge?dl(t.council.judge):`auto`}),(0,Q.jsx)(X,{variant:`outline`,size:`sm`,className:`h-7 text-xs`,disabled:s,onClick:()=>f(`judge`),children:`Pick…`}),t.council.judge&&(0,Q.jsx)(X,{variant:`ghost`,size:`sm`,className:`h-7 text-xs`,disabled:s,onClick:()=>p({council:{judge:null}}),children:`Auto`})]})]}),(0,Q.jsx)(nl,{label:`Quorum`,hint:`Fraction of seats that must return a valid vote.`,value:t.council.quorum===void 0?`default`:String(t.council.quorum),options:ll,onChange:e=>p({council:{quorum:e==="default"?null:Number(e)}})}),(0,Q.jsx)(nl,{label:`Approval`,hint:`Fraction of cast vote weight the winning option must exceed.`,value:t.council.approval===void 0?`default`:String(t.council.approval),options:ll,onChange:e=>p({council:{approval:e==="default"?null:Number(e)}})})]}),(0,Q.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium`,children:`Decision ledger`}),(0,Q.jsx)($,{label:`Record decisions + outcomes`,hint:`Persists every decision and its observed outcome; similar past outcomes are fed back into future Brain prompts.`,value:t.ledger.enabled,onChange:()=>p({ledger:{enabled:!t.ledger.enabled}})}),(0,Q.jsx)(nl,{label:`Auto-deny after failures`,hint:`Deny deterministically (no LLM) once this many consecutive approvals of a decision group ended in observed failures.`,value:t.ledger.autoDenyAfterFailures===void 0?`default`:String(t.ledger.autoDenyAfterFailures),options:[{value:`default`,label:`Default (3)`},{value:`0`,label:`Off`},{value:`2`,label:`2`},{value:`3`,label:`3`},{value:`5`,label:`5`}],onChange:e=>p({ledger:{autoDenyAfterFailures:e==="default"?null:Number(e)}})}),t.ledger.path&&(0,Q.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:t.ledger.path})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-2 rounded-md border border-border/70 bg-card/70 p-3`,children:[(0,Q.jsxs)(`span`,{className:`text-sm font-medium`,children:[`Recent decisions (`,r.length,`)`]}),(0,Q.jsx)(`div`,{className:`space-y-1 max-h-[300px] overflow-y-auto`,children:r.length===0?(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground py-2`,children:`No decisions recorded yet this session.`}):r.map(e=>(0,Q.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-border/50 bg-background/40 px-2 py-1.5 text-xs`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground shrink-0 w-8`,children:e.age}),(0,Q.jsx)(el,{variant:`outline`,className:`text-[10px] shrink-0`,children:e.kind}),(0,Q.jsx)(`span`,{className:`flex-1 truncate`,children:e.question}),e.outcome&&(0,Q.jsx)(`span`,{className:`text-muted-foreground shrink-0 italic`,children:e.outcome})]},`${e.age}-${e.kind}-${e.question.slice(0,32)}`))})]})]})}function ml(){let{t:e}=V(),{wsUrl:t,setConfig:n}=q($t(e=>({wsUrl:e.wsUrl,setConfig:e.setConfig})));return(0,Q.jsxs)(nc,{value:`connection`,className:`mt-0 space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`label`,{htmlFor:`websocket-url`,className:`text-sm font-medium flex items-center gap-2`,children:[(0,Q.jsx)(Rn,{className:`h-4 w-4 text-muted-foreground`}),e(`settings:connection.wsUrlLabel`)]}),(0,Q.jsx)(fi,{id:`websocket-url`,value:t,onChange:e=>n({wsUrl:e.target.value}),placeholder:e(`settings:connection.wsUrlPlaceholder`),className:`font-mono text-sm`}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings:connection.wsUrlHint`)})]}),(0,Q.jsxs)(`div`,{className:`p-4 rounded-lg border bg-muted/50`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium mb-2`,children:e(`settings:connection.startingHeading`)}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mb-3`,children:e(`settings:connection.startingBody`)})]})]})}function hl(){let{t:e}=V(),{theme:t,setTheme:n}=Ti(),{updatePrefs:r}=dr(),i=W(),a=(0,Z.useCallback)((e,t)=>{i.set({[e]:t}),r({[e]:t})},[i,r]),o=(0,Z.useCallback)(e=>{i.set({uiLocale:e}),H.language!==e&&H.changeLanguage(e),a(`uiLocale`,e)},[i,a]);return(0,Q.jsxs)(nc,{value:`appearance`,className:`mt-0 space-y-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold mb-3`,children:e(`settings:appearance.themeHeading`)}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 max-w-md`,children:[(0,Q.jsxs)(X,{variant:t===`light`?`default`:`outline`,size:`sm`,onClick:()=>n(`light`),children:[(0,Q.jsx)(ln,{className:`h-4 w-4 mr-1`}),e(`settings:appearance.themeLight`)]}),(0,Q.jsxs)(X,{variant:t===`dark`?`default`:`outline`,size:`sm`,onClick:()=>n(`dark`),children:[(0,Q.jsx)(A,{className:`h-4 w-4 mr-1`}),e(`settings:appearance.themeDark`)]}),(0,Q.jsxs)(X,{variant:t===`system`?`default`:`outline`,size:`sm`,onClick:()=>n(`system`),children:[(0,Q.jsx)(E,{className:`h-4 w-4 mr-1`}),e(`settings:appearance.themeSystem`)]})]}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-2`,children:e(`settings:appearance.themeSystemHint`)})]}),(0,Q.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold mb-3 mt-3`,children:e(`settings:appearance.languageHeading`)}),(0,Q.jsx)(nl,{label:e(`settings:appearance.languageLabel`),hint:e(`settings:appearance.languageHint`),value:i.uiLocale,options:er.map(e=>({value:e.code,label:e.name})),onChange:o})]}),(0,Q.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold mb-3 mt-3`,children:e(`settings:appearance.preferencesHeading`)}),(0,Q.jsx)($,{label:e(`settings:appearance.compactDensity`),hint:e(`settings:appearance.compactDensityHint`),selector:e=>e.compactMode,onChange:()=>U.getState().toggleCompactMode()}),(0,Q.jsx)($,{label:e(`settings:appearance.soundOnComplete`),hint:e(`settings:appearance.soundOnCompleteHint`),selector:null,configKey:`soundOnComplete`}),(0,Q.jsx)($,{label:e(`settings:appearance.titleAnimation`),hint:e(`settings:appearance.titleAnimationHint`),value:i.titleAnimation,onChange:()=>a(`titleAnimation`,!i.titleAnimation)}),(0,Q.jsx)($,{label:e(`settings:appearance.showThinkingLabel`),hint:e(`settings:appearance.showThinkingHint`),value:i.showThinkingLogs,onChange:()=>a(`showThinkingLogs`,!i.showThinkingLogs)}),(0,Q.jsx)($,{label:e(`settings:appearance.groupToolCallsLabel`),hint:e(`settings:appearance.groupToolCallsHint`),value:i.groupToolCalls,onChange:()=>a(`groupToolCalls`,!i.groupToolCalls)})]})]})}function gl({syncPref:e,sessionProvider:t,sessionModel:n}){let{t:r}=V(),i=W(),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),l=i.fallbackProfiles??{},u=i.autoReviewFallbackProfile?l[i.autoReviewFallbackProfile]??[]:i.autoReviewFallbackModels??[],d=(0,Z.useCallback)(()=>o(!0),[]),f=(0,Z.useCallback)(()=>o(!1),[]),p=(0,Z.useCallback)(()=>c(!0),[]),m=(0,Z.useCallback)(()=>c(!1),[]);return(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`h3`,{className:`text-sm font-semibold mb-2 flex items-center gap-2`,children:[(0,Q.jsx)(ke,{className:`h-4 w-4 text-muted-foreground`}),r(`settings:features.chimeraDedicatedHeading`)]}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`settings:features.chimeraDedicatedHint`)})]}),(0,Q.jsxs)(`section`,{className:G(`space-y-3 rounded-lg border p-4`,i.chimeraEnabled?`border-border/70 bg-card/40`:`border-dashed border-border/50 bg-muted/30`),children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-semibold`,children:r(`settings:features.chimeraSectionEnabled`)}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:r(`settings:features.chimeraSectionEnabledHint`)})]}),(0,Q.jsx)($,{label:r(`settings:features.chimeraSectionEnabled`),hint:r(`settings:features.chimeraSectionEnabledHint`),value:i.chimeraEnabled,onChange:()=>e(`chimeraEnabled`,!i.chimeraEnabled)})]}),(0,Q.jsx)(`div`,{className:`pt-2 border-t`,children:(0,Q.jsx)(nl,{label:r(`settings:features.chimeraProviderLabel`),hint:r(`settings:features.chimeraProviderHint`),value:i.chimeraProvider,options:[{value:``,label:t?`${r(`settings:features.chimeraProviderSessionDefault`)} (${t})`:r(`settings:features.chimeraProviderSessionDefault`)},...i.chimeraProvider&&i.chimeraProvider!==t?[{value:i.chimeraProvider,label:i.chimeraProvider}]:[]],onChange:t=>e(`chimeraProvider`,t)})}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-border p-3 cursor-pointer hover:bg-muted/50 transition-colors`,onClick:d,role:`button`,tabIndex:0,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),d())},children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:r(`settings:features.chimeraModelLabel`)}),(0,Q.jsx)(`div`,{className:`text-xs font-medium mt-0.5`,children:i.chimeraProvider||t?(0,Q.jsxs)(`span`,{className:`font-mono`,children:[i.chimeraProvider||t,`/`,i.chimeraModel||n||r(`settings:features.chimeraModelSessionDefault`)]}):(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:r(`settings:features.chimeraModelSessionDefault`)})}),(0,Q.jsx)(`p`,{className:`text-[10px] text-muted-foreground mt-0.5`,children:r(`settings:features.chimeraModelHint`)})]}),(0,Q.jsx)(Tt,{className:`h-4 w-4 shrink-0 text-muted-foreground`})]}),(0,Q.jsx)(tl,{label:r(`settings:features.chimeraMaxFilesLabel`),hint:r(`settings:features.chimeraMaxFilesHint`),value:i.chimeraMaxFiles,min:1,max:50,step:1,onChange:t=>e(`chimeraMaxFiles`,t)}),(0,Q.jsx)(`div`,{className:`pt-2 border-t`,children:(0,Q.jsx)(nl,{label:r(`settings:features.chimeraAutoFixLabel`),hint:r(`settings:features.chimeraAutoFixHint`),value:i.chimeraAutoFix,options:[{value:`off`,label:r(`settings:features.chimeraAutoFixOff`)},{value:`ask`,label:r(`settings:features.chimeraAutoFixAsk`)},{value:`auto`,label:r(`settings:features.chimeraAutoFixAuto`)}],onChange:t=>e(`chimeraAutoFix`,t)})})]}),(0,Q.jsxs)(`section`,{className:G(`space-y-3 rounded-lg border p-4`,i.autoReviewEnabled?`border-border/70 bg-card/40`:`border-dashed border-border/50 bg-muted/30`),children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-semibold`,children:r(`settings:features.autoReviewSectionEnabled`)}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:r(`settings:features.autoReviewSectionEnabledHint`)})]}),(0,Q.jsx)($,{label:r(`settings:features.autoReviewSectionEnabled`),hint:r(`settings:features.autoReviewSectionEnabledHint`),value:i.autoReviewEnabled,onChange:()=>e(`autoReviewEnabled`,!i.autoReviewEnabled)})]}),(0,Q.jsx)(`div`,{className:`pt-2 border-t`,children:(0,Q.jsx)(nl,{label:r(`settings:features.autoReviewFallbackProfileLabel`),hint:r(`settings:features.autoReviewFallbackProfileHint`),value:i.autoReviewFallbackProfile,options:[{value:``,label:r(`settings:features.autoReviewFallbackProfileNone`)},...Object.keys(l).sort((e,t)=>e.localeCompare(t)).map(e=>({value:e,label:`${e} (${(l[e]??[]).length})`}))],onChange:t=>e(`autoReviewFallbackProfile`,t)})}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:r(`settings:features.autoReviewFallbackModelsLabel`)}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1 rounded-md border border-border bg-muted/30 px-2 py-1.5 min-h-[2rem]`,children:u.length===0?(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground italic`,children:r(`settings:features.autoReviewFallbackModelsEmpty`)}):u.map((e,t)=>(0,Q.jsx)(`span`,{className:`text-xs font-mono px-1.5 py-0.5 rounded bg-primary/10 text-primary`,children:e},`${e}-${t}`))}),(0,Q.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:r(`settings:features.autoReviewFallbackModelsHint`)})]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-border p-3 cursor-pointer hover:bg-muted/50 transition-colors`,onClick:p,role:`button`,tabIndex:0,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),p())},children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:r(`settings:features.autoReviewModelLabel`)}),(0,Q.jsx)(`div`,{className:`text-xs font-medium mt-0.5`,children:i.autoReviewProvider||t?(0,Q.jsxs)(`span`,{className:`font-mono`,children:[i.autoReviewProvider||t,`/`,i.autoReviewModel||n||r(`settings:features.chimeraModelSessionDefault`)]}):(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:r(`settings:features.chimeraModelSessionDefault`)})}),(0,Q.jsx)(`p`,{className:`text-[10px] text-muted-foreground mt-0.5`,children:r(`settings:features.autoReviewModelHint`)})]}),(0,Q.jsx)(Tt,{className:`h-4 w-4 shrink-0 text-muted-foreground`})]}),(0,Q.jsx)(`div`,{className:`pt-2 border-t`,children:(0,Q.jsx)(tl,{label:r(`settings:features.autoReviewDebounceLabel`),hint:r(`settings:features.autoReviewDebounceHint`),value:i.autoReviewDebounceMs,min:0,max:6e4,step:500,unit:`ms`,onChange:t=>e(`autoReviewDebounceMs`,t)})}),(0,Q.jsx)(tl,{label:r(`settings:features.autoReviewMaxFilesLabel`),hint:r(`settings:features.autoReviewMaxFilesHint`),value:i.autoReviewMaxFilesPerBatch,min:1,max:50,step:1,onChange:t=>e(`autoReviewMaxFilesPerBatch`,t)}),(0,Q.jsx)(tl,{label:r(`settings:features.autoReviewMaxConcurrentLabel`),hint:r(`settings:features.autoReviewMaxConcurrentHint`),value:i.autoReviewMaxConcurrentReviews,min:1,max:10,step:1,onChange:t=>e(`autoReviewMaxConcurrentReviews`,t)}),(0,Q.jsx)(`div`,{className:`pt-2 border-t`,children:(0,Q.jsx)(nl,{label:r(`settings:features.autoReviewCascadeLabel`),hint:r(`settings:features.autoReviewCascadeHint`),value:i.autoReviewCascadeOn,options:[{value:`off`,label:r(`settings:features.autoReviewCascadeOff`)},{value:`critical`,label:r(`settings:features.autoReviewCascadeCritical`)},{value:`high`,label:r(`settings:features.autoReviewCascadeHigh`)}],onChange:t=>e(`autoReviewCascadeOn`,t)})})]}),(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground flex items-center gap-1.5`,children:[(0,Q.jsx)(et,{className:`h-3 w-3`}),r(`settings:features.pluginsPerPluginHint`)]}),a&&(0,Q.jsx)(Qc,{open:a,mode:`provider-model`,title:r(`settings:features.chimeraPickModel`),hint:r(`settings:features.chimeraPickModelHint`),onPick:t=>{t.type===`provider-model`?(e(`chimeraProvider`,t.provider),e(`chimeraModel`,t.model)):t.type===`clear`&&(e(`chimeraProvider`,``),e(`chimeraModel`,``)),o(!1)},onClose:f}),s&&(0,Q.jsx)(Qc,{open:s,mode:`both`,title:r(`settings:features.autoReviewPickModel`),hint:r(`settings:features.autoReviewPickModelHint`),fallbackProfiles:l,onPick:t=>{t.type===`provider-model`?(e(`autoReviewProvider`,t.provider),e(`autoReviewModel`,t.model),e(`autoReviewFallbackProfile`,``)):t.type===`fallback-profile`?(e(`autoReviewProvider`,``),e(`autoReviewModel`,``),e(`autoReviewFallbackProfile`,t.name)):t.type===`clear`&&(e(`autoReviewProvider`,``),e(`autoReviewModel`,``),e(`autoReviewFallbackProfile`,``)),c(!1)},onClose:m})]})}var _l=[{name:`filesystem`,description:`Read, write, and navigate the local filesystem. Good for exploring projects.`,transport:`stdio`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-filesystem`,`.`]},{name:`github`,description:`GitHub API — issues, PRs, repos, search, and file operations.`,transport:`stdio`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-github`],requiresEnvVars:[`GITHUB_PERSONAL_ACCESS_TOKEN`],badge:`Popular`},{name:`context7`,description:`Codebase-aware documentation and Q&A grounded in your actual library versions.`,transport:`streamable-http`,url:`https://mcp.context7.com/mcp`,badge:`New`},{name:`brave-search`,description:`Web search via Brave Browser. Free tier: 2,000 queries/month.`,transport:`stdio`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-brave-search`],requiresEnvVars:[`BRAVE_SEARCH_API_KEY`]},{name:`google-maps`,description:`Directions, geocoding, places, and distance matrix via Google Maps.`,transport:`stdio`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-google-maps`],requiresEnvVars:[`GOOGLE_MAPS_API_KEY`]},{name:`aws`,description:`AWS — EC2, S3, Lambda, IAM, CloudFormation, and cost management.`,transport:`stdio`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-aws`],requiresEnvVars:[`AWS_ACCESS_KEY_ID`,`AWS_SECRET_ACCESS_KEY`]},{name:`slack`,description:`Slack — messaging, channels, and search.`,transport:`stdio`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-slack`],requiresEnvVars:[`SLACK_BOT_TOKEN`]},{name:`everart`,description:`AI image generation via multiple providers.`,transport:`stdio`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-everart`],requiresEnvVars:[`EVERART_API_KEY`]},{name:`sentinel`,description:`Security vulnerability scanning via Sentinel.`,transport:`streamable-http`,url:`https://mcp.sentinel.ai`,badge:`Security`},{name:`playwright`,description:`Browser automation — navigate, click, type, screenshot, evaluate JS (headless Chromium).`,transport:`stdio`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-playwright`],badge:`Browser`},{name:`zai-vision`,description:`Image analysis, screenshot understanding, and diagram interpretation.`,transport:`stdio`,command:`npx`,args:[`-y`,`@z_ai/mcp-server@latest`],env:{Z_AI_MODE:`ZAI`},requiresEnvVars:[`Z_AI_API_KEY`],allowedTools:[`image_analysis`,`extract_text_from_screenshot`,`diagnose_error_screenshot`,`understand_technical_diagram`,`analyze_data_visualization`,`ui_diff_check`],badge:`Vision`},{name:`minimax-vision`,description:`MiniMax image understanding via understand_image (read-only, safe for auto-run).`,transport:`stdio`,command:`uvx`,args:[`minimax-coding-plan-mcp`,`-y`],env:{MINIMAX_MCP_BASE_PATH:`./.wrongstack/minimax-output`,MINIMAX_API_HOST:`https://api.minimax.io`,MINIMAX_API_RESOURCE_MODE:`url`},requiresEnvVars:[`MINIMAX_API_KEY`],allowedTools:[`understand_image`],badge:`Vision`},{name:`block`,description:`Postgres database access via SQL (Block MCP server).`,transport:`stdio`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-block`],requiresEnvVars:[`DATABASE_URL`]}];function vl(e,t=!1){return{name:e.name,description:e.description,transport:e.transport,command:e.command,args:e.args,url:e.url,env:e.env,allowedTools:e.allowedTools,enabled:t}}function yl(e){switch(e){case`connected`:return{color:`bg-success`};case`connecting`:return{color:`bg-warning animate-pulse`};case`sleeping`:return{color:`bg-info`};case`discovering`:return{color:`bg-primary animate-pulse`};case`error`:return{color:`bg-destructive`};case`stopped`:return{color:`bg-muted-foreground`};default:return{color:`bg-muted-foreground/70`}}}function bl({status:e}){let{color:t}=yl(e);return(0,Q.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-full ${t}`})}function xl({server:e,onWake:t,onSleep:n,onDiscover:r,onEdit:i,onRemove:a}){let[o,s]=(0,Z.useState)(!1),{color:c}=yl(e.status),{t:l}=V();return(0,Q.jsxs)(`div`,{className:`rounded-md border border-border/70 bg-card/70 p-3 transition-colors hover:bg-card`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-2 text-left`,onClick:()=>s(!o),children:[o?(0,Q.jsx)(b,{className:`h-4 w-4 text-muted-foreground`}):(0,Q.jsx)(Kn,{className:`h-4 w-4 text-muted-foreground`}),(0,Q.jsx)(bl,{status:e.status}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:e.name}),(0,Q.jsx)(`span`,{className:`rounded bg-muted/60 px-1.5 py-0.5 text-xs text-muted-foreground`,children:e.transport}),!e.enabled&&(0,Q.jsx)(el,{variant:`outline`,className:`text-xs`,children:l(`settings:mcp.disabled`)})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[e.status===`sleeping`&&(0,Q.jsx)(X,{variant:`ghost`,size:`sm`,onClick:t,title:l(`settings:mcp.wakeTitle`),children:(0,Q.jsx)(ln,{className:`w-4 h-4`})}),(e.status===`connected`||e.status===`connecting`)&&(0,Q.jsx)(X,{variant:`ghost`,size:`sm`,onClick:n,title:l(`settings:mcp.sleepTitle`),children:(0,Q.jsx)(A,{className:`w-4 h-4`})}),(e.status===`stopped`||e.status===`sleeping`)&&(0,Q.jsx)(X,{variant:`ghost`,size:`sm`,onClick:r,title:l(`settings:mcp.discoverTitle`),children:(0,Q.jsx)(Tn,{className:`w-4 h-4`})}),(0,Q.jsx)(X,{variant:`ghost`,size:`sm`,onClick:i,title:l(`settings:mcp.editTitle`),children:(0,Q.jsx)(yn,{className:`w-4 h-4`})}),(0,Q.jsx)(X,{variant:`ghost`,size:`sm`,onClick:a,title:l(`settings:mcp.removeTitle`),className:`text-destructive hover:text-destructive`,children:(0,Q.jsx)(C,{className:`w-4 h-4`})})]})]}),o&&(0,Q.jsxs)(`div`,{className:`mt-3 space-y-2 border-t border-border/60 pl-6 pt-3 text-sm`,children:[(0,Q.jsxs)(`div`,{className:`grid grid-cols-[max-content_1fr] gap-x-3 gap-y-1`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:l(`settings:mcp.statusLabel`)}),(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-full ${c}`}),l(`settings:mcp.status.${e.status}`,{defaultValue:e.status})]}),(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:l(`settings:mcp.enabledLabel`)}),(0,Q.jsx)(`span`,{children:e.enabled?l(`settings:mcp.yes`):l(`settings:mcp.no`)}),e.description&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:l(`settings:mcp.descriptionLabel`)}),(0,Q.jsx)(`span`,{children:e.description})]}),e.pid&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:l(`settings:mcp.pidLabel`)}),(0,Q.jsx)(`span`,{children:e.pid})]}),e.error&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:l(`settings:mcp.errorLabel`)}),(0,Q.jsx)(`span`,{className:`text-destructive`,children:e.error})]}),e.health&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`Operational health`}),(0,Q.jsx)(`span`,{children:e.health.healthState}),(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`Failures (transport/protocol/tool)`}),(0,Q.jsxs)(`span`,{children:[e.health.failures.transport,`/`,e.health.failures.protocol,`/`,e.health.failures.tool]}),(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`Call latency p50/p95`}),(0,Q.jsxs)(`span`,{children:[e.health.callLatency.p50Ms??`-`,`ms /`,` `,e.health.callLatency.p95Ms??`-`,`ms`]}),(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`Reconnect / wake / sleep`}),(0,Q.jsxs)(`span`,{children:[e.health.reconnectCount,` / `,e.health.wakeCount,` /`,` `,e.health.sleepCount]}),(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`Calls in flight / peak`}),(0,Q.jsxs)(`span`,{children:[e.health.inFlightCalls,` / `,e.health.peakInFlightCalls]})]})]}),e.tools&&e.tools.length>0&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:l(`settings:mcp.toolsLabel`,{count:e.tools.length})}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-1`,children:e.tools.map(e=>(0,Q.jsx)(el,{variant:`secondary`,className:`text-xs`,children:e},e))})]}),(!e.tools||e.tools.length===0)&&e.status===`connected`&&(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:l(`settings:mcp.noTools`)})]})]})}function Sl({open:e,onOpenChange:t,server:n,onSave:r,prefillConfig:i}){let{t:a}=V(),[o,s]=(0,Z.useState)(n?.name??i?.name??``),[c,l]=(0,Z.useState)(n?.transport??i?.transport??`stdio`),[u,d]=(0,Z.useState)(n?.description??i?.description??``),[f,p]=(0,Z.useState)(i?.command??``),[m,h]=(0,Z.useState)(i?.args?.join(` `)??``),[g,_]=(0,Z.useState)(``),[v,y]=(0,Z.useState)(i?.url??``),[b,x]=(0,Z.useState)(n?.enabled??!0),[S,C]=(0,Z.useState)(n?.lazy??i?.lazy??!1);(0,Z.useEffect)(()=>{e&&(n?(s(n.name),l(n.transport),d(n.description??``),x(n.enabled),C(n.lazy??!1),p(``),h(``),_(``),y(``)):i?(s(i.name),l(i.transport),d(i.description??``),x(!0),C(i.lazy??!1),p(i.command??``),h(i.args?.join(` `)??``),_(i.env?Object.entries(i.env).map(([e,t])=>`${e}=${t}`).join(`
117
117
  `):``),y(i.url??``)):(s(``),l(`stdio`),d(``),x(!0),C(!1),p(``),h(``),_(``),y(``)))},[n,i,e]);let w=()=>{if(!o.trim()){Y.error(a(`settings:mcp.serverNameRequired`));return}let e={};if(g.trim())for(let t of g.trim().split(`
118
118
  `)){let n=t.indexOf(`=`);n>0&&(e[t.slice(0,n).trim()]=t.slice(n+1).trim())}r({name:o.trim(),transport:c,description:u.trim()||void 0,enabled:b,command:f.trim()||void 0,args:m.trim()?m.trim().split(/\s+/):void 0,env:Object.keys(e).length>0?e:void 0,url:v.trim()||void 0,lazy:S}),t(!1)},T=!!n,E=!!i;return(0,Q.jsx)($r,{open:e,onOpenChange:t,children:(0,Q.jsxs)(Xr,{children:[(0,Q.jsx)(Jr,{children:(0,Q.jsx)(Zr,{children:a(T?`settings:mcp.dialogTitleEdit`:E?`settings:mcp.dialogTitleAdd`:`settings:mcp.dialogTitleAddCustom`)})}),(0,Q.jsxs)(`div`,{className:`space-y-4 py-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium`,children:a(`settings:mcp.fieldName`)}),(0,Q.jsx)(fi,{value:o,onChange:e=>s(e.target.value),placeholder:a(`settings:mcp.fieldNamePlaceholder`),disabled:T||E})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium`,children:a(`settings:mcp.fieldTransport`)}),(0,Q.jsxs)(`select`,{className:`w-full h-10 px-3 rounded-md border border-input bg-background text-sm`,value:c,onChange:e=>l(e.target.value),disabled:E,children:[(0,Q.jsx)(`option`,{value:`stdio`,children:`stdio`}),(0,Q.jsx)(`option`,{value:`sse`,children:`sse`}),(0,Q.jsx)(`option`,{value:`streamable-http`,children:`streamable-http`}),(0,Q.jsx)(`option`,{value:`http`,children:`http`})]})]}),(c===`streamable-http`||c===`sse`||c===`http`)&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium`,children:a(`settings:mcp.fieldUrl`)}),(0,Q.jsx)(fi,{value:v,onChange:e=>y(e.target.value),placeholder:`https://mcp.example.com/mcp`,disabled:E})]}),c===`stdio`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium`,children:a(`settings:mcp.fieldCommand`)}),(0,Q.jsx)(fi,{value:f,onChange:e=>p(e.target.value),placeholder:a(`settings:mcp.fieldCommandPlaceholder`),disabled:E})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsxs)(`span`,{className:`text-sm font-medium`,children:[a(`settings:mcp.fieldArgs`),` `,(0,Q.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:a(`settings:mcp.fieldArgsHint`)})]}),(0,Q.jsx)(fi,{value:m,onChange:e=>h(e.target.value),placeholder:a(`settings:mcp.fieldArgsPlaceholder`),disabled:E})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsxs)(`span`,{className:`text-sm font-medium`,children:[a(`settings:mcp.fieldEnv`),` `,(0,Q.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:a(`settings:mcp.fieldEnvHint`)})]}),(0,Q.jsx)(`textarea`,{className:`w-full h-20 px-3 py-2 rounded-md border border-input bg-background text-sm font-mono resize-none`,value:g,onChange:e=>_(e.target.value),placeholder:`GITHUB_TOKEN=ghp_...
119
- AWS_REGION=us-east-1`})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium`,children:a(`settings:mcp.fieldDescription`)}),(0,Q.jsx)(fi,{value:u,onChange:e=>d(e.target.value),placeholder:a(`settings:mcp.fieldDescriptionPlaceholder`)})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,id:`server-enabled`,checked:b,onChange:e=>x(e.target.checked),className:`rounded`}),(0,Q.jsx)(`label`,{htmlFor:`server-enabled`,className:`text-sm`,children:a(`settings:mcp.enableServer`)})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,id:`server-lazy`,checked:S,onChange:e=>C(e.target.checked),className:`rounded`}),(0,Q.jsxs)(`label`,{htmlFor:`server-lazy`,className:`text-sm`,children:[a(`settings:mcp.lazyConnect`),` `,(0,Q.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:a(`settings:mcp.lazyConnectHint`)})]})]})]}),(0,Q.jsxs)(Yr,{children:[(0,Q.jsx)(X,{variant:`outline`,onClick:()=>t(!1),children:a(`common:action.cancel`)}),(0,Q.jsx)(X,{onClick:w,children:a(T?`settings:mcp.saveChanges`:`settings:mcp.addServer`)})]})]})})}function Cl({server:e,isAdded:t,onAdd:n}){let{t:r}=V();return(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3 rounded-md border border-border/70 bg-card/70 p-3 transition-colors hover:bg-card`,children:[(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-sm`,children:e.name}),e.badge&&(0,Q.jsx)(el,{variant:`secondary`,className:`text-xs shrink-0`,children:e.badge}),(0,Q.jsx)(el,{variant:`outline`,className:`text-xs shrink-0`,children:e.transport})]}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e.description}),e.requiresEnvVars&&e.requiresEnvVars.length>0&&(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-warning`,children:r(`settings:mcp.requires`,{vars:e.requiresEnvVars.join(`, `)})})]}),(0,Q.jsx)(`div`,{className:`shrink-0`,children:t?(0,Q.jsxs)(X,{variant:`ghost`,size:`sm`,disabled:!0,children:[(0,Q.jsx)(Wn,{className:`w-4 h-4 mr-1`}),r(`settings:mcp.added`)]}):(0,Q.jsxs)(X,{size:`sm`,variant:`outline`,onClick:n,children:[(0,Q.jsx)(jt,{className:`w-4 h-4 mr-1`}),r(`common:action.add`)]})})]})}function wl(){let e=dr(),{t}=V(),[n,r]=(0,Z.useState)([]),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(`list`),[c,l]=(0,Z.useState)(),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)(),[_,v]=(0,Z.useState)(null);(0,Z.useEffect)(()=>{if(!e.client)return;let t=e=>{if(e.type===`mcp.list`){let t=e.payload;r(t.servers??[]),a(!1)}},n=e=>{if(e.type===`mcp.server.added`){let t=e.payload;r(e=>[...e.filter(e=>e.name!==t.server.name),t.server]),Y.success(H.t(`settings:mcp.toastAdded`,{name:t.server.name}))}},i=e=>{if(e.type===`mcp.server.removed`){let t=e.payload;r(e=>e.filter(e=>e.name!==t.name)),Y.success(H.t(`settings:mcp.toastRemoved`,{name:t.name}))}},o=e=>{if(e.type===`mcp.server.updated`){let t=e.payload;r(e=>e.map(e=>e.name===t.server.name?t.server:e))}},s=e=>{if(e.type===`mcp.server.discovered`){let t=e.payload;r(e=>e.map(e=>e.name===t.name?{...e,status:`sleeping`,tools:t.tools}:e)),v(null),Y.success(H.t(`settings:mcp.toastDiscovered`,{count:t.tools.length,name:t.name}))}},c=e=>{if(e.type===`mcp.server.sleeping`){let t=e.payload;r(e=>e.map(e=>e.name===t.name?{...e,status:`sleeping`}:e)),v(null),Y.info(H.t(`settings:mcp.toastSleeping`,{name:t.name}))}},l=e=>{if(e.type===`mcp.server.waking`){let t=e.payload;r(e=>e.map(e=>e.name===t.name?{...e,status:`connecting`}:e))}},u=e=>{if(e.type===`mcp.server.connected`){let t=e.payload;r(e=>e.map(e=>e.name===t.name?{...e,status:`connected`,pid:t.pid,error:void 0,lastError:void 0}:e)),v(null),Y.success(H.t(`settings:mcp.toastConnected`,{name:t.name}))}},d=e=>{if(e.type===`mcp.server.reconnected`){let t=e.payload;r(e=>e.map(e=>e.name===t.name?{...e,status:`connected`,error:void 0,lastError:void 0}:e)),v(null),Y.success(H.t(`settings:mcp.toastReconnected`,{name:t.name}))}},f=e=>{if(e.type===`mcp.server.disconnected`){let t=e.payload;r(e=>e.map(e=>e.name===t.name?{...e,status:`error`,error:t.reason,lastError:t.reason,pid:void 0}:e)),v(null),Y.warn(H.t(`settings:mcp.toastDisconnected`,{name:t.name,reason:t.reason}))}},p=e=>{if(e.type===`mcp.server.error`){let t=e.payload;r(e=>e.map(e=>e.name===t.name?{...e,status:`error`,error:t.error}:e)),v(null),Y.error(H.t(`settings:mcp.toastError`,{name:t.name,error:t.error}))}},m=e=>{if(e.type===`mcp.operation_result`){let t=e.payload;t.success||Y.error(t.message),v(null)}},h=e.client.on(`mcp.list`,t),g=e.client.on(`mcp.server.added`,n),_=e.client.on(`mcp.server.removed`,i),y=e.client.on(`mcp.server.updated`,o),b=e.client.on(`mcp.server.discovered`,s),x=e.client.on(`mcp.server.sleeping`,c),S=e.client.on(`mcp.server.waking`,l),C=e.client.on(`mcp.server.connected`,u),w=e.client.on(`mcp.server.error`,p),T=e.client.on(`mcp.operation_result`,m),E=e.client.on(`mcp.server.reconnected`,d),D=e.client.on(`mcp.server.disconnected`,f);return a(!0),e.client?.listMcpServers(),()=>{h?.(),g?.(),_?.(),y?.(),b?.(),x?.(),S?.(),C?.(),w?.(),T?.(),E?.(),D?.()}},[e.client]);let y=(0,Z.useCallback)(t=>{e.client?.addMcpServer(t)},[e]),b=(0,Z.useCallback)(e=>{h(vl(e,!1)),p(!0)},[]),x=(0,Z.useCallback)(n=>{mi({title:t(`settings:mcp.removeConfirmTitle`,{name:n}),message:t(`settings:mcp.removeConfirmBody`),confirmLabel:t(`common:action.remove`),danger:!0}).then(t=>{t&&e.client?.removeMcpServer(n)})},[e]),S=(0,Z.useCallback)(e=>{l(e),h(void 0),d(!0)},[]),C=(0,Z.useCallback)(t=>{e.client?.updateMcpServer(t)},[e]),w=(0,Z.useCallback)(t=>{v(t),e.client?.wakeMcpServer(t)},[e]),T=(0,Z.useCallback)(t=>{v(t),e.client?.sleepMcpServer(t)},[e]),E=(0,Z.useCallback)(t=>{v(t),e.client?.discoverMcpServer(t)},[e]),D=(0,Z.useCallback)(()=>{a(!0),e.client?.listMcpServers()},[e]),O=n.filter(e=>e.status===`connected`).length,k=n.filter(e=>e.status===`sleeping`).length,A=new Set(n.map(e=>e.name));return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Q.jsx)(`span`,{className:`flex h-9 w-9 items-center justify-center rounded-md border border-primary/20 bg-primary/10 text-primary`,children:(0,Q.jsx)(re,{className:`h-5 w-5`})}),(0,Q.jsx)(`h2`,{className:`text-base font-semibold`,children:t(`settings:mcp.heading`)}),n.length>0&&(0,Q.jsx)(`span`,{className:`rounded-md border border-border/60 bg-muted/30 px-2 py-1 text-xs text-muted-foreground`,children:t(`settings:mcp.summary`,{connected:O,sleeping:k,total:n.length})})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(X,{variant:`outline`,size:`sm`,onClick:D,disabled:i,children:[i?(0,Q.jsx)(g,{className:`w-4 h-4 animate-spin`}):null,t(`common:action.refresh`)]}),(0,Q.jsxs)(X,{size:`sm`,onClick:()=>{h(void 0),p(!0)},children:[(0,Q.jsx)(jt,{className:`w-4 h-4 mr-1`}),t(`settings:mcp.addCustom`)]})]})]}),(0,Q.jsxs)($s,{value:o,onValueChange:e=>s(e),children:[(0,Q.jsxs)(ec,{children:[(0,Q.jsxs)(tc,{value:`recommended`,children:[(0,Q.jsx)(rn,{className:`w-3.5 h-3.5 mr-1`}),t(`settings:mcp.tabRecommended`)]}),(0,Q.jsx)(tc,{value:`list`,children:t(`settings:mcp.tabServers`)}),(0,Q.jsx)(tc,{value:`add`,children:t(`settings:mcp.tabAddCustom`)})]}),(0,Q.jsxs)(nc,{value:`recommended`,className:`space-y-3`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`settings:mcp.recommendedBody`)}),(0,Q.jsx)(`div`,{className:`grid gap-2`,children:_l.map(e=>(0,Q.jsx)(Cl,{server:e,isAdded:A.has(e.name),onAdd:()=>b(e)},e.name))})]}),(0,Q.jsx)(nc,{value:`list`,className:`space-y-3`,children:i&&n.length===0?(0,Q.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground`,children:[(0,Q.jsx)(g,{className:`w-5 h-5 animate-spin mr-2`}),t(`settings:mcp.loadingServers`)]}):n.length===0?(0,Q.jsxs)(`div`,{className:`text-center py-8 text-muted-foreground`,children:[(0,Q.jsx)(re,{className:`w-10 h-10 mx-auto mb-2 opacity-50`}),(0,Q.jsx)(`p`,{children:t(`settings:mcp.noServers`)}),(0,Q.jsx)(`p`,{className:`text-sm`,children:t(`settings:mcp.noServersHint`)})]}):n.map(e=>(0,Q.jsx)(xl,{server:e,onWake:()=>w(e.name),onSleep:()=>T(e.name),onDiscover:()=>E(e.name),onEdit:()=>S(e),onRemove:()=>x(e.name)},e.name))}),(0,Q.jsx)(nc,{value:`add`,children:(0,Q.jsxs)(`div`,{className:`text-sm text-muted-foreground`,children:[(0,Q.jsx)(`p`,{children:t(`settings:mcp.addCustomBody`)}),(0,Q.jsx)(`p`,{className:`mt-1`,children:t(`settings:mcp.addCustomBodyHint`)})]})})]}),(0,Q.jsx)(Sl,{open:f,onOpenChange:e=>{e||(p(!1),h(void 0))},prefillConfig:m,onSave:y}),(0,Q.jsx)(Sl,{open:u,onOpenChange:d,server:c,onSave:C})]})}function Tl({provider:e,catalogModels:t,currentCatalogProvider:n,isLoadingModels:r,setIsLoadingModels:i,onModelSelect:a,refreshModels:o}){let s=q(e=>e.model),{t:c}=V();return(0,Q.jsx)(`div`,{className:`space-y-4`,children:e?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium`,children:n?.name||e}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e})]}),(0,Q.jsx)(X,{variant:`ghost`,size:`sm`,onClick:()=>{i(!0),o(e)},children:(0,Q.jsx)(Dn,{className:G(`h-4 w-4`,r&&`animate-spin`)})})]}),r&&!t[e]?(0,Q.jsxs)(`div`,{className:`flex items-center justify-center py-8`,children:[(0,Q.jsx)(g,{className:`h-6 w-6 animate-spin text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`ml-2 text-muted-foreground`,children:c(`settings:model.loading`)})]}):(0,Q.jsx)(Zc,{options:(t[e]||[]).map(e=>({id:e.id,label:e.name||e.id,badges:e.capabilities,detail:[e.contextWindow?`${Math.round(e.contextWindow/1e3)}k`:``,e.inputCost==null?``:`${e.inputCost}/${e.outputCost}`].filter(Boolean).join(` · `),detailHighlight:!0})),selectedId:s,onSelect:a,emptyMessage:c(`settings:model.notFound`)})]}):(0,Q.jsxs)(`div`,{className:`text-center py-8 text-muted-foreground`,children:[(0,Q.jsx)(yt,{className:`h-8 w-8 mx-auto mb-2 opacity-50`}),(0,Q.jsx)(`p`,{children:c(`settings:model.selectProviderFirst`)})]})})}var El=[[`wstack-chimera`,`settings:features.pluginChimera`],[`wstack-skills`,`settings:features.pluginSkills`],[`wstack-prompts`,`settings:features.pluginPrompts`],[`wstack-security`,`settings:features.pluginSecurity`],[`cost-tracker`,`settings:features.pluginCostTracker`],[`telegram`,`settings:features.pluginTelegram`],[`knowledge-graph`,`settings:features.pluginKnowledgeGraph`],[`error-lens`,`settings:features.pluginErrorLens`],[`todo-tracker`,`settings:features.pluginTodoTracker`],[`secret-scanner`,`settings:features.pluginSecretScanner`],[`lint-gate`,`settings:features.pluginLintGate`],[`diff-summary`,`settings:features.pluginDiffSummary`],[`dep-guard`,`settings:features.pluginDepGuard`],[`type-gate`,`settings:features.pluginTypeGate`],[`injection-shield`,`settings:features.pluginInjectionShield`],[`prompt-firewall`,`settings:features.pluginPromptFirewall`],[`token-budget`,`settings:features.pluginTokenBudget`],[`loop-breaker`,`settings:features.pluginLoopBreaker`]];function Dl(){let{t:e}=V(),t=W();return(0,Q.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Q.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 mt-3 flex items-center gap-2`,children:[(0,Q.jsx)(wt,{className:`h-4 w-4 text-muted-foreground`}),e(`settings:features.pluginsPerPluginHeading`)]}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mb-2`,children:e(`settings:features.pluginsPerPluginHint`)}),El.map(([n,r])=>{let i=t.pluginsEnabled?.[n]??!0;return(0,Q.jsx)($,{label:e(r),value:i,onChange:()=>{let e={...t.pluginsEnabled,[n]:!i};t.set({pluginsEnabled:e})}},n)})]})}function Ol(){let e=(0,Z.useRef)([]);return{setFieldRef:(0,Z.useCallback)(t=>n=>{e.current[t]=n},[]),handleKeyDown:(0,Z.useCallback)((t,n,r)=>{if(t.key===`ArrowDown`){t.preventDefault();for(let t=n+1;t<e.current.length;t++){let n=e.current[t];if(n&&!n.hasAttribute(`disabled`)&&n.getAttribute(`aria-disabled`)!==`true`){if(n.focus(),n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement){let e=n.value.length;n.setSelectionRange(e,e)}return}}return}if(t.key===`ArrowUp`){t.preventDefault();for(let t=n-1;t>=0;t--){let n=e.current[t];if(n&&!n.hasAttribute(`disabled`)&&n.getAttribute(`aria-disabled`)!==`true`){n.focus(),(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement)&&n.setSelectionRange(n.value.length,n.value.length);return}}return}t.key===`Enter`&&r&&(t.preventDefault(),r())},[])}}var kl=`openai-compatible`,Al=[{id:`omniroute`,label:`OmniRoute`,defaultBaseUrl:`http://localhost:20128/v1`,noAuth:!0,hint:`WrongStack local gateway · port 20128 · no key · auto-discovers models`},{id:`ollama`,label:`Ollama`,defaultBaseUrl:`http://localhost:11434/v1`,noAuth:!0,hint:`ollama.com · port 11434 · no key`},{id:`vllm`,label:`vLLM`,defaultBaseUrl:`http://localhost:8000/v1`,noAuth:!1,hint:`docs.vllm.ai · port 8000 · optional key`},{id:`lmstudio`,label:`LM Studio`,defaultBaseUrl:`http://localhost:1234/v1`,noAuth:!1,hint:`lmstudio.ai · port 1234 · optional key`}],jl=[{kind:`chatgpt`,label:`ChatGPT`,subtitle:`Plus / Pro / Team → openai-codex`,icon:(0,Q.jsx)(ee,{className:`h-5 w-5`})},{kind:`claude`,label:`Claude`,subtitle:`Pro / Max → anthropic-oauth`,icon:(0,Q.jsx)(Ee,{className:`h-5 w-5`})},{kind:`copilot`,label:`GitHub Copilot`,subtitle:`Copilot → github-copilot`,icon:(0,Q.jsx)(En,{className:`h-5 w-5`})}],Ml=[`awaiting_browser`,`awaiting_code`,`exchanging`,`fetching_models`];function Nl({ws:e}){let{t}=V(),[n,r]=(0,Z.useState)({chatgpt:{phase:`idle`},claude:{phase:`idle`},copilot:{phase:`idle`}}),[i,a]=(0,Z.useState)(``),[o,s]=(0,Z.useState)(null);(0,Z.useEffect)(()=>{let t=e.on(`auth.oauth.status`,e=>{if(e.type!==`auth.oauth.status`)return;let t=e.payload;r(e=>({...e,[t.kind]:{...t}})),t.phase===`success`?(Y.success(t.message??H.t(`settings:oauth.signedInToast`,{provider:t.providerId??t.kind})),s(null),a(``)):t.phase===`error`&&Y.error(t.message??H.t(`settings:oauth.signInFailed`))});return()=>t?.()},[e]);let c=(0,Z.useCallback)(t=>{r(e=>({...e,[t]:{phase:t===`copilot`?`awaiting_code`:`awaiting_browser`}})),e.startOAuth(t)},[e]),l=(0,Z.useCallback)(t=>{e.cancelOAuth(t),r(e=>({...e,[t]:{phase:`idle`}})),s(null)},[e]),u=(0,Z.useCallback)(t=>{let n=i.trim();n&&(e.submitOAuthCode(t,n),r(e=>({...e,[t]:{...e[t],phase:`exchanging`}})))},[i,e]);return(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`div`,{className:`rounded-md border border-warning/30 bg-warning/5 p-3`,children:(0,Q.jsx)(`p`,{className:`text-xs leading-5 text-warning`,children:t(`settings:oauth.termsWarning`)})}),(0,Q.jsx)(`div`,{className:`grid grid-cols-1 gap-2 lg:grid-cols-3`,children:jl.map(e=>{let r=n[e.kind],d=Ml.includes(r.phase);return(0,Q.jsxs)(`div`,{className:`rounded-lg border border-border bg-background/70 p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 lg:flex-col lg:items-stretch`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`div`,{className:`font-medium`,children:e.label}),(0,Q.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.subtitle})]})]}),d?(0,Q.jsx)(X,{size:`sm`,variant:`ghost`,onClick:()=>l(e.kind),className:`shrink-0 lg:w-full`,children:t(`common:action.cancel`)}):(0,Q.jsx)(X,{size:`sm`,onClick:()=>c(e.kind),className:`shrink-0 lg:w-full`,children:t(`settings:oauth.signIn`)})]}),r.phase===`awaiting_browser`&&(0,Q.jsxs)(`div`,{className:`mt-3 space-y-2 border-t pt-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,Q.jsx)(g,{className:`h-4 w-4 animate-spin text-muted-foreground`}),(0,Q.jsx)(`span`,{children:t(`settings:oauth.waitingBrowser`)})]}),r.authorizeUrl&&(0,Q.jsxs)(X,{size:`sm`,variant:`outline`,onClick:()=>window.open(r.authorizeUrl,`_blank`,`noopener,noreferrer`),children:[(0,Q.jsx)(tt,{className:`h-3.5 w-3.5 mr-1`}),t(`settings:oauth.openSignIn`)]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`button`,{type:`button`,className:`text-xs text-muted-foreground underline`,onClick:()=>s(o===e.kind?null:e.kind),children:r.bound===!1?t(`settings:oauth.pasteLoopbackBusy`):t(`settings:oauth.pasteCantReach`)}),o===e.kind&&(0,Q.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,Q.jsx)(fi,{placeholder:`http://localhost:.../callback?code=…`,value:i,onChange:e=>a(e.target.value),className:`font-mono text-xs`,onKeyDown:t=>{t.key===`Enter`&&u(e.kind)}}),(0,Q.jsx)(X,{size:`sm`,onClick:()=>u(e.kind),disabled:!i.trim(),children:t(`settings:oauth.submit`)})]})]})]}),r.phase===`awaiting_code`&&(0,Q.jsxs)(`div`,{className:`mt-3 space-y-2 border-t pt-3`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`settings:oauth.enterCode`)}),(0,Q.jsx)(`div`,{className:`font-mono text-2xl font-bold tracking-widest`,children:r.userCode??`…`}),r.verificationUri&&(0,Q.jsxs)(X,{size:`sm`,variant:`outline`,onClick:()=>window.open(r.verificationUri,`_blank`,`noopener,noreferrer`),children:[(0,Q.jsx)(tt,{className:`h-3.5 w-3.5 mr-1`}),t(`settings:oauth.openVerification`)]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(g,{className:`h-3.5 w-3.5 animate-spin`}),(0,Q.jsx)(`span`,{children:t(`settings:oauth.waitingCode`)})]})]}),(r.phase===`exchanging`||r.phase===`fetching_models`)&&(0,Q.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 border-t pt-3 text-sm`,children:[(0,Q.jsx)(g,{className:`h-4 w-4 animate-spin text-muted-foreground`}),(0,Q.jsx)(`span`,{children:r.phase===`exchanging`?t(`settings:oauth.exchanging`):t(`settings:oauth.fetchingModels`)})]}),r.phase===`success`&&(0,Q.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 border-t pt-3 text-sm text-success`,children:[(0,Q.jsx)(Gt,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{children:r.message??t(`settings:oauth.signedIn`)})]}),r.phase===`error`&&r.message&&(0,Q.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 border-t pt-3 text-sm text-destructive`,children:[(0,Q.jsx)(un,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{children:r.message})]})]},e.kind)})})]})}function Pl({open:e,providerId:t,modelCount:n,onConfirm:r,onCancel:i}){let a=(0,Z.useRef)(null),{t:o}=V();return(0,Z.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Enter`?(e.preventDefault(),r()):e.key===`Escape`&&(e.preventDefault(),i())};return window.addEventListener(`keydown`,t),a.current?.focus(),()=>window.removeEventListener(`keydown`,t)},[e,r,i]),(0,Q.jsx)($r,{open:e,onOpenChange:e=>{e||i()},children:(0,Q.jsxs)(Xr,{className:`sm:max-w-md border-warning/50`,ref:a,tabIndex:-1,"data-clear-allowlist-dialog":!0,children:[(0,Q.jsxs)(Jr,{children:[(0,Q.jsxs)(Zr,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(kt,{className:`h-5 w-5 text-warning`}),o(`settings:allowlist.title`)]}),(0,Q.jsx)(Qr,{children:o(`settings:allowlist.body`,{count:n,provider:t})})]}),(0,Q.jsx)(`div`,{className:`rounded-md bg-muted/50 border border-border/60 px-3 py-2 text-xs text-muted-foreground`,children:o(`settings:allowlist.undoHint`)}),(0,Q.jsxs)(Yr,{className:`gap-2 sm:gap-2 flex-wrap`,children:[(0,Q.jsxs)(X,{variant:`outline`,size:`sm`,onClick:i,title:o(`settings:allowlist.keepTitle`),"data-action":`cancel`,children:[o(`common:action.cancel`),` `,(0,Q.jsx)(`kbd`,{className:`ml-1 text-[10px] border rounded px-1 bg-background`,children:`Esc`})]}),(0,Q.jsxs)(X,{variant:`destructive`,size:`sm`,onClick:r,title:o(`settings:allowlist.clearTitle`),"data-action":`confirm`,children:[o(`settings:allowlist.clear`),` `,(0,Q.jsx)(`kbd`,{className:`ml-1 text-[10px] border rounded px-1 bg-background/80`,children:`↵`})]})]})]})})}function Fl(){return{inFlight:!1,last:null,picked:null}}function Il(e){return{providerId:e.providerId,ok:e.ok,status:e.status,...e.httpStatus===void 0?{}:{httpStatus:e.httpStatus},...e.elapsedMs===void 0?{}:{elapsedMs:e.elapsedMs},...e.modelCount===void 0?{}:{modelCount:e.modelCount},...e.modelIds===void 0?{}:{modelIds:e.modelIds},...e.detail===void 0?{}:{detail:e.detail}}}function Ll(e,t,n){return e.picked?e.picked:e.last?.ok&&e.last.modelIds&&e.last.modelIds.length>0&&e.last.modelIds[0]?e.last.modelIds[0]:t||(n&&n.length>0&&n[0]?n[0]:``)}function Rl(e){if(e.inFlight)return{text:`Checking model endpoint...`,tone:`muted`};let t=e.last;if(!t)return{text:`Saved model list shown`,tone:`muted`};let n=t.elapsedMs===void 0?``:` (${t.elapsedMs}ms)`;switch(t.status){case`ok`:{let e=t.modelCount??t.modelIds?.length??0;return{text:`Server returned ${e} model${e===1?``:`s`}${n}`,tone:`success`}}case`unreachable`:return{text:`server unreachable${t.detail?` — ${t.detail}`:``}`,tone:`error`};case`timeout`:return{text:`timed out${t.detail?` — ${t.detail}`:``}`,tone:`error`};case`http_error`:return{text:`got${t.httpStatus===void 0?``:` HTTP ${t.httpStatus}`}${t.detail?` — ${t.detail}`:``}`,tone:`warning`};case`invalid_response`:return{text:t.detail?`unexpected response — ${t.detail}`:`unexpected response shape`,tone:`warning`};case`no_provider`:return{text:`Provider is no longer saved`,tone:`error`};case`no_base_url`:return{text:`No model endpoint configured`,tone:`warning`}}}function zl(e,t){return e.last?.ok&&e.last.modelIds&&e.last.modelIds.length>0?e.last.modelIds:t??[]}function Bl(e){return(e?.length??0)>0}function Vl(e,t){return`Allowlist cleared for ${e} — ${t} model${t===1?``:`s`} removed`}function Hl(e){return e.length>0}function Ul(e){return e.previousModels.length===0?{kind:`skip`}:e.onUndoClear?{kind:`callback`,providerId:e.providerId,previousModels:e.previousModels}:{kind:`ws-default`,providerId:e.providerId,previousModels:e.previousModels}}var Wl=3e3;function Gl({providerId:e,savedPickedModelId:t,savedModels:n,ws:r,onPickModel:i,onClearModels:a,onUndoClear:o}){let[s,c]=(0,Z.useState)(()=>Fl()),{t:l}=V(),[u,d]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>r.on(`provider.probe`,t=>{t.type===`provider.probe`&&t.payload.providerId===e&&c(e=>({...e,inFlight:!1,last:Il(t.payload)}))}),[r,e]);let f=(0,Z.useCallback)(()=>{c(e=>({...e,inFlight:!0})),r.probeProvider(e,Wl)},[r,e]),p=(0,Z.useCallback)(t=>{c(e=>({...e,picked:t})),i?.(e,t)},[i,e]),m=(0,Z.useCallback)(()=>{d(!0)},[]),h=(0,Z.useCallback)(()=>{d(!1)},[]),_=(0,Z.useCallback)(()=>{d(!1);let t=n?[...n]:[];c(e=>({...e,picked:null,last:null})),a?a(e):r.clearProviderModels(e),Hl(t)&&Y.undoable(Vl(e,t.length),()=>{let n=Ul({providerId:e,previousModels:t,onUndoClear:o});switch(n.kind){case`skip`:return;case`callback`:o?.(n.providerId,n.previousModels);return;case`ws-default`:r.undoProviderClear(n.providerId,n.previousModels);return}})},[a,o,r,e,n]),v=(0,Z.useMemo)(()=>Ll(s,t,n),[s,t,n]),y=(0,Z.useMemo)(()=>zl(s,n),[s,n]),b=ho(y,12,e),x=(0,Z.useMemo)(()=>Rl(s),[s]),S=(0,Z.useMemo)(()=>Bl(n),[n]),C=y.length>8;return(0,Q.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-background/75 p-3 shadow-sm shadow-black/[0.02]`,"data-provider-models-panel":e,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[(0,Q.jsx)(ge,{className:`h-3.5 w-3.5`}),l(`activity:providerModels.allowlistTitle`)]}),y.length>0&&(0,Q.jsx)(`span`,{className:`rounded-full border border-border/70 bg-muted/40 px-2 py-0.5 text-[11px] text-muted-foreground`,children:l(`activity:providerModels.modelCount`,{count:y.length})})]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:l(`activity:providerModels.using`)}),v?(0,Q.jsx)(`span`,{className:`max-w-full truncate rounded-md bg-primary/10 px-2 py-0.5 font-mono text-xs text-primary`,children:v}):(0,Q.jsx)(`span`,{className:`text-xs italic text-muted-foreground`,children:l(`activity:providerModels.noModelPicked`)})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 sm:justify-end`,children:[(0,Q.jsxs)(X,{variant:`outline`,size:`sm`,onClick:f,disabled:s.inFlight,"aria-label":l(`activity:providerModels.refreshAria`,{provider:e}),className:`h-8 px-2 text-xs`,children:[s.inFlight?(0,Q.jsx)(g,{className:`h-3.5 w-3.5 animate-spin`}):(0,Q.jsx)(Dn,{className:`h-3.5 w-3.5`}),s.inFlight?l(`activity:providerModels.probing`):l(`activity:providerModels.refresh`)]}),S&&(0,Q.jsx)(X,{variant:`ghost`,size:`sm`,onClick:m,"aria-label":l(`activity:providerModels.clearAllowlistAria`,{provider:e}),"data-action":`clear-models`,className:`h-8 px-2 text-xs`,children:l(`activity:providerModels.clearAllowlist`)})]})]}),(0,Q.jsx)(Kl,{formatted:x}),y.length>0&&(0,Q.jsxs)(`div`,{className:`relative mt-3`,children:[(0,Q.jsx)(`ul`,{className:G(`flex flex-wrap gap-1.5 pr-1 [scrollbar-gutter:stable]`,C&&`max-h-40 overflow-y-scroll pb-7`),"data-provider-models-list":e,children:b.pageItems.map(t=>{let n=t===v;return(0,Q.jsx)(`li`,{className:`max-w-full`,children:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{n||p(t)},disabled:n,className:n?`inline-flex max-w-full items-center gap-1.5 rounded-md border border-primary/25 bg-primary/10 px-2 py-1 text-left font-mono text-xs text-primary shadow-sm`:`inline-flex max-w-full items-center gap-1.5 rounded-md border border-border/70 bg-muted/25 px-2 py-1 text-left font-mono text-xs text-foreground/85 transition-colors hover:border-primary/35 hover:bg-primary/5 hover:text-primary`,"aria-label":n?void 0:l(`activity:providerModels.useModelAria`,{model:t,provider:e}),children:[n&&(0,Q.jsx)(Wn,{className:`h-3.5 w-3.5 shrink-0`}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:t}),!n&&(0,Q.jsx)(`span`,{className:`shrink-0 border-l border-border/70 pl-1.5 font-sans text-[10px] font-semibold uppercase tracking-wide text-primary`,children:l(`activity:providerModels.use`)})]})},t)})}),C&&(0,Q.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 h-9 rounded-b-md bg-gradient-to-t from-background via-background/90 to-transparent`}),(0,Q.jsx)(ni,{page:b.page,pageSize:b.pageSize,totalItems:b.totalItems,onPageChange:b.setPage,className:`mt-2`,compact:!0,itemLabel:`models`})]}),(0,Q.jsx)(Pl,{open:u,providerId:e,modelCount:n?.length??0,onConfirm:_,onCancel:h})]})}function Kl({formatted:e}){let t=e.tone===`success`?`text-success`:e.tone===`warning`?`text-warning`:e.tone===`error`?`text-destructive`:`text-muted-foreground`,n=e.tone===`success`?`bg-success`:e.tone===`warning`?`bg-warning`:e.tone===`error`?`bg-destructive`:`bg-muted-foreground/60`;return(0,Q.jsxs)(`p`,{className:`mt-2 flex items-center gap-1.5 text-xs ${t}`,"data-probe-tone":e.tone,children:[(0,Q.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full ${n}`}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:e.text})]})}var ql=[`anthropic`,`openai`,`google`,`openai-compatible`];function Jl({activeProvider:e,catalogProviders:t,isLoadingCatalog:n,savedProviders:r,isLoadingSaved:i,providerTab:a,setProviderTab:s,onSelectProvider:c,onAddKey:l,onDeleteKey:u,onSetActiveKey:d,onAddProvider:f,onRemoveProvider:p,onPickProviderModel:m,ws:h,catalogQuery:_,setCatalogQuery:y}){let{t:b}=V(),[x,S]=(0,Z.useState)(null),[w,T]=(0,Z.useState)(``),[E,D]=(0,Z.useState)(``),[O,k]=(0,Z.useState)(!1),[A,j]=(0,Z.useState)(!1),[M,N]=(0,Z.useState)(``),[P,ee]=(0,Z.useState)(`openai-compatible`),[te,F]=(0,Z.useState)(``),[I,ne]=(0,Z.useState)(``),L=Ol(),ie=Ol(),ae=(0,Z.useCallback)(e=>{!w.trim()||!E.trim()||(l(e,w.trim(),E.trim()),T(``),D(``),S(null))},[l,w,E]),z=(0,Z.useCallback)(()=>{M.trim()&&(f(M.trim(),P,te||void 0,I||void 0),N(``),ee(`openai-compatible`),F(``),ne(``),j(!1))},[f,M,P,te,I]),oe=(0,Z.useCallback)(e=>{N(e.id),ee(kl),F(e.defaultBaseUrl),e.noAuth&&ne(``)},[]),[se,ce]=(0,Z.useState)(null),[le,ue]=(0,Z.useState)(``),[de,fe]=(0,Z.useState)(!1),[pe,me]=(0,Z.useState)({}),he=(0,Z.useMemo)(()=>new Set(r.map(e=>e.id)),[r]),ge=(0,Z.useMemo)(()=>({keys:r.reduce((e,t)=>e+t.apiKeys.length,0),activeKeys:r.reduce((e,t)=>e+t.apiKeys.filter(e=>e.isActive).length,0),models:r.reduce((e,t)=>e+(t.models?.length??0),0)}),[r]);(0,Z.useEffect)(()=>{let e=h.on(`provider.probe`,e=>{if(e.type!==`provider.probe`)return;let t=e.payload;t.status===`no_base_url`||t.status===`no_provider`||me(e=>({...e,[t.providerId]:{ok:t.ok,status:t.status,detail:t.detail}}))});return()=>e?.()},[h]);let _e=(0,Z.useCallback)(e=>{let t=le.trim();t&&(he.has(e.id)?l(e.id,`default`,t):f(e.id,e.family,e.apiBase??void 0,t),ue(``),ce(null),fe(!1),Y.success(b(`settings:provider.savedToast`,{name:e.name})),e.apiBase&&setTimeout(()=>h.probeProvider(e.id,6e3),700))},[le,he,l,f,h]),ve=_.trim()?t.filter(e=>{let t=_.trim().toLowerCase();return e.id.toLowerCase().includes(t)||e.name.toLowerCase().includes(t)||e.family.toLowerCase().includes(t)}):t,ye=ve.reduce((e,t)=>(e[t.family]||(e[t.family]=[]),e[t.family]?.push(t),e),{});return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsxs)(`h3`,{className:`text-sm font-semibold flex items-center gap-2`,children:[(0,Q.jsx)(o,{className:`h-4 w-4 text-muted-foreground`}),b(`settings:provider.subscriptionHeading`)]}),(0,Q.jsx)(Nl,{ws:h})]}),(0,Q.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Q.jsxs)(`h3`,{className:`text-sm font-semibold mb-1 flex items-center gap-2`,children:[(0,Q.jsx)(Rn,{className:`h-4 w-4 text-muted-foreground`}),b(`settings:provider.apiKeysHeading`)]}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mb-3`,children:b(`settings:provider.apiKeysBody`)})]}),(0,Q.jsxs)(`div`,{className:`flex gap-2 mb-4`,children:[(0,Q.jsxs)(X,{variant:a===`catalog`?`default`:`outline`,size:`sm`,onClick:()=>s(`catalog`),children:[(0,Q.jsx)(Rn,{className:`h-4 w-4 mr-1`}),b(`settings:provider.tabCatalog`)]}),(0,Q.jsxs)(X,{variant:a===`saved`?`default`:`outline`,size:`sm`,onClick:()=>s(`saved`),children:[(0,Q.jsx)(o,{className:`h-4 w-4 mr-1`}),b(`settings:provider.tabSaved`,{count:r.length})]})]}),a===`catalog`&&(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(fi,{placeholder:b(`settings:provider.searchPlaceholder`,{count:t.length}),value:_,onChange:e=>y(e.target.value),className:`text-sm`}),n&&t.length===0?(0,Q.jsxs)(`div`,{className:`flex items-center justify-center py-8`,children:[(0,Q.jsx)(g,{className:`h-6 w-6 animate-spin text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`ml-2 text-muted-foreground`,children:b(`settings:provider.loadingCatalog`)})]}):ve.length===0&&_?(0,Q.jsx)(`div`,{className:`text-center py-8 text-muted-foreground text-sm`,children:b(`settings:provider.noMatch`,{query:_})}):ql.map(t=>{let n=ye[t];return n?.length?(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-muted-foreground uppercase tracking-wider`,children:t}),(0,Q.jsx)(`div`,{className:`grid grid-cols-1 gap-2`,children:n.map(t=>{let n=pe[t.id],r=e===t.id;return(0,Q.jsxs)(`div`,{className:G(`rounded-lg border transition-all`,r?`border-primary bg-primary/5 ring-2 ring-primary/20`:`border-border`),children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>c(t.id),className:G(`flex w-full flex-col items-start p-3 text-left rounded-lg`,!r&&`hover:bg-muted`),children:[(0,Q.jsxs)(`div`,{className:`flex w-full justify-between items-start`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:t.name}),(0,Q.jsxs)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:[`(`,t.id,`)`]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t.hasApiKey&&(0,Q.jsxs)(`span`,{className:`text-xs bg-success/10 text-success px-2 py-0.5 rounded`,children:[(0,Q.jsx)(o,{className:`h-3 w-3 inline mr-1`}),b(`settings:provider.configured`)]}),n&&(0,Q.jsxs)(`span`,{className:G(`text-xs px-2 py-0.5 rounded inline-flex items-center gap-1`,n.ok?`bg-success/10 text-success`:`bg-destructive/10 text-destructive`),title:n.detail??n.status,children:[n.ok?(0,Q.jsx)(Gt,{className:`h-3 w-3`}):(0,Q.jsx)(un,{className:`h-3 w-3`}),n.ok?b(`settings:provider.reachable`):n.status]}),t.envVars[0]&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:b(`settings:provider.envVar`,{var:t.envVars[0]})}),r&&(0,Q.jsx)(Gt,{className:`h-4 w-4 text-primary`})]})]}),(0,Q.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[b(`settings:provider.modelCount`,{count:t.modelCount}),t.apiBase&&` · ${t.apiBase}`]})]}),r&&!t.hasApiKey&&(0,Q.jsx)(`div`,{className:`px-3 pb-3 -mt-1 space-y-2`,children:se===t.id?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(fi,{autoFocus:!0,type:de?`text`:`password`,placeholder:b(`settings:provider.keyPlaceholder`,{name:t.name}),value:le,onChange:e=>ue(e.target.value),className:`text-sm`,onKeyDown:e=>{e.key===`Enter`&&_e(t)}}),(0,Q.jsx)(X,{size:`icon`,variant:`ghost`,onClick:()=>fe(e=>!e),children:de?(0,Q.jsx)(R,{className:`h-4 w-4`}):(0,Q.jsx)(it,{className:`h-4 w-4`})}),(0,Q.jsx)(X,{size:`sm`,onClick:()=>_e(t),disabled:!le.trim(),children:b(`common:action.save`)})]}),t.envVars[0]&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:b(`settings:provider.orEnv`,{env:t.envVars[0]})})]}):(0,Q.jsxs)(X,{size:`sm`,variant:`outline`,onClick:()=>{ce(t.id),ue(``)},children:[(0,Q.jsx)(o,{className:`h-3.5 w-3.5 mr-1`}),b(`settings:provider.addApiKey`)]})})]},t.id)})})]},t):null})]}),a===`saved`&&(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:b(`settings:provider.manageKeys`)}),(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2 text-xs text-muted-foreground`,children:[(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-muted/30 px-2 py-1`,children:[(0,Q.jsx)(re,{className:`h-3.5 w-3.5`}),b(`settings:provider.savedProviderCount`,{count:r.length})]}),(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-muted/30 px-2 py-1`,children:[(0,Q.jsx)(o,{className:`h-3.5 w-3.5`}),b(`settings:provider.keyCount`,{count:ge.keys})]}),(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-muted/30 px-2 py-1`,children:[(0,Q.jsx)(v,{className:`h-3.5 w-3.5`}),b(`settings:provider.activeKeyCount`,{count:ge.activeKeys})]}),(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-muted/30 px-2 py-1`,children:[(0,Q.jsx)(yt,{className:`h-3.5 w-3.5`}),b(`settings:provider.modelCount`,{count:ge.models})]})]})]}),(0,Q.jsxs)(X,{size:`sm`,variant:`outline`,onClick:()=>j(!A),children:[(0,Q.jsx)(jt,{className:`h-4 w-4 mr-1`}),b(`settings:provider.addProvider`)]})]}),A&&(0,Q.jsxs)(`div`,{className:`p-4 border rounded-lg space-y-3 bg-muted/50`,children:[(0,Q.jsx)(`h4`,{className:`font-medium`,children:b(`settings:provider.addCustomHeading`)}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:b(`settings:provider.localServers`)}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:Al.map(e=>(0,Q.jsx)(X,{type:`button`,size:`sm`,variant:M===e.id?`default`:`outline`,onClick:()=>oe(e),title:e.hint,children:e.label},e.id))})]}),(0,Q.jsx)(fi,{placeholder:b(`settings:provider.providerIdPlaceholder`),value:M,onChange:e=>N(e.target.value),ref:L.setFieldRef(0),onKeyDown:e=>L.handleKeyDown(e,0)}),(0,Q.jsxs)(`select`,{className:`flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm`,value:P,onChange:e=>ee(e.target.value),ref:L.setFieldRef(1),onKeyDown:e=>L.handleKeyDown(e,1),children:[(0,Q.jsx)(`option`,{value:`anthropic`,children:`Anthropic`}),(0,Q.jsx)(`option`,{value:`openai`,children:`OpenAI`}),(0,Q.jsx)(`option`,{value:`openai-compatible`,children:`OpenAI Compatible`}),(0,Q.jsx)(`option`,{value:`google`,children:`Google`})]}),(0,Q.jsx)(fi,{placeholder:`Base URL (optional, e.g. http://localhost:11434/v1)`,value:te,onChange:e=>F(e.target.value),ref:L.setFieldRef(2),onKeyDown:e=>L.handleKeyDown(e,2)}),(0,Q.jsx)(fi,{type:`password`,placeholder:b(`settings:provider.apiKeyOptionalPlaceholder`),value:I,onChange:e=>ne(e.target.value),ref:L.setFieldRef(3),onKeyDown:e=>L.handleKeyDown(e,3)}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(X,{size:`sm`,onClick:z,disabled:!M.trim(),ref:L.setFieldRef(4),onKeyDown:e=>L.handleKeyDown(e,4,z),children:b(`common:action.add`)}),(0,Q.jsx)(X,{size:`sm`,variant:`ghost`,onClick:()=>j(!1),ref:L.setFieldRef(5),onKeyDown:e=>L.handleKeyDown(e,5),children:b(`common:action.cancel`)})]})]}),i?(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,Q.jsx)(g,{className:`h-6 w-6 animate-spin text-muted-foreground`})}):r.length===0?(0,Q.jsxs)(`div`,{className:`text-center py-8 text-muted-foreground`,children:[(0,Q.jsx)(o,{className:`h-8 w-8 mx-auto mb-2 opacity-50`}),(0,Q.jsx)(`p`,{children:b(`settings:provider.noSaved`)}),(0,Q.jsx)(`p`,{className:`text-sm`,children:b(`settings:provider.noSavedHint`)})]}):r.map(e=>(0,Q.jsxs)(`div`,{className:`rounded-lg border border-border/80 bg-card/70 p-4 shadow-sm shadow-black/[0.02]`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`h4`,{className:`min-w-0 truncate font-mono text-sm font-semibold text-foreground`,children:e.id}),e.family&&(0,Q.jsx)(`span`,{className:`rounded-full border border-border/70 bg-muted/40 px-2 py-0.5 text-[11px] font-medium text-muted-foreground`,children:e.family}),e.apiKeys.some(e=>e.isActive)&&(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-success/10 px-2 py-0.5 text-[11px] font-medium text-success`,children:[(0,Q.jsx)(v,{className:`h-3 w-3`}),b(`settings:provider.active`)]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-xs text-muted-foreground`,children:[e.baseUrl&&(0,Q.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-1 rounded-md border border-border/70 bg-background/60 px-2 py-1`,children:[(0,Q.jsx)(Rn,{className:`h-3.5 w-3.5 shrink-0`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.baseUrl})]}),(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-background/60 px-2 py-1`,children:[(0,Q.jsx)(yt,{className:`h-3.5 w-3.5`}),b(`settings:provider.modelCount`,{count:e.models?.length??0})]}),(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-background/60 px-2 py-1`,children:[(0,Q.jsx)(o,{className:`h-3.5 w-3.5`}),b(`settings:provider.keyCount`,{count:e.apiKeys.length})]})]})]}),(0,Q.jsx)(`div`,{className:`flex gap-2 sm:justify-end`,children:(0,Q.jsx)(X,{size:`icon`,variant:`ghost`,onClick:()=>p(e.id),"aria-label":`Remove provider ${e.id}`,title:`Remove provider ${e.id}`,className:`h-8 w-8 text-muted-foreground hover:bg-destructive/10 hover:text-destructive`,children:(0,Q.jsx)(C,{className:`h-4 w-4 text-destructive`})})})]}),(0,Q.jsxs)(`div`,{className:`mt-4 grid gap-4 xl:grid-cols-[minmax(0,1.35fr)_minmax(280px,0.85fr)]`,children:[(0,Q.jsx)(Gl,{providerId:e.id,savedPickedModelId:e.pickedModelId,savedModels:e.models,ws:h,onPickModel:m}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-background/75 p-3 shadow-sm shadow-black/[0.02]`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-semibold`,children:b(`settings:provider.apiKeysLabel`)}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:b(`settings:provider.keyCount`,{count:e.apiKeys.length})})]}),(0,Q.jsxs)(X,{size:`sm`,variant:`ghost`,onClick:()=>S(x===e.id?null:e.id),className:`h-8 px-2 text-xs`,children:[(0,Q.jsx)(jt,{className:`h-3.5 w-3.5`}),b(`settings:provider.addKey`)]})]}),e.apiKeys.length===0&&!x&&(0,Q.jsx)(`p`,{className:`mt-3 rounded-md border border-dashed border-border/70 bg-muted/20 px-3 py-2 text-xs text-muted-foreground`,children:b(`settings:provider.noKeys`)}),e.apiKeys.length>0&&(0,Q.jsx)(`div`,{className:`mt-3 space-y-2`,children:e.apiKeys.map(t=>(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-border/70 bg-muted/20 p-2.5 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,Q.jsx)(`span`,{className:`mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-border/70 bg-background text-muted-foreground`,children:(0,Q.jsx)(o,{className:`h-3.5 w-3.5`})}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`truncate text-sm font-medium`,children:t.label}),t.isActive&&(0,Q.jsx)(`span`,{className:`rounded-full bg-success/10 px-2 py-0.5 text-[11px] font-medium text-success`,children:b(`settings:provider.active`)})]}),(0,Q.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-xs text-muted-foreground`,children:t.maskedKey})]})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-1`,children:[!t.isActive&&(0,Q.jsx)(X,{size:`sm`,variant:`outline`,onClick:()=>d(e.id,t.label),className:`h-8 px-2 text-xs`,children:b(`settings:provider.setActive`)}),(0,Q.jsx)(X,{size:`icon`,variant:`ghost`,onClick:()=>u(e.id,t.label),"aria-label":`Delete key ${t.label}`,title:`Delete key ${t.label}`,className:`h-8 w-8 text-muted-foreground hover:bg-destructive/10 hover:text-destructive`,children:(0,Q.jsx)(C,{className:`h-3.5 w-3.5 text-destructive`})})]})]},t.label))}),x===e.id&&(0,Q.jsxs)(`div`,{className:`mt-3 space-y-2 rounded-lg border border-border/70 bg-background p-3`,children:[(0,Q.jsx)(fi,{placeholder:b(`settings:provider.keyLabelPlaceholder`),value:w,onChange:e=>T(e.target.value),ref:ie.setFieldRef(0),onKeyDown:e=>ie.handleKeyDown(e,0)}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(fi,{type:O?`text`:`password`,placeholder:b(`settings:provider.apiKeyPlaceholder`),value:E,onChange:e=>D(e.target.value),ref:ie.setFieldRef(1),onKeyDown:e=>ie.handleKeyDown(e,1)}),(0,Q.jsx)(X,{size:`icon`,variant:`ghost`,onClick:()=>k(!O),children:O?(0,Q.jsx)(R,{className:`h-4 w-4`}):(0,Q.jsx)(it,{className:`h-4 w-4`})})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(X,{size:`sm`,onClick:()=>ae(e.id),disabled:!w.trim()||!E.trim(),ref:ie.setFieldRef(2),onKeyDown:t=>ie.handleKeyDown(t,2,()=>ae(e.id)),children:b(`settings:provider.saveKey`)}),(0,Q.jsx)(X,{size:`sm`,variant:`ghost`,onClick:()=>{S(null),T(``),D(``)},ref:ie.setFieldRef(3),onKeyDown:e=>ie.handleKeyDown(e,3),children:b(`common:action.cancel`)})]})]})]})]})]},e.id))]})]})}var Yl=[{phase:`discovery`,label:`Discovery`,roles:[{role:`explore`,name:`Explore`},{role:`search`,name:`Search`},{role:`research`,name:`Research`}]},{phase:`planning`,label:`Planning`,roles:[{role:`analyst`,name:`Analyst`},{role:`planner`,name:`Planner`},{role:`architect`,name:`Architect`},{role:`critic`,name:`Critic`},{role:`refactor-planner`,name:`Refactor Planner`}]},{phase:`build`,label:`Build`,roles:[{role:`executor`,name:`Executor`},{role:`refactor`,name:`Refactor`},{role:`simplifier`,name:`Simplifier`},{role:`migration`,name:`Migration`},{role:`vision`,name:`Vision`},{role:`debugger`,name:`Debugger`},{role:`tracer`,name:`Tracer`}]},{phase:`verify`,label:`Verify`,roles:[{role:`verifier`,name:`Verifier`},{role:`test`,name:`Test`},{role:`e2e`,name:`E2E`},{role:`browser`,name:`Browser`},{role:`performance`,name:`Performance`},{role:`chaos`,name:`Chaos`},{role:`security-scanner`,name:`Security Scanner`},{role:`bug-hunter`,name:`Bug Hunter`},{role:`audit-log`,name:`Audit Log`}]},{phase:`review`,label:`Review`,roles:[{role:`reviewer`,name:`Reviewer`},{role:`code-reviewer`,name:`Code Reviewer`},{role:`security-reviewer`,name:`Security Reviewer`},{role:`accessibility`,name:`Accessibility`},{role:`compliance`,name:`Compliance`}]},{phase:`domain`,label:`Domain`,roles:[{role:`database`,name:`Database`},{role:`api`,name:`API`},{role:`auth`,name:`Auth`},{role:`data`,name:`Data`},{role:`frontend`,name:`Frontend`},{role:`backend`,name:`Backend`},{role:`designer`,name:`Designer`},{role:`ios`,name:`iOS`}]},{phase:`knowledge`,label:`Knowledge`,roles:[{role:`document`,name:`Document`},{role:`uml`,name:`UML`},{role:`i18n`,name:`I18n`},{role:`prompt`,name:`Prompt`}]},{phase:`delivery`,label:`Delivery`,roles:[{role:`git`,name:`Git`},{role:`release`,name:`Release`},{role:`devops`,name:`DevOps`},{role:`observability`,name:`Observability`},{role:`dependency`,name:`Dependency`}]},{phase:`meta`,label:`Meta`,roles:[{role:`skill-manage`,name:`Skill Manager`},{role:`self-improving`,name:`Self-Improving`},{role:`context`,name:`Context`},{role:`cost`,name:`Cost`},{role:`tech-stack`,name:`Tech Stack Validator`}]}],Xl=Yl.map(e=>e.phase),Zl=Yl.flatMap(e=>[...e.roles]),Ql=Zl.map(e=>e.role),$l=[`*`,...Xl,...Ql];function eu(e){if(e===`*`)return`Default (*)`;let t=Yl.find(t=>t.phase===e);if(t)return`Phase: ${t.label} (${t.phase})`;let n=Zl.find(t=>t.role===e);return n?`${n.name} (${n.role})`:`Custom: ${e}`}var tu=[{value:``,label:`mode: inherit`},{value:`auto`,label:`mode: auto`},{value:`on`,label:`mode: on`},{value:`off`,label:`mode: off`}],nu=[{value:``,label:`effort: inherit`},{value:`none`,label:`effort: none`},{value:`minimal`,label:`effort: minimal`},{value:`low`,label:`effort: low`},{value:`medium`,label:`effort: medium`},{value:`high`,label:`effort: high`},{value:`xhigh`,label:`effort: xhigh`},{value:`max`,label:`effort: max`}],ru=[{value:``,label:`preserve: inherit`},{value:`on`,label:`preserve: on`},{value:`off`,label:`preserve: off`}],iu=new Set($l);function au(e,t,n){let r={};return e&&(r.mode=e),t&&(r.effort=t),n&&(r.preserve=n===`on`),Object.keys(r).length>0?{reasoning:r}:void 0}function ou(e){return e?[e.mode?`mode:${e.mode}`:``,e.effort?`effort:${e.effort}`:``,e.preserve===void 0?``:`preserve:${e.preserve?`on`:`off`}`].filter(Boolean):[]}function su({syncPref:e,candidates:t}){let n=W(),{t:r}=V(),[i,a]=(0,Z.useState)(`*`),[o,s]=(0,Z.useState)(``),[c,l]=(0,Z.useState)(``),[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(``),m=(0,Z.useCallback)(t=>e(`modelMatrix`,t),[e]),h=(0,Z.useCallback)(()=>{let e=i.trim(),t=o.trim(),r=au(c,u,f);if(!e||!t&&!r)return;let a=t?n.fallbackProfiles[t]?{fallbackProfile:t}:t.includes(`/`)?{provider:t.slice(0,t.indexOf(`/`)),model:t.slice(t.indexOf(`/`)+1)}:{model:t}:{},h=n.modelMatrix[e]?.modelRuntime;r?a.modelRuntime=r:h&&(a.modelRuntime=h),m({...n.modelMatrix,[e]:a}),s(``),l(``),d(``),p(``)},[n.fallbackProfiles,n.modelMatrix,i,f,u,c,o,m]),g=(0,Z.useCallback)(e=>{let{[e]:t,...r}=n.modelMatrix;m(r)},[n.modelMatrix,m]),_=(0,Z.useCallback)((e,t,r)=>{let i={...n.modelMatrix},a={...i[e]??{}},o={...a.modelRuntime??{}},s={...o.reasoning??{}};t===`mode`?r?s.mode=r:delete s.mode:t===`effort`?r?s.effort=r:delete s.effort:r?s.preserve=r===`on`:delete s.preserve,Object.keys(s).length>0?o.reasoning=s:delete o.reasoning,Object.keys(o).length>0?a.modelRuntime=o:delete a.modelRuntime,a.model||a.fallbackProfile||a.modelRuntime?i[e]=a:delete i[e],m(i)},[n.modelMatrix,m]),v=e=>{let t=e.provider&&e.model?`${e.provider}/${e.model}`:e.model,n=e.modelRuntime?.reasoning;return[t??(!e.fallbackProfile&&n?r(`settings:agent.leaderModel`):``),e.fallbackProfile?`profile:${e.fallbackProfile}`:``,...ou(n)].filter(Boolean).join(` + `)},y=Array.from(new Set([...Object.keys(n.modelMatrix),i].filter(e=>e&&!iu.has(e)))).sort((e,t)=>e.localeCompare(t));return(0,Q.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Q.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 mt-3 flex items-center gap-2`,children:[(0,Q.jsx)(vt,{className:`h-4 w-4 text-muted-foreground`}),r(`settings:agent.routingHeading`)]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-[minmax(0,180px)_1fr_auto]`,children:[(0,Q.jsxs)(`select`,{"aria-label":r(`settings:agent.routingRouteKey`),value:i,onChange:e=>a(e.target.value),className:`h-9 min-w-0 rounded-md border bg-background px-3 font-mono text-sm`,children:[(0,Q.jsx)(`option`,{value:`*`,children:eu(`*`)}),(0,Q.jsx)(`optgroup`,{label:r(`settings:agent.routingPhasesGroup`),children:Yl.map(e=>(0,Q.jsx)(`option`,{value:e.phase,children:eu(e.phase)},e.phase))}),Yl.map(e=>(0,Q.jsx)(`optgroup`,{label:r(`settings:agent.routingRolesGroup`,{label:e.label}),children:e.roles.map(e=>(0,Q.jsx)(`option`,{value:e.role,children:eu(e.role)},e.role))},e.phase)),y.length>0?(0,Q.jsx)(`optgroup`,{label:r(`settings:agent.routingCustomGroup`),children:y.map(e=>(0,Q.jsx)(`option`,{value:e,children:eu(e)},e))}):null]}),(0,Q.jsxs)(`select`,{"aria-label":r(`settings:agent.routingTargetAria`),value:o,onChange:e=>s(e.target.value),className:`h-9 min-w-0 rounded-md border bg-background px-3 font-mono text-sm`,children:[(0,Q.jsx)(`option`,{value:``,children:r(`settings:agent.routingTargetEmpty`)}),Object.keys(n.fallbackProfiles).length>0&&(0,Q.jsx)(`optgroup`,{label:r(`settings:agent.routingTargetProfilesGroup`),children:Object.keys(n.fallbackProfiles).map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e))}),t&&t.length>0&&(0,Q.jsx)(`optgroup`,{label:r(`settings:agent.routingTargetModelsGroup`),children:t.map(e=>(0,Q.jsxs)(`option`,{value:`${e.provider}/${e.model}`,children:[e.provider,`/`,e.model]},`${e.provider}/${e.model}`))})]}),(0,Q.jsx)(X,{type:`button`,variant:`outline`,onClick:h,children:r(`settings:agent.routingSet`)})]}),(0,Q.jsxs)(`div`,{className:`mt-2 grid grid-cols-1 gap-2 sm:grid-cols-3`,children:[(0,Q.jsx)(`select`,{"aria-label":r(`settings:agent.routingReasoningModeAria`),value:c,onChange:e=>l(e.target.value),className:`h-8 min-w-0 rounded-md border bg-background px-2 text-xs`,children:tu.map(e=>(0,Q.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))}),(0,Q.jsx)(`select`,{"aria-label":r(`settings:agent.routingReasoningEffortAria`),value:u,onChange:e=>d(e.target.value),className:`h-8 min-w-0 rounded-md border bg-background px-2 text-xs`,children:nu.map(e=>(0,Q.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))}),(0,Q.jsx)(`select`,{"aria-label":r(`settings:agent.routingReasoningPreserveAria`),value:f,onChange:e=>p(e.target.value),className:`h-8 min-w-0 rounded-md border bg-background px-2 text-xs`,children:ru.map(e=>(0,Q.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))})]}),(0,Q.jsx)(`div`,{className:`mt-3 space-y-1.5`,children:Object.keys(n.modelMatrix).length===0?(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`settings:agent.noRoutes`)}):Object.entries(n.modelMatrix).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>(0,Q.jsxs)(`div`,{className:`rounded-md border border-border bg-muted px-2 py-1.5 text-xs`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`w-40 shrink-0 truncate font-mono text-muted-foreground`,title:e,children:eu(e)}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:v(t)}),(0,Q.jsx)(X,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>g(e),children:r(`common:action.remove`)})]}),(0,Q.jsxs)(`div`,{className:`mt-2 grid grid-cols-1 gap-2 sm:grid-cols-3`,children:[(0,Q.jsx)(`select`,{"aria-label":r(`settings:agent.routingReasoningModeFor`,{key:e}),value:t.modelRuntime?.reasoning?.mode??``,onChange:t=>_(e,`mode`,t.target.value),className:`h-8 min-w-0 rounded-md border bg-background px-2 text-xs`,children:tu.map(e=>(0,Q.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))}),(0,Q.jsx)(`select`,{"aria-label":r(`settings:agent.routingReasoningEffortFor`,{key:e}),value:t.modelRuntime?.reasoning?.effort??``,onChange:t=>_(e,`effort`,t.target.value),className:`h-8 min-w-0 rounded-md border bg-background px-2 text-xs`,children:nu.map(e=>(0,Q.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))}),(0,Q.jsx)(`select`,{"aria-label":r(`settings:agent.routingReasoningPreserveFor`,{key:e}),value:t.modelRuntime?.reasoning?.preserve===void 0?``:t.modelRuntime.reasoning.preserve?`on`:`off`,onChange:t=>_(e,`preserve`,t.target.value),className:`h-8 min-w-0 rounded-md border bg-background px-2 text-xs`,children:ru.map(e=>(0,Q.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))})]})]},e))})]})}function cu(){let[e,t]=(0,Z.useState)(null),[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!0);(0,Z.useEffect)(()=>{s(!1)},[]);let c=(0,Z.useCallback)(async()=>{a(!0),r(!0),t(`pending`),a(!1)},[]),l=(0,Z.useCallback)(async()=>{a(!0),r(!1),t(null),a(!1)},[]);return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(it,{className:`h-5 w-5 text-info`}),(0,Q.jsx)(`h3`,{className:`text-lg font-semibold`,children:`Shadow Agent`}),o&&(0,Q.jsx)(g,{className:`h-4 w-4 animate-spin ml-2`}),n?(0,Q.jsx)(el,{className:`bg-success text-primary-foreground text-[10px]`,children:`● running`}):(0,Q.jsx)(el,{variant:`outline`,className:`text-[10px]`,children:`○ stopped`})]}),e&&(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Agent ID: `,(0,Q.jsxs)(`code`,{className:`font-mono`,children:[e.slice(0,12),`…`]})]}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`The Shadow Agent monitors all fleet agents, tracks their tasks, and detects anomalies (spike tasks, stuck agents, mailbox loops).`}),(0,Q.jsx)(`div`,{className:`flex gap-2`,children:n?(0,Q.jsxs)(X,{variant:`destructive`,size:`sm`,className:`gap-1`,onClick:l,disabled:i,children:[i?(0,Q.jsx)(g,{className:`h-4 w-4 animate-spin`}):(0,Q.jsx)(An,{className:`h-4 w-4`}),`Stop Shadow Agent`]}):(0,Q.jsxs)(X,{variant:`default`,size:`sm`,className:`gap-1`,onClick:c,disabled:i,children:[i?(0,Q.jsx)(g,{className:`h-4 w-4 animate-spin`}):(0,Q.jsx)(it,{className:`h-4 w-4`}),`Start Shadow Agent`]})})]})}function lu({disabled:e,mutating:t}){return(0,Q.jsx)(`span`,{className:`inline-block h-2 w-2 shrink-0 rounded-full ${e?`bg-muted-foreground`:t?`bg-warning`:`bg-success`}`,title:e?`disabled`:t?`mutating`:`read-only`})}function uu({tool:e,onToggle:t,busy:n}){let[r,i]=(0,Z.useState)(!1);return(0,Q.jsxs)(`div`,{className:`space-y-2 rounded-md border border-border/70 bg-card/70 p-3 transition-colors hover:bg-card`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 sm:flex-row sm:items-start`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-2`,children:[(0,Q.jsx)(lu,{disabled:e.disabled,mutating:e.mutating}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`code`,{className:`block truncate text-sm font-mono font-semibold`,title:e.name,children:e.name}),(0,Q.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1.5`,children:[(0,Q.jsx)(el,{variant:`outline`,className:`px-1.5 text-[10px]`,children:e.permission}),(0,Q.jsx)(el,{variant:`outline`,className:`px-1.5 text-[10px]`,children:e.mutating?`mutating`:`read-only`}),(0,Q.jsx)(`span`,{className:`truncate text-[11px] text-muted-foreground`,title:e.owner,children:e.owner})]})]})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-1`,children:[(0,Q.jsxs)(X,{variant:e.disabled?`default`:`secondary`,size:`sm`,className:`h-7 gap-1 px-2 text-xs`,onClick:t,disabled:n,children:[n?(0,Q.jsx)(g,{className:`h-3 w-3 animate-spin`}):e.disabled?(0,Q.jsx)(An,{className:`h-3 w-3`}):(0,Q.jsx)(gn,{className:`h-3 w-3`}),e.disabled?`Enable`:`Disable`]}),(0,Q.jsx)(`button`,{type:`button`,className:`rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,onClick:()=>i(!r),"aria-label":r?`Collapse`:`Expand`,children:(0,Q.jsx)(b,{className:`h-4 w-4 transition-transform ${r?`rotate-180`:``}`})})]})]}),r&&(0,Q.jsxs)(`div`,{className:`space-y-1 border-t border-border/60 pt-2 text-xs text-muted-foreground sm:ml-4`,children:[(0,Q.jsx)(`p`,{children:e.description}),e.params.length>0&&(0,Q.jsxs)(`p`,{children:[`Params: `,(0,Q.jsx)(`code`,{className:`break-all font-mono`,children:e.params.join(`, `)})]})]})]})}function du(){let{client:e}=dr(),[t,n]=(0,Z.useState)([]),[r,i]=(0,Z.useState)(!0),[a,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(new Set);(0,Z.useEffect)(()=>{let t=e.on(`tools.list`,e=>{let t=e.payload;n(t.tools),i(!1)}),r=t=>{if(t.type===`tool.disabled`||t.type===`tool.enabled`){let n=t.payload;c(e=>{let t=new Set(e);return t.delete(n.name),t}),n.ok?e.send({type:`tools.list`},{echoToChat:!1}):Y.error(`Tool "${n.name}" ${t.type===`tool.disabled`?`disable`:`enable`} failed.`)}},a=e.on(`tool.disabled`,r),o=e.on(`tool.enabled`,r);return()=>{t(),a(),o()}},[e]),(0,Z.useEffect)(()=>{e.send({type:`tools.list`},{echoToChat:!1})},[e]);let l=(0,Z.useCallback)((t,n)=>{c(e=>new Set(e).add(t)),e.send({type:n?`tool.enable`:`tool.disable`,payload:{name:t}})},[e]),u=a?t.filter(e=>e.name.toLowerCase().includes(a.toLowerCase())||e.owner.toLowerCase().includes(a.toLowerCase())):t,d=t.filter(e=>!e.disabled).length,f=t.filter(e=>e.disabled).length;return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Q.jsx)(`span`,{className:`flex h-9 w-9 items-center justify-center rounded-md border border-primary/20 bg-primary/10 text-primary`,children:(0,Q.jsx)(Mn,{className:`h-5 w-5`})}),(0,Q.jsx)(`h3`,{className:`text-base font-semibold`,children:`Tools`})]}),!r&&(0,Q.jsxs)(`span`,{className:`rounded-md border border-border/60 bg-muted/30 px-2 py-1 text-xs text-muted-foreground sm:ml-auto`,children:[d,` active · `,f,` disabled · `,t.length,` total`]})]}),(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(Tn,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground`}),(0,Q.jsx)(fi,{placeholder:`Filter tools by name or owner…`,value:a,onChange:e=>o(e.target.value),className:`pl-8 h-9 text-sm`})]}),r?(0,Q.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground gap-2`,children:[(0,Q.jsx)(g,{className:`h-4 w-4 animate-spin`}),`Loading tools…`]}):u.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground py-4 text-center`,children:a?`No tools matching "${a}".`:`No tools registered.`}):(0,Q.jsxs)(`div`,{className:`relative overflow-hidden rounded-lg border border-border/70 bg-background/35 shadow-inner`,children:[(0,Q.jsx)(`ul`,{className:`max-h-[min(58dvh,660px)] space-y-2 overflow-y-scroll p-2 pr-3 [scrollbar-gutter:stable]`,"aria-label":`Tools list`,children:u.map(e=>(0,Q.jsx)(`li`,{children:(0,Q.jsx)(uu,{tool:e,onToggle:()=>l(e.name,e.disabled),busy:s.has(e.name)})},e.name))}),(0,Q.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 top-0 h-4 bg-gradient-to-b from-background/90 to-transparent`}),(0,Q.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 h-8 bg-gradient-to-t from-background/95 to-transparent`})]})]})}function fu(){let{settingsActiveTab:e,setSettingsActiveTab:t}=U($t(e=>({settingsActiveTab:e.settingsActiveTab,setSettingsActiveTab:e.setSettingsActiveTab}))),n=Os(`settings`),{provider:r,model:i,setProvider:a,setModel:o,wsConnected:s}=q($t(e=>({provider:e.provider,model:e.model,setProvider:e.setProvider,setModel:e.setModel,wsConnected:e.wsConnected}))),c=dr(),l=c.client,{updatePrefs:u,switchAutonomy:d}=c,f=W(),{t:p}=V(),m=ei(!0),h=(0,Z.useCallback)((e,t)=>{f.set({[e]:t}),u({[e]:t})},[f,u]),[g,_]=(0,Z.useState)([]),[v,y]=(0,Z.useState)({}),[b,S]=(0,Z.useState)([]),[C,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(!1),[D,O]=(0,Z.useState)(!1),[k,A]=(0,Z.useState)(`catalog`),[j,M]=(0,Z.useState)(``),[N,P]=(0,Z.useState)(``),[ee,te]=(0,Z.useState)(!1),F=g.find(e=>e.id===r);(0,Z.useEffect)(()=>{let e=e=>{if(e.type===`provider.catalog`){let t=e.payload;_(t.providers.sort((e,t)=>e.id.localeCompare(t.id))),w(!1)}},t=e=>{if(e.type===`provider.models`){let t=e.payload;y(e=>({...e,[t.provider]:t.models})),E(!1)}},n=e=>{if(e.type===`providers.saved`){let t=e.payload.providers.sort((e,t)=>e.id.localeCompare(t.id));S(t),O(!1),t.length>0&&A(`saved`)}};if(!s||!l)return;let r=l.on(`provider.catalog`,e),i=l.on(`provider.models`,t),a=l.on(`providers.saved`,n);return w(!0),O(!0),l.listProviders(),l.listSavedProviders(),()=>{r?.(),i?.(),a?.()}},[s,l]);let I=(0,Z.useCallback)(e=>{a(e),v[e]||(E(!0),c.listProviderModels?.(e))},[v,a,c]),ne=(0,Z.useCallback)(e=>{o(e);let t=q.getState().provider;if(l){let n=null,r=l.on(`key.operation_result`,i=>{n&&clearTimeout(n),r();let a=i.payload;a.success?Y.success(H.t(`settings:toast.switchingTo`,{provider:t,model:e})):Y.error(a.message)});n=setTimeout(r,8e3)}c.switchModel?.(t,e)},[o,c,l]),L=(0,Z.useCallback)((e,t,n)=>{c.addKey?.(e,t,n)},[c]),ie=(0,Z.useCallback)((e,t)=>{c.deleteKey?.(e,t)},[c]),ae=(0,Z.useCallback)((e,t)=>{c.setActiveKey?.(e,t)},[c]),R=(0,Z.useCallback)((e,t,n,r)=>{c.addProvider?.(e,t,n,r)},[c]),z=(0,Z.useCallback)(e=>{c.removeProvider?.(e)},[c]),oe=(0,Z.useCallback)((e,t)=>{c.client.updateProvider({id:e,models:[t]}),e===q.getState().provider&&o(t)},[o,c.client]),se=(0,Z.useCallback)(e=>h(`fallbackProfiles`,e),[h]),ce=(0,Z.useCallback)(()=>{let e=N.trim();if(e){if(f.fallbackProfiles[e]){Y.error(H.t(`settings:toast.fallbackExists`,{name:e}));return}se({...f.fallbackProfiles,[e]:[]}),P(``)}},[f.fallbackProfiles,N,se]),le=(0,Z.useCallback)(()=>{let e=r&&i?`${r}/${i}`:``;if(!e){Y.error(H.t(`settings:toast.selectProviderModelFirst`));return}let t=[e,...f.fallbackModels].filter((e,t,n)=>e&&n.indexOf(e)===t);se({...f.fallbackProfiles,default:t}),Y.success(H.t(`settings:toast.defaultProfileCreated`))},[i,f.fallbackModels,f.fallbackProfiles,r,se]);(0,Z.useEffect)(()=>{if(Object.keys(f.fallbackProfiles).length>0)return;let e=r&&i?`${r}/${i}`:``;if(!e)return;let t=[e,...f.fallbackModels].filter((e,t,n)=>e&&n.indexOf(e)===t);se({default:t})},[i,f.fallbackModels,f.fallbackProfiles,r,se]);let ue=(0,Z.useCallback)((e,t)=>{se({...f.fallbackProfiles,[e]:t})},[f.fallbackProfiles,se]),de=(0,Z.useCallback)(e=>{let{[e]:t,...n}=f.fallbackProfiles;se(n)},[f.fallbackProfiles,se]),fe=(0,Z.useCallback)(e=>{let t=f.fallbackProfiles[e]??[];h(`fallbackModels`,t)},[f.fallbackProfiles,h]),pe=(0,Z.useCallback)(e=>{let t=f.fallbackProfiles[e]??[],n=t[0];if(!n){Y.error(H.t(`settings:toast.profileEmpty`,{name:e}));return}let i=n.indexOf(`/`),s=i>0?n.slice(0,i):r,l=i>0?n.slice(i+1):n;a(s),o(l),c.switchModel?.(s,l),h(`fallbackModels`,t.slice(1)),Y.success(H.t(`settings:toast.leaderSetFrom`,{name:e}))},[f.fallbackProfiles,r,o,a,h,c]);return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col bg-background/70`,children:[(0,Q.jsxs)(`header`,{className:`flex items-center justify-between px-4 py-3 border-b border-border/70 bg-card/90 backdrop-blur-xl shrink-0 shadow-sm`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h1`,{className:`text-lg font-semibold`,children:p(`settings:title`)}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:r&&i?`${r} / ${i}`:p(`settings:tabs.provider`)})]}),(0,Q.jsx)(X,{variant:`ghost`,size:`icon`,onClick:()=>J(`chat`),children:(0,Q.jsx)(vn,{className:`h-4 w-4`})})]}),(0,Q.jsx)(Zs,{className:`min-h-0 flex-1`,ref:n,children:(0,Q.jsx)(`div`,{className:`mx-auto max-w-6xl p-4 sm:p-6`,children:(0,Q.jsxs)($s,{value:e,onValueChange:t,className:`grid min-h-[calc(100dvh-9rem)] gap-3 lg:grid-cols-[13.5rem_minmax(0,1fr)] lg:gap-5`,children:[(0,Q.jsxs)(`div`,{className:`relative min-w-0`,children:[(0,Q.jsxs)(ec,{className:`flex h-auto w-full justify-start gap-1 overflow-x-scroll rounded-lg border border-border/70 bg-card/60 p-1 pb-2 shadow-sm [scrollbar-gutter:stable] lg:sticky lg:top-4 lg:flex-col lg:overflow-visible lg:rounded-xl lg:bg-card/65 lg:p-2`,children:[(0,Q.jsxs)(tc,{value:`provider`,className:`h-9 shrink-0 gap-2 rounded-md px-3 text-xs scroll-mt-2 lg:w-full lg:justify-start`,children:[(0,Q.jsx)(x,{className:`h-3.5 w-3.5`}),p(`settings:tabs.provider`)]}),(0,Q.jsxs)(tc,{value:`connection`,className:`h-9 shrink-0 gap-2 rounded-md px-3 text-xs scroll-mt-2 lg:w-full lg:justify-start`,children:[(0,Q.jsx)(Rn,{className:`h-3.5 w-3.5`}),p(`settings:tabs.connection`)]}),(0,Q.jsxs)(tc,{value:`appearance`,className:`h-9 shrink-0 gap-2 rounded-md px-3 text-xs scroll-mt-2 lg:w-full lg:justify-start`,children:[(0,Q.jsx)(Dt,{className:`h-3.5 w-3.5`}),p(`settings:tabs.appearance`)]}),(0,Q.jsxs)(tc,{value:`agent`,className:`h-9 shrink-0 gap-2 rounded-md px-3 text-xs scroll-mt-2 lg:w-full lg:justify-start`,children:[(0,Q.jsx)(Ee,{className:`h-3.5 w-3.5`}),p(`settings:tabs.agent`)]}),(0,Q.jsxs)(tc,{value:`features`,className:`h-9 shrink-0 gap-2 rounded-md px-3 text-xs scroll-mt-2 lg:w-full lg:justify-start`,children:[(0,Q.jsx)(wt,{className:`h-3.5 w-3.5`}),p(`settings:tabs.features`)]}),(0,Q.jsxs)(tc,{value:`tools`,className:`h-9 shrink-0 gap-2 rounded-md px-3 text-xs scroll-mt-2 lg:w-full lg:justify-start`,children:[(0,Q.jsx)(Mn,{className:`h-3.5 w-3.5`}),p(`settings:tabs.tools`)]}),(0,Q.jsxs)(tc,{value:`mcp`,className:`h-9 shrink-0 gap-2 rounded-md px-3 text-xs scroll-mt-2 lg:w-full lg:justify-start`,children:[(0,Q.jsx)(re,{className:`h-3.5 w-3.5`}),p(`settings:tabs.mcp`)]}),(0,Q.jsxs)(tc,{value:`brain`,className:`h-9 shrink-0 gap-2 rounded-md px-3 text-xs scroll-mt-2 lg:w-full lg:justify-start`,children:[(0,Q.jsx)(on,{className:`h-3.5 w-3.5`}),p(`settings:tabs.brain`)]}),(0,Q.jsxs)(tc,{value:`shadow`,className:`h-9 shrink-0 gap-2 rounded-md px-3 text-xs scroll-mt-2 lg:w-full lg:justify-start`,children:[(0,Q.jsx)(it,{className:`h-3.5 w-3.5`}),p(`settings:tabs.shadow`)]})]}),(0,Q.jsx)(`div`,{className:`pointer-events-none absolute inset-y-1 left-0 z-10 w-8 rounded-l-lg bg-gradient-to-r from-background via-background/90 to-transparent lg:hidden`}),(0,Q.jsx)(`div`,{className:`pointer-events-none absolute inset-y-1 right-0 z-10 w-8 rounded-r-lg bg-gradient-to-l from-background via-background/90 to-transparent lg:hidden`})]}),(0,Q.jsxs)(`div`,{className:`min-w-0 rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm sm:p-5`,children:[(0,Q.jsxs)(nc,{value:`provider`,className:`mt-0 space-y-4`,children:[(0,Q.jsx)(Jl,{activeProvider:r,catalogProviders:g,isLoadingCatalog:C,savedProviders:b,isLoadingSaved:D,providerTab:k,setProviderTab:A,onSelectProvider:I,onAddKey:L,onDeleteKey:ie,onSetActiveKey:ae,onAddProvider:R,onRemoveProvider:z,onPickProviderModel:oe,ws:c.client,catalogQuery:j,setCatalogQuery:M}),(0,Q.jsxs)(`div`,{className:`pt-4 border-t`,children:[(0,Q.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 flex items-center gap-2`,children:[(0,Q.jsx)(yt,{className:`h-4 w-4 text-muted-foreground`}),p(`settings:agent.modelHeading`)]}),(0,Q.jsx)(Tl,{provider:r,catalogModels:v,currentCatalogProvider:F,isLoadingModels:T,setIsLoadingModels:E,onModelSelect:ne,refreshModels:e=>c.listProviderModels?.(e)})]})]}),(0,Q.jsx)(ml,{}),(0,Q.jsx)(hl,{}),(0,Q.jsxs)(nc,{value:`agent`,className:`mt-0 space-y-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 flex items-center gap-2`,children:[(0,Q.jsx)(_t,{className:`h-4 w-4 text-muted-foreground`}),p(`settings:agent.autonomyHeading`)]}),(0,Q.jsx)(nl,{label:p(`settings:agent.autonomyModeLabel`),hint:p(`settings:agent.autonomyModeHint`),value:f.autonomy,options:[{value:`off`,label:p(`settings:agent.autonomyModeOff`)},{value:`suggest`,label:p(`settings:agent.autonomyModeSuggest`)},{value:`auto`,label:p(`settings:agent.autonomyModeAuto`)},{value:`eternal`,label:p(`settings:agent.autonomyModeEternal`)},{value:`eternal-parallel`,label:p(`settings:agent.autonomyModeEternalParallel`)}],onChange:e=>{f.set({autonomy:e}),d(e)}}),(0,Q.jsx)(tl,{label:p(`settings:agent.autoProceedDelayLabel`),hint:p(`settings:agent.autoProceedDelayHint`),value:f.autonomyDelayMs,min:0,max:1e4,step:500,unit:`ms`,onChange:e=>h(`autonomyDelayMs`,e)}),(0,Q.jsx)($,{label:p(`settings:agent.yoloLabel`),hint:p(`settings:agent.yoloHint`),value:f.yolo,onChange:()=>h(`yolo`,!f.yolo)})]}),(0,Q.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Q.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 mt-3 flex items-center gap-2`,children:[(0,Q.jsx)(Tt,{className:`h-4 w-4 text-muted-foreground`}),p(`settings:agent.refineHeading`)]}),(0,Q.jsx)($,{label:p(`settings:agent.enableRefineLabel`),hint:p(`settings:agent.enableRefineHint`),value:f.enhanceEnabled,onChange:()=>h(`enhanceEnabled`,!f.enhanceEnabled)}),(0,Q.jsx)(tl,{label:p(`settings:agent.refineDelayLabel`),hint:p(`settings:agent.refineDelayHint`),value:f.enhanceDelayMs,min:3e4,max:12e4,step:15e3,unit:`ms`,onChange:e=>h(`enhanceDelayMs`,e)}),(0,Q.jsx)(nl,{label:p(`settings:agent.refineLanguageLabel`),hint:p(`settings:agent.refineLanguageHint`),value:f.enhanceLanguage,options:[{value:`original`,label:p(`settings:agent.refineLanguageOriginal`)},{value:`english`,label:p(`settings:agent.refineLanguageEnglish`)}],onChange:e=>h(`enhanceLanguage`,e)}),(0,Q.jsxs)(`div`,{className:`pt-2`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium mb-1`,children:p(`settings:agent.refineHeading`)}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-border p-3 cursor-pointer hover:bg-muted/50 transition-colors`,onClick:()=>te(!0),children:[(0,Q.jsx)(`div`,{className:`min-w-0 flex-1`,children:f.refinerFallbackProfile?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-mono text-primary bg-primary/10 px-1.5 py-0.5 rounded`,children:f.refinerFallbackProfile}),(0,Q.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[(f.fallbackProfiles[f.refinerFallbackProfile]??[]).slice(0,2).join(` → `),(f.fallbackProfiles[f.refinerFallbackProfile]??[]).length>2?` …`:``]})]}):f.refinerProvider&&f.refinerModel?(0,Q.jsxs)(`span`,{className:`text-xs font-mono`,children:[f.refinerProvider,`/`,f.refinerModel]}):f.refinerProvider?(0,Q.jsxs)(`span`,{className:`text-xs font-mono`,children:[f.refinerProvider,` /`,` `,(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`(session model)`})]}):(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:p(`settings:agent.refinerProviderDefault`)})}),(0,Q.jsx)(yt,{className:`h-4 w-4 shrink-0 text-muted-foreground`})]}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:p(`settings:agent.refineDelayHint`)})]}),ee&&(0,Q.jsx)(Qc,{open:ee,mode:`both`,title:p(`settings:agent.refineHeading`),hint:p(`settings:agent.refinerProviderHint`),fallbackProfiles:f.fallbackProfiles,clearLabel:p(`common:action.clear`),onPick:e=>{e.type===`clear`?(h(`refinerProvider`,``),h(`refinerModel`,``),h(`refinerFallbackProfile`,``)):e.type===`provider-model`?(h(`refinerProvider`,e.provider),h(`refinerModel`,e.model),h(`refinerFallbackProfile`,``)):e.type===`fallback-profile`&&(h(`refinerProvider`,``),h(`refinerModel`,``),h(`refinerFallbackProfile`,e.name)),te(!1)},onClose:()=>te(!1)})]}),(0,Q.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Q.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 mt-3 flex items-center gap-2`,children:[(0,Q.jsx)(yt,{className:`h-4 w-4 text-muted-foreground`}),p(`settings:agent.reasoningHeading`)]}),(0,Q.jsx)(nl,{label:p(`settings:agent.reasoningModeLabel`),hint:p(`settings:agent.reasoningModeHint`),value:f.reasoningMode,options:[{value:`auto`,label:p(`settings:agent.reasoningModeAuto`)},{value:`on`,label:p(`settings:agent.reasoningModeOn`)},{value:`off`,label:p(`settings:agent.reasoningModeOff`)}],onChange:e=>h(`reasoningMode`,e)}),(0,Q.jsx)(nl,{label:p(`settings:agent.reasoningEffortLabel`),hint:p(`settings:agent.reasoningEffortHint`),value:f.reasoningEffort,options:[{value:`none`,label:p(`settings:agent.reasoningEffortNone`)},{value:`minimal`,label:p(`settings:agent.reasoningEffortMinimal`)},{value:`low`,label:p(`settings:agent.reasoningEffortLow`)},{value:`medium`,label:p(`settings:agent.reasoningEffortMedium`)},{value:`high`,label:p(`settings:agent.reasoningEffortHigh`)},{value:`xhigh`,label:p(`settings:agent.reasoningEffortXhigh`)},{value:`max`,label:p(`settings:agent.reasoningEffortMax`)}],onChange:e=>h(`reasoningEffort`,e)}),(0,Q.jsx)($,{label:p(`settings:agent.preserveThinkingLabel`),hint:p(`settings:agent.preserveThinkingHint`),value:f.reasoningPreserve,onChange:()=>h(`reasoningPreserve`,!f.reasoningPreserve)}),(0,Q.jsx)(nl,{label:p(`settings:agent.cacheTtlLabel`),hint:p(`settings:agent.cacheTtlHint`),value:f.cacheTtl,options:[{value:`default`,label:p(`settings:agent.cacheTtlDefault`)},{value:`5m`,label:p(`settings:agent.cacheTtl5m`)},{value:`1h`,label:p(`settings:agent.cacheTtl1h`)}],onChange:e=>h(`cacheTtl`,e)}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-2`,children:p(`settings:agent.capsHint`)})]}),(0,Q.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold mb-2 mt-3`,children:`Provider/model availability calendar`}),(0,Q.jsx)(`p`,{className:`mb-3 text-xs text-muted-foreground`,children:`Prevent autonomous and overnight runs from using selected providers or models during recurring windows.`}),(0,Q.jsx)(Yc,{value:f.modelAvailabilitySchedule,candidates:m,onChange:e=>h(`modelAvailabilitySchedule`,e)})]}),(0,Q.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Q.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 mt-3 flex items-center gap-2`,children:[(0,Q.jsx)(yt,{className:`h-4 w-4 text-muted-foreground`}),p(`settings:agent.fallbackHeading`)]}),(0,Q.jsx)(`p`,{className:`mb-2 text-xs text-muted-foreground`,children:p(`settings:agent.fallbackBody`)}),(0,Q.jsx)(Xc,{value:f.fallbackModels,candidates:m,onChange:e=>h(`fallbackModels`,e)}),(0,Q.jsxs)(`div`,{className:`pt-1`,children:[(0,Q.jsx)($,{label:p(`settings:agent.autoFallbackLabel`),hint:p(`settings:agent.autoFallbackHint`),value:f.fallbackAuto,onChange:()=>h(`fallbackAuto`,!f.fallbackAuto)}),(0,Q.jsx)($,{label:p(`settings:agent.favoritesOnlyLabel`),hint:p(`settings:agent.favoritesOnlyHint`),value:f.favoriteModelsOnly,onChange:()=>h(`favoriteModelsOnly`,!f.favoriteModelsOnly)})]})]}),(0,Q.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Q.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 mt-3 flex items-center gap-2`,children:[(0,Q.jsx)(et,{className:`h-4 w-4 text-muted-foreground`}),p(`settings:agent.profilesHeading`)]}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(fi,{value:N,onChange:e=>P(e.target.value),placeholder:`fallback1`,className:`font-mono text-sm`,onKeyDown:e=>{e.key===`Enter`&&ce()}}),(0,Q.jsx)(X,{type:`button`,variant:`outline`,onClick:ce,children:p(`settings:agent.addProfile`)})]}),(0,Q.jsx)(`div`,{className:`mt-3 space-y-3`,children:Object.keys(f.fallbackProfiles).length===0?(0,Q.jsxs)(`div`,{className:`rounded-md border border-dashed border-border p-3`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:p(`settings:agent.noProfiles`)}),(0,Q.jsx)(X,{type:`button`,variant:`outline`,size:`sm`,className:`mt-2`,onClick:le,children:p(`settings:agent.createDefault`)})]}):Object.entries(f.fallbackProfiles).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>(0,Q.jsxs)(`div`,{className:`rounded-md border border-border p-3`,children:[(0,Q.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`span`,{className:`font-mono text-sm font-medium`,children:e}),(0,Q.jsxs)(`div`,{className:`flex gap-1`,children:[(0,Q.jsx)(X,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>fe(e),children:p(`settings:agent.useChain`)}),(0,Q.jsx)(X,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>pe(e),children:p(`settings:agent.setLeader`)}),(0,Q.jsx)(X,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>de(e),children:p(`common:action.remove`)})]})]}),(0,Q.jsx)(Xc,{value:t,candidates:m,placeholder:p(`settings:agent.addModelToProfile`),emptyHint:p(`settings:agent.profileEmpty`),onChange:t=>ue(e,t)})]},e))})]}),(0,Q.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Q.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 mt-3 flex items-center gap-2`,children:[(0,Q.jsx)(yt,{className:`h-4 w-4 text-muted-foreground`}),p(`settings:agent.favoritesHeading`)]}),(0,Q.jsx)(Xc,{value:f.favoriteModels,candidates:m,placeholder:p(`settings:agent.addFavoriteModel`),emptyHint:p(`settings:agent.favoritesEmpty`),onChange:e=>h(`favoriteModels`,e)})]}),(0,Q.jsx)(su,{syncPref:h,candidates:m}),(0,Q.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Q.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 mt-3 flex items-center gap-2`,children:[(0,Q.jsx)(x,{className:`h-4 w-4 text-muted-foreground`}),p(`settings:agent.hqHeading`)]}),(0,Q.jsx)($,{label:p(`settings:agent.hqPublishingLabel`),hint:p(`settings:agent.hqPublishingHint`),value:f.hqEnabled,onChange:()=>h(`hqEnabled`,!f.hqEnabled)}),(0,Q.jsxs)(`div`,{className:`space-y-1 py-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium`,children:p(`settings:agent.hqUrlLabel`)}),(0,Q.jsx)(fi,{value:f.hqUrl,placeholder:`http://host:3499`,onChange:e=>h(`hqUrl`,e.target.value)}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:p(`settings:agent.hqUrlHint`)})]}),(0,Q.jsxs)(`div`,{className:`space-y-1 py-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium`,children:p(`settings:agent.hqTokenLabel`)}),(0,Q.jsx)(fi,{type:`password`,value:f.hqToken,placeholder:`Client token from wstack --hq`,onChange:e=>h(`hqToken`,e.target.value)})]}),(0,Q.jsx)($,{label:p(`settings:agent.hqRawContentLabel`),hint:p(`settings:agent.hqRawContentHint`),value:f.hqRawContent,onChange:()=>h(`hqRawContent`,!f.hqRawContent)})]}),(0,Q.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Q.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 mt-3 flex items-center gap-2`,children:[(0,Q.jsx)(Tt,{className:`h-4 w-4 text-muted-foreground`}),p(`settings:agent.executionHeading`)]}),(0,Q.jsx)(tl,{label:p(`settings:agent.maxIterationsLabel`),hint:p(`settings:agent.maxIterationsHint`),value:f.maxIterations,min:10,max:2e3,step:10,onChange:e=>h(`maxIterations`,e)}),(0,Q.jsx)(tl,{label:p(`settings:agent.autoProceedMaxIterationsLabel`),hint:p(`settings:agent.autoProceedMaxIterationsHint`),value:f.autoProceedMaxIterations,min:0,max:250,step:5,onChange:e=>h(`autoProceedMaxIterations`,e)}),(0,Q.jsx)($,{label:p(`settings:agent.confirmExitLabel`),hint:p(`settings:agent.confirmExitHint`),value:f.confirmExit,onChange:()=>h(`confirmExit`,!f.confirmExit)}),(0,Q.jsx)($,{label:p(`settings:agent.chimeLabel`),hint:p(`settings:agent.chimeHint`),value:f.chime,onChange:()=>h(`chime`,!f.chime)})]}),(0,Q.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Q.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 mt-3 flex items-center gap-2`,children:[(0,Q.jsx)(vt,{className:`h-4 w-4 text-muted-foreground`}),p(`settings:agent.fleetHeading`)]}),(0,Q.jsx)($,{label:p(`settings:agent.streamFleetLabel`),hint:p(`settings:agent.streamFleetHint`),value:f.streamFleet,onChange:()=>h(`streamFleet`,!f.streamFleet)}),(0,Q.jsx)(tl,{label:p(`settings:agent.maxConcurrentLabel`),hint:p(`settings:agent.maxConcurrentHint`),value:f.maxConcurrent,min:1,max:50,step:1,onChange:e=>h(`maxConcurrent`,e)}),(0,Q.jsx)($,{label:p(`settings:agent.nextPredictionLabel`),hint:p(`settings:agent.nextPredictionHint`),value:f.nextPrediction,onChange:()=>h(`nextPrediction`,!f.nextPrediction)})]}),(0,Q.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Q.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 mt-3 flex items-center gap-2`,children:[(0,Q.jsx)(_e,{className:`h-4 w-4 text-muted-foreground`}),p(`settings:agent.telegramHeading`)]}),f.tgConfigured?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)($,{label:p(`settings:agent.telegramSessionEndLabel`),hint:p(`settings:agent.telegramSessionEndHint`),value:f.tgSessionEnd,onChange:()=>h(`tgSessionEnd`,!f.tgSessionEnd)}),(0,Q.jsx)($,{label:p(`settings:agent.telegramDelegateLabel`),hint:p(`settings:agent.telegramDelegateHint`),value:f.tgDelegate,onChange:()=>h(`tgDelegate`,!f.tgDelegate)}),(0,Q.jsx)($,{label:p(`settings:agent.telegramLongToolLabel`),hint:p(`settings:agent.telegramLongToolHint`,{ms:f.tgLongToolMs}),value:f.tgLongToolMs>0,onChange:()=>h(`tgLongToolMs`,f.tgLongToolMs>0?0:3e4)}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-2`,children:p(`settings:agent.telegramChangesApply`)})]}):(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:p(`settings:agent.telegramNotConfigured`)})]})]}),(0,Q.jsxs)(nc,{value:`features`,className:`mt-0 space-y-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 flex items-center gap-2`,children:[(0,Q.jsx)(wt,{className:`h-4 w-4 text-muted-foreground`}),p(`settings:features.flagsHeading`)]}),(0,Q.jsx)($,{label:p(`settings:features.mcpLabel`),hint:p(`settings:features.mcpHint`),value:f.featureMcp,onChange:()=>h(`featureMcp`,!f.featureMcp)}),(0,Q.jsx)($,{label:p(`settings:features.pluginsLabel`),hint:p(`settings:features.pluginsHint`),value:f.featurePlugins,onChange:()=>h(`featurePlugins`,!f.featurePlugins)}),(0,Q.jsx)($,{label:p(`settings:features.memoryLabel`),hint:p(`settings:features.memoryHint`),value:f.featureMemory,onChange:()=>h(`featureMemory`,!f.featureMemory)}),(0,Q.jsx)($,{label:p(`settings:features.skillsLabel`),hint:p(`settings:features.skillsHint`),value:f.featureSkills,onChange:()=>h(`featureSkills`,!f.featureSkills)}),(0,Q.jsx)($,{label:p(`settings:features.modelsRegistryLabel`),hint:p(`settings:features.modelsRegistryHint`),value:f.featureModelsRegistry,onChange:()=>h(`featureModelsRegistry`,!f.featureModelsRegistry)}),(0,Q.jsx)($,{label:p(`settings:features.indexOnStartLabel`),hint:p(`settings:features.indexOnStartHint`),value:f.indexOnStart,onChange:()=>h(`indexOnStart`,!f.indexOnStart)})]}),(0,Q.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Q.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 mt-3 flex items-center gap-2`,children:[(0,Q.jsx)(Tt,{className:`h-4 w-4 text-muted-foreground`}),p(`settings:features.chimeraHeading`)]}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:p(`settings:features.chimeraAutoFixHint`)})]}),(0,Q.jsx)(`div`,{className:`pt-2 border-t`,children:(0,Q.jsx)(gl,{syncPref:h,sessionProvider:r,sessionModel:i})}),(0,Q.jsx)(Dl,{}),(0,Q.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Q.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 mt-3 flex items-center gap-2`,children:[(0,Q.jsx)(We,{className:`h-4 w-4 text-muted-foreground`}),p(`settings:features.contextHeading`)]}),(0,Q.jsx)($,{label:p(`settings:features.autoCompactLabel`),hint:p(`settings:features.autoCompactHint`),value:f.contextAutoCompact,onChange:()=>h(`contextAutoCompact`,!f.contextAutoCompact)}),(0,Q.jsx)(nl,{label:p(`settings:features.compactorStrategyLabel`),hint:p(`settings:features.compactorStrategyHint`),value:f.contextStrategy,options:[{value:`hybrid`,label:p(`settings:features.compactorStrategyHybrid`)},{value:`intelligent`,label:p(`settings:features.compactorStrategyIntelligent`)},{value:`selective`,label:p(`settings:features.compactorStrategySelective`)}],onChange:e=>h(`contextStrategy`,e)}),(0,Q.jsx)(nl,{label:p(`settings:features.contextModeLabel`),hint:p(`settings:features.contextModeHint`),value:f.contextMode,options:[{value:`balanced`,label:p(`settings:features.contextModeBalanced`)},{value:`frugal`,label:p(`settings:features.contextModeFrugal`)},{value:`deep`,label:p(`settings:features.contextModeDeep`)},{value:`archival`,label:p(`settings:features.contextModeArchival`)}],onChange:e=>h(`contextMode`,e)}),(0,Q.jsx)(nl,{label:p(`settings:features.tokenSavingLabel`),hint:p(`settings:features.tokenSavingHint`),value:f.tokenSavingTier,options:[{value:`off`,label:p(`settings:features.tokenSavingOff`)},{value:`minimal`,label:p(`settings:features.tokenSavingMinimal`)},{value:`light`,label:p(`settings:features.tokenSavingLight`)},{value:`medium`,label:p(`settings:features.tokenSavingMedium`)},{value:`aggressive`,label:p(`settings:features.tokenSavingAggressive`)}],onChange:e=>h(`tokenSavingTier`,e)}),(0,Q.jsx)(nl,{label:p(`settings:features.logLevelLabel`),hint:p(`settings:features.logLevelHint`),value:f.logLevel,options:[{value:`debug`,label:p(`settings:features.logLevelDebug`)},{value:`info`,label:p(`settings:features.logLevelInfo`)},{value:`warn`,label:p(`settings:features.logLevelWarn`)},{value:`error`,label:p(`settings:features.logLevelError`)}],onChange:e=>h(`logLevel`,e)}),(0,Q.jsx)(nl,{label:p(`settings:features.auditLevelLabel`),hint:p(`settings:features.auditLevelHint`),value:f.auditLevel,options:[{value:`minimal`,label:p(`settings:features.auditLevelMinimal`)},{value:`standard`,label:p(`settings:features.auditLevelStandard`)},{value:`full`,label:p(`settings:features.auditLevelFull`)}],onChange:e=>h(`auditLevel`,e)})]})]}),(0,Q.jsx)(nc,{value:`tools`,className:`mt-0 space-y-4`,children:(0,Q.jsx)(du,{})}),(0,Q.jsx)(nc,{value:`mcp`,className:`mt-0 space-y-4`,children:f.featureMcp?(0,Q.jsx)(wl,{}):(0,Q.jsxs)(`div`,{className:`text-center py-8 text-muted-foreground`,children:[(0,Q.jsx)(re,{className:`w-10 h-10 mx-auto mb-2 opacity-50`}),(0,Q.jsx)(`p`,{children:p(`settings:mcp.disabled`)}),(0,Q.jsx)(`p`,{className:`text-sm mt-1`,children:p(`settings:mcp.disabledHint`)})]})}),(0,Q.jsx)(nc,{value:`brain`,className:`mt-0 space-y-4`,children:(0,Q.jsx)(pl,{})}),(0,Q.jsx)(nc,{value:`shadow`,className:`mt-0 space-y-4`,children:(0,Q.jsx)(cu,{})})]})]})})})]})}var pu=[{sectionKey:`sectionGlobal`,items:[{keys:[`Ctrl`,`K`],descKey:`dCommandPalette`},{keys:[`?`],descKey:`dShowOverlay`},{keys:[`Ctrl`,`\\`],descKey:`dToggleSidebar`},{keys:[`Ctrl`,`1-8`],descKey:`dOpenPanel`},{keys:[`Ctrl`,`0`],descKey:`dDesignStudio`},{keys:[`Ctrl`,`Shift`,`W`],descKey:`dWorktrees`},{keys:[`Ctrl`,`/`],descKey:`dFocusInput`}]},{sectionKey:`sectionTuiParity`,items:[{keys:[`F1`],descKey:`dSessionPanel`},{keys:[`F2`],descKey:`dFleetOverlay`},{keys:[`F3`],descKey:`dAgentsOverlay`},{keys:[`F4`],descKey:`dWorktreeMonitor`},{keys:[`F5`],descKey:`dPlanPanel`},{keys:[`F6`],descKey:`dTodosPanel`},{keys:[`F7`],descKey:`dQueuePanel`},{keys:[`F8`],descKey:`dProcessMonitor`},{keys:[`F9`],descKey:`dGoalPanel`},{keys:[`F10`],descKey:`dSessionsDashboard`},{keys:[`F11`],descKey:`dOfficeMap`},{keys:[`F12`],descKey:`dDockPicker`}]},{sectionKey:`sectionFleet`,items:[{keys:[`Ctrl`,`Shift`,`M`],descKey:`dOpenFleet`},{keys:[`Ctrl`,`Shift`,`A`],descKey:`dOpenAgents`},{keys:[`↑`,`↓`],descKey:`dNavigateAgents`},{keys:[`Enter`],descKey:`dSelectAgent`},{keys:[`Esc`],descKey:`dCloseOverlay`}]},{sectionKey:`sectionChatInput`,items:[{keys:[`Enter`],descKey:`dSendMessage`},{keys:[`Shift`,`Enter`],descKey:`dNewline`},{keys:[`↑`],descKey:`dRecallPrev`},{keys:[`↓`],descKey:`dRecallNext`},{keys:[`/`],descKey:`dSlashPopup`},{keys:[`Tab`],descKey:`dAutocomplete`},{keys:[`Esc`],descKey:`dDismissPopup`}]},{sectionKey:`sectionChat`,items:[{keys:[`Ctrl`,`F`],descKey:`dSearchChat`},{keys:[`Ctrl`,`L`],descKey:`dClearContext`},{keys:[`Ctrl`,`N`],descKey:`dNewSession`},{keys:[`Ctrl`,`E`],descKey:`dExportMarkdown`},{keys:[`Ctrl`,`M`],descKey:`dModelSwitcher`},{keys:[`Ctrl`,`Shift`,`D`],descKey:`dCompactDensity`},{keys:[`Esc`],descKey:`dAbortRun`}]},{sectionKey:`sectionChatNav`,items:[{keys:[`j`],descKey:`dFocusNext`},{keys:[`k`],descKey:`dFocusPrev`},{keys:[`g`],descKey:`dJumpFirst`},{keys:[`Shift`,`G`],descKey:`dJumpLast`},{keys:[`c`],descKey:`dCopyFocused`},{keys:[`Esc`],descKey:`dClearFocused`}]}];function mu(){let{t:e}=V(),t=U(e=>e.shortcutsOpen),n=U(e=>e.setShortcutsOpen);return(0,Z.useEffect)(()=>{let e=e=>{let t=e.target,r=t?.tagName?.toLowerCase();!(r===`input`||r===`textarea`||t?.isContentEditable)&&e.key===`?`&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&(e.preventDefault(),n(!U.getState().shortcutsOpen))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),(0,Q.jsx)($r,{open:t,onOpenChange:e=>{e||n(!1)},children:(0,Q.jsxs)(Xr,{className:`max-w-2xl gap-0 p-0 overflow-hidden flex flex-col max-h-[80dvh]`,children:[(0,Q.jsx)(`div`,{className:`flex items-center justify-between px-5 py-4 border-b`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Le,{className:`h-4 w-4 text-muted-foreground`}),(0,Q.jsx)(Zr,{className:`text-sm font-semibold`,children:e(`activity:shortcuts.heading`)})]})}),(0,Q.jsx)(Qr,{className:`sr-only`,children:e(`activity:shortcuts.heading`)}),(0,Q.jsx)(`div`,{className:`overflow-y-auto overscroll-contain px-5 py-4 space-y-6`,children:pu.map(t=>(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground mb-2`,children:e(`activity:shortcuts.${t.sectionKey}`)}),(0,Q.jsx)(`div`,{className:`grid grid-cols-1 gap-1.5`,children:t.items.map(t=>(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-sm px-2 py-1.5 rounded hover:bg-muted/40`,children:[(0,Q.jsx)(`span`,{className:`text-foreground/80`,children:e(`activity:shortcuts.${t.descKey}`)}),(0,Q.jsx)(`span`,{className:`flex items-center gap-1 shrink-0`,children:t.keys.map((e,t)=>(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[t>0&&(0,Q.jsx)(`span`,{className:`text-muted-foreground/65 text-xs`,children:`+`}),(0,Q.jsx)(`kbd`,{className:`font-mono text-[10px] border rounded px-1.5 py-0.5 bg-background`,children:e})]},e))})]},t.descKey))})]},t.sectionKey))}),(0,Q.jsxs)(`div`,{className:`border-t px-5 py-3 text-xs text-muted-foreground`,children:[e(`activity:shortcuts.footerPre`),` `,(0,Q.jsx)(`kbd`,{className:`font-mono text-[10px] border rounded px-1 py-0.5 bg-background`,children:`?`}),` `,e(`activity:shortcuts.footerPost`)]})]})})}function hu(e,t){let n=[],r=(e,i)=>{for(let a of e)if(n.push({node:a,depth:i}),a.type===`directory`&&t.has(a.path)){let e=a.children??[];e.length>0?r(e,i+1):n.push({node:a,depth:i+1,emptyPlaceholder:!0})}};return r(e,0),n}function gu(e){let t=[],n=e=>{for(let r of e)r.type===`directory`&&(t.push(r.path),r.children&&n(r.children))};return n(e),t}var _u=(0,Z.memo)(function({node:e,depth:t,emptyPlaceholder:n,expanded:r,isActive:i,isSelected:a,isFocused:o,onToggle:s,onSelect:c,onOpen:l,onContextMenu:u}){let{t:d}=V();if(n)return(0,Q.jsx)(`div`,{className:`text-[10px] text-muted-foreground italic py-0.5`,style:{paddingLeft:`${t*14+4}px`},children:d(`activity:fileExplorer.emptyDir`)});if(e.type===`directory`){let n=r?Ge:Zn,i=e.name===`.git`,a=Ia(e.name,!0);return(0,Q.jsxs)(`button`,{type:`button`,role:`treeitem`,"aria-expanded":r,"aria-level":t+1,tabIndex:-1,onClick:()=>s(e.path),onContextMenu:t=>u(t,e),className:G(`flex items-center gap-1 w-full text-left px-1 py-0.5 text-[11px] rounded`,`hover:bg-muted/60 transition-colors`,o&&`ring-1 ring-inset ring-primary/40 bg-muted/40`),style:{paddingLeft:`${t*14+4}px`},children:[(0,Q.jsx)(Kn,{className:G(`h-3 w-3 shrink-0 text-muted-foreground transition-transform`,r&&`rotate-90`)}),i?(0,Q.jsx)(S,{className:G(`h-3.5 w-3.5 shrink-0`,a)}):(0,Q.jsx)(n,{className:G(`h-3.5 w-3.5 shrink-0`,a)}),(0,Q.jsx)(`span`,{className:`truncate font-medium flex-1 min-w-0`,children:e.name})]})}let f=La(e.name),p=Ia(e.name,!1);return(0,Q.jsxs)(`button`,{type:`button`,role:`treeitem`,"aria-level":t+1,"aria-selected":i||a,tabIndex:-1,onClick:()=>c(e.path),onContextMenu:t=>u(t,e),onDoubleClick:t=>{t.preventDefault(),l(e.path)},className:G(`flex items-center gap-1.5 w-full text-left px-1 py-0.5 text-[11px] rounded`,`hover:bg-muted/60 transition-colors`,i&&`bg-primary/10 text-primary`,a&&!i&&`bg-muted/70 ring-1 ring-inset ring-border`,o&&!i&&!a&&`ring-1 ring-inset ring-primary/40 bg-muted/40`),style:{paddingLeft:`${t*14+4}px`},children:[(0,Q.jsx)(`span`,{className:`w-3 shrink-0`}),` `,(0,Q.jsx)(f,{className:G(`h-3.5 w-3.5 shrink-0`,p)}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.name})]})});function vu(){let{t:e}=V(),t=gr(e=>e.tree),n=gr(e=>e.treeLoading),r=gr(e=>e.error),i=gr(e=>e.openFiles),a=gr(e=>e.activeFilePath),o=K(e=>e.cwd),s=K(e=>e.projectName),c=o?.includes(`\\`)?`\\`:`/`,l=(e,t=8,n=4)=>e.length<=t+n+2?e:`${e.slice(0,t)}…${e.slice(-n)}`,u=(()=>{if(!o||!s)return!0;let e=o.replace(/\\/g,`/`).split(`/`).filter(Boolean);return(e[e.length-1]??``)===s})(),d=(0,Z.useMemo)(()=>{if(!o||!s)return[];let e=o.replace(/\\/g,`/`).split(`/`).filter(Boolean),t=-1;for(let n=e.length-1;n>=0;n--)if(e[n]===s){t=n;break}if(t===-1)return e.map((t,n)=>({label:t,path:`/`+e.slice(0,n+1).join(`/`),isLast:n===e.length-1}));let n=e.slice(t);return n.map((r,i)=>({label:r,path:`/`+e.slice(0,t+i+1).join(`/`),isLast:i===n.length-1}))},[o,s]),f=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{let e=f.current;e&&d.length>1&&(e.scrollLeft=e.scrollWidth)},[d]);let p=(0,Z.useCallback)(e=>{pr().send({type:`working_dir.set`,payload:{path:e}})},[]),[m,h]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(null),y=(0,Z.useCallback)((e,t)=>{e.preventDefault(),e.stopPropagation(),v({x:e.clientX,y:e.clientY,node:t})},[]),b=(0,Z.useCallback)(e=>{e.type===`file`&&(_r.getState().addRef({kind:`file`,path:e.path}),J(`chat`)),v(null)},[]);(0,Z.useEffect)(()=>{if(!m&&!_)return;let e=()=>{h(null),v(null)},t=t=>{t.key===`Escape`&&e()};return window.addEventListener(`click`,e),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`click`,e),window.removeEventListener(`keydown`,t)}},[m,_]);let x=(0,Z.useCallback)((e,t)=>{e.preventDefault(),e.stopPropagation(),h({x:e.clientX,y:e.clientY,crumb:t})},[]),S=(0,Z.useCallback)(t=>{si(t).then(t=>{t?Y.success(e(`common:action.copied`)):Y.error(e(`common:action.copyFailed`))}),h(null)},[e]),C=(0,Z.useCallback)(()=>{if(!a)return;let e=a.replace(/\\/g,`/`).split(`/`).slice(0,-1).join(`/`)||`.`;pr().send({type:`working_dir.set`,payload:{path:e}})},[a]),w=(0,Z.useCallback)((e,t)=>{pr().send({type:`shell.open`,payload:{path:e,target:t}}),h(null)},[]),T=(0,Z.useCallback)(()=>{if(!o)return;let e=o.replace(/\\/g,`/`),t=e.split(`/`).slice(0,-1).join(`/`)||e;pr().send({type:`working_dir.set`,payload:{path:t}})},[o]),[E,D]=(0,Z.useState)(!1),O=(0,Z.useRef)(null);(0,Z.useEffect)(()=>(n?O.current=setTimeout(()=>D(!0),150):(O.current&&clearTimeout(O.current),D(!1)),()=>{O.current&&clearTimeout(O.current)}),[n]);let[k,A]=(0,Z.useState)(null),[j,M]=(0,Z.useState)(new Set),N=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{N.current!==(o??``)&&t.length!==0&&(N.current=o??``,M(new Set(t.filter(e=>e.type===`directory`).map(e=>e.path))))},[o,t]);let P=(0,Z.useCallback)(e=>{M(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),ee=(0,Z.useMemo)(()=>gu(t),[t]),te=ee.length,F=(0,Z.useMemo)(()=>hu(t,j),[t,j]),I=(0,Z.useMemo)(()=>{let e=0,n=0;for(let r of t)r.type===`directory`?n++:e++;return{files:e,dirs:n}},[t]),ne=(0,Z.useCallback)(()=>{M(new Set)},[]),re=(0,Z.useCallback)(()=>{M(new Set(ee))},[ee]),L=(0,Z.useCallback)(e=>{if(i.find(t=>t.path===e)){gr.getState().setActiveFile(e);return}A(t=>t===e?null:e)},[i]),ie=(0,Z.useCallback)(e=>{window.dispatchEvent(new CustomEvent(`wrongstack:open-file`,{detail:{filePath:e}})),A(null)},[]);(0,Z.useEffect)(()=>{a&&A(null)},[a]);let ae=(0,Z.useRef)(null),[R,z]=(0,Z.useState)(-1),oe=R>=0&&R<F.length&&!F[R]?.emptyPlaceholder?F[R]?.node.path??null:null,se=(0,Z.useCallback)(e=>{if(F.length===0)return;let t=(e,t)=>{let n=e+t;for(;n>=0&&n<F.length&&F[n]?.emptyPlaceholder;)n+=t;return n<0||n>=F.length?e:n},n=e=>{z(e),ae.current?.scrollToIndex(e,{align:`nearest`})},r=R,i=r>=0&&r<F.length?F[r]:void 0;switch(e.key){case`ArrowDown`:e.preventDefault(),n(t(r,1));break;case`ArrowUp`:e.preventDefault(),n(t(r===-1?F.length:r,-1));break;case`ArrowRight`:if(!i||i.emptyPlaceholder)break;e.preventDefault(),i.node.type===`directory`&&(j.has(i.node.path)?n(t(r,1)):P(i.node.path));break;case`ArrowLeft`:if(!i||i.emptyPlaceholder)break;if(e.preventDefault(),i.node.type===`directory`&&j.has(i.node.path)){P(i.node.path);break}for(let e=r-1;e>=0;e--){let t=F[e];if(t&&!t.emptyPlaceholder&&t.depth<i.depth){n(e);break}}break;case`Enter`:if(!i||i.emptyPlaceholder)break;e.preventDefault(),i.node.type===`directory`?P(i.node.path):ie(i.node.path);break;case` `:if(!i||i.emptyPlaceholder)break;e.preventDefault(),i.node.type===`directory`?P(i.node.path):L(i.node.path);break;case`Home`:e.preventDefault(),n(t(-1,1));break;case`End`:e.preventDefault(),n(t(F.length,-1));break}},[F,R,j,P,ie,L]),ce=(0,Z.useCallback)(()=>{z(e=>e===-1&&F.length>0?0:e)},[F.length]);return E?(0,Q.jsx)(`div`,{className:`flex items-center justify-center h-full py-8`,children:(0,Q.jsx)(g,{className:`h-5 w-5 animate-spin text-muted-foreground`})}):r?(0,Q.jsx)(`div`,{className:`p-3 text-[11px] text-destructive`,children:e(`activity:fileExplorer.loadFailed`,{error:r})}):(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col overflow-hidden`,children:[t.length>0&&te>0&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-0.5 px-2 py-0.5 border-b shrink-0`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:re,className:G(`flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] transition-colors`,`hover:bg-muted/60 text-muted-foreground hover:text-foreground`),title:e(`activity:fileExplorer.expandAllTitle`),children:[(0,Q.jsx)(Hn,{className:`h-3 w-3`}),(0,Q.jsx)(`span`,{children:e(`activity:fileExplorer.expandAll`)})]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:ne,className:G(`flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] transition-colors`,`hover:bg-muted/60 text-muted-foreground hover:text-foreground`),title:e(`activity:fileExplorer.collapseAllTitle`),children:[(0,Q.jsx)(sn,{className:`h-3 w-3`}),(0,Q.jsx)(`span`,{children:e(`activity:fileExplorer.collapse`)})]}),(0,Q.jsx)(`span`,{className:`ml-auto text-[9px] text-muted-foreground/70 tabular-nums`,children:e(`activity:fileExplorer.folders`,{count:te})})]}),(0,Q.jsxs)(`div`,{className:`min-h-0 min-w-0 flex flex-1 flex-col py-1`,children:[d.length>0&&(0,Q.jsxs)(`div`,{ref:f,className:`relative flex shrink-0 items-center gap-0.5 px-1 pb-1 border-b border-border/30 overflow-x-auto`,children:[(0,Q.jsx)(`span`,{className:`sticky left-0 shrink-0 w-3 h-full bg-gradient-to-r from-background to-transparent pointer-events-none`}),d.map((t,n)=>{let r=t.isLast?t.label:l(t.label),i=t.path.replace(/\//g,c),a=o?o.replace(/\\/g,`/`).split(`/`).filter(Boolean):[],u=(()=>{for(let e=a.length-1;e>=0;e--)if(a[e]===s)return e;return-1})(),d=u>=0?a.slice(0,u+n+1):a.slice(0,n+1),f=c===`\\`?d.join(`\\`):`/`+d.join(`/`),m=(u>=0?a.slice(u+1,u+n+1):[]).join(c)||`.`;return(0,Q.jsxs)(`span`,{className:`flex items-center gap-0.5 shrink-0`,children:[n>0&&(0,Q.jsx)(`span`,{className:`text-[9px] text-muted-foreground/65 select-none`,children:c}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>p(t.path),onContextMenu:e=>x(e,{absPath:f,relPath:m}),className:G(`px-1 py-0.5 rounded text-[11px] transition-colors whitespace-nowrap`,t.isLast?`text-foreground font-medium`:`text-muted-foreground hover:text-foreground hover:bg-muted/60`),title:t.isLast?e(`activity:fileExplorer.currentDirTitle`,{path:i}):e(`activity:fileExplorer.navigateToTitle`,{path:i}),children:r})]},t.path)}),t.length>0&&(0,Q.jsxs)(`span`,{className:`ml-auto shrink-0 text-[9px] text-muted-foreground/70 tabular-nums pl-2`,children:[I.files>0&&e(`activity:fileExplorer.filesSuffix`,{count:I.files}),I.files>0&&I.dirs>0&&`, `,I.dirs>0&&e(`activity:fileExplorer.folders`,{count:I.dirs})]})]}),a&&(0,Q.jsxs)(`button`,{type:`button`,onClick:C,className:`flex shrink-0 items-center gap-1 w-full text-left px-2 py-0.5 border-b border-border/30 text-[10px] text-muted-foreground hover:text-foreground hover:bg-accent/50 transition-colors`,title:e(`activity:fileExplorer.navigateParentTitle`,{path:a.replace(/\//g,c)}),children:[(0,Q.jsx)(B,{className:`h-3 w-3 shrink-0`}),(0,Q.jsx)(`span`,{className:`truncate`,children:(()=>{let e=a.replace(/\\/g,`/`).split(`/`);return e[e.length-1]??a})()}),(0,Q.jsx)(`span`,{className:`ml-auto text-[8px] text-muted-foreground/65 shrink-0`,children:e(`activity:fileExplorer.goToDir`)})]}),d.length===0&&!u&&(0,Q.jsxs)(`button`,{type:`button`,onClick:T,className:G(`flex shrink-0 items-center gap-1.5 w-full text-left px-1 py-0.5 text-[11px] rounded`,`hover:bg-muted/60 transition-colors text-muted-foreground hover:text-foreground`,`font-medium`),children:[(0,Q.jsx)(Re,{className:`h-3.5 w-3.5 shrink-0`}),(0,Q.jsx)(`span`,{children:`..`}),(0,Q.jsx)(`span`,{className:`text-[9px] text-muted-foreground/70 ml-auto`,children:e(`activity:fileExplorer.parentDirectory`)})]}),t.length>0?(0,Q.jsx)(`div`,{role:`tree`,"aria-label":e(`activity:fileExplorer.folders`,{count:te}),tabIndex:0,onKeyDown:se,onFocus:ce,className:`min-h-0 min-w-0 flex-1 outline-none`,children:(0,Q.jsx)(Te,{ref:ae,className:`h-full`,children:F.map(e=>(0,Q.jsx)(_u,{node:e.node,depth:e.depth,emptyPlaceholder:e.emptyPlaceholder,expanded:e.node.type===`directory`&&j.has(e.node.path),isActive:e.node.type===`file`&&e.node.path===a,isSelected:!e.emptyPlaceholder&&e.node.path===k,isFocused:!e.emptyPlaceholder&&e.node.path===oe,onToggle:P,onSelect:L,onOpen:ie,onContextMenu:y},e.emptyPlaceholder?`${e.node.path}#empty`:e.node.path))})}):(0,Q.jsx)(`p`,{className:`text-[11px] text-muted-foreground italic p-2`,children:e(`activity:fileExplorer.noFiles`)})]}),m&&(0,Q.jsxs)(`div`,{className:`fixed z-50 min-w-[140px] bg-popover border rounded-md shadow-md py-1 text-[11px]`,style:{left:m.x,top:m.y},children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>S(m.crumb.absPath),className:`flex items-center gap-2 w-full text-left px-3 py-1.5 hover:bg-accent transition-colors`,children:e(`activity:fileExplorer.copyAbsPath`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>S(m.crumb.relPath),className:`flex items-center gap-2 w-full text-left px-3 py-1.5 hover:bg-accent transition-colors`,children:e(`activity:fileExplorer.copyRelPath`)}),(0,Q.jsx)(`div`,{className:`border-t border-border/50 my-0.5`}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>w(m.crumb.absPath,`terminal`),className:`flex items-center gap-2 w-full text-left px-3 py-1.5 hover:bg-accent transition-colors`,children:e(`activity:fileExplorer.openInTerminal`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>w(m.crumb.absPath,`file-manager`),className:`flex items-center gap-2 w-full text-left px-3 py-1.5 hover:bg-accent transition-colors`,children:e(`activity:fileExplorer.openInFileManager`)}),(0,Q.jsx)(`div`,{className:`border-t border-border/50 mt-0.5 pt-0.5`,children:(0,Q.jsx)(`div`,{className:`px-3 py-1 text-[9px] text-muted-foreground/70 truncate max-w-[200px]`,children:m.crumb.absPath})})]}),_&&(0,Q.jsxs)(`div`,{className:`fixed z-50 min-w-[160px] bg-popover border rounded-md shadow-md py-1 text-[11px]`,style:{left:_.x,top:_.y},children:[_.node.type===`file`&&(0,Q.jsx)(`button`,{type:`button`,onClick:()=>b(_.node),className:`flex items-center gap-2 w-full text-left px-3 py-1.5 hover:bg-accent transition-colors`,children:e(`activity:fileExplorer.mentionInChat`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{si(_.node.path).then(t=>{t?Y.success(e(`common:action.copied`)):Y.error(e(`common:action.copyFailed`))}),v(null)},className:`flex items-center gap-2 w-full text-left px-3 py-1.5 hover:bg-accent transition-colors`,children:e(`activity:fileExplorer.copyPath`)}),(0,Q.jsx)(`div`,{className:`border-t border-border/50 mt-0.5 pt-0.5`,children:(0,Q.jsx)(`div`,{className:`px-3 py-1 text-[9px] text-muted-foreground/70 truncate max-w-[200px]`,children:_.node.path})})]})]})}var yu={note:je,ask:Vt,assign:_e,steer:ze,btw:se,broadcast:_e,status:At,result:Gt};function bu(e){let t=new Date(e),n=Date.now()-t.getTime();return n<6e4?H.t(`activity:mailbox.timeNow`):n<36e5?`${Math.round(n/6e4)}m`:n<864e5?`${Math.round(n/36e5)}h`:t.toLocaleDateString()}function xu({className:e}){let t=zr(e=>e.messages),n=zr(e=>e.agents),r=zr(e=>e.lastCompaction),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1),[u,f]=(0,Z.useState)(!1),{client:p}=dr(),{t:m}=V(),[h,g]=(0,Z.useState)(p.status.state===`open`);(0,Z.useEffect)(()=>{let e=p.onStatus(e=>g(e.state===`open`));return()=>e()},[p]),(0,Z.useEffect)(()=>{h&&(p.send({type:`mailbox.messages`,payload:{limit:30}}),p.send({type:`mailbox.agents`,payload:{}}))},[h,p]);let _=U(e=>e.selectedMailMessage),v=U(e=>e.setSelectedMailMessage);function y(e){if(_?.id===e.id){v(null),J(`chat`);return}v(e),J(`mailbox`)}let b=t.filter(e=>!e.completed).length,x=n.filter(e=>e.online).length,S=ho(t,8),w=ho(n.filter(e=>e.online),5);async function T(){t.length!==0&&await mi({title:m(`activity:mailbox.deleteAllConfirmTitle`,{count:t.length}),message:m(`activity:mailbox.deleteAllConfirmBody`),confirmLabel:m(`activity:mailbox.deleteAll`),danger:!0})&&(s(!0),p.send({type:`mailbox.clear`}))}(0,Z.useEffect)(()=>{o&&t.length===0&&s(!1)},[o,t.length]);async function E(){await mi({title:m(`activity:mailbox.purgeConfirmTitle`),message:m(`activity:mailbox.purgeConfirmBody`),confirmLabel:m(`activity:mailbox.purge`),danger:!1})&&(l(!0),p.send({type:`mailbox.purge`}))}(0,Z.useEffect)(()=>{if(c){let e=setTimeout(()=>l(!1),3e3);return()=>clearTimeout(e)}},[c]);async function D(){f(!0),p.send({type:`mailbox.compact`})}return(0,Z.useEffect)(()=>{if(u){let e=setTimeout(()=>f(!1),3e3);return()=>clearTimeout(e)}},[u]),(0,Q.jsxs)(`div`,{className:G(`rounded-lg border border-border bg-card/60 backdrop-blur-sm`,e),children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`flex w-full items-center gap-2 px-3 py-2.5 text-left hover:bg-accent/40 rounded-t-lg transition-colors`,children:[(0,Q.jsx)(P,{className:`h-4 w-4 text-primary`}),(0,Q.jsx)(`span`,{className:`text-xs font-semibold text-foreground flex-1 min-w-0 truncate`,children:m(`activity:nav.mailbox`)}),b>0&&(0,Q.jsx)(`span`,{className:`inline-flex items-center px-1.5 py-0.5 rounded-full text-[10px] font-bold bg-warning/10 text-warning`,children:b}),(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:m(`activity:mailbox.onlineCount`,{count:x})})]}),!i&&(0,Q.jsxs)(`div`,{className:`px-3 pb-3 space-y-2`,children:[t.length>0?(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wide`,children:m(`activity:mailbox.messages`)}),(0,Q.jsxs)(`button`,{type:`button`,onClick:T,disabled:o,className:`flex items-center gap-1 text-[10px] text-muted-foreground hover:text-destructive disabled:opacity-40 transition-colors`,title:m(`activity:mailbox.deleteAllTitle`),children:[(0,Q.jsx)(C,{className:`h-3 w-3`}),m(o?`activity:mailbox.deleting`:`activity:mailbox.deleteAll`)]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:E,disabled:c,className:`flex items-center gap-1 text-[10px] text-muted-foreground hover:text-primary disabled:opacity-40 transition-colors`,title:m(`activity:mailbox.purgeTitle`),children:[(0,Q.jsx)(ee,{className:`h-3 w-3`}),m(c?`activity:mailbox.purging`:`activity:mailbox.purge`)]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:D,disabled:u,className:`flex items-center gap-1 text-[10px] text-muted-foreground hover:text-primary disabled:opacity-40 transition-colors`,title:m(`activity:mailbox.compactTitle`),children:[(0,Q.jsx)(Tt,{className:`h-3 w-3`}),m(u?`activity:mailbox.compacting`:`activity:mailbox.compact`)]})]}),r&&r.totalRemoved>0&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 py-1 rounded text-[10px] bg-primary/5 text-primary/70 border border-primary/10`,children:[(0,Q.jsx)(Tt,{className:`h-3 w-3 shrink-0`}),(0,Q.jsxs)(`span`,{children:[m(`activity:mailbox.compactRemoved`,{count:r.totalRemoved}),r.expiredRemoved>0&&` (${m(`activity:mailbox.compactExpired`,{count:r.expiredRemoved})})`,r.readByAllRemoved>0&&` (${m(`activity:mailbox.compactReadByAll`,{count:r.readByAllRemoved})})`,r.stalePurged>0&&` (${m(`activity:mailbox.compactStale`,{count:r.stalePurged})})`,` — `,m(`activity:mailbox.compactRemaining`,{count:r.remaining})]})]}),S.pageItems.map(e=>{let t=yu[e.type]??d,n=e.readByCount>0,r=_?.id===e.id,i=e.scope?{scope:e.scope,recipientSessionId:e.recipientSessionId}:Br(e.to);return(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>y(e),className:G(`flex items-start gap-2 px-2 py-1.5 rounded text-xs w-full text-left cursor-pointer transition-colors hover:bg-accent/60`,!n&&`bg-warning/8`,r&&`ring-1 ring-primary bg-primary/5`),children:[(0,Q.jsx)(t,{className:G(`h-3.5 w-3.5 mt-0.5 shrink-0`,n?`text-muted-foreground`:`text-warning`)}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(`span`,{className:G(`font-medium truncate`,!n&&`text-warning`),children:e.from}),e.completed&&(0,Q.jsx)(Gt,{className:`h-3 w-3 text-success shrink-0`}),!n&&(0,Q.jsx)(`span`,{className:`text-[9px] text-warning font-bold`,children:m(`activity:mailbox.newLabel`)}),i.scope===`session`&&(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 px-1 py-0 rounded text-[9px] font-semibold bg-warning/12 text-warning`,title:m(`activity:mailbox.sessionScopeTitle`,{sid:i.recipientSessionId??``}),children:[(0,Q.jsx)($n,{className:`h-2.5 w-2.5`}),m(`activity:mailbox.sessionLabel`)]}),i.scope===`project`&&(0,Q.jsx)(`span`,{className:`inline-flex items-center px-1 py-0 rounded text-[9px] font-semibold bg-primary/12 text-primary`,children:m(`activity:mailbox.projectLabel`)})]}),(0,Q.jsx)(`div`,{className:`text-muted-foreground truncate`,children:e.subject}),(0,Q.jsxs)(`div`,{className:`text-[10px] text-muted-foreground/70 truncate`,children:[e.body.slice(0,60),e.body.length>60?`…`:``]})]}),(0,Q.jsxs)(`div`,{className:`shrink-0 text-[10px] text-muted-foreground flex flex-col items-end gap-0.5`,children:[(0,Q.jsx)(`span`,{children:bu(e.timestamp)}),n&&(0,Q.jsxs)(`span`,{className:`flex items-center gap-0.5`,children:[(0,Q.jsx)(xt,{className:`h-3 w-3`}),e.readByCount]})]})]},e.id)}),(0,Q.jsx)(ni,{page:S.page,pageSize:S.pageSize,totalItems:S.totalItems,onPageChange:S.setPage,compact:!0,itemLabel:`messages`})]}):(0,Q.jsxs)(`div`,{className:`text-xs text-muted-foreground py-2 text-center`,children:[(0,Q.jsx)(ce,{className:`h-4 w-4 mx-auto mb-1 opacity-40`}),m(`activity:mailbox.empty`)]}),n.length>0&&(0,Q.jsxs)(`div`,{className:`border-t border-border pt-2`,children:[(0,Q.jsxs)(`div`,{className:`text-[10px] font-semibold text-muted-foreground mb-1 flex items-center gap-1`,children:[(0,Q.jsx)(xn,{className:`h-3 w-3`}),` `,m(`activity:nav.agents`)]}),w.pageItems.map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] text-muted-foreground py-0.5`,children:[(0,Q.jsx)(`span`,{className:G(`h-1.5 w-1.5 rounded-full`,e.online?`bg-success`:`bg-muted-foreground/30`)}),(0,Q.jsx)(`span`,{className:`font-medium text-foreground/80`,children:e.name}),e.role&&(0,Q.jsxs)(`span`,{className:`opacity-60`,children:[`(`,e.role,`)`]}),(0,Q.jsx)(`span`,{className:`opacity-50`,children:e.status}),e.currentTool&&(0,Q.jsx)(`span`,{className:`text-primary`,children:e.currentTool}),(0,Q.jsx)(`span`,{className:`ml-auto opacity-50`,children:bu(e.lastSeenAt)})]},e.agentId)),(0,Q.jsx)(ni,{page:w.page,pageSize:w.pageSize,totalItems:w.totalItems,onPageChange:w.setPage,compact:!0,itemLabel:`online agents`}),n.filter(e=>!e.online).length>0&&(0,Q.jsx)(`div`,{className:`text-[10px] text-muted-foreground/70 mt-0.5`,children:m(`activity:mailbox.offlineCount`,{count:n.filter(e=>!e.online).length})})]})]})]})}var Su={M:{label:`M`,cls:`text-warning`},A:{label:`A`,cls:`text-success`},D:{label:`D`,cls:`text-destructive`},R:{label:`R`,cls:`text-info`},C:{label:`C`,cls:`text-info`},U:{label:`U`,cls:`text-warning`},"?":{label:`U`,cls:`text-muted-foreground`}};function Cu(e){let t=e.lastIndexOf(`/`);return t<0?{name:e,dir:``}:{name:e.slice(t+1),dir:e.slice(0,t+1)}}function wu({file:e,active:t,onSelect:n}){let r=Su[e.status]??Su.M,{name:i,dir:a}=Cu(e.path);return(0,Q.jsxs)(`button`,{type:`button`,onClick:n,title:e.path,className:G(`group flex items-center gap-2 w-full px-2 py-1 text-left text-xs rounded hover:bg-accent/60`,t&&`bg-accent`),children:[(0,Q.jsx)(`span`,{className:G(`w-3 shrink-0 text-center font-mono font-bold`,r?.cls),children:r?.label}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-baseline gap-1 overflow-hidden`,children:[(0,Q.jsx)(`span`,{className:G(`min-w-0 truncate`,e.status===`D`&&`line-through opacity-70`),children:i}),a&&(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-muted-foreground/75`,children:a})]}),(0,Q.jsxs)(`span`,{className:`shrink-0 font-mono text-[10px] tabular-nums`,children:[e.added>0&&(0,Q.jsxs)(`span`,{className:`text-success`,children:[`+`,e.added]}),e.deleted>0&&(0,Q.jsxs)(`span`,{className:`text-destructive ml-1`,children:[`-`,e.deleted]})]})]})}function Tu(){let{client:e}=dr(),{t}=V(),n=q(e=>e.wsConnected),r=Er(e=>e.files),i=Er(e=>e.error),a=Er(e=>e.loadingList),o=Er(e=>e.selectedPath),s=(0,Z.useCallback)(()=>{n&&(Er.getState().setListLoading(!0),e?.getGitChanges?.())},[e,n]);(0,Z.useEffect)(()=>{s()},[s]);let c=t=>{Er.getState().select(t),e?.getGitDiff?.(t),J(`changes`)},l=r.reduce((e,t)=>e+t.added,0),u=r.reduce((e,t)=>e+t.deleted,0);return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col overflow-hidden`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b shrink-0`,children:[(0,Q.jsxs)(`span`,{className:`text-[11px] text-muted-foreground font-mono`,children:[t(`activity:changes.fileCount`,{count:r.length}),r.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[` · `,(0,Q.jsxs)(`span`,{className:`text-success`,children:[`+`,l]}),` `,(0,Q.jsxs)(`span`,{className:`text-destructive`,children:[`-`,u]})]})]}),(0,Q.jsx)(`button`,{type:`button`,onClick:s,title:t(`activity:changes.refreshTitle`),className:`h-6 w-6 inline-flex items-center justify-center rounded hover:bg-accent text-muted-foreground`,children:a?(0,Q.jsx)(g,{className:`h-3.5 w-3.5 animate-spin`}):(0,Q.jsx)(Dn,{className:`h-3.5 w-3.5`})})]}),(0,Q.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain p-1.5`,children:i?(0,Q.jsx)(`div`,{className:`px-2 py-6 text-center text-xs text-muted-foreground`,children:i}):r.length===0?(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-2 py-10 text-center text-xs text-muted-foreground`,children:[(0,Q.jsx)(Ut,{className:`h-6 w-6 opacity-40`}),t(a?`activity:changes.loading`:`activity:changes.clean`)]}):(0,Q.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:r.map(e=>(0,Q.jsx)(wu,{file:e,active:e.path===o,onSelect:()=>c(e.path)},e.path))})})]})}var Eu=10,Du=20,Ou=e=>{if(!e)return 0;let t=Date.parse(e);return Number.isNaN(t)?0:t},ku=e=>(e.iterationCount??0)+(e.toolCallCount??0)+(e.fileChangeCount??0),Au=e=>{let t=Date.parse(e);if(Number.isNaN(t))return``;let n=Math.max(0,Date.now()-t);if(n<6e4)return H.t(`common:time.justNow`);if(n<36e5)return H.t(`common:time.minutesAgo`,{count:Math.floor(n/6e4)});if(n<864e5)return H.t(`common:time.hoursAgo`,{count:Math.floor(n/36e5)});let r=Math.floor(n/864e5);return r<7?H.t(`common:time.daysAgo`,{count:r}):new Date(t).toLocaleDateString()};function ju(e){let t=Ou(e.startedAt);if(!t)return``;let n=e.isCurrent?Date.now():Ou(e.endedAt)||t,r=Math.max(0,Math.floor((n-t)/6e4));if(r<1)return`<1m`;if(r<60)return`${r}m`;let i=Math.floor(r/60);return i<24?`${i}h ${r%60}m`:`${Math.floor(i/24)}d ${i%24}h`}function Mu(e){return new Intl.NumberFormat(void 0,{notation:e>=1e3?`compact`:`standard`,maximumFractionDigits:1}).format(e)}function Nu(e){return e.filter(e=>e.tokenTotal===0&&!e.isCurrent).map(e=>e.id)}function Pu(e,t){let n=t.query.trim().toLocaleLowerCase(),r=new Set(t.favoriteIds);return[...e.filter(e=>{if(!(!n||[e.name,e.title,e.model,e.provider,e.id,...Object.keys(e.toolBreakdown??{})].some(e=>e?.toLocaleLowerCase().includes(n))))return!1;switch(t.filter){case`favorites`:return r.has(e.id);case`active`:return e.isCurrent;case`completed`:return!e.isCurrent&&(e.outcome===`completed`||e.outcome===void 0&&!!e.endedAt);case`issues`:return e.outcome===`error`||e.outcome===`timeout`||e.outcome===`aborted`||(e.toolErrorCount??0)>0;default:return!0}})].sort((e,n)=>{if(t.sort===`tokens`&&n.tokenTotal!==e.tokenTotal)return n.tokenTotal-e.tokenTotal;if(t.sort===`activity`){let t=ku(n)-ku(e);if(t!==0)return t}return Ou(n.startedAt)-Ou(e.startedAt)})}function Fu(e,t,n=Date.now()){let r=new Date(n);r.setHours(0,0,0,0);let i=r.getTime(),a=i-864e5,o=i-6*864e5,s=new Set(t),c=e.filter(e=>s.has(e.id)),l={today:[],yesterday:[],thisWeek:[],earlier:[]};for(let t of e){if(s.has(t.id))continue;let e=Ou(t.startedAt);e>=i?l.today.push(t):e>=a?l.yesterday.push(t):e>=o?l.thisWeek.push(t):l.earlier.push(t)}let u=[];c.length>0&&u.push({label:`favorites`,rows:c,favorite:!0});for(let e of[`today`,`yesterday`,`thisWeek`,`earlier`])l[e].length>0&&u.push({label:e,rows:l[e]});return u}function Iu(e){return e.reduce((e,t)=>({sessions:e.sessions+1,active:e.active+ +!!t.isCurrent,tokens:e.tokens+t.tokenTotal,tools:e.tools+(t.toolCallCount??0),files:e.files+(t.fileChangeCount??0),errors:e.errors+(t.toolErrorCount??0)+ +(t.outcome===`error`)}),{sessions:0,active:0,tokens:0,tools:0,files:0,errors:0})}function Lu(e){if(e.isCurrent)return{icon:_t,label:`active`,defaultLabel:`Active`,className:`text-primary`};switch(e.outcome){case`completed`:return{icon:Gt,label:`completed`,defaultLabel:`Completed`,className:`text-success`};case`error`:return{icon:kt,label:`error`,defaultLabel:`Error`,className:`text-destructive`};case`timeout`:return{icon:Ct,label:`timeout`,defaultLabel:`Timed out`,className:`text-warning`};case`aborted`:return{icon:Pt,label:`aborted`,defaultLabel:`Aborted`,className:`text-muted-foreground`};default:return e.endedAt?{icon:Gt,label:`completed`,defaultLabel:`Completed`,className:`text-success`}:{icon:_n,label:`saved`,defaultLabel:`Saved session`,className:`text-muted-foreground`}}}function Ru({stats:e}){let{t}=V();return(0,Q.jsx)(`div`,{className:`grid grid-cols-2 border-b border-border/75 bg-card md:grid-cols-5`,children:[{label:t(`activity:sessions.stats.sessions`,{defaultValue:`Sessions`}),value:e.sessions,icon:_n},{label:t(`activity:sessions.stats.tokens`,{defaultValue:`Tokens`}),value:e.tokens,icon:_t},{label:t(`activity:sessions.stats.tools`,{defaultValue:`Tool calls`}),value:e.tools,icon:Mn},{label:t(`activity:sessions.stats.files`,{defaultValue:`Files changed`}),value:e.files,icon:Ue},{label:t(`activity:sessions.stats.errors`,{defaultValue:`Errors`}),value:e.errors,icon:kt}].map(e=>{let t=e.icon;return(0,Q.jsxs)(`div`,{className:`border-b border-r border-border/75 px-4 py-3 md:border-b-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-[0.12em] text-muted-foreground`,children:[(0,Q.jsx)(t,{className:`h-3 w-3`}),e.label]}),(0,Q.jsx)(`div`,{className:`mt-1 font-mono text-xl font-semibold tabular-nums`,children:Mu(e.value)})]},e.label)})})}function zu({historyQuery:e,setHistoryQuery:t,historyEntries:n,historyLoading:r,historyError:i,wsConnected:a,listSessions:o,resumeSession:s,deleteSession:c,renameSession:l,variant:u=`sidebar`}){let{t:d}=V(),f=U(e=>e.favoriteSessionIds),p=U(e=>e.toggleFavoriteSession),m=U(e=>e.sessionNicknames),h=U(e=>e.setSessionNickname),[_,v]=(0,Z.useState)(`all`),[y,b]=(0,Z.useState)(`recent`),[x,S]=(0,Z.useState)(null),[w,T]=(0,Z.useState)(``),[E,D]=(0,Z.useState)(null),[O,k]=(0,Z.useState)(1),A=(0,Z.useRef)(null),j=(0,Z.useRef)(null),M=u===`workspace`,N=(0,Z.useCallback)(e=>e.name||m[e.id]||e.title||d(`activity:sessions.empty`),[m,d]),P=(0,Z.useCallback)(e=>{S(e.id),T(e.name??m[e.id]??e.title??``)},[m]),ee=(0,Z.useCallback)(e=>{S(null),h(e,w),l(e,w)},[w,l,h]);(0,Z.useEffect)(()=>{E&&n.some(e=>e.id===E&&e.isCurrent)&&(D(null),A.current&&clearTimeout(A.current))},[n,E]),(0,Z.useEffect)(()=>{x&&(j.current?.focus(),j.current?.select())},[x]),(0,Z.useEffect)(()=>()=>{A.current&&clearTimeout(A.current)},[]);let te=(0,Z.useCallback)(e=>{D(e),s(e),A.current&&clearTimeout(A.current),A.current=setTimeout(()=>D(null),1e4)},[s]),F=(0,Z.useMemo)(()=>Nu(n),[n]),I=(0,Z.useMemo)(()=>Pu(n,{query:e,filter:_,sort:y,favoriteIds:f}),[f,_,n,e,y]),ne=M?Du:Eu,re=(0,Z.useMemo)(()=>I.slice((O-1)*ne,O*ne),[O,ne,I]),L=(0,Z.useMemo)(()=>Fu(re,f),[f,re]),ie=(0,Z.useMemo)(()=>Iu(n),[n]);(0,Z.useEffect)(()=>{k(1)},[_,e,y]),(0,Z.useEffect)(()=>{let e=Math.max(1,Math.ceil(I.length/ne));O>e&&k(e)},[O,ne,I.length]);let ae=(0,Z.useCallback)(async()=>{if(F.length!==0&&await mi({title:d(`activity:sessions.deleteEmptyTitle`,{count:F.length}),message:d(`activity:sessions.deleteEmptyConfirmBody`),confirmLabel:d(`common:action.delete`),danger:!0}))for(let e of F)c(e)},[c,F,d]),R=[{id:`all`,label:d(`activity:sessions.filters.all`,{defaultValue:`All`})},{id:`favorites`,label:d(`activity:sessions.filters.favorites`,{defaultValue:`Pinned`})},{id:`active`,label:d(`activity:sessions.filters.active`,{defaultValue:`Active`})},{id:`completed`,label:d(`activity:sessions.filters.completed`,{defaultValue:`Completed`})},{id:`issues`,label:d(`activity:sessions.filters.issues`,{defaultValue:`Issues`})}];return(0,Q.jsxs)(`div`,{className:G(`flex min-h-0 min-w-0 flex-1 flex-col bg-background`,M&&`h-full`),"data-history-variant":u,children:[M?(0,Q.jsx)(Ru,{stats:ie}):null,(0,Q.jsxs)(`div`,{className:G(`border-b border-border/75 bg-card`,M?`px-4 py-3`:`px-3 py-2`),children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:d(`activity:sessions.recentSessions`)}),M?(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:d(`activity:sessions.workspaceHint`,{defaultValue:`Search, inspect, pin and resume every project conversation.`})}):null]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center border border-border/75`,children:[F.length>0?(0,Q.jsxs)(`button`,{type:`button`,className:`inline-flex h-8 items-center justify-center gap-1 border-r border-border/75 px-2 text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive disabled:opacity-40`,onClick:ae,disabled:!a,title:d(`activity:sessions.deleteEmptyTitle`,{count:F.length}),children:[(0,Q.jsx)(C,{className:`h-3.5 w-3.5`}),M?(0,Q.jsx)(`span`,{className:`text-[10px]`,children:F.length}):null]}):null,(0,Q.jsx)(`button`,{type:`button`,className:`inline-flex h-8 w-8 items-center justify-center text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-40`,onClick:()=>o(200),disabled:!a,title:d(`common:action.refresh`),children:r?(0,Q.jsx)(g,{className:`h-3.5 w-3.5 animate-spin`}):(0,Q.jsx)(Dn,{className:`h-3.5 w-3.5`})})]})]}),(0,Q.jsxs)(`div`,{className:G(`grid gap-2`,M?`mt-3 lg:grid-cols-[minmax(18rem,1fr)_auto_auto]`:`mt-2`),children:[(0,Q.jsxs)(`div`,{className:`relative min-w-0`,children:[(0,Q.jsx)(Tn,{className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,Q.jsx)(`input`,{type:`search`,value:e,onChange:e=>t(e.target.value),placeholder:d(`activity:sessions.filterPlaceholder`),"aria-label":d(`activity:sessions.filterPlaceholder`),className:`h-9 w-full border border-border/75 bg-background pl-8 pr-8 text-xs outline-none transition-colors placeholder:text-muted-foreground/70 focus:border-primary focus:ring-1 focus:ring-primary`}),e?(0,Q.jsx)(`button`,{type:`button`,onClick:()=>t(``),className:`absolute right-0 top-0 inline-flex h-9 w-8 items-center justify-center text-muted-foreground hover:text-foreground`,title:d(`activity:sessions.clearFilter`),children:(0,Q.jsx)(vn,{className:`h-3.5 w-3.5`})}):null]}),(0,Q.jsxs)(`fieldset`,{className:`flex min-w-0 overflow-x-auto border border-border/75`,children:[(0,Q.jsx)(`legend`,{className:`sr-only`,children:`History filters`}),R.map(e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>v(e.id),"aria-pressed":_===e.id,className:G(`h-9 shrink-0 border-r border-border/75 px-2.5 text-[10px] font-semibold uppercase tracking-[0.08em] transition-colors last:border-r-0`,_===e.id?`bg-foreground text-background`:`bg-background text-muted-foreground hover:bg-muted hover:text-foreground`),children:e.label},e.id))]}),(0,Q.jsxs)(`select`,{value:y,onChange:e=>b(e.target.value),"aria-label":d(`activity:sessions.sort.label`,{defaultValue:`Sort sessions`}),className:`h-9 border border-border/75 bg-background px-2 text-[10px] font-semibold uppercase tracking-[0.08em] text-muted-foreground outline-none focus:border-primary`,children:[(0,Q.jsx)(`option`,{value:`recent`,children:d(`activity:sessions.sort.recent`,{defaultValue:`Recent`})}),(0,Q.jsx)(`option`,{value:`tokens`,children:d(`activity:sessions.sort.tokens`,{defaultValue:`Most tokens`})}),(0,Q.jsx)(`option`,{value:`activity`,children:d(`activity:sessions.sort.activity`,{defaultValue:`Most activity`})})]})]})]}),i?(0,Q.jsx)(`div`,{className:`border-b border-destructive/30 bg-destructive/5 px-4 py-2 text-xs text-destructive`,children:i}):null,(0,Q.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain overflow-x-hidden [scrollbar-gutter:stable]`,children:n.length===0&&!r?(0,Q.jsxs)(`div`,{className:`flex min-h-56 flex-col items-center justify-center px-4 py-10 text-center text-muted-foreground`,children:[(0,Q.jsx)(_n,{className:`h-9 w-9 opacity-25`}),(0,Q.jsx)(`p`,{className:`mt-3 text-sm font-medium text-foreground`,children:d(`activity:sessions.noHistory`)}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs`,children:d(`activity:sessions.noHistoryHint`)})]}):L.length===0?(0,Q.jsxs)(`div`,{className:`flex min-h-56 flex-col items-center justify-center px-4 py-10 text-center text-muted-foreground`,children:[(0,Q.jsx)(Tn,{className:`h-9 w-9 opacity-25`}),(0,Q.jsx)(`p`,{className:`mt-3 text-sm font-medium text-foreground`,children:d(`activity:sessions.noMatches`)}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs`,children:d(`activity:sessions.noMatchesHint`)})]}):(0,Q.jsxs)(`div`,{className:G(M?`mx-auto w-full max-w-7xl p-4 lg:p-6`:`p-2`),children:[(0,Q.jsx)(`div`,{className:G(`space-y-5`,M&&`grid gap-x-5 space-y-0 xl:grid-cols-2`),children:L.map(e=>(0,Q.jsxs)(`section`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:G(`sticky top-0 z-[1] flex items-center gap-1 border-b border-border/75 bg-background/95 px-1 py-2 text-[10px] font-semibold uppercase tracking-[0.14em] backdrop-blur-sm`,e.favorite?`text-warning`:`text-muted-foreground`),children:[e.favorite?(0,Q.jsx)(rn,{className:`h-3 w-3 fill-current`}):null,d(`activity:sessions.group.${e.label}`),(0,Q.jsx)(`span`,{className:`ml-1 font-mono font-normal text-muted-foreground`,children:e.rows.length})]}),(0,Q.jsx)(`div`,{className:`divide-y divide-border/75 border-x border-b border-border/75`,children:e.rows.map(e=>{let t=f.includes(e.id),n=Lu(e),r=n.icon,i=x===e.id,a=E===e.id;return(0,Q.jsxs)(`article`,{className:G(`group grid min-w-0 grid-cols-[minmax(0,1fr)_auto] bg-card transition-colors`,e.isCurrent?`border-l-2 border-l-primary bg-primary/5`:`border-l-2 border-l-transparent hover:bg-muted/45`),"data-session-id":e.id,children:[i?(0,Q.jsxs)(`div`,{className:`min-w-0 px-3 py-3`,children:[(0,Q.jsx)(`label`,{className:`block text-[10px] font-semibold uppercase tracking-[0.1em] text-muted-foreground`,htmlFor:`session-name-${e.id}`,children:d(`activity:sessions.rename`,{defaultValue:`Session name`})}),(0,Q.jsx)(`input`,{ref:j,id:`session-name-${e.id}`,value:w,onChange:e=>T(e.target.value),onBlur:()=>ee(e.id),onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),ee(e.id)):t.key===`Escape`&&(t.preventDefault(),S(null))},placeholder:e.title||d(`activity:sessions.nicknamePlaceholder`),className:`mt-1 h-8 w-full border border-primary bg-background px-2 text-sm outline-none ring-1 ring-primary`})]}):(0,Q.jsx)(`button`,{type:`button`,disabled:e.isCurrent||E!==null,onClick:()=>te(e.id),onDoubleClick:()=>P(e),"aria-current":e.isCurrent?`page`:void 0,className:`min-w-0 px-3 py-3 text-left outline-none focus-visible:bg-muted focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary disabled:cursor-default`,children:(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,Q.jsx)(`span`,{className:G(`mt-0.5 shrink-0`,n.className),title:d(`activity:sessions.status.${n.label}`,{defaultValue:n.defaultLabel}),children:(0,Q.jsx)(r,{className:G(`h-3.5 w-3.5`,e.isCurrent&&`animate-pulse`)})}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`truncate text-sm font-semibold text-foreground`,title:N(e),children:N(e)}),(0,Q.jsxs)(`div`,{className:`mt-0.5 truncate font-mono text-[10px] text-muted-foreground`,children:[e.provider,`/`,e.model]}),(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-2 gap-y-1 font-mono text-[10px] text-muted-foreground`,children:[a?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-sans font-semibold text-primary`,children:[(0,Q.jsx)(g,{className:`h-3 w-3 animate-spin`}),d(`activity:sessions.resuming`)]}):(0,Q.jsx)(`span`,{title:new Date(e.startedAt).toLocaleString(),children:Au(e.startedAt)}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,Q.jsx)(`span`,{children:ju(e)}),e.tokenTotal>0?(0,Q.jsxs)(`span`,{children:[Mu(e.tokenTotal),` tok`]}):null,(e.toolCallCount??0)>0?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Q.jsx)(Mn,{className:`h-3 w-3`}),e.toolCallCount]}):null,(e.fileChangeCount??0)>0?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Q.jsx)(Ue,{className:`h-3 w-3`}),e.fileChangeCount]}):null,(e.toolErrorCount??0)>0?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-destructive`,children:[(0,Q.jsx)(kt,{className:`h-3 w-3`}),e.toolErrorCount]}):null]})]})]})}),(0,Q.jsxs)(`div`,{className:`flex items-start gap-0.5 p-2`,children:[!e.isCurrent&&M&&!i?(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>te(e.id),disabled:E!==null,className:`inline-flex h-7 items-center gap-1 border border-border/75 px-2 text-[10px] font-semibold uppercase tracking-[0.08em] text-muted-foreground hover:border-primary hover:text-primary disabled:opacity-40`,title:d(`activity:sessions.resume`,{defaultValue:`Resume session`}),children:[(0,Q.jsx)(dn,{className:`h-3 w-3`}),d(`activity:sessions.resumeShort`,{defaultValue:`Resume`})]}):null,(0,Q.jsx)(`button`,{type:`button`,onClick:()=>p(e.id),"aria-pressed":t,className:G(`inline-flex h-7 w-7 items-center justify-center transition-colors hover:bg-warning/10 hover:text-warning`,t?`text-warning`:`text-muted-foreground`),title:d(t?`activity:sessions.unfavorite`:`activity:sessions.markFavorite`),children:(0,Q.jsx)(rn,{className:G(`h-3.5 w-3.5`,t&&`fill-current`)})}),i?null:(0,Q.jsx)(`button`,{type:`button`,onClick:()=>P(e),className:`inline-flex h-7 w-7 items-center justify-center text-muted-foreground transition-colors hover:bg-primary/10 hover:text-primary`,title:d(`activity:sessions.renameAction`,{defaultValue:`Rename`}),children:(0,Q.jsx)(Ht,{className:`h-3.5 w-3.5`})}),e.isCurrent?null:(0,Q.jsx)(`button`,{type:`button`,onClick:async()=>{await mi({title:d(`activity:sessions.deleteSessionConfirmTitle`),message:d(`activity:sessions.deleteSessionConfirmBody`,{name:N(e)}),confirmLabel:d(`common:action.delete`),danger:!0})&&c(e.id)},className:`inline-flex h-7 w-7 items-center justify-center text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive`,title:d(`activity:sessions.deleteSessionTitle`),children:(0,Q.jsx)(C,{className:`h-3.5 w-3.5`})})]})]},e.id)})})]},e.label))}),(0,Q.jsx)(ni,{page:O,pageSize:ne,totalItems:I.length,onPageChange:k,compact:!M,itemLabel:`sessions`})]})})]})}function Bu(){let e=q(e=>e.wsConnected),{entries:t,loading:n,error:r}=Cr($t(e=>({entries:e.entries,loading:e.loading,error:e.error}))),{listSessions:i,resumeSession:a,deleteSession:o,renameSession:s}=dr(),c=K(e=>e.session?.id),{t:l}=V(),[u,d]=(0,Z.useState)(``);return(0,Z.useEffect)(()=>{e&&i(200)},[e,c,i]),(0,Q.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,Q.jsx)(zu,{historyQuery:u,setHistoryQuery:d,historyEntries:t,historyLoading:n,historyError:r,wsConnected:e,listSessions:i,resumeSession:a,deleteSession:o,renameSession:s,variant:`sidebar`}),(0,Q.jsx)(`div`,{className:`border-t px-3 py-2 shrink-0`,children:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{let e=U.getState();e.setCurrentView(`sessions`),e.setSidebarOpen(!1)},className:`flex h-8 w-full items-center justify-center gap-1.5 border border-border text-[11px] font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:[(0,Q.jsx)(ft,{className:`h-3 w-3`}),l(`activity:history.openDashboard`)]})})]})}function Vu(e){return e<=0?`$0.000`:e>=.01?`$${e.toFixed(3)}`:`$${e.toFixed(4)}`}function Hu(e){if(e<=0)return`--`;let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m ${t%60}s`:`${Math.floor(n/60)}h ${n%60}m`}function Uu(e){let t=e.split(`/`).pop()??e;return t.length>18?t.slice(0,18):t}function Wu({icon:e,label:t,onClick:n,disabled:r,tone:i,title:a}){return(0,Q.jsxs)(`button`,{type:`button`,onClick:n,disabled:r,title:a??t,className:G(`flex items-center justify-center gap-1.5 h-8 rounded-md border text-[11px] font-medium transition-colors`,`disabled:opacity-40 disabled:cursor-not-allowed`,i===`primary`?`border-primary/40 bg-primary/10 text-primary hover:bg-primary/20`:i===`danger`?`border-destructive/40 bg-destructive/10 text-destructive hover:bg-destructive/20`:`border-border bg-card hover:bg-accent text-foreground/80`),children:[e,t]})}function Gu({label:e,value:t,sub:n}){return(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col rounded-lg border border-border/60 bg-card/65 p-2 shadow-sm`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:e}),(0,Q.jsx)(`span`,{className:`text-sm font-semibold tabular-nums truncate`,children:t}),n&&(0,Q.jsx)(`span`,{className:`text-[9px] text-muted-foreground/70 truncate`,children:n})]})}function Ku({icon:e,label:t,right:n}){return(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[10px] uppercase text-muted-foreground font-semibold`,children:[e,t]}),n]})}function qu({label:e,value:t,onChange:n,title:r}){return(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 py-1`,title:r,children:[(0,Q.jsx)(`span`,{className:`text-xs text-foreground/80`,children:e}),(0,Q.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":t,onClick:n,className:G(`shrink-0 relative inline-flex h-4 w-7 rounded-full border transition-colors`,t?`bg-primary border-primary`:`bg-muted border-input hover:bg-muted/80`),children:(0,Q.jsx)(`span`,{className:G(`absolute top-0.5 left-0.5 h-2.5 w-2.5 rounded-full bg-background shadow transition-transform`,t&&`translate-x-3`)})})]})}function Ju(){let{client:e,updatePrefs:t,switchAutonomy:n}=dr(),{t:r}=V(),a=q(e=>e.wsConnected),o=q(e=>e.wsUrl),s=q(e=>e.provider),c=q(e=>e.model),l=q(e=>e.soundOnComplete),u=K(e=>e.session),d=K(e=>e.totalTokens),f=K(e=>e.cost),p=K(e=>e.iteration),m=K(e=>e.todos),h=K(e=>e.lastInputTokens),g=K(e=>e.maxContext),_=i(e=>e.messages),v=i(e=>e.isLoading),y=xr(e=>e.agents),b=U(e=>e.pinnedIds),x=U(e=>e.unpinAll),S=U(e=>e.setModelSwitcherOpen),C=W(),w=(0,Z.useCallback)((e,n)=>{C.set({[e]:n}),t({[e]:n})},[C,t]),T=U(e=>e.setSideContextBreakdownOpen),E=u?.startedAt??null,[D,O]=(0,Z.useState)(()=>Date.now());(0,Z.useEffect)(()=>{if(!E)return;let e=setInterval(()=>O(Date.now()),1e3);return()=>clearInterval(e)},[E]);let k=(0,Z.useMemo)(()=>Array.from(y.values()).filter(e=>e.status===`running`).length,[y]),A=g>0&&h>0?Math.min(100,Math.round(h/g*100)):0,j=b.map(e=>_.find(t=>t.id===e)).filter(e=>!!e&&e.content.length>0),M=ho(m,12,u?.id),N=ho(j,8,u?.id),P=e=>pr(o)?.send?.(e),ee=(0,Z.useCallback)(async()=>{v&&!await mi({title:r(`activity:sessionPanel.actions.newSessionConfirm`),message:r(`activity:sessionPanel.actions.newSessionConfirmMessage`),confirmLabel:r(`activity:sessionPanel.actions.newSession`),danger:!0})||(e?.newSession?.(),J(`chat`))},[e,v,r]);return(0,Q.jsxs)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain bg-[hsl(var(--surface-2)/0.28)] [scrollbar-gutter:stable]`,children:[(0,Q.jsxs)(`div`,{className:`grid grid-cols-2 gap-1.5 border-b border-border/70 bg-card/55 px-3 py-2.5`,children:[v&&(0,Q.jsx)(Wu,{icon:(0,Q.jsx)(we,{className:`h-3 w-3`}),label:r(`activity:sessionPanel.actions.abort`),tone:`danger`,onClick:()=>P({type:`abort`,payload:{}}),disabled:!a}),(0,Q.jsx)(Wu,{icon:(0,Q.jsx)(jt,{className:`h-3 w-3`}),label:r(`activity:sessionPanel.actions.newSession`),tone:`primary`,onClick:()=>void ee(),disabled:!a,title:r(`activity:sessionPanel.actions.newSessionTitle`)}),(0,Q.jsx)(Wu,{icon:(0,Q.jsx)(wn,{className:`h-3 w-3`}),label:r(`activity:sessionPanel.actions.export`),onClick:()=>oa(),title:r(`activity:sessionPanel.actions.exportTitle`)}),(0,Q.jsx)(Wu,{icon:(0,Q.jsx)(be,{className:`h-3 w-3`}),label:r(`activity:sessionPanel.actions.compact`),onClick:()=>P({type:`context.compact`,payload:{aggressive:!1}}),disabled:!a,title:r(`activity:sessionPanel.actions.compactTitle`)}),(0,Q.jsx)(Wu,{icon:(0,Q.jsx)(ct,{className:`h-3 w-3`}),label:r(`common:action.clear`),onClick:()=>P({type:`context.clear`}),disabled:!a,title:r(`activity:sessionPanel.actions.clearTitle`)})]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>S(!0),className:`w-full border-b border-border/70 bg-card/35 px-4 py-2.5 text-left transition-colors hover:bg-muted/40`,title:r(`activity:sessionPanel.modelTitle`),children:[(0,Q.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-0.5`,children:r(`activity:sessionPanel.model`)}),(0,Q.jsxs)(`div`,{className:`font-mono text-xs truncate`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:s||`—`}),(0,Q.jsx)(`span`,{className:`text-muted-foreground/65 mx-1`,children:`/`}),(0,Q.jsx)(`span`,{className:`font-medium`,children:c||`—`})]})]}),g>0&&(0,Q.jsxs)(`div`,{className:`space-y-1.5 border-b border-border/70 bg-card/35 px-4 py-2.5`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>T(!0),className:`w-full block text-left`,title:r(`activity:sessionPanel.contextTitle`),children:(0,Q.jsx)(Ku,{icon:null,label:r(`activity:sessionPanel.context`),right:(0,Q.jsxs)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums font-mono`,children:[eo(h),`/`,eo(g),` · `,A,`%`]})})}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>T(!0),className:`w-full block`,title:r(`activity:sessionPanel.contextTitle`),children:(0,Q.jsx)(mo,{pct:A,tokens:h,maxTokens:g,showTokens:!0})})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5 border-b border-border/70 px-3 py-2.5`,children:[(0,Q.jsx)(Ku,{icon:(0,Q.jsx)(yt,{className:`h-3 w-3`}),label:r(`activity:sessionPanel.sessionLabel`)}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-2 gap-1.5`,children:[(0,Q.jsx)(Gu,{label:r(`activity:sessionPanel.stats.messages`),value:_.length}),(0,Q.jsx)(Gu,{label:r(`activity:sessionPanel.stats.elapsed`),value:E?Hu(D-E):`--`}),(0,Q.jsx)(Gu,{label:r(`activity:sessionPanel.stats.tokens`),value:eo(d.input+d.output),sub:r(`activity:sessionPanel.stats.tokensSub`,{in:eo(d.input),out:eo(d.output)})}),(0,Q.jsx)(Gu,{label:r(`activity:sessionPanel.stats.cost`),value:Vu(f)}),p&&(0,Q.jsx)(Gu,{label:r(`activity:sessionPanel.stats.iteration`),value:p.index,sub:p.max?r(`activity:sessionPanel.stats.iterationOf`,{max:p.max}):void 0}),y.size>0&&(0,Q.jsx)(Gu,{label:r(`activity:sessionPanel.stats.agents`),value:y.size,sub:k>0?r(`activity:sessionPanel.stats.agentsRunning`,{count:k}):void 0})]})]}),m.length>0&&(()=>{let e=m.filter(e=>e.status===`completed`).length,t=m.filter(e=>e.status===`in_progress`).length,n=Math.round(e/m.length*100),i=e===m.length;return(0,Q.jsxs)(`div`,{className:`space-y-1.5 border-b border-border/70 px-3 py-2.5`,children:[(0,Q.jsx)(Ku,{icon:(0,Q.jsx)(ae,{className:`h-3 w-3`}),label:r(`activity:sessionPanel.plan`),right:(0,Q.jsxs)(`span`,{className:`tabular-nums text-[10px] text-muted-foreground`,children:[e,`/`,m.length]})}),(0,Q.jsx)(`div`,{className:G(`relative h-1.5 w-full overflow-hidden rounded-full bg-muted`,t>0&&`bar-sweep`),title:r(`activity:sessionPanel.planComplete`,{pct:n}),children:(0,Q.jsx)(`div`,{className:G(`h-full rounded-full transition-all duration-500`,i?`bg-success`:`bg-primary`),style:{width:`${Math.max(n,t>0?4:0)}%`}})}),(0,Q.jsx)(`ul`,{className:`space-y-0.5 max-h-56 overflow-y-auto pr-1 -mx-1`,children:M.pageItems.map(e=>{let t=e.status===`completed`?Gt:e.status===`in_progress`?qt:At,n=e.status===`in_progress`,r=e.status===`completed`?`text-success line-through opacity-60`:n?`text-foreground`:`text-muted-foreground`;return(0,Q.jsxs)(`li`,{className:G(`flex items-start gap-2 text-xs leading-snug rounded-md px-1.5 py-1 transition-colors`,n&&`bg-primary/10 ring-1 ring-inset ring-primary/20`,r),children:[(0,Q.jsx)(t,{className:G(`h-3.5 w-3.5 mt-0.5 shrink-0`,n&&`text-primary animate-pulse`)}),(0,Q.jsx)(`span`,{className:`break-words`,children:n&&e.activeForm?e.activeForm:e.content})]},e.id)})}),(0,Q.jsx)(ni,{page:M.page,pageSize:M.pageSize,totalItems:M.totalItems,onPageChange:M.setPage,compact:!0,itemLabel:`todos`})]})})(),j.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-1.5 border-b border-border/70 px-3 py-2.5`,children:[(0,Q.jsx)(Ku,{icon:(0,Q.jsx)(Ft,{className:`h-3 w-3 text-warning`}),label:r(`activity:sessionPanel.pinned`),right:(0,Q.jsx)(`button`,{type:`button`,onClick:x,className:`text-[10px] text-muted-foreground hover:text-destructive`,children:r(`common:action.clear`)})}),(0,Q.jsx)(`ul`,{className:`space-y-1 max-h-48 overflow-y-auto pr-1`,children:N.pageItems.map(e=>{let t=e.content.replace(/\s+/g,` `).slice(0,80);return(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{let t=document.querySelector(`[data-message-id="${e.id}"]`);t&&(t.scrollIntoView({behavior:`smooth`,block:`center`}),t.classList.add(`ring-2`,`ring-warning/60`),setTimeout(()=>{t.classList.remove(`ring-2`,`ring-warning/60`)},1600))},className:`w-full text-left text-xs px-2 py-1.5 rounded bg-muted/40 hover:bg-muted/70 border border-warning/20 leading-snug`,title:e.content.slice(0,400),children:[t,e.content.length>80?`…`:``]})},e.id)})}),(0,Q.jsx)(ni,{page:N.page,pageSize:N.pageSize,totalItems:N.totalItems,onPageChange:N.setPage,compact:!0,itemLabel:`pinned answers`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1 border-b border-border/70 px-3 py-2.5`,children:[(0,Q.jsx)(Ku,{icon:(0,Q.jsx)(ue,{className:`h-3 w-3`}),label:r(`activity:sessionPanel.quickSettings`)}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 py-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs text-foreground/80`,children:r(`activity:sessionPanel.autonomy`)}),(0,Q.jsxs)(`select`,{value:C.autonomy,onChange:e=>{let t=e.target.value;C.set({autonomy:t}),n(t)},className:`shrink-0 h-6 max-w-[150px] rounded-md border bg-background px-1.5 text-[11px]`,children:[(0,Q.jsx)(`option`,{value:`off`,children:r(`activity:sessionPanel.autonomyOptions.off`)}),(0,Q.jsx)(`option`,{value:`suggest`,children:r(`activity:sessionPanel.autonomyOptions.suggest`)}),(0,Q.jsx)(`option`,{value:`auto`,children:r(`activity:sessionPanel.autonomyOptions.auto`)}),(0,Q.jsx)(`option`,{value:`eternal`,children:r(`activity:sessionPanel.autonomyOptions.eternal`)}),(0,Q.jsx)(`option`,{value:`eternal-parallel`,children:r(`activity:sessionPanel.autonomyOptions.eternal-parallel`)})]})]}),(0,Q.jsx)(qu,{label:r(`activity:sessionPanel.yolo`),title:r(`activity:sessionPanel.yoloTitle`),value:C.yolo,onChange:()=>w(`yolo`,!C.yolo)}),(0,Q.jsx)(qu,{label:r(`activity:sessionPanel.refine`),title:r(`activity:sessionPanel.refineTitle`),value:C.enhanceEnabled,onChange:()=>w(`enhanceEnabled`,!C.enhanceEnabled)}),(0,Q.jsx)(qu,{label:r(`activity:sessionPanel.sound`),title:r(`activity:sessionPanel.soundTitle`),value:l,onChange:()=>{let e=!q.getState().soundOnComplete;q.getState().setSoundOnComplete(e),e&&rr()}})]}),(0,Q.jsxs)(`div`,{className:`px-4 py-2.5`,children:[(0,Q.jsxs)(`div`,{className:G(`flex items-center gap-2 text-[11px]`,a?`text-success`:`text-warning`),children:[a?(0,Q.jsx)(Nt,{className:`h-3.5 w-3.5`}):(0,Q.jsx)(pn,{className:`h-3.5 w-3.5`}),(0,Q.jsx)(`span`,{className:`font-medium`,children:r(a?`common:status.connected`:`common:status.disconnected`)}),(0,Q.jsx)(`span`,{className:`text-muted-foreground font-mono truncate ml-auto`,title:o,children:o})]}),u&&(0,Q.jsx)(`div`,{className:`text-[10px] text-muted-foreground font-mono mt-1 truncate`,title:u.id,children:r(`activity:sessionPanel.sessionId`,{id:Uu(u.id)})})]})]})}var Yu=16;function Xu(e,t){switch(t){case`project`:return e(`activity:skillDetail.scopeProject`);case`user`:return e(`activity:skillDetail.scopeGlobal`);case`bundled`:return e(`activity:skillDetail.scopeBundled`);case`foreign`:return e(`activity:skillsList.scopeForeign`)}}function Zu(e){return e===`project`||e===`user`||e===`bundled`?e:`foreign`}function Qu({source:e}){let{t}=V(),n=Zu(e);return(0,Q.jsx)(`span`,{className:G(`inline-flex items-center rounded-md border px-1.5 py-0.5 text-[9px] font-semibold uppercase tracking-wide`,n===`project`&&`border-success/25 bg-success/8 text-success`,n===`user`&&`border-primary/25 bg-primary/10 text-primary`,n===`bundled`&&`border-border/70 bg-muted/60 text-muted-foreground`,n===`foreign`&&`border-warning/28 bg-warning/10 text-warning`),children:Xu(t,n)})}function $u({className:e}){let{t}=V(),{client:n}=dr(),r=U(e=>e.skillsState),i=U(e=>e.setSkillsState),[a,o]=(0,Z.useState)([]),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(`all`),[d,f]=(0,Z.useState)(``),[p,m]=(0,Z.useState)(1),h=(0,Z.useRef)(r);h.current=r;let[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(``),[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(null),[D,O]=(0,Z.useState)(null),[k,A]=(0,Z.useState)(!1),[j,M]=(0,Z.useState)(``),[N,P]=(0,Z.useState)(``),[te,F]=(0,Z.useState)(`project`),[I,ne]=(0,Z.useState)(!1),[re,L]=(0,Z.useState)(null),[ie,ae]=(0,Z.useState)(null),[R,z]=(0,Z.useState)(!1),[oe,se]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{if(!_&&!k)return;let e=e=>{e.key===`Escape`&&(_&&v(!1),k&&A(!1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[_,k]);let ce=(0,Z.useRef)(new Map);(0,Z.useEffect)(()=>{let e=ce.current;return()=>{for(let t of e.values())t();e.clear()}},[]);let le=(0,Z.useCallback)((e,t,r,i=15e3)=>{if(!n)return;ce.current.get(e)?.();let a=null,o=e=>{s(),t(e)},s=()=>{a&&clearTimeout(a),n.off(e,o),ce.current.delete(e)};a=setTimeout(()=>{s(),r()},i),n.on(e,o),ce.current.set(e,s)},[n]),ue=(0,Z.useCallback)(()=>{!n||!y.trim()||(w(!0),E(null),O(null),le(`skills.installed`,e=>{let t=e;if(w(!1),t.payload.success){let e=t.payload.results?.map(e=>e.name).join(`, `)??y;O(H.t(`activity:skillsList.installedMsg`,{names:e})),n.send({type:`skills.list`},{echoToChat:!1})}else E(t.payload.error??H.t(`activity:skillsList.installFailed`))},()=>{w(!1),E(H.t(`activity:skillsList.installFailed`))}),n.installSkill(y.trim(),x))},[n,y,x,le]),de=(0,Z.useCallback)(()=>{!n||!j.trim()||!N.trim()||(ne(!0),L(null),ae(null),le(`skills.created`,e=>{let t=e;ne(!1),t.payload.success?(ae(H.t(`activity:skillsList.createdMsg`,{name:t.payload.skill?.name??``})),n.send({type:`skills.list`},{echoToChat:!1})):L(t.payload.error??H.t(`activity:skillsList.createFailed`))},()=>{ne(!1),L(H.t(`activity:skillsList.createFailed`))}),n.createSkill(j.trim(),N.trim(),te))},[n,j,N,te,le]),fe=(0,Z.useCallback)(()=>{n&&(se(!0),n.checkForUpdates(void 0,void 0))},[n]),pe=(0,Z.useCallback)(()=>{n&&(z(!0),le(`skills.exported`,e=>{let t=e;if(z(!1),t.payload.error){console.error(t.payload.error);return}let n=atob(t.payload.zipBase64),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);let i=new Blob([r],{type:`application/zip`}),a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=`wrongstack-skills-${Date.now()}.zip`,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(a)},()=>z(!1),3e4),n.exportAllSkills())},[n,le]);(0,Z.useEffect)(()=>{if(!n)return;c(!0);let e=e=>{let t=e;if(t.payload.enabled&&t.payload.skills){o(t.payload.skills);let e=h.current,n=e.knownRefs,r=0,a={...n};for(let e of t.payload.skills){if(e.source===`bundled`)continue;let t=e.ref;if(!t)continue;let i=n[e.name];a[e.name]=t,i&&i!==t&&r++}i({...e,knownRefs:a,updateAvailableCount:r})}c(!1)},t=e=>{let t=e;if(se(!1),t.payload.success){let e=h.current,r={...e.knownRefs};for(let e of t.payload.updated??[])r[e.name]=e.newRef;i({...e,knownRefs:r,updateAvailableCount:0}),n.send({type:`skills.list`},{echoToChat:!1})}};return n.on(`skills.list`,e),n.on(`skills.updated`,t),n.send({type:`skills.list`},{echoToChat:!1}),()=>{n.off(`skills.list`,e),n.off(`skills.updated`,t)}},[n,i]);let me=(0,Z.useCallback)(e=>{i({...h.current,selectedSkill:e,navHistory:[e],historyIndex:0,detailOpen:!0}),J(`skills`)},[i]),he=(0,Z.useMemo)(()=>{let e=a;if(l!==`all`&&(e=e.filter(e=>Zu(e.source)===l)),d.trim()){let t=d.toLowerCase();e=e.filter(e=>e.name.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)||e.trigger.toLowerCase().includes(t))}return e},[a,l,d]),ge=(0,Z.useMemo)(()=>he.slice((p-1)*Yu,p*Yu),[he,p]),_e=(0,Z.useMemo)(()=>{let e={project:[],user:[],foreign:[],bundled:[]};for(let t of ge)e[Zu(t.source)].push(t);return e},[ge]);(0,Z.useEffect)(()=>{m(1)},[l,d]),(0,Z.useEffect)(()=>{let e=Math.max(1,Math.ceil(he.length/Yu));p>e&&m(e)},[he.length,p]);let ve=r.selectedSkill?.name;return(0,Q.jsxs)(`div`,{className:G(`flex h-full min-h-0 min-w-0 flex-col overflow-hidden bg-[hsl(var(--surface-2)/0.28)]`,e),children:[(0,Q.jsxs)(`div`,{className:`flex w-full items-center gap-1 border-b border-border/60 bg-card/65 px-2 py-2`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{b(``),E(null),O(null),S(!1),v(!0)},className:`flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,title:t(`activity:skillsList.installTitle`),children:(0,Q.jsx)(jt,{className:`h-4 w-4`})}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{M(``),P(``),F(`project`),L(null),ae(null),A(!0)},className:`flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,title:t(`activity:skillsList.createTitle`),children:(0,Q.jsx)(je,{className:`h-4 w-4`})}),(0,Q.jsx)(`button`,{type:`button`,onClick:pe,disabled:R||a.length===0,className:`flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:opacity-40`,title:t(`activity:skillsList.exportTitle`),children:R?(0,Q.jsx)(g,{className:`h-4 w-4 animate-spin`}):(0,Q.jsx)(wn,{className:`h-4 w-4`})}),(0,Q.jsxs)(`button`,{type:`button`,onClick:fe,disabled:oe,className:`relative flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:opacity-40`,title:t(`activity:skillsList.checkUpdatesTitle`),children:[oe?(0,Q.jsx)(g,{className:`h-4 w-4 animate-spin`}):(0,Q.jsx)(Dn,{className:`h-4 w-4`}),!oe&&r.updateAvailableCount>0&&(0,Q.jsx)(`span`,{className:`absolute top-0.5 right-0.5 h-2.5 w-2.5 rounded-full bg-primary text-[8px] font-bold text-primary-foreground flex items-center justify-center`,children:r.updateAvailableCount>9?`9+`:r.updateAvailableCount})]})]}),(0,Q.jsxs)(`div`,{className:`shrink-0 space-y-2 border-b border-border/60 bg-card/45 p-2`,children:[(0,Q.jsx)(`input`,{type:`text`,value:d,onChange:e=>f(e.target.value),placeholder:t(`activity:skillsList.searchPlaceholder`),className:`w-full rounded-md border border-border/70 bg-background/70 px-2 py-1.5 text-xs shadow-sm focus:outline-none focus:ring-1 focus:ring-ring`}),(0,Q.jsx)(`div`,{className:`flex gap-1 flex-wrap`,children:[`all`,`project`,`user`,`foreign`,`bundled`].map(e=>{let n=e===`all`?he.length:he.filter(t=>Zu(t.source)===e).length;return(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>u(e),className:G(`rounded-md px-1.5 py-0.5 text-[10px] transition-colors`,l===e?`bg-primary text-primary-foreground`:`bg-background/60 text-muted-foreground hover:bg-accent`),children:[e===`all`?t(`common:action.all`):Xu(t,e),(0,Q.jsxs)(`span`,{className:G(`ml-1 font-medium`,l===e?`opacity-90`:`opacity-60`,n===0&&`line-through`),children:[`(`,n,`)`]})]},e)})})]}),(0,Q.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain p-2 [scrollbar-gutter:stable]`,children:s?(0,Q.jsx)(`div`,{className:`rounded-lg border border-border/60 bg-card/55 p-4 text-center text-xs text-muted-foreground`,children:t(`activity:skillsList.loading`)}):he.length===0?(0,Q.jsx)(`div`,{className:`rounded-lg border border-border/60 bg-card/55 p-4 text-center text-xs text-muted-foreground`,children:a.length===0?t(`activity:skillsList.noSkills`):t(`activity:skillsList.noMatch`)}):(0,Q.jsx)(`div`,{className:`space-y-2`,children:[`project`,`user`,`foreign`,`bundled`].map(e=>{let n=_e[e];return n.length===0?null:(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 px-1 py-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[(0,Q.jsx)(Qu,{source:e}),(0,Q.jsx)(`span`,{className:`ml-auto opacity-60`,children:n.length})]}),n.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>me(e),className:G(`w-full rounded-lg border px-2.5 py-2 text-left text-xs transition-colors`,ve===e.name?`border-primary/30 bg-primary/10 text-primary shadow-sm`:`border-border/50 bg-card/55 text-foreground hover:border-border hover:bg-accent/50`),children:[(0,Q.jsxs)(`div`,{className:`font-medium truncate flex items-center gap-1`,children:[(0,Q.jsx)(ee,{className:`h-3 w-3 shrink-0`}),e.name]}),(0,Q.jsx)(`div`,{className:`text-[10px] text-muted-foreground truncate mt-0.5`,children:e.trigger||e.description?.slice(0,50)||t(`activity:skillsList.noDescription`)})]},e.name))]},e)})})}),(0,Q.jsx)(ni,{page:p,pageSize:Yu,totalItems:he.length,onPageChange:m,compact:!0,itemLabel:`skills`}),(0,Q.jsx)($r,{open:_,onOpenChange:v,children:(0,Q.jsxs)(Xr,{className:`flex max-h-[calc(100dvh-2rem)] w-[420px] max-w-[90vw] flex-col gap-0 overflow-hidden p-0`,showCloseButton:!1,children:[(0,Q.jsxs)(Jr,{className:`flex shrink-0 items-center justify-between border-b border-border/70 p-4 sm:flex-row sm:justify-between sm:space-y-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(wn,{className:`h-4 w-4 text-primary`}),(0,Q.jsx)(Zr,{className:`font-semibold text-sm`,children:t(`activity:skillsList.installHeading`)})]}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>v(!1),"aria-label":t(`common:action.close`),className:`rounded p-1 text-muted-foreground hover:bg-accent hover:text-accent-foreground`,children:(0,Q.jsx)(vn,{className:`h-4 w-4`})})]}),(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-4 space-y-3`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`activity:skillsList.installHint`)}),(0,Q.jsx)(`input`,{type:`text`,value:y,onChange:e=>{b(e.target.value),E(null),O(null)},onKeyDown:e=>{e.key===`Enter`&&!C&&ue()},placeholder:t(`activity:skillsList.installPlaceholder`),className:`w-full rounded-md border border-border/70 bg-background/70 px-3 py-2 text-xs shadow-sm focus:outline-none focus:ring-1 focus:ring-ring`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t(`activity:skillsList.installScope`)}),(0,Q.jsxs)(`div`,{className:`flex overflow-hidden rounded-md border border-border/70`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>S(!1),className:G(`px-2 py-1 text-[10px] transition-colors`,x?`bg-background hover:bg-accent`:`bg-primary text-primary-foreground`),children:t(`activity:skillDetail.scopeProject`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>S(!0),className:G(`px-2 py-1 text-[10px] transition-colors border-l border-border`,x?`bg-primary text-primary-foreground`:`bg-background hover:bg-accent`),children:t(`activity:skillDetail.scopeGlobal`)})]})]}),T&&(0,Q.jsx)(`p`,{className:`rounded-md bg-destructive/10 px-2 py-1 text-xs text-destructive`,children:T}),D&&(0,Q.jsx)(`p`,{className:`rounded-md bg-success/10 px-2 py-1 text-xs text-success`,children:D})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-border/70 bg-muted/20 p-4`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>v(!1),className:`rounded-md border border-border/70 px-3 py-1.5 text-xs transition-colors hover:bg-accent`,children:t(D?`common:action.close`:`common:action.cancel`)}),!D&&(0,Q.jsxs)(`button`,{type:`button`,onClick:ue,disabled:C||!y.trim(),className:`flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground transition-colors hover:bg-primary/90 disabled:cursor-not-allowed disabled:opacity-50`,children:[C&&(0,Q.jsx)(g,{className:`h-3 w-3 animate-spin`}),t(`activity:skillsList.installBtn`)]})]})]})}),(0,Q.jsx)($r,{open:k,onOpenChange:A,children:(0,Q.jsxs)(Xr,{className:`flex max-h-[calc(100dvh-2rem)] w-[480px] max-w-[90vw] flex-col gap-0 overflow-hidden p-0`,showCloseButton:!1,children:[(0,Q.jsxs)(Jr,{className:`flex shrink-0 items-center justify-between border-b border-border/70 p-4 sm:flex-row sm:justify-between sm:space-y-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(je,{className:`h-4 w-4 text-primary`}),(0,Q.jsx)(Zr,{className:`font-semibold text-sm`,children:t(`activity:skillsList.createHeading`)})]}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>A(!1),"aria-label":t(`common:action.close`),className:`rounded p-1 text-muted-foreground hover:bg-accent hover:text-accent-foreground`,children:(0,Q.jsx)(vn,{className:`h-4 w-4`})})]}),(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-4 space-y-3`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`activity:skillsList.createHint`)}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`span`,{className:`block text-xs font-medium mb-1`,children:[t(`activity:skillsList.nameLabel`),` `,(0,Q.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,Q.jsx)(`input`,{type:`text`,value:j,onChange:e=>{let t=e.target.value.trim().toLowerCase().replace(/\s+/g,`-`).replace(/[^a-z0-9-]/g,``);M(t),L(null),ae(null)},placeholder:t(`activity:skillsList.namePlaceholder`),className:`w-full rounded-md border border-border/70 bg-background/70 px-3 py-2 font-mono text-xs shadow-sm focus:outline-none focus:ring-1 focus:ring-ring`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`span`,{className:`block text-xs font-medium mb-1`,children:[t(`activity:skillsList.descLabel`),` `,(0,Q.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,Q.jsx)(`textarea`,{value:N,onChange:e=>{P(e.target.value),L(null),ae(null)},onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&!I&&de()},placeholder:t(`activity:skillsList.descPlaceholder`),rows:4,className:`w-full resize-y rounded-md border border-border/70 bg-background/70 px-3 py-2 text-xs shadow-sm focus:outline-none focus:ring-1 focus:ring-ring`})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t(`activity:skillsList.saveIn`)}),(0,Q.jsxs)(`div`,{className:`flex overflow-hidden rounded-md border border-border/70`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>F(`project`),className:G(`px-2 py-1 text-[10px] transition-colors`,te===`project`?`bg-primary text-primary-foreground`:`bg-background hover:bg-accent`),children:t(`activity:skillDetail.scopeProject`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>F(`global`),className:G(`px-2 py-1 text-[10px] transition-colors border-l border-border`,te===`global`?`bg-primary text-primary-foreground`:`bg-background hover:bg-accent`),children:t(`activity:skillDetail.scopeGlobal`)})]})]}),re&&(0,Q.jsx)(`p`,{className:`rounded-md bg-destructive/10 px-2 py-1 text-xs text-destructive`,children:re}),ie&&(0,Q.jsx)(`p`,{className:`rounded-md bg-success/10 px-2 py-1 text-xs text-success`,children:ie})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-border/70 bg-muted/20 p-4`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>A(!1),className:`rounded-md border border-border/70 px-3 py-1.5 text-xs transition-colors hover:bg-accent`,children:t(ie?`common:action.close`:`common:action.cancel`)}),!ie&&(0,Q.jsxs)(`button`,{type:`button`,onClick:de,disabled:I||!j.trim()||!N.trim(),className:`flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground transition-colors hover:bg-primary/90 disabled:cursor-not-allowed disabled:opacity-50`,children:[I&&(0,Q.jsx)(g,{className:`h-3 w-3 animate-spin`}),t(`activity:skillsList.createBtn`)]})]})]})})]})}var ed=[`web`,`react-native`,`flutter`,`swiftui`,`compose`],td=[`bg`,`surface`,`primary`,`accent`,`fg`,`border`];function nd({tokens:e,label:t}){let n=td.filter(t=>e[t]);return n.length===0?null:(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-[9px] uppercase tracking-wide text-muted-foreground w-7`,children:t}),(0,Q.jsx)(`div`,{className:`flex gap-0.5`,children:n.map(t=>(0,Q.jsx)(`div`,{className:`w-4 h-4 rounded-sm border border-black/10 dark:border-white/10`,style:{backgroundColor:e[t]},title:`${t}: ${e[t]}`},t))})]})}function rd({className:e}){let{client:t}=dr(),{t:n}=V(),[r,i]=(0,Z.useState)([]),[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(!0),[l,u]=(0,Z.useState)(`web`),[d,f]=(0,Z.useState)(null);(0,Z.useEffect)(()=>{if(!t)return;let e=e=>{let t=e.payload;i(t?.kits??[]),o(t?.activeKit??null),c(!1)},n=e=>{let t=e.payload;f(null),t?.ok&&t.kit&&o(t.kit)};return t.on(`design.list`,e),t.on(`design.use`,n),t.send({type:`design.list`}),()=>{t.off(`design.list`,e),t.off(`design.use`,n)}},[t]);let p=(0,Z.useCallback)(e=>{t&&(f(e),t.send({type:`design.use`,payload:{kit:e,stack:l}}))},[t,l]),m=(0,Z.useMemo)(()=>[...r].sort((e,t)=>e.name.localeCompare(t.name)),[r]),h=ho(m,10,l);return(0,Q.jsxs)(`div`,{className:G(`flex h-full min-h-0 min-w-0 flex-col`,e),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 border-b border-border/50`,children:[(0,Q.jsx)(Dt,{className:`w-4 h-4 text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground flex-1`,children:n(`activity:designStudio.pickHint`)}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>J(`design`),className:`inline-flex items-center gap-1 text-[11px] px-1.5 py-0.5 rounded border border-border/60 hover:bg-muted`,title:n(`activity:designStudio.galleryTitle`),children:[(0,Q.jsx)(ft,{className:`w-3 h-3`}),` `,n(`activity:designStudio.gallery`)]}),(0,Q.jsx)(`select`,{value:l,onChange:e=>u(e.target.value),className:`text-[11px] bg-transparent border border-border/60 rounded px-1 py-0.5`,title:n(`activity:designStudio.stackTitle`),children:ed.map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e))})]}),(0,Q.jsxs)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain p-2 space-y-2`,children:[s&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground p-3`,children:[(0,Q.jsx)(g,{className:`w-4 h-4 animate-spin`}),` `,n(`activity:designStudio.loading`)]}),!s&&m.length===0&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground p-3`,children:n(`activity:designStudio.notFound`)}),h.pageItems.map(e=>{let t=a===e.id;return(0,Q.jsxs)(`div`,{className:G(`rounded-lg border p-3 transition-colors`,t?`border-primary/60 bg-primary/5`:`border-border/60 hover:border-border`),children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold truncate`,children:e.name}),t&&(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-[9px] font-semibold uppercase text-primary`,children:[(0,Q.jsx)(Wn,{className:`w-3 h-3`}),` `,n(`activity:design.active`)]})]}),(0,Q.jsx)(`p`,{className:`text-[11px] text-muted-foreground leading-snug mt-0.5`,children:e.aesthetic})]}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>p(e.id),disabled:d===e.id,className:G(`shrink-0 text-[11px] px-2 py-1 rounded font-medium`,t?`bg-primary/10 text-primary`:`bg-primary text-primary-foreground hover:opacity-90`),children:d===e.id?`…`:n(t?`activity:design.reapply`:`activity:design.use`)})]}),(0,Q.jsxs)(`div`,{className:`mt-2 space-y-1`,children:[(0,Q.jsx)(nd,{tokens:e.light,label:n(`activity:designStudio.light`)}),(0,Q.jsx)(nd,{tokens:e.dark,label:n(`activity:designStudio.dark`)})]}),e.bestFor&&(0,Q.jsxs)(`p`,{className:`text-[10px] text-muted-foreground mt-2 leading-snug`,children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:n(`activity:designStudio.bestFor`)}),` `,e.bestFor]}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-1.5`,children:e.stacks.map(e=>(0,Q.jsx)(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-muted text-muted-foreground`,children:e},e))})]},e.id)})]}),(0,Q.jsx)(ni,{page:h.page,pageSize:h.pageSize,totalItems:h.totalItems,onPageChange:h.setPage,compact:!0,itemLabel:`design kits`})]})}var id=new Set([`allocating`,`active`,`committing`,`merging`]),ad={active:`text-warning`,committing:`text-primary`,merging:`text-info`,merged:`text-success`,"needs-review":`text-destructive`,failed:`text-destructive`,orphan:`text-muted-foreground`};function od(){let{client:e}=dr(),{t}=V(),n=e=>e?e.replace(/^wstack\/ap\//,``):t(`activity:worktrees.detached`),r=Nr(e=>e.worktrees),i=Nr(e=>e.orphans),a=Nr(e=>e.baseBranch),o=Nr(e=>e.canClean),s=Nr(e=>e.cleanResult),c=Nr(e=>e.mergeResult),l=Nr(e=>e.diffByDir),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(null),m=(0,Z.useMemo)(()=>e?e.send.bind(e):void 0,[e]);(0,Z.useEffect)(()=>{m?.({type:`worktree.scan`})},[m]),(0,Z.useEffect)(()=>{d(null)},[c,s]);let h=(0,Z.useMemo)(()=>{let e=new Set(r.map(e=>e.branch)),t=r.map(e=>({branch:e.branch,dir:e.dir,status:e.status,baseBranch:e.baseBranch,insertions:e.insertions,deletions:e.deletions,files:e.files,owner:e.ownerLabel,live:id.has(e.status)}));for(let n of i)n.branch&&e.has(n.branch)||t.push({branch:n.branch,dir:n.dir,status:`orphan`,insertions:0,deletions:0,files:0,live:!1});return t},[r,i]),_=(e,t)=>{e&&m?.({type:`shell.open`,payload:{path:e,target:t}})},v=e=>{e&&(m?.({type:`worktree.diff`,payload:{dir:e}}),p(t=>t===e?null:e))},y=async e=>{e&&await mi({title:t(`activity:worktrees.mergeConfirmTitle`,{branch:n(e),base:a||t(`activity:worktrees.baseLabel`)}),message:t(`activity:worktrees.mergeConfirmMsg`),confirmLabel:t(`activity:worktrees.mergeAction`)})&&(d(e),m?.({type:`worktree.merge`,payload:{branch:e}}))},b=async e=>{await mi({title:t(`activity:worktrees.removeConfirmTitle`,{branch:n(e.branch)}),message:t(`activity:worktrees.removeConfirmMsg`),confirmLabel:t(`common:action.remove`),danger:!0})&&(d(e.branch??``),m?.({type:`worktree.remove`,payload:{dir:e.dir,branch:e.branch}}))};return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2`,children:[(0,Q.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[t(`activity:worktrees.count`,{count:h.length}),a?t(`activity:worktrees.baseSuffix`,{base:a}):``]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[i.length>0&&(0,Q.jsxs)(`button`,{type:`button`,disabled:!o,onClick:()=>m?.({type:`worktree.cleanup`}),title:t(o?`activity:worktrees.cleanOrphansTitle`:`activity:worktrees.liveBusyTitle`),className:`inline-flex items-center gap-1 rounded bg-warning px-1.5 py-0.5 text-[11px] font-medium text-primary-foreground hover:bg-warning/90 disabled:opacity-50`,children:[(0,Q.jsx)(ct,{className:`h-3 w-3`}),` `,t(`activity:worktrees.cleanOrphans`)]}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>m?.({type:`worktree.scan`}),title:t(`activity:worktrees.rescanTitle`),className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,Q.jsx)(Dn,{className:`h-3.5 w-3.5`})})]})]}),s&&(0,Q.jsx)(cd,{ok:s.ok,children:s.ok?t(`activity:worktrees.removed`,{count:s.removed}):s.reason??t(`activity:worktrees.failed`)}),c&&(0,Q.jsx)(cd,{ok:c.ok,children:c.ok?t(`activity:worktrees.mergedIntoBase`,{branch:n(c.branch)}):c.conflict?t(`activity:worktrees.conflictMerge`,{branch:n(c.branch),files:(c.conflictFiles??[]).join(`, `)||t(`activity:worktrees.seeGit`)}):t(`activity:worktrees.mergeFailed`,{reason:c.reason??t(`activity:worktrees.unknownReason`)})}),(0,Q.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain px-2 pb-3 [scrollbar-gutter:stable]`,children:h.length===0?(0,Q.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 text-center text-xs text-muted-foreground`,children:[(0,Q.jsx)(bn,{className:`h-8 w-8 opacity-30`}),(0,Q.jsx)(`p`,{children:t(`activity:worktrees.empty`)}),(0,Q.jsx)(`p`,{className:`max-w-[200px]`,children:t(`activity:worktrees.emptyHint`)})]}):h.map((e,r)=>{let i=u===(e.branch??``),a=e.dir?l[e.dir]:void 0;return(0,Q.jsxs)(`div`,{className:`mb-1.5 rounded-md border border-border bg-card/60 px-2.5 py-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(bn,{className:G(`h-3.5 w-3.5 shrink-0`,ad[e.status]??`text-muted-foreground`)}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-foreground`,title:e.branch,children:n(e.branch)}),(0,Q.jsx)(`span`,{className:G(`shrink-0 text-[10px] uppercase`,ad[e.status]??`text-muted-foreground`),children:e.status})]}),(0,Q.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-2 pl-5 text-[10px] text-muted-foreground`,children:[e.owner&&(0,Q.jsx)(`span`,{className:`truncate`,children:e.owner}),(e.insertions>0||e.deletions>0)&&(0,Q.jsxs)(`span`,{className:`shrink-0`,children:[(0,Q.jsxs)(`span`,{className:`text-success`,children:[`+`,e.insertions]}),` `,(0,Q.jsxs)(`span`,{className:`text-destructive`,children:[`−`,e.deletions]}),` · `,e.files,`f`]})]}),(0,Q.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-0.5 pl-5`,children:[(0,Q.jsx)(sd,{title:t(`activity:worktrees.actOpenTerm`),disabled:!e.dir,onClick:()=>_(e.dir,`terminal`),children:(0,Q.jsx)(Ze,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(sd,{title:t(`activity:worktrees.actOpenFolder`),disabled:!e.dir,onClick:()=>_(e.dir,`file-manager`),children:(0,Q.jsx)(Ge,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(sd,{title:t(`activity:worktrees.actViewChanges`),disabled:!e.dir,onClick:()=>v(e.dir),children:(0,Q.jsx)(it,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(sd,{title:t(`activity:worktrees.actMerge`),disabled:e.live||!e.branch,onClick:()=>y(e.branch),children:i?(0,Q.jsx)(g,{className:`h-3.5 w-3.5 animate-spin`}):(0,Q.jsx)(It,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(sd,{title:t(`activity:worktrees.actRemove`),danger:!0,disabled:e.live,onClick:()=>b(e),children:(0,Q.jsx)(C,{className:`h-3.5 w-3.5`})}),e.live&&(0,Q.jsx)(`span`,{className:`ml-1 text-[10px] text-warning`,children:t(`activity:worktrees.live`)})]}),f===e.dir&&a!==void 0&&(0,Q.jsx)(`div`,{className:`mt-1.5 ml-5 rounded bg-muted/50 p-1.5 text-[10px]`,children:a===null||a.files.length===0?(0,Q.jsxs)(`span`,{className:`text-muted-foreground`,children:[t(`activity:worktrees.noUncommitted`),a&&a.commits>0?` · ${t(`activity:worktrees.commitsAhead`,{count:a.commits})}`:``,`.`]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`mb-1 text-muted-foreground`,children:[a.commits>0?`${t(`activity:worktrees.commitsAhead`,{count:a.commits})} · `:``,(0,Q.jsxs)(`span`,{className:`text-success`,children:[`+`,a.insertions]}),` `,(0,Q.jsxs)(`span`,{className:`text-destructive`,children:[`−`,a.deletions]})]}),a.files.slice(0,12).map(e=>(0,Q.jsxs)(`div`,{className:`truncate font-mono`,children:[(0,Q.jsxs)(`span`,{className:`text-success`,children:[`+`,e.insertions]}),` `,(0,Q.jsxs)(`span`,{className:`text-destructive`,children:[`−`,e.deletions]}),` `,e.path]},e.path)),a.files.length>12&&(0,Q.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:worktrees.more`,{count:a.files.length-12})})]})})]},`${e.branch??e.dir??r}`)})})]})}function sd({title:e,onClick:t,disabled:n,danger:r,children:i}){return(0,Q.jsx)(`button`,{type:`button`,title:e,disabled:n,onClick:t,className:G(`rounded p-1 text-muted-foreground hover:bg-muted disabled:cursor-not-allowed disabled:opacity-30`,r?`hover:text-destructive`:`hover:text-foreground`),children:i})}function cd({ok:e,children:t}){return(0,Q.jsxs)(`div`,{className:G(`flex items-start gap-1.5 border-y px-3 py-1.5 text-[11px]`,e?`border-success/30 bg-success/5 text-success`:`border-warning/30 bg-warning/5 text-warning`),children:[e?(0,Q.jsx)(Gt,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}):(0,Q.jsx)(kt,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1`,children:t}),!e&&(0,Q.jsx)(un,{className:`mt-0.5 h-3 w-3 shrink-0 opacity-40`})]})}function ld({label:e,checked:t,onChange:n}){return(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>n(!t),className:`flex w-full items-center justify-between px-2 py-1.5 rounded text-xs hover:bg-accent/50 transition-colors`,children:[(0,Q.jsx)(`span`,{className:`text-foreground`,children:e}),(0,Q.jsx)(`span`,{className:G(`relative inline-flex h-4 w-7 shrink-0 items-center rounded-full transition-colors`,t?`bg-primary`:`bg-muted`),children:(0,Q.jsx)(`span`,{className:G(`inline-block h-3 w-3 transform rounded-full bg-background transition-transform`,t?`translate-x-3.5`:`translate-x-0.5`)})})]})}var ud=[{value:`dots`,labelKey:`bgDots`},{value:`lines`,labelKey:`bgLines`},{value:`cross`,labelKey:`bgCross`},{value:`none`,labelKey:`bgNone`}];function dd(){let{t:e}=V(),{showHud:t,showLegend:n,showMinimap:r,showControls:i,animateEdges:a,background:o,setShowHud:s,setShowLegend:c,setShowMinimap:l,setShowControls:u,setAnimateEdges:d,setBackground:f}=Sr($t(e=>({showHud:e.showHud,showLegend:e.showLegend,showMinimap:e.showMinimap,showControls:e.showControls,animateEdges:e.animateEdges,background:e.background,setShowHud:e.setShowHud,setShowLegend:e.setShowLegend,setShowMinimap:e.setShowMinimap,setShowControls:e.setShowControls,setAnimateEdges:e.setAnimateEdges,setBackground:e.setBackground}))),{clientCounts:p,currentSession:m,totalAgents:h,activeAgents:g}=kr($t(e=>({clientCounts:e.clientCounts,currentSession:e.currentSession,totalAgents:e.totalAgents,activeAgents:e.activeAgents}))),_=p.tui+p.webui+p.repl;return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col gap-4 overflow-y-auto overscroll-contain p-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-2`,children:e(`activity:officeMap.liveHeading`)}),(0,Q.jsxs)(`div`,{className:`space-y-1.5 text-xs`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Q.jsx)(xn,{className:`h-3.5 w-3.5`}),` `,e(`activity:officeMap.clients`)]}),(0,Q.jsx)(`span`,{className:`font-mono`,children:_})]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Q.jsx)(Ee,{className:`h-3.5 w-3.5`}),` `,e(`activity:officeMap.agents`)]}),(0,Q.jsxs)(`span`,{className:`font-mono`,children:[g,(0,Q.jsxs)(`span`,{className:`text-muted-foreground`,children:[` / `,h]})]})]}),m.model&&(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Q.jsx)(yt,{className:`h-3.5 w-3.5`}),` `,e(`activity:officeMap.model`)]}),(0,Q.jsx)(`span`,{className:`font-mono truncate max-w-[140px]`,title:m.model,children:m.model.split(`/`).pop()})]}),m.mode&&(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Q.jsx)(Tt,{className:`h-3.5 w-3.5`}),` `,e(`activity:officeMap.mode`)]}),(0,Q.jsx)(`span`,{className:`font-mono uppercase text-xs`,children:m.mode})]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Q.jsx)(_t,{className:`h-3.5 w-3.5`}),` `,e(`activity:officeMap.toolCalls`)]}),(0,Q.jsx)(`span`,{className:`font-mono`,children:(e=>e?.toLocaleString()??`0`)(m.toolCalls)})]})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-1`,children:e(`activity:officeMap.displayHeading`)}),(0,Q.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,Q.jsx)(ld,{label:e(`activity:officeMap.statsHud`),checked:t,onChange:s}),(0,Q.jsx)(ld,{label:e(`activity:officeMap.legends`),checked:n,onChange:c}),(0,Q.jsx)(ld,{label:e(`activity:officeMap.minimap`),checked:r,onChange:l}),(0,Q.jsx)(ld,{label:e(`activity:officeMap.zoomControls`),checked:i,onChange:u}),(0,Q.jsx)(ld,{label:e(`activity:officeMap.animateWires`),checked:a,onChange:d})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-1.5 px-2`,children:e(`activity:officeMap.backgroundHeading`)}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1 px-2`,children:ud.map(t=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>f(t.value),className:G(`px-2 py-1 text-xs rounded transition-colors`,o===t.value?`bg-primary text-primary-foreground`:`bg-muted text-muted-foreground hover:bg-accent`),children:e(`activity:officeMap.${t.labelKey}`)},t.value))})]})]})}function fd({className:e,leaderName:t}){let n=xr($t(br)),r=xr(e=>e.eventTimeline),{t:i}=V(),a=n.total>0,o=r.slice(0,3),s=(0,Z.useCallback)(()=>{let e=U.getState();e.setInspectorTab(`fleet`),e.setInspectorOpen(!0)},[]);return(0,Q.jsxs)(`div`,{className:G(`flex flex-col gap-0.5 border-b border-border/70 bg-muted/20 px-3 py-1.5 text-[10px]`,e),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0 flex-wrap`,children:[(0,Q.jsx)(pd,{label:String(n.running),ledClass:`bg-success`,pulse:n.running>0}),(0,Q.jsx)(`span`,{className:`tabular-nums text-success count-transition`,children:i(`activity:agents.runningCount`,{count:n.running})}),n.completed>0&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,Q.jsxs)(`span`,{className:`tabular-nums text-muted-foreground count-transition`,children:[n.completed,` done`]})]}),n.failed>0&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,Q.jsx)(pd,{label:String(n.failed),ledClass:`bg-destructive`,pulse:!1})]}),(0,Q.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,Q.jsx)(`span`,{className:`tabular-nums text-muted-foreground count-transition`,children:i(`activity:agents.totalCount`,{count:n.total})}),(0,Q.jsx)(`span`,{className:`flex-1 min-w-0`}),n.totalCost>0&&(0,Q.jsx)(`span`,{className:`tabular-nums font-mono text-muted-foreground ml-auto shrink-0 count-transition`,children:Ns(n.totalCost)}),t&&(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 rounded border border-warning/30 bg-warning/10 px-1 py-0.5 text-[9px] font-medium text-warning shrink-0`,children:[(0,Q.jsx)(pt,{className:`h-2.5 w-2.5`}),t]})]}),a&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0 flex-wrap`,children:[(0,Q.jsx)(sc,{current:n.concurrency,max:n.concurrencyMax,showLabel:!0}),n.tokensIn+n.tokensOut>0&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,Q.jsxs)(`span`,{className:`tabular-nums font-mono text-muted-foreground count-transition`,children:[`↓`,Fr(n.tokensIn),` `,`↑`,Fr(n.tokensOut)]})]})]}),o.length>0&&(0,Q.jsx)(`div`,{className:`flex items-center gap-1 min-w-0 overflow-x-auto no-scrollbar`,children:o.map(e=>(0,Q.jsxs)(`span`,{onClick:s,className:`inline-flex items-center gap-1 shrink-0 rounded border border-border/50 bg-background/40 px-1.5 py-0.5 text-[9px] text-muted-foreground cursor-pointer hover:bg-accent/50 hover:text-foreground transition-colors`,title:e.message,"aria-label":`${md[e.kind]??e.kind}: ${e.message}`,children:[(0,Q.jsx)(gd,{kind:e.kind}),md[e.kind]??e.kind]},e.id))}),!a&&(0,Q.jsx)(`div`,{className:`flex items-center gap-2 min-w-0`,children:(0,Q.jsx)(`span`,{className:`text-muted-foreground italic`,children:`Fleet idle`})})]})}function pd({label:e,ledClass:t,pulse:n}){return(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 shrink-0`,children:[(0,Q.jsx)(`span`,{className:G(`led h-1.5 w-1.5`,t,n&&`led-pulse`),"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`tabular-nums font-medium`,children:e})]})}var md={spawned:`spawned`,task_started:`started`,tool_executed:`tool`,iteration_summary:`iter`,budget_warning:`budget`,budget_extended:`extended`,task_completed:`done`,ctx_pct:`ctx`,leader_updated:`leader`},hd={spawned:`bg-primary`,task_started:`bg-info`,tool_executed:`bg-warning`,iteration_summary:`bg-muted-foreground`,budget_warning:`bg-destructive`,budget_extended:`bg-warning`,task_completed:`bg-success`,ctx_pct:`bg-muted-foreground`,leader_updated:`bg-warning`};function gd({kind:e}){return(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:G(`inline-block h-1.5 w-1.5 rounded-full shrink-0`,hd[e]??`bg-muted-foreground`)})}function _d({agent:e,isExpanded:t,onOpenInspector:n}){let{t:r}=V(),[i,a]=(0,Z.useState)(!1),o=(0,Z.useRef)(null),s=(0,Z.useRef)(null),[l,u]=(0,Z.useState)(0);(0,Z.useEffect)(()=>{s.current&&u(t?s.current.scrollHeight:0)},[t,e]),(0,Z.useEffect)(()=>{t&&o.current&&e.status===`running`&&(o.current.scrollTop=o.current.scrollHeight)},[t,e.partialText,e.status]);let d=e.toolLog??[],f=i?d:d.slice(0,10),p=[{label:r(`activity:agents.configProvider`),value:e.provider},{label:r(`activity:agents.configModel`),value:e.model},{label:r(`activity:agents.configDescription`),value:e.description},{label:r(`activity:agents.configTaskId`),value:e.taskId}].filter(e=>e.value!=null&&e.value!==``),m=e.partialText&&e.partialText.length>0&&e.status===`running`,h=xr(t=>t.agentTranscripts.get(e.id)??Tr),[g,_]=(0,Z.useState)(!1),v=g?h:h.slice(-20);return(0,Q.jsx)(`div`,{className:`overflow-hidden transition-all duration-[250ms] ease-out`,style:{maxHeight:t?l:0,opacity:+!!t},children:(0,Q.jsxs)(`div`,{ref:s,className:`space-y-2 px-3 pb-3 pt-0.5`,children:[d.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,Q.jsxs)(`span`,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wider`,children:[r(`activity:agents.toolLog`),` (`,d.length,`)`]}),(0,Q.jsxs)(`div`,{className:`space-y-0.5`,children:[f.map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] font-mono min-w-0`,children:[e.ok?(0,Q.jsx)(Wn,{className:`h-2.5 w-2.5 shrink-0 text-success`}):(0,Q.jsx)(vn,{className:`h-2.5 w-2.5 shrink-0 text-destructive`}),(0,Q.jsx)(`span`,{className:G(`truncate`,e.ok?``:`text-destructive`),children:e.name}),(0,Q.jsx)(`span`,{className:`tabular-nums text-muted-foreground ml-auto shrink-0`,children:mr(e.durationMs)})]},e.at)),d.length>10&&(0,Q.jsx)(`button`,{type:`button`,onClick:()=>a(!i),"aria-label":r(i?`activity:agents.showFewer`:`activity:agents.showAll`),className:`flex items-center gap-0.5 text-[10px] text-primary hover:text-primary/80 transition-colors`,children:i?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Et,{className:`h-2.5 w-2.5`}),` `,r(`activity:agents.showFewer`)]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(b,{className:`h-2.5 w-2.5`}),` `,r(`activity:agents.showAll`),` (`,d.length,`)`]})})]})]}),m&&(0,Q.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wider`,children:r(`activity:agents.streaming`)}),(0,Q.jsx)(`div`,{ref:o,className:`max-h-20 overflow-y-auto rounded bg-muted/40 p-1.5 text-[10px] font-mono text-muted-foreground leading-snug whitespace-pre-wrap break-all`,children:e.partialText})]}),(e.status===`failed`||e.status===`timeout`)&&(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(`span`,{className:G(`text-[10px] font-semibold uppercase tracking-wider`,e.status===`failed`?`text-destructive`:`text-warning`),children:e.status===`failed`?r(`activity:agents.failure`):r(`activity:agents.timeout`)}),(0,Q.jsx)(`span`,{className:`flex-1`}),(0,Q.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation()},className:`flex items-center gap-0.5 rounded border border-border/50 px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-foreground hover:bg-accent transition-colors`,title:r(`activity:agents.reRunTitle`),children:[(0,Q.jsx)(c,{className:`h-2.5 w-2.5`}),r(`activity:agents.reRun`)]})]}),(e.failureReason||e.error)&&(0,Q.jsxs)(`div`,{className:G(`rounded p-1.5 text-[10px] leading-snug`,e.status===`failed`?`bg-destructive/5 text-destructive`:`bg-warning/5 text-warning`),children:[e.failureReason&&(0,Q.jsx)(`div`,{className:`font-medium`,children:e.failureReason}),e.error&&(0,Q.jsxs)(`div`,{className:G(`mt-0.5`,e.status===`failed`?`text-destructive/80`:`text-warning/80`),children:[e.error.kind&&(0,Q.jsxs)(`span`,{className:`font-mono`,children:[`[`,e.error.kind,`] `]}),e.error.message]})]}),d.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:r(`activity:agents.lastToolCalls`,{count:Math.min(3,d.length)})}),(0,Q.jsx)(`div`,{className:`space-y-0.5`,children:d.slice(0,3).map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] font-mono min-w-0`,children:[e.ok?(0,Q.jsx)(Wn,{className:`h-2.5 w-2.5 shrink-0 text-success`}):(0,Q.jsx)(vn,{className:`h-2.5 w-2.5 shrink-0 text-destructive`}),(0,Q.jsx)(`span`,{className:G(`truncate`,e.ok?``:`text-destructive`),children:e.name}),(0,Q.jsx)(`span`,{className:`tabular-nums text-muted-foreground ml-auto shrink-0`,children:mr(e.durationMs)})]},e.at))})]})]}),p.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wider`,children:r(`activity:agents.config`)}),(0,Q.jsx)(`div`,{className:`rounded bg-muted/30 p-1.5 space-y-0.5`,children:p.map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] min-w-0`,children:[(0,Q.jsxs)(`span`,{className:`text-muted-foreground shrink-0`,children:[e.label,`:`]}),(0,Q.jsx)(`span`,{className:`font-mono truncate text-foreground/90`,children:e.value})]},e.label))})]}),h.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsxs)(`span`,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wider`,children:[r(`activity:agents.transcript`),` (`,h.length,`)`]}),h.length>20&&(0,Q.jsx)(`button`,{type:`button`,onClick:()=>_(!g),className:`ml-auto flex items-center gap-0.5 text-[10px] text-primary hover:text-primary/80 transition-colors`,children:g?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Et,{className:`h-2.5 w-2.5`}),` `,r(`activity:agents.showFewer`)]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(b,{className:`h-2.5 w-2.5`}),` `,r(`activity:agents.showAll`)]})})]}),(0,Q.jsx)(Cc,{entries:v,agentName:e.name,compact:!0,maxHeightClassName:`max-h-32`,showHeader:!1})]}),n&&(0,Q.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),n()},className:`flex items-center gap-1 text-[10px] text-primary hover:text-primary/80 transition-colors`,children:[(0,Q.jsx)(tt,{className:`h-2.5 w-2.5`}),r(`activity:agents.openInspector`)]})]})})}var vd={running:{led:`bg-success`,pulse:!0},completed:{led:`bg-success`,pulse:!1},failed:{led:`bg-destructive`,pulse:!1},timeout:{led:`bg-warning`,pulse:!1},stopped:{led:`bg-muted-foreground`,pulse:!1}};function yd({agent:e,isLeader:t,isExpanded:n,isFocused:r,onToggle:i,onOpenInspector:a,now:o}){let{t:s}=V(),[c,l]=(0,Z.useState)(Date.now()),u=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{if(o!==void 0||e.status!==`running`){u.current&&clearInterval(u.current),u.current=null;return}return u.current=setInterval(()=>l(Date.now()),1e4),()=>{u.current&&clearInterval(u.current)}},[o,e.status]);let d=o??c,f=(0,Z.useMemo)(()=>vr(e,d),[e,d]),p=vd[e.status],m=e.status===`running`,h=e.currentTool||e.lastTool;return(0,Q.jsxs)(`div`,{className:G(`animate-message`,n&&`rounded-lg ring-1 ring-primary/20`),children:[(0,Q.jsxs)(`button`,{type:`button`,id:`agent-card-${e.id}`,"data-agent-card":!0,role:`option`,"aria-selected":n,"aria-expanded":n,onClick:i,className:G(`w-full text-left rounded-lg border px-3 py-2.5 transition-colors space-y-2`,!n&&`rounded-b-lg`,n&&`rounded-b-none border-b-0`,m&&`border-primary/40 bg-primary/[0.03]`,!m&&e.status===`completed`&&`border-success/30 bg-success/[0.02]`,!m&&e.status===`failed`&&`border-destructive/30 bg-destructive/[0.02]`,!m&&e.status===`timeout`&&`border-warning/30 bg-warning/[0.02]`,!m&&e.status===`stopped`&&`border-border/60 bg-card/40`,`hover:border-primary/40 hover:bg-primary/[0.04]`,t&&`ring-1 ring-warning/30`,r&&`ring-2 ring-primary`),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,Q.jsx)(`span`,{className:G(`led shrink-0`,p.led,p.pulse&&`led-pulse`),"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`truncate text-[11px] font-semibold`,title:e.name,children:e.name}),t&&(0,Q.jsx)(pt,{className:`h-3 w-3 shrink-0 text-warning`,"aria-label":s(`activity:fleet.leader`)}),(0,Q.jsx)(`span`,{className:`flex-1 min-w-0`}),(0,Q.jsx)(`span`,{className:`tabular-nums font-mono text-[10px] text-muted-foreground shrink-0`,children:f.cost}),(0,Q.jsx)(b,{className:G(`h-3 w-3 shrink-0 text-muted-foreground/50 transition-transform duration-200`,n&&`rotate-180`)})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[e.model?(0,Q.jsx)(`span`,{className:`truncate rounded bg-muted/60 px-1.5 py-0.5 text-[10px] font-mono text-muted-foreground max-w-[10rem]`,children:e.model}):(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground italic`,children:s(`activity:agents.pending`)}),(0,Q.jsxs)(`span`,{className:`tabular-nums text-[10px] text-muted-foreground`,children:[f.iterationCount,s(`activity:agents.itSuffix`),` · `,f.toolCount,s(`activity:agents.tcSuffix`)]}),(0,Q.jsx)(`span`,{className:`ml-auto tabular-nums text-[10px] text-muted-foreground/70 shrink-0`,children:f.elapsed})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,Q.jsx)(oc,{bins:e.sparklineBins,className:`text-[9px] font-mono min-w-0`}),(0,Q.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,Q.jsx)(mo,{pct:f.ctxClamped,tokens:e.ctxTokens,maxTokens:e.maxContext,showTokens:!0})}),e.budgetWarning&&(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 rounded bg-warning/10 px-1.5 py-0.5 text-[10px] text-warning shrink-0`,title:s(`activity:fleet.hittingLimitTitle`,{kind:e.budgetWarning.kind,used:e.budgetWarning.used,limit:e.budgetWarning.limit}),children:[(0,Q.jsx)(Tt,{className:`h-2.5 w-2.5`}),e.budgetWarning.kind]})]}),h&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground min-w-0`,children:[(0,Q.jsx)(Mn,{className:G(`h-2.5 w-2.5 shrink-0`,m&&`animate-pulse text-primary`)}),(0,Q.jsx)(`span`,{className:`truncate font-mono`,children:e.currentTool??e.lastTool})]})]}),(0,Q.jsx)(_d,{agent:e,isExpanded:!!n,onOpenInspector:a})]})}var bd=[{value:`all`,label:`All`},{value:`running`,label:`Running`},{value:`completed`,label:`Done`},{value:`failed`,label:`Failed`}];function xd(){let e=xr($t(Lr)),t=xr(e=>e.leaderId),n=xr(Pr),r=xr(e=>e.clearFinishedAgents),{t:i}=V(),[a,o]=(0,Z.useState)(`all`),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(-1),d=(0,Z.useRef)(null),[f,p]=(0,Z.useState)(!0),m=(0,Z.useMemo)(()=>a===`all`?e:e.filter(e=>a===`running`?e.status===`running`:a===`completed`?e.status===`completed`:a!==`failed`||e.status===`failed`||e.status===`timeout`),[e,a]),h=e.some(e=>e.status!==`running`),g=(0,Z.useCallback)(e=>{let t=U.getState();e?(t.setInspectorFocusedAgentId(e),t.setInspectorTab(`agents`)):t.setInspectorTab(`fleet`),t.setInspectorOpen(!0)},[]),_=(0,Z.useCallback)(e=>{c(t=>t===e?null:e)},[]),v=(0,Z.useCallback)(e=>{let t=m;if(t.length!==0)switch(e.key){case`ArrowDown`:e.preventDefault(),u(e=>{let n=Math.min(e+1,t.length-1);return p(!1),n});break;case`ArrowUp`:e.preventDefault(),u(e=>{let t=Math.max(e-1,0);return p(!1),t});break;case`Enter`:case` `:e.preventDefault(),l>=0&&l<t.length&&_(t[l].id);break;case`Escape`:e.preventDefault(),s&&c(null);break}},[m,l,_,s]);(0,Z.useEffect)(()=>{l>=0&&d.current&&d.current.querySelectorAll(`[data-agent-card]`)[l]?.focus()},[l]);let y=e.length>0&&e.every(e=>e.status!==`running`);return e.length===0?(0,Q.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center bg-[hsl(var(--surface-2)/0.35)] p-3`,children:(0,Q.jsxs)(`div`,{className:`ws-surface flex max-w-[15rem] flex-col items-center gap-3 rounded-xl p-5 text-center text-muted-foreground`,children:[(0,Q.jsx)(`span`,{className:`flex h-11 w-11 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,Q.jsx)(Ee,{className:`h-5 w-5`})}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-sm font-semibold text-foreground`,children:i(`activity:agents.empty`)}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs`,children:i(`activity:agents.emptyHint`)})]})]})}):m.length===0&&a!==`all`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(fd,{leaderName:n}),(0,Q.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center bg-[hsl(var(--surface-2)/0.35)] p-3`,children:(0,Q.jsxs)(`div`,{className:`ws-surface flex max-w-[15rem] flex-col items-center gap-3 rounded-xl p-5 text-center text-muted-foreground`,children:[(0,Q.jsx)(`span`,{className:`flex h-11 w-11 items-center justify-center rounded-lg bg-muted/60 text-muted-foreground`,children:(0,Q.jsx)(I,{className:`h-5 w-5`})}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-sm font-semibold text-foreground`,children:i(`activity:agents.emptyFilteredTitle`)}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs`,children:i(`activity:agents.emptyFilteredHint`)})]}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>o(`all`),className:`h-7 rounded-md border border-border px-3 text-[11px] font-medium text-foreground hover:bg-accent transition-colors`,children:i(`activity:agents.emptyFilteredClear`)})]})})]}):y&&a===`all`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(fd,{leaderName:n}),(0,Q.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center bg-[hsl(var(--surface-2)/0.35)] p-3`,children:(0,Q.jsxs)(`div`,{className:`ws-surface flex max-w-[15rem] flex-col items-center gap-3 rounded-xl p-5 text-center text-muted-foreground`,children:[(0,Q.jsx)(`span`,{className:`flex h-11 w-11 items-center justify-center rounded-lg bg-success/10 text-success`,children:(0,Q.jsx)(Gt,{className:`h-5 w-5`})}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-sm font-semibold text-foreground`,children:i(`activity:agents.emptyFinishedTitle`)}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs`,children:i(`activity:agents.emptyFinishedHint`)}),(0,Q.jsx)(`p`,{className:`mt-2 text-[11px] tabular-nums text-muted-foreground`,children:i(`activity:agents.emptyFinishedStats`,{completed:e.filter(e=>e.status===`completed`).length,failed:e.filter(e=>e.status===`failed`||e.status===`timeout`).length})})]})]})}),(0,Q.jsx)(`div`,{className:`shrink-0 border-t border-border/70 bg-card/75 px-3 py-2`,children:(0,Q.jsxs)(`button`,{type:`button`,onClick:r,className:`w-full flex items-center justify-center gap-1.5 h-7 rounded-md border border-border text-[11px] text-muted-foreground hover:text-foreground hover:bg-accent transition-colors`,children:[(0,Q.jsx)(C,{className:`h-3 w-3`}),i(`activity:agents.clearFinished`)]})})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(fd,{leaderName:n}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-border/70 px-2 py-1 shrink-0`,children:[bd.map(e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>o(e.value),"aria-pressed":a===e.value,className:G(`rounded px-1.5 py-0.5 text-[10px] font-medium transition-colors`,a===e.value?`bg-primary/10 text-primary`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),children:i(`activity:agents.filter${e.value.charAt(0).toUpperCase()+e.value.slice(1)}`)},e.value)),(0,Q.jsx)(`span`,{className:`flex-1`}),h&&(0,Q.jsxs)(`button`,{type:`button`,onClick:r,"aria-label":i(`activity:agents.clearFinishedTitle`),title:i(`activity:agents.clearFinishedTitle`),className:`inline-flex items-center gap-0.5 rounded px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors`,children:[(0,Q.jsx)(C,{className:`h-2.5 w-2.5`}),i(`activity:agents.clearFinished`)]})]}),(0,Q.jsxs)(`div`,{ref:d,role:`listbox`,"aria-label":`Agent roster`,"aria-activedescendant":l>=0?`agent-card-${m[l]?.id}`:void 0,tabIndex:0,onKeyDown:v,className:`min-h-0 min-w-0 flex-1 space-y-1.5 overflow-y-auto overscroll-contain bg-[hsl(var(--surface-2)/0.35)] p-2`,children:[f&&l===-1&&(0,Q.jsx)(`div`,{className:`text-[9px] text-muted-foreground/60 text-center py-1 italic select-none`,children:i(`activity:agents.rosterHint`)}),m.map(e=>(0,Q.jsx)(yd,{agent:e,isLeader:e.id===t,isExpanded:s===e.id,isFocused:l>=0&&m[l]?.id===e.id,onToggle:()=>_(e.id),onOpenInspector:()=>g(e.id)},e.id))]}),(0,Q.jsx)(`div`,{className:`shrink-0 border-t border-border/70 bg-card/75 px-3 py-2`,children:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>g(),className:`w-full flex items-center justify-center gap-1.5 h-7 rounded-md border border-border text-[11px] text-muted-foreground hover:text-foreground hover:bg-accent transition-colors`,children:[(0,Q.jsx)(ft,{className:`h-3 w-3`}),i(`activity:agents.openFull`)]})})]})}var Sd={chat:`Run state, model, context and quick controls`,agents:`Live fleet roster and agent monitoring`,history:`Resume or inspect previous sessions`,files:`Browse and open project files`,changes:`Review source control changes`,mailbox:`Cross-surface coordination messages`,skills:`Installed skills and capability docs`,design:`Design studio assets and previews`,worktrees:`Parallel branches and worktree lanes`,officemap:`Fleet map settings and filters`};function Cd({desktopShell:e=!1}){let t=U(e=>e.activeActivity),n=U(e=>e.setSidebarOpen),r=U(e=>e.sidebarWidth),i=U(e=>e.setSidebarWidth),a=q(e=>e.wsConnected),{client:o}=dr(),{t:s}=V(),c=e?`min(${Math.min(r,280)}px, calc(100vw - 2.5rem))`:`min(${r}px, calc(100vw - 3rem))`;return(0,Z.useEffect)(()=>{if(t!==`files`||!a)return;gr.getState().setTreeLoading(!0);let e=K.getState().cwd;o?.send({type:`files.tree`,payload:e?{path:e}:{}})},[t,a,o]),(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:G(`fixed inset-y-0 right-0 z-30 bg-black/35 backdrop-blur-[2px] md:hidden`,e?`left-10`:`left-12`),onClick:()=>n(!1),"aria-hidden":`true`}),(0,Q.jsxs)(`aside`,{style:{width:c},role:`dialog`,"aria-modal":`true`,"aria-label":s(`activity:sidebar.label`),className:G(`fixed inset-y-0 z-40 flex min-h-0 min-w-0 shrink-0 flex-col overflow-hidden border-r border-border/70 bg-card/95 shadow-2xl backdrop-blur-xl animate-slide-in md:relative md:inset-auto md:z-auto md:shadow-none`,e?`left-10`:`left-12`),children:[(0,Q.jsx)(`hr`,{"aria-orientation":`vertical`,"aria-valuemin":240,"aria-valuemax":560,"aria-valuenow":r,tabIndex:0,onMouseDown:e=>{e.preventDefault();let t=e.clientX,n=r,a=e=>i(n+(e.clientX-t)),o=()=>{window.removeEventListener(`mousemove`,a),window.removeEventListener(`mouseup`,o),document.body.style.cursor=``,document.body.style.userSelect=``};window.addEventListener(`mousemove`,a),window.addEventListener(`mouseup`,o),document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`},onDoubleClick:()=>i(304),className:`group/handle absolute top-0 right-0 z-10 m-0 h-full w-2 cursor-col-resize border-0 border-r border-border/70 hover:border-primary/70`,title:s(`activity:sidePanel.dragHint`)}),(0,Q.jsxs)(`div`,{className:G(`flex items-center justify-between border-b shrink-0`,`bg-muted/25`,e?`px-2.5 py-2`:`px-3 py-3`),children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-semibold text-foreground`,children:s(`activity:nav.${t}`)}),(0,Q.jsx)(`div`,{className:`mt-0.5 truncate text-[11px] text-muted-foreground`,children:Sd[t]})]}),(0,Q.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-7 w-7 shrink-0`,onClick:()=>n(!1),title:s(`activity:sidePanel.collapse`),children:(0,Q.jsx)(Xn,{className:`h-3.5 w-3.5`})})]}),(0,Q.jsxs)(`div`,{className:`flex-1 min-h-0 min-w-0 flex flex-col overflow-hidden`,children:[t===`chat`&&(0,Q.jsx)(Ju,{}),t===`agents`&&(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-y-auto overscroll-contain`,children:(0,Q.jsx)(xd,{})}),t===`history`&&(0,Q.jsx)(Bu,{}),t===`files`&&(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-y-auto overscroll-contain`,children:(0,Q.jsx)(vu,{})}),t===`changes`&&(0,Q.jsx)(Tu,{}),t===`mailbox`&&(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-y-auto overscroll-contain p-3`,children:(0,Q.jsx)(xu,{})}),t===`skills`&&(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Q.jsx)($u,{className:`h-full`})}),t===`design`&&(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Q.jsx)(rd,{className:`h-full`})}),t===`worktrees`&&(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Q.jsx)(od,{})}),t===`officemap`&&(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Q.jsx)(dd,{})})]})]})]})}function wd(){let e=Ar(e=>e.info),{client:t}=dr(),n=(0,Z.useRef)(null),r=(0,Z.useCallback)(()=>{t?.getGitInfo?.()},[t]);return(0,Z.useEffect)(()=>(r(),n.current=setInterval(r,3e4),()=>{n.current&&clearInterval(n.current)}),[r]),e}function Td({sessionId:e,className:t}){let{t:n}=V(),[r,a]=(0,Z.useState)([]),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(0),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(``),[b,x]=(0,Z.useState)(``),[S,C]=(0,Z.useState)(!1),[w,T]=(0,Z.useState)(``),E=pr(q(e=>e.wsUrl)),D=i(e=>e.messages).filter(e=>e.role===`tool`&&e.toolResult===void 0&&!!e.toolUseId);(0,Z.useEffect)(()=>{let t=[];return t.push(E.on(`collab.state`,t=>{let n=t.payload;n.sessionId===e&&a(n.participants??[])})),t.push(E.on(`collab.participant.joined`,t=>{let n=t.payload;n.sessionId===e&&a(e=>e.some(e=>e.participantId===n.participantId)?e:[...e,{participantId:n.participantId,role:n.role,joinedAt:n.joinedAt}])})),t.push(E.on(`collab.participant.left`,t=>{let n=t.payload;if(n.sessionId!==e)return;let r=n.participantId;a(e=>e.filter(e=>e.participantId!==r))})),t.push(E.on(`error`,e=>{let t=e.payload;t.phase===`collab`&&(d(t.message),s(!1))})),t.push(E.on(`collab.annotation.added`,t=>{let n=t.payload;n.sessionId===e&&(n.annotation?.resolved||p(e=>e+1))})),t.push(E.on(`collab.annotation.resolved`,t=>{t.payload.sessionId===e&&p(e=>Math.max(0,e-1))})),t.push(E.on(`collab.pause.granted`,t=>{t.payload.sessionId===e&&h(!0)})),t.push(E.on(`collab.pause.released`,t=>{t.payload.sessionId===e&&h(!1)})),()=>{for(let e of t)e()}},[E,e]);let O=(t=`observer`)=>{d(null),E.send({type:`collab.join`,payload:{sessionId:e,role:t}}),s(!0),l(t)},k=()=>{E.send({type:`collab.request_pause`,payload:{sessionId:e}})},A=()=>{E.send({type:`collab.resume`,payload:{sessionId:e}})},j=()=>{E.send({type:`collab.leave`,payload:{sessionId:e}}),s(!1),a([])},M=t=>{E.send({type:`collab.grant_control`,payload:{sessionId:e,toParticipant:t}})},N=()=>{v&&(E.send({type:`collab.inject_tool`,payload:{sessionId:e,toolUseId:v,content:b,isError:S,reason:w.trim()||H.t(`activity:collab.controllerInjection`)}}),_(!1),y(``),x(``),C(!1),T(``))},P=o&&c===`controller`;return r.length===0&&!u?(0,Q.jsxs)(`div`,{className:G(`flex items-center gap-2 px-3 py-2 rounded-md border border-dashed border-border bg-card/40`,t),children:[(0,Q.jsx)(xn,{className:`w-4 h-4 text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`activity:collab.noObservers`)}),(0,Q.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>O(`observer`),className:`inline-flex items-center gap-1 text-xs px-2 py-1 rounded bg-primary text-primary-foreground hover:bg-primary/90 transition-colors`,title:n(`activity:collab.observerTitle`),children:[(0,Q.jsx)(He,{className:`w-3 h-3`}),n(`activity:collab.observerRole`)]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>O(`annotator`),className:`inline-flex items-center gap-1 text-xs px-2 py-1 rounded border border-warning/40 bg-warning/10 text-warning hover:bg-warning/20 transition-colors`,title:n(`activity:collab.annotatorTitle`),children:[(0,Q.jsx)(nn,{className:`w-3 h-3`}),n(`activity:collab.annotatorRole`)]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>O(`controller`),className:`inline-flex items-center gap-1 text-xs px-2 py-1 rounded border border-destructive/40 bg-destructive/10 text-destructive hover:bg-destructive/20 transition-colors`,title:n(`activity:collab.controllerTitle`),children:[(0,Q.jsx)(mn,{className:`w-3 h-3`}),n(`activity:collab.controllerRole`)]})]})]}):u?(0,Q.jsxs)(`div`,{className:G(`flex items-center gap-2 px-3 py-2 rounded-md border border-destructive/50 bg-destructive/10`,t),role:`alert`,children:[(0,Q.jsx)(`span`,{className:`text-xs text-destructive`,children:n(`activity:collab.errorPrefix`,{error:u})}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{d(null),s(!1)},className:`ml-auto text-xs underline text-destructive`,children:n(`activity:collab.dismiss`)})]}):(0,Q.jsxs)(`div`,{className:G(`relative flex items-center gap-2 px-3 py-2 rounded-md border border-success/40 bg-success/5`,t),children:[(0,Q.jsxs)(`span`,{className:`relative flex h-2 w-2`,role:`img`,"aria-label":n(`common:status.live`),children:[(0,Q.jsx)(`span`,{className:`absolute inline-flex h-full w-full rounded-full bg-success opacity-75 animate-ping`}),(0,Q.jsx)(`span`,{className:`relative inline-flex rounded-full h-2 w-2 bg-success`})]}),(0,Q.jsx)(xn,{className:`w-4 h-4 text-success`}),(0,Q.jsx)(`span`,{className:`text-xs font-medium text-success`,children:n(`activity:collab.observers`,{count:r.length})}),f>0&&(0,Q.jsxs)(`span`,{title:n(`activity:collab.annotationsTitle`,{count:f}),className:`ml-2 inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-warning/15 text-warning border border-warning/30`,children:[(0,Q.jsx)(nn,{className:`w-3 h-3`}),n(`activity:collab.notes`,{count:f})]}),m&&(0,Q.jsxs)(`span`,{title:n(`activity:collab.pausedTitle`),className:`ml-2 inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-destructive/15 text-destructive border border-destructive/40`,children:[(0,Q.jsx)(mn,{className:`w-3 h-3`}),n(`activity:collab.paused`)]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 ml-2`,children:[r.slice(0,3).map(e=>(0,Q.jsxs)(`span`,{title:n(`activity:collab.joinedTitle`,{time:new Date(e.joinedAt).toLocaleTimeString()}),className:`inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-success/10 text-success`,children:[(0,Q.jsx)(it,{className:`w-3 h-3`}),e.role,P&&e.role!==`controller`&&(0,Q.jsx)(`button`,{type:`button`,onClick:()=>M(e.participantId),title:n(`activity:collab.grantTitle`),className:`ml-0.5 inline-flex items-center rounded hover:bg-success/20 transition-colors`,children:(0,Q.jsx)(Yt,{className:`w-3 h-3`})})]},e.participantId)),r.length>3&&(0,Q.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`+`,r.length-3]})]}),P&&(0,Q.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>_(e=>!e),className:`inline-flex items-center gap-1 text-xs px-2 py-1 rounded border border-info/40 bg-info/10 text-info hover:bg-info/20 transition-colors`,title:n(`activity:collab.injectTitle`),children:[(0,Q.jsx)(Me,{className:`w-3 h-3`}),n(`activity:collab.inject`)]}),m?(0,Q.jsxs)(`button`,{type:`button`,onClick:A,className:`inline-flex items-center gap-1 text-xs px-2 py-1 rounded border border-destructive/40 bg-destructive/10 text-destructive hover:bg-destructive/20 transition-colors`,title:n(`activity:collab.resumeTitle`),children:[(0,Q.jsx)(dn,{className:`w-3 h-3`}),n(`activity:collab.resume`)]}):(0,Q.jsxs)(`button`,{type:`button`,onClick:k,className:`inline-flex items-center gap-1 text-xs px-2 py-1 rounded border border-warning/40 bg-warning/10 text-warning hover:bg-warning/20 transition-colors`,title:n(`activity:collab.pauseTitle`),children:[(0,Q.jsx)(mn,{className:`w-3 h-3`}),n(`activity:collab.pauseAgent`)]})]}),o&&c!==`controller`&&(0,Q.jsxs)(`button`,{type:`button`,onClick:j,className:`ml-auto inline-flex items-center gap-1 text-xs px-2 py-1 rounded border border-border hover:bg-muted transition-colors`,title:n(`activity:collab.leaveTitle`),children:[(0,Q.jsx)(ye,{className:`w-3 h-3`}),n(`activity:collab.leave`)]}),P&&g&&(0,Q.jsxs)(`div`,{className:`absolute top-full left-0 right-0 mt-1 z-50 flex flex-col gap-2 p-3 rounded-md border border-info/40 bg-card shadow-lg text-xs`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Me,{className:`w-3.5 h-3.5 text-info`}),(0,Q.jsx)(`span`,{className:`font-medium`,children:n(`activity:collab.injectToolResult`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>_(!1),className:`ml-auto text-muted-foreground hover:text-foreground`,children:n(`activity:collab.close`)})]}),(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:n(`activity:collab.targetTool`)}),(0,Q.jsx)(`input`,{list:`collab-inject-tools`,value:v,onChange:e=>y(e.target.value),placeholder:n(`activity:collab.targetPlaceholder`),className:`px-2 py-1 rounded border border-border bg-background font-mono`}),(0,Q.jsx)(`datalist`,{id:`collab-inject-tools`,children:D.map(e=>{let t=e.toolInput===void 0?``:` — ${JSON.stringify(e.toolInput).slice(0,40)}`;return(0,Q.jsxs)(`option`,{value:e.toolUseId,children:[e.toolName??n(`activity:collab.toolFallback`),t]},e.toolUseId)})}),D.length===0&&(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:n(`activity:collab.noPendingTools`)})]}),(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:n(`activity:collab.resultContent`)}),(0,Q.jsx)(`textarea`,{value:b,onChange:e=>x(e.target.value),rows:3,placeholder:n(`activity:collab.resultPlaceholder`),className:`px-2 py-1 rounded border border-border bg-background font-mono`})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsxs)(`label`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:S,onChange:e=>C(e.target.checked)}),(0,Q.jsx)(`span`,{children:n(`activity:collab.markError`)})]}),(0,Q.jsx)(`input`,{type:`text`,value:w,onChange:e=>T(e.target.value),placeholder:n(`activity:collab.reasonPlaceholder`),className:`flex-1 px-2 py-1 rounded border border-border bg-background`})]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:N,disabled:!v,className:`self-end inline-flex items-center gap-1 text-xs px-3 py-1 rounded bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:[(0,Q.jsx)(Me,{className:`w-3 h-3`}),n(`activity:collab.queueInjection`)]})]})]})}var Ed={running:{led:`text-success`,pulse:!0},completed:{led:`text-success`,pulse:!1},failed:{led:`text-destructive`,pulse:!1},timeout:{led:`text-warning`,pulse:!1},stopped:{led:`text-muted-foreground`,pulse:!1}};function Dd({agent:e,onClose:t}){Ed[e.status];let{t:n}=V(),r=e.status===`running`,i=e.currentTool??e.lastTool,a=Date.now()-e.startedAt,[o,c]=(0,Z.useState)(!1);xr(e=>e.leaderId),e.id;let l=xr(t=>t.agentTranscripts.get(e.id)??Tr),u=Math.min(100,Math.max(0,e.ctxPct)),d=(0,Z.useCallback)(async e=>{try{await navigator.clipboard.writeText(e),c(!0),setTimeout(()=>c(!1),2e3)}catch{}},[]);(0,Z.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let f=u>=85?`bg-destructive/12 text-destructive`:u>=70?`bg-warning/12 text-warning`:`bg-muted text-muted-foreground`;return(0,Q.jsxs)(`div`,{className:`p-3 space-y-3`,children:[e.description&&(0,Q.jsx)(`div`,{className:`text-xs text-muted-foreground leading-relaxed`,children:e.description}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,Q.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 px-3 py-2`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:n(`activity:fleet.providerModel`)}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 mt-0.5`,children:[(0,Q.jsx)(yt,{className:`h-3 w-3 text-muted-foreground`}),(0,Q.jsxs)(`span`,{className:`text-xs font-mono font-medium`,children:[e.provider??`?`,`/`,e.model??`?`]})]})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 px-3 py-2`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:n(`activity:fleet.elapsed`)}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 mt-0.5`,children:[(0,Q.jsx)(Zt,{className:`h-3 w-3 text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`text-xs font-mono tabular`,children:Fs(a)}),r&&(0,Q.jsxs)(`span`,{className:`text-[10px] text-success`,children:[`· `,n(`activity:fleet.running`)]})]})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 px-3 py-2`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:n(`activity:fleet.iterations`)}),(0,Q.jsx)(`span`,{className:`block text-xs font-mono font-medium mt-0.5 tabular`,children:e.iteration})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 px-3 py-2`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:n(`activity:fleet.toolCalls`)}),(0,Q.jsx)(`span`,{className:`block text-xs font-mono font-medium mt-0.5 tabular`,children:e.toolCalls})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 px-3 py-2`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:n(`activity:fleet.cost`)}),(0,Q.jsx)(`span`,{className:`block text-xs font-mono font-medium mt-0.5 tabular`,children:Ns(e.costUsd)})]}),e.extensions>0&&(0,Q.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 px-3 py-2`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:n(`activity:fleet.budgetExtensions`)}),(0,Q.jsxs)(`span`,{className:`block text-xs font-mono font-medium mt-0.5 tabular`,children:[`⚡×`,e.extensions]})]})]}),r&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:n(`activity:fleet.activity`)}),(0,Q.jsx)(oc,{bins:e.sparklineBins,className:`font-mono`})]}),e.budgetWarning&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg bg-warning/10 border border-warning/25 text-xs`,children:[(0,Q.jsx)(Tt,{className:`h-3.5 w-3.5 text-warning shrink-0`}),(0,Q.jsx)(`span`,{className:`text-warning`,children:n(`activity:fleet.budgetWarning`,{kind:e.budgetWarning.kind,used:e.budgetWarning.used,limit:e.budgetWarning.limit})})]}),e.maxContext>0&&(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between text-[10px]`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:n(`activity:fleet.contextWindow`)}),(0,Q.jsxs)(`span`,{className:G(`tabular font-medium`,f.replace(/bg-\S+\s*/g,``)),children:[u,`%`]})]}),(0,Q.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded-full bg-muted`,children:(0,Q.jsx)(`div`,{className:G(`h-full rounded-full transition-all`,u>=85?`bg-destructive`:u>=70?`bg-warning`:`bg-primary`),style:{width:`${Math.max(2,u)}%`}})}),(0,Q.jsx)(`div`,{className:`text-[10px] text-muted-foreground tabular text-right`,children:n(`activity:fleet.tokensUsed`,{used:Ps(e.ctxTokens),max:Ps(e.maxContext)})})]}),i&&(0,Q.jsxs)(`div`,{className:G(`flex items-center gap-2 rounded-lg border px-3 py-2`,r?`border-primary/30 bg-primary/[0.04]`:`border-border bg-muted/30`),children:[(0,Q.jsx)(Mn,{className:G(`h-3.5 w-3.5`,r?`text-primary animate-pulse`:`text-muted-foreground`)}),(0,Q.jsx)(`span`,{className:`text-xs font-mono`,children:i}),(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground ml-auto`,children:e.currentTool?n(`activity:fleet.toolRunning`):n(`activity:fleet.lastTool`)})]}),(0,Q.jsx)(Cc,{entries:l,agentName:e.name,compact:!0,maxHeightClassName:`max-h-80`}),e.error&&(0,Q.jsxs)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/5 p-3`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] font-semibold text-destructive uppercase tracking-wider`,children:n(`activity:fleet.error`)}),(0,Q.jsx)(`p`,{className:`text-xs text-destructive/90 mt-1 leading-relaxed`,children:e.error.message})]}),e.finalText?(0,Q.jsxs)(`div`,{className:`rounded-lg border bg-muted/20 p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wider`,children:n(`activity:fleet.finalOutput`)}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>d(e.finalText),className:`flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] text-muted-foreground hover:text-foreground hover:bg-muted transition-colors`,title:n(`activity:fleet.copyOutput`),children:[o?(0,Q.jsx)(Wn,{className:`h-3 w-3 text-success`}):(0,Q.jsx)(s,{className:`h-3 w-3`}),n(o?`common:action.copied`:`common:action.copy`)]})]}),(0,Q.jsx)(`pre`,{className:`text-xs whitespace-pre-wrap font-mono text-foreground/80 leading-relaxed max-h-64 overflow-y-auto`,children:e.finalText})]}):e.partialText?(0,Q.jsxs)(`div`,{className:`rounded-lg border bg-muted/20 p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wider`,children:n(`activity:fleet.liveOutput`)}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>d(e.partialText),className:`flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] text-muted-foreground hover:text-foreground hover:bg-muted transition-colors`,title:n(`activity:fleet.copyOutput`),children:[o?(0,Q.jsx)(Wn,{className:`h-3 w-3 text-success`}):(0,Q.jsx)(s,{className:`h-3 w-3`}),n(o?`common:action.copied`:`common:action.copy`)]})]}),(0,Q.jsx)(`pre`,{className:`text-xs whitespace-pre-wrap font-mono text-foreground/80 leading-relaxed max-h-48 overflow-y-auto`,children:e.partialText})]}):r?(0,Q.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border p-3 text-center`,children:[(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`activity:fleet.waitingOutput`)}),(0,Q.jsx)(`p`,{className:`text-[10px] text-muted-foreground/75 mt-0.5`,children:n(`activity:fleet.outputHint`)})]}):null,e.toolLog.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wider`,children:n(`activity:fleet.toolLog`,{count:e.toolLog.length})}),(0,Q.jsxs)(`div`,{className:`max-h-40 overflow-y-auto space-y-0.5`,children:[e.toolLog.slice(0,15).map((e,t)=>(0,Q.jsxs)(`div`,{className:G(`flex items-center gap-2 rounded px-2 py-1 text-[10px]`,e.ok?`bg-muted/30`:`bg-destructive/5 border border-destructive/20`),children:[(0,Q.jsx)(`span`,{className:G(`led shrink-0`,e.ok?`text-success`:`text-destructive`)}),(0,Q.jsx)(`span`,{className:`font-mono truncate flex-1`,children:e.name}),(0,Q.jsxs)(`span`,{className:`tabular text-muted-foreground`,children:[e.durationMs,`ms`]}),!e.ok&&(0,Q.jsx)(`span`,{className:`text-destructive font-medium`,children:n(`activity:fleet.fail`)})]},`${e.name}-${e.at}-${t}`)),e.toolLog.length>15&&(0,Q.jsx)(`p`,{className:`text-[9px] text-muted-foreground text-center px-2 py-0.5`,children:n(`activity:fleet.moreTools`,{count:e.toolLog.length-15})})]})]})]})}function Od({a:e,onClick:t}){let n=Ed[e.status],{t:r}=V(),i=e.status===`running`,a=e.currentTool??e.lastTool,o=Math.min(100,Math.max(0,e.ctxPct));return(0,Q.jsxs)(`button`,{type:`button`,onClick:t,className:G(`flex min-w-[12rem] max-w-[15rem] flex-col gap-1 rounded-lg border p-2 transition-colors text-left cursor-pointer`,`hover:border-primary/40 hover:bg-primary/[0.06]`,i?`border-primary/30 bg-primary/[0.04]`:`border-border bg-card opacity-85`),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,Q.jsx)(`span`,{className:G(`led shrink-0`,n.led,n.pulse&&`led-pulse`)}),(0,Q.jsx)(`span`,{className:`truncate text-[11px] font-semibold text-foreground`,title:e.name,children:e.name}),(0,Q.jsxs)(`span`,{className:`tabular ml-auto shrink-0 text-[10px] text-muted-foreground`,children:[e.iteration,`it · `,e.toolCalls,`t`]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[e.model&&(0,Q.jsxs)(`span`,{className:`flex items-center gap-0.5 text-[10px] text-muted-foreground truncate`,title:`${e.provider??``}/${e.model}`,children:[(0,Q.jsx)(yt,{className:`h-2.5 w-2.5 shrink-0`}),(0,Q.jsx)(`span`,{className:`truncate font-mono`,children:e.model})]}),(0,Q.jsx)(`span`,{className:`tabular text-[10px] text-foreground/75 ml-auto`,children:Ns(e.costUsd)})]}),a&&(0,Q.jsxs)(`div`,{className:G(`flex items-center gap-1 text-[10px] truncate`,i?`text-primary`:`text-muted-foreground`),title:e.currentTool?r(`activity:fleet.cardRunning`,{tool:a}):r(`activity:fleet.cardLastTool`,{tool:a}),children:[(0,Q.jsx)(Mn,{className:G(`h-2.5 w-2.5 shrink-0`,i&&`animate-pulse`)}),(0,Q.jsx)(`span`,{className:`truncate font-mono`,children:a})]}),i&&e.maxContext>0&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,title:r(`activity:fleet.contextPercent`,{pct:o}),children:[(0,Q.jsx)(`div`,{className:`h-1 flex-1 overflow-hidden rounded-full bg-muted`,children:(0,Q.jsx)(`div`,{className:G(`h-full rounded-full transition-all`,o>=85?`bg-destructive`:o>=70?`bg-warning`:`bg-primary`),style:{width:`${Math.max(2,o)}%`}})}),(0,Q.jsx)(`span`,{className:`tabular text-[9px] text-muted-foreground`,children:e.maxContext>0?`${o}%`:`—`})]}),e.error&&(0,Q.jsx)(`div`,{className:`truncate rounded bg-destructive/10 px-1 py-0.5 text-[9px] text-destructive`,title:e.error.message,children:e.error.message})]})}function kd({className:e}){let t=xr(e=>e.agents),{t:n}=V(),[r,i]=(0,Z.useState)(!0),[a,o]=(0,Z.useState)(null),s=(0,Z.useMemo)(()=>{let e=Array.from(t.values());return e.sort(Ir),e},[t]),c=a?s.find(e=>e.id===a):null;if(s.length===0)return null;let l=yr(s),u=s.reduce((e,t)=>e+(t.costUsd??0),0),d=r&&s.length>=3;return(0,Q.jsxs)(`div`,{className:G(`flex min-h-0 min-w-0 gap-3`,e),children:[(0,Q.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col rounded-lg border border-border bg-card/50 backdrop-blur-sm overflow-hidden`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>i(e=>!e),className:`flex w-full items-center gap-2 px-3 py-1.5 text-left hover:bg-muted/30 transition-colors shrink-0`,children:[(0,Q.jsx)(Ee,{className:`h-3.5 w-3.5 text-primary`}),(0,Q.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground`,children:`Fleet`}),(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5 ml-auto text-[10px]`,children:[l.running>0&&(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 text-success`,children:[(0,Q.jsx)(`span`,{className:`led led-pulse text-success`}),l.running]}),l.completed>0&&(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:n(`activity:fleet.doneCount`,{count:l.completed})}),l.failed>0&&(0,Q.jsx)(`span`,{className:`text-destructive`,children:n(`activity:fleet.errCount`,{count:l.failed})}),u>0&&(0,Q.jsx)(`span`,{className:`tabular text-foreground/70`,children:Ns(u)})]}),d?(0,Q.jsx)(Kn,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}):(0,Q.jsx)(b,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`})]}),!d&&(0,Q.jsx)(`div`,{children:(0,Q.jsx)(`div`,{className:`flex gap-2 overflow-x-auto px-2 pb-2 min-h-0`,children:s.map(e=>(0,Q.jsx)(Od,{a:e,onClick:()=>o(a===e.id?null:e.id)},e.id))})})]}),c&&(0,Q.jsx)(`div`,{className:`w-96 max-w-full shrink-0 rounded-lg border border-border bg-card shadow-lg overflow-hidden`,children:(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,Q.jsxs)(`div`,{className:`shrink-0 flex items-center justify-between px-3 py-2 border-b bg-muted/20`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-semibold text-foreground truncate`,children:c.name}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>o(null),className:`p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors`,"aria-label":n(`common:action.close`),children:(0,Q.jsx)(vn,{className:`h-3.5 w-3.5`})})]}),(0,Q.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Q.jsx)(Dd,{agent:c,onClose:()=>o(null)})})]})})]})}var Ad={up:(0,Q.jsx)(Jn,{className:`h-3.5 w-3.5 text-success`}),down:(0,Q.jsx)(Ke,{className:`h-3.5 w-3.5 text-destructive`}),stable:(0,Q.jsx)(Ae,{className:`h-3.5 w-3.5 text-warning`})},jd={active:{color:`text-success`,bg:`bg-success/10`,labelKey:`statusActive`},paused:{color:`text-warning`,bg:`bg-warning/10`,labelKey:`statusPaused`},completed:{color:`text-info`,bg:`bg-info/10`,labelKey:`statusDone`},failed:{color:`text-destructive`,bg:`bg-destructive/10`,labelKey:`statusFailed`},abandoned:{color:`text-muted-foreground`,bg:`bg-muted`,labelKey:`statusAbandoned`}};function Md({goal:e,className:t}){let{t:n}=V(),[r,i]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{let e=pr();e?.send?.({type:`goal.get`});let t=setInterval(()=>{e?.send?.({type:`goal.get`})},1e4);return()=>clearInterval(t)},[]),(0,Z.useEffect)(()=>{(!e||e.goalState===`completed`||e.goalState===`failed`||e.goalState===`abandoned`)&&i(!0)},[e]);let a=e?.deliverables??[],o=[...e?.journal??[]].reverse();if(!e||e.goalState===`completed`||e.goalState===`failed`||e.goalState===`abandoned`)return null;let s=jd[e.goalState],c=e.deliverables?.filter(e=>e.status===`done`).length??0,l=e.deliverables?.length??0,u=e.progressTrend?Ad[e.progressTrend]:null;return(0,Q.jsxs)(`div`,{className:G(`rounded-lg border border-border bg-card/60 backdrop-blur-sm`,t),children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>i(e=>!e),className:`flex w-full items-center gap-2 px-3 py-2.5 text-left hover:bg-accent/40 rounded-t-lg transition-colors`,children:[(0,Q.jsx)(M,{className:`h-4 w-4 text-primary`}),(0,Q.jsx)(`span`,{className:`text-xs font-semibold text-foreground flex-1 min-w-0 truncate`,children:n(`activity:goal.heading`)}),(0,Q.jsx)(`span`,{className:G(`inline-flex items-center px-1.5 py-0.5 rounded-full text-[10px] font-medium shrink-0`,s.bg,s.color),children:n(`activity:goal.${s.labelKey}`)}),r?(0,Q.jsx)(Kn,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}):(0,Q.jsx)(b,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`})]}),!r&&(0,Q.jsxs)(`div`,{className:`px-3 pb-3 space-y-3 border-t pt-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-xs text-foreground leading-relaxed whitespace-pre-wrap break-words`,children:e.goal}),e.refinedGoal&&e.refinedGoal!==e.goal&&(0,Q.jsxs)(`div`,{className:`mt-1.5 p-2 rounded bg-accent/40 border border-border/50`,children:[(0,Q.jsx)(`p`,{className:`text-[10px] text-muted-foreground mb-0.5 uppercase tracking-wider font-medium`,children:n(`activity:goal.refined`)}),(0,Q.jsx)(`p`,{className:`text-xs leading-relaxed whitespace-pre-wrap break-words`,children:e.refinedGoal})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between text-[10px]`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground uppercase tracking-wider font-medium`,children:n(`activity:goal.progress`)}),(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 tabular-nums`,children:[u,(0,Q.jsxs)(`span`,{className:`font-medium text-foreground`,children:[e.progress,`%`]})]})]}),(0,Q.jsx)(`div`,{className:`h-1.5 bg-muted rounded-full overflow-hidden`,children:(0,Q.jsx)(`div`,{className:G(`h-full transition-all duration-700 rounded-full`,e.progress>=80?`bg-success`:e.progress>=50?`bg-warning`:`bg-primary`),style:{width:`${e.progress>0?Math.max(2,e.progress):0}%`}})}),e.progressNote&&(0,Q.jsx)(`p`,{className:`text-[10px] text-muted-foreground italic`,children:e.progressNote})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] text-muted-foreground`,children:[(0,Q.jsx)(Zt,{className:`h-3 w-3`}),(0,Q.jsx)(`span`,{className:`tabular-nums font-medium`,children:e.iterations}),(0,Q.jsx)(`span`,{children:n(`activity:goal.iterations`)}),e.lastStatus&&(0,Q.jsx)(`span`,{className:`text-border`,children:`·`}),e.lastStatus&&(0,Q.jsx)(`span`,{className:`truncate`,children:e.lastStatus})]}),l>0&&(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between text-[10px] text-muted-foreground uppercase tracking-wider font-medium`,children:[(0,Q.jsx)(`span`,{children:n(`activity:goal.deliverables`)}),(0,Q.jsxs)(`span`,{className:`tabular-nums`,children:[c,`/`,l]})]}),(0,Q.jsx)(`ul`,{className:`space-y-0.5`,children:a.map(e=>(0,Q.jsxs)(`li`,{className:`flex items-start gap-1.5 text-[11px]`,children:[e.status===`done`?(0,Q.jsx)(Gt,{className:`h-3 w-3 text-success mt-0.5 shrink-0`}):(0,Q.jsx)(At,{className:`h-3 w-3 text-muted-foreground/70 mt-0.5 shrink-0`}),(0,Q.jsx)(`span`,{className:G(`leading-snug`,e.status===`done`?`text-muted-foreground line-through`:`text-foreground`),children:e.text})]},e.id))})]}),o.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`p`,{className:`text-[10px] text-muted-foreground uppercase tracking-wider font-medium`,children:n(`activity:goal.recentActivity`)}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:o.map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex items-start gap-1.5 text-[10px] text-muted-foreground`,children:[(0,Q.jsxs)(`span`,{className:`font-mono tabular-nums shrink-0 text-foreground/60`,children:[`#`,e.iteration]}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.task||e.status||e.progressNote||`…`})]},`${e.iteration}-${t}`))})]})]})]})}var Nd={in_progress:0,pending:1,completed:2};function Pd(){let{t:e}=V(),t=K(e=>e.todos),n=K(e=>e.session?.id),[r,i]=(0,Z.useState)(new Set),a=pr();(0,Z.useEffect)(()=>{n&&a.send({type:`todos.get`,payload:{sessionId:n}})},[n,a]);let o=(0,Z.useCallback)(e=>{a.removeTodo(e)},[a]),s=(0,Z.useCallback)(e=>{if(e.status===`in_progress`)return;let t=e.status===`completed`?`pending`:`completed`;a.updateTodoStatus(e.id,t)},[a]),c=[...t].sort((e,t)=>(Nd[e.status]??9)-(Nd[t.status]??9)),l=c.filter(e=>e.status===`completed`).length,u=c.filter(e=>e.status===`in_progress`),d=c.filter(e=>e.status===`pending`),f=c.filter(e=>e.status===`completed`),p=f.length>0,m=r.has(`completed`),h=e=>{i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},g=t=>{let n=t.status===`in_progress`&&t.activeForm?t.activeForm:t.content,r=t.status===`in_progress`,i=t.status===`completed`,a=!r;return(0,Q.jsxs)(`div`,{className:G(`relative px-3 py-1.5 flex items-start gap-2 text-[13px] group transition-colors`,a&&`hover:bg-accent/40`,r?`bg-warning/8`:i?`bg-success/5`:`bg-background`),children:[a&&(0,Q.jsx)(`button`,{type:`button`,className:`absolute inset-0 cursor-pointer`,"aria-label":e(`activity:todos.toggleAria`,{content:t.content}),onClick:()=>s(t)}),(0,Q.jsx)(`span`,{className:`pointer-events-none relative mt-0.5 shrink-0`,children:i?(0,Q.jsx)(Gt,{className:`w-3.5 h-3.5 text-success`}):r?(0,Q.jsx)(Zt,{className:`w-3.5 h-3.5 text-warning animate-spin`}):(0,Q.jsx)(At,{className:G(`w-3.5 h-3.5 transition-colors`,`text-muted-foreground/65 group-hover:text-success`)})}),(0,Q.jsx)(`span`,{className:G(`pointer-events-none relative leading-snug flex-1 min-w-0`,r?`text-warning font-medium`:i?`text-muted-foreground line-through`:`text-foreground/80`),children:n}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>o(t.id),className:`relative shrink-0 p-0.5 rounded opacity-0 group-hover:opacity-50 hover:opacity-100 hover:bg-destructive/10 transition-all`,title:e(`activity:todos.removeTitle`),"aria-label":e(`activity:todos.removeAria`,{content:t.content}),children:(0,Q.jsx)(C,{className:`w-3 h-3 text-muted-foreground`})})]},t.id)};return t.length===0?null:(0,Q.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/50 backdrop-blur-sm overflow-hidden`,children:[(0,Q.jsxs)(`div`,{className:`px-3 py-1.5 flex items-center gap-2 border-b border-border/50`,children:[(0,Q.jsx)(`h2`,{className:`text-[11px] font-semibold text-foreground uppercase tracking-wider`,children:e(`activity:work.todos`)}),(0,Q.jsxs)(`span`,{className:`tabular text-[10px] text-muted-foreground ml-auto`,children:[l,`/`,t.length]})]}),u.length>0&&(0,Q.jsx)(`div`,{className:`border-b border-border/30 last:border-b-0`,children:u.map(g)}),d.length>0&&(0,Q.jsx)(`div`,{className:`border-b border-border/30 last:border-b-0`,children:d.map(g)}),p&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>h(`completed`),className:`w-full px-3 py-1 flex items-center gap-1.5 text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:(0,Q.jsxs)(`span`,{className:`tabular`,children:[m?`▶`:`▼`,` `,e(`activity:todos.completedCount`,{count:f.length})]})}),!m&&f.map(g)]})]})}var Fd={pending:{icon:(0,Q.jsx)(At,{className:`w-3.5 h-3.5`}),labelKey:`statusPending`,color:`text-muted-foreground/70`},in_progress:{icon:(0,Q.jsx)(Zt,{className:`w-3.5 h-3.5 animate-spin`}),labelKey:`statusInProgress`,color:`text-warning`},blocked:{icon:(0,Q.jsx)(mn,{className:`w-3.5 h-3.5`}),labelKey:`statusBlocked`,color:`text-warning`},failed:{icon:(0,Q.jsx)(un,{className:`w-3.5 h-3.5`}),labelKey:`statusFailed`,color:`text-destructive`},review:{icon:(0,Q.jsx)(c,{className:`w-3.5 h-3.5`}),labelKey:`statusReview`,color:`text-info`},completed:{icon:(0,Q.jsx)(Gt,{className:`w-3.5 h-3.5`}),labelKey:`statusDone`,color:`text-success`}},Id={critical:`text-destructive`,high:`text-warning`,medium:`text-warning/85`,low:`text-muted-foreground`},Ld={feature:`⚡`,bugfix:`🐛`,refactor:`♻️`,docs:`📝`,test:`🧪`,chore:`🔧`};function Rd(){let{t:e}=V(),[t,n]=(0,Z.useState)([]),[r,i]=(0,Z.useState)(new Set),a=pr(),o=(0,Z.useRef)(null);(0,Z.useEffect)(()=>(a.getTasks(),o.current=a.on(`tasks.updated`,e=>{let t=e?.payload;t?.tasks&&n(t.tasks)}),()=>{o.current?.()}),[a]);let s=(0,Z.useCallback)(e=>{i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),c=(0,Z.useCallback)((e,t)=>{a.updateTaskStatus(e,t)},[a]),l=[`in_progress`,`blocked`,`review`,`pending`,`failed`,`completed`],u=[...t].sort((e,t)=>l.indexOf(e.status)-l.indexOf(t.status)),d=new Map;for(let e of u){let t=d.get(e.status)??[];t.push(e),d.set(e.status,t)}let f=t.filter(e=>e.status===`completed`).length;return t.length===0?null:(0,Q.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/50 backdrop-blur-sm overflow-hidden`,children:[(0,Q.jsxs)(`div`,{className:`px-3 py-1.5 flex items-center gap-2 border-b border-border/50`,children:[(0,Q.jsx)(`h2`,{className:`text-[11px] font-semibold text-foreground uppercase tracking-wider`,children:e(`activity:work.tasks`)}),(0,Q.jsxs)(`span`,{className:`tabular text-[10px] text-muted-foreground ml-auto`,children:[f,`/`,t.length]})]}),l.map(t=>{let n=d.get(t);if(!n||n.length===0)return null;let i=Fd[t],a=r.has(t);return(0,Q.jsxs)(`div`,{className:`border-b border-border/30 last:border-b-0`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>s(t),className:`w-full px-3 py-1 flex items-center gap-1.5 text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:(0,Q.jsxs)(`span`,{className:`tabular`,children:[a?`▶`:`▼`,` `,n.length,` `,e(`activity:task.${i.labelKey}`)]})}),!a&&n.map(t=>(0,Q.jsxs)(`div`,{className:G(`px-3 py-1.5 flex items-start gap-2 text-[13px] group`,t.status===`in_progress`?`bg-warning/8`:``),children:[(0,Q.jsx)(`span`,{className:G(`mt-0.5 shrink-0`,i.color),children:i.icon}),(0,Q.jsxs)(`span`,{className:`leading-snug flex-1 min-w-0`,children:[(0,Q.jsxs)(`span`,{className:G(t.status===`completed`?`text-muted-foreground line-through`:`text-foreground/80`),children:[Ld[t.type],` `,t.title]}),t.priority!==`medium`&&(0,Q.jsx)(`span`,{className:G(`ml-1 text-[10px]`,Id[t.priority]),children:t.priority}),t.assignee&&(0,Q.jsxs)(`span`,{className:`ml-1 text-[10px] text-muted-foreground`,children:[`@`,t.assignee]}),t.estimateHours&&(0,Q.jsxs)(`span`,{className:`ml-1 text-[10px] text-muted-foreground`,children:[t.estimateHours,`h`]})]}),(0,Q.jsxs)(`div`,{className:`flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity shrink-0`,children:[t.status!==`in_progress`&&t.status!==`completed`&&(0,Q.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c(t.id,`in_progress`)},className:`px-1.5 py-0.5 text-[9px] rounded bg-primary/15 text-primary hover:bg-primary/25 transition-colors`,title:e(`activity:task.startTitle`),children:e(`common:action.start`)}),t.status===`in_progress`&&(0,Q.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c(t.id,`completed`)},className:`px-1.5 py-0.5 text-[9px] rounded bg-success/15 text-success hover:bg-success/25 transition-colors`,title:e(`activity:task.completeTitle`),children:e(`activity:task.statusDone`)}),t.status!==`completed`&&t.status!==`failed`&&(0,Q.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c(t.id,`failed`)},className:`px-1.5 py-0.5 text-[9px] rounded bg-destructive/15 text-destructive hover:bg-destructive/25 transition-colors`,title:e(`activity:task.failTitle`),children:e(`activity:task.fail`)})]})]},t.id))]},t)})]})}var zd={open:{icon:(0,Q.jsx)(At,{className:`w-3.5 h-3.5`}),labelKey:`statusOpen`,color:`text-muted-foreground/70`},in_progress:{icon:(0,Q.jsx)(Zt,{className:`w-3.5 h-3.5 animate-spin`}),labelKey:`statusInProgress`,color:`text-warning`},done:{icon:(0,Q.jsx)(Gt,{className:`w-3.5 h-3.5`}),labelKey:`statusDone`,color:`text-success`}};function Bd(){let{t:e}=V(),[t,n]=(0,Z.useState)([]),[r,i]=(0,Z.useState)(new Set),a=pr(),o=(0,Z.useRef)(null);(0,Z.useEffect)(()=>(a.getPlan(),o.current=a.on(`plan.updated`,e=>{let t=e?.payload;t?.plan?.items&&n(t.plan.items)}),()=>{o.current?.()}),[a]);let s=(0,Z.useCallback)(e=>{i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),c=(0,Z.useCallback)((e,t)=>{a.updatePlanItem(e.id,t)},[a]),l=[`in_progress`,`open`,`done`],u=[...t].sort((e,t)=>l.indexOf(e.status)-l.indexOf(t.status)),d=new Map;for(let e of u){let t=d.get(e.status)??[];t.push(e),d.set(e.status,t)}let f=t.filter(e=>e.status===`done`).length;return t.length===0?null:(0,Q.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/50 backdrop-blur-sm overflow-hidden`,children:[(0,Q.jsxs)(`div`,{className:`px-3 py-1.5 flex items-center gap-2 border-b border-border/50`,children:[(0,Q.jsxs)(`h2`,{className:`text-[11px] font-semibold text-foreground uppercase tracking-wider`,children:[`📋 `,e(`activity:work.plan`)]}),(0,Q.jsxs)(`span`,{className:`tabular text-[10px] text-muted-foreground ml-auto`,children:[f,`/`,t.length]})]}),l.map(t=>{let n=d.get(t);if(!n||n.length===0)return null;let i=zd[t],a=r.has(t);return(0,Q.jsxs)(`div`,{className:`border-b border-border/30 last:border-b-0`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>s(t),className:`w-full px-3 py-1 flex items-center gap-1.5 text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:(0,Q.jsxs)(`span`,{className:`tabular`,children:[a?`▶`:`▼`,` `,n.length,` `,e(`activity:plan.${i.labelKey}`)]})}),!a&&n.map(t=>(0,Q.jsxs)(`div`,{className:G(`px-3 py-1.5 flex items-start gap-2 text-[13px] group`,t.status===`in_progress`?`bg-warning/8`:``),children:[(0,Q.jsx)(`span`,{className:G(`mt-0.5 shrink-0`,i.color),children:i.icon}),(0,Q.jsx)(`span`,{className:G(`leading-snug flex-1 min-w-0`,t.status===`done`?`text-muted-foreground line-through`:`text-foreground/80`),children:t.title}),(0,Q.jsxs)(`div`,{className:`flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity shrink-0`,children:[t.status===`open`&&(0,Q.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c(t,`in_progress`)},className:`px-1.5 py-0.5 text-[9px] rounded bg-primary/15 text-primary hover:bg-primary/25 transition-colors`,title:e(`activity:plan.startTitle`),children:e(`common:action.start`)}),t.status!==`done`&&(0,Q.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c(t,`done`)},className:`px-1.5 py-0.5 text-[9px] rounded bg-success/15 text-success hover:bg-success/25 transition-colors`,title:e(`activity:plan.doneTitle`),children:e(`activity:plan.statusDone`)}),t.status===`done`&&(0,Q.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c(t,`open`)},className:`px-1.5 py-0.5 text-[9px] rounded bg-muted text-muted-foreground hover:bg-accent hover:text-foreground transition-colors`,title:e(`activity:plan.reopenTitle`),children:e(`activity:plan.reopen`)})]})]},t.id))]},t)})]})}var Vd=[{id:`todos`,labelKey:`work.todos`,icon:`✅`},{id:`tasks`,labelKey:`work.tasks`,icon:`📋`},{id:`plan`,labelKey:`work.plan`,icon:`🗺️`}];function Hd(){let{t:e}=V(),t=U(e=>e.workDashboardTab),n=U(e=>e.setWorkDashboardTab);return(0,Q.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/50 backdrop-blur-sm overflow-hidden`,children:[(0,Q.jsx)(`div`,{className:`flex border-b border-border/50 bg-muted/30`,children:Vd.map(r=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>n(r.id),className:G(`flex items-center gap-1 px-3 py-1.5 text-[11px] font-medium transition-colors`,`border-b-2 -mb-px`,t===r.id?`border-primary text-foreground bg-background`:`border-transparent text-muted-foreground hover:text-foreground hover:bg-accent/30`),children:[(0,Q.jsx)(`span`,{className:`text-xs`,children:r.icon}),e(`activity:${r.labelKey}`)]},r.id))}),(0,Q.jsx)(`div`,{className:G(t===`todos`?`block`:`hidden`),children:(0,Q.jsx)(Pd,{})}),(0,Q.jsx)(`div`,{className:G(t===`tasks`?`block`:`hidden`),children:(0,Q.jsx)(Rd,{})}),(0,Q.jsx)(`div`,{className:G(t===`plan`?`block`:`hidden`),children:(0,Q.jsx)(Bd,{})})]})}var Ud={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))`,foreground:`hsl(var(--foreground))`},Wd=[Ud.primary,Ud.info,Ud.success,Ud.warning,Ud.destructive,Ud.muted],Gd=e=>e.replace(/^wstack\/ap\//,``);function Kd(e){return[...e].sort((e,t)=>e.allocatedAt-t.allocatedAt).map((e,t)=>({handle:e,color:Wd[t%Wd.length],y:60+t*48}))}var qd={allocating:{dash:`4 4`,opacity:.4},active:{dash:`4 4`,opacity:.6},committing:{dash:`4 4`,opacity:.8},merging:{dash:`0`,opacity:.9},merged:{dash:`0`,opacity:1},"needs-review":{dash:`2 3`,opacity:.9},failed:{dash:`2 3`,opacity:.6}};function Jd({worktrees:e,baseBranch:n}){let{t:r}=V(),i=Kd(e),a=Math.max(120,60+i.length*48+20);return(0,Q.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-border/70 bg-card/70 p-3`,children:(0,Q.jsxs)(`svg`,{width:`100%`,height:a,viewBox:`0 0 600 ${a}`,className:`min-w-[420px]`,role:`img`,"aria-label":r(`activity:worktree.graphAria`,{base:n||`HEAD`}),children:[(0,Q.jsx)(`title`,{children:r(`activity:worktree.graphAria`,{base:n||`HEAD`})}),(0,Q.jsx)(`line`,{x1:40,y1:20,x2:40,y2:a-10,stroke:Ud.primary,strokeWidth:3}),(0,Q.jsx)(`text`,{x:36,y:14,fontSize:11,fill:Ud.muted,children:n||`HEAD`}),(0,Q.jsx)(`circle`,{cx:40,cy:20,r:5,fill:Ud.primary}),i.map(e=>{let i=qd[e.handle.status]??t(qd.active),a=e.handle.status===`merged`,o=e.handle.status===`needs-review`||e.handle.status===`failed`;return(0,Q.jsxs)(`g`,{className:`transition-all duration-500`,children:[(0,Q.jsx)(`path`,{d:`M 40 ${e.y-24} C 100 ${e.y-24}, 160 ${e.y}, 220 ${e.y}`,fill:`none`,stroke:e.color,strokeWidth:2,strokeDasharray:i.dash,opacity:i.opacity}),a?(0,Q.jsx)(`path`,{d:`M 220 ${e.y} C 160 ${e.y+20}, 100 ${e.y+24}, 40 ${e.y+24}`,fill:`none`,stroke:Ud.success,strokeWidth:2,opacity:.9}):null,(0,Q.jsx)(`circle`,{cx:220,cy:e.y,r:5,fill:o?Ud.destructive:e.color}),(0,Q.jsx)(`text`,{x:232,y:e.y-6,fontSize:12,fill:Ud.foreground,fontFamily:`monospace`,children:Gd(e.handle.branch)}),(0,Q.jsx)(`text`,{x:232,y:e.y+10,fontSize:10,fill:Ud.muted,children:o?`⚠ ${e.handle.status}`:a?r(`activity:worktree.mergedLabel`,{base:n}):`+${e.handle.insertions}/-${e.handle.deletions} · ${e.handle.ownerLabel}`})]},e.handle.handleId)})]})})}var Yd={allocating:{icon:`○`,labelKey:`statusAllocating`,tint:`border-muted-foreground/40`,dot:`bg-muted-foreground`},active:{icon:`●`,labelKey:`statusActive`,tint:`border-warning/40`,dot:`bg-warning animate-pulse`},committing:{icon:`◐`,labelKey:`statusCommitting`,tint:`border-primary/40`,dot:`bg-primary animate-pulse`},merging:{icon:`⇡`,labelKey:`statusMerging`,tint:`border-info/40`,dot:`bg-info animate-pulse`},merged:{icon:`✓`,labelKey:`statusMerged`,tint:`border-success/40`,dot:`bg-success`},"needs-review":{icon:`⚠`,labelKey:`statusConflict`,tint:`border-destructive/50`,dot:`bg-destructive`},failed:{icon:`✗`,labelKey:`statusFailed`,tint:`border-destructive/50`,dot:`bg-destructive`}};function Xd(e){return Yd[e]??{icon:`?`,labelKey:``,tint:`border-border`,dot:`bg-muted-foreground`}}var Zd=e=>e.replace(/^wstack\/ap\//,``);function Qd({worktrees:e,baseBranch:t}){let{t:n}=V(),r=[...e].sort((e,t)=>e.allocatedAt-t.allocatedAt);return(0,Q.jsxs)(`div`,{className:`rounded-lg border bg-card/50 backdrop-blur-sm px-3 py-3`,children:[(0,Q.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`span`,{className:`font-semibold tracking-wide uppercase text-[10px]`,children:n(`activity:worktree.lanesHeading`)}),(0,Q.jsxs)(`span`,{className:`opacity-60`,children:[`· `,n(`activity:worktree.base`)]}),(0,Q.jsx)(`code`,{className:`font-mono text-primary`,children:t||`HEAD`}),(0,Q.jsxs)(`span`,{className:`opacity-60`,children:[`· `,n(`activity:worktree.isolatedCount`,{count:r.length})]})]}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:r.map(e=>{let t=Xd(e.status),r=e.status===`needs-review`,i=Math.min(100,e.insertions+e.deletions);return(0,Q.jsxs)(`div`,{className:G(`group relative flex items-center gap-3 rounded-lg border px-3 py-2 transition-all duration-500`,`bg-background/60 hover:bg-accent/20`,t.tint),children:[(0,Q.jsx)(`span`,{className:G(`h-2.5 w-2.5 shrink-0 rounded-full`,t.dot),"aria-hidden":!0}),(0,Q.jsx)(`code`,{className:`w-44 shrink-0 truncate font-mono text-sm`,children:Zd(e.branch)}),(0,Q.jsxs)(`span`,{className:`shrink-0 rounded bg-muted px-2 py-0.5 text-xs text-muted-foreground`,children:[`⟵ `,e.ownerLabel]}),r?(0,Q.jsx)(`span`,{className:`font-mono text-xs font-bold text-destructive`,children:n(`activity:worktree.conflictBadge`)}):(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 font-mono text-xs transition-all duration-500`,children:[(0,Q.jsxs)(`span`,{className:`text-success`,children:[`+`,e.insertions]}),(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`·`}),(0,Q.jsxs)(`span`,{className:`text-destructive`,children:[`-`,e.deletions]}),(0,Q.jsxs)(`span`,{className:`ml-1 text-muted-foreground`,children:[e.files,`f`]})]}),(0,Q.jsx)(`div`,{className:`ml-auto hidden h-1 w-24 overflow-hidden rounded-full bg-muted sm:block`,children:(0,Q.jsx)(`div`,{className:`h-full bg-gradient-to-r from-success to-destructive transition-all duration-700`,style:{width:`${i}%`}})}),(0,Q.jsx)(`span`,{className:`w-20 shrink-0 text-right text-xs text-muted-foreground`,children:t.labelKey?n(`activity:worktree.${t.labelKey}`):e.status}),e.recentActivity.length>0?(0,Q.jsxs)(`span`,{className:`absolute -bottom-2 left-9 max-w-[60%] truncate rounded bg-muted px-1.5 text-[10px] text-muted-foreground opacity-0 transition-opacity duration-300 group-hover:opacity-100`,children:[e.recentActivity[e.recentActivity.length-1]?.kind,`: `,e.recentActivity[e.recentActivity.length-1]?.text]}):null]},e.handleId)})})]})}var $d=e=>e?e.replace(/^wstack\/ap\//,``):``;function ef(){let{t:e}=V(),{client:t}=dr(),n=Nr(e=>e.orphans),r=Nr(e=>e.canClean),i=Nr(e=>e.cleanBlockedReason),a=Nr(e=>e.cleanResult),[o,s]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{t?.send?.({type:`worktree.scan`})},[t]),(0,Z.useEffect)(()=>{a&&s(!1)},[a]),n.length===0&&!a?null:(0,Q.jsxs)(`div`,{className:`rounded-md border border-warning/30 bg-warning/5 px-3 py-2 text-xs`,children:[n.length>0?(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(kt,{className:`mt-0.5 h-4 w-4 shrink-0 text-warning`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`font-medium text-warning`,children:e(`activity:worktree.orphanCount`,{count:n.length})}),(0,Q.jsx)(`div`,{className:`mt-0.5 max-h-16 overflow-auto font-mono text-[10px] text-muted-foreground`,children:n.map((e,t)=>(0,Q.jsxs)(`div`,{className:`truncate`,children:[e.kind===`branch`?`⌥ `:`▢ `,$d(e.branch)||e.dir]},`${e.kind}-${e.branch??e.dir??t}`))})]}),(0,Q.jsxs)(`button`,{type:`button`,disabled:!r||o,onClick:async()=>{let r=n.length;await mi({title:e(`activity:worktree.cleanTitle`,{count:r}),message:e(`activity:worktree.cleanMessage`),confirmLabel:e(`activity:worktree.cleanConfirm`),danger:!0})&&(s(!0),t?.send?.({type:`worktree.cleanup`}))},title:r?e(`activity:worktree.cleanButtonTitle`):i,className:`inline-flex shrink-0 items-center gap-1 rounded bg-warning px-2 py-1 font-medium text-primary-foreground hover:bg-warning/90 disabled:cursor-not-allowed disabled:opacity-50`,children:[o?(0,Q.jsx)(g,{className:`h-3.5 w-3.5 animate-spin`}):(0,Q.jsx)(ct,{className:`h-3.5 w-3.5`}),e(`activity:worktree.cleanConfirm`)]})]}):null,a&&(0,Q.jsx)(`div`,{className:a.ok?`mt-1 text-success`:`mt-1 text-destructive`,children:a.ok?e(`activity:worktree.removed`,{count:a.removed}):`✗ ${a.reason??e(`activity:worktree.cleanupFailed`)}`})]})}var tf={goal:{active:`bg-primary/12 border-primary/40 text-primary shadow-sm`,idle:`text-primary/80 hover:bg-primary/10`},"goal-state":{active:`bg-destructive/10 border-destructive/35 text-destructive shadow-sm`,idle:`text-destructive/80 hover:bg-destructive/10`},fleet:{active:`bg-success/12 border-success/35 text-success shadow-sm`,idle:`text-success/80 hover:bg-success/10`},work:{active:`bg-warning/12 border-warning/35 text-warning shadow-sm`,idle:`text-warning/80 hover:bg-warning/10`},worktrees:{active:`bg-info/12 border-info/35 text-info shadow-sm`,idle:`text-info/80 hover:bg-info/10`},collab:{active:`bg-accent border-primary/25 text-accent-foreground shadow-sm`,idle:`text-muted-foreground hover:bg-muted/60`}},nf={goal:`Goal`,"goal-state":`Goal State`,fleet:`Fleet`,work:`Work`,worktrees:`Worktrees`,collab:`Collab`},rf=[`goal`,`goal-state`,`fleet`,`work`,`worktrees`,`collab`];function af({section:e,icon:t,label:n,value:r,active:i,pulse:a,onClick:o}){let s=tf[e],{t:c}=V();return(0,Q.jsxs)(`button`,{type:`button`,onClick:o,title:c(i?`activity:dock.collapseChip`:`activity:dock.expandChip`,{label:n}),className:G(`flex items-center gap-2 h-7 px-2.5 rounded-md border text-xs font-medium shrink-0 transition-colors`,i?s.active:G(`border-border/40`,s.idle)),children:[(0,Q.jsx)(`span`,{className:G(a&&`animate-pulse`),children:t}),n,r&&(0,Q.jsx)(`span`,{className:`tabular-nums opacity-80`,children:r})]})}function of(){let e=U(e=>e.dockSection),{t}=V(),n=U(e=>e.toggleDockSection),r=U(e=>e.hiddenChips),i=U(e=>e.toggleChipHidden),a=U(e=>e.dockCustomizeOpen),o=U(e=>e.setDockCustomizeOpen),s=wr(e=>e.goal),c=jr(e=>e.phases.length),l=jr(e=>e.overallPercent),u=jr(e=>e.activePhaseId),d=Nr(e=>e.worktrees),f=K(e=>e.todos),p=xr(e=>e.agents),m=wd(),h=p.size,g=(0,Z.useMemo)(()=>Array.from(p.values()).filter(e=>e.status===`running`).length,[p]),_=f.filter(e=>e.status===`completed`).length,v=f.some(e=>e.status===`in_progress`),y=c>0,b=(0,Z.useMemo)(()=>new Set(r),[r]),x={goal:y,"goal-state":s!==null,fleet:h>0,work:!0,worktrees:d.length>0,collab:!0},S={goal:(x.goal||e===`goal`)&&!b.has(`goal`),"goal-state":(x[`goal-state`]||e===`goal-state`)&&!b.has(`goal-state`),fleet:(x.fleet||e===`fleet`)&&!b.has(`fleet`),work:(x.work||e===`work`)&&!b.has(`work`),worktrees:(x.worktrees||e===`worktrees`)&&!b.has(`worktrees`),collab:(x.collab||e===`collab`)&&!b.has(`collab`)},C=e&&S[e]?e:null;return(0,Q.jsx)(`div`,{children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 rounded-lg border border-border/70 bg-card/70 px-2 py-1.5 shadow-sm`,children:[S.goal&&(0,Q.jsx)(af,{section:`goal`,icon:(0,Q.jsx)(zt,{className:`h-3 w-3`}),label:`Goal`,value:`${l}%`,active:!1,pulse:u!=null,onClick:()=>Gr(`goal`)}),S[`goal-state`]&&s&&(0,Q.jsx)(af,{section:`goal-state`,icon:(0,Q.jsx)(M,{className:`h-3 w-3`}),label:`Goal State`,value:`${s.progress}%`,active:C===`goal-state`,pulse:s.goalState===`active`,onClick:()=>n(`goal-state`)}),S.fleet&&(0,Q.jsx)(af,{section:`fleet`,icon:(0,Q.jsx)(Ee,{className:`h-3 w-3`}),label:`Fleet`,value:`${g}/${h}`,active:C===`fleet`,pulse:g>0,onClick:()=>n(`fleet`)}),(0,Q.jsx)(af,{section:`work`,icon:(0,Q.jsx)(ae,{className:`h-3 w-3`}),label:`Work`,value:f.length>0?`${_}/${f.length}`:void 0,active:C===`work`,pulse:v,onClick:()=>n(`work`)}),S.worktrees&&(0,Q.jsx)(af,{section:`worktrees`,icon:(0,Q.jsx)(bn,{className:`h-3 w-3`}),label:`Worktrees`,value:String(d.length),active:C===`worktrees`,onClick:()=>n(`worktrees`)}),m&&(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{},className:`inline-flex h-8 max-w-full min-w-0 items-center gap-1.5 rounded-md border border-border/50 px-2.5 text-xs font-mono transition-colors hover:bg-muted/60 sm:h-7`,children:[(0,Q.jsx)(bn,{className:`h-3 w-3 shrink-0 text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate font-semibold text-foreground`,children:m.branch}),m.ahead>0&&(0,Q.jsxs)(`span`,{className:`text-success`,title:t(`activity:dock.ahead`,{count:m.ahead}),children:[`↑`,m.ahead]}),m.behind>0&&(0,Q.jsxs)(`span`,{className:`text-warning`,title:t(`activity:dock.behind`,{count:m.behind}),children:[`↓`,m.behind]}),m.added>0&&(0,Q.jsxs)(`span`,{className:`text-success`,title:t(`activity:dock.linesAdded`,{count:m.added}),children:[`+`,m.added]}),m.deleted>0&&(0,Q.jsxs)(`span`,{className:`text-destructive`,title:t(`activity:dock.linesDeleted`,{count:m.deleted}),children:[`-`,m.deleted]}),m.untracked>0&&(0,Q.jsxs)(`span`,{className:`text-muted-foreground`,title:t(`activity:dock.untrackedFiles`,{count:m.untracked}),children:[m.untracked,`?`]})]}),(0,Q.jsx)(af,{section:`collab`,icon:(0,Q.jsx)(xn,{className:`h-3 w-3`}),label:`Collab`,active:C===`collab`,onClick:()=>n(`collab`)}),(0,Q.jsxs)(Ei,{open:a,onOpenChange:o,children:[(0,Q.jsx)(Di,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,title:t(`activity:dock.customizeTitle`),className:`ml-auto inline-flex items-center justify-center h-7 w-7 rounded-md border border-border/50 text-muted-foreground hover:bg-muted/60 transition-colors shrink-0`,children:(0,Q.jsx)(ue,{className:`h-3 w-3`})})}),(0,Q.jsxs)(ji,{align:`end`,className:`w-44`,children:[(0,Q.jsx)(Fi,{children:t(`activity:dock.dockChips`)}),(0,Q.jsx)(Ii,{}),rf.map(e=>(0,Q.jsx)(Ni,{checked:!b.has(e),onCheckedChange:()=>i(e),onSelect:e=>e.preventDefault(),children:nf[e]},e))]})]})]})})}var sf={"goal-state":{title:`Goal State`,detail:`Active objective and progress`},fleet:{title:`Fleet`,detail:`Live agent roster and activity`},work:{title:`Work`,detail:`Todos, tasks, and plan`},worktrees:{title:`Worktrees`,detail:`Parallel branches and lanes`},collab:{title:`Collab`,detail:`Session participants and controls`}};function cf({sessionId:e}){let t=U(e=>e.dockSection),n=U(e=>e.setDockSection),r=wr(e=>e.goal),i=Nr(e=>e.worktrees),a=Nr(e=>e.baseBranch),[o,s]=(0,Z.useState)(`graph`),{t:c}=V(),l=t!==null&&t!==`goal`,u=l?t:null,d=u?sf[u]:null;return(0,Z.useEffect)(()=>{if(!l)return;let e=e=>{e.key===`Escape`&&n(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[l,n]),(0,Q.jsxs)(`aside`,{id:`workspace-dock-inspector`,"data-testid":l?`workspace-dock-inspector`:void 0,"aria-hidden":!l,inert:!l||void 0,"aria-label":d?`${d.title} workspace inspector`:`Workspace inspector`,className:G(`fixed inset-y-0 right-0 z-50 flex w-[calc(100vw-3rem)] max-w-none flex-col overflow-hidden border-l border-border/80 bg-card/96 shadow-[-24px_0_64px_-36px_hsl(var(--shadow-color)/0.65)] backdrop-blur-xl transition-transform duration-200 sm:w-[min(680px,48vw)] sm:max-w-[680px]`,l?`translate-x-0`:`pointer-events-none translate-x-full`),children:[(0,Q.jsxs)(`header`,{className:`relative shrink-0 border-b border-border/70 bg-muted/20 px-4 py-3 pr-12`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-foreground`,children:[(0,Q.jsx)(Kt,{className:`h-4 w-4 text-primary`}),d?.title??`Workspace`]}),(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:d?.detail??`Workspace details`}),(0,Q.jsx)(`button`,{type:`button`,"data-testid":`workspace-dock-inspector-close`,onClick:()=>n(null),className:`absolute right-3 top-3 inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,"aria-label":`Close workspace inspector`,title:`Close workspace inspector`,children:(0,Q.jsx)(vn,{className:`h-4 w-4`})})]}),(0,Q.jsxs)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain p-3 sm:p-4`,children:[u===`goal-state`&&(r?(0,Q.jsx)(Md,{goal:r}):(0,Q.jsx)(lf,{title:c(`activity:dock.noActiveGoal`),detail:c(`activity:dock.noActiveGoalDetail`)})),u===`fleet`&&(0,Q.jsx)(kd,{}),u===`worktrees`&&(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:[`graph`,`lanes`].map(e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>s(e),className:G(`rounded-md border px-2.5 py-1 text-xs capitalize transition-colors`,o===e?`border-primary/30 bg-primary/10 text-primary`:`border-border text-muted-foreground hover:text-foreground`),children:e},e))}),(0,Q.jsx)(ef,{}),o===`graph`?(0,Q.jsx)(Jd,{worktrees:i,baseBranch:a||`HEAD`}):(0,Q.jsx)(Qd,{worktrees:i,baseBranch:a||`HEAD`})]}),(0,Q.jsx)(`div`,{className:G(u===`work`?`block`:`hidden`),id:`panel-work`,children:(0,Q.jsx)(Hd,{})}),(0,Q.jsx)(`div`,{className:G(u===`collab`?`block`:`hidden`),children:(0,Q.jsx)(Td,{sessionId:e})})]})]})}function lf({title:e,detail:t}){return(0,Q.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-muted/20 px-3 py-2 text-xs`,children:[(0,Q.jsx)(`div`,{className:`font-medium text-foreground`,children:e}),(0,Q.jsx)(`div`,{className:`mt-1 text-muted-foreground`,children:t})]})}var uf=(0,Z.lazy)(()=>nr(()=>import(`./AnalyticsDashboard-DausPJOP.js`).then(e=>({default:e.AnalyticsDashboard})),__vite__mapDeps([27,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,19,18,20,22,17,21,23,28]))),df=(0,Z.lazy)(()=>nr(()=>import(`./CodeMap-T1dsXVRH.js`).then(e=>({default:e.CodeMap})),__vite__mapDeps([29,1,2,3,4,5,6,18,21]))),ff=(0,Z.lazy)(()=>nr(()=>import(`./ChronicleDashboard-CMkQ7EBt.js`).then(e=>({default:e.ChronicleDashboard})),__vite__mapDeps([30,1,2,3,4,5,6,19,18,20,28]))),pf=(0,Z.lazy)(()=>nr(()=>import(`./GoalView-Dh27cG1z.js`).then(e=>({default:e.GoalView})),__vite__mapDeps([31,1,17,2,3,4,5,6,18,7,8,9,10,11,12,13,14,15,16,19,20,21,22,23,24,25,32,33,26,34]))),mf=(0,Z.lazy)(()=>nr(()=>import(`./ChangesView-DPfs8VeV.js`).then(e=>({default:e.ChangesView})),__vite__mapDeps([35,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,19,18,20,22,17,21,23,36]))),hf=(0,Z.lazy)(()=>nr(()=>import(`./CronJobsPanel-CKQw0vat.js`).then(e=>({default:e.CronJobsPanel})),__vite__mapDeps([37,1,2,3,4,5,6,22,17,18,8,19,20,21,23,26]))),gf=(0,Z.lazy)(()=>nr(()=>import(`./CodeEditor-iYG6Q0ag.js`).then(e=>({default:e.CodeEditor})),__vite__mapDeps([38,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,19,18,20,21,22,17,23,24,36]))),_f=(0,Z.lazy)(()=>nr(()=>import(`./DebugDashboard-BeDOPYmE.js`).then(e=>({default:e.DebugDashboard})),__vite__mapDeps([39,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]))),vf=(0,Z.lazy)(()=>nr(()=>import(`./DesignGalleryView-DY3atfBB.js`).then(e=>({default:e.DesignGalleryView})),__vite__mapDeps([40,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]))),yf=(0,Z.lazy)(()=>nr(()=>import(`./MailboxDetailView-DQpxIh_A.js`).then(e=>({default:e.MailboxDetailView})),__vite__mapDeps([41,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,18,23,24,42]))),bf=(0,Z.lazy)(()=>nr(()=>import(`./MemoryManager-D1_0SW_m.js`).then(e=>({default:e.MemoryManager})),__vite__mapDeps([43,1,2,3,4,5,6,8,16,17,18,19,20,21,22,23,24,25,7,9,10,11,12,13,14,15,26,32,28,34,44]))),xf=(0,Z.lazy)(()=>nr(()=>import(`./AudienceMemoryPanel-di7dxMBb.js`).then(e=>({default:e.AudienceMemoryPanel})),__vite__mapDeps([45,1,2,3,4,5,6,16,17,18,8,19,20,21,22,23,24,25,7,9,10,11,12,13,14,15,26,32,28,34,44]))),Sf=(0,Z.lazy)(()=>nr(()=>import(`./KanbanView-DYa0iSlV.js`).then(e=>({default:e.KanbanView})),__vite__mapDeps([46,1,2,3,4,5,6,19,18,20,22,17,8,21,23,47,7,9,10,11,12,13,14,15,16,24,25,28]))),Cf=(0,Z.lazy)(()=>nr(()=>import(`./OfficeMapPanel-DTQPdV7a.js`).then(e=>({default:e.OfficeMapPanel})),__vite__mapDeps([48,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,19,18,20,22,17,21,23,42,49]))),wf=(0,Z.lazy)(()=>nr(()=>import(`./ProcessMonitor-DjO7eNsN.js`).then(e=>({default:e.ProcessMonitor})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]))),Tf=(0,Z.lazy)(()=>nr(()=>import(`./QueuePanel-lUChp6xi.js`).then(e=>({default:e.QueuePanel})),__vite__mapDeps([50,1,17,2,3,4,5,6,18,7,8,9,10,11,12,13,14,15,22,19,20,21,23,26]))),Ef=(0,Z.lazy)(()=>nr(()=>import(`./RefreshDebugView-BNa6ehdH.js`).then(e=>({default:e.RefreshDebugView})),__vite__mapDeps([51,1,17,2,3,4,5,6,18,7,8,9,10,11,12,13,14,15,20]))),Df=(0,Z.lazy)(()=>nr(()=>import(`./SddHub-BW7ExYNe.js`).then(e=>({default:e.SddHub})),__vite__mapDeps([52,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,47,32,53]))),Of=(0,Z.lazy)(()=>nr(()=>import(`./SessionsDashboard-Cf_67b9g.js`).then(e=>({default:e.SessionsDashboard})),__vite__mapDeps([54,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,28]))),kf=(0,Z.lazy)(()=>nr(()=>import(`./SetupScreen-fu9Qr5Qj.js`).then(e=>({default:e.SetupScreen})),__vite__mapDeps([55,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,32,28,34]))),Af=(0,Z.lazy)(()=>nr(()=>import(`./SkillDetailView-DHcDX_1A.js`).then(e=>({default:e.SkillDetailView})),__vite__mapDeps([56,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,42])));(0,Z.lazy)(()=>nr(()=>import(`./SpecsView-CNqNOKqo.js`).then(e=>({default:e.SpecsView})),__vite__mapDeps([53,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,32])));var jf=(0,Z.lazy)(()=>nr(()=>import(`./TechStackView-CXE80hAc.js`).then(e=>({default:e.TechStackView})),__vite__mapDeps([57,1,2,3,4,5,6,18,22,17,8,19,20,21,23,32,28,34]))),Mf=(0,Z.lazy)(()=>nr(()=>import(`./TerminalPanel-KysALyRz.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([58,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,19,18,20,22,17,21,23,59,60])));function Nf(e){return e.split(`-`).map(e=>e.slice(0,1).toUpperCase()+e.slice(1)).join(` `)}function Pf(e){return e>=1024**3?`${(e/1024**3).toFixed(1)} GB`:e>=1024**2?`${Math.round(e/1024**2)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${Math.round(e)} B`}function Ff(){let[e,t]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>{let e=!1,n=async()=>{try{let n=await fetch(`/debug/system`,{cache:`no-store`});if(!n.ok)return;let r=await n.json();!e&&Number.isFinite(r.memoryUsage?.rss)&&t(r)}catch{}};n();let r=window.setInterval(()=>void n(),5e3);return()=>{e=!0,window.clearInterval(r)}},[]),e}function If({currentView:e,projectName:t,sessionLabel:n,isLoading:r,iteration:i,onPalette:a,onSearch:o,onModel:s,onSettings:c}){let l=Ff(),u=l?l.memoryUsage.heapUsed/l.heapLimit:0;return(0,Q.jsx)(`div`,{className:`hidden shrink-0 border-b border-border/70 bg-card/85 px-3 py-2 shadow-sm backdrop-blur-xl md:block`,children:(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Q.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`truncate text-sm font-semibold`,children:t||`WrongStack`}),(0,Q.jsx)(`span`,{className:`rounded-md border border-border/70 bg-muted/50 px-1.5 py-0.5 text-[11px] text-muted-foreground`,children:Nf(e)}),(0,Q.jsxs)(`span`,{className:G(`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[11px] font-medium`,r?`bg-primary/10 text-primary`:`bg-muted text-muted-foreground`),children:[r?(0,Q.jsx)(Ee,{className:`h-3 w-3 animate-pulse`}):(0,Q.jsx)(ee,{className:`h-3 w-3`}),r?`Running`:`Ready`,i?(0,Q.jsxs)(`span`,{className:`tabular`,children:[i.index,i.max>0?`/${i.max}`:``]}):null]}),l?(0,Q.jsxs)(`span`,{className:G(`rounded-md border border-border/70 bg-muted/50 px-1.5 py-0.5 text-[11px] font-medium tabular-nums`,u>=.85?`text-destructive`:u>=.6?`text-warning`:`text-success`),title:`WebUI server PID ${l.pid} · heap ${Pf(l.memoryUsage.heapUsed)} / ${Pf(l.heapLimit)}`,children:[`RAM `,Pf(l.memoryUsage.rss)]}):null]}),(0,Q.jsx)(`div`,{className:`mt-0.5 truncate text-[11px] text-muted-foreground`,children:n||`No named session`})]})}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:o,className:`inline-flex h-8 items-center gap-1.5 rounded-md border border-border/70 bg-background/60 px-2 text-xs text-muted-foreground hover:bg-accent/60 hover:text-foreground`,title:`Search chat`,children:[(0,Q.jsx)(Tn,{className:`h-3.5 w-3.5`}),`Search`]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:a,className:`inline-flex h-8 items-center gap-1.5 rounded-md border border-border/70 bg-background/60 px-2 text-xs text-muted-foreground hover:bg-accent/60 hover:text-foreground`,title:`Command palette`,children:[(0,Q.jsx)(Rt,{className:`h-3.5 w-3.5`}),`Command`]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:s,className:`inline-flex h-8 items-center gap-1.5 rounded-md border border-border/70 bg-background/60 px-2 text-xs text-muted-foreground hover:bg-accent/60 hover:text-foreground`,title:`Switch model`,children:[(0,Q.jsx)(yt,{className:`h-3.5 w-3.5`}),`Model`]}),(0,Q.jsx)(Vc,{}),(0,Q.jsx)(Ys,{}),(0,Q.jsx)(`button`,{type:`button`,onClick:c,className:`inline-flex h-8 w-8 items-center justify-center rounded-md border border-border/70 bg-background/60 text-muted-foreground hover:bg-accent/60 hover:text-foreground`,title:`Settings`,children:(0,Q.jsx)(lt,{className:`h-3.5 w-3.5`})})]})]})})}function Lf({label:e}){return(0,Q.jsx)(`div`,{className:`flex flex-1 min-h-0 min-w-0 items-center justify-center bg-background text-muted-foreground`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[(0,Q.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-muted-foreground/30 border-t-primary`}),e?(0,Q.jsx)(`span`,{className:`text-xs`,children:e}):null]})})}function Rf(){let{theme:e}=Ti(),t=or(),{currentView:n,sidebarOpen:r,toggleSidebar:a,setSearchOpen:o,setSidebarOpen:s,setInspectorTab:c,setPaletteOpen:l,setShortcutsOpen:u,setModelSwitcherOpen:d,setPromptLibraryOpen:f,toggleInspector:p,setFleetMonitorOpen:m,setAgentsMonitorOpen:h,processMonitorOpen:g,setProcessMonitorOpen:_,queuePanelOpen:v,setQueuePanelOpen:y,cronJobsOpen:b,setCronJobsOpen:x,terminalOpen:S,setTerminalOpen:C}=U($t(e=>({currentView:e.currentView,sidebarOpen:e.sidebarOpen,toggleSidebar:e.toggleSidebar,setSearchOpen:e.setSearchOpen,setSidebarOpen:e.setSidebarOpen,setInspectorTab:e.setInspectorTab,setPaletteOpen:e.setPaletteOpen,setShortcutsOpen:e.setShortcutsOpen,setModelSwitcherOpen:e.setModelSwitcherOpen,setPromptLibraryOpen:e.setPromptLibraryOpen,toggleInspector:e.toggleInspector,setFleetMonitorOpen:e.setFleetMonitorOpen,setAgentsMonitorOpen:e.setAgentsMonitorOpen,processMonitorOpen:e.processMonitorOpen,setProcessMonitorOpen:e.setProcessMonitorOpen,queuePanelOpen:e.queuePanelOpen,setQueuePanelOpen:e.setQueuePanelOpen,cronJobsOpen:e.cronJobsOpen,setCronJobsOpen:e.setCronJobsOpen,terminalOpen:e.terminalOpen,setTerminalOpen:e.setTerminalOpen}))),w=i(e=>e.isLoading),T=K(e=>e.iteration),E=K(e=>e.projectName),D=K(e=>e.session?.title),O=K(e=>e.session?.id),k=U(e=>O?e.sessionNicknames[O]:void 0),A=U(e=>e.sideContextBreakdownOpen),j=U(e=>e.setSideContextBreakdownOpen);xr(e=>e.agents),ua({setPaletteOpen:l,setSearchOpen:o,setShortcutsOpen:u,setModelSwitcherOpen:d,setPromptLibraryOpen:f,setFleetMonitorOpen:m,setAgentsMonitorOpen:h,setProcessMonitorOpen:_,setQueuePanelOpen:y,setCronJobsOpen:x,setTerminalOpen:C}),(0,Z.useEffect)(()=>{typeof window>`u`||(window.location.pathname===`/debug`?Ur(`debug`):window.location.pathname===`/analytics`?Ur(`analytics`):window.location.pathname===`/refresh-debug`&&Ur(`refresh-debug`))},[]),(0,Z.useEffect)(()=>{let e=e=>{let{filePath:t}=e.detail,n=pr(q.getState().wsUrl);n&&n.send({type:`files.read`,payload:{filePath:t}})};return window.addEventListener(`wrongstack:open-file`,e),()=>window.removeEventListener(`wrongstack:open-file`,e)},[]),(0,Z.useEffect)(()=>{let e=e=>{let{filePath:t}=e.detail,n=gr.getState().openFiles.find(e=>e.path===t);if(!n)return;let r=pr(q.getState().wsUrl);r&&r.send({type:`files.write`,payload:{filePath:t,content:n.content}})};return window.addEventListener(`wrongstack:save-file`,e),()=>window.removeEventListener(`wrongstack:save-file`,e)},[]);let[M,N]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{if(typeof window>`u`)return;let e=window.matchMedia(`(max-width: 768px)`),t=()=>{let t=U.getState().sidebarOpen;e.matches&&t&&s(!1),N(e.matches&&t)};return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[s]),(0,Z.useEffect)(()=>{if(typeof window>`u`)return;let e=window.matchMedia(`(max-width: 768px)`);N(e.matches&&r)},[r]),sr(),da(),(0,Z.useEffect)(()=>{let e=[];if(w){let t=T?` iter ${T.index}${T.max?`/${T.max}`:``}`:``;e.push(`●${t}`)}let t=k?.trim()||D?.trim(),n=E?.trim();t&&e.push(t),n&&e.push(n),e.length===0&&e.push(n||`AI Agent`);let r=e.filter(Boolean).join(` · `);return document.title=r,()=>{document.title=E||`AI Agent`}},[w,T,E,D,k]),fa({toggleSidebar:a,setSearchOpen:o,toggleInspector:p,setInspectorTab:c}),(0,Q.jsxs)(`div`,{"data-shell":t?`desktop`:`browser`,className:G(`ws-app-root flex min-h-0 min-w-0 overflow-hidden`,t&&`ws-desktop-shell`,e),children:[(0,Q.jsx)(`a`,{href:`#main-content`,className:`sr-only focus:not-sr-only focus:absolute focus:top-2 focus:left-2 focus:z-[100] focus:rounded-md focus:bg-background focus:px-3 focus:py-1.5 focus:text-sm focus:font-medium focus:shadow-lg focus:ring-2 focus:ring-primary`,children:`Skip to content`}),n!==`setup`&&(0,Q.jsx)(Yi,{desktopShell:t}),r&&n!==`setup`&&(0,Q.jsx)(Cd,{desktopShell:t}),(0,Q.jsxs)(`main`,{id:`main-content`,className:`flex-1 min-w-0 min-h-0 flex flex-col overflow-hidden bg-background/70`,...M?{inert:!0}:{},children:[n!==`setup`&&(0,Q.jsx)(If,{currentView:n,projectName:E,sessionLabel:k||D||O||void 0,isLoading:w,iteration:T??null,onPalette:()=>l(!0),onSearch:()=>o(!0),onModel:()=>d(!0),onSettings:()=>Gr(`settings`)}),n!==`setup`&&(0,Q.jsx)(Ds,{}),n===`chat`&&(0,Q.jsxs)(Q.Fragment,{children:[O&&(0,Q.jsx)(`div`,{className:`ws-workspace-dock-wrap shrink-0 px-3 pt-2 sm:px-4`,children:(0,Q.jsx)(of,{})}),(0,Q.jsx)(Xs,{level:`panel`,name:`Chat`,children:(0,Q.jsx)(Cs,{})})]}),n===`settings`&&(0,Q.jsx)(Xs,{level:`panel`,name:`Settings`,children:(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Q.jsx)(fu,{})})}),n===`memory`&&(0,Q.jsx)(Xs,{level:`panel`,name:`Memory Manager`,children:(0,Q.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col lg:flex-row`,children:[(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lf,{label:`Loading…`}),children:(0,Q.jsx)(`div`,{className:`h-[38dvh] min-h-56 w-full shrink-0 border-b border-border/40 lg:h-full lg:min-h-0 lg:w-80 lg:border-b-0 lg:border-r`,children:(0,Q.jsx)(xf,{})})}),(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lf,{label:`Loading Super Memory…`}),children:(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Q.jsx)(bf,{})})})]})}),n===`context`&&(0,Q.jsx)(Xs,{level:`panel`,name:`Context Dashboard`,children:(0,Q.jsx)(Js,{})}),n===`setup`&&(0,Q.jsx)(Xs,{level:`panel`,name:`Setup`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lf,{}),children:(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Q.jsx)(kf,{})})})}),n===`goal`&&(0,Q.jsx)(Xs,{level:`panel`,name:`Goal`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lf,{}),children:(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Q.jsx)(pf,{onClose:()=>J(`chat`)})})})}),n===`sddhub`&&(0,Q.jsx)(Xs,{level:`panel`,name:`SDD Hub`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lf,{}),children:(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Q.jsx)(Df,{})})})}),n===`kanban`&&(0,Q.jsx)(Xs,{level:`panel`,name:`Kanban`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lf,{}),children:(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Q.jsx)(Sf,{onClose:()=>J(`chat`)})})})}),n===`sessions`&&(0,Q.jsx)(Xs,{level:`panel`,name:`Sessions`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lf,{}),children:(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Q.jsx)(Of,{})})})}),n===`chronicle`&&(0,Q.jsx)(Xs,{level:`panel`,name:`Chronicle`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lf,{}),children:(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Q.jsx)(ff,{})})})}),n===`debug`&&(0,Q.jsx)(Xs,{level:`panel`,name:`Debug Dashboard`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lf,{}),children:(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Q.jsx)(_f,{})})})}),n===`refresh-debug`&&(0,Q.jsx)(Xs,{level:`panel`,name:`Refresh Debug`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lf,{}),children:(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Q.jsx)(Ef,{})})})}),n===`files`&&(0,Q.jsx)(Xs,{level:`panel`,name:`Editor`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lf,{label:`Loading editor…`}),children:(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Q.jsx)(gf,{})})})}),n===`changes`&&(0,Q.jsx)(Xs,{level:`panel`,name:`Changes`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lf,{label:`Loading diff…`}),children:(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Q.jsx)(mf,{className:`h-full min-h-0`})})})}),n===`mailbox`&&(0,Q.jsx)(Xs,{level:`panel`,name:`Mailbox`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lf,{}),children:(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Q.jsx)(yf,{className:`h-full min-h-0`})})})}),n===`design-gallery`&&(0,Q.jsx)(Xs,{level:`panel`,name:`Design Gallery`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lf,{}),children:(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Q.jsx)(vf,{className:`h-full`})})})}),n===`skill`&&(0,Q.jsx)(Xs,{level:`panel`,name:`Skill`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lf,{}),children:(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Q.jsx)(Af,{className:`h-full`})})})}),n===`officemap`&&(0,Q.jsx)(Xs,{level:`panel`,name:`Office Map`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lf,{label:`Loading map…`}),children:(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Q.jsx)(Cf,{})})})}),n===`analytics`&&(0,Q.jsx)(Xs,{level:`panel`,name:`Analytics`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lf,{}),children:(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Q.jsx)(uf,{})})})}),n===`codemap`&&(0,Q.jsx)(Xs,{level:`panel`,name:`CodeMap`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lf,{label:`Loading CodeMap…`}),children:(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Q.jsx)(df,{})})})}),n===`techstack`&&(0,Q.jsx)(Xs,{level:`panel`,name:`TechStack`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lf,{label:`Loading TechStack…`}),children:(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Q.jsx)(jf,{})})})}),S&&(0,Q.jsx)(Xs,{level:`panel`,name:`Terminal`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lf,{label:`Loading terminal…`}),children:(0,Q.jsx)(Mf,{desktopShell:t,onClose:()=>C(!1)})})})]}),n!==`setup`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Xs,{level:`panel`,name:`Inspector`,children:(0,Q.jsx)(Hc,{})}),O&&n===`chat`&&(0,Q.jsx)(Xs,{level:`panel`,name:`Workspace Inspector`,children:(0,Q.jsx)(cf,{sessionId:O})})]}),g&&(0,Q.jsx)(Xs,{level:`panel`,name:`Process Monitor`,children:(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(wf,{open:g,onClose:()=>_(!1)})})}),v&&(0,Q.jsx)(Xs,{level:`panel`,name:`Queue`,children:(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(Tf,{open:v,onClose:()=>y(!1)})})}),b&&(0,Q.jsx)(Xs,{level:`panel`,name:`Cron Jobs`,children:(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(hf,{open:b,onClose:()=>x(!1)})})}),A&&(0,Q.jsx)(go,{open:A,onClose:()=>j(!1)}),(0,Q.jsx)(Es,{}),(0,Q.jsx)(hi,{}),(0,Q.jsx)(pi,{}),(0,Q.jsx)(ca,{}),(0,Q.jsx)(mu,{}),(0,Q.jsx)(qc,{}),(0,Q.jsx)(qr,{})]})}function zf(){return(0,Q.jsx)(Xs,{children:(0,Q.jsx)(wi,{defaultTheme:`system`,children:(0,Q.jsx)(Rf,{})})})}gi.createRoot(t(document.getElementById(`root`))).render((0,Q.jsx)(Z.StrictMode,{children:(0,Q.jsx)(zf,{})}));export{Ti as C,ho as S,$o as _,kl as a,So as b,el as c,$s as d,nc as f,Os as g,Zs as h,zu as i,Xc as l,tc as m,Qd as n,Al as o,ec as p,Jd as r,Ol as s,ef as t,Cc as u,Wo as v,bo as x,Ho as y};
119
+ AWS_REGION=us-east-1`})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium`,children:a(`settings:mcp.fieldDescription`)}),(0,Q.jsx)(fi,{value:u,onChange:e=>d(e.target.value),placeholder:a(`settings:mcp.fieldDescriptionPlaceholder`)})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,id:`server-enabled`,checked:b,onChange:e=>x(e.target.checked),className:`rounded`}),(0,Q.jsx)(`label`,{htmlFor:`server-enabled`,className:`text-sm`,children:a(`settings:mcp.enableServer`)})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,id:`server-lazy`,checked:S,onChange:e=>C(e.target.checked),className:`rounded`}),(0,Q.jsxs)(`label`,{htmlFor:`server-lazy`,className:`text-sm`,children:[a(`settings:mcp.lazyConnect`),` `,(0,Q.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:a(`settings:mcp.lazyConnectHint`)})]})]})]}),(0,Q.jsxs)(Yr,{children:[(0,Q.jsx)(X,{variant:`outline`,onClick:()=>t(!1),children:a(`common:action.cancel`)}),(0,Q.jsx)(X,{onClick:w,children:a(T?`settings:mcp.saveChanges`:`settings:mcp.addServer`)})]})]})})}function Cl({server:e,isAdded:t,onAdd:n}){let{t:r}=V();return(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3 rounded-md border border-border/70 bg-card/70 p-3 transition-colors hover:bg-card`,children:[(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-sm`,children:e.name}),e.badge&&(0,Q.jsx)(el,{variant:`secondary`,className:`text-xs shrink-0`,children:e.badge}),(0,Q.jsx)(el,{variant:`outline`,className:`text-xs shrink-0`,children:e.transport})]}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e.description}),e.requiresEnvVars&&e.requiresEnvVars.length>0&&(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-warning`,children:r(`settings:mcp.requires`,{vars:e.requiresEnvVars.join(`, `)})})]}),(0,Q.jsx)(`div`,{className:`shrink-0`,children:t?(0,Q.jsxs)(X,{variant:`ghost`,size:`sm`,disabled:!0,children:[(0,Q.jsx)(Wn,{className:`w-4 h-4 mr-1`}),r(`settings:mcp.added`)]}):(0,Q.jsxs)(X,{size:`sm`,variant:`outline`,onClick:n,children:[(0,Q.jsx)(jt,{className:`w-4 h-4 mr-1`}),r(`common:action.add`)]})})]})}function wl(){let e=dr(),{t}=V(),[n,r]=(0,Z.useState)([]),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(`list`),[c,l]=(0,Z.useState)(),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)(),[_,v]=(0,Z.useState)(null);(0,Z.useEffect)(()=>{if(!e.client)return;let t=e=>{if(e.type===`mcp.list`){let t=e.payload;r(t.servers??[]),a(!1)}},n=e=>{if(e.type===`mcp.server.added`){let t=e.payload;r(e=>[...e.filter(e=>e.name!==t.server.name),t.server]),Y.success(H.t(`settings:mcp.toastAdded`,{name:t.server.name}))}},i=e=>{if(e.type===`mcp.server.removed`){let t=e.payload;r(e=>e.filter(e=>e.name!==t.name)),Y.success(H.t(`settings:mcp.toastRemoved`,{name:t.name}))}},o=e=>{if(e.type===`mcp.server.updated`){let t=e.payload;r(e=>e.map(e=>e.name===t.server.name?t.server:e))}},s=e=>{if(e.type===`mcp.server.discovered`){let t=e.payload;r(e=>e.map(e=>e.name===t.name?{...e,status:`sleeping`,tools:t.tools}:e)),v(null),Y.success(H.t(`settings:mcp.toastDiscovered`,{count:t.tools.length,name:t.name}))}},c=e=>{if(e.type===`mcp.server.sleeping`){let t=e.payload;r(e=>e.map(e=>e.name===t.name?{...e,status:`sleeping`}:e)),v(null),Y.info(H.t(`settings:mcp.toastSleeping`,{name:t.name}))}},l=e=>{if(e.type===`mcp.server.waking`){let t=e.payload;r(e=>e.map(e=>e.name===t.name?{...e,status:`connecting`}:e))}},u=e=>{if(e.type===`mcp.server.connected`){let t=e.payload;r(e=>e.map(e=>e.name===t.name?{...e,status:`connected`,pid:t.pid,error:void 0,lastError:void 0}:e)),v(null),Y.success(H.t(`settings:mcp.toastConnected`,{name:t.name}))}},d=e=>{if(e.type===`mcp.server.reconnected`){let t=e.payload;r(e=>e.map(e=>e.name===t.name?{...e,status:`connected`,error:void 0,lastError:void 0}:e)),v(null),Y.success(H.t(`settings:mcp.toastReconnected`,{name:t.name}))}},f=e=>{if(e.type===`mcp.server.disconnected`){let t=e.payload;r(e=>e.map(e=>e.name===t.name?{...e,status:`error`,error:t.reason,lastError:t.reason,pid:void 0}:e)),v(null),Y.warn(H.t(`settings:mcp.toastDisconnected`,{name:t.name,reason:t.reason}))}},p=e=>{if(e.type===`mcp.server.error`){let t=e.payload;r(e=>e.map(e=>e.name===t.name?{...e,status:`error`,error:t.error}:e)),v(null),Y.error(H.t(`settings:mcp.toastError`,{name:t.name,error:t.error}))}},m=e=>{if(e.type===`mcp.operation_result`){let t=e.payload;t.success||Y.error(t.message),v(null)}},h=e.client.on(`mcp.list`,t),g=e.client.on(`mcp.server.added`,n),_=e.client.on(`mcp.server.removed`,i),y=e.client.on(`mcp.server.updated`,o),b=e.client.on(`mcp.server.discovered`,s),x=e.client.on(`mcp.server.sleeping`,c),S=e.client.on(`mcp.server.waking`,l),C=e.client.on(`mcp.server.connected`,u),w=e.client.on(`mcp.server.error`,p),T=e.client.on(`mcp.operation_result`,m),E=e.client.on(`mcp.server.reconnected`,d),D=e.client.on(`mcp.server.disconnected`,f);return a(!0),e.client?.listMcpServers(),()=>{h?.(),g?.(),_?.(),y?.(),b?.(),x?.(),S?.(),C?.(),w?.(),T?.(),E?.(),D?.()}},[e.client]);let y=(0,Z.useCallback)(t=>{e.client?.addMcpServer(t)},[e]),b=(0,Z.useCallback)(e=>{h(vl(e,!1)),p(!0)},[]),x=(0,Z.useCallback)(n=>{mi({title:t(`settings:mcp.removeConfirmTitle`,{name:n}),message:t(`settings:mcp.removeConfirmBody`),confirmLabel:t(`common:action.remove`),danger:!0}).then(t=>{t&&e.client?.removeMcpServer(n)})},[e]),S=(0,Z.useCallback)(e=>{l(e),h(void 0),d(!0)},[]),C=(0,Z.useCallback)(t=>{e.client?.updateMcpServer(t)},[e]),w=(0,Z.useCallback)(t=>{v(t),e.client?.wakeMcpServer(t)},[e]),T=(0,Z.useCallback)(t=>{v(t),e.client?.sleepMcpServer(t)},[e]),E=(0,Z.useCallback)(t=>{v(t),e.client?.discoverMcpServer(t)},[e]),D=(0,Z.useCallback)(()=>{a(!0),e.client?.listMcpServers()},[e]),O=n.filter(e=>e.status===`connected`).length,k=n.filter(e=>e.status===`sleeping`).length,A=new Set(n.map(e=>e.name));return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Q.jsx)(`span`,{className:`flex h-9 w-9 items-center justify-center rounded-md border border-primary/20 bg-primary/10 text-primary`,children:(0,Q.jsx)(re,{className:`h-5 w-5`})}),(0,Q.jsx)(`h2`,{className:`text-base font-semibold`,children:t(`settings:mcp.heading`)}),n.length>0&&(0,Q.jsx)(`span`,{className:`rounded-md border border-border/60 bg-muted/30 px-2 py-1 text-xs text-muted-foreground`,children:t(`settings:mcp.summary`,{connected:O,sleeping:k,total:n.length})})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(X,{variant:`outline`,size:`sm`,onClick:D,disabled:i,children:[i?(0,Q.jsx)(g,{className:`w-4 h-4 animate-spin`}):null,t(`common:action.refresh`)]}),(0,Q.jsxs)(X,{size:`sm`,onClick:()=>{h(void 0),p(!0)},children:[(0,Q.jsx)(jt,{className:`w-4 h-4 mr-1`}),t(`settings:mcp.addCustom`)]})]})]}),(0,Q.jsxs)($s,{value:o,onValueChange:e=>s(e),children:[(0,Q.jsxs)(ec,{children:[(0,Q.jsxs)(tc,{value:`recommended`,children:[(0,Q.jsx)(rn,{className:`w-3.5 h-3.5 mr-1`}),t(`settings:mcp.tabRecommended`)]}),(0,Q.jsx)(tc,{value:`list`,children:t(`settings:mcp.tabServers`)}),(0,Q.jsx)(tc,{value:`add`,children:t(`settings:mcp.tabAddCustom`)})]}),(0,Q.jsxs)(nc,{value:`recommended`,className:`space-y-3`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`settings:mcp.recommendedBody`)}),(0,Q.jsx)(`div`,{className:`grid gap-2`,children:_l.map(e=>(0,Q.jsx)(Cl,{server:e,isAdded:A.has(e.name),onAdd:()=>b(e)},e.name))})]}),(0,Q.jsx)(nc,{value:`list`,className:`space-y-3`,children:i&&n.length===0?(0,Q.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground`,children:[(0,Q.jsx)(g,{className:`w-5 h-5 animate-spin mr-2`}),t(`settings:mcp.loadingServers`)]}):n.length===0?(0,Q.jsxs)(`div`,{className:`text-center py-8 text-muted-foreground`,children:[(0,Q.jsx)(re,{className:`w-10 h-10 mx-auto mb-2 opacity-50`}),(0,Q.jsx)(`p`,{children:t(`settings:mcp.noServers`)}),(0,Q.jsx)(`p`,{className:`text-sm`,children:t(`settings:mcp.noServersHint`)})]}):n.map(e=>(0,Q.jsx)(xl,{server:e,onWake:()=>w(e.name),onSleep:()=>T(e.name),onDiscover:()=>E(e.name),onEdit:()=>S(e),onRemove:()=>x(e.name)},e.name))}),(0,Q.jsx)(nc,{value:`add`,children:(0,Q.jsxs)(`div`,{className:`text-sm text-muted-foreground`,children:[(0,Q.jsx)(`p`,{children:t(`settings:mcp.addCustomBody`)}),(0,Q.jsx)(`p`,{className:`mt-1`,children:t(`settings:mcp.addCustomBodyHint`)})]})})]}),(0,Q.jsx)(Sl,{open:f,onOpenChange:e=>{e||(p(!1),h(void 0))},prefillConfig:m,onSave:y}),(0,Q.jsx)(Sl,{open:u,onOpenChange:d,server:c,onSave:C})]})}function Tl({provider:e,catalogModels:t,currentCatalogProvider:n,isLoadingModels:r,setIsLoadingModels:i,onModelSelect:a,refreshModels:o}){let s=q(e=>e.model),{t:c}=V();return(0,Q.jsx)(`div`,{className:`space-y-4`,children:e?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium`,children:n?.name||e}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e})]}),(0,Q.jsx)(X,{variant:`ghost`,size:`sm`,onClick:()=>{i(!0),o(e)},children:(0,Q.jsx)(Dn,{className:G(`h-4 w-4`,r&&`animate-spin`)})})]}),r&&!t[e]?(0,Q.jsxs)(`div`,{className:`flex items-center justify-center py-8`,children:[(0,Q.jsx)(g,{className:`h-6 w-6 animate-spin text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`ml-2 text-muted-foreground`,children:c(`settings:model.loading`)})]}):(0,Q.jsx)(Zc,{options:(t[e]||[]).map(e=>({id:e.id,label:e.name||e.id,badges:e.capabilities,detail:[e.contextWindow?`${Math.round(e.contextWindow/1e3)}k`:``,e.inputCost==null?``:`${e.inputCost}/${e.outputCost}`].filter(Boolean).join(` · `),detailHighlight:!0})),selectedId:s,onSelect:a,emptyMessage:c(`settings:model.notFound`)})]}):(0,Q.jsxs)(`div`,{className:`text-center py-8 text-muted-foreground`,children:[(0,Q.jsx)(yt,{className:`h-8 w-8 mx-auto mb-2 opacity-50`}),(0,Q.jsx)(`p`,{children:c(`settings:model.selectProviderFirst`)})]})})}var El=[[`wstack-chimera`,`settings:features.pluginChimera`],[`wstack-skills`,`settings:features.pluginSkills`],[`wstack-prompts`,`settings:features.pluginPrompts`],[`wstack-security`,`settings:features.pluginSecurity`],[`cost-tracker`,`settings:features.pluginCostTracker`],[`telegram`,`settings:features.pluginTelegram`],[`knowledge-graph`,`settings:features.pluginKnowledgeGraph`],[`error-lens`,`settings:features.pluginErrorLens`],[`todo-tracker`,`settings:features.pluginTodoTracker`],[`secret-scanner`,`settings:features.pluginSecretScanner`],[`lint-gate`,`settings:features.pluginLintGate`],[`diff-summary`,`settings:features.pluginDiffSummary`],[`dep-guard`,`settings:features.pluginDepGuard`],[`type-gate`,`settings:features.pluginTypeGate`],[`injection-shield`,`settings:features.pluginInjectionShield`],[`prompt-firewall`,`settings:features.pluginPromptFirewall`],[`token-budget`,`settings:features.pluginTokenBudget`],[`loop-breaker`,`settings:features.pluginLoopBreaker`]];function Dl(){let{t:e}=V(),t=W();return(0,Q.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Q.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 mt-3 flex items-center gap-2`,children:[(0,Q.jsx)(wt,{className:`h-4 w-4 text-muted-foreground`}),e(`settings:features.pluginsPerPluginHeading`)]}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mb-2`,children:e(`settings:features.pluginsPerPluginHint`)}),El.map(([n,r])=>{let i=t.pluginsEnabled?.[n]??!0;return(0,Q.jsx)($,{label:e(r),value:i,onChange:()=>{let e={...t.pluginsEnabled,[n]:!i};t.set({pluginsEnabled:e})}},n)})]})}function Ol(){let e=(0,Z.useRef)([]);return{setFieldRef:(0,Z.useCallback)(t=>n=>{e.current[t]=n},[]),handleKeyDown:(0,Z.useCallback)((t,n,r)=>{if(t.key===`ArrowDown`){t.preventDefault();for(let t=n+1;t<e.current.length;t++){let n=e.current[t];if(n&&!n.hasAttribute(`disabled`)&&n.getAttribute(`aria-disabled`)!==`true`){if(n.focus(),n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement){let e=n.value.length;n.setSelectionRange(e,e)}return}}return}if(t.key===`ArrowUp`){t.preventDefault();for(let t=n-1;t>=0;t--){let n=e.current[t];if(n&&!n.hasAttribute(`disabled`)&&n.getAttribute(`aria-disabled`)!==`true`){n.focus(),(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement)&&n.setSelectionRange(n.value.length,n.value.length);return}}return}t.key===`Enter`&&r&&(t.preventDefault(),r())},[])}}var kl=`openai-compatible`,Al=[{id:`omniroute`,label:`OmniRoute`,defaultBaseUrl:`http://localhost:20128/v1`,noAuth:!0,hint:`WrongStack local gateway · port 20128 · no key · auto-discovers models`},{id:`ollama`,label:`Ollama`,defaultBaseUrl:`http://localhost:11434/v1`,noAuth:!0,hint:`ollama.com · port 11434 · no key`},{id:`vllm`,label:`vLLM`,defaultBaseUrl:`http://localhost:8000/v1`,noAuth:!1,hint:`docs.vllm.ai · port 8000 · optional key`},{id:`lmstudio`,label:`LM Studio`,defaultBaseUrl:`http://localhost:1234/v1`,noAuth:!1,hint:`lmstudio.ai · port 1234 · optional key`}],jl=[{kind:`chatgpt`,label:`ChatGPT`,subtitle:`Plus / Pro / Team → openai-codex`,icon:(0,Q.jsx)(ee,{className:`h-5 w-5`})},{kind:`claude`,label:`Claude`,subtitle:`Pro / Max → anthropic-oauth`,icon:(0,Q.jsx)(Ee,{className:`h-5 w-5`})},{kind:`copilot`,label:`GitHub Copilot`,subtitle:`Copilot → github-copilot`,icon:(0,Q.jsx)(En,{className:`h-5 w-5`})}],Ml=[`awaiting_browser`,`awaiting_code`,`exchanging`,`fetching_models`];function Nl({ws:e}){let{t}=V(),[n,r]=(0,Z.useState)({chatgpt:{phase:`idle`},claude:{phase:`idle`},copilot:{phase:`idle`}}),[i,a]=(0,Z.useState)(``),[o,s]=(0,Z.useState)(null);(0,Z.useEffect)(()=>{let t=e.on(`auth.oauth.status`,e=>{if(e.type!==`auth.oauth.status`)return;let t=e.payload;r(e=>({...e,[t.kind]:{...t}})),t.phase===`success`?(Y.success(t.message??H.t(`settings:oauth.signedInToast`,{provider:t.providerId??t.kind})),s(null),a(``)):t.phase===`error`&&Y.error(t.message??H.t(`settings:oauth.signInFailed`))});return()=>t?.()},[e]);let c=(0,Z.useCallback)(t=>{r(e=>({...e,[t]:{phase:t===`copilot`?`awaiting_code`:`awaiting_browser`}})),e.startOAuth(t)},[e]),l=(0,Z.useCallback)(t=>{e.cancelOAuth(t),r(e=>({...e,[t]:{phase:`idle`}})),s(null)},[e]),u=(0,Z.useCallback)(t=>{let n=i.trim();n&&(e.submitOAuthCode(t,n),r(e=>({...e,[t]:{...e[t],phase:`exchanging`}})))},[i,e]);return(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`div`,{className:`rounded-md border border-warning/30 bg-warning/5 p-3`,children:(0,Q.jsx)(`p`,{className:`text-xs leading-5 text-warning`,children:t(`settings:oauth.termsWarning`)})}),(0,Q.jsx)(`div`,{className:`grid grid-cols-1 gap-2 lg:grid-cols-3`,children:jl.map(e=>{let r=n[e.kind],d=Ml.includes(r.phase);return(0,Q.jsxs)(`div`,{className:`rounded-lg border border-border bg-background/70 p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 lg:flex-col lg:items-stretch`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`div`,{className:`font-medium`,children:e.label}),(0,Q.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.subtitle})]})]}),d?(0,Q.jsx)(X,{size:`sm`,variant:`ghost`,onClick:()=>l(e.kind),className:`shrink-0 lg:w-full`,children:t(`common:action.cancel`)}):(0,Q.jsx)(X,{size:`sm`,onClick:()=>c(e.kind),className:`shrink-0 lg:w-full`,children:t(`settings:oauth.signIn`)})]}),r.phase===`awaiting_browser`&&(0,Q.jsxs)(`div`,{className:`mt-3 space-y-2 border-t pt-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,Q.jsx)(g,{className:`h-4 w-4 animate-spin text-muted-foreground`}),(0,Q.jsx)(`span`,{children:t(`settings:oauth.waitingBrowser`)})]}),r.authorizeUrl&&(0,Q.jsxs)(X,{size:`sm`,variant:`outline`,onClick:()=>window.open(r.authorizeUrl,`_blank`,`noopener,noreferrer`),children:[(0,Q.jsx)(tt,{className:`h-3.5 w-3.5 mr-1`}),t(`settings:oauth.openSignIn`)]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`button`,{type:`button`,className:`text-xs text-muted-foreground underline`,onClick:()=>s(o===e.kind?null:e.kind),children:r.bound===!1?t(`settings:oauth.pasteLoopbackBusy`):t(`settings:oauth.pasteCantReach`)}),o===e.kind&&(0,Q.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,Q.jsx)(fi,{placeholder:`http://localhost:.../callback?code=…`,value:i,onChange:e=>a(e.target.value),className:`font-mono text-xs`,onKeyDown:t=>{t.key===`Enter`&&u(e.kind)}}),(0,Q.jsx)(X,{size:`sm`,onClick:()=>u(e.kind),disabled:!i.trim(),children:t(`settings:oauth.submit`)})]})]})]}),r.phase===`awaiting_code`&&(0,Q.jsxs)(`div`,{className:`mt-3 space-y-2 border-t pt-3`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`settings:oauth.enterCode`)}),(0,Q.jsx)(`div`,{className:`font-mono text-2xl font-bold tracking-widest`,children:r.userCode??`…`}),r.verificationUri&&(0,Q.jsxs)(X,{size:`sm`,variant:`outline`,onClick:()=>window.open(r.verificationUri,`_blank`,`noopener,noreferrer`),children:[(0,Q.jsx)(tt,{className:`h-3.5 w-3.5 mr-1`}),t(`settings:oauth.openVerification`)]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(g,{className:`h-3.5 w-3.5 animate-spin`}),(0,Q.jsx)(`span`,{children:t(`settings:oauth.waitingCode`)})]})]}),(r.phase===`exchanging`||r.phase===`fetching_models`)&&(0,Q.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 border-t pt-3 text-sm`,children:[(0,Q.jsx)(g,{className:`h-4 w-4 animate-spin text-muted-foreground`}),(0,Q.jsx)(`span`,{children:r.phase===`exchanging`?t(`settings:oauth.exchanging`):t(`settings:oauth.fetchingModels`)})]}),r.phase===`success`&&(0,Q.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 border-t pt-3 text-sm text-success`,children:[(0,Q.jsx)(Gt,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{children:r.message??t(`settings:oauth.signedIn`)})]}),r.phase===`error`&&r.message&&(0,Q.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 border-t pt-3 text-sm text-destructive`,children:[(0,Q.jsx)(un,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{children:r.message})]})]},e.kind)})})]})}function Pl({open:e,providerId:t,modelCount:n,onConfirm:r,onCancel:i}){let a=(0,Z.useRef)(null),{t:o}=V();return(0,Z.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Enter`?(e.preventDefault(),r()):e.key===`Escape`&&(e.preventDefault(),i())};return window.addEventListener(`keydown`,t),a.current?.focus(),()=>window.removeEventListener(`keydown`,t)},[e,r,i]),(0,Q.jsx)($r,{open:e,onOpenChange:e=>{e||i()},children:(0,Q.jsxs)(Xr,{className:`sm:max-w-md border-warning/50`,ref:a,tabIndex:-1,"data-clear-allowlist-dialog":!0,children:[(0,Q.jsxs)(Jr,{children:[(0,Q.jsxs)(Zr,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(kt,{className:`h-5 w-5 text-warning`}),o(`settings:allowlist.title`)]}),(0,Q.jsx)(Qr,{children:o(`settings:allowlist.body`,{count:n,provider:t})})]}),(0,Q.jsx)(`div`,{className:`rounded-md bg-muted/50 border border-border/60 px-3 py-2 text-xs text-muted-foreground`,children:o(`settings:allowlist.undoHint`)}),(0,Q.jsxs)(Yr,{className:`gap-2 sm:gap-2 flex-wrap`,children:[(0,Q.jsxs)(X,{variant:`outline`,size:`sm`,onClick:i,title:o(`settings:allowlist.keepTitle`),"data-action":`cancel`,children:[o(`common:action.cancel`),` `,(0,Q.jsx)(`kbd`,{className:`ml-1 text-[10px] border rounded px-1 bg-background`,children:`Esc`})]}),(0,Q.jsxs)(X,{variant:`destructive`,size:`sm`,onClick:r,title:o(`settings:allowlist.clearTitle`),"data-action":`confirm`,children:[o(`settings:allowlist.clear`),` `,(0,Q.jsx)(`kbd`,{className:`ml-1 text-[10px] border rounded px-1 bg-background/80`,children:`↵`})]})]})]})})}function Fl(){return{inFlight:!1,last:null,picked:null}}function Il(e){return{providerId:e.providerId,ok:e.ok,status:e.status,...e.httpStatus===void 0?{}:{httpStatus:e.httpStatus},...e.elapsedMs===void 0?{}:{elapsedMs:e.elapsedMs},...e.modelCount===void 0?{}:{modelCount:e.modelCount},...e.modelIds===void 0?{}:{modelIds:e.modelIds},...e.detail===void 0?{}:{detail:e.detail}}}function Ll(e,t,n){return e.picked?e.picked:e.last?.ok&&e.last.modelIds&&e.last.modelIds.length>0&&e.last.modelIds[0]?e.last.modelIds[0]:t||(n&&n.length>0&&n[0]?n[0]:``)}function Rl(e){if(e.inFlight)return{text:`Checking model endpoint...`,tone:`muted`};let t=e.last;if(!t)return{text:`Saved model list shown`,tone:`muted`};let n=t.elapsedMs===void 0?``:` (${t.elapsedMs}ms)`;switch(t.status){case`ok`:{let e=t.modelCount??t.modelIds?.length??0;return{text:`Server returned ${e} model${e===1?``:`s`}${n}`,tone:`success`}}case`unreachable`:return{text:`server unreachable${t.detail?` — ${t.detail}`:``}`,tone:`error`};case`timeout`:return{text:`timed out${t.detail?` — ${t.detail}`:``}`,tone:`error`};case`http_error`:return{text:`got${t.httpStatus===void 0?``:` HTTP ${t.httpStatus}`}${t.detail?` — ${t.detail}`:``}`,tone:`warning`};case`invalid_response`:return{text:t.detail?`unexpected response — ${t.detail}`:`unexpected response shape`,tone:`warning`};case`no_provider`:return{text:`Provider is no longer saved`,tone:`error`};case`no_base_url`:return{text:`No model endpoint configured`,tone:`warning`}}}function zl(e,t){return e.last?.ok&&e.last.modelIds&&e.last.modelIds.length>0?e.last.modelIds:t??[]}function Bl(e){return(e?.length??0)>0}function Vl(e,t){return`Allowlist cleared for ${e} — ${t} model${t===1?``:`s`} removed`}function Hl(e){return e.length>0}function Ul(e){return e.previousModels.length===0?{kind:`skip`}:e.onUndoClear?{kind:`callback`,providerId:e.providerId,previousModels:e.previousModels}:{kind:`ws-default`,providerId:e.providerId,previousModels:e.previousModels}}var Wl=3e3;function Gl({providerId:e,savedPickedModelId:t,savedModels:n,ws:r,onPickModel:i,onClearModels:a,onUndoClear:o}){let[s,c]=(0,Z.useState)(()=>Fl()),{t:l}=V(),[u,d]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>r.on(`provider.probe`,t=>{t.type===`provider.probe`&&t.payload.providerId===e&&c(e=>({...e,inFlight:!1,last:Il(t.payload)}))}),[r,e]);let f=(0,Z.useCallback)(()=>{c(e=>({...e,inFlight:!0})),r.probeProvider(e,Wl)},[r,e]),p=(0,Z.useCallback)(t=>{c(e=>({...e,picked:t})),i?.(e,t)},[i,e]),m=(0,Z.useCallback)(()=>{d(!0)},[]),h=(0,Z.useCallback)(()=>{d(!1)},[]),_=(0,Z.useCallback)(()=>{d(!1);let t=n?[...n]:[];c(e=>({...e,picked:null,last:null})),a?a(e):r.clearProviderModels(e),Hl(t)&&Y.undoable(Vl(e,t.length),()=>{let n=Ul({providerId:e,previousModels:t,onUndoClear:o});switch(n.kind){case`skip`:return;case`callback`:o?.(n.providerId,n.previousModels);return;case`ws-default`:r.undoProviderClear(n.providerId,n.previousModels);return}})},[a,o,r,e,n]),v=(0,Z.useMemo)(()=>Ll(s,t,n),[s,t,n]),y=(0,Z.useMemo)(()=>zl(s,n),[s,n]),b=ho(y,12,e),x=(0,Z.useMemo)(()=>Rl(s),[s]),S=(0,Z.useMemo)(()=>Bl(n),[n]),C=y.length>8;return(0,Q.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-background/75 p-3 shadow-sm shadow-black/[0.02]`,"data-provider-models-panel":e,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[(0,Q.jsx)(ge,{className:`h-3.5 w-3.5`}),l(`activity:providerModels.allowlistTitle`)]}),y.length>0&&(0,Q.jsx)(`span`,{className:`rounded-full border border-border/70 bg-muted/40 px-2 py-0.5 text-[11px] text-muted-foreground`,children:l(`activity:providerModels.modelCount`,{count:y.length})})]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:l(`activity:providerModels.using`)}),v?(0,Q.jsx)(`span`,{className:`max-w-full truncate rounded-md bg-primary/10 px-2 py-0.5 font-mono text-xs text-primary`,children:v}):(0,Q.jsx)(`span`,{className:`text-xs italic text-muted-foreground`,children:l(`activity:providerModels.noModelPicked`)})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 sm:justify-end`,children:[(0,Q.jsxs)(X,{variant:`outline`,size:`sm`,onClick:f,disabled:s.inFlight,"aria-label":l(`activity:providerModels.refreshAria`,{provider:e}),className:`h-8 px-2 text-xs`,children:[s.inFlight?(0,Q.jsx)(g,{className:`h-3.5 w-3.5 animate-spin`}):(0,Q.jsx)(Dn,{className:`h-3.5 w-3.5`}),s.inFlight?l(`activity:providerModels.probing`):l(`activity:providerModels.refresh`)]}),S&&(0,Q.jsx)(X,{variant:`ghost`,size:`sm`,onClick:m,"aria-label":l(`activity:providerModels.clearAllowlistAria`,{provider:e}),"data-action":`clear-models`,className:`h-8 px-2 text-xs`,children:l(`activity:providerModels.clearAllowlist`)})]})]}),(0,Q.jsx)(Kl,{formatted:x}),y.length>0&&(0,Q.jsxs)(`div`,{className:`relative mt-3`,children:[(0,Q.jsx)(`ul`,{className:G(`flex flex-wrap gap-1.5 pr-1 [scrollbar-gutter:stable]`,C&&`max-h-40 overflow-y-scroll pb-7`),"data-provider-models-list":e,children:b.pageItems.map(t=>{let n=t===v;return(0,Q.jsx)(`li`,{className:`max-w-full`,children:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{n||p(t)},disabled:n,className:n?`inline-flex max-w-full items-center gap-1.5 rounded-md border border-primary/25 bg-primary/10 px-2 py-1 text-left font-mono text-xs text-primary shadow-sm`:`inline-flex max-w-full items-center gap-1.5 rounded-md border border-border/70 bg-muted/25 px-2 py-1 text-left font-mono text-xs text-foreground/85 transition-colors hover:border-primary/35 hover:bg-primary/5 hover:text-primary`,"aria-label":n?void 0:l(`activity:providerModels.useModelAria`,{model:t,provider:e}),children:[n&&(0,Q.jsx)(Wn,{className:`h-3.5 w-3.5 shrink-0`}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:t}),!n&&(0,Q.jsx)(`span`,{className:`shrink-0 border-l border-border/70 pl-1.5 font-sans text-[10px] font-semibold uppercase tracking-wide text-primary`,children:l(`activity:providerModels.use`)})]})},t)})}),C&&(0,Q.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 h-9 rounded-b-md bg-gradient-to-t from-background via-background/90 to-transparent`}),(0,Q.jsx)(ni,{page:b.page,pageSize:b.pageSize,totalItems:b.totalItems,onPageChange:b.setPage,className:`mt-2`,compact:!0,itemLabel:`models`})]}),(0,Q.jsx)(Pl,{open:u,providerId:e,modelCount:n?.length??0,onConfirm:_,onCancel:h})]})}function Kl({formatted:e}){let t=e.tone===`success`?`text-success`:e.tone===`warning`?`text-warning`:e.tone===`error`?`text-destructive`:`text-muted-foreground`,n=e.tone===`success`?`bg-success`:e.tone===`warning`?`bg-warning`:e.tone===`error`?`bg-destructive`:`bg-muted-foreground/60`;return(0,Q.jsxs)(`p`,{className:`mt-2 flex items-center gap-1.5 text-xs ${t}`,"data-probe-tone":e.tone,children:[(0,Q.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full ${n}`}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:e.text})]})}var ql=[`anthropic`,`openai`,`google`,`openai-compatible`];function Jl({activeProvider:e,catalogProviders:t,isLoadingCatalog:n,savedProviders:r,isLoadingSaved:i,providerTab:a,setProviderTab:s,onSelectProvider:c,onAddKey:l,onDeleteKey:u,onSetActiveKey:d,onAddProvider:f,onRemoveProvider:p,onPickProviderModel:m,ws:h,catalogQuery:_,setCatalogQuery:y}){let{t:b}=V(),[x,S]=(0,Z.useState)(null),[w,T]=(0,Z.useState)(``),[E,D]=(0,Z.useState)(``),[O,k]=(0,Z.useState)(!1),[A,j]=(0,Z.useState)(!1),[M,N]=(0,Z.useState)(``),[P,ee]=(0,Z.useState)(`openai-compatible`),[te,F]=(0,Z.useState)(``),[I,ne]=(0,Z.useState)(``),L=Ol(),ie=Ol(),ae=(0,Z.useCallback)(e=>{!w.trim()||!E.trim()||(l(e,w.trim(),E.trim()),T(``),D(``),S(null))},[l,w,E]),z=(0,Z.useCallback)(()=>{M.trim()&&(f(M.trim(),P,te||void 0,I||void 0),N(``),ee(`openai-compatible`),F(``),ne(``),j(!1))},[f,M,P,te,I]),oe=(0,Z.useCallback)(e=>{N(e.id),ee(kl),F(e.defaultBaseUrl),e.noAuth&&ne(``)},[]),[se,ce]=(0,Z.useState)(null),[le,ue]=(0,Z.useState)(``),[de,fe]=(0,Z.useState)(!1),[pe,me]=(0,Z.useState)({}),he=(0,Z.useMemo)(()=>new Set(r.map(e=>e.id)),[r]),ge=(0,Z.useMemo)(()=>({keys:r.reduce((e,t)=>e+t.apiKeys.length,0),activeKeys:r.reduce((e,t)=>e+t.apiKeys.filter(e=>e.isActive).length,0),models:r.reduce((e,t)=>e+(t.models?.length??0),0)}),[r]);(0,Z.useEffect)(()=>{let e=h.on(`provider.probe`,e=>{if(e.type!==`provider.probe`)return;let t=e.payload;t.status===`no_base_url`||t.status===`no_provider`||me(e=>({...e,[t.providerId]:{ok:t.ok,status:t.status,detail:t.detail}}))});return()=>e?.()},[h]);let _e=(0,Z.useCallback)(e=>{let t=le.trim();t&&(he.has(e.id)?l(e.id,`default`,t):f(e.id,e.family,e.apiBase??void 0,t),ue(``),ce(null),fe(!1),Y.success(b(`settings:provider.savedToast`,{name:e.name})),e.apiBase&&setTimeout(()=>h.probeProvider(e.id,6e3),700))},[le,he,l,f,h]),ve=_.trim()?t.filter(e=>{let t=_.trim().toLowerCase();return e.id.toLowerCase().includes(t)||e.name.toLowerCase().includes(t)||e.family.toLowerCase().includes(t)}):t,ye=ve.reduce((e,t)=>(e[t.family]||(e[t.family]=[]),e[t.family]?.push(t),e),{});return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsxs)(`h3`,{className:`text-sm font-semibold flex items-center gap-2`,children:[(0,Q.jsx)(o,{className:`h-4 w-4 text-muted-foreground`}),b(`settings:provider.subscriptionHeading`)]}),(0,Q.jsx)(Nl,{ws:h})]}),(0,Q.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Q.jsxs)(`h3`,{className:`text-sm font-semibold mb-1 flex items-center gap-2`,children:[(0,Q.jsx)(Rn,{className:`h-4 w-4 text-muted-foreground`}),b(`settings:provider.apiKeysHeading`)]}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mb-3`,children:b(`settings:provider.apiKeysBody`)})]}),(0,Q.jsxs)(`div`,{className:`flex gap-2 mb-4`,children:[(0,Q.jsxs)(X,{variant:a===`catalog`?`default`:`outline`,size:`sm`,onClick:()=>s(`catalog`),children:[(0,Q.jsx)(Rn,{className:`h-4 w-4 mr-1`}),b(`settings:provider.tabCatalog`)]}),(0,Q.jsxs)(X,{variant:a===`saved`?`default`:`outline`,size:`sm`,onClick:()=>s(`saved`),children:[(0,Q.jsx)(o,{className:`h-4 w-4 mr-1`}),b(`settings:provider.tabSaved`,{count:r.length})]})]}),a===`catalog`&&(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(fi,{placeholder:b(`settings:provider.searchPlaceholder`,{count:t.length}),value:_,onChange:e=>y(e.target.value),className:`text-sm`}),n&&t.length===0?(0,Q.jsxs)(`div`,{className:`flex items-center justify-center py-8`,children:[(0,Q.jsx)(g,{className:`h-6 w-6 animate-spin text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`ml-2 text-muted-foreground`,children:b(`settings:provider.loadingCatalog`)})]}):ve.length===0&&_?(0,Q.jsx)(`div`,{className:`text-center py-8 text-muted-foreground text-sm`,children:b(`settings:provider.noMatch`,{query:_})}):ql.map(t=>{let n=ye[t];return n?.length?(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-muted-foreground uppercase tracking-wider`,children:t}),(0,Q.jsx)(`div`,{className:`grid grid-cols-1 gap-2`,children:n.map(t=>{let n=pe[t.id],r=e===t.id;return(0,Q.jsxs)(`div`,{className:G(`rounded-lg border transition-all`,r?`border-primary bg-primary/5 ring-2 ring-primary/20`:`border-border`),children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>c(t.id),className:G(`flex w-full flex-col items-start p-3 text-left rounded-lg`,!r&&`hover:bg-muted`),children:[(0,Q.jsxs)(`div`,{className:`flex w-full justify-between items-start`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:t.name}),(0,Q.jsxs)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:[`(`,t.id,`)`]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t.hasApiKey&&(0,Q.jsxs)(`span`,{className:`text-xs bg-success/10 text-success px-2 py-0.5 rounded`,children:[(0,Q.jsx)(o,{className:`h-3 w-3 inline mr-1`}),b(`settings:provider.configured`)]}),n&&(0,Q.jsxs)(`span`,{className:G(`text-xs px-2 py-0.5 rounded inline-flex items-center gap-1`,n.ok?`bg-success/10 text-success`:`bg-destructive/10 text-destructive`),title:n.detail??n.status,children:[n.ok?(0,Q.jsx)(Gt,{className:`h-3 w-3`}):(0,Q.jsx)(un,{className:`h-3 w-3`}),n.ok?b(`settings:provider.reachable`):n.status]}),t.envVars[0]&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:b(`settings:provider.envVar`,{var:t.envVars[0]})}),r&&(0,Q.jsx)(Gt,{className:`h-4 w-4 text-primary`})]})]}),(0,Q.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[b(`settings:provider.modelCount`,{count:t.modelCount}),t.apiBase&&` · ${t.apiBase}`]})]}),r&&!t.hasApiKey&&(0,Q.jsx)(`div`,{className:`px-3 pb-3 -mt-1 space-y-2`,children:se===t.id?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(fi,{autoFocus:!0,type:de?`text`:`password`,placeholder:b(`settings:provider.keyPlaceholder`,{name:t.name}),value:le,onChange:e=>ue(e.target.value),className:`text-sm`,onKeyDown:e=>{e.key===`Enter`&&_e(t)}}),(0,Q.jsx)(X,{size:`icon`,variant:`ghost`,onClick:()=>fe(e=>!e),children:de?(0,Q.jsx)(R,{className:`h-4 w-4`}):(0,Q.jsx)(it,{className:`h-4 w-4`})}),(0,Q.jsx)(X,{size:`sm`,onClick:()=>_e(t),disabled:!le.trim(),children:b(`common:action.save`)})]}),t.envVars[0]&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:b(`settings:provider.orEnv`,{env:t.envVars[0]})})]}):(0,Q.jsxs)(X,{size:`sm`,variant:`outline`,onClick:()=>{ce(t.id),ue(``)},children:[(0,Q.jsx)(o,{className:`h-3.5 w-3.5 mr-1`}),b(`settings:provider.addApiKey`)]})})]},t.id)})})]},t):null})]}),a===`saved`&&(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:b(`settings:provider.manageKeys`)}),(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2 text-xs text-muted-foreground`,children:[(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-muted/30 px-2 py-1`,children:[(0,Q.jsx)(re,{className:`h-3.5 w-3.5`}),b(`settings:provider.savedProviderCount`,{count:r.length})]}),(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-muted/30 px-2 py-1`,children:[(0,Q.jsx)(o,{className:`h-3.5 w-3.5`}),b(`settings:provider.keyCount`,{count:ge.keys})]}),(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-muted/30 px-2 py-1`,children:[(0,Q.jsx)(v,{className:`h-3.5 w-3.5`}),b(`settings:provider.activeKeyCount`,{count:ge.activeKeys})]}),(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-muted/30 px-2 py-1`,children:[(0,Q.jsx)(yt,{className:`h-3.5 w-3.5`}),b(`settings:provider.modelCount`,{count:ge.models})]})]})]}),(0,Q.jsxs)(X,{size:`sm`,variant:`outline`,onClick:()=>j(!A),children:[(0,Q.jsx)(jt,{className:`h-4 w-4 mr-1`}),b(`settings:provider.addProvider`)]})]}),A&&(0,Q.jsxs)(`div`,{className:`p-4 border rounded-lg space-y-3 bg-muted/50`,children:[(0,Q.jsx)(`h4`,{className:`font-medium`,children:b(`settings:provider.addCustomHeading`)}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:b(`settings:provider.localServers`)}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:Al.map(e=>(0,Q.jsx)(X,{type:`button`,size:`sm`,variant:M===e.id?`default`:`outline`,onClick:()=>oe(e),title:e.hint,children:e.label},e.id))})]}),(0,Q.jsx)(fi,{placeholder:b(`settings:provider.providerIdPlaceholder`),value:M,onChange:e=>N(e.target.value),ref:L.setFieldRef(0),onKeyDown:e=>L.handleKeyDown(e,0)}),(0,Q.jsxs)(`select`,{className:`flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm`,value:P,onChange:e=>ee(e.target.value),ref:L.setFieldRef(1),onKeyDown:e=>L.handleKeyDown(e,1),children:[(0,Q.jsx)(`option`,{value:`anthropic`,children:`Anthropic`}),(0,Q.jsx)(`option`,{value:`openai`,children:`OpenAI`}),(0,Q.jsx)(`option`,{value:`openai-compatible`,children:`OpenAI Compatible`}),(0,Q.jsx)(`option`,{value:`google`,children:`Google`})]}),(0,Q.jsx)(fi,{placeholder:`Base URL (optional, e.g. http://localhost:11434/v1)`,value:te,onChange:e=>F(e.target.value),ref:L.setFieldRef(2),onKeyDown:e=>L.handleKeyDown(e,2)}),(0,Q.jsx)(fi,{type:`password`,placeholder:b(`settings:provider.apiKeyOptionalPlaceholder`),value:I,onChange:e=>ne(e.target.value),ref:L.setFieldRef(3),onKeyDown:e=>L.handleKeyDown(e,3)}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(X,{size:`sm`,onClick:z,disabled:!M.trim(),ref:L.setFieldRef(4),onKeyDown:e=>L.handleKeyDown(e,4,z),children:b(`common:action.add`)}),(0,Q.jsx)(X,{size:`sm`,variant:`ghost`,onClick:()=>j(!1),ref:L.setFieldRef(5),onKeyDown:e=>L.handleKeyDown(e,5),children:b(`common:action.cancel`)})]})]}),i?(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,Q.jsx)(g,{className:`h-6 w-6 animate-spin text-muted-foreground`})}):r.length===0?(0,Q.jsxs)(`div`,{className:`text-center py-8 text-muted-foreground`,children:[(0,Q.jsx)(o,{className:`h-8 w-8 mx-auto mb-2 opacity-50`}),(0,Q.jsx)(`p`,{children:b(`settings:provider.noSaved`)}),(0,Q.jsx)(`p`,{className:`text-sm`,children:b(`settings:provider.noSavedHint`)})]}):r.map(e=>(0,Q.jsxs)(`div`,{className:`rounded-lg border border-border/80 bg-card/70 p-4 shadow-sm shadow-black/[0.02]`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`h4`,{className:`min-w-0 truncate font-mono text-sm font-semibold text-foreground`,children:e.id}),e.family&&(0,Q.jsx)(`span`,{className:`rounded-full border border-border/70 bg-muted/40 px-2 py-0.5 text-[11px] font-medium text-muted-foreground`,children:e.family}),e.apiKeys.some(e=>e.isActive)&&(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-success/10 px-2 py-0.5 text-[11px] font-medium text-success`,children:[(0,Q.jsx)(v,{className:`h-3 w-3`}),b(`settings:provider.active`)]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-xs text-muted-foreground`,children:[e.baseUrl&&(0,Q.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-1 rounded-md border border-border/70 bg-background/60 px-2 py-1`,children:[(0,Q.jsx)(Rn,{className:`h-3.5 w-3.5 shrink-0`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.baseUrl})]}),(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-background/60 px-2 py-1`,children:[(0,Q.jsx)(yt,{className:`h-3.5 w-3.5`}),b(`settings:provider.modelCount`,{count:e.models?.length??0})]}),(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-background/60 px-2 py-1`,children:[(0,Q.jsx)(o,{className:`h-3.5 w-3.5`}),b(`settings:provider.keyCount`,{count:e.apiKeys.length})]})]})]}),(0,Q.jsx)(`div`,{className:`flex gap-2 sm:justify-end`,children:(0,Q.jsx)(X,{size:`icon`,variant:`ghost`,onClick:()=>p(e.id),"aria-label":`Remove provider ${e.id}`,title:`Remove provider ${e.id}`,className:`h-8 w-8 text-muted-foreground hover:bg-destructive/10 hover:text-destructive`,children:(0,Q.jsx)(C,{className:`h-4 w-4 text-destructive`})})})]}),(0,Q.jsxs)(`div`,{className:`mt-4 grid gap-4 xl:grid-cols-[minmax(0,1.35fr)_minmax(280px,0.85fr)]`,children:[(0,Q.jsx)(Gl,{providerId:e.id,savedPickedModelId:e.pickedModelId,savedModels:e.models,ws:h,onPickModel:m}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-background/75 p-3 shadow-sm shadow-black/[0.02]`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-semibold`,children:b(`settings:provider.apiKeysLabel`)}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:b(`settings:provider.keyCount`,{count:e.apiKeys.length})})]}),(0,Q.jsxs)(X,{size:`sm`,variant:`ghost`,onClick:()=>S(x===e.id?null:e.id),className:`h-8 px-2 text-xs`,children:[(0,Q.jsx)(jt,{className:`h-3.5 w-3.5`}),b(`settings:provider.addKey`)]})]}),e.apiKeys.length===0&&!x&&(0,Q.jsx)(`p`,{className:`mt-3 rounded-md border border-dashed border-border/70 bg-muted/20 px-3 py-2 text-xs text-muted-foreground`,children:b(`settings:provider.noKeys`)}),e.apiKeys.length>0&&(0,Q.jsx)(`div`,{className:`mt-3 space-y-2`,children:e.apiKeys.map(t=>(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-border/70 bg-muted/20 p-2.5 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,Q.jsx)(`span`,{className:`mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-border/70 bg-background text-muted-foreground`,children:(0,Q.jsx)(o,{className:`h-3.5 w-3.5`})}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`truncate text-sm font-medium`,children:t.label}),t.isActive&&(0,Q.jsx)(`span`,{className:`rounded-full bg-success/10 px-2 py-0.5 text-[11px] font-medium text-success`,children:b(`settings:provider.active`)})]}),(0,Q.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-xs text-muted-foreground`,children:t.maskedKey})]})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-1`,children:[!t.isActive&&(0,Q.jsx)(X,{size:`sm`,variant:`outline`,onClick:()=>d(e.id,t.label),className:`h-8 px-2 text-xs`,children:b(`settings:provider.setActive`)}),(0,Q.jsx)(X,{size:`icon`,variant:`ghost`,onClick:()=>u(e.id,t.label),"aria-label":`Delete key ${t.label}`,title:`Delete key ${t.label}`,className:`h-8 w-8 text-muted-foreground hover:bg-destructive/10 hover:text-destructive`,children:(0,Q.jsx)(C,{className:`h-3.5 w-3.5 text-destructive`})})]})]},t.label))}),x===e.id&&(0,Q.jsxs)(`div`,{className:`mt-3 space-y-2 rounded-lg border border-border/70 bg-background p-3`,children:[(0,Q.jsx)(fi,{placeholder:b(`settings:provider.keyLabelPlaceholder`),value:w,onChange:e=>T(e.target.value),ref:ie.setFieldRef(0),onKeyDown:e=>ie.handleKeyDown(e,0)}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(fi,{type:O?`text`:`password`,placeholder:b(`settings:provider.apiKeyPlaceholder`),value:E,onChange:e=>D(e.target.value),ref:ie.setFieldRef(1),onKeyDown:e=>ie.handleKeyDown(e,1)}),(0,Q.jsx)(X,{size:`icon`,variant:`ghost`,onClick:()=>k(!O),children:O?(0,Q.jsx)(R,{className:`h-4 w-4`}):(0,Q.jsx)(it,{className:`h-4 w-4`})})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(X,{size:`sm`,onClick:()=>ae(e.id),disabled:!w.trim()||!E.trim(),ref:ie.setFieldRef(2),onKeyDown:t=>ie.handleKeyDown(t,2,()=>ae(e.id)),children:b(`settings:provider.saveKey`)}),(0,Q.jsx)(X,{size:`sm`,variant:`ghost`,onClick:()=>{S(null),T(``),D(``)},ref:ie.setFieldRef(3),onKeyDown:e=>ie.handleKeyDown(e,3),children:b(`common:action.cancel`)})]})]})]})]})]},e.id))]})]})}var Yl=[{phase:`discovery`,label:`Discovery`,roles:[{role:`explore`,name:`Explore`},{role:`search`,name:`Search`},{role:`research`,name:`Research`}]},{phase:`planning`,label:`Planning`,roles:[{role:`analyst`,name:`Analyst`},{role:`planner`,name:`Planner`},{role:`architect`,name:`Architect`},{role:`critic`,name:`Critic`},{role:`refactor-planner`,name:`Refactor Planner`}]},{phase:`build`,label:`Build`,roles:[{role:`executor`,name:`Executor`},{role:`refactor`,name:`Refactor`},{role:`simplifier`,name:`Simplifier`},{role:`migration`,name:`Migration`},{role:`vision`,name:`Vision`},{role:`debugger`,name:`Debugger`},{role:`tracer`,name:`Tracer`}]},{phase:`verify`,label:`Verify`,roles:[{role:`verifier`,name:`Verifier`},{role:`test`,name:`Test`},{role:`e2e`,name:`E2E`},{role:`browser`,name:`Browser`},{role:`performance`,name:`Performance`},{role:`chaos`,name:`Chaos`},{role:`security-scanner`,name:`Security Scanner`},{role:`bug-hunter`,name:`Bug Hunter`},{role:`audit-log`,name:`Audit Log`}]},{phase:`review`,label:`Review`,roles:[{role:`reviewer`,name:`Reviewer`},{role:`code-reviewer`,name:`Code Reviewer`},{role:`security-reviewer`,name:`Security Reviewer`},{role:`accessibility`,name:`Accessibility`},{role:`compliance`,name:`Compliance`}]},{phase:`domain`,label:`Domain`,roles:[{role:`database`,name:`Database`},{role:`api`,name:`API`},{role:`auth`,name:`Auth`},{role:`data`,name:`Data`},{role:`frontend`,name:`Frontend`},{role:`backend`,name:`Backend`},{role:`designer`,name:`Designer`},{role:`ios`,name:`iOS`}]},{phase:`knowledge`,label:`Knowledge`,roles:[{role:`document`,name:`Document`},{role:`uml`,name:`UML`},{role:`i18n`,name:`I18n`},{role:`prompt`,name:`Prompt`}]},{phase:`delivery`,label:`Delivery`,roles:[{role:`git`,name:`Git`},{role:`release`,name:`Release`},{role:`devops`,name:`DevOps`},{role:`observability`,name:`Observability`},{role:`dependency`,name:`Dependency`}]},{phase:`meta`,label:`Meta`,roles:[{role:`skill-manage`,name:`Skill Manager`},{role:`self-improving`,name:`Self-Improving`},{role:`context`,name:`Context`},{role:`cost`,name:`Cost`},{role:`tech-stack`,name:`Tech Stack Validator`}]}],Xl=Yl.map(e=>e.phase),Zl=Yl.flatMap(e=>[...e.roles]),Ql=Zl.map(e=>e.role),$l=[`*`,...Xl,...Ql];function eu(e){if(e===`*`)return`Default (*)`;let t=Yl.find(t=>t.phase===e);if(t)return`Phase: ${t.label} (${t.phase})`;let n=Zl.find(t=>t.role===e);return n?`${n.name} (${n.role})`:`Custom: ${e}`}var tu=[{value:``,label:`mode: inherit`},{value:`auto`,label:`mode: auto`},{value:`on`,label:`mode: on`},{value:`off`,label:`mode: off`}],nu=[{value:``,label:`effort: inherit`},{value:`none`,label:`effort: none`},{value:`minimal`,label:`effort: minimal`},{value:`low`,label:`effort: low`},{value:`medium`,label:`effort: medium`},{value:`high`,label:`effort: high`},{value:`xhigh`,label:`effort: xhigh`},{value:`max`,label:`effort: max`}],ru=[{value:``,label:`preserve: inherit`},{value:`on`,label:`preserve: on`},{value:`off`,label:`preserve: off`}],iu=new Set($l);function au(e,t,n){let r={};return e&&(r.mode=e),t&&(r.effort=t),n&&(r.preserve=n===`on`),Object.keys(r).length>0?{reasoning:r}:void 0}function ou(e){return e?[e.mode?`mode:${e.mode}`:``,e.effort?`effort:${e.effort}`:``,e.preserve===void 0?``:`preserve:${e.preserve?`on`:`off`}`].filter(Boolean):[]}function su({syncPref:e,candidates:t}){let n=W(),{t:r}=V(),[i,a]=(0,Z.useState)(`*`),[o,s]=(0,Z.useState)(``),[c,l]=(0,Z.useState)(``),[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(``),m=(0,Z.useCallback)(t=>e(`modelMatrix`,t),[e]),h=(0,Z.useCallback)(()=>{let e=i.trim(),t=o.trim(),r=au(c,u,f);if(!e||!t&&!r)return;let a=t?n.fallbackProfiles[t]?{fallbackProfile:t}:t.includes(`/`)?{provider:t.slice(0,t.indexOf(`/`)),model:t.slice(t.indexOf(`/`)+1)}:{model:t}:{},h=n.modelMatrix[e]?.modelRuntime;r?a.modelRuntime=r:h&&(a.modelRuntime=h),m({...n.modelMatrix,[e]:a}),s(``),l(``),d(``),p(``)},[n.fallbackProfiles,n.modelMatrix,i,f,u,c,o,m]),g=(0,Z.useCallback)(e=>{let{[e]:t,...r}=n.modelMatrix;m(r)},[n.modelMatrix,m]),_=(0,Z.useCallback)((e,t,r)=>{let i={...n.modelMatrix},a={...i[e]??{}},o={...a.modelRuntime??{}},s={...o.reasoning??{}};t===`mode`?r?s.mode=r:delete s.mode:t===`effort`?r?s.effort=r:delete s.effort:r?s.preserve=r===`on`:delete s.preserve,Object.keys(s).length>0?o.reasoning=s:delete o.reasoning,Object.keys(o).length>0?a.modelRuntime=o:delete a.modelRuntime,a.model||a.fallbackProfile||a.modelRuntime?i[e]=a:delete i[e],m(i)},[n.modelMatrix,m]),v=e=>{let t=e.provider&&e.model?`${e.provider}/${e.model}`:e.model,n=e.modelRuntime?.reasoning;return[t??(!e.fallbackProfile&&n?r(`settings:agent.leaderModel`):``),e.fallbackProfile?`profile:${e.fallbackProfile}`:``,...ou(n)].filter(Boolean).join(` + `)},y=Array.from(new Set([...Object.keys(n.modelMatrix),i].filter(e=>e&&!iu.has(e)))).sort((e,t)=>e.localeCompare(t));return(0,Q.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Q.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 mt-3 flex items-center gap-2`,children:[(0,Q.jsx)(vt,{className:`h-4 w-4 text-muted-foreground`}),r(`settings:agent.routingHeading`)]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-[minmax(0,180px)_1fr_auto]`,children:[(0,Q.jsxs)(`select`,{"aria-label":r(`settings:agent.routingRouteKey`),value:i,onChange:e=>a(e.target.value),className:`h-9 min-w-0 rounded-md border bg-background px-3 font-mono text-sm`,children:[(0,Q.jsx)(`option`,{value:`*`,children:eu(`*`)}),(0,Q.jsx)(`optgroup`,{label:r(`settings:agent.routingPhasesGroup`),children:Yl.map(e=>(0,Q.jsx)(`option`,{value:e.phase,children:eu(e.phase)},e.phase))}),Yl.map(e=>(0,Q.jsx)(`optgroup`,{label:r(`settings:agent.routingRolesGroup`,{label:e.label}),children:e.roles.map(e=>(0,Q.jsx)(`option`,{value:e.role,children:eu(e.role)},e.role))},e.phase)),y.length>0?(0,Q.jsx)(`optgroup`,{label:r(`settings:agent.routingCustomGroup`),children:y.map(e=>(0,Q.jsx)(`option`,{value:e,children:eu(e)},e))}):null]}),(0,Q.jsxs)(`select`,{"aria-label":r(`settings:agent.routingTargetAria`),value:o,onChange:e=>s(e.target.value),className:`h-9 min-w-0 rounded-md border bg-background px-3 font-mono text-sm`,children:[(0,Q.jsx)(`option`,{value:``,children:r(`settings:agent.routingTargetEmpty`)}),Object.keys(n.fallbackProfiles).length>0&&(0,Q.jsx)(`optgroup`,{label:r(`settings:agent.routingTargetProfilesGroup`),children:Object.keys(n.fallbackProfiles).map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e))}),t&&t.length>0&&(0,Q.jsx)(`optgroup`,{label:r(`settings:agent.routingTargetModelsGroup`),children:t.map(e=>(0,Q.jsxs)(`option`,{value:`${e.provider}/${e.model}`,children:[e.provider,`/`,e.model]},`${e.provider}/${e.model}`))})]}),(0,Q.jsx)(X,{type:`button`,variant:`outline`,onClick:h,children:r(`settings:agent.routingSet`)})]}),(0,Q.jsxs)(`div`,{className:`mt-2 grid grid-cols-1 gap-2 sm:grid-cols-3`,children:[(0,Q.jsx)(`select`,{"aria-label":r(`settings:agent.routingReasoningModeAria`),value:c,onChange:e=>l(e.target.value),className:`h-8 min-w-0 rounded-md border bg-background px-2 text-xs`,children:tu.map(e=>(0,Q.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))}),(0,Q.jsx)(`select`,{"aria-label":r(`settings:agent.routingReasoningEffortAria`),value:u,onChange:e=>d(e.target.value),className:`h-8 min-w-0 rounded-md border bg-background px-2 text-xs`,children:nu.map(e=>(0,Q.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))}),(0,Q.jsx)(`select`,{"aria-label":r(`settings:agent.routingReasoningPreserveAria`),value:f,onChange:e=>p(e.target.value),className:`h-8 min-w-0 rounded-md border bg-background px-2 text-xs`,children:ru.map(e=>(0,Q.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))})]}),(0,Q.jsx)(`div`,{className:`mt-3 space-y-1.5`,children:Object.keys(n.modelMatrix).length===0?(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`settings:agent.noRoutes`)}):Object.entries(n.modelMatrix).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>(0,Q.jsxs)(`div`,{className:`rounded-md border border-border bg-muted px-2 py-1.5 text-xs`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`w-40 shrink-0 truncate font-mono text-muted-foreground`,title:e,children:eu(e)}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:v(t)}),(0,Q.jsx)(X,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>g(e),children:r(`common:action.remove`)})]}),(0,Q.jsxs)(`div`,{className:`mt-2 grid grid-cols-1 gap-2 sm:grid-cols-3`,children:[(0,Q.jsx)(`select`,{"aria-label":r(`settings:agent.routingReasoningModeFor`,{key:e}),value:t.modelRuntime?.reasoning?.mode??``,onChange:t=>_(e,`mode`,t.target.value),className:`h-8 min-w-0 rounded-md border bg-background px-2 text-xs`,children:tu.map(e=>(0,Q.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))}),(0,Q.jsx)(`select`,{"aria-label":r(`settings:agent.routingReasoningEffortFor`,{key:e}),value:t.modelRuntime?.reasoning?.effort??``,onChange:t=>_(e,`effort`,t.target.value),className:`h-8 min-w-0 rounded-md border bg-background px-2 text-xs`,children:nu.map(e=>(0,Q.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))}),(0,Q.jsx)(`select`,{"aria-label":r(`settings:agent.routingReasoningPreserveFor`,{key:e}),value:t.modelRuntime?.reasoning?.preserve===void 0?``:t.modelRuntime.reasoning.preserve?`on`:`off`,onChange:t=>_(e,`preserve`,t.target.value),className:`h-8 min-w-0 rounded-md border bg-background px-2 text-xs`,children:ru.map(e=>(0,Q.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))})]})]},e))})]})}function cu(){let[e,t]=(0,Z.useState)(null),[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!0);(0,Z.useEffect)(()=>{s(!1)},[]);let c=(0,Z.useCallback)(async()=>{a(!0),r(!0),t(`pending`),a(!1)},[]),l=(0,Z.useCallback)(async()=>{a(!0),r(!1),t(null),a(!1)},[]);return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(it,{className:`h-5 w-5 text-info`}),(0,Q.jsx)(`h3`,{className:`text-lg font-semibold`,children:`Shadow Agent`}),o&&(0,Q.jsx)(g,{className:`h-4 w-4 animate-spin ml-2`}),n?(0,Q.jsx)(el,{className:`bg-success text-primary-foreground text-[10px]`,children:`● running`}):(0,Q.jsx)(el,{variant:`outline`,className:`text-[10px]`,children:`○ stopped`})]}),e&&(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Agent ID: `,(0,Q.jsxs)(`code`,{className:`font-mono`,children:[e.slice(0,12),`…`]})]}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`The Shadow Agent monitors all fleet agents, tracks their tasks, and detects anomalies (spike tasks, stuck agents, mailbox loops).`}),(0,Q.jsx)(`div`,{className:`flex gap-2`,children:n?(0,Q.jsxs)(X,{variant:`destructive`,size:`sm`,className:`gap-1`,onClick:l,disabled:i,children:[i?(0,Q.jsx)(g,{className:`h-4 w-4 animate-spin`}):(0,Q.jsx)(An,{className:`h-4 w-4`}),`Stop Shadow Agent`]}):(0,Q.jsxs)(X,{variant:`default`,size:`sm`,className:`gap-1`,onClick:c,disabled:i,children:[i?(0,Q.jsx)(g,{className:`h-4 w-4 animate-spin`}):(0,Q.jsx)(it,{className:`h-4 w-4`}),`Start Shadow Agent`]})})]})}function lu({disabled:e,mutating:t}){return(0,Q.jsx)(`span`,{className:`inline-block h-2 w-2 shrink-0 rounded-full ${e?`bg-muted-foreground`:t?`bg-warning`:`bg-success`}`,title:e?`disabled`:t?`mutating`:`read-only`})}function uu({tool:e,onToggle:t,busy:n}){let[r,i]=(0,Z.useState)(!1);return(0,Q.jsxs)(`div`,{className:`space-y-2 rounded-md border border-border/70 bg-card/70 p-3 transition-colors hover:bg-card`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 sm:flex-row sm:items-start`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-2`,children:[(0,Q.jsx)(lu,{disabled:e.disabled,mutating:e.mutating}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`code`,{className:`block truncate text-sm font-mono font-semibold`,title:e.name,children:e.name}),(0,Q.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1.5`,children:[(0,Q.jsx)(el,{variant:`outline`,className:`px-1.5 text-[10px]`,children:e.permission}),(0,Q.jsx)(el,{variant:`outline`,className:`px-1.5 text-[10px]`,children:e.mutating?`mutating`:`read-only`}),(0,Q.jsx)(`span`,{className:`truncate text-[11px] text-muted-foreground`,title:e.owner,children:e.owner})]})]})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-1`,children:[(0,Q.jsxs)(X,{variant:e.disabled?`default`:`secondary`,size:`sm`,className:`h-7 gap-1 px-2 text-xs`,onClick:t,disabled:n,children:[n?(0,Q.jsx)(g,{className:`h-3 w-3 animate-spin`}):e.disabled?(0,Q.jsx)(An,{className:`h-3 w-3`}):(0,Q.jsx)(gn,{className:`h-3 w-3`}),e.disabled?`Enable`:`Disable`]}),(0,Q.jsx)(`button`,{type:`button`,className:`rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,onClick:()=>i(!r),"aria-label":r?`Collapse`:`Expand`,children:(0,Q.jsx)(b,{className:`h-4 w-4 transition-transform ${r?`rotate-180`:``}`})})]})]}),r&&(0,Q.jsxs)(`div`,{className:`space-y-1 border-t border-border/60 pt-2 text-xs text-muted-foreground sm:ml-4`,children:[(0,Q.jsx)(`p`,{children:e.description}),e.params.length>0&&(0,Q.jsxs)(`p`,{children:[`Params: `,(0,Q.jsx)(`code`,{className:`break-all font-mono`,children:e.params.join(`, `)})]})]})]})}function du(){let{client:e}=dr(),[t,n]=(0,Z.useState)([]),[r,i]=(0,Z.useState)(!0),[a,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(new Set);(0,Z.useEffect)(()=>{let t=e.on(`tools.list`,e=>{let t=e.payload;n(t.tools),i(!1)}),r=t=>{if(t.type===`tool.disabled`||t.type===`tool.enabled`){let n=t.payload;c(e=>{let t=new Set(e);return t.delete(n.name),t}),n.ok?e.send({type:`tools.list`},{echoToChat:!1}):Y.error(`Tool "${n.name}" ${t.type===`tool.disabled`?`disable`:`enable`} failed.`)}},a=e.on(`tool.disabled`,r),o=e.on(`tool.enabled`,r);return()=>{t(),a(),o()}},[e]),(0,Z.useEffect)(()=>{e.send({type:`tools.list`},{echoToChat:!1})},[e]);let l=(0,Z.useCallback)((t,n)=>{c(e=>new Set(e).add(t)),e.send({type:n?`tool.enable`:`tool.disable`,payload:{name:t}})},[e]),u=a?t.filter(e=>e.name.toLowerCase().includes(a.toLowerCase())||e.owner.toLowerCase().includes(a.toLowerCase())):t,d=t.filter(e=>!e.disabled).length,f=t.filter(e=>e.disabled).length;return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Q.jsx)(`span`,{className:`flex h-9 w-9 items-center justify-center rounded-md border border-primary/20 bg-primary/10 text-primary`,children:(0,Q.jsx)(Mn,{className:`h-5 w-5`})}),(0,Q.jsx)(`h3`,{className:`text-base font-semibold`,children:`Tools`})]}),!r&&(0,Q.jsxs)(`span`,{className:`rounded-md border border-border/60 bg-muted/30 px-2 py-1 text-xs text-muted-foreground sm:ml-auto`,children:[d,` active · `,f,` disabled · `,t.length,` total`]})]}),(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(Tn,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground`}),(0,Q.jsx)(fi,{placeholder:`Filter tools by name or owner…`,value:a,onChange:e=>o(e.target.value),className:`pl-8 h-9 text-sm`})]}),r?(0,Q.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground gap-2`,children:[(0,Q.jsx)(g,{className:`h-4 w-4 animate-spin`}),`Loading tools…`]}):u.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground py-4 text-center`,children:a?`No tools matching "${a}".`:`No tools registered.`}):(0,Q.jsxs)(`div`,{className:`relative overflow-hidden rounded-lg border border-border/70 bg-background/35 shadow-inner`,children:[(0,Q.jsx)(`ul`,{className:`max-h-[min(58dvh,660px)] space-y-2 overflow-y-scroll p-2 pr-3 [scrollbar-gutter:stable]`,"aria-label":`Tools list`,children:u.map(e=>(0,Q.jsx)(`li`,{children:(0,Q.jsx)(uu,{tool:e,onToggle:()=>l(e.name,e.disabled),busy:s.has(e.name)})},e.name))}),(0,Q.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 top-0 h-4 bg-gradient-to-b from-background/90 to-transparent`}),(0,Q.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 h-8 bg-gradient-to-t from-background/95 to-transparent`})]})]})}function fu(){let{settingsActiveTab:e,setSettingsActiveTab:t}=U($t(e=>({settingsActiveTab:e.settingsActiveTab,setSettingsActiveTab:e.setSettingsActiveTab}))),n=Os(`settings`),{provider:r,model:i,setProvider:a,setModel:o,wsConnected:s}=q($t(e=>({provider:e.provider,model:e.model,setProvider:e.setProvider,setModel:e.setModel,wsConnected:e.wsConnected}))),c=dr(),l=c.client,{updatePrefs:u,switchAutonomy:d}=c,f=W(),{t:p}=V(),m=ei(!0),h=(0,Z.useCallback)((e,t)=>{f.set({[e]:t}),u({[e]:t})},[f,u]),[g,_]=(0,Z.useState)([]),[v,y]=(0,Z.useState)({}),[b,S]=(0,Z.useState)([]),[C,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(!1),[D,O]=(0,Z.useState)(!1),[k,A]=(0,Z.useState)(`catalog`),[j,M]=(0,Z.useState)(``),[N,P]=(0,Z.useState)(``),[ee,te]=(0,Z.useState)(!1),F=g.find(e=>e.id===r);(0,Z.useEffect)(()=>{let e=e=>{if(e.type===`provider.catalog`){let t=e.payload;_(t.providers.sort((e,t)=>e.id.localeCompare(t.id))),w(!1)}},t=e=>{if(e.type===`provider.models`){let t=e.payload;y(e=>({...e,[t.provider]:t.models})),E(!1)}},n=e=>{if(e.type===`providers.saved`){let t=e.payload.providers.sort((e,t)=>e.id.localeCompare(t.id));S(t),O(!1),t.length>0&&A(`saved`)}};if(!s||!l)return;let r=l.on(`provider.catalog`,e),i=l.on(`provider.models`,t),a=l.on(`providers.saved`,n);return w(!0),O(!0),l.listProviders(),l.listSavedProviders(),()=>{r?.(),i?.(),a?.()}},[s,l]);let I=(0,Z.useCallback)(e=>{a(e),v[e]||(E(!0),c.listProviderModels?.(e))},[v,a,c]),ne=(0,Z.useCallback)(e=>{o(e);let t=q.getState().provider;if(l){let n=null,r=l.on(`key.operation_result`,i=>{n&&clearTimeout(n),r();let a=i.payload;a.success?Y.success(H.t(`settings:toast.switchingTo`,{provider:t,model:e})):Y.error(a.message)});n=setTimeout(r,8e3)}c.switchModel?.(t,e)},[o,c,l]),L=(0,Z.useCallback)((e,t,n)=>{c.addKey?.(e,t,n)},[c]),ie=(0,Z.useCallback)((e,t)=>{c.deleteKey?.(e,t)},[c]),ae=(0,Z.useCallback)((e,t)=>{c.setActiveKey?.(e,t)},[c]),R=(0,Z.useCallback)((e,t,n,r)=>{c.addProvider?.(e,t,n,r)},[c]),z=(0,Z.useCallback)(e=>{c.removeProvider?.(e)},[c]),oe=(0,Z.useCallback)((e,t)=>{c.client.updateProvider({id:e,models:[t]}),e===q.getState().provider&&o(t)},[o,c.client]),se=(0,Z.useCallback)(e=>h(`fallbackProfiles`,e),[h]),ce=(0,Z.useCallback)(()=>{let e=N.trim();if(e){if(f.fallbackProfiles[e]){Y.error(H.t(`settings:toast.fallbackExists`,{name:e}));return}se({...f.fallbackProfiles,[e]:[]}),P(``)}},[f.fallbackProfiles,N,se]),le=(0,Z.useCallback)(()=>{let e=r&&i?`${r}/${i}`:``;if(!e){Y.error(H.t(`settings:toast.selectProviderModelFirst`));return}let t=[e,...f.fallbackModels].filter((e,t,n)=>e&&n.indexOf(e)===t);se({...f.fallbackProfiles,default:t}),Y.success(H.t(`settings:toast.defaultProfileCreated`))},[i,f.fallbackModels,f.fallbackProfiles,r,se]);(0,Z.useEffect)(()=>{if(Object.keys(f.fallbackProfiles).length>0)return;let e=r&&i?`${r}/${i}`:``;if(!e)return;let t=[e,...f.fallbackModels].filter((e,t,n)=>e&&n.indexOf(e)===t);se({default:t})},[i,f.fallbackModels,f.fallbackProfiles,r,se]);let ue=(0,Z.useCallback)((e,t)=>{se({...f.fallbackProfiles,[e]:t})},[f.fallbackProfiles,se]),de=(0,Z.useCallback)(e=>{let{[e]:t,...n}=f.fallbackProfiles;se(n)},[f.fallbackProfiles,se]),fe=(0,Z.useCallback)(e=>{let t=f.fallbackProfiles[e]??[];h(`fallbackModels`,t)},[f.fallbackProfiles,h]),pe=(0,Z.useCallback)(e=>{let t=f.fallbackProfiles[e]??[],n=t[0];if(!n){Y.error(H.t(`settings:toast.profileEmpty`,{name:e}));return}let i=n.indexOf(`/`),s=i>0?n.slice(0,i):r,l=i>0?n.slice(i+1):n;a(s),o(l),c.switchModel?.(s,l),h(`fallbackModels`,t.slice(1)),Y.success(H.t(`settings:toast.leaderSetFrom`,{name:e}))},[f.fallbackProfiles,r,o,a,h,c]);return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col bg-background/70`,children:[(0,Q.jsxs)(`header`,{className:`flex items-center justify-between px-4 py-3 border-b border-border/70 bg-card/90 backdrop-blur-xl shrink-0 shadow-sm`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h1`,{className:`text-lg font-semibold`,children:p(`settings:title`)}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:r&&i?`${r} / ${i}`:p(`settings:tabs.provider`)})]}),(0,Q.jsx)(X,{variant:`ghost`,size:`icon`,onClick:()=>J(`chat`),children:(0,Q.jsx)(vn,{className:`h-4 w-4`})})]}),(0,Q.jsx)(Zs,{className:`min-h-0 flex-1`,ref:n,children:(0,Q.jsx)(`div`,{className:`mx-auto max-w-6xl p-4 sm:p-6`,children:(0,Q.jsxs)($s,{value:e,onValueChange:t,className:`grid min-h-[calc(100dvh-9rem)] gap-3 lg:grid-cols-[13.5rem_minmax(0,1fr)] lg:gap-5`,children:[(0,Q.jsxs)(`div`,{className:`relative min-w-0`,children:[(0,Q.jsxs)(ec,{className:`flex h-auto w-full justify-start gap-1 overflow-x-scroll rounded-lg border border-border/70 bg-card/60 p-1 pb-2 shadow-sm [scrollbar-gutter:stable] lg:sticky lg:top-4 lg:flex-col lg:overflow-visible lg:rounded-xl lg:bg-card/65 lg:p-2`,children:[(0,Q.jsxs)(tc,{value:`provider`,className:`h-9 shrink-0 gap-2 rounded-md px-3 text-xs scroll-mt-2 lg:w-full lg:justify-start`,children:[(0,Q.jsx)(x,{className:`h-3.5 w-3.5`}),p(`settings:tabs.provider`)]}),(0,Q.jsxs)(tc,{value:`connection`,className:`h-9 shrink-0 gap-2 rounded-md px-3 text-xs scroll-mt-2 lg:w-full lg:justify-start`,children:[(0,Q.jsx)(Rn,{className:`h-3.5 w-3.5`}),p(`settings:tabs.connection`)]}),(0,Q.jsxs)(tc,{value:`appearance`,className:`h-9 shrink-0 gap-2 rounded-md px-3 text-xs scroll-mt-2 lg:w-full lg:justify-start`,children:[(0,Q.jsx)(Dt,{className:`h-3.5 w-3.5`}),p(`settings:tabs.appearance`)]}),(0,Q.jsxs)(tc,{value:`agent`,className:`h-9 shrink-0 gap-2 rounded-md px-3 text-xs scroll-mt-2 lg:w-full lg:justify-start`,children:[(0,Q.jsx)(Ee,{className:`h-3.5 w-3.5`}),p(`settings:tabs.agent`)]}),(0,Q.jsxs)(tc,{value:`features`,className:`h-9 shrink-0 gap-2 rounded-md px-3 text-xs scroll-mt-2 lg:w-full lg:justify-start`,children:[(0,Q.jsx)(wt,{className:`h-3.5 w-3.5`}),p(`settings:tabs.features`)]}),(0,Q.jsxs)(tc,{value:`tools`,className:`h-9 shrink-0 gap-2 rounded-md px-3 text-xs scroll-mt-2 lg:w-full lg:justify-start`,children:[(0,Q.jsx)(Mn,{className:`h-3.5 w-3.5`}),p(`settings:tabs.tools`)]}),(0,Q.jsxs)(tc,{value:`mcp`,className:`h-9 shrink-0 gap-2 rounded-md px-3 text-xs scroll-mt-2 lg:w-full lg:justify-start`,children:[(0,Q.jsx)(re,{className:`h-3.5 w-3.5`}),p(`settings:tabs.mcp`)]}),(0,Q.jsxs)(tc,{value:`brain`,className:`h-9 shrink-0 gap-2 rounded-md px-3 text-xs scroll-mt-2 lg:w-full lg:justify-start`,children:[(0,Q.jsx)(on,{className:`h-3.5 w-3.5`}),p(`settings:tabs.brain`)]}),(0,Q.jsxs)(tc,{value:`shadow`,className:`h-9 shrink-0 gap-2 rounded-md px-3 text-xs scroll-mt-2 lg:w-full lg:justify-start`,children:[(0,Q.jsx)(it,{className:`h-3.5 w-3.5`}),p(`settings:tabs.shadow`)]})]}),(0,Q.jsx)(`div`,{className:`pointer-events-none absolute inset-y-1 left-0 z-10 w-8 rounded-l-lg bg-gradient-to-r from-background via-background/90 to-transparent lg:hidden`}),(0,Q.jsx)(`div`,{className:`pointer-events-none absolute inset-y-1 right-0 z-10 w-8 rounded-r-lg bg-gradient-to-l from-background via-background/90 to-transparent lg:hidden`})]}),(0,Q.jsxs)(`div`,{className:`min-w-0 rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm sm:p-5`,children:[(0,Q.jsxs)(nc,{value:`provider`,className:`mt-0 space-y-4`,children:[(0,Q.jsx)(Jl,{activeProvider:r,catalogProviders:g,isLoadingCatalog:C,savedProviders:b,isLoadingSaved:D,providerTab:k,setProviderTab:A,onSelectProvider:I,onAddKey:L,onDeleteKey:ie,onSetActiveKey:ae,onAddProvider:R,onRemoveProvider:z,onPickProviderModel:oe,ws:c.client,catalogQuery:j,setCatalogQuery:M}),(0,Q.jsxs)(`div`,{className:`pt-4 border-t`,children:[(0,Q.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 flex items-center gap-2`,children:[(0,Q.jsx)(yt,{className:`h-4 w-4 text-muted-foreground`}),p(`settings:agent.modelHeading`)]}),(0,Q.jsx)(Tl,{provider:r,catalogModels:v,currentCatalogProvider:F,isLoadingModels:T,setIsLoadingModels:E,onModelSelect:ne,refreshModels:e=>c.listProviderModels?.(e)})]})]}),(0,Q.jsx)(ml,{}),(0,Q.jsx)(hl,{}),(0,Q.jsxs)(nc,{value:`agent`,className:`mt-0 space-y-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 flex items-center gap-2`,children:[(0,Q.jsx)(_t,{className:`h-4 w-4 text-muted-foreground`}),p(`settings:agent.autonomyHeading`)]}),(0,Q.jsx)(nl,{label:p(`settings:agent.autonomyModeLabel`),hint:p(`settings:agent.autonomyModeHint`),value:f.autonomy,options:[{value:`off`,label:p(`settings:agent.autonomyModeOff`)},{value:`suggest`,label:p(`settings:agent.autonomyModeSuggest`)},{value:`auto`,label:p(`settings:agent.autonomyModeAuto`)},{value:`eternal`,label:p(`settings:agent.autonomyModeEternal`)},{value:`eternal-parallel`,label:p(`settings:agent.autonomyModeEternalParallel`)}],onChange:e=>{f.set({autonomy:e}),d(e)}}),(0,Q.jsx)(tl,{label:p(`settings:agent.autoProceedDelayLabel`),hint:p(`settings:agent.autoProceedDelayHint`),value:f.autonomyDelayMs,min:0,max:1e4,step:500,unit:`ms`,onChange:e=>h(`autonomyDelayMs`,e)}),(0,Q.jsx)($,{label:p(`settings:agent.yoloLabel`),hint:p(`settings:agent.yoloHint`),value:f.yolo,onChange:()=>h(`yolo`,!f.yolo)})]}),(0,Q.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Q.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 mt-3 flex items-center gap-2`,children:[(0,Q.jsx)(Tt,{className:`h-4 w-4 text-muted-foreground`}),p(`settings:agent.refineHeading`)]}),(0,Q.jsx)($,{label:p(`settings:agent.enableRefineLabel`),hint:p(`settings:agent.enableRefineHint`),value:f.enhanceEnabled,onChange:()=>h(`enhanceEnabled`,!f.enhanceEnabled)}),(0,Q.jsx)(tl,{label:p(`settings:agent.refineDelayLabel`),hint:p(`settings:agent.refineDelayHint`),value:f.enhanceDelayMs,min:3e4,max:12e4,step:15e3,unit:`ms`,onChange:e=>h(`enhanceDelayMs`,e)}),(0,Q.jsx)(nl,{label:p(`settings:agent.refineLanguageLabel`),hint:p(`settings:agent.refineLanguageHint`),value:f.enhanceLanguage,options:[{value:`original`,label:p(`settings:agent.refineLanguageOriginal`)},{value:`english`,label:p(`settings:agent.refineLanguageEnglish`)}],onChange:e=>h(`enhanceLanguage`,e)}),(0,Q.jsxs)(`div`,{className:`pt-2`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium mb-1`,children:p(`settings:agent.refineHeading`)}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-border p-3 cursor-pointer hover:bg-muted/50 transition-colors`,onClick:()=>te(!0),children:[(0,Q.jsx)(`div`,{className:`min-w-0 flex-1`,children:f.refinerFallbackProfile?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-mono text-primary bg-primary/10 px-1.5 py-0.5 rounded`,children:f.refinerFallbackProfile}),(0,Q.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[(f.fallbackProfiles[f.refinerFallbackProfile]??[]).slice(0,2).join(` → `),(f.fallbackProfiles[f.refinerFallbackProfile]??[]).length>2?` …`:``]})]}):f.refinerProvider&&f.refinerModel?(0,Q.jsxs)(`span`,{className:`text-xs font-mono`,children:[f.refinerProvider,`/`,f.refinerModel]}):f.refinerProvider?(0,Q.jsxs)(`span`,{className:`text-xs font-mono`,children:[f.refinerProvider,` /`,` `,(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`(session model)`})]}):(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:p(`settings:agent.refinerProviderDefault`)})}),(0,Q.jsx)(yt,{className:`h-4 w-4 shrink-0 text-muted-foreground`})]}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:p(`settings:agent.refineDelayHint`)})]}),ee&&(0,Q.jsx)(Qc,{open:ee,mode:`both`,title:p(`settings:agent.refineHeading`),hint:p(`settings:agent.refinerProviderHint`),fallbackProfiles:f.fallbackProfiles,clearLabel:p(`common:action.clear`),onPick:e=>{e.type===`clear`?(h(`refinerProvider`,``),h(`refinerModel`,``),h(`refinerFallbackProfile`,``)):e.type===`provider-model`?(h(`refinerProvider`,e.provider),h(`refinerModel`,e.model),h(`refinerFallbackProfile`,``)):e.type===`fallback-profile`&&(h(`refinerProvider`,``),h(`refinerModel`,``),h(`refinerFallbackProfile`,e.name)),te(!1)},onClose:()=>te(!1)})]}),(0,Q.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Q.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 mt-3 flex items-center gap-2`,children:[(0,Q.jsx)(yt,{className:`h-4 w-4 text-muted-foreground`}),p(`settings:agent.reasoningHeading`)]}),(0,Q.jsx)(nl,{label:p(`settings:agent.reasoningModeLabel`),hint:p(`settings:agent.reasoningModeHint`),value:f.reasoningMode,options:[{value:`auto`,label:p(`settings:agent.reasoningModeAuto`)},{value:`on`,label:p(`settings:agent.reasoningModeOn`)},{value:`off`,label:p(`settings:agent.reasoningModeOff`)}],onChange:e=>h(`reasoningMode`,e)}),(0,Q.jsx)(nl,{label:p(`settings:agent.reasoningEffortLabel`),hint:p(`settings:agent.reasoningEffortHint`),value:f.reasoningEffort,options:[{value:`none`,label:p(`settings:agent.reasoningEffortNone`)},{value:`minimal`,label:p(`settings:agent.reasoningEffortMinimal`)},{value:`low`,label:p(`settings:agent.reasoningEffortLow`)},{value:`medium`,label:p(`settings:agent.reasoningEffortMedium`)},{value:`high`,label:p(`settings:agent.reasoningEffortHigh`)},{value:`xhigh`,label:p(`settings:agent.reasoningEffortXhigh`)},{value:`max`,label:p(`settings:agent.reasoningEffortMax`)}],onChange:e=>h(`reasoningEffort`,e)}),(0,Q.jsx)($,{label:p(`settings:agent.preserveThinkingLabel`),hint:p(`settings:agent.preserveThinkingHint`),value:f.reasoningPreserve,onChange:()=>h(`reasoningPreserve`,!f.reasoningPreserve)}),(0,Q.jsx)(nl,{label:p(`settings:agent.cacheTtlLabel`),hint:p(`settings:agent.cacheTtlHint`),value:f.cacheTtl,options:[{value:`default`,label:p(`settings:agent.cacheTtlDefault`)},{value:`5m`,label:p(`settings:agent.cacheTtl5m`)},{value:`1h`,label:p(`settings:agent.cacheTtl1h`)}],onChange:e=>h(`cacheTtl`,e)}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-2`,children:p(`settings:agent.capsHint`)})]}),(0,Q.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold mb-2 mt-3`,children:`Provider/model availability calendar`}),(0,Q.jsx)(`p`,{className:`mb-3 text-xs text-muted-foreground`,children:`Prevent autonomous and overnight runs from using selected providers or models during recurring windows.`}),(0,Q.jsx)(Yc,{value:f.modelAvailabilitySchedule,candidates:m,onChange:e=>h(`modelAvailabilitySchedule`,e)})]}),(0,Q.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Q.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 mt-3 flex items-center gap-2`,children:[(0,Q.jsx)(yt,{className:`h-4 w-4 text-muted-foreground`}),p(`settings:agent.fallbackHeading`)]}),(0,Q.jsx)(`p`,{className:`mb-2 text-xs text-muted-foreground`,children:p(`settings:agent.fallbackBody`)}),(0,Q.jsx)(Xc,{value:f.fallbackModels,candidates:m,onChange:e=>h(`fallbackModels`,e)}),(0,Q.jsxs)(`div`,{className:`pt-1`,children:[(0,Q.jsx)($,{label:p(`settings:agent.autoFallbackLabel`),hint:p(`settings:agent.autoFallbackHint`),value:f.fallbackAuto,onChange:()=>h(`fallbackAuto`,!f.fallbackAuto)}),(0,Q.jsx)($,{label:p(`settings:agent.favoritesOnlyLabel`),hint:p(`settings:agent.favoritesOnlyHint`),value:f.favoriteModelsOnly,onChange:()=>h(`favoriteModelsOnly`,!f.favoriteModelsOnly)})]})]}),(0,Q.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Q.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 mt-3 flex items-center gap-2`,children:[(0,Q.jsx)(et,{className:`h-4 w-4 text-muted-foreground`}),p(`settings:agent.profilesHeading`)]}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(fi,{value:N,onChange:e=>P(e.target.value),placeholder:`fallback1`,className:`font-mono text-sm`,onKeyDown:e=>{e.key===`Enter`&&ce()}}),(0,Q.jsx)(X,{type:`button`,variant:`outline`,onClick:ce,children:p(`settings:agent.addProfile`)})]}),(0,Q.jsx)(`div`,{className:`mt-3 space-y-3`,children:Object.keys(f.fallbackProfiles).length===0?(0,Q.jsxs)(`div`,{className:`rounded-md border border-dashed border-border p-3`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:p(`settings:agent.noProfiles`)}),(0,Q.jsx)(X,{type:`button`,variant:`outline`,size:`sm`,className:`mt-2`,onClick:le,children:p(`settings:agent.createDefault`)})]}):Object.entries(f.fallbackProfiles).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>(0,Q.jsxs)(`div`,{className:`rounded-md border border-border p-3`,children:[(0,Q.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`span`,{className:`font-mono text-sm font-medium`,children:e}),(0,Q.jsxs)(`div`,{className:`flex gap-1`,children:[(0,Q.jsx)(X,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>fe(e),children:p(`settings:agent.useChain`)}),(0,Q.jsx)(X,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>pe(e),children:p(`settings:agent.setLeader`)}),(0,Q.jsx)(X,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>de(e),children:p(`common:action.remove`)})]})]}),(0,Q.jsx)(Xc,{value:t,candidates:m,placeholder:p(`settings:agent.addModelToProfile`),emptyHint:p(`settings:agent.profileEmpty`),onChange:t=>ue(e,t)})]},e))})]}),(0,Q.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Q.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 mt-3 flex items-center gap-2`,children:[(0,Q.jsx)(yt,{className:`h-4 w-4 text-muted-foreground`}),p(`settings:agent.favoritesHeading`)]}),(0,Q.jsx)(Xc,{value:f.favoriteModels,candidates:m,placeholder:p(`settings:agent.addFavoriteModel`),emptyHint:p(`settings:agent.favoritesEmpty`),onChange:e=>h(`favoriteModels`,e)})]}),(0,Q.jsx)(su,{syncPref:h,candidates:m}),(0,Q.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Q.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 mt-3 flex items-center gap-2`,children:[(0,Q.jsx)(x,{className:`h-4 w-4 text-muted-foreground`}),p(`settings:agent.hqHeading`)]}),(0,Q.jsx)($,{label:p(`settings:agent.hqPublishingLabel`),hint:p(`settings:agent.hqPublishingHint`),value:f.hqEnabled,onChange:()=>h(`hqEnabled`,!f.hqEnabled)}),(0,Q.jsxs)(`div`,{className:`space-y-1 py-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium`,children:p(`settings:agent.hqUrlLabel`)}),(0,Q.jsx)(fi,{value:f.hqUrl,placeholder:`http://host:3499`,onChange:e=>h(`hqUrl`,e.target.value)}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:p(`settings:agent.hqUrlHint`)})]}),(0,Q.jsxs)(`div`,{className:`space-y-1 py-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium`,children:p(`settings:agent.hqTokenLabel`)}),(0,Q.jsx)(fi,{type:`password`,value:f.hqToken,placeholder:`Client token from wstack --hq`,onChange:e=>h(`hqToken`,e.target.value)})]}),(0,Q.jsx)($,{label:p(`settings:agent.hqRawContentLabel`),hint:p(`settings:agent.hqRawContentHint`),value:f.hqRawContent,onChange:()=>h(`hqRawContent`,!f.hqRawContent)})]}),(0,Q.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Q.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 mt-3 flex items-center gap-2`,children:[(0,Q.jsx)(Tt,{className:`h-4 w-4 text-muted-foreground`}),p(`settings:agent.executionHeading`)]}),(0,Q.jsx)(tl,{label:p(`settings:agent.maxIterationsLabel`),hint:p(`settings:agent.maxIterationsHint`),value:f.maxIterations,min:10,max:2e3,step:10,onChange:e=>h(`maxIterations`,e)}),(0,Q.jsx)(tl,{label:p(`settings:agent.autoProceedMaxIterationsLabel`),hint:p(`settings:agent.autoProceedMaxIterationsHint`),value:f.autoProceedMaxIterations,min:0,max:250,step:5,onChange:e=>h(`autoProceedMaxIterations`,e)}),(0,Q.jsx)($,{label:p(`settings:agent.confirmExitLabel`),hint:p(`settings:agent.confirmExitHint`),value:f.confirmExit,onChange:()=>h(`confirmExit`,!f.confirmExit)}),(0,Q.jsx)($,{label:p(`settings:agent.chimeLabel`),hint:p(`settings:agent.chimeHint`),value:f.chime,onChange:()=>h(`chime`,!f.chime)})]}),(0,Q.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Q.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 mt-3 flex items-center gap-2`,children:[(0,Q.jsx)(vt,{className:`h-4 w-4 text-muted-foreground`}),p(`settings:agent.fleetHeading`)]}),(0,Q.jsx)($,{label:p(`settings:agent.streamFleetLabel`),hint:p(`settings:agent.streamFleetHint`),value:f.streamFleet,onChange:()=>h(`streamFleet`,!f.streamFleet)}),(0,Q.jsx)(tl,{label:p(`settings:agent.maxConcurrentLabel`),hint:p(`settings:agent.maxConcurrentHint`),value:f.maxConcurrent,min:1,max:50,step:1,onChange:e=>h(`maxConcurrent`,e)}),(0,Q.jsx)($,{label:p(`settings:agent.nextPredictionLabel`),hint:p(`settings:agent.nextPredictionHint`),value:f.nextPrediction,onChange:()=>h(`nextPrediction`,!f.nextPrediction)})]}),(0,Q.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Q.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 mt-3 flex items-center gap-2`,children:[(0,Q.jsx)(_e,{className:`h-4 w-4 text-muted-foreground`}),p(`settings:agent.telegramHeading`)]}),f.tgConfigured?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)($,{label:p(`settings:agent.telegramSessionEndLabel`),hint:p(`settings:agent.telegramSessionEndHint`),value:f.tgSessionEnd,onChange:()=>h(`tgSessionEnd`,!f.tgSessionEnd)}),(0,Q.jsx)($,{label:p(`settings:agent.telegramDelegateLabel`),hint:p(`settings:agent.telegramDelegateHint`),value:f.tgDelegate,onChange:()=>h(`tgDelegate`,!f.tgDelegate)}),(0,Q.jsx)($,{label:p(`settings:agent.telegramLongToolLabel`),hint:p(`settings:agent.telegramLongToolHint`,{ms:f.tgLongToolMs}),value:f.tgLongToolMs>0,onChange:()=>h(`tgLongToolMs`,f.tgLongToolMs>0?0:3e4)}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-2`,children:p(`settings:agent.telegramChangesApply`)})]}):(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:p(`settings:agent.telegramNotConfigured`)})]})]}),(0,Q.jsxs)(nc,{value:`features`,className:`mt-0 space-y-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 flex items-center gap-2`,children:[(0,Q.jsx)(wt,{className:`h-4 w-4 text-muted-foreground`}),p(`settings:features.flagsHeading`)]}),(0,Q.jsx)($,{label:p(`settings:features.mcpLabel`),hint:p(`settings:features.mcpHint`),value:f.featureMcp,onChange:()=>h(`featureMcp`,!f.featureMcp)}),(0,Q.jsx)($,{label:p(`settings:features.pluginsLabel`),hint:p(`settings:features.pluginsHint`),value:f.featurePlugins,onChange:()=>h(`featurePlugins`,!f.featurePlugins)}),(0,Q.jsx)($,{label:p(`settings:features.memoryLabel`),hint:p(`settings:features.memoryHint`),value:f.featureMemory,onChange:()=>h(`featureMemory`,!f.featureMemory)}),(0,Q.jsx)($,{label:p(`settings:features.skillsLabel`),hint:p(`settings:features.skillsHint`),value:f.featureSkills,onChange:()=>h(`featureSkills`,!f.featureSkills)}),(0,Q.jsx)($,{label:p(`settings:features.modelsRegistryLabel`),hint:p(`settings:features.modelsRegistryHint`),value:f.featureModelsRegistry,onChange:()=>h(`featureModelsRegistry`,!f.featureModelsRegistry)}),(0,Q.jsx)($,{label:p(`settings:features.indexOnStartLabel`),hint:p(`settings:features.indexOnStartHint`),value:f.indexOnStart,onChange:()=>h(`indexOnStart`,!f.indexOnStart)})]}),(0,Q.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Q.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 mt-3 flex items-center gap-2`,children:[(0,Q.jsx)(Tt,{className:`h-4 w-4 text-muted-foreground`}),p(`settings:features.chimeraHeading`)]}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:p(`settings:features.chimeraAutoFixHint`)})]}),(0,Q.jsx)(`div`,{className:`pt-2 border-t`,children:(0,Q.jsx)(gl,{syncPref:h,sessionProvider:r,sessionModel:i})}),(0,Q.jsx)(Dl,{}),(0,Q.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Q.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 mt-3 flex items-center gap-2`,children:[(0,Q.jsx)(We,{className:`h-4 w-4 text-muted-foreground`}),p(`settings:features.contextHeading`)]}),(0,Q.jsx)($,{label:p(`settings:features.autoCompactLabel`),hint:p(`settings:features.autoCompactHint`),value:f.contextAutoCompact,onChange:()=>h(`contextAutoCompact`,!f.contextAutoCompact)}),(0,Q.jsx)(nl,{label:p(`settings:features.compactorStrategyLabel`),hint:p(`settings:features.compactorStrategyHint`),value:f.contextStrategy,options:[{value:`hybrid`,label:p(`settings:features.compactorStrategyHybrid`)},{value:`intelligent`,label:p(`settings:features.compactorStrategyIntelligent`)},{value:`selective`,label:p(`settings:features.compactorStrategySelective`)}],onChange:e=>h(`contextStrategy`,e)}),(0,Q.jsx)(nl,{label:p(`settings:features.contextModeLabel`),hint:p(`settings:features.contextModeHint`),value:f.contextMode,options:[{value:`balanced`,label:p(`settings:features.contextModeBalanced`)},{value:`frugal`,label:p(`settings:features.contextModeFrugal`)},{value:`deep`,label:p(`settings:features.contextModeDeep`)},{value:`archival`,label:p(`settings:features.contextModeArchival`)}],onChange:e=>h(`contextMode`,e)}),(0,Q.jsx)(nl,{label:p(`settings:features.tokenSavingLabel`),hint:p(`settings:features.tokenSavingHint`),value:f.tokenSavingTier,options:[{value:`off`,label:p(`settings:features.tokenSavingOff`)},{value:`minimal`,label:p(`settings:features.tokenSavingMinimal`)},{value:`light`,label:p(`settings:features.tokenSavingLight`)},{value:`medium`,label:p(`settings:features.tokenSavingMedium`)},{value:`aggressive`,label:p(`settings:features.tokenSavingAggressive`)}],onChange:e=>h(`tokenSavingTier`,e)}),(0,Q.jsx)(nl,{label:p(`settings:features.logLevelLabel`),hint:p(`settings:features.logLevelHint`),value:f.logLevel,options:[{value:`debug`,label:p(`settings:features.logLevelDebug`)},{value:`info`,label:p(`settings:features.logLevelInfo`)},{value:`warn`,label:p(`settings:features.logLevelWarn`)},{value:`error`,label:p(`settings:features.logLevelError`)}],onChange:e=>h(`logLevel`,e)}),(0,Q.jsx)(nl,{label:p(`settings:features.auditLevelLabel`),hint:p(`settings:features.auditLevelHint`),value:f.auditLevel,options:[{value:`minimal`,label:p(`settings:features.auditLevelMinimal`)},{value:`standard`,label:p(`settings:features.auditLevelStandard`)},{value:`full`,label:p(`settings:features.auditLevelFull`)}],onChange:e=>h(`auditLevel`,e)})]})]}),(0,Q.jsx)(nc,{value:`tools`,className:`mt-0 space-y-4`,children:(0,Q.jsx)(du,{})}),(0,Q.jsx)(nc,{value:`mcp`,className:`mt-0 space-y-4`,children:f.featureMcp?(0,Q.jsx)(wl,{}):(0,Q.jsxs)(`div`,{className:`text-center py-8 text-muted-foreground`,children:[(0,Q.jsx)(re,{className:`w-10 h-10 mx-auto mb-2 opacity-50`}),(0,Q.jsx)(`p`,{children:p(`settings:mcp.disabled`)}),(0,Q.jsx)(`p`,{className:`text-sm mt-1`,children:p(`settings:mcp.disabledHint`)})]})}),(0,Q.jsx)(nc,{value:`brain`,className:`mt-0 space-y-4`,children:(0,Q.jsx)(pl,{})}),(0,Q.jsx)(nc,{value:`shadow`,className:`mt-0 space-y-4`,children:(0,Q.jsx)(cu,{})})]})]})})})]})}var pu=[{sectionKey:`sectionGlobal`,items:[{keys:[`Ctrl`,`K`],descKey:`dCommandPalette`},{keys:[`?`],descKey:`dShowOverlay`},{keys:[`Ctrl`,`\\`],descKey:`dToggleSidebar`},{keys:[`Ctrl`,`1-8`],descKey:`dOpenPanel`},{keys:[`Ctrl`,`0`],descKey:`dDesignStudio`},{keys:[`Ctrl`,`Shift`,`W`],descKey:`dWorktrees`},{keys:[`Ctrl`,`/`],descKey:`dFocusInput`}]},{sectionKey:`sectionTuiParity`,items:[{keys:[`F1`],descKey:`dSessionPanel`},{keys:[`F2`],descKey:`dFleetOverlay`},{keys:[`F3`],descKey:`dAgentsOverlay`},{keys:[`F4`],descKey:`dWorktreeMonitor`},{keys:[`F5`],descKey:`dPlanPanel`},{keys:[`F6`],descKey:`dTodosPanel`},{keys:[`F7`],descKey:`dQueuePanel`},{keys:[`F8`],descKey:`dProcessMonitor`},{keys:[`F9`],descKey:`dGoalPanel`},{keys:[`F10`],descKey:`dSessionsDashboard`},{keys:[`F11`],descKey:`dOfficeMap`},{keys:[`F12`],descKey:`dDockPicker`}]},{sectionKey:`sectionFleet`,items:[{keys:[`Ctrl`,`Shift`,`M`],descKey:`dOpenFleet`},{keys:[`Ctrl`,`Shift`,`A`],descKey:`dOpenAgents`},{keys:[`↑`,`↓`],descKey:`dNavigateAgents`},{keys:[`Enter`],descKey:`dSelectAgent`},{keys:[`Esc`],descKey:`dCloseOverlay`}]},{sectionKey:`sectionChatInput`,items:[{keys:[`Enter`],descKey:`dSendMessage`},{keys:[`Shift`,`Enter`],descKey:`dNewline`},{keys:[`↑`],descKey:`dRecallPrev`},{keys:[`↓`],descKey:`dRecallNext`},{keys:[`/`],descKey:`dSlashPopup`},{keys:[`Tab`],descKey:`dAutocomplete`},{keys:[`Esc`],descKey:`dDismissPopup`}]},{sectionKey:`sectionChat`,items:[{keys:[`Ctrl`,`F`],descKey:`dSearchChat`},{keys:[`Ctrl`,`L`],descKey:`dClearContext`},{keys:[`Ctrl`,`N`],descKey:`dNewSession`},{keys:[`Ctrl`,`E`],descKey:`dExportMarkdown`},{keys:[`Ctrl`,`M`],descKey:`dModelSwitcher`},{keys:[`Ctrl`,`Shift`,`D`],descKey:`dCompactDensity`},{keys:[`Esc`],descKey:`dAbortRun`}]},{sectionKey:`sectionChatNav`,items:[{keys:[`j`],descKey:`dFocusNext`},{keys:[`k`],descKey:`dFocusPrev`},{keys:[`g`],descKey:`dJumpFirst`},{keys:[`Shift`,`G`],descKey:`dJumpLast`},{keys:[`c`],descKey:`dCopyFocused`},{keys:[`Esc`],descKey:`dClearFocused`}]}];function mu(){let{t:e}=V(),t=U(e=>e.shortcutsOpen),n=U(e=>e.setShortcutsOpen);return(0,Z.useEffect)(()=>{let e=e=>{let t=e.target,r=t?.tagName?.toLowerCase();!(r===`input`||r===`textarea`||t?.isContentEditable)&&e.key===`?`&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&(e.preventDefault(),n(!U.getState().shortcutsOpen))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),(0,Q.jsx)($r,{open:t,onOpenChange:e=>{e||n(!1)},children:(0,Q.jsxs)(Xr,{className:`max-w-2xl gap-0 p-0 overflow-hidden flex flex-col max-h-[80dvh]`,children:[(0,Q.jsx)(`div`,{className:`flex items-center justify-between px-5 py-4 border-b`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Le,{className:`h-4 w-4 text-muted-foreground`}),(0,Q.jsx)(Zr,{className:`text-sm font-semibold`,children:e(`activity:shortcuts.heading`)})]})}),(0,Q.jsx)(Qr,{className:`sr-only`,children:e(`activity:shortcuts.heading`)}),(0,Q.jsx)(`div`,{className:`overflow-y-auto overscroll-contain px-5 py-4 space-y-6`,children:pu.map(t=>(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground mb-2`,children:e(`activity:shortcuts.${t.sectionKey}`)}),(0,Q.jsx)(`div`,{className:`grid grid-cols-1 gap-1.5`,children:t.items.map(t=>(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-sm px-2 py-1.5 rounded hover:bg-muted/40`,children:[(0,Q.jsx)(`span`,{className:`text-foreground/80`,children:e(`activity:shortcuts.${t.descKey}`)}),(0,Q.jsx)(`span`,{className:`flex items-center gap-1 shrink-0`,children:t.keys.map((e,t)=>(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[t>0&&(0,Q.jsx)(`span`,{className:`text-muted-foreground/65 text-xs`,children:`+`}),(0,Q.jsx)(`kbd`,{className:`font-mono text-[10px] border rounded px-1.5 py-0.5 bg-background`,children:e})]},e))})]},t.descKey))})]},t.sectionKey))}),(0,Q.jsxs)(`div`,{className:`border-t px-5 py-3 text-xs text-muted-foreground`,children:[e(`activity:shortcuts.footerPre`),` `,(0,Q.jsx)(`kbd`,{className:`font-mono text-[10px] border rounded px-1 py-0.5 bg-background`,children:`?`}),` `,e(`activity:shortcuts.footerPost`)]})]})})}function hu(e,t){let n=[],r=(e,i)=>{for(let a of e)if(n.push({node:a,depth:i}),a.type===`directory`&&t.has(a.path)){let e=a.children??[];e.length>0?r(e,i+1):n.push({node:a,depth:i+1,emptyPlaceholder:!0})}};return r(e,0),n}function gu(e){let t=[],n=e=>{for(let r of e)r.type===`directory`&&(t.push(r.path),r.children&&n(r.children))};return n(e),t}var _u=(0,Z.memo)(function({node:e,depth:t,emptyPlaceholder:n,expanded:r,isActive:i,isSelected:a,isFocused:o,onToggle:s,onSelect:c,onOpen:l,onContextMenu:u}){let{t:d}=V();if(n)return(0,Q.jsx)(`div`,{className:`text-[10px] text-muted-foreground italic py-0.5`,style:{paddingLeft:`${t*14+4}px`},children:d(`activity:fileExplorer.emptyDir`)});if(e.type===`directory`){let n=r?Ge:Zn,i=e.name===`.git`,a=Ia(e.name,!0);return(0,Q.jsxs)(`button`,{type:`button`,role:`treeitem`,"aria-expanded":r,"aria-level":t+1,tabIndex:-1,onClick:()=>s(e.path),onContextMenu:t=>u(t,e),className:G(`flex items-center gap-1 w-full text-left px-1 py-0.5 text-[11px] rounded`,`hover:bg-muted/60 transition-colors`,o&&`ring-1 ring-inset ring-primary/40 bg-muted/40`),style:{paddingLeft:`${t*14+4}px`},children:[(0,Q.jsx)(Kn,{className:G(`h-3 w-3 shrink-0 text-muted-foreground transition-transform`,r&&`rotate-90`)}),i?(0,Q.jsx)(S,{className:G(`h-3.5 w-3.5 shrink-0`,a)}):(0,Q.jsx)(n,{className:G(`h-3.5 w-3.5 shrink-0`,a)}),(0,Q.jsx)(`span`,{className:`truncate font-medium flex-1 min-w-0`,children:e.name})]})}let f=La(e.name),p=Ia(e.name,!1);return(0,Q.jsxs)(`button`,{type:`button`,role:`treeitem`,"aria-level":t+1,"aria-selected":i||a,tabIndex:-1,onClick:()=>c(e.path),onContextMenu:t=>u(t,e),onDoubleClick:t=>{t.preventDefault(),l(e.path)},className:G(`flex items-center gap-1.5 w-full text-left px-1 py-0.5 text-[11px] rounded`,`hover:bg-muted/60 transition-colors`,i&&`bg-primary/10 text-primary`,a&&!i&&`bg-muted/70 ring-1 ring-inset ring-border`,o&&!i&&!a&&`ring-1 ring-inset ring-primary/40 bg-muted/40`),style:{paddingLeft:`${t*14+4}px`},children:[(0,Q.jsx)(`span`,{className:`w-3 shrink-0`}),` `,(0,Q.jsx)(f,{className:G(`h-3.5 w-3.5 shrink-0`,p)}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.name})]})});function vu(){let{t:e}=V(),t=gr(e=>e.tree),n=gr(e=>e.treeLoading),r=gr(e=>e.error),i=gr(e=>e.openFiles),a=gr(e=>e.activeFilePath),o=K(e=>e.cwd),s=K(e=>e.projectName),c=o?.includes(`\\`)?`\\`:`/`,l=(e,t=8,n=4)=>e.length<=t+n+2?e:`${e.slice(0,t)}…${e.slice(-n)}`,u=(()=>{if(!o||!s)return!0;let e=o.replace(/\\/g,`/`).split(`/`).filter(Boolean);return(e[e.length-1]??``)===s})(),d=(0,Z.useMemo)(()=>{if(!o||!s)return[];let e=o.replace(/\\/g,`/`).split(`/`).filter(Boolean),t=-1;for(let n=e.length-1;n>=0;n--)if(e[n]===s){t=n;break}if(t===-1)return e.map((t,n)=>({label:t,path:`/`+e.slice(0,n+1).join(`/`),isLast:n===e.length-1}));let n=e.slice(t);return n.map((r,i)=>({label:r,path:`/`+e.slice(0,t+i+1).join(`/`),isLast:i===n.length-1}))},[o,s]),f=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{let e=f.current;e&&d.length>1&&(e.scrollLeft=e.scrollWidth)},[d]);let p=(0,Z.useCallback)(e=>{pr().send({type:`working_dir.set`,payload:{path:e}})},[]),[m,h]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(null),y=(0,Z.useCallback)((e,t)=>{e.preventDefault(),e.stopPropagation(),v({x:e.clientX,y:e.clientY,node:t})},[]),b=(0,Z.useCallback)(e=>{e.type===`file`&&(_r.getState().addRef({kind:`file`,path:e.path}),J(`chat`)),v(null)},[]);(0,Z.useEffect)(()=>{if(!m&&!_)return;let e=()=>{h(null),v(null)},t=t=>{t.key===`Escape`&&e()};return window.addEventListener(`click`,e),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`click`,e),window.removeEventListener(`keydown`,t)}},[m,_]);let x=(0,Z.useCallback)((e,t)=>{e.preventDefault(),e.stopPropagation(),h({x:e.clientX,y:e.clientY,crumb:t})},[]),S=(0,Z.useCallback)(t=>{si(t).then(t=>{t?Y.success(e(`common:action.copied`)):Y.error(e(`common:action.copyFailed`))}),h(null)},[e]),C=(0,Z.useCallback)(()=>{if(!a)return;let e=a.replace(/\\/g,`/`).split(`/`).slice(0,-1).join(`/`)||`.`;pr().send({type:`working_dir.set`,payload:{path:e}})},[a]),w=(0,Z.useCallback)((e,t)=>{pr().send({type:`shell.open`,payload:{path:e,target:t}}),h(null)},[]),T=(0,Z.useCallback)(()=>{if(!o)return;let e=o.replace(/\\/g,`/`),t=e.split(`/`).slice(0,-1).join(`/`)||e;pr().send({type:`working_dir.set`,payload:{path:t}})},[o]),[E,D]=(0,Z.useState)(!1),O=(0,Z.useRef)(null);(0,Z.useEffect)(()=>(n?O.current=setTimeout(()=>D(!0),150):(O.current&&clearTimeout(O.current),D(!1)),()=>{O.current&&clearTimeout(O.current)}),[n]);let[k,A]=(0,Z.useState)(null),[j,M]=(0,Z.useState)(new Set),N=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{N.current!==(o??``)&&t.length!==0&&(N.current=o??``,M(new Set(t.filter(e=>e.type===`directory`).map(e=>e.path))))},[o,t]);let P=(0,Z.useCallback)(e=>{M(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),ee=(0,Z.useMemo)(()=>gu(t),[t]),te=ee.length,F=(0,Z.useMemo)(()=>hu(t,j),[t,j]),I=(0,Z.useMemo)(()=>{let e=0,n=0;for(let r of t)r.type===`directory`?n++:e++;return{files:e,dirs:n}},[t]),ne=(0,Z.useCallback)(()=>{M(new Set)},[]),re=(0,Z.useCallback)(()=>{M(new Set(ee))},[ee]),L=(0,Z.useCallback)(e=>{if(i.find(t=>t.path===e)){gr.getState().setActiveFile(e);return}A(t=>t===e?null:e)},[i]),ie=(0,Z.useCallback)(e=>{window.dispatchEvent(new CustomEvent(`wrongstack:open-file`,{detail:{filePath:e}})),A(null)},[]);(0,Z.useEffect)(()=>{a&&A(null)},[a]);let ae=(0,Z.useRef)(null),[R,z]=(0,Z.useState)(-1),oe=R>=0&&R<F.length&&!F[R]?.emptyPlaceholder?F[R]?.node.path??null:null,se=(0,Z.useCallback)(e=>{if(F.length===0)return;let t=(e,t)=>{let n=e+t;for(;n>=0&&n<F.length&&F[n]?.emptyPlaceholder;)n+=t;return n<0||n>=F.length?e:n},n=e=>{z(e),ae.current?.scrollToIndex(e,{align:`nearest`})},r=R,i=r>=0&&r<F.length?F[r]:void 0;switch(e.key){case`ArrowDown`:e.preventDefault(),n(t(r,1));break;case`ArrowUp`:e.preventDefault(),n(t(r===-1?F.length:r,-1));break;case`ArrowRight`:if(!i||i.emptyPlaceholder)break;e.preventDefault(),i.node.type===`directory`&&(j.has(i.node.path)?n(t(r,1)):P(i.node.path));break;case`ArrowLeft`:if(!i||i.emptyPlaceholder)break;if(e.preventDefault(),i.node.type===`directory`&&j.has(i.node.path)){P(i.node.path);break}for(let e=r-1;e>=0;e--){let t=F[e];if(t&&!t.emptyPlaceholder&&t.depth<i.depth){n(e);break}}break;case`Enter`:if(!i||i.emptyPlaceholder)break;e.preventDefault(),i.node.type===`directory`?P(i.node.path):ie(i.node.path);break;case` `:if(!i||i.emptyPlaceholder)break;e.preventDefault(),i.node.type===`directory`?P(i.node.path):L(i.node.path);break;case`Home`:e.preventDefault(),n(t(-1,1));break;case`End`:e.preventDefault(),n(t(F.length,-1));break}},[F,R,j,P,ie,L]),ce=(0,Z.useCallback)(()=>{z(e=>e===-1&&F.length>0?0:e)},[F.length]);return E?(0,Q.jsx)(`div`,{className:`flex items-center justify-center h-full py-8`,children:(0,Q.jsx)(g,{className:`h-5 w-5 animate-spin text-muted-foreground`})}):r?(0,Q.jsx)(`div`,{className:`p-3 text-[11px] text-destructive`,children:e(`activity:fileExplorer.loadFailed`,{error:r})}):(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col overflow-hidden`,children:[t.length>0&&te>0&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-0.5 px-2 py-0.5 border-b shrink-0`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:re,className:G(`flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] transition-colors`,`hover:bg-muted/60 text-muted-foreground hover:text-foreground`),title:e(`activity:fileExplorer.expandAllTitle`),children:[(0,Q.jsx)(Hn,{className:`h-3 w-3`}),(0,Q.jsx)(`span`,{children:e(`activity:fileExplorer.expandAll`)})]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:ne,className:G(`flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] transition-colors`,`hover:bg-muted/60 text-muted-foreground hover:text-foreground`),title:e(`activity:fileExplorer.collapseAllTitle`),children:[(0,Q.jsx)(sn,{className:`h-3 w-3`}),(0,Q.jsx)(`span`,{children:e(`activity:fileExplorer.collapse`)})]}),(0,Q.jsx)(`span`,{className:`ml-auto text-[9px] text-muted-foreground/70 tabular-nums`,children:e(`activity:fileExplorer.folders`,{count:te})})]}),(0,Q.jsxs)(`div`,{className:`min-h-0 min-w-0 flex flex-1 flex-col py-1`,children:[d.length>0&&(0,Q.jsxs)(`div`,{ref:f,className:`relative flex shrink-0 items-center gap-0.5 px-1 pb-1 border-b border-border/30 overflow-x-auto`,children:[(0,Q.jsx)(`span`,{className:`sticky left-0 shrink-0 w-3 h-full bg-gradient-to-r from-background to-transparent pointer-events-none`}),d.map((t,n)=>{let r=t.isLast?t.label:l(t.label),i=t.path.replace(/\//g,c),a=o?o.replace(/\\/g,`/`).split(`/`).filter(Boolean):[],u=(()=>{for(let e=a.length-1;e>=0;e--)if(a[e]===s)return e;return-1})(),d=u>=0?a.slice(0,u+n+1):a.slice(0,n+1),f=c===`\\`?d.join(`\\`):`/`+d.join(`/`),m=(u>=0?a.slice(u+1,u+n+1):[]).join(c)||`.`;return(0,Q.jsxs)(`span`,{className:`flex items-center gap-0.5 shrink-0`,children:[n>0&&(0,Q.jsx)(`span`,{className:`text-[9px] text-muted-foreground/65 select-none`,children:c}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>p(t.path),onContextMenu:e=>x(e,{absPath:f,relPath:m}),className:G(`px-1 py-0.5 rounded text-[11px] transition-colors whitespace-nowrap`,t.isLast?`text-foreground font-medium`:`text-muted-foreground hover:text-foreground hover:bg-muted/60`),title:t.isLast?e(`activity:fileExplorer.currentDirTitle`,{path:i}):e(`activity:fileExplorer.navigateToTitle`,{path:i}),children:r})]},t.path)}),t.length>0&&(0,Q.jsxs)(`span`,{className:`ml-auto shrink-0 text-[9px] text-muted-foreground/70 tabular-nums pl-2`,children:[I.files>0&&e(`activity:fileExplorer.filesSuffix`,{count:I.files}),I.files>0&&I.dirs>0&&`, `,I.dirs>0&&e(`activity:fileExplorer.folders`,{count:I.dirs})]})]}),a&&(0,Q.jsxs)(`button`,{type:`button`,onClick:C,className:`flex shrink-0 items-center gap-1 w-full text-left px-2 py-0.5 border-b border-border/30 text-[10px] text-muted-foreground hover:text-foreground hover:bg-accent/50 transition-colors`,title:e(`activity:fileExplorer.navigateParentTitle`,{path:a.replace(/\//g,c)}),children:[(0,Q.jsx)(B,{className:`h-3 w-3 shrink-0`}),(0,Q.jsx)(`span`,{className:`truncate`,children:(()=>{let e=a.replace(/\\/g,`/`).split(`/`);return e[e.length-1]??a})()}),(0,Q.jsx)(`span`,{className:`ml-auto text-[8px] text-muted-foreground/65 shrink-0`,children:e(`activity:fileExplorer.goToDir`)})]}),d.length===0&&!u&&(0,Q.jsxs)(`button`,{type:`button`,onClick:T,className:G(`flex shrink-0 items-center gap-1.5 w-full text-left px-1 py-0.5 text-[11px] rounded`,`hover:bg-muted/60 transition-colors text-muted-foreground hover:text-foreground`,`font-medium`),children:[(0,Q.jsx)(Re,{className:`h-3.5 w-3.5 shrink-0`}),(0,Q.jsx)(`span`,{children:`..`}),(0,Q.jsx)(`span`,{className:`text-[9px] text-muted-foreground/70 ml-auto`,children:e(`activity:fileExplorer.parentDirectory`)})]}),t.length>0?(0,Q.jsx)(`div`,{role:`tree`,"aria-label":e(`activity:fileExplorer.folders`,{count:te}),tabIndex:0,onKeyDown:se,onFocus:ce,className:`min-h-0 min-w-0 flex-1 outline-none`,children:(0,Q.jsx)(Te,{ref:ae,className:`h-full`,children:F.map(e=>(0,Q.jsx)(_u,{node:e.node,depth:e.depth,emptyPlaceholder:e.emptyPlaceholder,expanded:e.node.type===`directory`&&j.has(e.node.path),isActive:e.node.type===`file`&&e.node.path===a,isSelected:!e.emptyPlaceholder&&e.node.path===k,isFocused:!e.emptyPlaceholder&&e.node.path===oe,onToggle:P,onSelect:L,onOpen:ie,onContextMenu:y},e.emptyPlaceholder?`${e.node.path}#empty`:e.node.path))})}):(0,Q.jsx)(`p`,{className:`text-[11px] text-muted-foreground italic p-2`,children:e(`activity:fileExplorer.noFiles`)})]}),m&&(0,Q.jsxs)(`div`,{className:`fixed z-50 min-w-[140px] bg-popover border rounded-md shadow-md py-1 text-[11px]`,style:{left:m.x,top:m.y},children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>S(m.crumb.absPath),className:`flex items-center gap-2 w-full text-left px-3 py-1.5 hover:bg-accent transition-colors`,children:e(`activity:fileExplorer.copyAbsPath`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>S(m.crumb.relPath),className:`flex items-center gap-2 w-full text-left px-3 py-1.5 hover:bg-accent transition-colors`,children:e(`activity:fileExplorer.copyRelPath`)}),(0,Q.jsx)(`div`,{className:`border-t border-border/50 my-0.5`}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>w(m.crumb.absPath,`terminal`),className:`flex items-center gap-2 w-full text-left px-3 py-1.5 hover:bg-accent transition-colors`,children:e(`activity:fileExplorer.openInTerminal`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>w(m.crumb.absPath,`file-manager`),className:`flex items-center gap-2 w-full text-left px-3 py-1.5 hover:bg-accent transition-colors`,children:e(`activity:fileExplorer.openInFileManager`)}),(0,Q.jsx)(`div`,{className:`border-t border-border/50 mt-0.5 pt-0.5`,children:(0,Q.jsx)(`div`,{className:`px-3 py-1 text-[9px] text-muted-foreground/70 truncate max-w-[200px]`,children:m.crumb.absPath})})]}),_&&(0,Q.jsxs)(`div`,{className:`fixed z-50 min-w-[160px] bg-popover border rounded-md shadow-md py-1 text-[11px]`,style:{left:_.x,top:_.y},children:[_.node.type===`file`&&(0,Q.jsx)(`button`,{type:`button`,onClick:()=>b(_.node),className:`flex items-center gap-2 w-full text-left px-3 py-1.5 hover:bg-accent transition-colors`,children:e(`activity:fileExplorer.mentionInChat`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{si(_.node.path).then(t=>{t?Y.success(e(`common:action.copied`)):Y.error(e(`common:action.copyFailed`))}),v(null)},className:`flex items-center gap-2 w-full text-left px-3 py-1.5 hover:bg-accent transition-colors`,children:e(`activity:fileExplorer.copyPath`)}),(0,Q.jsx)(`div`,{className:`border-t border-border/50 mt-0.5 pt-0.5`,children:(0,Q.jsx)(`div`,{className:`px-3 py-1 text-[9px] text-muted-foreground/70 truncate max-w-[200px]`,children:_.node.path})})]})]})}var yu={note:je,ask:Vt,assign:_e,steer:ze,btw:se,broadcast:_e,status:At,result:Gt};function bu(e){let t=new Date(e),n=Date.now()-t.getTime();return n<6e4?H.t(`activity:mailbox.timeNow`):n<36e5?`${Math.round(n/6e4)}m`:n<864e5?`${Math.round(n/36e5)}h`:t.toLocaleDateString()}function xu({className:e}){let t=zr(e=>e.messages),n=zr(e=>e.agents),r=zr(e=>e.lastCompaction),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1),[u,f]=(0,Z.useState)(!1),{client:p}=dr(),{t:m}=V(),[h,g]=(0,Z.useState)(p.status.state===`open`);(0,Z.useEffect)(()=>{let e=p.onStatus(e=>g(e.state===`open`));return()=>e()},[p]),(0,Z.useEffect)(()=>{h&&(p.send({type:`mailbox.messages`,payload:{limit:30}}),p.send({type:`mailbox.agents`,payload:{}}))},[h,p]);let _=U(e=>e.selectedMailMessage),v=U(e=>e.setSelectedMailMessage);function y(e){if(_?.id===e.id){v(null),J(`chat`);return}v(e),J(`mailbox`)}let b=t.filter(e=>!e.completed).length,x=n.filter(e=>e.online).length,S=ho(t,8),w=ho(n.filter(e=>e.online),5);async function T(){t.length!==0&&await mi({title:m(`activity:mailbox.deleteAllConfirmTitle`,{count:t.length}),message:m(`activity:mailbox.deleteAllConfirmBody`),confirmLabel:m(`activity:mailbox.deleteAll`),danger:!0})&&(s(!0),p.send({type:`mailbox.clear`}))}(0,Z.useEffect)(()=>{o&&t.length===0&&s(!1)},[o,t.length]);async function E(){await mi({title:m(`activity:mailbox.purgeConfirmTitle`),message:m(`activity:mailbox.purgeConfirmBody`),confirmLabel:m(`activity:mailbox.purge`),danger:!1})&&(l(!0),p.send({type:`mailbox.purge`}))}(0,Z.useEffect)(()=>{if(c){let e=setTimeout(()=>l(!1),3e3);return()=>clearTimeout(e)}},[c]);async function D(){f(!0),p.send({type:`mailbox.compact`})}return(0,Z.useEffect)(()=>{if(u){let e=setTimeout(()=>f(!1),3e3);return()=>clearTimeout(e)}},[u]),(0,Q.jsxs)(`div`,{className:G(`rounded-lg border border-border bg-card/60 backdrop-blur-sm`,e),children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`flex w-full items-center gap-2 px-3 py-2.5 text-left hover:bg-accent/40 rounded-t-lg transition-colors`,children:[(0,Q.jsx)(P,{className:`h-4 w-4 text-primary`}),(0,Q.jsx)(`span`,{className:`text-xs font-semibold text-foreground flex-1 min-w-0 truncate`,children:m(`activity:nav.mailbox`)}),b>0&&(0,Q.jsx)(`span`,{className:`inline-flex items-center px-1.5 py-0.5 rounded-full text-[10px] font-bold bg-warning/10 text-warning`,children:b}),(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:m(`activity:mailbox.onlineCount`,{count:x})})]}),!i&&(0,Q.jsxs)(`div`,{className:`px-3 pb-3 space-y-2`,children:[t.length>0?(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wide`,children:m(`activity:mailbox.messages`)}),(0,Q.jsxs)(`button`,{type:`button`,onClick:T,disabled:o,className:`flex items-center gap-1 text-[10px] text-muted-foreground hover:text-destructive disabled:opacity-40 transition-colors`,title:m(`activity:mailbox.deleteAllTitle`),children:[(0,Q.jsx)(C,{className:`h-3 w-3`}),m(o?`activity:mailbox.deleting`:`activity:mailbox.deleteAll`)]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:E,disabled:c,className:`flex items-center gap-1 text-[10px] text-muted-foreground hover:text-primary disabled:opacity-40 transition-colors`,title:m(`activity:mailbox.purgeTitle`),children:[(0,Q.jsx)(ee,{className:`h-3 w-3`}),m(c?`activity:mailbox.purging`:`activity:mailbox.purge`)]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:D,disabled:u,className:`flex items-center gap-1 text-[10px] text-muted-foreground hover:text-primary disabled:opacity-40 transition-colors`,title:m(`activity:mailbox.compactTitle`),children:[(0,Q.jsx)(Tt,{className:`h-3 w-3`}),m(u?`activity:mailbox.compacting`:`activity:mailbox.compact`)]})]}),r&&r.totalRemoved>0&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 py-1 rounded text-[10px] bg-primary/5 text-primary/70 border border-primary/10`,children:[(0,Q.jsx)(Tt,{className:`h-3 w-3 shrink-0`}),(0,Q.jsxs)(`span`,{children:[m(`activity:mailbox.compactRemoved`,{count:r.totalRemoved}),r.expiredRemoved>0&&` (${m(`activity:mailbox.compactExpired`,{count:r.expiredRemoved})})`,r.readByAllRemoved>0&&` (${m(`activity:mailbox.compactReadByAll`,{count:r.readByAllRemoved})})`,r.stalePurged>0&&` (${m(`activity:mailbox.compactStale`,{count:r.stalePurged})})`,` — `,m(`activity:mailbox.compactRemaining`,{count:r.remaining})]})]}),S.pageItems.map(e=>{let t=yu[e.type]??d,n=e.readByCount>0,r=_?.id===e.id,i=e.scope?{scope:e.scope,recipientSessionId:e.recipientSessionId}:Br(e.to);return(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>y(e),className:G(`flex items-start gap-2 px-2 py-1.5 rounded text-xs w-full text-left cursor-pointer transition-colors hover:bg-accent/60`,!n&&`bg-warning/8`,r&&`ring-1 ring-primary bg-primary/5`),children:[(0,Q.jsx)(t,{className:G(`h-3.5 w-3.5 mt-0.5 shrink-0`,n?`text-muted-foreground`:`text-warning`)}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(`span`,{className:G(`font-medium truncate`,!n&&`text-warning`),children:e.from}),e.completed&&(0,Q.jsx)(Gt,{className:`h-3 w-3 text-success shrink-0`}),!n&&(0,Q.jsx)(`span`,{className:`text-[9px] text-warning font-bold`,children:m(`activity:mailbox.newLabel`)}),i.scope===`session`&&(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 px-1 py-0 rounded text-[9px] font-semibold bg-warning/12 text-warning`,title:m(`activity:mailbox.sessionScopeTitle`,{sid:i.recipientSessionId??``}),children:[(0,Q.jsx)($n,{className:`h-2.5 w-2.5`}),m(`activity:mailbox.sessionLabel`)]}),i.scope===`project`&&(0,Q.jsx)(`span`,{className:`inline-flex items-center px-1 py-0 rounded text-[9px] font-semibold bg-primary/12 text-primary`,children:m(`activity:mailbox.projectLabel`)})]}),(0,Q.jsx)(`div`,{className:`text-muted-foreground truncate`,children:e.subject}),(0,Q.jsxs)(`div`,{className:`text-[10px] text-muted-foreground/70 truncate`,children:[e.body.slice(0,60),e.body.length>60?`…`:``]})]}),(0,Q.jsxs)(`div`,{className:`shrink-0 text-[10px] text-muted-foreground flex flex-col items-end gap-0.5`,children:[(0,Q.jsx)(`span`,{children:bu(e.timestamp)}),n&&(0,Q.jsxs)(`span`,{className:`flex items-center gap-0.5`,children:[(0,Q.jsx)(xt,{className:`h-3 w-3`}),e.readByCount]})]})]},e.id)}),(0,Q.jsx)(ni,{page:S.page,pageSize:S.pageSize,totalItems:S.totalItems,onPageChange:S.setPage,compact:!0,itemLabel:`messages`})]}):(0,Q.jsxs)(`div`,{className:`text-xs text-muted-foreground py-2 text-center`,children:[(0,Q.jsx)(ce,{className:`h-4 w-4 mx-auto mb-1 opacity-40`}),m(`activity:mailbox.empty`)]}),n.length>0&&(0,Q.jsxs)(`div`,{className:`border-t border-border pt-2`,children:[(0,Q.jsxs)(`div`,{className:`text-[10px] font-semibold text-muted-foreground mb-1 flex items-center gap-1`,children:[(0,Q.jsx)(xn,{className:`h-3 w-3`}),` `,m(`activity:nav.agents`)]}),w.pageItems.map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] text-muted-foreground py-0.5`,children:[(0,Q.jsx)(`span`,{className:G(`h-1.5 w-1.5 rounded-full`,e.online?`bg-success`:`bg-muted-foreground/30`)}),(0,Q.jsx)(`span`,{className:`font-medium text-foreground/80`,children:e.name}),e.role&&(0,Q.jsxs)(`span`,{className:`opacity-60`,children:[`(`,e.role,`)`]}),(0,Q.jsx)(`span`,{className:`opacity-50`,children:e.status}),e.currentTool&&(0,Q.jsx)(`span`,{className:`text-primary`,children:e.currentTool}),(0,Q.jsx)(`span`,{className:`ml-auto opacity-50`,children:bu(e.lastSeenAt)})]},e.agentId)),(0,Q.jsx)(ni,{page:w.page,pageSize:w.pageSize,totalItems:w.totalItems,onPageChange:w.setPage,compact:!0,itemLabel:`online agents`}),n.filter(e=>!e.online).length>0&&(0,Q.jsx)(`div`,{className:`text-[10px] text-muted-foreground/70 mt-0.5`,children:m(`activity:mailbox.offlineCount`,{count:n.filter(e=>!e.online).length})})]})]})]})}var Su={M:{label:`M`,cls:`text-warning`},A:{label:`A`,cls:`text-success`},D:{label:`D`,cls:`text-destructive`},R:{label:`R`,cls:`text-info`},C:{label:`C`,cls:`text-info`},U:{label:`U`,cls:`text-warning`},"?":{label:`U`,cls:`text-muted-foreground`}};function Cu(e){let t=e.lastIndexOf(`/`);return t<0?{name:e,dir:``}:{name:e.slice(t+1),dir:e.slice(0,t+1)}}function wu({file:e,active:t,onSelect:n}){let r=Su[e.status]??Su.M,{name:i,dir:a}=Cu(e.path);return(0,Q.jsxs)(`button`,{type:`button`,onClick:n,title:e.path,className:G(`group flex items-center gap-2 w-full px-2 py-1 text-left text-xs rounded hover:bg-accent/60`,t&&`bg-accent`),children:[(0,Q.jsx)(`span`,{className:G(`w-3 shrink-0 text-center font-mono font-bold`,r?.cls),children:r?.label}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-baseline gap-1 overflow-hidden`,children:[(0,Q.jsx)(`span`,{className:G(`min-w-0 truncate`,e.status===`D`&&`line-through opacity-70`),children:i}),a&&(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-muted-foreground/75`,children:a})]}),(0,Q.jsxs)(`span`,{className:`shrink-0 font-mono text-[10px] tabular-nums`,children:[e.added>0&&(0,Q.jsxs)(`span`,{className:`text-success`,children:[`+`,e.added]}),e.deleted>0&&(0,Q.jsxs)(`span`,{className:`text-destructive ml-1`,children:[`-`,e.deleted]})]})]})}function Tu(){let{client:e}=dr(),{t}=V(),n=q(e=>e.wsConnected),r=Er(e=>e.files),i=Er(e=>e.error),a=Er(e=>e.loadingList),o=Er(e=>e.selectedPath),s=(0,Z.useCallback)(()=>{n&&(Er.getState().setListLoading(!0),e?.getGitChanges?.())},[e,n]);(0,Z.useEffect)(()=>{s()},[s]);let c=t=>{Er.getState().select(t),e?.getGitDiff?.(t),J(`changes`)},l=r.reduce((e,t)=>e+t.added,0),u=r.reduce((e,t)=>e+t.deleted,0);return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col overflow-hidden`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b shrink-0`,children:[(0,Q.jsxs)(`span`,{className:`text-[11px] text-muted-foreground font-mono`,children:[t(`activity:changes.fileCount`,{count:r.length}),r.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[` · `,(0,Q.jsxs)(`span`,{className:`text-success`,children:[`+`,l]}),` `,(0,Q.jsxs)(`span`,{className:`text-destructive`,children:[`-`,u]})]})]}),(0,Q.jsx)(`button`,{type:`button`,onClick:s,title:t(`activity:changes.refreshTitle`),className:`h-6 w-6 inline-flex items-center justify-center rounded hover:bg-accent text-muted-foreground`,children:a?(0,Q.jsx)(g,{className:`h-3.5 w-3.5 animate-spin`}):(0,Q.jsx)(Dn,{className:`h-3.5 w-3.5`})})]}),(0,Q.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain p-1.5`,children:i?(0,Q.jsx)(`div`,{className:`px-2 py-6 text-center text-xs text-muted-foreground`,children:i}):r.length===0?(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-2 py-10 text-center text-xs text-muted-foreground`,children:[(0,Q.jsx)(Ut,{className:`h-6 w-6 opacity-40`}),t(a?`activity:changes.loading`:`activity:changes.clean`)]}):(0,Q.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:r.map(e=>(0,Q.jsx)(wu,{file:e,active:e.path===o,onSelect:()=>c(e.path)},e.path))})})]})}var Eu=10,Du=20,Ou=e=>{if(!e)return 0;let t=Date.parse(e);return Number.isNaN(t)?0:t},ku=e=>(e.iterationCount??0)+(e.toolCallCount??0)+(e.fileChangeCount??0),Au=e=>{let t=Date.parse(e);if(Number.isNaN(t))return``;let n=Math.max(0,Date.now()-t);if(n<6e4)return H.t(`common:time.justNow`);if(n<36e5)return H.t(`common:time.minutesAgo`,{count:Math.floor(n/6e4)});if(n<864e5)return H.t(`common:time.hoursAgo`,{count:Math.floor(n/36e5)});let r=Math.floor(n/864e5);return r<7?H.t(`common:time.daysAgo`,{count:r}):new Date(t).toLocaleDateString()};function ju(e){let t=Ou(e.startedAt);if(!t)return``;let n=e.isCurrent?Date.now():Ou(e.endedAt)||t,r=Math.max(0,Math.floor((n-t)/6e4));if(r<1)return`<1m`;if(r<60)return`${r}m`;let i=Math.floor(r/60);return i<24?`${i}h ${r%60}m`:`${Math.floor(i/24)}d ${i%24}h`}function Mu(e){return new Intl.NumberFormat(void 0,{notation:e>=1e3?`compact`:`standard`,maximumFractionDigits:1}).format(e)}function Nu(e){return e.filter(e=>e.tokenTotal===0&&!e.isCurrent).map(e=>e.id)}function Pu(e,t){let n=t.query.trim().toLocaleLowerCase(),r=new Set(t.favoriteIds);return[...e.filter(e=>{if(!(!n||[e.name,e.title,e.model,e.provider,e.id,...Object.keys(e.toolBreakdown??{})].some(e=>e?.toLocaleLowerCase().includes(n))))return!1;switch(t.filter){case`favorites`:return r.has(e.id);case`active`:return e.isCurrent;case`completed`:return!e.isCurrent&&(e.outcome===`completed`||e.outcome===void 0&&!!e.endedAt);case`issues`:return e.outcome===`error`||e.outcome===`timeout`||e.outcome===`aborted`||(e.toolErrorCount??0)>0;default:return!0}})].sort((e,n)=>{if(t.sort===`tokens`&&n.tokenTotal!==e.tokenTotal)return n.tokenTotal-e.tokenTotal;if(t.sort===`activity`){let t=ku(n)-ku(e);if(t!==0)return t}return Ou(n.startedAt)-Ou(e.startedAt)})}function Fu(e,t,n=Date.now()){let r=new Date(n);r.setHours(0,0,0,0);let i=r.getTime(),a=i-864e5,o=i-6*864e5,s=new Set(t),c=e.filter(e=>s.has(e.id)),l={today:[],yesterday:[],thisWeek:[],earlier:[]};for(let t of e){if(s.has(t.id))continue;let e=Ou(t.startedAt);e>=i?l.today.push(t):e>=a?l.yesterday.push(t):e>=o?l.thisWeek.push(t):l.earlier.push(t)}let u=[];c.length>0&&u.push({label:`favorites`,rows:c,favorite:!0});for(let e of[`today`,`yesterday`,`thisWeek`,`earlier`])l[e].length>0&&u.push({label:e,rows:l[e]});return u}function Iu(e){return e.reduce((e,t)=>({sessions:e.sessions+1,active:e.active+ +!!t.isCurrent,tokens:e.tokens+t.tokenTotal,tools:e.tools+(t.toolCallCount??0),files:e.files+(t.fileChangeCount??0),errors:e.errors+(t.toolErrorCount??0)+ +(t.outcome===`error`)}),{sessions:0,active:0,tokens:0,tools:0,files:0,errors:0})}function Lu(e){if(e.isCurrent)return{icon:_t,label:`active`,defaultLabel:`Active`,className:`text-primary`};switch(e.outcome){case`completed`:return{icon:Gt,label:`completed`,defaultLabel:`Completed`,className:`text-success`};case`error`:return{icon:kt,label:`error`,defaultLabel:`Error`,className:`text-destructive`};case`timeout`:return{icon:Ct,label:`timeout`,defaultLabel:`Timed out`,className:`text-warning`};case`aborted`:return{icon:Pt,label:`aborted`,defaultLabel:`Aborted`,className:`text-muted-foreground`};default:return e.endedAt?{icon:Gt,label:`completed`,defaultLabel:`Completed`,className:`text-success`}:{icon:_n,label:`saved`,defaultLabel:`Saved session`,className:`text-muted-foreground`}}}function Ru({stats:e}){let{t}=V();return(0,Q.jsx)(`div`,{className:`grid grid-cols-2 border-b border-border/75 bg-card md:grid-cols-5`,children:[{label:t(`activity:sessions.stats.sessions`,{defaultValue:`Sessions`}),value:e.sessions,icon:_n},{label:t(`activity:sessions.stats.tokens`,{defaultValue:`Tokens`}),value:e.tokens,icon:_t},{label:t(`activity:sessions.stats.tools`,{defaultValue:`Tool calls`}),value:e.tools,icon:Mn},{label:t(`activity:sessions.stats.files`,{defaultValue:`Files changed`}),value:e.files,icon:Ue},{label:t(`activity:sessions.stats.errors`,{defaultValue:`Errors`}),value:e.errors,icon:kt}].map(e=>{let t=e.icon;return(0,Q.jsxs)(`div`,{className:`border-b border-r border-border/75 px-4 py-3 md:border-b-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-[0.12em] text-muted-foreground`,children:[(0,Q.jsx)(t,{className:`h-3 w-3`}),e.label]}),(0,Q.jsx)(`div`,{className:`mt-1 font-mono text-xl font-semibold tabular-nums`,children:Mu(e.value)})]},e.label)})})}function zu({historyQuery:e,setHistoryQuery:t,historyEntries:n,historyLoading:r,historyError:i,wsConnected:a,listSessions:o,resumeSession:s,deleteSession:c,renameSession:l,variant:u=`sidebar`}){let{t:d}=V(),f=U(e=>e.favoriteSessionIds),p=U(e=>e.toggleFavoriteSession),m=U(e=>e.sessionNicknames),h=U(e=>e.setSessionNickname),[_,v]=(0,Z.useState)(`all`),[y,b]=(0,Z.useState)(`recent`),[x,S]=(0,Z.useState)(null),[w,T]=(0,Z.useState)(``),[E,D]=(0,Z.useState)(null),[O,k]=(0,Z.useState)(1),A=(0,Z.useRef)(null),j=(0,Z.useRef)(null),M=u===`workspace`,N=(0,Z.useCallback)(e=>e.name||m[e.id]||e.title||d(`activity:sessions.empty`),[m,d]),P=(0,Z.useCallback)(e=>{S(e.id),T(e.name??m[e.id]??e.title??``)},[m]),ee=(0,Z.useCallback)(e=>{S(null),h(e,w),l(e,w)},[w,l,h]);(0,Z.useEffect)(()=>{E&&n.some(e=>e.id===E&&e.isCurrent)&&(D(null),A.current&&clearTimeout(A.current))},[n,E]),(0,Z.useEffect)(()=>{x&&(j.current?.focus(),j.current?.select())},[x]),(0,Z.useEffect)(()=>()=>{A.current&&clearTimeout(A.current)},[]);let te=(0,Z.useCallback)(e=>{D(e),s(e),A.current&&clearTimeout(A.current),A.current=setTimeout(()=>D(null),1e4)},[s]),F=(0,Z.useMemo)(()=>Nu(n),[n]),I=(0,Z.useMemo)(()=>Pu(n,{query:e,filter:_,sort:y,favoriteIds:f}),[f,_,n,e,y]),ne=M?Du:Eu,re=(0,Z.useMemo)(()=>I.slice((O-1)*ne,O*ne),[O,ne,I]),L=(0,Z.useMemo)(()=>Fu(re,f),[f,re]),ie=(0,Z.useMemo)(()=>Iu(n),[n]);(0,Z.useEffect)(()=>{k(1)},[_,e,y]),(0,Z.useEffect)(()=>{let e=Math.max(1,Math.ceil(I.length/ne));O>e&&k(e)},[O,ne,I.length]);let ae=(0,Z.useCallback)(async()=>{if(F.length!==0&&await mi({title:d(`activity:sessions.deleteEmptyTitle`,{count:F.length}),message:d(`activity:sessions.deleteEmptyConfirmBody`),confirmLabel:d(`common:action.delete`),danger:!0}))for(let e of F)c(e)},[c,F,d]),R=[{id:`all`,label:d(`activity:sessions.filters.all`,{defaultValue:`All`})},{id:`favorites`,label:d(`activity:sessions.filters.favorites`,{defaultValue:`Pinned`})},{id:`active`,label:d(`activity:sessions.filters.active`,{defaultValue:`Active`})},{id:`completed`,label:d(`activity:sessions.filters.completed`,{defaultValue:`Completed`})},{id:`issues`,label:d(`activity:sessions.filters.issues`,{defaultValue:`Issues`})}];return(0,Q.jsxs)(`div`,{className:G(`flex min-h-0 min-w-0 flex-1 flex-col bg-background`,M&&`h-full`),"data-history-variant":u,children:[M?(0,Q.jsx)(Ru,{stats:ie}):null,(0,Q.jsxs)(`div`,{className:G(`border-b border-border/75 bg-card`,M?`px-4 py-3`:`px-3 py-2`),children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:d(`activity:sessions.recentSessions`)}),M?(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:d(`activity:sessions.workspaceHint`,{defaultValue:`Search, inspect, pin and resume every project conversation.`})}):null]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center border border-border/75`,children:[F.length>0?(0,Q.jsxs)(`button`,{type:`button`,className:`inline-flex h-8 items-center justify-center gap-1 border-r border-border/75 px-2 text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive disabled:opacity-40`,onClick:ae,disabled:!a,title:d(`activity:sessions.deleteEmptyTitle`,{count:F.length}),children:[(0,Q.jsx)(C,{className:`h-3.5 w-3.5`}),M?(0,Q.jsx)(`span`,{className:`text-[10px]`,children:F.length}):null]}):null,(0,Q.jsx)(`button`,{type:`button`,className:`inline-flex h-8 w-8 items-center justify-center text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-40`,onClick:()=>o(200),disabled:!a,title:d(`common:action.refresh`),children:r?(0,Q.jsx)(g,{className:`h-3.5 w-3.5 animate-spin`}):(0,Q.jsx)(Dn,{className:`h-3.5 w-3.5`})})]})]}),(0,Q.jsxs)(`div`,{className:G(`grid gap-2`,M?`mt-3 lg:grid-cols-[minmax(18rem,1fr)_auto_auto]`:`mt-2`),children:[(0,Q.jsxs)(`div`,{className:`relative min-w-0`,children:[(0,Q.jsx)(Tn,{className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,Q.jsx)(`input`,{type:`search`,value:e,onChange:e=>t(e.target.value),placeholder:d(`activity:sessions.filterPlaceholder`),"aria-label":d(`activity:sessions.filterPlaceholder`),className:`h-9 w-full border border-border/75 bg-background pl-8 pr-8 text-xs outline-none transition-colors placeholder:text-muted-foreground/70 focus:border-primary focus:ring-1 focus:ring-primary`}),e?(0,Q.jsx)(`button`,{type:`button`,onClick:()=>t(``),className:`absolute right-0 top-0 inline-flex h-9 w-8 items-center justify-center text-muted-foreground hover:text-foreground`,title:d(`activity:sessions.clearFilter`),children:(0,Q.jsx)(vn,{className:`h-3.5 w-3.5`})}):null]}),(0,Q.jsxs)(`fieldset`,{className:`flex min-w-0 overflow-x-auto border border-border/75`,children:[(0,Q.jsx)(`legend`,{className:`sr-only`,children:`History filters`}),R.map(e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>v(e.id),"aria-pressed":_===e.id,className:G(`h-9 shrink-0 border-r border-border/75 px-2.5 text-[10px] font-semibold uppercase tracking-[0.08em] transition-colors last:border-r-0`,_===e.id?`bg-foreground text-background`:`bg-background text-muted-foreground hover:bg-muted hover:text-foreground`),children:e.label},e.id))]}),(0,Q.jsxs)(`select`,{value:y,onChange:e=>b(e.target.value),"aria-label":d(`activity:sessions.sort.label`,{defaultValue:`Sort sessions`}),className:`h-9 border border-border/75 bg-background px-2 text-[10px] font-semibold uppercase tracking-[0.08em] text-muted-foreground outline-none focus:border-primary`,children:[(0,Q.jsx)(`option`,{value:`recent`,children:d(`activity:sessions.sort.recent`,{defaultValue:`Recent`})}),(0,Q.jsx)(`option`,{value:`tokens`,children:d(`activity:sessions.sort.tokens`,{defaultValue:`Most tokens`})}),(0,Q.jsx)(`option`,{value:`activity`,children:d(`activity:sessions.sort.activity`,{defaultValue:`Most activity`})})]})]})]}),i?(0,Q.jsx)(`div`,{className:`border-b border-destructive/30 bg-destructive/5 px-4 py-2 text-xs text-destructive`,children:i}):null,(0,Q.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain overflow-x-hidden [scrollbar-gutter:stable]`,children:n.length===0&&!r?(0,Q.jsxs)(`div`,{className:`flex min-h-56 flex-col items-center justify-center px-4 py-10 text-center text-muted-foreground`,children:[(0,Q.jsx)(_n,{className:`h-9 w-9 opacity-25`}),(0,Q.jsx)(`p`,{className:`mt-3 text-sm font-medium text-foreground`,children:d(`activity:sessions.noHistory`)}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs`,children:d(`activity:sessions.noHistoryHint`)})]}):L.length===0?(0,Q.jsxs)(`div`,{className:`flex min-h-56 flex-col items-center justify-center px-4 py-10 text-center text-muted-foreground`,children:[(0,Q.jsx)(Tn,{className:`h-9 w-9 opacity-25`}),(0,Q.jsx)(`p`,{className:`mt-3 text-sm font-medium text-foreground`,children:d(`activity:sessions.noMatches`)}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs`,children:d(`activity:sessions.noMatchesHint`)})]}):(0,Q.jsxs)(`div`,{className:G(M?`mx-auto w-full max-w-7xl p-4 lg:p-6`:`p-2`),children:[(0,Q.jsx)(`div`,{className:G(`space-y-5`,M&&`grid gap-x-5 space-y-0 xl:grid-cols-2`),children:L.map(e=>(0,Q.jsxs)(`section`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:G(`sticky top-0 z-[1] flex items-center gap-1 border-b border-border/75 bg-background/95 px-1 py-2 text-[10px] font-semibold uppercase tracking-[0.14em] backdrop-blur-sm`,e.favorite?`text-warning`:`text-muted-foreground`),children:[e.favorite?(0,Q.jsx)(rn,{className:`h-3 w-3 fill-current`}):null,d(`activity:sessions.group.${e.label}`),(0,Q.jsx)(`span`,{className:`ml-1 font-mono font-normal text-muted-foreground`,children:e.rows.length})]}),(0,Q.jsx)(`div`,{className:`divide-y divide-border/75 border-x border-b border-border/75`,children:e.rows.map(e=>{let t=f.includes(e.id),n=Lu(e),r=n.icon,i=x===e.id,a=E===e.id;return(0,Q.jsxs)(`article`,{className:G(`group grid min-w-0 grid-cols-[minmax(0,1fr)_auto] bg-card transition-colors`,e.isCurrent?`border-l-2 border-l-primary bg-primary/5`:`border-l-2 border-l-transparent hover:bg-muted/45`),"data-session-id":e.id,children:[i?(0,Q.jsxs)(`div`,{className:`min-w-0 px-3 py-3`,children:[(0,Q.jsx)(`label`,{className:`block text-[10px] font-semibold uppercase tracking-[0.1em] text-muted-foreground`,htmlFor:`session-name-${e.id}`,children:d(`activity:sessions.rename`,{defaultValue:`Session name`})}),(0,Q.jsx)(`input`,{ref:j,id:`session-name-${e.id}`,value:w,onChange:e=>T(e.target.value),onBlur:()=>ee(e.id),onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),ee(e.id)):t.key===`Escape`&&(t.preventDefault(),S(null))},placeholder:e.title||d(`activity:sessions.nicknamePlaceholder`),className:`mt-1 h-8 w-full border border-primary bg-background px-2 text-sm outline-none ring-1 ring-primary`})]}):(0,Q.jsx)(`button`,{type:`button`,disabled:e.isCurrent||E!==null,onClick:()=>te(e.id),onDoubleClick:()=>P(e),"aria-current":e.isCurrent?`page`:void 0,className:`min-w-0 px-3 py-3 text-left outline-none focus-visible:bg-muted focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary disabled:cursor-default`,children:(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,Q.jsx)(`span`,{className:G(`mt-0.5 shrink-0`,n.className),title:d(`activity:sessions.status.${n.label}`,{defaultValue:n.defaultLabel}),children:(0,Q.jsx)(r,{className:G(`h-3.5 w-3.5`,e.isCurrent&&`animate-pulse`)})}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`truncate text-sm font-semibold text-foreground`,title:N(e),children:N(e)}),(0,Q.jsxs)(`div`,{className:`mt-0.5 truncate font-mono text-[10px] text-muted-foreground`,children:[e.provider,`/`,e.model]}),(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-2 gap-y-1 font-mono text-[10px] text-muted-foreground`,children:[a?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-sans font-semibold text-primary`,children:[(0,Q.jsx)(g,{className:`h-3 w-3 animate-spin`}),d(`activity:sessions.resuming`)]}):(0,Q.jsx)(`span`,{title:new Date(e.startedAt).toLocaleString(),children:Au(e.startedAt)}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,Q.jsx)(`span`,{children:ju(e)}),e.tokenTotal>0?(0,Q.jsxs)(`span`,{children:[Mu(e.tokenTotal),` tok`]}):null,(e.toolCallCount??0)>0?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Q.jsx)(Mn,{className:`h-3 w-3`}),e.toolCallCount]}):null,(e.fileChangeCount??0)>0?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Q.jsx)(Ue,{className:`h-3 w-3`}),e.fileChangeCount]}):null,(e.toolErrorCount??0)>0?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-destructive`,children:[(0,Q.jsx)(kt,{className:`h-3 w-3`}),e.toolErrorCount]}):null]})]})]})}),(0,Q.jsxs)(`div`,{className:`flex items-start gap-0.5 p-2`,children:[!e.isCurrent&&M&&!i?(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>te(e.id),disabled:E!==null,className:`inline-flex h-7 items-center gap-1 border border-border/75 px-2 text-[10px] font-semibold uppercase tracking-[0.08em] text-muted-foreground hover:border-primary hover:text-primary disabled:opacity-40`,title:d(`activity:sessions.resume`,{defaultValue:`Resume session`}),children:[(0,Q.jsx)(dn,{className:`h-3 w-3`}),d(`activity:sessions.resumeShort`,{defaultValue:`Resume`})]}):null,(0,Q.jsx)(`button`,{type:`button`,onClick:()=>p(e.id),"aria-pressed":t,className:G(`inline-flex h-7 w-7 items-center justify-center transition-colors hover:bg-warning/10 hover:text-warning`,t?`text-warning`:`text-muted-foreground`),title:d(t?`activity:sessions.unfavorite`:`activity:sessions.markFavorite`),children:(0,Q.jsx)(rn,{className:G(`h-3.5 w-3.5`,t&&`fill-current`)})}),i?null:(0,Q.jsx)(`button`,{type:`button`,onClick:()=>P(e),className:`inline-flex h-7 w-7 items-center justify-center text-muted-foreground transition-colors hover:bg-primary/10 hover:text-primary`,title:d(`activity:sessions.renameAction`,{defaultValue:`Rename`}),children:(0,Q.jsx)(Ht,{className:`h-3.5 w-3.5`})}),e.isCurrent?null:(0,Q.jsx)(`button`,{type:`button`,onClick:async()=>{await mi({title:d(`activity:sessions.deleteSessionConfirmTitle`),message:d(`activity:sessions.deleteSessionConfirmBody`,{name:N(e)}),confirmLabel:d(`common:action.delete`),danger:!0})&&c(e.id)},className:`inline-flex h-7 w-7 items-center justify-center text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive`,title:d(`activity:sessions.deleteSessionTitle`),children:(0,Q.jsx)(C,{className:`h-3.5 w-3.5`})})]})]},e.id)})})]},e.label))}),(0,Q.jsx)(ni,{page:O,pageSize:ne,totalItems:I.length,onPageChange:k,compact:!M,itemLabel:`sessions`})]})})]})}function Bu(){let e=q(e=>e.wsConnected),{entries:t,loading:n,error:r}=Cr($t(e=>({entries:e.entries,loading:e.loading,error:e.error}))),{listSessions:i,resumeSession:a,deleteSession:o,renameSession:s}=dr(),c=K(e=>e.session?.id),{t:l}=V(),[u,d]=(0,Z.useState)(``);return(0,Z.useEffect)(()=>{e&&i(200)},[e,c,i]),(0,Q.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,Q.jsx)(zu,{historyQuery:u,setHistoryQuery:d,historyEntries:t,historyLoading:n,historyError:r,wsConnected:e,listSessions:i,resumeSession:a,deleteSession:o,renameSession:s,variant:`sidebar`}),(0,Q.jsx)(`div`,{className:`border-t px-3 py-2 shrink-0`,children:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{let e=U.getState();e.setCurrentView(`sessions`),e.setSidebarOpen(!1)},className:`flex h-8 w-full items-center justify-center gap-1.5 border border-border text-[11px] font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:[(0,Q.jsx)(ft,{className:`h-3 w-3`}),l(`activity:history.openDashboard`)]})})]})}function Vu(e){return e<=0?`$0.000`:e>=.01?`$${e.toFixed(3)}`:`$${e.toFixed(4)}`}function Hu(e){if(e<=0)return`--`;let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m ${t%60}s`:`${Math.floor(n/60)}h ${n%60}m`}function Uu(e){let t=e.split(`/`).pop()??e;return t.length>18?t.slice(0,18):t}function Wu({icon:e,label:t,onClick:n,disabled:r,tone:i,title:a}){return(0,Q.jsxs)(`button`,{type:`button`,onClick:n,disabled:r,title:a??t,className:G(`flex items-center justify-center gap-1.5 h-8 rounded-md border text-[11px] font-medium transition-colors`,`disabled:opacity-40 disabled:cursor-not-allowed`,i===`primary`?`border-primary/40 bg-primary/10 text-primary hover:bg-primary/20`:i===`danger`?`border-destructive/40 bg-destructive/10 text-destructive hover:bg-destructive/20`:`border-border bg-card hover:bg-accent text-foreground/80`),children:[e,t]})}function Gu({label:e,value:t,sub:n}){return(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col rounded-lg border border-border/60 bg-card/65 p-2 shadow-sm`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:e}),(0,Q.jsx)(`span`,{className:`text-sm font-semibold tabular-nums truncate`,children:t}),n&&(0,Q.jsx)(`span`,{className:`text-[9px] text-muted-foreground/70 truncate`,children:n})]})}function Ku({icon:e,label:t,right:n}){return(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[10px] uppercase text-muted-foreground font-semibold`,children:[e,t]}),n]})}function qu({label:e,value:t,onChange:n,title:r}){return(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 py-1`,title:r,children:[(0,Q.jsx)(`span`,{className:`text-xs text-foreground/80`,children:e}),(0,Q.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":t,onClick:n,className:G(`shrink-0 relative inline-flex h-4 w-7 rounded-full border transition-colors`,t?`bg-primary border-primary`:`bg-muted border-input hover:bg-muted/80`),children:(0,Q.jsx)(`span`,{className:G(`absolute top-0.5 left-0.5 h-2.5 w-2.5 rounded-full bg-background shadow transition-transform`,t&&`translate-x-3`)})})]})}function Ju(){let{client:e,updatePrefs:t,switchAutonomy:n}=dr(),{t:r}=V(),a=q(e=>e.wsConnected),o=q(e=>e.wsUrl),s=q(e=>e.provider),c=q(e=>e.model),l=q(e=>e.soundOnComplete),u=K(e=>e.session),d=K(e=>e.totalTokens),f=K(e=>e.cost),p=K(e=>e.iteration),m=K(e=>e.todos),h=K(e=>e.lastInputTokens),g=K(e=>e.maxContext),_=i(e=>e.messages),v=i(e=>e.isLoading),y=xr(e=>e.agents),b=U(e=>e.pinnedIds),x=U(e=>e.unpinAll),S=U(e=>e.setModelSwitcherOpen),C=W(),w=(0,Z.useCallback)((e,n)=>{C.set({[e]:n}),t({[e]:n})},[C,t]),T=U(e=>e.setSideContextBreakdownOpen),E=u?.startedAt??null,[D,O]=(0,Z.useState)(()=>Date.now());(0,Z.useEffect)(()=>{if(!E)return;let e=setInterval(()=>O(Date.now()),1e3);return()=>clearInterval(e)},[E]);let k=(0,Z.useMemo)(()=>Array.from(y.values()).filter(e=>e.status===`running`).length,[y]),A=g>0&&h>0?Math.min(100,Math.round(h/g*100)):0,j=b.map(e=>_.find(t=>t.id===e)).filter(e=>!!e&&e.content.length>0),M=ho(m,12,u?.id),N=ho(j,8,u?.id),P=e=>pr(o)?.send?.(e),ee=(0,Z.useCallback)(async()=>{v&&!await mi({title:r(`activity:sessionPanel.actions.newSessionConfirm`),message:r(`activity:sessionPanel.actions.newSessionConfirmMessage`),confirmLabel:r(`activity:sessionPanel.actions.newSession`),danger:!0})||(e?.newSession?.(),J(`chat`))},[e,v,r]);return(0,Q.jsxs)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain bg-[hsl(var(--surface-2)/0.28)] [scrollbar-gutter:stable]`,children:[(0,Q.jsxs)(`div`,{className:`grid grid-cols-2 gap-1.5 border-b border-border/70 bg-card/55 px-3 py-2.5`,children:[v&&(0,Q.jsx)(Wu,{icon:(0,Q.jsx)(we,{className:`h-3 w-3`}),label:r(`activity:sessionPanel.actions.abort`),tone:`danger`,onClick:()=>P({type:`abort`,payload:{}}),disabled:!a}),(0,Q.jsx)(Wu,{icon:(0,Q.jsx)(jt,{className:`h-3 w-3`}),label:r(`activity:sessionPanel.actions.newSession`),tone:`primary`,onClick:()=>void ee(),disabled:!a,title:r(`activity:sessionPanel.actions.newSessionTitle`)}),(0,Q.jsx)(Wu,{icon:(0,Q.jsx)(wn,{className:`h-3 w-3`}),label:r(`activity:sessionPanel.actions.export`),onClick:()=>oa(),title:r(`activity:sessionPanel.actions.exportTitle`)}),(0,Q.jsx)(Wu,{icon:(0,Q.jsx)(be,{className:`h-3 w-3`}),label:r(`activity:sessionPanel.actions.compact`),onClick:()=>P({type:`context.compact`,payload:{aggressive:!1}}),disabled:!a,title:r(`activity:sessionPanel.actions.compactTitle`)}),(0,Q.jsx)(Wu,{icon:(0,Q.jsx)(ct,{className:`h-3 w-3`}),label:r(`common:action.clear`),onClick:()=>P({type:`context.clear`}),disabled:!a,title:r(`activity:sessionPanel.actions.clearTitle`)})]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>S(!0),className:`w-full border-b border-border/70 bg-card/35 px-4 py-2.5 text-left transition-colors hover:bg-muted/40`,title:r(`activity:sessionPanel.modelTitle`),children:[(0,Q.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-0.5`,children:r(`activity:sessionPanel.model`)}),(0,Q.jsxs)(`div`,{className:`font-mono text-xs truncate`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:s||`—`}),(0,Q.jsx)(`span`,{className:`text-muted-foreground/65 mx-1`,children:`/`}),(0,Q.jsx)(`span`,{className:`font-medium`,children:c||`—`})]})]}),g>0&&(0,Q.jsxs)(`div`,{className:`space-y-1.5 border-b border-border/70 bg-card/35 px-4 py-2.5`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>T(!0),className:`w-full block text-left`,title:r(`activity:sessionPanel.contextTitle`),children:(0,Q.jsx)(Ku,{icon:null,label:r(`activity:sessionPanel.context`),right:(0,Q.jsxs)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums font-mono`,children:[eo(h),`/`,eo(g),` · `,A,`%`]})})}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>T(!0),className:`w-full block`,title:r(`activity:sessionPanel.contextTitle`),children:(0,Q.jsx)(mo,{pct:A,tokens:h,maxTokens:g,showTokens:!0})})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5 border-b border-border/70 px-3 py-2.5`,children:[(0,Q.jsx)(Ku,{icon:(0,Q.jsx)(yt,{className:`h-3 w-3`}),label:r(`activity:sessionPanel.sessionLabel`)}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-2 gap-1.5`,children:[(0,Q.jsx)(Gu,{label:r(`activity:sessionPanel.stats.messages`),value:_.length}),(0,Q.jsx)(Gu,{label:r(`activity:sessionPanel.stats.elapsed`),value:E?Hu(D-E):`--`}),(0,Q.jsx)(Gu,{label:r(`activity:sessionPanel.stats.tokens`),value:eo(d.input+d.output),sub:r(`activity:sessionPanel.stats.tokensSub`,{in:eo(d.input),out:eo(d.output)})}),(0,Q.jsx)(Gu,{label:r(`activity:sessionPanel.stats.cost`),value:Vu(f)}),p&&(0,Q.jsx)(Gu,{label:r(`activity:sessionPanel.stats.iteration`),value:p.index,sub:p.max?r(`activity:sessionPanel.stats.iterationOf`,{max:p.max}):void 0}),y.size>0&&(0,Q.jsx)(Gu,{label:r(`activity:sessionPanel.stats.agents`),value:y.size,sub:k>0?r(`activity:sessionPanel.stats.agentsRunning`,{count:k}):void 0})]})]}),m.length>0&&(()=>{let e=m.filter(e=>e.status===`completed`).length,t=m.filter(e=>e.status===`in_progress`).length,n=Math.round(e/m.length*100),i=e===m.length;return(0,Q.jsxs)(`div`,{className:`space-y-1.5 border-b border-border/70 px-3 py-2.5`,children:[(0,Q.jsx)(Ku,{icon:(0,Q.jsx)(ae,{className:`h-3 w-3`}),label:r(`activity:sessionPanel.plan`),right:(0,Q.jsxs)(`span`,{className:`tabular-nums text-[10px] text-muted-foreground`,children:[e,`/`,m.length]})}),(0,Q.jsx)(`div`,{className:G(`relative h-1.5 w-full overflow-hidden rounded-full bg-muted`,t>0&&`bar-sweep`),title:r(`activity:sessionPanel.planComplete`,{pct:n}),children:(0,Q.jsx)(`div`,{className:G(`h-full rounded-full transition-all duration-500`,i?`bg-success`:`bg-primary`),style:{width:`${Math.max(n,t>0?4:0)}%`}})}),(0,Q.jsx)(`ul`,{className:`space-y-0.5 max-h-56 overflow-y-auto pr-1 -mx-1`,children:M.pageItems.map(e=>{let t=e.status===`completed`?Gt:e.status===`in_progress`?qt:At,n=e.status===`in_progress`,r=e.status===`completed`?`text-success line-through opacity-60`:n?`text-foreground`:`text-muted-foreground`;return(0,Q.jsxs)(`li`,{className:G(`flex items-start gap-2 text-xs leading-snug rounded-md px-1.5 py-1 transition-colors`,n&&`bg-primary/10 ring-1 ring-inset ring-primary/20`,r),children:[(0,Q.jsx)(t,{className:G(`h-3.5 w-3.5 mt-0.5 shrink-0`,n&&`text-primary animate-pulse`)}),(0,Q.jsx)(`span`,{className:`break-words`,children:n&&e.activeForm?e.activeForm:e.content})]},e.id)})}),(0,Q.jsx)(ni,{page:M.page,pageSize:M.pageSize,totalItems:M.totalItems,onPageChange:M.setPage,compact:!0,itemLabel:`todos`})]})})(),j.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-1.5 border-b border-border/70 px-3 py-2.5`,children:[(0,Q.jsx)(Ku,{icon:(0,Q.jsx)(Ft,{className:`h-3 w-3 text-warning`}),label:r(`activity:sessionPanel.pinned`),right:(0,Q.jsx)(`button`,{type:`button`,onClick:x,className:`text-[10px] text-muted-foreground hover:text-destructive`,children:r(`common:action.clear`)})}),(0,Q.jsx)(`ul`,{className:`space-y-1 max-h-48 overflow-y-auto pr-1`,children:N.pageItems.map(e=>{let t=e.content.replace(/\s+/g,` `).slice(0,80);return(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{let t=document.querySelector(`[data-message-id="${e.id}"]`);t&&(t.scrollIntoView({behavior:`smooth`,block:`center`}),t.classList.add(`ring-2`,`ring-warning/60`),setTimeout(()=>{t.classList.remove(`ring-2`,`ring-warning/60`)},1600))},className:`w-full text-left text-xs px-2 py-1.5 rounded bg-muted/40 hover:bg-muted/70 border border-warning/20 leading-snug`,title:e.content.slice(0,400),children:[t,e.content.length>80?`…`:``]})},e.id)})}),(0,Q.jsx)(ni,{page:N.page,pageSize:N.pageSize,totalItems:N.totalItems,onPageChange:N.setPage,compact:!0,itemLabel:`pinned answers`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1 border-b border-border/70 px-3 py-2.5`,children:[(0,Q.jsx)(Ku,{icon:(0,Q.jsx)(ue,{className:`h-3 w-3`}),label:r(`activity:sessionPanel.quickSettings`)}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 py-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs text-foreground/80`,children:r(`activity:sessionPanel.autonomy`)}),(0,Q.jsxs)(`select`,{value:C.autonomy,onChange:e=>{let t=e.target.value;C.set({autonomy:t}),n(t)},className:`shrink-0 h-6 max-w-[150px] rounded-md border bg-background px-1.5 text-[11px]`,children:[(0,Q.jsx)(`option`,{value:`off`,children:r(`activity:sessionPanel.autonomyOptions.off`)}),(0,Q.jsx)(`option`,{value:`suggest`,children:r(`activity:sessionPanel.autonomyOptions.suggest`)}),(0,Q.jsx)(`option`,{value:`auto`,children:r(`activity:sessionPanel.autonomyOptions.auto`)}),(0,Q.jsx)(`option`,{value:`eternal`,children:r(`activity:sessionPanel.autonomyOptions.eternal`)}),(0,Q.jsx)(`option`,{value:`eternal-parallel`,children:r(`activity:sessionPanel.autonomyOptions.eternal-parallel`)})]})]}),(0,Q.jsx)(qu,{label:r(`activity:sessionPanel.yolo`),title:r(`activity:sessionPanel.yoloTitle`),value:C.yolo,onChange:()=>w(`yolo`,!C.yolo)}),(0,Q.jsx)(qu,{label:r(`activity:sessionPanel.refine`),title:r(`activity:sessionPanel.refineTitle`),value:C.enhanceEnabled,onChange:()=>w(`enhanceEnabled`,!C.enhanceEnabled)}),(0,Q.jsx)(qu,{label:r(`activity:sessionPanel.sound`),title:r(`activity:sessionPanel.soundTitle`),value:l,onChange:()=>{let e=!q.getState().soundOnComplete;q.getState().setSoundOnComplete(e),e&&rr()}})]}),(0,Q.jsxs)(`div`,{className:`px-4 py-2.5`,children:[(0,Q.jsxs)(`div`,{className:G(`flex items-center gap-2 text-[11px]`,a?`text-success`:`text-warning`),children:[a?(0,Q.jsx)(Nt,{className:`h-3.5 w-3.5`}):(0,Q.jsx)(pn,{className:`h-3.5 w-3.5`}),(0,Q.jsx)(`span`,{className:`font-medium`,children:r(a?`common:status.connected`:`common:status.disconnected`)}),(0,Q.jsx)(`span`,{className:`text-muted-foreground font-mono truncate ml-auto`,title:o,children:o})]}),u&&(0,Q.jsx)(`div`,{className:`text-[10px] text-muted-foreground font-mono mt-1 truncate`,title:u.id,children:r(`activity:sessionPanel.sessionId`,{id:Uu(u.id)})})]})]})}var Yu=16;function Xu(e,t){switch(t){case`project`:return e(`activity:skillDetail.scopeProject`);case`user`:return e(`activity:skillDetail.scopeGlobal`);case`bundled`:return e(`activity:skillDetail.scopeBundled`);case`foreign`:return e(`activity:skillsList.scopeForeign`)}}function Zu(e){return e===`project`||e===`user`||e===`bundled`?e:`foreign`}function Qu({source:e}){let{t}=V(),n=Zu(e);return(0,Q.jsx)(`span`,{className:G(`inline-flex items-center rounded-md border px-1.5 py-0.5 text-[9px] font-semibold uppercase tracking-wide`,n===`project`&&`border-success/25 bg-success/8 text-success`,n===`user`&&`border-primary/25 bg-primary/10 text-primary`,n===`bundled`&&`border-border/70 bg-muted/60 text-muted-foreground`,n===`foreign`&&`border-warning/28 bg-warning/10 text-warning`),children:Xu(t,n)})}function $u({className:e}){let{t}=V(),{client:n}=dr(),r=U(e=>e.skillsState),i=U(e=>e.setSkillsState),[a,o]=(0,Z.useState)([]),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(`all`),[d,f]=(0,Z.useState)(``),[p,m]=(0,Z.useState)(1),h=(0,Z.useRef)(r);h.current=r;let[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(``),[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(null),[D,O]=(0,Z.useState)(null),[k,A]=(0,Z.useState)(!1),[j,M]=(0,Z.useState)(``),[N,P]=(0,Z.useState)(``),[te,F]=(0,Z.useState)(`project`),[I,ne]=(0,Z.useState)(!1),[re,L]=(0,Z.useState)(null),[ie,ae]=(0,Z.useState)(null),[R,z]=(0,Z.useState)(!1),[oe,se]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{if(!_&&!k)return;let e=e=>{e.key===`Escape`&&(_&&v(!1),k&&A(!1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[_,k]);let ce=(0,Z.useRef)(new Map);(0,Z.useEffect)(()=>{let e=ce.current;return()=>{for(let t of e.values())t();e.clear()}},[]);let le=(0,Z.useCallback)((e,t,r,i=15e3)=>{if(!n)return;ce.current.get(e)?.();let a=null,o=e=>{s(),t(e)},s=()=>{a&&clearTimeout(a),n.off(e,o),ce.current.delete(e)};a=setTimeout(()=>{s(),r()},i),n.on(e,o),ce.current.set(e,s)},[n]),ue=(0,Z.useCallback)(()=>{!n||!y.trim()||(w(!0),E(null),O(null),le(`skills.installed`,e=>{let t=e;if(w(!1),t.payload.success){let e=t.payload.results?.map(e=>e.name).join(`, `)??y;O(H.t(`activity:skillsList.installedMsg`,{names:e})),n.send({type:`skills.list`},{echoToChat:!1})}else E(t.payload.error??H.t(`activity:skillsList.installFailed`))},()=>{w(!1),E(H.t(`activity:skillsList.installFailed`))}),n.installSkill(y.trim(),x))},[n,y,x,le]),de=(0,Z.useCallback)(()=>{!n||!j.trim()||!N.trim()||(ne(!0),L(null),ae(null),le(`skills.created`,e=>{let t=e;ne(!1),t.payload.success?(ae(H.t(`activity:skillsList.createdMsg`,{name:t.payload.skill?.name??``})),n.send({type:`skills.list`},{echoToChat:!1})):L(t.payload.error??H.t(`activity:skillsList.createFailed`))},()=>{ne(!1),L(H.t(`activity:skillsList.createFailed`))}),n.createSkill(j.trim(),N.trim(),te))},[n,j,N,te,le]),fe=(0,Z.useCallback)(()=>{n&&(se(!0),n.checkForUpdates(void 0,void 0))},[n]),pe=(0,Z.useCallback)(()=>{n&&(z(!0),le(`skills.exported`,e=>{let t=e;if(z(!1),t.payload.error){console.error(t.payload.error);return}let n=atob(t.payload.zipBase64),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);let i=new Blob([r],{type:`application/zip`}),a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=`wrongstack-skills-${Date.now()}.zip`,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(a)},()=>z(!1),3e4),n.exportAllSkills())},[n,le]);(0,Z.useEffect)(()=>{if(!n)return;c(!0);let e=e=>{let t=e;if(t.payload.enabled&&t.payload.skills){o(t.payload.skills);let e=h.current,n=e.knownRefs,r=0,a={...n};for(let e of t.payload.skills){if(e.source===`bundled`)continue;let t=e.ref;if(!t)continue;let i=n[e.name];a[e.name]=t,i&&i!==t&&r++}i({...e,knownRefs:a,updateAvailableCount:r})}c(!1)},t=e=>{let t=e;if(se(!1),t.payload.success){let e=h.current,r={...e.knownRefs};for(let e of t.payload.updated??[])r[e.name]=e.newRef;i({...e,knownRefs:r,updateAvailableCount:0}),n.send({type:`skills.list`},{echoToChat:!1})}};return n.on(`skills.list`,e),n.on(`skills.updated`,t),n.send({type:`skills.list`},{echoToChat:!1}),()=>{n.off(`skills.list`,e),n.off(`skills.updated`,t)}},[n,i]);let me=(0,Z.useCallback)(e=>{i({...h.current,selectedSkill:e,navHistory:[e],historyIndex:0,detailOpen:!0}),J(`skills`)},[i]),he=(0,Z.useMemo)(()=>{let e=a;if(l!==`all`&&(e=e.filter(e=>Zu(e.source)===l)),d.trim()){let t=d.toLowerCase();e=e.filter(e=>e.name.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)||e.trigger.toLowerCase().includes(t))}return e},[a,l,d]),ge=(0,Z.useMemo)(()=>he.slice((p-1)*Yu,p*Yu),[he,p]),_e=(0,Z.useMemo)(()=>{let e={project:[],user:[],foreign:[],bundled:[]};for(let t of ge)e[Zu(t.source)].push(t);return e},[ge]);(0,Z.useEffect)(()=>{m(1)},[l,d]),(0,Z.useEffect)(()=>{let e=Math.max(1,Math.ceil(he.length/Yu));p>e&&m(e)},[he.length,p]);let ve=r.selectedSkill?.name;return(0,Q.jsxs)(`div`,{className:G(`flex h-full min-h-0 min-w-0 flex-col overflow-hidden bg-[hsl(var(--surface-2)/0.28)]`,e),children:[(0,Q.jsxs)(`div`,{className:`flex w-full items-center gap-1 border-b border-border/60 bg-card/65 px-2 py-2`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{b(``),E(null),O(null),S(!1),v(!0)},className:`flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,title:t(`activity:skillsList.installTitle`),children:(0,Q.jsx)(jt,{className:`h-4 w-4`})}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{M(``),P(``),F(`project`),L(null),ae(null),A(!0)},className:`flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,title:t(`activity:skillsList.createTitle`),children:(0,Q.jsx)(je,{className:`h-4 w-4`})}),(0,Q.jsx)(`button`,{type:`button`,onClick:pe,disabled:R||a.length===0,className:`flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:opacity-40`,title:t(`activity:skillsList.exportTitle`),children:R?(0,Q.jsx)(g,{className:`h-4 w-4 animate-spin`}):(0,Q.jsx)(wn,{className:`h-4 w-4`})}),(0,Q.jsxs)(`button`,{type:`button`,onClick:fe,disabled:oe,className:`relative flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:opacity-40`,title:t(`activity:skillsList.checkUpdatesTitle`),children:[oe?(0,Q.jsx)(g,{className:`h-4 w-4 animate-spin`}):(0,Q.jsx)(Dn,{className:`h-4 w-4`}),!oe&&r.updateAvailableCount>0&&(0,Q.jsx)(`span`,{className:`absolute top-0.5 right-0.5 h-2.5 w-2.5 rounded-full bg-primary text-[8px] font-bold text-primary-foreground flex items-center justify-center`,children:r.updateAvailableCount>9?`9+`:r.updateAvailableCount})]})]}),(0,Q.jsxs)(`div`,{className:`shrink-0 space-y-2 border-b border-border/60 bg-card/45 p-2`,children:[(0,Q.jsx)(`input`,{type:`text`,value:d,onChange:e=>f(e.target.value),placeholder:t(`activity:skillsList.searchPlaceholder`),className:`w-full rounded-md border border-border/70 bg-background/70 px-2 py-1.5 text-xs shadow-sm focus:outline-none focus:ring-1 focus:ring-ring`}),(0,Q.jsx)(`div`,{className:`flex gap-1 flex-wrap`,children:[`all`,`project`,`user`,`foreign`,`bundled`].map(e=>{let n=e===`all`?he.length:he.filter(t=>Zu(t.source)===e).length;return(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>u(e),className:G(`rounded-md px-1.5 py-0.5 text-[10px] transition-colors`,l===e?`bg-primary text-primary-foreground`:`bg-background/60 text-muted-foreground hover:bg-accent`),children:[e===`all`?t(`common:action.all`):Xu(t,e),(0,Q.jsxs)(`span`,{className:G(`ml-1 font-medium`,l===e?`opacity-90`:`opacity-60`,n===0&&`line-through`),children:[`(`,n,`)`]})]},e)})})]}),(0,Q.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain p-2 [scrollbar-gutter:stable]`,children:s?(0,Q.jsx)(`div`,{className:`rounded-lg border border-border/60 bg-card/55 p-4 text-center text-xs text-muted-foreground`,children:t(`activity:skillsList.loading`)}):he.length===0?(0,Q.jsx)(`div`,{className:`rounded-lg border border-border/60 bg-card/55 p-4 text-center text-xs text-muted-foreground`,children:a.length===0?t(`activity:skillsList.noSkills`):t(`activity:skillsList.noMatch`)}):(0,Q.jsx)(`div`,{className:`space-y-2`,children:[`project`,`user`,`foreign`,`bundled`].map(e=>{let n=_e[e];return n.length===0?null:(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 px-1 py-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[(0,Q.jsx)(Qu,{source:e}),(0,Q.jsx)(`span`,{className:`ml-auto opacity-60`,children:n.length})]}),n.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>me(e),className:G(`w-full rounded-lg border px-2.5 py-2 text-left text-xs transition-colors`,ve===e.name?`border-primary/30 bg-primary/10 text-primary shadow-sm`:`border-border/50 bg-card/55 text-foreground hover:border-border hover:bg-accent/50`),children:[(0,Q.jsxs)(`div`,{className:`font-medium truncate flex items-center gap-1`,children:[(0,Q.jsx)(ee,{className:`h-3 w-3 shrink-0`}),e.name]}),(0,Q.jsx)(`div`,{className:`text-[10px] text-muted-foreground truncate mt-0.5`,children:e.trigger||e.description?.slice(0,50)||t(`activity:skillsList.noDescription`)})]},e.name))]},e)})})}),(0,Q.jsx)(ni,{page:p,pageSize:Yu,totalItems:he.length,onPageChange:m,compact:!0,itemLabel:`skills`}),(0,Q.jsx)($r,{open:_,onOpenChange:v,children:(0,Q.jsxs)(Xr,{className:`flex max-h-[calc(100dvh-2rem)] w-[420px] max-w-[90vw] flex-col gap-0 overflow-hidden p-0`,showCloseButton:!1,children:[(0,Q.jsxs)(Jr,{className:`flex shrink-0 items-center justify-between border-b border-border/70 p-4 sm:flex-row sm:justify-between sm:space-y-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(wn,{className:`h-4 w-4 text-primary`}),(0,Q.jsx)(Zr,{className:`font-semibold text-sm`,children:t(`activity:skillsList.installHeading`)})]}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>v(!1),"aria-label":t(`common:action.close`),className:`rounded p-1 text-muted-foreground hover:bg-accent hover:text-accent-foreground`,children:(0,Q.jsx)(vn,{className:`h-4 w-4`})})]}),(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-4 space-y-3`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`activity:skillsList.installHint`)}),(0,Q.jsx)(`input`,{type:`text`,value:y,onChange:e=>{b(e.target.value),E(null),O(null)},onKeyDown:e=>{e.key===`Enter`&&!C&&ue()},placeholder:t(`activity:skillsList.installPlaceholder`),className:`w-full rounded-md border border-border/70 bg-background/70 px-3 py-2 text-xs shadow-sm focus:outline-none focus:ring-1 focus:ring-ring`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t(`activity:skillsList.installScope`)}),(0,Q.jsxs)(`div`,{className:`flex overflow-hidden rounded-md border border-border/70`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>S(!1),className:G(`px-2 py-1 text-[10px] transition-colors`,x?`bg-background hover:bg-accent`:`bg-primary text-primary-foreground`),children:t(`activity:skillDetail.scopeProject`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>S(!0),className:G(`px-2 py-1 text-[10px] transition-colors border-l border-border`,x?`bg-primary text-primary-foreground`:`bg-background hover:bg-accent`),children:t(`activity:skillDetail.scopeGlobal`)})]})]}),T&&(0,Q.jsx)(`p`,{className:`rounded-md bg-destructive/10 px-2 py-1 text-xs text-destructive`,children:T}),D&&(0,Q.jsx)(`p`,{className:`rounded-md bg-success/10 px-2 py-1 text-xs text-success`,children:D})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-border/70 bg-muted/20 p-4`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>v(!1),className:`rounded-md border border-border/70 px-3 py-1.5 text-xs transition-colors hover:bg-accent`,children:t(D?`common:action.close`:`common:action.cancel`)}),!D&&(0,Q.jsxs)(`button`,{type:`button`,onClick:ue,disabled:C||!y.trim(),className:`flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground transition-colors hover:bg-primary/90 disabled:cursor-not-allowed disabled:opacity-50`,children:[C&&(0,Q.jsx)(g,{className:`h-3 w-3 animate-spin`}),t(`activity:skillsList.installBtn`)]})]})]})}),(0,Q.jsx)($r,{open:k,onOpenChange:A,children:(0,Q.jsxs)(Xr,{className:`flex max-h-[calc(100dvh-2rem)] w-[480px] max-w-[90vw] flex-col gap-0 overflow-hidden p-0`,showCloseButton:!1,children:[(0,Q.jsxs)(Jr,{className:`flex shrink-0 items-center justify-between border-b border-border/70 p-4 sm:flex-row sm:justify-between sm:space-y-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(je,{className:`h-4 w-4 text-primary`}),(0,Q.jsx)(Zr,{className:`font-semibold text-sm`,children:t(`activity:skillsList.createHeading`)})]}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>A(!1),"aria-label":t(`common:action.close`),className:`rounded p-1 text-muted-foreground hover:bg-accent hover:text-accent-foreground`,children:(0,Q.jsx)(vn,{className:`h-4 w-4`})})]}),(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-4 space-y-3`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`activity:skillsList.createHint`)}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`span`,{className:`block text-xs font-medium mb-1`,children:[t(`activity:skillsList.nameLabel`),` `,(0,Q.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,Q.jsx)(`input`,{type:`text`,value:j,onChange:e=>{let t=e.target.value.trim().toLowerCase().replace(/\s+/g,`-`).replace(/[^a-z0-9-]/g,``);M(t),L(null),ae(null)},placeholder:t(`activity:skillsList.namePlaceholder`),className:`w-full rounded-md border border-border/70 bg-background/70 px-3 py-2 font-mono text-xs shadow-sm focus:outline-none focus:ring-1 focus:ring-ring`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`span`,{className:`block text-xs font-medium mb-1`,children:[t(`activity:skillsList.descLabel`),` `,(0,Q.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,Q.jsx)(`textarea`,{value:N,onChange:e=>{P(e.target.value),L(null),ae(null)},onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&!I&&de()},placeholder:t(`activity:skillsList.descPlaceholder`),rows:4,className:`w-full resize-y rounded-md border border-border/70 bg-background/70 px-3 py-2 text-xs shadow-sm focus:outline-none focus:ring-1 focus:ring-ring`})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t(`activity:skillsList.saveIn`)}),(0,Q.jsxs)(`div`,{className:`flex overflow-hidden rounded-md border border-border/70`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>F(`project`),className:G(`px-2 py-1 text-[10px] transition-colors`,te===`project`?`bg-primary text-primary-foreground`:`bg-background hover:bg-accent`),children:t(`activity:skillDetail.scopeProject`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>F(`global`),className:G(`px-2 py-1 text-[10px] transition-colors border-l border-border`,te===`global`?`bg-primary text-primary-foreground`:`bg-background hover:bg-accent`),children:t(`activity:skillDetail.scopeGlobal`)})]})]}),re&&(0,Q.jsx)(`p`,{className:`rounded-md bg-destructive/10 px-2 py-1 text-xs text-destructive`,children:re}),ie&&(0,Q.jsx)(`p`,{className:`rounded-md bg-success/10 px-2 py-1 text-xs text-success`,children:ie})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-border/70 bg-muted/20 p-4`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>A(!1),className:`rounded-md border border-border/70 px-3 py-1.5 text-xs transition-colors hover:bg-accent`,children:t(ie?`common:action.close`:`common:action.cancel`)}),!ie&&(0,Q.jsxs)(`button`,{type:`button`,onClick:de,disabled:I||!j.trim()||!N.trim(),className:`flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground transition-colors hover:bg-primary/90 disabled:cursor-not-allowed disabled:opacity-50`,children:[I&&(0,Q.jsx)(g,{className:`h-3 w-3 animate-spin`}),t(`activity:skillsList.createBtn`)]})]})]})})]})}var ed=[`web`,`react-native`,`flutter`,`swiftui`,`compose`],td=[`bg`,`surface`,`primary`,`accent`,`fg`,`border`];function nd({tokens:e,label:t}){let n=td.filter(t=>e[t]);return n.length===0?null:(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-[9px] uppercase tracking-wide text-muted-foreground w-7`,children:t}),(0,Q.jsx)(`div`,{className:`flex gap-0.5`,children:n.map(t=>(0,Q.jsx)(`div`,{className:`w-4 h-4 rounded-sm border border-black/10 dark:border-white/10`,style:{backgroundColor:e[t]},title:`${t}: ${e[t]}`},t))})]})}function rd({className:e}){let{client:t}=dr(),{t:n}=V(),[r,i]=(0,Z.useState)([]),[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(!0),[l,u]=(0,Z.useState)(`web`),[d,f]=(0,Z.useState)(null);(0,Z.useEffect)(()=>{if(!t)return;let e=e=>{let t=e.payload;i(t?.kits??[]),o(t?.activeKit??null),c(!1)},n=e=>{let t=e.payload;f(null),t?.ok&&t.kit&&o(t.kit)};return t.on(`design.list`,e),t.on(`design.use`,n),t.send({type:`design.list`}),()=>{t.off(`design.list`,e),t.off(`design.use`,n)}},[t]);let p=(0,Z.useCallback)(e=>{t&&(f(e),t.send({type:`design.use`,payload:{kit:e,stack:l}}))},[t,l]),m=(0,Z.useMemo)(()=>[...r].sort((e,t)=>e.name.localeCompare(t.name)),[r]),h=ho(m,10,l);return(0,Q.jsxs)(`div`,{className:G(`flex h-full min-h-0 min-w-0 flex-col`,e),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 border-b border-border/50`,children:[(0,Q.jsx)(Dt,{className:`w-4 h-4 text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground flex-1`,children:n(`activity:designStudio.pickHint`)}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>J(`design`),className:`inline-flex items-center gap-1 text-[11px] px-1.5 py-0.5 rounded border border-border/60 hover:bg-muted`,title:n(`activity:designStudio.galleryTitle`),children:[(0,Q.jsx)(ft,{className:`w-3 h-3`}),` `,n(`activity:designStudio.gallery`)]}),(0,Q.jsx)(`select`,{value:l,onChange:e=>u(e.target.value),className:`text-[11px] bg-transparent border border-border/60 rounded px-1 py-0.5`,title:n(`activity:designStudio.stackTitle`),children:ed.map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e))})]}),(0,Q.jsxs)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain p-2 space-y-2`,children:[s&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground p-3`,children:[(0,Q.jsx)(g,{className:`w-4 h-4 animate-spin`}),` `,n(`activity:designStudio.loading`)]}),!s&&m.length===0&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground p-3`,children:n(`activity:designStudio.notFound`)}),h.pageItems.map(e=>{let t=a===e.id;return(0,Q.jsxs)(`div`,{className:G(`rounded-lg border p-3 transition-colors`,t?`border-primary/60 bg-primary/5`:`border-border/60 hover:border-border`),children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold truncate`,children:e.name}),t&&(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-[9px] font-semibold uppercase text-primary`,children:[(0,Q.jsx)(Wn,{className:`w-3 h-3`}),` `,n(`activity:design.active`)]})]}),(0,Q.jsx)(`p`,{className:`text-[11px] text-muted-foreground leading-snug mt-0.5`,children:e.aesthetic})]}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>p(e.id),disabled:d===e.id,className:G(`shrink-0 text-[11px] px-2 py-1 rounded font-medium`,t?`bg-primary/10 text-primary`:`bg-primary text-primary-foreground hover:opacity-90`),children:d===e.id?`…`:n(t?`activity:design.reapply`:`activity:design.use`)})]}),(0,Q.jsxs)(`div`,{className:`mt-2 space-y-1`,children:[(0,Q.jsx)(nd,{tokens:e.light,label:n(`activity:designStudio.light`)}),(0,Q.jsx)(nd,{tokens:e.dark,label:n(`activity:designStudio.dark`)})]}),e.bestFor&&(0,Q.jsxs)(`p`,{className:`text-[10px] text-muted-foreground mt-2 leading-snug`,children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:n(`activity:designStudio.bestFor`)}),` `,e.bestFor]}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-1.5`,children:e.stacks.map(e=>(0,Q.jsx)(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-muted text-muted-foreground`,children:e},e))})]},e.id)})]}),(0,Q.jsx)(ni,{page:h.page,pageSize:h.pageSize,totalItems:h.totalItems,onPageChange:h.setPage,compact:!0,itemLabel:`design kits`})]})}var id=new Set([`allocating`,`active`,`committing`,`merging`]),ad={active:`text-warning`,committing:`text-primary`,merging:`text-info`,merged:`text-success`,"needs-review":`text-destructive`,failed:`text-destructive`,orphan:`text-muted-foreground`};function od(){let{client:e}=dr(),{t}=V(),n=e=>e?e.replace(/^wstack\/ap\//,``):t(`activity:worktrees.detached`),r=Nr(e=>e.worktrees),i=Nr(e=>e.orphans),a=Nr(e=>e.baseBranch),o=Nr(e=>e.canClean),s=Nr(e=>e.cleanResult),c=Nr(e=>e.mergeResult),l=Nr(e=>e.diffByDir),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(null),m=(0,Z.useMemo)(()=>e?e.send.bind(e):void 0,[e]);(0,Z.useEffect)(()=>{m?.({type:`worktree.scan`})},[m]),(0,Z.useEffect)(()=>{d(null)},[c,s]);let h=(0,Z.useMemo)(()=>{let e=new Set(r.map(e=>e.branch)),t=r.map(e=>({branch:e.branch,dir:e.dir,status:e.status,baseBranch:e.baseBranch,insertions:e.insertions,deletions:e.deletions,files:e.files,owner:e.ownerLabel,live:id.has(e.status)}));for(let n of i)n.branch&&e.has(n.branch)||t.push({branch:n.branch,dir:n.dir,status:`orphan`,insertions:0,deletions:0,files:0,live:!1});return t},[r,i]),_=(e,t)=>{e&&m?.({type:`shell.open`,payload:{path:e,target:t}})},v=e=>{e&&(m?.({type:`worktree.diff`,payload:{dir:e}}),p(t=>t===e?null:e))},y=async e=>{e&&await mi({title:t(`activity:worktrees.mergeConfirmTitle`,{branch:n(e),base:a||t(`activity:worktrees.baseLabel`)}),message:t(`activity:worktrees.mergeConfirmMsg`),confirmLabel:t(`activity:worktrees.mergeAction`)})&&(d(e),m?.({type:`worktree.merge`,payload:{branch:e}}))},b=async e=>{await mi({title:t(`activity:worktrees.removeConfirmTitle`,{branch:n(e.branch)}),message:t(`activity:worktrees.removeConfirmMsg`),confirmLabel:t(`common:action.remove`),danger:!0})&&(d(e.branch??``),m?.({type:`worktree.remove`,payload:{dir:e.dir,branch:e.branch}}))};return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2`,children:[(0,Q.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[t(`activity:worktrees.count`,{count:h.length}),a?t(`activity:worktrees.baseSuffix`,{base:a}):``]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[i.length>0&&(0,Q.jsxs)(`button`,{type:`button`,disabled:!o,onClick:()=>m?.({type:`worktree.cleanup`}),title:t(o?`activity:worktrees.cleanOrphansTitle`:`activity:worktrees.liveBusyTitle`),className:`inline-flex items-center gap-1 rounded bg-warning px-1.5 py-0.5 text-[11px] font-medium text-primary-foreground hover:bg-warning/90 disabled:opacity-50`,children:[(0,Q.jsx)(ct,{className:`h-3 w-3`}),` `,t(`activity:worktrees.cleanOrphans`)]}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>m?.({type:`worktree.scan`}),title:t(`activity:worktrees.rescanTitle`),className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,Q.jsx)(Dn,{className:`h-3.5 w-3.5`})})]})]}),s&&(0,Q.jsx)(cd,{ok:s.ok,children:s.ok?t(`activity:worktrees.removed`,{count:s.removed}):s.reason??t(`activity:worktrees.failed`)}),c&&(0,Q.jsx)(cd,{ok:c.ok,children:c.ok?t(`activity:worktrees.mergedIntoBase`,{branch:n(c.branch)}):c.conflict?t(`activity:worktrees.conflictMerge`,{branch:n(c.branch),files:(c.conflictFiles??[]).join(`, `)||t(`activity:worktrees.seeGit`)}):t(`activity:worktrees.mergeFailed`,{reason:c.reason??t(`activity:worktrees.unknownReason`)})}),(0,Q.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain px-2 pb-3 [scrollbar-gutter:stable]`,children:h.length===0?(0,Q.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 text-center text-xs text-muted-foreground`,children:[(0,Q.jsx)(bn,{className:`h-8 w-8 opacity-30`}),(0,Q.jsx)(`p`,{children:t(`activity:worktrees.empty`)}),(0,Q.jsx)(`p`,{className:`max-w-[200px]`,children:t(`activity:worktrees.emptyHint`)})]}):h.map((e,r)=>{let i=u===(e.branch??``),a=e.dir?l[e.dir]:void 0;return(0,Q.jsxs)(`div`,{className:`mb-1.5 rounded-md border border-border bg-card/60 px-2.5 py-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(bn,{className:G(`h-3.5 w-3.5 shrink-0`,ad[e.status]??`text-muted-foreground`)}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-foreground`,title:e.branch,children:n(e.branch)}),(0,Q.jsx)(`span`,{className:G(`shrink-0 text-[10px] uppercase`,ad[e.status]??`text-muted-foreground`),children:e.status})]}),(0,Q.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-2 pl-5 text-[10px] text-muted-foreground`,children:[e.owner&&(0,Q.jsx)(`span`,{className:`truncate`,children:e.owner}),(e.insertions>0||e.deletions>0)&&(0,Q.jsxs)(`span`,{className:`shrink-0`,children:[(0,Q.jsxs)(`span`,{className:`text-success`,children:[`+`,e.insertions]}),` `,(0,Q.jsxs)(`span`,{className:`text-destructive`,children:[`−`,e.deletions]}),` · `,e.files,`f`]})]}),(0,Q.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-0.5 pl-5`,children:[(0,Q.jsx)(sd,{title:t(`activity:worktrees.actOpenTerm`),disabled:!e.dir,onClick:()=>_(e.dir,`terminal`),children:(0,Q.jsx)(Ze,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(sd,{title:t(`activity:worktrees.actOpenFolder`),disabled:!e.dir,onClick:()=>_(e.dir,`file-manager`),children:(0,Q.jsx)(Ge,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(sd,{title:t(`activity:worktrees.actViewChanges`),disabled:!e.dir,onClick:()=>v(e.dir),children:(0,Q.jsx)(it,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(sd,{title:t(`activity:worktrees.actMerge`),disabled:e.live||!e.branch,onClick:()=>y(e.branch),children:i?(0,Q.jsx)(g,{className:`h-3.5 w-3.5 animate-spin`}):(0,Q.jsx)(It,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(sd,{title:t(`activity:worktrees.actRemove`),danger:!0,disabled:e.live,onClick:()=>b(e),children:(0,Q.jsx)(C,{className:`h-3.5 w-3.5`})}),e.live&&(0,Q.jsx)(`span`,{className:`ml-1 text-[10px] text-warning`,children:t(`activity:worktrees.live`)})]}),f===e.dir&&a!==void 0&&(0,Q.jsx)(`div`,{className:`mt-1.5 ml-5 rounded bg-muted/50 p-1.5 text-[10px]`,children:a===null||a.files.length===0?(0,Q.jsxs)(`span`,{className:`text-muted-foreground`,children:[t(`activity:worktrees.noUncommitted`),a&&a.commits>0?` · ${t(`activity:worktrees.commitsAhead`,{count:a.commits})}`:``,`.`]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`mb-1 text-muted-foreground`,children:[a.commits>0?`${t(`activity:worktrees.commitsAhead`,{count:a.commits})} · `:``,(0,Q.jsxs)(`span`,{className:`text-success`,children:[`+`,a.insertions]}),` `,(0,Q.jsxs)(`span`,{className:`text-destructive`,children:[`−`,a.deletions]})]}),a.files.slice(0,12).map(e=>(0,Q.jsxs)(`div`,{className:`truncate font-mono`,children:[(0,Q.jsxs)(`span`,{className:`text-success`,children:[`+`,e.insertions]}),` `,(0,Q.jsxs)(`span`,{className:`text-destructive`,children:[`−`,e.deletions]}),` `,e.path]},e.path)),a.files.length>12&&(0,Q.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:worktrees.more`,{count:a.files.length-12})})]})})]},`${e.branch??e.dir??r}`)})})]})}function sd({title:e,onClick:t,disabled:n,danger:r,children:i}){return(0,Q.jsx)(`button`,{type:`button`,title:e,disabled:n,onClick:t,className:G(`rounded p-1 text-muted-foreground hover:bg-muted disabled:cursor-not-allowed disabled:opacity-30`,r?`hover:text-destructive`:`hover:text-foreground`),children:i})}function cd({ok:e,children:t}){return(0,Q.jsxs)(`div`,{className:G(`flex items-start gap-1.5 border-y px-3 py-1.5 text-[11px]`,e?`border-success/30 bg-success/5 text-success`:`border-warning/30 bg-warning/5 text-warning`),children:[e?(0,Q.jsx)(Gt,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}):(0,Q.jsx)(kt,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1`,children:t}),!e&&(0,Q.jsx)(un,{className:`mt-0.5 h-3 w-3 shrink-0 opacity-40`})]})}function ld({label:e,checked:t,onChange:n}){return(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>n(!t),className:`flex w-full items-center justify-between px-2 py-1.5 rounded text-xs hover:bg-accent/50 transition-colors`,children:[(0,Q.jsx)(`span`,{className:`text-foreground`,children:e}),(0,Q.jsx)(`span`,{className:G(`relative inline-flex h-4 w-7 shrink-0 items-center rounded-full transition-colors`,t?`bg-primary`:`bg-muted`),children:(0,Q.jsx)(`span`,{className:G(`inline-block h-3 w-3 transform rounded-full bg-background transition-transform`,t?`translate-x-3.5`:`translate-x-0.5`)})})]})}var ud=[{value:`dots`,labelKey:`bgDots`},{value:`lines`,labelKey:`bgLines`},{value:`cross`,labelKey:`bgCross`},{value:`none`,labelKey:`bgNone`}];function dd(){let{t:e}=V(),{showHud:t,showLegend:n,showMinimap:r,showControls:i,animateEdges:a,background:o,setShowHud:s,setShowLegend:c,setShowMinimap:l,setShowControls:u,setAnimateEdges:d,setBackground:f}=Sr($t(e=>({showHud:e.showHud,showLegend:e.showLegend,showMinimap:e.showMinimap,showControls:e.showControls,animateEdges:e.animateEdges,background:e.background,setShowHud:e.setShowHud,setShowLegend:e.setShowLegend,setShowMinimap:e.setShowMinimap,setShowControls:e.setShowControls,setAnimateEdges:e.setAnimateEdges,setBackground:e.setBackground}))),{clientCounts:p,currentSession:m,totalAgents:h,activeAgents:g}=kr($t(e=>({clientCounts:e.clientCounts,currentSession:e.currentSession,totalAgents:e.totalAgents,activeAgents:e.activeAgents}))),_=p.tui+p.webui+p.repl;return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col gap-4 overflow-y-auto overscroll-contain p-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-2`,children:e(`activity:officeMap.liveHeading`)}),(0,Q.jsxs)(`div`,{className:`space-y-1.5 text-xs`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Q.jsx)(xn,{className:`h-3.5 w-3.5`}),` `,e(`activity:officeMap.clients`)]}),(0,Q.jsx)(`span`,{className:`font-mono`,children:_})]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Q.jsx)(Ee,{className:`h-3.5 w-3.5`}),` `,e(`activity:officeMap.agents`)]}),(0,Q.jsxs)(`span`,{className:`font-mono`,children:[g,(0,Q.jsxs)(`span`,{className:`text-muted-foreground`,children:[` / `,h]})]})]}),m.model&&(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Q.jsx)(yt,{className:`h-3.5 w-3.5`}),` `,e(`activity:officeMap.model`)]}),(0,Q.jsx)(`span`,{className:`font-mono truncate max-w-[140px]`,title:m.model,children:m.model.split(`/`).pop()})]}),m.mode&&(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Q.jsx)(Tt,{className:`h-3.5 w-3.5`}),` `,e(`activity:officeMap.mode`)]}),(0,Q.jsx)(`span`,{className:`font-mono uppercase text-xs`,children:m.mode})]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Q.jsx)(_t,{className:`h-3.5 w-3.5`}),` `,e(`activity:officeMap.toolCalls`)]}),(0,Q.jsx)(`span`,{className:`font-mono`,children:(e=>e?.toLocaleString()??`0`)(m.toolCalls)})]})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-1`,children:e(`activity:officeMap.displayHeading`)}),(0,Q.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,Q.jsx)(ld,{label:e(`activity:officeMap.statsHud`),checked:t,onChange:s}),(0,Q.jsx)(ld,{label:e(`activity:officeMap.legends`),checked:n,onChange:c}),(0,Q.jsx)(ld,{label:e(`activity:officeMap.minimap`),checked:r,onChange:l}),(0,Q.jsx)(ld,{label:e(`activity:officeMap.zoomControls`),checked:i,onChange:u}),(0,Q.jsx)(ld,{label:e(`activity:officeMap.animateWires`),checked:a,onChange:d})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-1.5 px-2`,children:e(`activity:officeMap.backgroundHeading`)}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1 px-2`,children:ud.map(t=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>f(t.value),className:G(`px-2 py-1 text-xs rounded transition-colors`,o===t.value?`bg-primary text-primary-foreground`:`bg-muted text-muted-foreground hover:bg-accent`),children:e(`activity:officeMap.${t.labelKey}`)},t.value))})]})]})}function fd({className:e,leaderName:t}){let n=xr($t(br)),r=xr(e=>e.eventTimeline),{t:i}=V(),a=n.total>0,o=r.slice(0,3),s=(0,Z.useCallback)(()=>{let e=U.getState();e.setInspectorTab(`fleet`),e.setInspectorOpen(!0)},[]);return(0,Q.jsxs)(`div`,{className:G(`flex flex-col gap-0.5 border-b border-border/70 bg-muted/20 px-3 py-1.5 text-[10px]`,e),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0 flex-wrap`,children:[(0,Q.jsx)(pd,{label:String(n.running),ledClass:`bg-success`,pulse:n.running>0}),(0,Q.jsx)(`span`,{className:`tabular-nums text-success count-transition`,children:i(`activity:agents.runningCount`,{count:n.running})}),n.completed>0&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,Q.jsxs)(`span`,{className:`tabular-nums text-muted-foreground count-transition`,children:[n.completed,` done`]})]}),n.failed>0&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,Q.jsx)(pd,{label:String(n.failed),ledClass:`bg-destructive`,pulse:!1})]}),(0,Q.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,Q.jsx)(`span`,{className:`tabular-nums text-muted-foreground count-transition`,children:i(`activity:agents.totalCount`,{count:n.total})}),(0,Q.jsx)(`span`,{className:`flex-1 min-w-0`}),n.totalCost>0&&(0,Q.jsx)(`span`,{className:`tabular-nums font-mono text-muted-foreground ml-auto shrink-0 count-transition`,children:Ns(n.totalCost)}),t&&(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 rounded border border-warning/30 bg-warning/10 px-1 py-0.5 text-[9px] font-medium text-warning shrink-0`,children:[(0,Q.jsx)(pt,{className:`h-2.5 w-2.5`}),t]})]}),a&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0 flex-wrap`,children:[(0,Q.jsx)(sc,{current:n.concurrency,max:n.concurrencyMax,showLabel:!0}),n.tokensIn+n.tokensOut>0&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,Q.jsxs)(`span`,{className:`tabular-nums font-mono text-muted-foreground count-transition`,children:[`↓`,Fr(n.tokensIn),` `,`↑`,Fr(n.tokensOut)]})]})]}),o.length>0&&(0,Q.jsx)(`div`,{className:`flex items-center gap-1 min-w-0 overflow-x-auto no-scrollbar`,children:o.map(e=>(0,Q.jsxs)(`span`,{onClick:s,className:`inline-flex items-center gap-1 shrink-0 rounded border border-border/50 bg-background/40 px-1.5 py-0.5 text-[9px] text-muted-foreground cursor-pointer hover:bg-accent/50 hover:text-foreground transition-colors`,title:e.message,"aria-label":`${md[e.kind]??e.kind}: ${e.message}`,children:[(0,Q.jsx)(gd,{kind:e.kind}),md[e.kind]??e.kind]},e.id))}),!a&&(0,Q.jsx)(`div`,{className:`flex items-center gap-2 min-w-0`,children:(0,Q.jsx)(`span`,{className:`text-muted-foreground italic`,children:`Fleet idle`})})]})}function pd({label:e,ledClass:t,pulse:n}){return(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 shrink-0`,children:[(0,Q.jsx)(`span`,{className:G(`led h-1.5 w-1.5`,t,n&&`led-pulse`),"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`tabular-nums font-medium`,children:e})]})}var md={spawned:`spawned`,task_started:`started`,tool_executed:`tool`,iteration_summary:`iter`,budget_warning:`budget`,budget_extended:`extended`,task_completed:`done`,ctx_pct:`ctx`,leader_updated:`leader`},hd={spawned:`bg-primary`,task_started:`bg-info`,tool_executed:`bg-warning`,iteration_summary:`bg-muted-foreground`,budget_warning:`bg-destructive`,budget_extended:`bg-warning`,task_completed:`bg-success`,ctx_pct:`bg-muted-foreground`,leader_updated:`bg-warning`};function gd({kind:e}){return(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:G(`inline-block h-1.5 w-1.5 rounded-full shrink-0`,hd[e]??`bg-muted-foreground`)})}function _d({agent:e,isExpanded:t,onOpenInspector:n}){let{t:r}=V(),[i,a]=(0,Z.useState)(!1),o=(0,Z.useRef)(null),s=(0,Z.useRef)(null),[l,u]=(0,Z.useState)(0);(0,Z.useEffect)(()=>{s.current&&u(t?s.current.scrollHeight:0)},[t,e]),(0,Z.useEffect)(()=>{t&&o.current&&e.status===`running`&&(o.current.scrollTop=o.current.scrollHeight)},[t,e.partialText,e.status]);let d=e.toolLog??[],f=i?d:d.slice(0,10),p=[{label:r(`activity:agents.configProvider`),value:e.provider},{label:r(`activity:agents.configModel`),value:e.model},{label:r(`activity:agents.configDescription`),value:e.description},{label:r(`activity:agents.configTaskId`),value:e.taskId}].filter(e=>e.value!=null&&e.value!==``),m=e.partialText&&e.partialText.length>0&&e.status===`running`,h=xr(t=>t.agentTranscripts.get(e.id)??Tr),[g,_]=(0,Z.useState)(!1),v=g?h:h.slice(-20);return(0,Q.jsx)(`div`,{className:`overflow-hidden transition-all duration-[250ms] ease-out`,style:{maxHeight:t?l:0,opacity:+!!t},children:(0,Q.jsxs)(`div`,{ref:s,className:`space-y-2 px-3 pb-3 pt-0.5`,children:[d.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,Q.jsxs)(`span`,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wider`,children:[r(`activity:agents.toolLog`),` (`,d.length,`)`]}),(0,Q.jsxs)(`div`,{className:`space-y-0.5`,children:[f.map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] font-mono min-w-0`,children:[e.ok?(0,Q.jsx)(Wn,{className:`h-2.5 w-2.5 shrink-0 text-success`}):(0,Q.jsx)(vn,{className:`h-2.5 w-2.5 shrink-0 text-destructive`}),(0,Q.jsx)(`span`,{className:G(`truncate`,e.ok?``:`text-destructive`),children:e.name}),(0,Q.jsx)(`span`,{className:`tabular-nums text-muted-foreground ml-auto shrink-0`,children:mr(e.durationMs)})]},e.at)),d.length>10&&(0,Q.jsx)(`button`,{type:`button`,onClick:()=>a(!i),"aria-label":r(i?`activity:agents.showFewer`:`activity:agents.showAll`),className:`flex items-center gap-0.5 text-[10px] text-primary hover:text-primary/80 transition-colors`,children:i?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Et,{className:`h-2.5 w-2.5`}),` `,r(`activity:agents.showFewer`)]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(b,{className:`h-2.5 w-2.5`}),` `,r(`activity:agents.showAll`),` (`,d.length,`)`]})})]})]}),m&&(0,Q.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wider`,children:r(`activity:agents.streaming`)}),(0,Q.jsx)(`div`,{ref:o,className:`max-h-20 overflow-y-auto rounded bg-muted/40 p-1.5 text-[10px] font-mono text-muted-foreground leading-snug whitespace-pre-wrap break-all`,children:e.partialText})]}),(e.status===`failed`||e.status===`timeout`)&&(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(`span`,{className:G(`text-[10px] font-semibold uppercase tracking-wider`,e.status===`failed`?`text-destructive`:`text-warning`),children:e.status===`failed`?r(`activity:agents.failure`):r(`activity:agents.timeout`)}),(0,Q.jsx)(`span`,{className:`flex-1`}),(0,Q.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation()},className:`flex items-center gap-0.5 rounded border border-border/50 px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-foreground hover:bg-accent transition-colors`,title:r(`activity:agents.reRunTitle`),children:[(0,Q.jsx)(c,{className:`h-2.5 w-2.5`}),r(`activity:agents.reRun`)]})]}),(e.failureReason||e.error)&&(0,Q.jsxs)(`div`,{className:G(`rounded p-1.5 text-[10px] leading-snug`,e.status===`failed`?`bg-destructive/5 text-destructive`:`bg-warning/5 text-warning`),children:[e.failureReason&&(0,Q.jsx)(`div`,{className:`font-medium`,children:e.failureReason}),e.error&&(0,Q.jsxs)(`div`,{className:G(`mt-0.5`,e.status===`failed`?`text-destructive/80`:`text-warning/80`),children:[e.error.kind&&(0,Q.jsxs)(`span`,{className:`font-mono`,children:[`[`,e.error.kind,`] `]}),e.error.message]})]}),d.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:r(`activity:agents.lastToolCalls`,{count:Math.min(3,d.length)})}),(0,Q.jsx)(`div`,{className:`space-y-0.5`,children:d.slice(0,3).map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] font-mono min-w-0`,children:[e.ok?(0,Q.jsx)(Wn,{className:`h-2.5 w-2.5 shrink-0 text-success`}):(0,Q.jsx)(vn,{className:`h-2.5 w-2.5 shrink-0 text-destructive`}),(0,Q.jsx)(`span`,{className:G(`truncate`,e.ok?``:`text-destructive`),children:e.name}),(0,Q.jsx)(`span`,{className:`tabular-nums text-muted-foreground ml-auto shrink-0`,children:mr(e.durationMs)})]},e.at))})]})]}),p.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wider`,children:r(`activity:agents.config`)}),(0,Q.jsx)(`div`,{className:`rounded bg-muted/30 p-1.5 space-y-0.5`,children:p.map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] min-w-0`,children:[(0,Q.jsxs)(`span`,{className:`text-muted-foreground shrink-0`,children:[e.label,`:`]}),(0,Q.jsx)(`span`,{className:`font-mono truncate text-foreground/90`,children:e.value})]},e.label))})]}),h.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsxs)(`span`,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wider`,children:[r(`activity:agents.transcript`),` (`,h.length,`)`]}),h.length>20&&(0,Q.jsx)(`button`,{type:`button`,onClick:()=>_(!g),className:`ml-auto flex items-center gap-0.5 text-[10px] text-primary hover:text-primary/80 transition-colors`,children:g?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Et,{className:`h-2.5 w-2.5`}),` `,r(`activity:agents.showFewer`)]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(b,{className:`h-2.5 w-2.5`}),` `,r(`activity:agents.showAll`)]})})]}),(0,Q.jsx)(Cc,{entries:v,agentName:e.name,compact:!0,maxHeightClassName:`max-h-32`,showHeader:!1})]}),n&&(0,Q.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),n()},className:`flex items-center gap-1 text-[10px] text-primary hover:text-primary/80 transition-colors`,children:[(0,Q.jsx)(tt,{className:`h-2.5 w-2.5`}),r(`activity:agents.openInspector`)]})]})})}var vd={running:{led:`bg-success`,pulse:!0},completed:{led:`bg-success`,pulse:!1},failed:{led:`bg-destructive`,pulse:!1},timeout:{led:`bg-warning`,pulse:!1},stopped:{led:`bg-muted-foreground`,pulse:!1}};function yd({agent:e,isLeader:t,isExpanded:n,isFocused:r,onToggle:i,onOpenInspector:a,now:o}){let{t:s}=V(),[c,l]=(0,Z.useState)(Date.now()),u=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{if(o!==void 0||e.status!==`running`){u.current&&clearInterval(u.current),u.current=null;return}return u.current=setInterval(()=>l(Date.now()),1e4),()=>{u.current&&clearInterval(u.current)}},[o,e.status]);let d=o??c,f=(0,Z.useMemo)(()=>vr(e,d),[e,d]),p=vd[e.status],m=e.status===`running`,h=e.currentTool||e.lastTool;return(0,Q.jsxs)(`div`,{className:G(`animate-message`,n&&`rounded-lg ring-1 ring-primary/20`),children:[(0,Q.jsxs)(`button`,{type:`button`,id:`agent-card-${e.id}`,"data-agent-card":!0,role:`option`,"aria-selected":n,"aria-expanded":n,onClick:i,className:G(`w-full text-left rounded-lg border px-3 py-2.5 transition-colors space-y-2`,!n&&`rounded-b-lg`,n&&`rounded-b-none border-b-0`,m&&`border-primary/40 bg-primary/[0.03]`,!m&&e.status===`completed`&&`border-success/30 bg-success/[0.02]`,!m&&e.status===`failed`&&`border-destructive/30 bg-destructive/[0.02]`,!m&&e.status===`timeout`&&`border-warning/30 bg-warning/[0.02]`,!m&&e.status===`stopped`&&`border-border/60 bg-card/40`,`hover:border-primary/40 hover:bg-primary/[0.04]`,t&&`ring-1 ring-warning/30`,r&&`ring-2 ring-primary`),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,Q.jsx)(`span`,{className:G(`led shrink-0`,p.led,p.pulse&&`led-pulse`),"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`truncate text-[11px] font-semibold`,title:e.name,children:e.name}),t&&(0,Q.jsx)(pt,{className:`h-3 w-3 shrink-0 text-warning`,"aria-label":s(`activity:fleet.leader`)}),(0,Q.jsx)(`span`,{className:`flex-1 min-w-0`}),(0,Q.jsx)(`span`,{className:`tabular-nums font-mono text-[10px] text-muted-foreground shrink-0`,children:f.cost}),(0,Q.jsx)(b,{className:G(`h-3 w-3 shrink-0 text-muted-foreground/50 transition-transform duration-200`,n&&`rotate-180`)})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[e.model?(0,Q.jsx)(`span`,{className:`truncate rounded bg-muted/60 px-1.5 py-0.5 text-[10px] font-mono text-muted-foreground max-w-[10rem]`,children:e.model}):(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground italic`,children:s(`activity:agents.pending`)}),(0,Q.jsxs)(`span`,{className:`tabular-nums text-[10px] text-muted-foreground`,children:[f.iterationCount,s(`activity:agents.itSuffix`),` · `,f.toolCount,s(`activity:agents.tcSuffix`)]}),(0,Q.jsx)(`span`,{className:`ml-auto tabular-nums text-[10px] text-muted-foreground/70 shrink-0`,children:f.elapsed})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,Q.jsx)(oc,{bins:e.sparklineBins,className:`text-[9px] font-mono min-w-0`}),(0,Q.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,Q.jsx)(mo,{pct:f.ctxClamped,tokens:e.ctxTokens,maxTokens:e.maxContext,showTokens:!0})}),e.budgetWarning&&(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 rounded bg-warning/10 px-1.5 py-0.5 text-[10px] text-warning shrink-0`,title:s(`activity:fleet.hittingLimitTitle`,{kind:e.budgetWarning.kind,used:e.budgetWarning.used,limit:e.budgetWarning.limit}),children:[(0,Q.jsx)(Tt,{className:`h-2.5 w-2.5`}),e.budgetWarning.kind]})]}),h&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground min-w-0`,children:[(0,Q.jsx)(Mn,{className:G(`h-2.5 w-2.5 shrink-0`,m&&`animate-pulse text-primary`)}),(0,Q.jsx)(`span`,{className:`truncate font-mono`,children:e.currentTool??e.lastTool})]})]}),(0,Q.jsx)(_d,{agent:e,isExpanded:!!n,onOpenInspector:a})]})}var bd=[{value:`all`,label:`All`},{value:`running`,label:`Running`},{value:`completed`,label:`Done`},{value:`failed`,label:`Failed`}];function xd(){let e=xr($t(Lr)),t=xr(e=>e.leaderId),n=xr(Pr),r=xr(e=>e.clearFinishedAgents),{t:i}=V(),[a,o]=(0,Z.useState)(`all`),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(-1),d=(0,Z.useRef)(null),[f,p]=(0,Z.useState)(!0),m=(0,Z.useMemo)(()=>a===`all`?e:e.filter(e=>a===`running`?e.status===`running`:a===`completed`?e.status===`completed`:a!==`failed`||e.status===`failed`||e.status===`timeout`),[e,a]),h=e.some(e=>e.status!==`running`),g=(0,Z.useCallback)(e=>{let t=U.getState();e?(t.setInspectorFocusedAgentId(e),t.setInspectorTab(`agents`)):t.setInspectorTab(`fleet`),t.setInspectorOpen(!0)},[]),_=(0,Z.useCallback)(e=>{c(t=>t===e?null:e)},[]),v=(0,Z.useCallback)(e=>{let t=m;if(t.length!==0)switch(e.key){case`ArrowDown`:e.preventDefault(),u(e=>{let n=Math.min(e+1,t.length-1);return p(!1),n});break;case`ArrowUp`:e.preventDefault(),u(e=>{let t=Math.max(e-1,0);return p(!1),t});break;case`Enter`:case` `:e.preventDefault(),l>=0&&l<t.length&&_(t[l].id);break;case`Escape`:e.preventDefault(),s&&c(null);break}},[m,l,_,s]);(0,Z.useEffect)(()=>{l>=0&&d.current&&d.current.querySelectorAll(`[data-agent-card]`)[l]?.focus()},[l]);let y=e.length>0&&e.every(e=>e.status!==`running`);return e.length===0?(0,Q.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center bg-[hsl(var(--surface-2)/0.35)] p-3`,children:(0,Q.jsxs)(`div`,{className:`ws-surface flex max-w-[15rem] flex-col items-center gap-3 rounded-xl p-5 text-center text-muted-foreground`,children:[(0,Q.jsx)(`span`,{className:`flex h-11 w-11 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,Q.jsx)(Ee,{className:`h-5 w-5`})}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-sm font-semibold text-foreground`,children:i(`activity:agents.empty`)}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs`,children:i(`activity:agents.emptyHint`)})]})]})}):m.length===0&&a!==`all`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(fd,{leaderName:n}),(0,Q.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center bg-[hsl(var(--surface-2)/0.35)] p-3`,children:(0,Q.jsxs)(`div`,{className:`ws-surface flex max-w-[15rem] flex-col items-center gap-3 rounded-xl p-5 text-center text-muted-foreground`,children:[(0,Q.jsx)(`span`,{className:`flex h-11 w-11 items-center justify-center rounded-lg bg-muted/60 text-muted-foreground`,children:(0,Q.jsx)(I,{className:`h-5 w-5`})}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-sm font-semibold text-foreground`,children:i(`activity:agents.emptyFilteredTitle`)}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs`,children:i(`activity:agents.emptyFilteredHint`)})]}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>o(`all`),className:`h-7 rounded-md border border-border px-3 text-[11px] font-medium text-foreground hover:bg-accent transition-colors`,children:i(`activity:agents.emptyFilteredClear`)})]})})]}):y&&a===`all`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(fd,{leaderName:n}),(0,Q.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center bg-[hsl(var(--surface-2)/0.35)] p-3`,children:(0,Q.jsxs)(`div`,{className:`ws-surface flex max-w-[15rem] flex-col items-center gap-3 rounded-xl p-5 text-center text-muted-foreground`,children:[(0,Q.jsx)(`span`,{className:`flex h-11 w-11 items-center justify-center rounded-lg bg-success/10 text-success`,children:(0,Q.jsx)(Gt,{className:`h-5 w-5`})}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-sm font-semibold text-foreground`,children:i(`activity:agents.emptyFinishedTitle`)}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs`,children:i(`activity:agents.emptyFinishedHint`)}),(0,Q.jsx)(`p`,{className:`mt-2 text-[11px] tabular-nums text-muted-foreground`,children:i(`activity:agents.emptyFinishedStats`,{completed:e.filter(e=>e.status===`completed`).length,failed:e.filter(e=>e.status===`failed`||e.status===`timeout`).length})})]})]})}),(0,Q.jsx)(`div`,{className:`shrink-0 border-t border-border/70 bg-card/75 px-3 py-2`,children:(0,Q.jsxs)(`button`,{type:`button`,onClick:r,className:`w-full flex items-center justify-center gap-1.5 h-7 rounded-md border border-border text-[11px] text-muted-foreground hover:text-foreground hover:bg-accent transition-colors`,children:[(0,Q.jsx)(C,{className:`h-3 w-3`}),i(`activity:agents.clearFinished`)]})})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(fd,{leaderName:n}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-border/70 px-2 py-1 shrink-0`,children:[bd.map(e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>o(e.value),"aria-pressed":a===e.value,className:G(`rounded px-1.5 py-0.5 text-[10px] font-medium transition-colors`,a===e.value?`bg-primary/10 text-primary`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),children:i(`activity:agents.filter${e.value.charAt(0).toUpperCase()+e.value.slice(1)}`)},e.value)),(0,Q.jsx)(`span`,{className:`flex-1`}),h&&(0,Q.jsxs)(`button`,{type:`button`,onClick:r,"aria-label":i(`activity:agents.clearFinishedTitle`),title:i(`activity:agents.clearFinishedTitle`),className:`inline-flex items-center gap-0.5 rounded px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors`,children:[(0,Q.jsx)(C,{className:`h-2.5 w-2.5`}),i(`activity:agents.clearFinished`)]})]}),(0,Q.jsxs)(`div`,{ref:d,role:`listbox`,"aria-label":`Agent roster`,"aria-activedescendant":l>=0?`agent-card-${m[l]?.id}`:void 0,tabIndex:0,onKeyDown:v,className:`min-h-0 min-w-0 flex-1 space-y-1.5 overflow-y-auto overscroll-contain bg-[hsl(var(--surface-2)/0.35)] p-2`,children:[f&&l===-1&&(0,Q.jsx)(`div`,{className:`text-[9px] text-muted-foreground/60 text-center py-1 italic select-none`,children:i(`activity:agents.rosterHint`)}),m.map(e=>(0,Q.jsx)(yd,{agent:e,isLeader:e.id===t,isExpanded:s===e.id,isFocused:l>=0&&m[l]?.id===e.id,onToggle:()=>_(e.id),onOpenInspector:()=>g(e.id)},e.id))]}),(0,Q.jsx)(`div`,{className:`shrink-0 border-t border-border/70 bg-card/75 px-3 py-2`,children:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>g(),className:`w-full flex items-center justify-center gap-1.5 h-7 rounded-md border border-border text-[11px] text-muted-foreground hover:text-foreground hover:bg-accent transition-colors`,children:[(0,Q.jsx)(ft,{className:`h-3 w-3`}),i(`activity:agents.openFull`)]})})]})}var Sd={chat:`Run state, model, context and quick controls`,agents:`Live fleet roster and agent monitoring`,history:`Resume or inspect previous sessions`,files:`Browse and open project files`,changes:`Review source control changes`,mailbox:`Cross-surface coordination messages`,skills:`Installed skills and capability docs`,design:`Design studio assets and previews`,worktrees:`Parallel branches and worktree lanes`,officemap:`Fleet map settings and filters`};function Cd({desktopShell:e=!1}){let t=U(e=>e.activeActivity),n=U(e=>e.setSidebarOpen),r=U(e=>e.sidebarWidth),i=U(e=>e.setSidebarWidth),a=q(e=>e.wsConnected),{client:o}=dr(),{t:s}=V(),c=e?`min(${Math.min(r,280)}px, calc(100vw - 2.5rem))`:`min(${r}px, calc(100vw - 3rem))`;return(0,Z.useEffect)(()=>{if(t!==`files`||!a)return;gr.getState().setTreeLoading(!0);let e=K.getState().cwd;o?.send({type:`files.tree`,payload:e?{path:e}:{}})},[t,a,o]),(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:G(`fixed inset-y-0 right-0 z-30 bg-black/35 backdrop-blur-[2px] md:hidden`,e?`left-10`:`left-12`),onClick:()=>n(!1),"aria-hidden":`true`}),(0,Q.jsxs)(`aside`,{style:{width:c},role:`dialog`,"aria-modal":`true`,"aria-label":s(`activity:sidebar.label`),className:G(`fixed inset-y-0 z-40 flex min-h-0 min-w-0 shrink-0 flex-col overflow-hidden border-r border-border/70 bg-card/95 shadow-2xl backdrop-blur-xl animate-slide-in md:relative md:inset-auto md:z-auto md:shadow-none`,e?`left-10`:`left-12`),children:[(0,Q.jsx)(`hr`,{"aria-orientation":`vertical`,"aria-valuemin":240,"aria-valuemax":560,"aria-valuenow":r,tabIndex:0,onMouseDown:e=>{e.preventDefault();let t=e.clientX,n=r,a=e=>i(n+(e.clientX-t)),o=()=>{window.removeEventListener(`mousemove`,a),window.removeEventListener(`mouseup`,o),document.body.style.cursor=``,document.body.style.userSelect=``};window.addEventListener(`mousemove`,a),window.addEventListener(`mouseup`,o),document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`},onDoubleClick:()=>i(304),className:`group/handle absolute top-0 right-0 z-10 m-0 h-full w-2 cursor-col-resize border-0 border-r border-border/70 hover:border-primary/70`,title:s(`activity:sidePanel.dragHint`)}),(0,Q.jsxs)(`div`,{className:G(`flex items-center justify-between border-b shrink-0`,`bg-muted/25`,e?`px-2.5 py-2`:`px-3 py-3`),children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-semibold text-foreground`,children:s(`activity:nav.${t}`)}),(0,Q.jsx)(`div`,{className:`mt-0.5 truncate text-[11px] text-muted-foreground`,children:Sd[t]})]}),(0,Q.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-7 w-7 shrink-0`,onClick:()=>n(!1),title:s(`activity:sidePanel.collapse`),children:(0,Q.jsx)(Xn,{className:`h-3.5 w-3.5`})})]}),(0,Q.jsxs)(`div`,{className:`flex-1 min-h-0 min-w-0 flex flex-col overflow-hidden`,children:[t===`chat`&&(0,Q.jsx)(Ju,{}),t===`agents`&&(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-y-auto overscroll-contain`,children:(0,Q.jsx)(xd,{})}),t===`history`&&(0,Q.jsx)(Bu,{}),t===`files`&&(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-y-auto overscroll-contain`,children:(0,Q.jsx)(vu,{})}),t===`changes`&&(0,Q.jsx)(Tu,{}),t===`mailbox`&&(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-y-auto overscroll-contain p-3`,children:(0,Q.jsx)(xu,{})}),t===`skills`&&(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Q.jsx)($u,{className:`h-full`})}),t===`design`&&(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Q.jsx)(rd,{className:`h-full`})}),t===`worktrees`&&(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Q.jsx)(od,{})}),t===`officemap`&&(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Q.jsx)(dd,{})})]})]})]})}function wd(){let e=Ar(e=>e.info),{client:t}=dr(),n=(0,Z.useRef)(null),r=(0,Z.useCallback)(()=>{t?.getGitInfo?.()},[t]);return(0,Z.useEffect)(()=>(r(),n.current=setInterval(r,3e4),()=>{n.current&&clearInterval(n.current)}),[r]),e}function Td({sessionId:e,className:t}){let{t:n}=V(),[r,a]=(0,Z.useState)([]),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(0),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(``),[b,x]=(0,Z.useState)(``),[S,C]=(0,Z.useState)(!1),[w,T]=(0,Z.useState)(``),E=pr(q(e=>e.wsUrl)),D=i(e=>e.messages).filter(e=>e.role===`tool`&&e.toolResult===void 0&&!!e.toolUseId);(0,Z.useEffect)(()=>{let t=[];return t.push(E.on(`collab.state`,t=>{let n=t.payload;n.sessionId===e&&a(n.participants??[])})),t.push(E.on(`collab.participant.joined`,t=>{let n=t.payload;n.sessionId===e&&a(e=>e.some(e=>e.participantId===n.participantId)?e:[...e,{participantId:n.participantId,role:n.role,joinedAt:n.joinedAt}])})),t.push(E.on(`collab.participant.left`,t=>{let n=t.payload;if(n.sessionId!==e)return;let r=n.participantId;a(e=>e.filter(e=>e.participantId!==r))})),t.push(E.on(`error`,e=>{let t=e.payload;t.phase===`collab`&&(d(t.message),s(!1))})),t.push(E.on(`collab.annotation.added`,t=>{let n=t.payload;n.sessionId===e&&(n.annotation?.resolved||p(e=>e+1))})),t.push(E.on(`collab.annotation.resolved`,t=>{t.payload.sessionId===e&&p(e=>Math.max(0,e-1))})),t.push(E.on(`collab.pause.granted`,t=>{t.payload.sessionId===e&&h(!0)})),t.push(E.on(`collab.pause.released`,t=>{t.payload.sessionId===e&&h(!1)})),()=>{for(let e of t)e()}},[E,e]);let O=(t=`observer`)=>{d(null),E.send({type:`collab.join`,payload:{sessionId:e,role:t}}),s(!0),l(t)},k=()=>{E.send({type:`collab.request_pause`,payload:{sessionId:e}})},A=()=>{E.send({type:`collab.resume`,payload:{sessionId:e}})},j=()=>{E.send({type:`collab.leave`,payload:{sessionId:e}}),s(!1),a([])},M=t=>{E.send({type:`collab.grant_control`,payload:{sessionId:e,toParticipant:t}})},N=()=>{v&&(E.send({type:`collab.inject_tool`,payload:{sessionId:e,toolUseId:v,content:b,isError:S,reason:w.trim()||H.t(`activity:collab.controllerInjection`)}}),_(!1),y(``),x(``),C(!1),T(``))},P=o&&c===`controller`;return r.length===0&&!u?(0,Q.jsxs)(`div`,{className:G(`flex items-center gap-2 px-3 py-2 rounded-md border border-dashed border-border bg-card/40`,t),children:[(0,Q.jsx)(xn,{className:`w-4 h-4 text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`activity:collab.noObservers`)}),(0,Q.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>O(`observer`),className:`inline-flex items-center gap-1 text-xs px-2 py-1 rounded bg-primary text-primary-foreground hover:bg-primary/90 transition-colors`,title:n(`activity:collab.observerTitle`),children:[(0,Q.jsx)(He,{className:`w-3 h-3`}),n(`activity:collab.observerRole`)]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>O(`annotator`),className:`inline-flex items-center gap-1 text-xs px-2 py-1 rounded border border-warning/40 bg-warning/10 text-warning hover:bg-warning/20 transition-colors`,title:n(`activity:collab.annotatorTitle`),children:[(0,Q.jsx)(nn,{className:`w-3 h-3`}),n(`activity:collab.annotatorRole`)]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>O(`controller`),className:`inline-flex items-center gap-1 text-xs px-2 py-1 rounded border border-destructive/40 bg-destructive/10 text-destructive hover:bg-destructive/20 transition-colors`,title:n(`activity:collab.controllerTitle`),children:[(0,Q.jsx)(mn,{className:`w-3 h-3`}),n(`activity:collab.controllerRole`)]})]})]}):u?(0,Q.jsxs)(`div`,{className:G(`flex items-center gap-2 px-3 py-2 rounded-md border border-destructive/50 bg-destructive/10`,t),role:`alert`,children:[(0,Q.jsx)(`span`,{className:`text-xs text-destructive`,children:n(`activity:collab.errorPrefix`,{error:u})}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{d(null),s(!1)},className:`ml-auto text-xs underline text-destructive`,children:n(`activity:collab.dismiss`)})]}):(0,Q.jsxs)(`div`,{className:G(`relative flex items-center gap-2 px-3 py-2 rounded-md border border-success/40 bg-success/5`,t),children:[(0,Q.jsxs)(`span`,{className:`relative flex h-2 w-2`,role:`img`,"aria-label":n(`common:status.live`),children:[(0,Q.jsx)(`span`,{className:`absolute inline-flex h-full w-full rounded-full bg-success opacity-75 animate-ping`}),(0,Q.jsx)(`span`,{className:`relative inline-flex rounded-full h-2 w-2 bg-success`})]}),(0,Q.jsx)(xn,{className:`w-4 h-4 text-success`}),(0,Q.jsx)(`span`,{className:`text-xs font-medium text-success`,children:n(`activity:collab.observers`,{count:r.length})}),f>0&&(0,Q.jsxs)(`span`,{title:n(`activity:collab.annotationsTitle`,{count:f}),className:`ml-2 inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-warning/15 text-warning border border-warning/30`,children:[(0,Q.jsx)(nn,{className:`w-3 h-3`}),n(`activity:collab.notes`,{count:f})]}),m&&(0,Q.jsxs)(`span`,{title:n(`activity:collab.pausedTitle`),className:`ml-2 inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-destructive/15 text-destructive border border-destructive/40`,children:[(0,Q.jsx)(mn,{className:`w-3 h-3`}),n(`activity:collab.paused`)]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 ml-2`,children:[r.slice(0,3).map(e=>(0,Q.jsxs)(`span`,{title:n(`activity:collab.joinedTitle`,{time:new Date(e.joinedAt).toLocaleTimeString()}),className:`inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-success/10 text-success`,children:[(0,Q.jsx)(it,{className:`w-3 h-3`}),e.role,P&&e.role!==`controller`&&(0,Q.jsx)(`button`,{type:`button`,onClick:()=>M(e.participantId),title:n(`activity:collab.grantTitle`),className:`ml-0.5 inline-flex items-center rounded hover:bg-success/20 transition-colors`,children:(0,Q.jsx)(Yt,{className:`w-3 h-3`})})]},e.participantId)),r.length>3&&(0,Q.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`+`,r.length-3]})]}),P&&(0,Q.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>_(e=>!e),className:`inline-flex items-center gap-1 text-xs px-2 py-1 rounded border border-info/40 bg-info/10 text-info hover:bg-info/20 transition-colors`,title:n(`activity:collab.injectTitle`),children:[(0,Q.jsx)(Me,{className:`w-3 h-3`}),n(`activity:collab.inject`)]}),m?(0,Q.jsxs)(`button`,{type:`button`,onClick:A,className:`inline-flex items-center gap-1 text-xs px-2 py-1 rounded border border-destructive/40 bg-destructive/10 text-destructive hover:bg-destructive/20 transition-colors`,title:n(`activity:collab.resumeTitle`),children:[(0,Q.jsx)(dn,{className:`w-3 h-3`}),n(`activity:collab.resume`)]}):(0,Q.jsxs)(`button`,{type:`button`,onClick:k,className:`inline-flex items-center gap-1 text-xs px-2 py-1 rounded border border-warning/40 bg-warning/10 text-warning hover:bg-warning/20 transition-colors`,title:n(`activity:collab.pauseTitle`),children:[(0,Q.jsx)(mn,{className:`w-3 h-3`}),n(`activity:collab.pauseAgent`)]})]}),o&&c!==`controller`&&(0,Q.jsxs)(`button`,{type:`button`,onClick:j,className:`ml-auto inline-flex items-center gap-1 text-xs px-2 py-1 rounded border border-border hover:bg-muted transition-colors`,title:n(`activity:collab.leaveTitle`),children:[(0,Q.jsx)(ye,{className:`w-3 h-3`}),n(`activity:collab.leave`)]}),P&&g&&(0,Q.jsxs)(`div`,{className:`absolute top-full left-0 right-0 mt-1 z-50 flex flex-col gap-2 p-3 rounded-md border border-info/40 bg-card shadow-lg text-xs`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Me,{className:`w-3.5 h-3.5 text-info`}),(0,Q.jsx)(`span`,{className:`font-medium`,children:n(`activity:collab.injectToolResult`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>_(!1),className:`ml-auto text-muted-foreground hover:text-foreground`,children:n(`activity:collab.close`)})]}),(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:n(`activity:collab.targetTool`)}),(0,Q.jsx)(`input`,{list:`collab-inject-tools`,value:v,onChange:e=>y(e.target.value),placeholder:n(`activity:collab.targetPlaceholder`),className:`px-2 py-1 rounded border border-border bg-background font-mono`}),(0,Q.jsx)(`datalist`,{id:`collab-inject-tools`,children:D.map(e=>{let t=e.toolInput===void 0?``:` — ${JSON.stringify(e.toolInput).slice(0,40)}`;return(0,Q.jsxs)(`option`,{value:e.toolUseId,children:[e.toolName??n(`activity:collab.toolFallback`),t]},e.toolUseId)})}),D.length===0&&(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:n(`activity:collab.noPendingTools`)})]}),(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:n(`activity:collab.resultContent`)}),(0,Q.jsx)(`textarea`,{value:b,onChange:e=>x(e.target.value),rows:3,placeholder:n(`activity:collab.resultPlaceholder`),className:`px-2 py-1 rounded border border-border bg-background font-mono`})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsxs)(`label`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:S,onChange:e=>C(e.target.checked)}),(0,Q.jsx)(`span`,{children:n(`activity:collab.markError`)})]}),(0,Q.jsx)(`input`,{type:`text`,value:w,onChange:e=>T(e.target.value),placeholder:n(`activity:collab.reasonPlaceholder`),className:`flex-1 px-2 py-1 rounded border border-border bg-background`})]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:N,disabled:!v,className:`self-end inline-flex items-center gap-1 text-xs px-3 py-1 rounded bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:[(0,Q.jsx)(Me,{className:`w-3 h-3`}),n(`activity:collab.queueInjection`)]})]})]})}var Ed={running:{led:`text-success`,pulse:!0},completed:{led:`text-success`,pulse:!1},failed:{led:`text-destructive`,pulse:!1},timeout:{led:`text-warning`,pulse:!1},stopped:{led:`text-muted-foreground`,pulse:!1}};function Dd({agent:e,onClose:t}){Ed[e.status];let{t:n}=V(),r=e.status===`running`,i=e.currentTool??e.lastTool,a=Date.now()-e.startedAt,[o,c]=(0,Z.useState)(!1);xr(e=>e.leaderId),e.id;let l=xr(t=>t.agentTranscripts.get(e.id)??Tr),u=Math.min(100,Math.max(0,e.ctxPct)),d=(0,Z.useCallback)(async e=>{try{await navigator.clipboard.writeText(e),c(!0),setTimeout(()=>c(!1),2e3)}catch{}},[]);(0,Z.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let f=u>=85?`bg-destructive/12 text-destructive`:u>=70?`bg-warning/12 text-warning`:`bg-muted text-muted-foreground`;return(0,Q.jsxs)(`div`,{className:`p-3 space-y-3`,children:[e.description&&(0,Q.jsx)(`div`,{className:`text-xs text-muted-foreground leading-relaxed`,children:e.description}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,Q.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 px-3 py-2`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:n(`activity:fleet.providerModel`)}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 mt-0.5`,children:[(0,Q.jsx)(yt,{className:`h-3 w-3 text-muted-foreground`}),(0,Q.jsxs)(`span`,{className:`text-xs font-mono font-medium`,children:[e.provider??`?`,`/`,e.model??`?`]})]})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 px-3 py-2`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:n(`activity:fleet.elapsed`)}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 mt-0.5`,children:[(0,Q.jsx)(Zt,{className:`h-3 w-3 text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`text-xs font-mono tabular`,children:Fs(a)}),r&&(0,Q.jsxs)(`span`,{className:`text-[10px] text-success`,children:[`· `,n(`activity:fleet.running`)]})]})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 px-3 py-2`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:n(`activity:fleet.iterations`)}),(0,Q.jsx)(`span`,{className:`block text-xs font-mono font-medium mt-0.5 tabular`,children:e.iteration})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 px-3 py-2`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:n(`activity:fleet.toolCalls`)}),(0,Q.jsx)(`span`,{className:`block text-xs font-mono font-medium mt-0.5 tabular`,children:e.toolCalls})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 px-3 py-2`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:n(`activity:fleet.cost`)}),(0,Q.jsx)(`span`,{className:`block text-xs font-mono font-medium mt-0.5 tabular`,children:Ns(e.costUsd)})]}),e.extensions>0&&(0,Q.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 px-3 py-2`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:n(`activity:fleet.budgetExtensions`)}),(0,Q.jsxs)(`span`,{className:`block text-xs font-mono font-medium mt-0.5 tabular`,children:[`⚡×`,e.extensions]})]})]}),r&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:n(`activity:fleet.activity`)}),(0,Q.jsx)(oc,{bins:e.sparklineBins,className:`font-mono`})]}),e.budgetWarning&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg bg-warning/10 border border-warning/25 text-xs`,children:[(0,Q.jsx)(Tt,{className:`h-3.5 w-3.5 text-warning shrink-0`}),(0,Q.jsx)(`span`,{className:`text-warning`,children:n(`activity:fleet.budgetWarning`,{kind:e.budgetWarning.kind,used:e.budgetWarning.used,limit:e.budgetWarning.limit})})]}),e.maxContext>0&&(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between text-[10px]`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:n(`activity:fleet.contextWindow`)}),(0,Q.jsxs)(`span`,{className:G(`tabular font-medium`,f.replace(/bg-\S+\s*/g,``)),children:[u,`%`]})]}),(0,Q.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded-full bg-muted`,children:(0,Q.jsx)(`div`,{className:G(`h-full rounded-full transition-all`,u>=85?`bg-destructive`:u>=70?`bg-warning`:`bg-primary`),style:{width:`${Math.max(2,u)}%`}})}),(0,Q.jsx)(`div`,{className:`text-[10px] text-muted-foreground tabular text-right`,children:n(`activity:fleet.tokensUsed`,{used:Ps(e.ctxTokens),max:Ps(e.maxContext)})})]}),i&&(0,Q.jsxs)(`div`,{className:G(`flex items-center gap-2 rounded-lg border px-3 py-2`,r?`border-primary/30 bg-primary/[0.04]`:`border-border bg-muted/30`),children:[(0,Q.jsx)(Mn,{className:G(`h-3.5 w-3.5`,r?`text-primary animate-pulse`:`text-muted-foreground`)}),(0,Q.jsx)(`span`,{className:`text-xs font-mono`,children:i}),(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground ml-auto`,children:e.currentTool?n(`activity:fleet.toolRunning`):n(`activity:fleet.lastTool`)})]}),(0,Q.jsx)(Cc,{entries:l,agentName:e.name,compact:!0,maxHeightClassName:`max-h-80`}),e.error&&(0,Q.jsxs)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/5 p-3`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] font-semibold text-destructive uppercase tracking-wider`,children:n(`activity:fleet.error`)}),(0,Q.jsx)(`p`,{className:`text-xs text-destructive/90 mt-1 leading-relaxed`,children:e.error.message})]}),e.finalText?(0,Q.jsxs)(`div`,{className:`rounded-lg border bg-muted/20 p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wider`,children:n(`activity:fleet.finalOutput`)}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>d(e.finalText),className:`flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] text-muted-foreground hover:text-foreground hover:bg-muted transition-colors`,title:n(`activity:fleet.copyOutput`),children:[o?(0,Q.jsx)(Wn,{className:`h-3 w-3 text-success`}):(0,Q.jsx)(s,{className:`h-3 w-3`}),n(o?`common:action.copied`:`common:action.copy`)]})]}),(0,Q.jsx)(`pre`,{className:`text-xs whitespace-pre-wrap font-mono text-foreground/80 leading-relaxed max-h-64 overflow-y-auto`,children:e.finalText})]}):e.partialText?(0,Q.jsxs)(`div`,{className:`rounded-lg border bg-muted/20 p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wider`,children:n(`activity:fleet.liveOutput`)}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>d(e.partialText),className:`flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] text-muted-foreground hover:text-foreground hover:bg-muted transition-colors`,title:n(`activity:fleet.copyOutput`),children:[o?(0,Q.jsx)(Wn,{className:`h-3 w-3 text-success`}):(0,Q.jsx)(s,{className:`h-3 w-3`}),n(o?`common:action.copied`:`common:action.copy`)]})]}),(0,Q.jsx)(`pre`,{className:`text-xs whitespace-pre-wrap font-mono text-foreground/80 leading-relaxed max-h-48 overflow-y-auto`,children:e.partialText})]}):r?(0,Q.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border p-3 text-center`,children:[(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`activity:fleet.waitingOutput`)}),(0,Q.jsx)(`p`,{className:`text-[10px] text-muted-foreground/75 mt-0.5`,children:n(`activity:fleet.outputHint`)})]}):null,e.toolLog.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wider`,children:n(`activity:fleet.toolLog`,{count:e.toolLog.length})}),(0,Q.jsxs)(`div`,{className:`max-h-40 overflow-y-auto space-y-0.5`,children:[e.toolLog.slice(0,15).map((e,t)=>(0,Q.jsxs)(`div`,{className:G(`flex items-center gap-2 rounded px-2 py-1 text-[10px]`,e.ok?`bg-muted/30`:`bg-destructive/5 border border-destructive/20`),children:[(0,Q.jsx)(`span`,{className:G(`led shrink-0`,e.ok?`text-success`:`text-destructive`)}),(0,Q.jsx)(`span`,{className:`font-mono truncate flex-1`,children:e.name}),(0,Q.jsxs)(`span`,{className:`tabular text-muted-foreground`,children:[e.durationMs,`ms`]}),!e.ok&&(0,Q.jsx)(`span`,{className:`text-destructive font-medium`,children:n(`activity:fleet.fail`)})]},`${e.name}-${e.at}-${t}`)),e.toolLog.length>15&&(0,Q.jsx)(`p`,{className:`text-[9px] text-muted-foreground text-center px-2 py-0.5`,children:n(`activity:fleet.moreTools`,{count:e.toolLog.length-15})})]})]})]})}function Od({a:e,onClick:t}){let n=Ed[e.status],{t:r}=V(),i=e.status===`running`,a=e.currentTool??e.lastTool,o=Math.min(100,Math.max(0,e.ctxPct));return(0,Q.jsxs)(`button`,{type:`button`,onClick:t,className:G(`flex min-w-[12rem] max-w-[15rem] flex-col gap-1 rounded-lg border p-2 transition-colors text-left cursor-pointer`,`hover:border-primary/40 hover:bg-primary/[0.06]`,i?`border-primary/30 bg-primary/[0.04]`:`border-border bg-card opacity-85`),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,Q.jsx)(`span`,{className:G(`led shrink-0`,n.led,n.pulse&&`led-pulse`)}),(0,Q.jsx)(`span`,{className:`truncate text-[11px] font-semibold text-foreground`,title:e.name,children:e.name}),(0,Q.jsxs)(`span`,{className:`tabular ml-auto shrink-0 text-[10px] text-muted-foreground`,children:[e.iteration,`it · `,e.toolCalls,`t`]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[e.model&&(0,Q.jsxs)(`span`,{className:`flex items-center gap-0.5 text-[10px] text-muted-foreground truncate`,title:`${e.provider??``}/${e.model}`,children:[(0,Q.jsx)(yt,{className:`h-2.5 w-2.5 shrink-0`}),(0,Q.jsx)(`span`,{className:`truncate font-mono`,children:e.model})]}),(0,Q.jsx)(`span`,{className:`tabular text-[10px] text-foreground/75 ml-auto`,children:Ns(e.costUsd)})]}),a&&(0,Q.jsxs)(`div`,{className:G(`flex items-center gap-1 text-[10px] truncate`,i?`text-primary`:`text-muted-foreground`),title:e.currentTool?r(`activity:fleet.cardRunning`,{tool:a}):r(`activity:fleet.cardLastTool`,{tool:a}),children:[(0,Q.jsx)(Mn,{className:G(`h-2.5 w-2.5 shrink-0`,i&&`animate-pulse`)}),(0,Q.jsx)(`span`,{className:`truncate font-mono`,children:a})]}),i&&e.maxContext>0&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,title:r(`activity:fleet.contextPercent`,{pct:o}),children:[(0,Q.jsx)(`div`,{className:`h-1 flex-1 overflow-hidden rounded-full bg-muted`,children:(0,Q.jsx)(`div`,{className:G(`h-full rounded-full transition-all`,o>=85?`bg-destructive`:o>=70?`bg-warning`:`bg-primary`),style:{width:`${Math.max(2,o)}%`}})}),(0,Q.jsx)(`span`,{className:`tabular text-[9px] text-muted-foreground`,children:e.maxContext>0?`${o}%`:`—`})]}),e.error&&(0,Q.jsx)(`div`,{className:`truncate rounded bg-destructive/10 px-1 py-0.5 text-[9px] text-destructive`,title:e.error.message,children:e.error.message})]})}function kd({className:e}){let t=xr(e=>e.agents),{t:n}=V(),[r,i]=(0,Z.useState)(!0),[a,o]=(0,Z.useState)(null),s=(0,Z.useMemo)(()=>{let e=Array.from(t.values());return e.sort(Ir),e},[t]),c=a?s.find(e=>e.id===a):null;if(s.length===0)return null;let l=yr(s),u=s.reduce((e,t)=>e+(t.costUsd??0),0),d=r&&s.length>=3;return(0,Q.jsxs)(`div`,{className:G(`flex min-h-0 min-w-0 gap-3`,e),children:[(0,Q.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col rounded-lg border border-border bg-card/50 backdrop-blur-sm overflow-hidden`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>i(e=>!e),className:`flex w-full items-center gap-2 px-3 py-1.5 text-left hover:bg-muted/30 transition-colors shrink-0`,children:[(0,Q.jsx)(Ee,{className:`h-3.5 w-3.5 text-primary`}),(0,Q.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground`,children:`Fleet`}),(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5 ml-auto text-[10px]`,children:[l.running>0&&(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 text-success`,children:[(0,Q.jsx)(`span`,{className:`led led-pulse text-success`}),l.running]}),l.completed>0&&(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:n(`activity:fleet.doneCount`,{count:l.completed})}),l.failed>0&&(0,Q.jsx)(`span`,{className:`text-destructive`,children:n(`activity:fleet.errCount`,{count:l.failed})}),u>0&&(0,Q.jsx)(`span`,{className:`tabular text-foreground/70`,children:Ns(u)})]}),d?(0,Q.jsx)(Kn,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}):(0,Q.jsx)(b,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`})]}),!d&&(0,Q.jsx)(`div`,{children:(0,Q.jsx)(`div`,{className:`flex gap-2 overflow-x-auto px-2 pb-2 min-h-0`,children:s.map(e=>(0,Q.jsx)(Od,{a:e,onClick:()=>o(a===e.id?null:e.id)},e.id))})})]}),c&&(0,Q.jsx)(`div`,{className:`w-96 max-w-full shrink-0 rounded-lg border border-border bg-card shadow-lg overflow-hidden`,children:(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,Q.jsxs)(`div`,{className:`shrink-0 flex items-center justify-between px-3 py-2 border-b bg-muted/20`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-semibold text-foreground truncate`,children:c.name}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>o(null),className:`p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors`,"aria-label":n(`common:action.close`),children:(0,Q.jsx)(vn,{className:`h-3.5 w-3.5`})})]}),(0,Q.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Q.jsx)(Dd,{agent:c,onClose:()=>o(null)})})]})})]})}var Ad={up:(0,Q.jsx)(Jn,{className:`h-3.5 w-3.5 text-success`}),down:(0,Q.jsx)(Ke,{className:`h-3.5 w-3.5 text-destructive`}),stable:(0,Q.jsx)(Ae,{className:`h-3.5 w-3.5 text-warning`})},jd={active:{color:`text-success`,bg:`bg-success/10`,labelKey:`statusActive`},paused:{color:`text-warning`,bg:`bg-warning/10`,labelKey:`statusPaused`},completed:{color:`text-info`,bg:`bg-info/10`,labelKey:`statusDone`},failed:{color:`text-destructive`,bg:`bg-destructive/10`,labelKey:`statusFailed`},abandoned:{color:`text-muted-foreground`,bg:`bg-muted`,labelKey:`statusAbandoned`}};function Md({goal:e,className:t}){let{t:n}=V(),[r,i]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{let e=pr();e?.send?.({type:`goal.get`});let t=setInterval(()=>{e?.send?.({type:`goal.get`})},1e4);return()=>clearInterval(t)},[]),(0,Z.useEffect)(()=>{(!e||e.goalState===`completed`||e.goalState===`failed`||e.goalState===`abandoned`)&&i(!0)},[e]);let a=e?.deliverables??[],o=[...e?.journal??[]].reverse();if(!e||e.goalState===`completed`||e.goalState===`failed`||e.goalState===`abandoned`)return null;let s=jd[e.goalState],c=e.deliverables?.filter(e=>e.status===`done`).length??0,l=e.deliverables?.length??0,u=e.progressTrend?Ad[e.progressTrend]:null;return(0,Q.jsxs)(`div`,{className:G(`rounded-lg border border-border bg-card/60 backdrop-blur-sm`,t),children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>i(e=>!e),className:`flex w-full items-center gap-2 px-3 py-2.5 text-left hover:bg-accent/40 rounded-t-lg transition-colors`,children:[(0,Q.jsx)(M,{className:`h-4 w-4 text-primary`}),(0,Q.jsx)(`span`,{className:`text-xs font-semibold text-foreground flex-1 min-w-0 truncate`,children:n(`activity:goal.heading`)}),(0,Q.jsx)(`span`,{className:G(`inline-flex items-center px-1.5 py-0.5 rounded-full text-[10px] font-medium shrink-0`,s.bg,s.color),children:n(`activity:goal.${s.labelKey}`)}),r?(0,Q.jsx)(Kn,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}):(0,Q.jsx)(b,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`})]}),!r&&(0,Q.jsxs)(`div`,{className:`px-3 pb-3 space-y-3 border-t pt-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-xs text-foreground leading-relaxed whitespace-pre-wrap break-words`,children:e.goal}),e.refinedGoal&&e.refinedGoal!==e.goal&&(0,Q.jsxs)(`div`,{className:`mt-1.5 p-2 rounded bg-accent/40 border border-border/50`,children:[(0,Q.jsx)(`p`,{className:`text-[10px] text-muted-foreground mb-0.5 uppercase tracking-wider font-medium`,children:n(`activity:goal.refined`)}),(0,Q.jsx)(`p`,{className:`text-xs leading-relaxed whitespace-pre-wrap break-words`,children:e.refinedGoal})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between text-[10px]`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground uppercase tracking-wider font-medium`,children:n(`activity:goal.progress`)}),(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 tabular-nums`,children:[u,(0,Q.jsxs)(`span`,{className:`font-medium text-foreground`,children:[e.progress,`%`]})]})]}),(0,Q.jsx)(`div`,{className:`h-1.5 bg-muted rounded-full overflow-hidden`,children:(0,Q.jsx)(`div`,{className:G(`h-full transition-all duration-700 rounded-full`,e.progress>=80?`bg-success`:e.progress>=50?`bg-warning`:`bg-primary`),style:{width:`${e.progress>0?Math.max(2,e.progress):0}%`}})}),e.progressNote&&(0,Q.jsx)(`p`,{className:`text-[10px] text-muted-foreground italic`,children:e.progressNote})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] text-muted-foreground`,children:[(0,Q.jsx)(Zt,{className:`h-3 w-3`}),(0,Q.jsx)(`span`,{className:`tabular-nums font-medium`,children:e.iterations}),(0,Q.jsx)(`span`,{children:n(`activity:goal.iterations`)}),e.lastStatus&&(0,Q.jsx)(`span`,{className:`text-border`,children:`·`}),e.lastStatus&&(0,Q.jsx)(`span`,{className:`truncate`,children:e.lastStatus})]}),l>0&&(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between text-[10px] text-muted-foreground uppercase tracking-wider font-medium`,children:[(0,Q.jsx)(`span`,{children:n(`activity:goal.deliverables`)}),(0,Q.jsxs)(`span`,{className:`tabular-nums`,children:[c,`/`,l]})]}),(0,Q.jsx)(`ul`,{className:`space-y-0.5`,children:a.map(e=>(0,Q.jsxs)(`li`,{className:`flex items-start gap-1.5 text-[11px]`,children:[e.status===`done`?(0,Q.jsx)(Gt,{className:`h-3 w-3 text-success mt-0.5 shrink-0`}):(0,Q.jsx)(At,{className:`h-3 w-3 text-muted-foreground/70 mt-0.5 shrink-0`}),(0,Q.jsx)(`span`,{className:G(`leading-snug`,e.status===`done`?`text-muted-foreground line-through`:`text-foreground`),children:e.text})]},e.id))})]}),o.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`p`,{className:`text-[10px] text-muted-foreground uppercase tracking-wider font-medium`,children:n(`activity:goal.recentActivity`)}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:o.map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex items-start gap-1.5 text-[10px] text-muted-foreground`,children:[(0,Q.jsxs)(`span`,{className:`font-mono tabular-nums shrink-0 text-foreground/60`,children:[`#`,e.iteration]}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.task||e.status||e.progressNote||`…`})]},`${e.iteration}-${t}`))})]})]})]})}var Nd={in_progress:0,pending:1,completed:2};function Pd(){let{t:e}=V(),t=K(e=>e.todos),n=K(e=>e.session?.id),[r,i]=(0,Z.useState)(new Set),a=pr();(0,Z.useEffect)(()=>{n&&a.send({type:`todos.get`,payload:{sessionId:n}})},[n,a]);let o=(0,Z.useCallback)(e=>{a.removeTodo(e)},[a]),s=(0,Z.useCallback)(e=>{if(e.status===`in_progress`)return;let t=e.status===`completed`?`pending`:`completed`;a.updateTodoStatus(e.id,t)},[a]),c=[...t].sort((e,t)=>(Nd[e.status]??9)-(Nd[t.status]??9)),l=c.filter(e=>e.status===`completed`).length,u=c.filter(e=>e.status===`in_progress`),d=c.filter(e=>e.status===`pending`),f=c.filter(e=>e.status===`completed`),p=f.length>0,m=r.has(`completed`),h=e=>{i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},g=t=>{let n=t.status===`in_progress`&&t.activeForm?t.activeForm:t.content,r=t.status===`in_progress`,i=t.status===`completed`,a=!r;return(0,Q.jsxs)(`div`,{className:G(`relative px-3 py-1.5 flex items-start gap-2 text-[13px] group transition-colors`,a&&`hover:bg-accent/40`,r?`bg-warning/8`:i?`bg-success/5`:`bg-background`),children:[a&&(0,Q.jsx)(`button`,{type:`button`,className:`absolute inset-0 cursor-pointer`,"aria-label":e(`activity:todos.toggleAria`,{content:t.content}),onClick:()=>s(t)}),(0,Q.jsx)(`span`,{className:`pointer-events-none relative mt-0.5 shrink-0`,children:i?(0,Q.jsx)(Gt,{className:`w-3.5 h-3.5 text-success`}):r?(0,Q.jsx)(Zt,{className:`w-3.5 h-3.5 text-warning animate-spin`}):(0,Q.jsx)(At,{className:G(`w-3.5 h-3.5 transition-colors`,`text-muted-foreground/65 group-hover:text-success`)})}),(0,Q.jsx)(`span`,{className:G(`pointer-events-none relative leading-snug flex-1 min-w-0`,r?`text-warning font-medium`:i?`text-muted-foreground line-through`:`text-foreground/80`),children:n}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>o(t.id),className:`relative shrink-0 p-0.5 rounded opacity-0 group-hover:opacity-50 hover:opacity-100 hover:bg-destructive/10 transition-all`,title:e(`activity:todos.removeTitle`),"aria-label":e(`activity:todos.removeAria`,{content:t.content}),children:(0,Q.jsx)(C,{className:`w-3 h-3 text-muted-foreground`})})]},t.id)};return t.length===0?null:(0,Q.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/50 backdrop-blur-sm overflow-hidden`,children:[(0,Q.jsxs)(`div`,{className:`px-3 py-1.5 flex items-center gap-2 border-b border-border/50`,children:[(0,Q.jsx)(`h2`,{className:`text-[11px] font-semibold text-foreground uppercase tracking-wider`,children:e(`activity:work.todos`)}),(0,Q.jsxs)(`span`,{className:`tabular text-[10px] text-muted-foreground ml-auto`,children:[l,`/`,t.length]})]}),u.length>0&&(0,Q.jsx)(`div`,{className:`border-b border-border/30 last:border-b-0`,children:u.map(g)}),d.length>0&&(0,Q.jsx)(`div`,{className:`border-b border-border/30 last:border-b-0`,children:d.map(g)}),p&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>h(`completed`),className:`w-full px-3 py-1 flex items-center gap-1.5 text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:(0,Q.jsxs)(`span`,{className:`tabular`,children:[m?`▶`:`▼`,` `,e(`activity:todos.completedCount`,{count:f.length})]})}),!m&&f.map(g)]})]})}var Fd={pending:{icon:(0,Q.jsx)(At,{className:`w-3.5 h-3.5`}),labelKey:`statusPending`,color:`text-muted-foreground/70`},in_progress:{icon:(0,Q.jsx)(Zt,{className:`w-3.5 h-3.5 animate-spin`}),labelKey:`statusInProgress`,color:`text-warning`},blocked:{icon:(0,Q.jsx)(mn,{className:`w-3.5 h-3.5`}),labelKey:`statusBlocked`,color:`text-warning`},failed:{icon:(0,Q.jsx)(un,{className:`w-3.5 h-3.5`}),labelKey:`statusFailed`,color:`text-destructive`},review:{icon:(0,Q.jsx)(c,{className:`w-3.5 h-3.5`}),labelKey:`statusReview`,color:`text-info`},completed:{icon:(0,Q.jsx)(Gt,{className:`w-3.5 h-3.5`}),labelKey:`statusDone`,color:`text-success`}},Id={critical:`text-destructive`,high:`text-warning`,medium:`text-warning/85`,low:`text-muted-foreground`},Ld={feature:`⚡`,bugfix:`🐛`,refactor:`♻️`,docs:`📝`,test:`🧪`,chore:`🔧`};function Rd(){let{t:e}=V(),[t,n]=(0,Z.useState)([]),[r,i]=(0,Z.useState)(new Set),a=pr(),o=(0,Z.useRef)(null);(0,Z.useEffect)(()=>(a.getTasks(),o.current=a.on(`tasks.updated`,e=>{let t=e?.payload;t?.tasks&&n(t.tasks)}),()=>{o.current?.()}),[a]);let s=(0,Z.useCallback)(e=>{i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),c=(0,Z.useCallback)((e,t)=>{a.updateTaskStatus(e,t)},[a]),l=[`in_progress`,`blocked`,`review`,`pending`,`failed`,`completed`],u=[...t].sort((e,t)=>l.indexOf(e.status)-l.indexOf(t.status)),d=new Map;for(let e of u){let t=d.get(e.status)??[];t.push(e),d.set(e.status,t)}let f=t.filter(e=>e.status===`completed`).length;return t.length===0?null:(0,Q.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/50 backdrop-blur-sm overflow-hidden`,children:[(0,Q.jsxs)(`div`,{className:`px-3 py-1.5 flex items-center gap-2 border-b border-border/50`,children:[(0,Q.jsx)(`h2`,{className:`text-[11px] font-semibold text-foreground uppercase tracking-wider`,children:e(`activity:work.tasks`)}),(0,Q.jsxs)(`span`,{className:`tabular text-[10px] text-muted-foreground ml-auto`,children:[f,`/`,t.length]})]}),l.map(t=>{let n=d.get(t);if(!n||n.length===0)return null;let i=Fd[t],a=r.has(t);return(0,Q.jsxs)(`div`,{className:`border-b border-border/30 last:border-b-0`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>s(t),className:`w-full px-3 py-1 flex items-center gap-1.5 text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:(0,Q.jsxs)(`span`,{className:`tabular`,children:[a?`▶`:`▼`,` `,n.length,` `,e(`activity:task.${i.labelKey}`)]})}),!a&&n.map(t=>(0,Q.jsxs)(`div`,{className:G(`px-3 py-1.5 flex items-start gap-2 text-[13px] group`,t.status===`in_progress`?`bg-warning/8`:``),children:[(0,Q.jsx)(`span`,{className:G(`mt-0.5 shrink-0`,i.color),children:i.icon}),(0,Q.jsxs)(`span`,{className:`leading-snug flex-1 min-w-0`,children:[(0,Q.jsxs)(`span`,{className:G(t.status===`completed`?`text-muted-foreground line-through`:`text-foreground/80`),children:[Ld[t.type],` `,t.title]}),t.priority!==`medium`&&(0,Q.jsx)(`span`,{className:G(`ml-1 text-[10px]`,Id[t.priority]),children:t.priority}),t.assignee&&(0,Q.jsxs)(`span`,{className:`ml-1 text-[10px] text-muted-foreground`,children:[`@`,t.assignee]}),t.estimateHours&&(0,Q.jsxs)(`span`,{className:`ml-1 text-[10px] text-muted-foreground`,children:[t.estimateHours,`h`]})]}),(0,Q.jsxs)(`div`,{className:`flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity shrink-0`,children:[t.status!==`in_progress`&&t.status!==`completed`&&(0,Q.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c(t.id,`in_progress`)},className:`px-1.5 py-0.5 text-[9px] rounded bg-primary/15 text-primary hover:bg-primary/25 transition-colors`,title:e(`activity:task.startTitle`),children:e(`common:action.start`)}),t.status===`in_progress`&&(0,Q.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c(t.id,`completed`)},className:`px-1.5 py-0.5 text-[9px] rounded bg-success/15 text-success hover:bg-success/25 transition-colors`,title:e(`activity:task.completeTitle`),children:e(`activity:task.statusDone`)}),t.status!==`completed`&&t.status!==`failed`&&(0,Q.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c(t.id,`failed`)},className:`px-1.5 py-0.5 text-[9px] rounded bg-destructive/15 text-destructive hover:bg-destructive/25 transition-colors`,title:e(`activity:task.failTitle`),children:e(`activity:task.fail`)})]})]},t.id))]},t)})]})}var zd={open:{icon:(0,Q.jsx)(At,{className:`w-3.5 h-3.5`}),labelKey:`statusOpen`,color:`text-muted-foreground/70`},in_progress:{icon:(0,Q.jsx)(Zt,{className:`w-3.5 h-3.5 animate-spin`}),labelKey:`statusInProgress`,color:`text-warning`},done:{icon:(0,Q.jsx)(Gt,{className:`w-3.5 h-3.5`}),labelKey:`statusDone`,color:`text-success`}};function Bd(){let{t:e}=V(),[t,n]=(0,Z.useState)([]),[r,i]=(0,Z.useState)(new Set),a=pr(),o=(0,Z.useRef)(null);(0,Z.useEffect)(()=>(a.getPlan(),o.current=a.on(`plan.updated`,e=>{let t=e?.payload;t?.plan?.items&&n(t.plan.items)}),()=>{o.current?.()}),[a]);let s=(0,Z.useCallback)(e=>{i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),c=(0,Z.useCallback)((e,t)=>{a.updatePlanItem(e.id,t)},[a]),l=[`in_progress`,`open`,`done`],u=[...t].sort((e,t)=>l.indexOf(e.status)-l.indexOf(t.status)),d=new Map;for(let e of u){let t=d.get(e.status)??[];t.push(e),d.set(e.status,t)}let f=t.filter(e=>e.status===`done`).length;return t.length===0?null:(0,Q.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/50 backdrop-blur-sm overflow-hidden`,children:[(0,Q.jsxs)(`div`,{className:`px-3 py-1.5 flex items-center gap-2 border-b border-border/50`,children:[(0,Q.jsxs)(`h2`,{className:`text-[11px] font-semibold text-foreground uppercase tracking-wider`,children:[`📋 `,e(`activity:work.plan`)]}),(0,Q.jsxs)(`span`,{className:`tabular text-[10px] text-muted-foreground ml-auto`,children:[f,`/`,t.length]})]}),l.map(t=>{let n=d.get(t);if(!n||n.length===0)return null;let i=zd[t],a=r.has(t);return(0,Q.jsxs)(`div`,{className:`border-b border-border/30 last:border-b-0`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>s(t),className:`w-full px-3 py-1 flex items-center gap-1.5 text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:(0,Q.jsxs)(`span`,{className:`tabular`,children:[a?`▶`:`▼`,` `,n.length,` `,e(`activity:plan.${i.labelKey}`)]})}),!a&&n.map(t=>(0,Q.jsxs)(`div`,{className:G(`px-3 py-1.5 flex items-start gap-2 text-[13px] group`,t.status===`in_progress`?`bg-warning/8`:``),children:[(0,Q.jsx)(`span`,{className:G(`mt-0.5 shrink-0`,i.color),children:i.icon}),(0,Q.jsx)(`span`,{className:G(`leading-snug flex-1 min-w-0`,t.status===`done`?`text-muted-foreground line-through`:`text-foreground/80`),children:t.title}),(0,Q.jsxs)(`div`,{className:`flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity shrink-0`,children:[t.status===`open`&&(0,Q.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c(t,`in_progress`)},className:`px-1.5 py-0.5 text-[9px] rounded bg-primary/15 text-primary hover:bg-primary/25 transition-colors`,title:e(`activity:plan.startTitle`),children:e(`common:action.start`)}),t.status!==`done`&&(0,Q.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c(t,`done`)},className:`px-1.5 py-0.5 text-[9px] rounded bg-success/15 text-success hover:bg-success/25 transition-colors`,title:e(`activity:plan.doneTitle`),children:e(`activity:plan.statusDone`)}),t.status===`done`&&(0,Q.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c(t,`open`)},className:`px-1.5 py-0.5 text-[9px] rounded bg-muted text-muted-foreground hover:bg-accent hover:text-foreground transition-colors`,title:e(`activity:plan.reopenTitle`),children:e(`activity:plan.reopen`)})]})]},t.id))]},t)})]})}var Vd=[{id:`todos`,labelKey:`work.todos`,icon:`✅`},{id:`tasks`,labelKey:`work.tasks`,icon:`📋`},{id:`plan`,labelKey:`work.plan`,icon:`🗺️`}];function Hd(){let{t:e}=V(),t=U(e=>e.workDashboardTab),n=U(e=>e.setWorkDashboardTab);return(0,Q.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/50 backdrop-blur-sm overflow-hidden`,children:[(0,Q.jsx)(`div`,{className:`flex border-b border-border/50 bg-muted/30`,children:Vd.map(r=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>n(r.id),className:G(`flex items-center gap-1 px-3 py-1.5 text-[11px] font-medium transition-colors`,`border-b-2 -mb-px`,t===r.id?`border-primary text-foreground bg-background`:`border-transparent text-muted-foreground hover:text-foreground hover:bg-accent/30`),children:[(0,Q.jsx)(`span`,{className:`text-xs`,children:r.icon}),e(`activity:${r.labelKey}`)]},r.id))}),(0,Q.jsx)(`div`,{className:G(t===`todos`?`block`:`hidden`),children:(0,Q.jsx)(Pd,{})}),(0,Q.jsx)(`div`,{className:G(t===`tasks`?`block`:`hidden`),children:(0,Q.jsx)(Rd,{})}),(0,Q.jsx)(`div`,{className:G(t===`plan`?`block`:`hidden`),children:(0,Q.jsx)(Bd,{})})]})}var Ud={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))`,foreground:`hsl(var(--foreground))`},Wd=[Ud.primary,Ud.info,Ud.success,Ud.warning,Ud.destructive,Ud.muted],Gd=e=>e.replace(/^wstack\/ap\//,``);function Kd(e){return[...e].sort((e,t)=>e.allocatedAt-t.allocatedAt).map((e,t)=>({handle:e,color:Wd[t%Wd.length],y:60+t*48}))}var qd={allocating:{dash:`4 4`,opacity:.4},active:{dash:`4 4`,opacity:.6},committing:{dash:`4 4`,opacity:.8},merging:{dash:`0`,opacity:.9},merged:{dash:`0`,opacity:1},"needs-review":{dash:`2 3`,opacity:.9},failed:{dash:`2 3`,opacity:.6}};function Jd({worktrees:e,baseBranch:n}){let{t:r}=V(),i=Kd(e),a=Math.max(120,60+i.length*48+20);return(0,Q.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-border/70 bg-card/70 p-3`,children:(0,Q.jsxs)(`svg`,{width:`100%`,height:a,viewBox:`0 0 600 ${a}`,className:`min-w-[420px]`,role:`img`,"aria-label":r(`activity:worktree.graphAria`,{base:n||`HEAD`}),children:[(0,Q.jsx)(`title`,{children:r(`activity:worktree.graphAria`,{base:n||`HEAD`})}),(0,Q.jsx)(`line`,{x1:40,y1:20,x2:40,y2:a-10,stroke:Ud.primary,strokeWidth:3}),(0,Q.jsx)(`text`,{x:36,y:14,fontSize:11,fill:Ud.muted,children:n||`HEAD`}),(0,Q.jsx)(`circle`,{cx:40,cy:20,r:5,fill:Ud.primary}),i.map(e=>{let i=qd[e.handle.status]??t(qd.active),a=e.handle.status===`merged`,o=e.handle.status===`needs-review`||e.handle.status===`failed`;return(0,Q.jsxs)(`g`,{className:`transition-all duration-500`,children:[(0,Q.jsx)(`path`,{d:`M 40 ${e.y-24} C 100 ${e.y-24}, 160 ${e.y}, 220 ${e.y}`,fill:`none`,stroke:e.color,strokeWidth:2,strokeDasharray:i.dash,opacity:i.opacity}),a?(0,Q.jsx)(`path`,{d:`M 220 ${e.y} C 160 ${e.y+20}, 100 ${e.y+24}, 40 ${e.y+24}`,fill:`none`,stroke:Ud.success,strokeWidth:2,opacity:.9}):null,(0,Q.jsx)(`circle`,{cx:220,cy:e.y,r:5,fill:o?Ud.destructive:e.color}),(0,Q.jsx)(`text`,{x:232,y:e.y-6,fontSize:12,fill:Ud.foreground,fontFamily:`monospace`,children:Gd(e.handle.branch)}),(0,Q.jsx)(`text`,{x:232,y:e.y+10,fontSize:10,fill:Ud.muted,children:o?`⚠ ${e.handle.status}`:a?r(`activity:worktree.mergedLabel`,{base:n}):`+${e.handle.insertions}/-${e.handle.deletions} · ${e.handle.ownerLabel}`})]},e.handle.handleId)})]})})}var Yd={allocating:{icon:`○`,labelKey:`statusAllocating`,tint:`border-muted-foreground/40`,dot:`bg-muted-foreground`},active:{icon:`●`,labelKey:`statusActive`,tint:`border-warning/40`,dot:`bg-warning animate-pulse`},committing:{icon:`◐`,labelKey:`statusCommitting`,tint:`border-primary/40`,dot:`bg-primary animate-pulse`},merging:{icon:`⇡`,labelKey:`statusMerging`,tint:`border-info/40`,dot:`bg-info animate-pulse`},merged:{icon:`✓`,labelKey:`statusMerged`,tint:`border-success/40`,dot:`bg-success`},"needs-review":{icon:`⚠`,labelKey:`statusConflict`,tint:`border-destructive/50`,dot:`bg-destructive`},failed:{icon:`✗`,labelKey:`statusFailed`,tint:`border-destructive/50`,dot:`bg-destructive`}};function Xd(e){return Yd[e]??{icon:`?`,labelKey:``,tint:`border-border`,dot:`bg-muted-foreground`}}var Zd=e=>e.replace(/^wstack\/ap\//,``);function Qd({worktrees:e,baseBranch:t}){let{t:n}=V(),r=[...e].sort((e,t)=>e.allocatedAt-t.allocatedAt);return(0,Q.jsxs)(`div`,{className:`rounded-lg border bg-card/50 backdrop-blur-sm px-3 py-3`,children:[(0,Q.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`span`,{className:`font-semibold tracking-wide uppercase text-[10px]`,children:n(`activity:worktree.lanesHeading`)}),(0,Q.jsxs)(`span`,{className:`opacity-60`,children:[`· `,n(`activity:worktree.base`)]}),(0,Q.jsx)(`code`,{className:`font-mono text-primary`,children:t||`HEAD`}),(0,Q.jsxs)(`span`,{className:`opacity-60`,children:[`· `,n(`activity:worktree.isolatedCount`,{count:r.length})]})]}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:r.map(e=>{let t=Xd(e.status),r=e.status===`needs-review`,i=Math.min(100,e.insertions+e.deletions);return(0,Q.jsxs)(`div`,{className:G(`group relative flex items-center gap-3 rounded-lg border px-3 py-2 transition-all duration-500`,`bg-background/60 hover:bg-accent/20`,t.tint),children:[(0,Q.jsx)(`span`,{className:G(`h-2.5 w-2.5 shrink-0 rounded-full`,t.dot),"aria-hidden":!0}),(0,Q.jsx)(`code`,{className:`w-44 shrink-0 truncate font-mono text-sm`,children:Zd(e.branch)}),(0,Q.jsxs)(`span`,{className:`shrink-0 rounded bg-muted px-2 py-0.5 text-xs text-muted-foreground`,children:[`⟵ `,e.ownerLabel]}),r?(0,Q.jsx)(`span`,{className:`font-mono text-xs font-bold text-destructive`,children:n(`activity:worktree.conflictBadge`)}):(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 font-mono text-xs transition-all duration-500`,children:[(0,Q.jsxs)(`span`,{className:`text-success`,children:[`+`,e.insertions]}),(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`·`}),(0,Q.jsxs)(`span`,{className:`text-destructive`,children:[`-`,e.deletions]}),(0,Q.jsxs)(`span`,{className:`ml-1 text-muted-foreground`,children:[e.files,`f`]})]}),(0,Q.jsx)(`div`,{className:`ml-auto hidden h-1 w-24 overflow-hidden rounded-full bg-muted sm:block`,children:(0,Q.jsx)(`div`,{className:`h-full bg-gradient-to-r from-success to-destructive transition-all duration-700`,style:{width:`${i}%`}})}),(0,Q.jsx)(`span`,{className:`w-20 shrink-0 text-right text-xs text-muted-foreground`,children:t.labelKey?n(`activity:worktree.${t.labelKey}`):e.status}),e.recentActivity.length>0?(0,Q.jsxs)(`span`,{className:`absolute -bottom-2 left-9 max-w-[60%] truncate rounded bg-muted px-1.5 text-[10px] text-muted-foreground opacity-0 transition-opacity duration-300 group-hover:opacity-100`,children:[e.recentActivity[e.recentActivity.length-1]?.kind,`: `,e.recentActivity[e.recentActivity.length-1]?.text]}):null]},e.handleId)})})]})}var $d=e=>e?e.replace(/^wstack\/ap\//,``):``;function ef(){let{t:e}=V(),{client:t}=dr(),n=Nr(e=>e.orphans),r=Nr(e=>e.canClean),i=Nr(e=>e.cleanBlockedReason),a=Nr(e=>e.cleanResult),[o,s]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{t?.send?.({type:`worktree.scan`})},[t]),(0,Z.useEffect)(()=>{a&&s(!1)},[a]),n.length===0&&!a?null:(0,Q.jsxs)(`div`,{className:`rounded-md border border-warning/30 bg-warning/5 px-3 py-2 text-xs`,children:[n.length>0?(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(kt,{className:`mt-0.5 h-4 w-4 shrink-0 text-warning`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`font-medium text-warning`,children:e(`activity:worktree.orphanCount`,{count:n.length})}),(0,Q.jsx)(`div`,{className:`mt-0.5 max-h-16 overflow-auto font-mono text-[10px] text-muted-foreground`,children:n.map((e,t)=>(0,Q.jsxs)(`div`,{className:`truncate`,children:[e.kind===`branch`?`⌥ `:`▢ `,$d(e.branch)||e.dir]},`${e.kind}-${e.branch??e.dir??t}`))})]}),(0,Q.jsxs)(`button`,{type:`button`,disabled:!r||o,onClick:async()=>{let r=n.length;await mi({title:e(`activity:worktree.cleanTitle`,{count:r}),message:e(`activity:worktree.cleanMessage`),confirmLabel:e(`activity:worktree.cleanConfirm`),danger:!0})&&(s(!0),t?.send?.({type:`worktree.cleanup`}))},title:r?e(`activity:worktree.cleanButtonTitle`):i,className:`inline-flex shrink-0 items-center gap-1 rounded bg-warning px-2 py-1 font-medium text-primary-foreground hover:bg-warning/90 disabled:cursor-not-allowed disabled:opacity-50`,children:[o?(0,Q.jsx)(g,{className:`h-3.5 w-3.5 animate-spin`}):(0,Q.jsx)(ct,{className:`h-3.5 w-3.5`}),e(`activity:worktree.cleanConfirm`)]})]}):null,a&&(0,Q.jsx)(`div`,{className:a.ok?`mt-1 text-success`:`mt-1 text-destructive`,children:a.ok?e(`activity:worktree.removed`,{count:a.removed}):`✗ ${a.reason??e(`activity:worktree.cleanupFailed`)}`})]})}var tf={goal:{active:`bg-primary/12 border-primary/40 text-primary shadow-sm`,idle:`text-primary/80 hover:bg-primary/10`},"goal-state":{active:`bg-destructive/10 border-destructive/35 text-destructive shadow-sm`,idle:`text-destructive/80 hover:bg-destructive/10`},fleet:{active:`bg-success/12 border-success/35 text-success shadow-sm`,idle:`text-success/80 hover:bg-success/10`},work:{active:`bg-warning/12 border-warning/35 text-warning shadow-sm`,idle:`text-warning/80 hover:bg-warning/10`},worktrees:{active:`bg-info/12 border-info/35 text-info shadow-sm`,idle:`text-info/80 hover:bg-info/10`},collab:{active:`bg-accent border-primary/25 text-accent-foreground shadow-sm`,idle:`text-muted-foreground hover:bg-muted/60`}},nf={goal:`Goal`,"goal-state":`Goal State`,fleet:`Fleet`,work:`Work`,worktrees:`Worktrees`,collab:`Collab`},rf=[`goal`,`goal-state`,`fleet`,`work`,`worktrees`,`collab`];function af({section:e,icon:t,label:n,value:r,active:i,pulse:a,onClick:o}){let s=tf[e],{t:c}=V();return(0,Q.jsxs)(`button`,{type:`button`,onClick:o,title:c(i?`activity:dock.collapseChip`:`activity:dock.expandChip`,{label:n}),className:G(`flex items-center gap-2 h-7 px-2.5 rounded-md border text-xs font-medium shrink-0 transition-colors`,i?s.active:G(`border-border/40`,s.idle)),children:[(0,Q.jsx)(`span`,{className:G(a&&`animate-pulse`),children:t}),n,r&&(0,Q.jsx)(`span`,{className:`tabular-nums opacity-80`,children:r})]})}function of(){let e=U(e=>e.dockSection),{t}=V(),n=U(e=>e.toggleDockSection),r=U(e=>e.hiddenChips),i=U(e=>e.toggleChipHidden),a=U(e=>e.dockCustomizeOpen),o=U(e=>e.setDockCustomizeOpen),s=wr(e=>e.goal),c=jr(e=>e.phases.length),l=jr(e=>e.overallPercent),u=jr(e=>e.activePhaseId),d=Nr(e=>e.worktrees),f=K(e=>e.todos),p=xr(e=>e.agents),m=wd(),h=p.size,g=(0,Z.useMemo)(()=>Array.from(p.values()).filter(e=>e.status===`running`).length,[p]),_=f.filter(e=>e.status===`completed`).length,v=f.some(e=>e.status===`in_progress`),y=c>0,b=(0,Z.useMemo)(()=>new Set(r),[r]),x={goal:y,"goal-state":s!==null,fleet:h>0,work:!0,worktrees:d.length>0,collab:!0},S={goal:(x.goal||e===`goal`)&&!b.has(`goal`),"goal-state":(x[`goal-state`]||e===`goal-state`)&&!b.has(`goal-state`),fleet:(x.fleet||e===`fleet`)&&!b.has(`fleet`),work:(x.work||e===`work`)&&!b.has(`work`),worktrees:(x.worktrees||e===`worktrees`)&&!b.has(`worktrees`),collab:(x.collab||e===`collab`)&&!b.has(`collab`)},C=e&&S[e]?e:null;return(0,Q.jsx)(`div`,{children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 rounded-lg border border-border/70 bg-card/70 px-2 py-1.5 shadow-sm`,children:[S.goal&&(0,Q.jsx)(af,{section:`goal`,icon:(0,Q.jsx)(zt,{className:`h-3 w-3`}),label:`Goal`,value:`${l}%`,active:!1,pulse:u!=null,onClick:()=>Gr(`goal`)}),S[`goal-state`]&&s&&(0,Q.jsx)(af,{section:`goal-state`,icon:(0,Q.jsx)(M,{className:`h-3 w-3`}),label:`Goal State`,value:`${s.progress}%`,active:C===`goal-state`,pulse:s.goalState===`active`,onClick:()=>n(`goal-state`)}),S.fleet&&(0,Q.jsx)(af,{section:`fleet`,icon:(0,Q.jsx)(Ee,{className:`h-3 w-3`}),label:`Fleet`,value:`${g}/${h}`,active:C===`fleet`,pulse:g>0,onClick:()=>n(`fleet`)}),(0,Q.jsx)(af,{section:`work`,icon:(0,Q.jsx)(ae,{className:`h-3 w-3`}),label:`Work`,value:f.length>0?`${_}/${f.length}`:void 0,active:C===`work`,pulse:v,onClick:()=>n(`work`)}),S.worktrees&&(0,Q.jsx)(af,{section:`worktrees`,icon:(0,Q.jsx)(bn,{className:`h-3 w-3`}),label:`Worktrees`,value:String(d.length),active:C===`worktrees`,onClick:()=>n(`worktrees`)}),m&&(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{},className:`inline-flex h-8 max-w-full min-w-0 items-center gap-1.5 rounded-md border border-border/50 px-2.5 text-xs font-mono transition-colors hover:bg-muted/60 sm:h-7`,children:[(0,Q.jsx)(bn,{className:`h-3 w-3 shrink-0 text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate font-semibold text-foreground`,children:m.branch}),m.ahead>0&&(0,Q.jsxs)(`span`,{className:`text-success`,title:t(`activity:dock.ahead`,{count:m.ahead}),children:[`↑`,m.ahead]}),m.behind>0&&(0,Q.jsxs)(`span`,{className:`text-warning`,title:t(`activity:dock.behind`,{count:m.behind}),children:[`↓`,m.behind]}),m.added>0&&(0,Q.jsxs)(`span`,{className:`text-success`,title:t(`activity:dock.linesAdded`,{count:m.added}),children:[`+`,m.added]}),m.deleted>0&&(0,Q.jsxs)(`span`,{className:`text-destructive`,title:t(`activity:dock.linesDeleted`,{count:m.deleted}),children:[`-`,m.deleted]}),m.untracked>0&&(0,Q.jsxs)(`span`,{className:`text-muted-foreground`,title:t(`activity:dock.untrackedFiles`,{count:m.untracked}),children:[m.untracked,`?`]})]}),(0,Q.jsx)(af,{section:`collab`,icon:(0,Q.jsx)(xn,{className:`h-3 w-3`}),label:`Collab`,active:C===`collab`,onClick:()=>n(`collab`)}),(0,Q.jsxs)(Ei,{open:a,onOpenChange:o,children:[(0,Q.jsx)(Di,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,title:t(`activity:dock.customizeTitle`),className:`ml-auto inline-flex items-center justify-center h-7 w-7 rounded-md border border-border/50 text-muted-foreground hover:bg-muted/60 transition-colors shrink-0`,children:(0,Q.jsx)(ue,{className:`h-3 w-3`})})}),(0,Q.jsxs)(ji,{align:`end`,className:`w-44`,children:[(0,Q.jsx)(Fi,{children:t(`activity:dock.dockChips`)}),(0,Q.jsx)(Ii,{}),rf.map(e=>(0,Q.jsx)(Ni,{checked:!b.has(e),onCheckedChange:()=>i(e),onSelect:e=>e.preventDefault(),children:nf[e]},e))]})]})]})})}var sf={"goal-state":{title:`Goal State`,detail:`Active objective and progress`},fleet:{title:`Fleet`,detail:`Live agent roster and activity`},work:{title:`Work`,detail:`Todos, tasks, and plan`},worktrees:{title:`Worktrees`,detail:`Parallel branches and lanes`},collab:{title:`Collab`,detail:`Session participants and controls`}};function cf({sessionId:e}){let t=U(e=>e.dockSection),n=U(e=>e.setDockSection),r=wr(e=>e.goal),i=Nr(e=>e.worktrees),a=Nr(e=>e.baseBranch),[o,s]=(0,Z.useState)(`graph`),{t:c}=V(),l=t!==null&&t!==`goal`,u=l?t:null,d=u?sf[u]:null;return(0,Z.useEffect)(()=>{if(!l)return;let e=e=>{e.key===`Escape`&&n(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[l,n]),(0,Q.jsxs)(`aside`,{id:`workspace-dock-inspector`,"data-testid":l?`workspace-dock-inspector`:void 0,"aria-hidden":!l,inert:!l||void 0,"aria-label":d?`${d.title} workspace inspector`:`Workspace inspector`,className:G(`fixed inset-y-0 right-0 z-50 flex w-[calc(100vw-3rem)] max-w-none flex-col overflow-hidden border-l border-border/80 bg-card/96 shadow-[-24px_0_64px_-36px_hsl(var(--shadow-color)/0.65)] backdrop-blur-xl transition-transform duration-200 sm:w-[min(680px,48vw)] sm:max-w-[680px]`,l?`translate-x-0`:`pointer-events-none translate-x-full`),children:[(0,Q.jsxs)(`header`,{className:`relative shrink-0 border-b border-border/70 bg-muted/20 px-4 py-3 pr-12`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-foreground`,children:[(0,Q.jsx)(Kt,{className:`h-4 w-4 text-primary`}),d?.title??`Workspace`]}),(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:d?.detail??`Workspace details`}),(0,Q.jsx)(`button`,{type:`button`,"data-testid":`workspace-dock-inspector-close`,onClick:()=>n(null),className:`absolute right-3 top-3 inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,"aria-label":`Close workspace inspector`,title:`Close workspace inspector`,children:(0,Q.jsx)(vn,{className:`h-4 w-4`})})]}),(0,Q.jsxs)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain p-3 sm:p-4`,children:[u===`goal-state`&&(r?(0,Q.jsx)(Md,{goal:r}):(0,Q.jsx)(lf,{title:c(`activity:dock.noActiveGoal`),detail:c(`activity:dock.noActiveGoalDetail`)})),u===`fleet`&&(0,Q.jsx)(kd,{}),u===`worktrees`&&(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:[`graph`,`lanes`].map(e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>s(e),className:G(`rounded-md border px-2.5 py-1 text-xs capitalize transition-colors`,o===e?`border-primary/30 bg-primary/10 text-primary`:`border-border text-muted-foreground hover:text-foreground`),children:e},e))}),(0,Q.jsx)(ef,{}),o===`graph`?(0,Q.jsx)(Jd,{worktrees:i,baseBranch:a||`HEAD`}):(0,Q.jsx)(Qd,{worktrees:i,baseBranch:a||`HEAD`})]}),(0,Q.jsx)(`div`,{className:G(u===`work`?`block`:`hidden`),id:`panel-work`,children:(0,Q.jsx)(Hd,{})}),(0,Q.jsx)(`div`,{className:G(u===`collab`?`block`:`hidden`),children:(0,Q.jsx)(Td,{sessionId:e})})]})]})}function lf({title:e,detail:t}){return(0,Q.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-muted/20 px-3 py-2 text-xs`,children:[(0,Q.jsx)(`div`,{className:`font-medium text-foreground`,children:e}),(0,Q.jsx)(`div`,{className:`mt-1 text-muted-foreground`,children:t})]})}var uf=(0,Z.lazy)(()=>nr(()=>import(`./AnalyticsDashboard-DM8YmJuy.js`).then(e=>({default:e.AnalyticsDashboard})),__vite__mapDeps([27,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,19,18,20,22,17,21,23,28]))),df=(0,Z.lazy)(()=>nr(()=>import(`./CodeMap-T1dsXVRH.js`).then(e=>({default:e.CodeMap})),__vite__mapDeps([29,1,2,3,4,5,6,18,21]))),ff=(0,Z.lazy)(()=>nr(()=>import(`./ChronicleDashboard-CtOiFCYV.js`).then(e=>({default:e.ChronicleDashboard})),__vite__mapDeps([30,1,2,3,4,5,6,19,18,20,28]))),pf=(0,Z.lazy)(()=>nr(()=>import(`./GoalView-p7f1544B.js`).then(e=>({default:e.GoalView})),__vite__mapDeps([31,1,17,2,3,4,5,6,18,7,8,9,10,11,12,13,14,15,16,19,20,21,22,23,24,25,32,33,26,34]))),mf=(0,Z.lazy)(()=>nr(()=>import(`./ChangesView-PgFw9vKk.js`).then(e=>({default:e.ChangesView})),__vite__mapDeps([35,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,19,18,20,22,17,21,23,36]))),hf=(0,Z.lazy)(()=>nr(()=>import(`./CronJobsPanel-CVXW2Y-n.js`).then(e=>({default:e.CronJobsPanel})),__vite__mapDeps([37,1,2,3,4,5,6,22,17,18,8,19,20,21,23,26]))),gf=(0,Z.lazy)(()=>nr(()=>import(`./CodeEditor-B_KwrAhN.js`).then(e=>({default:e.CodeEditor})),__vite__mapDeps([38,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,19,18,20,21,22,17,23,24,36]))),_f=(0,Z.lazy)(()=>nr(()=>import(`./DebugDashboard-BldwPA32.js`).then(e=>({default:e.DebugDashboard})),__vite__mapDeps([39,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]))),vf=(0,Z.lazy)(()=>nr(()=>import(`./DesignGalleryView-CUi5RBHH.js`).then(e=>({default:e.DesignGalleryView})),__vite__mapDeps([40,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]))),yf=(0,Z.lazy)(()=>nr(()=>import(`./MailboxDetailView-DQpxIh_A.js`).then(e=>({default:e.MailboxDetailView})),__vite__mapDeps([41,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,18,23,24,42]))),bf=(0,Z.lazy)(()=>nr(()=>import(`./MemoryManager-BrCVqIJK.js`).then(e=>({default:e.MemoryManager})),__vite__mapDeps([43,1,2,3,4,5,6,8,16,17,18,19,20,21,22,23,24,25,7,9,10,11,12,13,14,15,26,32,28,34,44]))),xf=(0,Z.lazy)(()=>nr(()=>import(`./AudienceMemoryPanel-BN1qR1rz.js`).then(e=>({default:e.AudienceMemoryPanel})),__vite__mapDeps([45,1,2,3,4,5,6,16,17,18,8,19,20,21,22,23,24,25,7,9,10,11,12,13,14,15,26,32,28,34,44]))),Sf=(0,Z.lazy)(()=>nr(()=>import(`./KanbanView-CD_x5YND.js`).then(e=>({default:e.KanbanView})),__vite__mapDeps([46,1,2,3,4,5,6,19,18,20,22,17,8,21,23,47,7,9,10,11,12,13,14,15,16,24,25,28]))),Cf=(0,Z.lazy)(()=>nr(()=>import(`./OfficeMapPanel-D01rqjLt.js`).then(e=>({default:e.OfficeMapPanel})),__vite__mapDeps([48,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,19,18,20,22,17,21,23,42,49]))),wf=(0,Z.lazy)(()=>nr(()=>import(`./ProcessMonitor-DjO7eNsN.js`).then(e=>({default:e.ProcessMonitor})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]))),Tf=(0,Z.lazy)(()=>nr(()=>import(`./QueuePanel-lUChp6xi.js`).then(e=>({default:e.QueuePanel})),__vite__mapDeps([50,1,17,2,3,4,5,6,18,7,8,9,10,11,12,13,14,15,22,19,20,21,23,26]))),Ef=(0,Z.lazy)(()=>nr(()=>import(`./RefreshDebugView-BNa6ehdH.js`).then(e=>({default:e.RefreshDebugView})),__vite__mapDeps([51,1,17,2,3,4,5,6,18,7,8,9,10,11,12,13,14,15,20]))),Df=(0,Z.lazy)(()=>nr(()=>import(`./SddHub-DLVIXlN6.js`).then(e=>({default:e.SddHub})),__vite__mapDeps([52,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,47,32,53]))),Of=(0,Z.lazy)(()=>nr(()=>import(`./SessionsDashboard-DsAc_Sx2.js`).then(e=>({default:e.SessionsDashboard})),__vite__mapDeps([54,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,28]))),kf=(0,Z.lazy)(()=>nr(()=>import(`./SetupScreen-KqV61-Ir.js`).then(e=>({default:e.SetupScreen})),__vite__mapDeps([55,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,32,28,34]))),Af=(0,Z.lazy)(()=>nr(()=>import(`./SkillDetailView-CK7MB8Uo.js`).then(e=>({default:e.SkillDetailView})),__vite__mapDeps([56,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,42])));(0,Z.lazy)(()=>nr(()=>import(`./SpecsView-CNqNOKqo.js`).then(e=>({default:e.SpecsView})),__vite__mapDeps([53,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,32])));var jf=(0,Z.lazy)(()=>nr(()=>import(`./TechStackView-nVNj4kWJ.js`).then(e=>({default:e.TechStackView})),__vite__mapDeps([57,1,2,3,4,5,6,18,22,17,8,19,20,21,23,32,28,34]))),Mf=(0,Z.lazy)(()=>nr(()=>import(`./TerminalPanel-KysALyRz.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([58,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,19,18,20,22,17,21,23,59,60])));function Nf(e){return e.split(`-`).map(e=>e.slice(0,1).toUpperCase()+e.slice(1)).join(` `)}function Pf(e){return e>=1024**3?`${(e/1024**3).toFixed(1)} GB`:e>=1024**2?`${Math.round(e/1024**2)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${Math.round(e)} B`}function Ff(){let[e,t]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>{let e=!1,n=async()=>{try{let n=await fetch(`/debug/system`,{cache:`no-store`});if(!n.ok)return;let r=await n.json();!e&&Number.isFinite(r.memoryUsage?.rss)&&t(r)}catch{}};n();let r=window.setInterval(()=>void n(),5e3);return()=>{e=!0,window.clearInterval(r)}},[]),e}function If({currentView:e,projectName:t,sessionLabel:n,isLoading:r,iteration:i,onPalette:a,onSearch:o,onModel:s,onSettings:c}){let l=Ff(),u=l?l.memoryUsage.heapUsed/l.heapLimit:0;return(0,Q.jsx)(`div`,{className:`hidden shrink-0 border-b border-border/70 bg-card/85 px-3 py-2 shadow-sm backdrop-blur-xl md:block`,children:(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Q.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`truncate text-sm font-semibold`,children:t||`WrongStack`}),(0,Q.jsx)(`span`,{className:`rounded-md border border-border/70 bg-muted/50 px-1.5 py-0.5 text-[11px] text-muted-foreground`,children:Nf(e)}),(0,Q.jsxs)(`span`,{className:G(`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[11px] font-medium`,r?`bg-primary/10 text-primary`:`bg-muted text-muted-foreground`),children:[r?(0,Q.jsx)(Ee,{className:`h-3 w-3 animate-pulse`}):(0,Q.jsx)(ee,{className:`h-3 w-3`}),r?`Running`:`Ready`,i?(0,Q.jsxs)(`span`,{className:`tabular`,children:[i.index,i.max>0?`/${i.max}`:``]}):null]}),l?(0,Q.jsxs)(`span`,{className:G(`rounded-md border border-border/70 bg-muted/50 px-1.5 py-0.5 text-[11px] font-medium tabular-nums`,u>=.85?`text-destructive`:u>=.6?`text-warning`:`text-success`),title:`WebUI server PID ${l.pid} · heap ${Pf(l.memoryUsage.heapUsed)} / ${Pf(l.heapLimit)}`,children:[`RAM `,Pf(l.memoryUsage.rss)]}):null]}),(0,Q.jsx)(`div`,{className:`mt-0.5 truncate text-[11px] text-muted-foreground`,children:n||`No named session`})]})}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:o,className:`inline-flex h-8 items-center gap-1.5 rounded-md border border-border/70 bg-background/60 px-2 text-xs text-muted-foreground hover:bg-accent/60 hover:text-foreground`,title:`Search chat`,children:[(0,Q.jsx)(Tn,{className:`h-3.5 w-3.5`}),`Search`]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:a,className:`inline-flex h-8 items-center gap-1.5 rounded-md border border-border/70 bg-background/60 px-2 text-xs text-muted-foreground hover:bg-accent/60 hover:text-foreground`,title:`Command palette`,children:[(0,Q.jsx)(Rt,{className:`h-3.5 w-3.5`}),`Command`]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:s,className:`inline-flex h-8 items-center gap-1.5 rounded-md border border-border/70 bg-background/60 px-2 text-xs text-muted-foreground hover:bg-accent/60 hover:text-foreground`,title:`Switch model`,children:[(0,Q.jsx)(yt,{className:`h-3.5 w-3.5`}),`Model`]}),(0,Q.jsx)(Vc,{}),(0,Q.jsx)(Ys,{}),(0,Q.jsx)(`button`,{type:`button`,onClick:c,className:`inline-flex h-8 w-8 items-center justify-center rounded-md border border-border/70 bg-background/60 text-muted-foreground hover:bg-accent/60 hover:text-foreground`,title:`Settings`,children:(0,Q.jsx)(lt,{className:`h-3.5 w-3.5`})})]})]})})}function Lf({label:e}){return(0,Q.jsx)(`div`,{className:`flex flex-1 min-h-0 min-w-0 items-center justify-center bg-background text-muted-foreground`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[(0,Q.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-muted-foreground/30 border-t-primary`}),e?(0,Q.jsx)(`span`,{className:`text-xs`,children:e}):null]})})}function Rf(){let{theme:e}=Ti(),t=or(),{currentView:n,sidebarOpen:r,toggleSidebar:a,setSearchOpen:o,setSidebarOpen:s,setInspectorTab:c,setPaletteOpen:l,setShortcutsOpen:u,setModelSwitcherOpen:d,setPromptLibraryOpen:f,toggleInspector:p,setFleetMonitorOpen:m,setAgentsMonitorOpen:h,processMonitorOpen:g,setProcessMonitorOpen:_,queuePanelOpen:v,setQueuePanelOpen:y,cronJobsOpen:b,setCronJobsOpen:x,terminalOpen:S,setTerminalOpen:C}=U($t(e=>({currentView:e.currentView,sidebarOpen:e.sidebarOpen,toggleSidebar:e.toggleSidebar,setSearchOpen:e.setSearchOpen,setSidebarOpen:e.setSidebarOpen,setInspectorTab:e.setInspectorTab,setPaletteOpen:e.setPaletteOpen,setShortcutsOpen:e.setShortcutsOpen,setModelSwitcherOpen:e.setModelSwitcherOpen,setPromptLibraryOpen:e.setPromptLibraryOpen,toggleInspector:e.toggleInspector,setFleetMonitorOpen:e.setFleetMonitorOpen,setAgentsMonitorOpen:e.setAgentsMonitorOpen,processMonitorOpen:e.processMonitorOpen,setProcessMonitorOpen:e.setProcessMonitorOpen,queuePanelOpen:e.queuePanelOpen,setQueuePanelOpen:e.setQueuePanelOpen,cronJobsOpen:e.cronJobsOpen,setCronJobsOpen:e.setCronJobsOpen,terminalOpen:e.terminalOpen,setTerminalOpen:e.setTerminalOpen}))),w=i(e=>e.isLoading),T=K(e=>e.iteration),E=K(e=>e.projectName),D=K(e=>e.session?.title),O=K(e=>e.session?.id),k=U(e=>O?e.sessionNicknames[O]:void 0),A=U(e=>e.sideContextBreakdownOpen),j=U(e=>e.setSideContextBreakdownOpen);xr(e=>e.agents),ua({setPaletteOpen:l,setSearchOpen:o,setShortcutsOpen:u,setModelSwitcherOpen:d,setPromptLibraryOpen:f,setFleetMonitorOpen:m,setAgentsMonitorOpen:h,setProcessMonitorOpen:_,setQueuePanelOpen:y,setCronJobsOpen:x,setTerminalOpen:C}),(0,Z.useEffect)(()=>{typeof window>`u`||(window.location.pathname===`/debug`?Ur(`debug`):window.location.pathname===`/analytics`?Ur(`analytics`):window.location.pathname===`/refresh-debug`&&Ur(`refresh-debug`))},[]),(0,Z.useEffect)(()=>{let e=e=>{let{filePath:t}=e.detail,n=pr(q.getState().wsUrl);n&&n.send({type:`files.read`,payload:{filePath:t}})};return window.addEventListener(`wrongstack:open-file`,e),()=>window.removeEventListener(`wrongstack:open-file`,e)},[]),(0,Z.useEffect)(()=>{let e=e=>{let{filePath:t}=e.detail,n=gr.getState().openFiles.find(e=>e.path===t);if(!n)return;let r=pr(q.getState().wsUrl);r&&r.send({type:`files.write`,payload:{filePath:t,content:n.content}})};return window.addEventListener(`wrongstack:save-file`,e),()=>window.removeEventListener(`wrongstack:save-file`,e)},[]);let[M,N]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{if(typeof window>`u`)return;let e=window.matchMedia(`(max-width: 768px)`),t=()=>{let t=U.getState().sidebarOpen;e.matches&&t&&s(!1),N(e.matches&&t)};return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[s]),(0,Z.useEffect)(()=>{if(typeof window>`u`)return;let e=window.matchMedia(`(max-width: 768px)`);N(e.matches&&r)},[r]),sr(),da(),(0,Z.useEffect)(()=>{let e=[];if(w){let t=T?` iter ${T.index}${T.max?`/${T.max}`:``}`:``;e.push(`●${t}`)}let t=k?.trim()||D?.trim(),n=E?.trim();t&&e.push(t),n&&e.push(n),e.length===0&&e.push(n||`AI Agent`);let r=e.filter(Boolean).join(` · `);return document.title=r,()=>{document.title=E||`AI Agent`}},[w,T,E,D,k]),fa({toggleSidebar:a,setSearchOpen:o,toggleInspector:p,setInspectorTab:c}),(0,Q.jsxs)(`div`,{"data-shell":t?`desktop`:`browser`,className:G(`ws-app-root flex min-h-0 min-w-0 overflow-hidden`,t&&`ws-desktop-shell`,e),children:[(0,Q.jsx)(`a`,{href:`#main-content`,className:`sr-only focus:not-sr-only focus:absolute focus:top-2 focus:left-2 focus:z-[100] focus:rounded-md focus:bg-background focus:px-3 focus:py-1.5 focus:text-sm focus:font-medium focus:shadow-lg focus:ring-2 focus:ring-primary`,children:`Skip to content`}),n!==`setup`&&(0,Q.jsx)(Yi,{desktopShell:t}),r&&n!==`setup`&&(0,Q.jsx)(Cd,{desktopShell:t}),(0,Q.jsxs)(`main`,{id:`main-content`,className:`flex-1 min-w-0 min-h-0 flex flex-col overflow-hidden bg-background/70`,...M?{inert:!0}:{},children:[n!==`setup`&&(0,Q.jsx)(If,{currentView:n,projectName:E,sessionLabel:k||D||O||void 0,isLoading:w,iteration:T??null,onPalette:()=>l(!0),onSearch:()=>o(!0),onModel:()=>d(!0),onSettings:()=>Gr(`settings`)}),n!==`setup`&&(0,Q.jsx)(Ds,{}),n===`chat`&&(0,Q.jsxs)(Q.Fragment,{children:[O&&(0,Q.jsx)(`div`,{className:`ws-workspace-dock-wrap shrink-0 px-3 pt-2 sm:px-4`,children:(0,Q.jsx)(of,{})}),(0,Q.jsx)(Xs,{level:`panel`,name:`Chat`,children:(0,Q.jsx)(Cs,{})})]}),n===`settings`&&(0,Q.jsx)(Xs,{level:`panel`,name:`Settings`,children:(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Q.jsx)(fu,{})})}),n===`memory`&&(0,Q.jsx)(Xs,{level:`panel`,name:`Memory Manager`,children:(0,Q.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col lg:flex-row`,children:[(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lf,{label:`Loading…`}),children:(0,Q.jsx)(`div`,{className:`h-[38dvh] min-h-56 w-full shrink-0 border-b border-border/40 lg:h-full lg:min-h-0 lg:w-80 lg:border-b-0 lg:border-r`,children:(0,Q.jsx)(xf,{})})}),(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lf,{label:`Loading Super Memory…`}),children:(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Q.jsx)(bf,{})})})]})}),n===`context`&&(0,Q.jsx)(Xs,{level:`panel`,name:`Context Dashboard`,children:(0,Q.jsx)(Js,{})}),n===`setup`&&(0,Q.jsx)(Xs,{level:`panel`,name:`Setup`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lf,{}),children:(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Q.jsx)(kf,{})})})}),n===`goal`&&(0,Q.jsx)(Xs,{level:`panel`,name:`Goal`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lf,{}),children:(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Q.jsx)(pf,{onClose:()=>J(`chat`)})})})}),n===`sddhub`&&(0,Q.jsx)(Xs,{level:`panel`,name:`SDD Hub`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lf,{}),children:(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Q.jsx)(Df,{})})})}),n===`kanban`&&(0,Q.jsx)(Xs,{level:`panel`,name:`Kanban`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lf,{}),children:(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Q.jsx)(Sf,{onClose:()=>J(`chat`)})})})}),n===`sessions`&&(0,Q.jsx)(Xs,{level:`panel`,name:`Sessions`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lf,{}),children:(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Q.jsx)(Of,{})})})}),n===`chronicle`&&(0,Q.jsx)(Xs,{level:`panel`,name:`Chronicle`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lf,{}),children:(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Q.jsx)(ff,{})})})}),n===`debug`&&(0,Q.jsx)(Xs,{level:`panel`,name:`Debug Dashboard`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lf,{}),children:(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Q.jsx)(_f,{})})})}),n===`refresh-debug`&&(0,Q.jsx)(Xs,{level:`panel`,name:`Refresh Debug`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lf,{}),children:(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Q.jsx)(Ef,{})})})}),n===`files`&&(0,Q.jsx)(Xs,{level:`panel`,name:`Editor`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lf,{label:`Loading editor…`}),children:(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Q.jsx)(gf,{})})})}),n===`changes`&&(0,Q.jsx)(Xs,{level:`panel`,name:`Changes`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lf,{label:`Loading diff…`}),children:(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Q.jsx)(mf,{className:`h-full min-h-0`})})})}),n===`mailbox`&&(0,Q.jsx)(Xs,{level:`panel`,name:`Mailbox`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lf,{}),children:(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Q.jsx)(yf,{className:`h-full min-h-0`})})})}),n===`design-gallery`&&(0,Q.jsx)(Xs,{level:`panel`,name:`Design Gallery`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lf,{}),children:(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Q.jsx)(vf,{className:`h-full`})})})}),n===`skill`&&(0,Q.jsx)(Xs,{level:`panel`,name:`Skill`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lf,{}),children:(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Q.jsx)(Af,{className:`h-full`})})})}),n===`officemap`&&(0,Q.jsx)(Xs,{level:`panel`,name:`Office Map`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lf,{label:`Loading map…`}),children:(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Q.jsx)(Cf,{})})})}),n===`analytics`&&(0,Q.jsx)(Xs,{level:`panel`,name:`Analytics`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lf,{}),children:(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Q.jsx)(uf,{})})})}),n===`codemap`&&(0,Q.jsx)(Xs,{level:`panel`,name:`CodeMap`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lf,{label:`Loading CodeMap…`}),children:(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Q.jsx)(df,{})})})}),n===`techstack`&&(0,Q.jsx)(Xs,{level:`panel`,name:`TechStack`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lf,{label:`Loading TechStack…`}),children:(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Q.jsx)(jf,{})})})}),S&&(0,Q.jsx)(Xs,{level:`panel`,name:`Terminal`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lf,{label:`Loading terminal…`}),children:(0,Q.jsx)(Mf,{desktopShell:t,onClose:()=>C(!1)})})})]}),n!==`setup`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Xs,{level:`panel`,name:`Inspector`,children:(0,Q.jsx)(Hc,{})}),O&&n===`chat`&&(0,Q.jsx)(Xs,{level:`panel`,name:`Workspace Inspector`,children:(0,Q.jsx)(cf,{sessionId:O})})]}),g&&(0,Q.jsx)(Xs,{level:`panel`,name:`Process Monitor`,children:(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(wf,{open:g,onClose:()=>_(!1)})})}),v&&(0,Q.jsx)(Xs,{level:`panel`,name:`Queue`,children:(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(Tf,{open:v,onClose:()=>y(!1)})})}),b&&(0,Q.jsx)(Xs,{level:`panel`,name:`Cron Jobs`,children:(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(hf,{open:b,onClose:()=>x(!1)})})}),A&&(0,Q.jsx)(go,{open:A,onClose:()=>j(!1)}),(0,Q.jsx)(Es,{}),(0,Q.jsx)(hi,{}),(0,Q.jsx)(pi,{}),(0,Q.jsx)(ca,{}),(0,Q.jsx)(mu,{}),(0,Q.jsx)(qc,{}),(0,Q.jsx)(qr,{})]})}function zf(){return(0,Q.jsx)(Xs,{children:(0,Q.jsx)(wi,{defaultTheme:`system`,children:(0,Q.jsx)(Rf,{})})})}gi.createRoot(t(document.getElementById(`root`))).render((0,Q.jsx)(Z.StrictMode,{children:(0,Q.jsx)(zf,{})}));export{Ti as C,ho as S,$o as _,kl as a,So as b,el as c,$s as d,nc as f,Os as g,Zs as h,zu as i,Xc as l,tc as m,Qd as n,Al as o,ec as p,Jd as r,Ol as s,ef as t,Cc as u,Wo as v,bo as x,Ho as y};