@wrongstack/webui 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AgentRosterView-B_J6SvVF.js → AgentRosterView-BXURTwLP.js} +1 -1
- package/dist/assets/{AnalyticsDashboard-BgZiiiDb.js → AnalyticsDashboard-yAGcObTd.js} +1 -1
- package/dist/assets/{AudienceMemoryPanel-CPuksIMN.js → AudienceMemoryPanel-BwtB_jYJ.js} +1 -1
- package/dist/assets/{ChangesView-CmZeNwbw.js → ChangesView-BgC27G9n.js} +1 -1
- package/dist/assets/{ChimeraReviewsView-CpfSkgQ2.js → ChimeraReviewsView-BZ3kmsEA.js} +1 -1
- package/dist/assets/{ChronicleDashboard-B6lhZGjz.js → ChronicleDashboard-DVor6J-y.js} +1 -1
- package/dist/assets/{CodeEditor-Daz1yqjF.js → CodeEditor-Dk2WJQks.js} +1 -1
- package/dist/assets/{CodeMap-D-H9FNUJ.js → CodeMap-CjWRQ37U.js} +1 -1
- package/dist/assets/{ConfirmModal-CjsZbvo3.js → ConfirmModal-C_KAUjBK.js} +1 -1
- package/dist/assets/{CronJobsPanel-DGKW_zwc.js → CronJobsPanel-CGq8lhRJ.js} +1 -1
- package/dist/assets/{DeadCodeScanPanel-Cn5bSfLv.js → DeadCodeScanPanel-CcPRcYm0.js} +1 -1
- package/dist/assets/{DebugDashboard-Uh9QLbEk.js → DebugDashboard-B-aDaDrO.js} +1 -1
- package/dist/assets/{DesignGalleryView-Da1QtI5b.js → DesignGalleryView-Ex3zW5ci.js} +1 -1
- package/dist/assets/{GoalView-BgVxzzzS.js → GoalView-CBDc5nCD.js} +1 -1
- package/dist/assets/{KanbanView-_JvZKFyI.js → KanbanView-azjPGLmM.js} +2 -2
- package/dist/assets/{MailboxDetailView-26bVSSbU.js → MailboxDetailView-BXW9zqle.js} +1 -1
- package/dist/assets/{MemoryDrawer-C5sEdVvj.js → MemoryDrawer-CyN_6CRo.js} +1 -1
- package/dist/assets/{MemoryManager-BqWzNt8w.js → MemoryManager-BLu0rLEm.js} +1 -1
- package/dist/assets/{ModelPicker-DqRzzv5J.js → ModelPicker-CXQR8UbH.js} +1 -1
- package/dist/assets/{ProcessMonitor-ygFLD5zk.js → ProcessMonitor-CBIQkbLx.js} +1 -1
- package/dist/assets/{PromptJournalView-B65KxlYi.js → PromptJournalView-C6O40uTv.js} +1 -1
- package/dist/assets/{QueuePanel-CJlIV0pX.js → QueuePanel-CutrvgTH.js} +1 -1
- package/dist/assets/{RefreshDebugView-CNovrSAn.js → RefreshDebugView-DDFD26EI.js} +1 -1
- package/dist/assets/{RequirementIntakeView-BnrQSVE_.js → RequirementIntakeView-BpFyFOlB.js} +1 -1
- package/dist/assets/{SageTabs-CJqOqiY7.js → SageTabs-Cx299O-q.js} +2 -2
- package/dist/assets/{SddFlowGraph-CNOyn5N9.js → SddFlowGraph-CJjawf9r.js} +1 -1
- package/dist/assets/{SddHub-mFjsa_Zl.js → SddHub-CmSlkvkM.js} +1 -1
- package/dist/assets/{SessionInspectView-MEmxIEzB.js → SessionInspectView-CtrlRlJu.js} +1 -1
- package/dist/assets/{SessionList-DmcQJmzw.js → SessionList-BWoK6Ro5.js} +1 -1
- package/dist/assets/{SessionsDashboard-BCYViJlx.js → SessionsDashboard-7C6Fj9pK.js} +1 -1
- package/dist/assets/{SetupScreen-BwnSJt7v.js → SetupScreen-IzaqHJ_O.js} +1 -1
- package/dist/assets/{SkillDetailView-ebz2dRUQ.js → SkillDetailView-C5nOcysX.js} +1 -1
- package/dist/assets/{TechStackView-DESDpUDA.js → TechStackView-DkNjeYPK.js} +1 -1
- package/dist/assets/{TerminalPanel-BiWnldbB.js → TerminalPanel-CTr-KAnH.js} +1 -1
- package/dist/assets/{chat-store-BcfvHUUj.js → chat-store-BbBGSliF.js} +1 -1
- package/dist/assets/i18n-tRUjoMoU.js +2 -0
- package/dist/assets/{index-TDhvFXb0.js → index-BnpuNJ9u.js} +7 -7
- package/dist/assets/{roster-ws-n_N7K9tX.js → roster-ws-B4xVrXos.js} +1 -1
- package/dist/assets/{stores-Cfei1ViB.js → stores-B7GcARdp.js} +1 -1
- package/dist/assets/{useWebSocket-AYEcpb1U.js → useWebSocket-L5s7ggJm.js} +1 -1
- package/dist/assets/{ws-client-C_IqS0t4.js → ws-client-BR51gfnV.js} +2 -2
- package/dist/index.html +8 -8
- package/dist/index.js +23 -20
- package/package.json +9 -9
- package/dist/assets/i18n-DBqM1FUM.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ws-client-
|
|
2
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,A as n,B as r,C as i,Ct as a,D as o,E as s,F as c,Ft as l,G as u,H as d,Ht as f,I as p,J as m,K as h,Lt as g,M as _,N as v,Nt as y,O as b,Ot as x,P as S,Q as C,R as w,S as T,T as E,Tt as D,U as O,Ut as k,V as A,W as j,X as M,Z as N,_ as P,a as F,at as I,b as L,et as R,f as ee,g as te,h as z,ht as ne,i as re,it as ie,j as ae,k as oe,kt as se,m as ce,nt as le,o as ue,ot as de,p as fe,q as B,rt as pe,st as me,t as V,tt as he,ut as ge,v as _e,vt as ve,w as ye,x as be,y as xe,yt as Se,z as Ce}from"./ws-client-C_IqS0t4.js";import{i as we,n as Te,t as Ee}from"./react-core-BNmTiJ-I.js";import{$ as De,$i as Oe,$r as ke,$t as Ae,A as je,Aa as Me,An as Ne,Ar as Pe,B as Fe,Bi as Ie,Bn as Le,Br as Re,Bt as ze,C as Be,Ca as Ve,Ci as He,Cn as Ue,D as We,Da as Ge,Di as Ke,Dn as qe,Dt as Je,E as Ye,Ea as Xe,Ei as Ze,En as Qe,Er as $e,Et as et,F as tt,Fa as H,Fn as nt,Fr as rt,Ft as it,G as at,Gi as ot,Gn as st,Gt as ct,H as lt,Hi as ut,Hn as dt,Hr as ft,I as pt,Ii as mt,In as ht,Ir as gt,J as _t,Ji as vt,Jn as yt,Jr as bt,Jt as xt,K as St,Ki as Ct,Kn as wt,L as Tt,Li as Et,Ln as Dt,Lr as Ot,Lt as kt,M as At,Ma as jt,Mn as Mt,Mr as Nt,Mt as Pt,N as Ft,Ni as It,Nn as Lt,Nr as Rt,Nt as zt,O as Bt,Oi as Vt,On as Ht,Or as Ut,Ot as Wt,P as Gt,Pn as Kt,Pt as qt,Q as Jt,Qn as Yt,Qr as Xt,Qt as Zt,R as Qt,Ra as U,Ri as $t,Rn as en,Rr as tn,Rt as nn,S as rn,Sa as an,Si as on,St as sn,T as cn,Tr as ln,U as un,Ui as dn,Un as fn,Ur as pn,Ut as mn,V as hn,Vi as gn,Vn as _n,Vt as vn,Wi as yn,Wn as bn,Wr as xn,Wt as Sn,X as Cn,Xi as wn,Xt as Tn,Y as En,Yi as Dn,Yn as On,Yr as kn,Yt as An,Z as jn,Zi as Mn,Zn as Nn,Zr as Pn,Zt as Fn,_ as In,_a as Ln,_i as Rn,_n as zn,_r as Bn,_t as Vn,a as Hn,an as Un,ar as Wn,at as Gn,b as Kn,ba as qn,bn as Jn,br as Yn,bt as Xn,c as Zn,ca as Qn,ci as $n,cn as er,cr as tr,ct as nr,d as rr,da as ir,di as ar,dn as or,dr as sr,dt as cr,ea as lr,ei as ur,er as dr,et as fr,f as pr,fa as mr,fi as hr,fn as gr,fr as _r,ft as vr,g as yr,ga as br,gi as xr,gn as Sr,gr as Cr,gt as wr,h as Tr,ha as Er,hi as Dr,hr as Or,ht as kr,i as Ar,ia as jr,ii as Mr,in as Nr,ir as Pr,j as Fr,jn as Ir,k as Lr,ki as Rr,kn as zr,kr as Br,kt as Vr,l as Hr,la as Ur,li as Wr,ln as Gr,lt as Kr,m as qr,mr as Jr,na as Yr,ni as Xr,nn as Zr,nt as Qr,o as $r,oa as ei,oi as ti,on as ni,or as ri,p as ii,pa as ai,pi as oi,pn as si,pt as ci,q as li,qi as ui,qr as di,ri as fi,rr as pi,rt as mi,s as hi,si as gi,sn as _i,sr as vi,st as yi,ta as bi,tn as xi,u as Si,ua as Ci,ui as wi,un as Ti,ur as Ei,ut as Di,v as Oi,va as ki,vn as Ai,vr as ji,vt as Mi,w as Ni,wi as Pi,wn as Fi,wr as Ii,wt as Li,x as Ri,xa as zi,xn as Bi,xr as Vi,xt as Hi,y as Ui,ya as Wi,yi as Gi,yn as Ki,yr as qi,yt as Ji,z as Yi,zi as Xi,zr as Zi,zt as Qi}from"./vendor-BshlG0z-.js";import{i as $i,n as W,r as ea}from"./i18n-DBqM1FUM.js";import{t as ta}from"./vite-preload-Czpn1I53.js";import{a as na,c as ra,d as ia,f as aa,h as oa,i as sa,l as ca,m as la,n as ua,o as da,p as fa,r as pa,s as ma,t as ha,u as ga}from"./useWebSocket-AYEcpb1U.js";import{t as G}from"./utils-BpBOwXlT.js";import{a as _a,i as va,n as K,r as ya,t as ba}from"./ui-store-CLXDcLPI.js";import{t as q}from"./chat-store-BcfvHUUj.js";import{C as xa,_ as Sa,b as Ca,d as wa,g as Ta,i as Ea,m as Da,p as Oa,s as ka,t as Aa,v as ja,x as Ma,y as Na}from"./stores-Cfei1ViB.js";import{n as Pa,r as Fa,t as Ia}from"./mailbox-store-yydAVjyj.js";import{a as La,i as Ra,n as za,o as J,r as Ba,s as Va,t as Ha}from"./view-navigation-CvWJeGMc.js";import{a as Ua,i as Wa,n as Ga,o as Ka,r as qa,t as Ja}from"./dialog-xJxaQi60.js";import{t as Y}from"./button-rqi3MczV.js";import{t as Ya}from"./input-ClZR-odw.js";import{i as Xa,n as Za,o as Qa,r as $a,t as eo}from"./ConfirmModal-CjsZbvo3.js";import{n as to,r as no,t as ro}from"./ModelPicker-DqRzzv5J.js";import{c as io,u as ao}from"./markdown-BP6Z3HKc.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),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var X=e(we(),1),oo=e(Te(),1),so=new Set([`chat`,`settings`,`goal`,`kanban`,`sddhub`,`files`,`changes`,`sessions`,`setup`,`skill`,`roster`,`mailbox`,`debug`,`design-gallery`,`refresh-debug`,`analytics`]),co=new Set([`goal`,`fleet`,`work`,`worktrees`,`collab`]),lo=new Set([`todos`,`tasks`,`plan`]);function uo(){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 fo(e){typeof window>`u`||window.wrongstackDesktopHost?.setReady?.(e)}function po(e,t,n){typeof window>`u`||typeof e!=`string`||window.wrongstackDesktopHost?.ackCommand?.(e,t,n)}var Z=Ee(),mo=Yi,ho=un,go=X.forwardRef(({className:e,inset:t,children:n,...r},i)=>(0,Z.jsxs)(lt,{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,Z.jsx)(ot,{className:`ml-auto h-4 w-4`})]}));go.displayName=lt.displayName;var _o=X.forwardRef(({className:e,...t},n)=>(0,Z.jsx)(hn,{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}));_o.displayName=hn.displayName;var vo=X.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,Z.jsx)(Tt,{children:(0,Z.jsx)(Ft,{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})}));vo.displayName=Ft.displayName;var yo=X.forwardRef(({className:e,inset:t,...n},r)=>(0,Z.jsx)(Gt,{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}));yo.displayName=Gt.displayName;var bo=X.forwardRef(({className:e,children:t,checked:n,...r},i)=>(0,Z.jsxs)(At,{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,Z.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,Z.jsx)(tt,{children:(0,Z.jsx)(ui,{className:`h-4 w-4`})})}),t]}));bo.displayName=At.displayName;var xo=X.forwardRef(({className:e,children:t,...n},r)=>(0,Z.jsxs)(Qt,{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,Z.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,Z.jsx)(tt,{children:(0,Z.jsx)(Vt,{className:`h-2 w-2 fill-current`})})}),t]}));xo.displayName=Qt.displayName;var So=X.forwardRef(({className:e,inset:t,...n},r)=>(0,Z.jsx)(pt,{ref:r,className:G(`px-2 py-1.5 text-sm font-semibold`,t&&`pl-8`,e),...n}));So.displayName=pt.displayName;var Co=X.forwardRef(({className:e,...t},n)=>(0,Z.jsx)(Fe,{ref:n,className:G(`-mx-1 my-1 h-px bg-muted`,e),...t}));Co.displayName=Fe.displayName;var wo=({className:e,...t})=>(0,Z.jsx)(`span`,{className:G(`ml-auto text-xs tracking-widest opacity-60`,e),...t});wo.displayName=`DropdownMenuShortcut`;var To=[{id:`chat`,icon:(0,Z.jsx)(Lt,{size:16}),label:`Session`},{id:`files`,icon:(0,Z.jsx)(Rt,{size:16}),label:`Files`},{id:`changes`,icon:(0,Z.jsx)(qi,{size:16}),label:`Changes`},{id:`mailbox`,icon:(0,Z.jsx)(Le,{size:16}),label:`Mailbox`},{id:`skills`,icon:(0,Z.jsx)(et,{size:16}),label:`Skills`},{id:`design`,icon:(0,Z.jsx)(Jn,{size:16}),label:`Design Studio`}],Eo=[{id:`roster`,icon:(0,Z.jsx)(jr,{size:16}),label:`Agent Roster`},{id:`sddhub`,icon:(0,Z.jsx)(Cn,{size:16}),label:`SDD`},{id:`kanban`,icon:(0,Z.jsx)(Rn,{size:16}),label:`Kanban`},{id:`goal`,icon:(0,Z.jsx)(Zt,{size:16}),label:`Goal`},{id:`codemap`,icon:(0,Z.jsx)(Fi,{size:16}),label:`CodeMap`},{id:`techstack`,icon:(0,Z.jsx)(Yr,{size:16}),label:`TechStack`},{id:`chronicle`,icon:(0,Z.jsx)(Dn,{size:16}),label:`Chronicle`},{id:`prompts`,icon:(0,Z.jsx)(mn,{size:16}),label:`Prompt Journal`},{id:`chimera`,icon:(0,Z.jsx)(qt,{size:16}),label:`Chimera Reviews`},{id:`intake`,icon:(0,Z.jsx)(Ze,{size:16}),label:`Requirements`},{id:`memory`,icon:(0,Z.jsx)(bi,{size:16}),label:`Memory`}],Do=[`chat`,`files`,`changes`,`mailbox`],Oo=[...Do,`skills`,`design`],ko=132,Ao=38,jo=165,Mo=46;function No(e,t){let n=To.length+Eo.length,r=Number.isFinite(e)?e:720,i=t?ko:jo,a=t?Ao:Mo,o=Math.floor((r-i)/a);return Math.max(Do.length,Math.min(n,o))}function Po(e){let t=To.length+Eo.length,n=Math.max(Do.length,Math.min(t,Math.floor(e))),r=Math.min(To.length,n),i=new Set(Oo.slice(0,r)),a=To.map(e=>e.id).filter(e=>i.has(e)),o=To.map(e=>e.id).filter(e=>!i.has(e)),s=Math.max(0,n-a.length),c=Eo.slice(0,s).map(e=>e.id),l=new Set(c);return{visiblePanelIds:a,overflowPanelIds:o,visibleViewIds:c,overflowViewIds:Eo.map(e=>e.id).filter(e=>!l.has(e))}}var Fo=To.map(e=>e.id);function Io(){return typeof window>`u`?720:window.visualViewport?.height??window.innerHeight}function Lo(e){let[t,n]=(0,X.useState)(Io);return(0,X.useEffect)(()=>{if(typeof window>`u`)return;let e=()=>n(Io());return e(),window.addEventListener(`resize`,e),window.visualViewport?.addEventListener(`resize`,e),()=>{window.removeEventListener(`resize`,e),window.visualViewport?.removeEventListener(`resize`,e)}},[]),No(t,e)}function Ro({desktopShell:e=!1}){let t=K(e=>e.activeActivity),n=K(e=>e.sidebarOpen),r=K(e=>e.currentView),i=N(e=>e.projectName),a=R(e=>e.wsConnected),{t:o}=H(),s=(e,t)=>o(`activity:nav.${e}`,t),c=Fa(Pa),l=P(e=>e.openTabIds.length),u=K(e=>e.inspectorOpen),d=Lo(e),f=(0,X.useMemo)(()=>Po(d),[d]),p=(0,X.useMemo)(()=>new Set(f.visiblePanelIds),[f.visiblePanelIds]),m=(0,X.useMemo)(()=>new Set(f.overflowPanelIds),[f.overflowPanelIds]),h=(0,X.useMemo)(()=>new Set(f.visibleViewIds),[f.visibleViewIds]),g=(0,X.useMemo)(()=>new Set(f.overflowViewIds),[f.overflowViewIds]),_=To.filter(e=>p.has(e.id)),v=To.filter(e=>m.has(e.id)),y=Eo.filter(e=>h.has(e.id)),b=Eo.filter(e=>g.has(e.id)),x=e=>{if(e===`mailbox`)return c||void 0;if(e===`chat`)return l>0?l:void 0};return(0,Z.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,Z.jsx)(`div`,{className:`flex flex-col items-center shrink-0 border-b border-border/60`,children:(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{J(`chat`)},title:i?o(`activity:brand.returnToChat`,{name:i}):o(`activity:brand.returnToChatDefault`),className:G(`relative flex items-center justify-center overflow-hidden bg-foreground transition-shadow hover:shadow-[0_3px_12px_-2px_hsl(var(--primary)/0.5)]`,e?`w-full h-8`:`w-full h-11`),children:(0,Z.jsx)(`img`,{src:`/wrongstack.svg`,alt:``,"aria-hidden":`true`,draggable:!1,className:`ws-brand-logo h-full w-full`})})}),(0,Z.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-hidden flex flex-col items-center pt-2 pb-1`,children:[_.map(r=>(0,Z.jsx)(Bo,{compact:e,icon:r.icon,label:`${s(r.id,r.label)} (${La(r.id)})`,active:n&&t===r.id,badge:x(r.id),onClick:()=>Ra(r.id)},r.id)),y.length>0&&(0,Z.jsx)(`div`,{className:`my-1.5 h-px w-6 shrink-0 bg-border/70`}),y.map(t=>(0,Z.jsx)(Bo,{compact:e,icon:t.icon,label:s(t.id,t.label),active:r===t.id,onClick:()=>Ba(t.id)},t.id))]}),(0,Z.jsx)(`div`,{role:`status`,"aria-label":a?o(`activity:connection.connected`,`Connected`):o(`activity:connection.disconnected`,`Disconnected`),className:`flex items-center justify-center py-1`,children:(0,Z.jsx)(`span`,{className:G(`h-1.5 w-1.5 rounded-full`,a?`bg-success`:`bg-muted-foreground/40`),title:a?o(`activity:connection.connected`,`Connected`):o(`activity:connection.disconnected`,`Disconnected`)})}),(0,Z.jsx)(`div`,{className:`flex flex-col items-center shrink-0 pt-1 pb-2 border-t border-border/60`,children:(0,Z.jsx)(zo,{compact:e,monitorOpen:u,overflowPanels:v,overflowViews:b})})]})}function zo({compact:e=!1,monitorOpen:t,overflowPanels:n,overflowViews:r}){let{t:i}=H(),a=K(e=>e.activeActivity),o=K(e=>e.sidebarOpen),s=K(e=>e.currentView),c=K(e=>e.inspectorOpen),l=K(e=>e.inspectorTab),u=n.length+r.length,d=n.some(e=>o&&a===e.id),f=r.some(e=>s===e.id),p=d||f,m=e=>{let t=K.getState();t.inspectorOpen&&t.inspectorTab===e?t.setInspectorOpen(!1):(t.setInspectorTab(e),t.setInspectorOpen(!0))};return(0,Z.jsxs)(mo,{children:[(0,Z.jsx)(ho,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,"aria-label":u>0?i(`activity:menu.moreWithHidden`,{count:u}):i(`activity:menu.moreOptions`),title:e&&u>0?i(`activity:menu.moreCompactHidden`,{count:u}):i(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||p)&&`text-primary`),children:[(0,Z.jsx)(`span`,{className:`h-5 w-5 flex items-center justify-center`,children:(0,Z.jsx)(fi,{size:16})}),u>0&&(0,Z.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`,p?`bg-primary text-primary-foreground`:`bg-muted-foreground text-background`),children:u>9?`9+`:u}),t&&u===0&&(0,Z.jsx)(`span`,{className:`absolute top-1 right-1 h-1.5 w-1.5 rounded-full bg-primary`})]})}),(0,Z.jsxs)(vo,{side:`right`,align:`end`,sideOffset:8,className:`w-56`,children:[(0,Z.jsxs)(yo,{onSelect:()=>K.getState().setPaletteOpen(!0),children:[(0,Z.jsx)(xr,{size:16}),(0,Z.jsx)(`span`,{children:i(`activity:menu.commandPalette`)}),(0,Z.jsx)(wo,{children:`⌘K`})]}),(0,Z.jsxs)(yo,{onSelect:()=>K.getState().setShortcutsOpen(!0),children:[(0,Z.jsx)(Wn,{size:16}),(0,Z.jsx)(`span`,{children:i(`activity:menu.keyboardShortcuts`)}),(0,Z.jsx)(wo,{children:`?`})]}),n.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Co,{}),(0,Z.jsx)(So,{className:`text-[11px] uppercase text-muted-foreground`,children:i(`activity:menu.panels`)}),n.map(e=>(0,Z.jsxs)(yo,{onSelect:()=>J(e.id),children:[e.icon,(0,Z.jsx)(`span`,{children:i(`activity:nav.${e.id}`,e.label)}),o&&a===e.id?(0,Z.jsx)(`span`,{className:`ml-auto w-1.5 h-1.5 rounded-full bg-primary`}):(0,Z.jsx)(wo,{children:La(e.id)})]},e.id))]}),r.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Co,{}),(0,Z.jsx)(So,{className:`text-[11px] uppercase text-muted-foreground`,children:i(`activity:menu.views`)}),r.map(e=>(0,Z.jsxs)(yo,{onSelect:()=>Ba(e.id),children:[e.icon,(0,Z.jsx)(`span`,{children:i(`activity:nav.${e.id}`,e.label)}),s===e.id&&(0,Z.jsx)(`span`,{className:`ml-auto w-1.5 h-1.5 rounded-full bg-primary`})]},e.id))]}),(0,Z.jsx)(Co,{}),(0,Z.jsx)(So,{className:`text-[11px] uppercase text-muted-foreground`,children:i(`activity:nav.settings`,`Settings`)}),(0,Z.jsxs)(yo,{onSelect:()=>Ba(`settings`),children:[(0,Z.jsx)(kt,{size:16}),(0,Z.jsx)(`span`,{children:i(`activity:nav.settings`,`Settings`)}),(0,Z.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:i(`settings:tabs.general`,`overview`)})]}),[{icon:(0,Z.jsx)(Jn,{size:14}),label:`General`,tab:`general`},{icon:(0,Z.jsx)(Fi,{size:14}),label:`Provider`,tab:`provider`},{icon:(0,Z.jsx)(jr,{size:14}),label:`Agent`,tab:`agent`},{icon:(0,Z.jsx)(at,{size:14}),label:`Execution`,tab:`execution`},{icon:(0,Z.jsx)(Pr,{size:14}),label:`Fallbacks`,tab:`fallbacks`}].map(({icon:e,label:t,tab:n})=>(0,Z.jsxs)(yo,{onSelect:()=>{K.getState().setSettingsActiveTab(n),Ba(`settings`)},children:[e,(0,Z.jsx)(`span`,{children:i(`settings:tabs.${n}`,t)})]},n)),(0,Z.jsx)(Co,{}),(0,Z.jsx)(So,{className:`text-[11px] uppercase text-muted-foreground`,children:i(`activity:menu.monitors`)}),(0,Z.jsxs)(yo,{onSelect:()=>m(`fleet`),children:[(0,Z.jsx)(pi,{size:16}),(0,Z.jsx)(`span`,{children:i(`activity:menu.fleetMonitor`)}),c&&l===`fleet`?(0,Z.jsx)(`span`,{className:`ml-auto w-1.5 h-1.5 rounded-full bg-primary`}):(0,Z.jsx)(wo,{children:`⇧⌘M`})]}),(0,Z.jsxs)(yo,{onSelect:()=>m(`sideEffects`),children:[(0,Z.jsx)(at,{size:16}),(0,Z.jsx)(`span`,{children:i(`activity:inspector.tabAudit`)}),c&&l===`sideEffects`?(0,Z.jsx)(`span`,{className:`ml-auto h-1.5 w-1.5 rounded-full bg-primary`}):null]})]})]})}function Bo({compact:e=!1,icon:t,label:n,active:r,badge:i,onClick:a}){return(0,Z.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,Z.jsx)(`span`,{className:`absolute left-0 top-1/2 -translate-y-1/2 w-0.5 h-6 rounded-r-full bg-primary`}),(0,Z.jsx)(`span`,{className:`h-5 w-5 shrink-0`,children:t}),i!==void 0&&i>0&&(0,Z.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 Vo=[{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:`/doctor`,category:`Config`,description:`Check config defaults; use /doctor fix to repair and back up`},{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}],Ho=[`Run`,`Session`,`Inspect`,`Agent`,`Config`,`App`];function Uo(e){let t=e.toLowerCase();return t===`/`||t===``?Vo.filter(e=>!e.hidden):Vo.filter(e=>e.name.startsWith(t)||(e.aliases?.some(e=>e.startsWith(t))??!1))}function Wo(e,t){let n=t-1;for(;n>=0;){let r=k(e[n]);if(r===`@`){let r=n>0?e[n-1]:``;return n===0||/\s/.test(r??``)?{start:n,query:e.slice(n+1,t)}:null}if(/\s/.test(r))return null;n--}return null}function Go(e){let t=e.thinkingLog;if(!t)return``;if(t.replayed)return`replay`;let n=Math.max(.1,t.durationMs/1e3);return`${n.toFixed(+(n<10))}s`}function Ko(e){let t=Math.max(3,...Array.from(e.matchAll(/`+/g),e=>e[0].length+1));return"`".repeat(t)}function qo(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function Jo(){let e=q.getState().messages,t=[],n=new Date().toISOString().slice(0,19).replace(/[:T]/g,`-`),r=N.getState().projectName||`chat`,i=N.getState().session?.title||r;t.push(`# ${i} — chat export`),t.push(`*Exported: ${new Date().toISOString()}*`),t.push(``);for(let n of e)if(n.thinkingLog){let e=Ko(n.thinkingLog.text),r=n.thinkingLog.text.split(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ws-client-BR51gfnV.js","assets/rolldown-runtime-hePW80VL.js","assets/react-core-BNmTiJ-I.js","assets/vendor-BshlG0z-.js","assets/xyflow-BNn76cbK.js","assets/xyflow-DLioOiRN.css","assets/markdown-BP6Z3HKc.js","assets/vendor-BShi5_Dg.css","assets/i18n-tRUjoMoU.js","assets/chat-BITJe8-v.js","assets/commandPalette-BovBiPec.js","assets/common-BBHmIHQW.js","assets/setup-qooXjj4V.js","assets/toasts-DZ6HdKgG.js","assets/vite-preload-Czpn1I53.js","assets/utils-BpBOwXlT.js","assets/ui-store-CLXDcLPI.js","assets/AnalyticsDashboard-yAGcObTd.js","assets/stores-B7GcARdp.js","assets/chat-store-BbBGSliF.js","assets/codemap-activity-store-CWi-Yd9Z.js","assets/mailbox-store-yydAVjyj.js","assets/AgentRosterView-BXURTwLP.js","assets/view-navigation-CvWJeGMc.js","assets/ModelPicker-CXQR8UbH.js","assets/useWebSocket-L5s7ggJm.js","assets/codemap-index-store-3M7F08K_.js","assets/roster-ws-B4xVrXos.js","assets/AudienceMemoryPanel-BwtB_jYJ.js","assets/dialog-xJxaQi60.js","assets/button-rqi3MczV.js","assets/input-ClZR-odw.js","assets/shared-D8dubdNH.js","assets/AgentRosterView-Ce7myLNH.css","assets/ChangesView-BgC27G9n.js","assets/monaco-_kWjHrlo.js","assets/monaco-Bowa0-zp.css","assets/empty-state-BxilAuC3.js","assets/monaco-theme-Dmx6JuoU.js","assets/ChronicleDashboard-DVor6J-y.js","assets/CodeEditor-Dk2WJQks.js","assets/MemoryDrawer-CyN_6CRo.js","assets/CodeMap-CjWRQ37U.js","assets/DebugDashboard-B-aDaDrO.js","assets/DesignGalleryView-Ex3zW5ci.js","assets/GoalView-CBDc5nCD.js","assets/ConfirmModal-C_KAUjBK.js","assets/KanbanView-azjPGLmM.js","assets/SddFlowGraph-CJjawf9r.js","assets/MailboxDetailView-BXW9zqle.js","assets/PromptJournalView-C6O40uTv.js","assets/RefreshDebugView-DDFD26EI.js","assets/SageTabs-Cx299O-q.js","assets/RequirementIntakeView-BpFyFOlB.js","assets/SddHub-CmSlkvkM.js","assets/SessionsDashboard-7C6Fj9pK.js","assets/SessionList-BWoK6Ro5.js","assets/SessionInspectView-CtrlRlJu.js","assets/SkillDetailView-C5nOcysX.js","assets/TechStackView-DkNjeYPK.js","assets/DeadCodeScanPanel-CcPRcYm0.js","assets/ChimeraReviewsView-BZ3kmsEA.js","assets/SetupScreen-IzaqHJ_O.js","assets/ProcessMonitor-CBIQkbLx.js","assets/TerminalPanel-CTr-KAnH.js","assets/xterm-BWzBEEhg.js","assets/xterm-BrP-ENHg.css","assets/CronJobsPanel-CGq8lhRJ.js","assets/QueuePanel-CutrvgTH.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,A as n,B as r,C as i,Ct as a,D as o,E as s,F as c,Ft as l,G as u,H as d,Ht as f,I as p,J as m,K as h,Lt as g,M as _,N as v,Nt as y,O as b,Ot as x,P as S,Q as C,R as w,S as T,T as E,Tt as D,U as O,Ut as k,V as A,W as j,X as M,Z as N,_ as P,a as F,at as I,b as L,et as R,f as ee,g as te,h as z,ht as ne,i as re,it as ie,j as ae,k as oe,kt as se,m as ce,nt as le,o as ue,ot as de,p as fe,q as B,rt as pe,st as me,t as V,tt as he,ut as ge,v as _e,vt as ve,w as ye,x as be,y as xe,yt as Se,z as Ce}from"./ws-client-BR51gfnV.js";import{i as we,n as Te,t as Ee}from"./react-core-BNmTiJ-I.js";import{$ as De,$i as Oe,$r as ke,$t as Ae,A as je,Aa as Me,An as Ne,Ar as Pe,B as Fe,Bi as Ie,Bn as Le,Br as Re,Bt as ze,C as Be,Ca as Ve,Ci as He,Cn as Ue,D as We,Da as Ge,Di as Ke,Dn as qe,Dt as Je,E as Ye,Ea as Xe,Ei as Ze,En as Qe,Er as $e,Et as et,F as tt,Fa as H,Fn as nt,Fr as rt,Ft as it,G as at,Gi as ot,Gn as st,Gt as ct,H as lt,Hi as ut,Hn as dt,Hr as ft,I as pt,Ii as mt,In as ht,Ir as gt,J as _t,Ji as vt,Jn as yt,Jr as bt,Jt as xt,K as St,Ki as Ct,Kn as wt,L as Tt,Li as Et,Ln as Dt,Lr as Ot,Lt as kt,M as At,Ma as jt,Mn as Mt,Mr as Nt,Mt as Pt,N as Ft,Ni as It,Nn as Lt,Nr as Rt,Nt as zt,O as Bt,Oi as Vt,On as Ht,Or as Ut,Ot as Wt,P as Gt,Pn as Kt,Pt as qt,Q as Jt,Qn as Yt,Qr as Xt,Qt as Zt,R as Qt,Ra as U,Ri as $t,Rn as en,Rr as tn,Rt as nn,S as rn,Sa as an,Si as on,St as sn,T as cn,Tr as ln,U as un,Ui as dn,Un as fn,Ur as pn,Ut as mn,V as hn,Vi as gn,Vn as _n,Vt as vn,Wi as yn,Wn as bn,Wr as xn,Wt as Sn,X as Cn,Xi as wn,Xt as Tn,Y as En,Yi as Dn,Yn as On,Yr as kn,Yt as An,Z as jn,Zi as Mn,Zn as Nn,Zr as Pn,Zt as Fn,_ as In,_a as Ln,_i as Rn,_n as zn,_r as Bn,_t as Vn,a as Hn,an as Un,ar as Wn,at as Gn,b as Kn,ba as qn,bn as Jn,br as Yn,bt as Xn,c as Zn,ca as Qn,ci as $n,cn as er,cr as tr,ct as nr,d as rr,da as ir,di as ar,dn as or,dr as sr,dt as cr,ea as lr,ei as ur,er as dr,et as fr,f as pr,fa as mr,fi as hr,fn as gr,fr as _r,ft as vr,g as yr,ga as br,gi as xr,gn as Sr,gr as Cr,gt as wr,h as Tr,ha as Er,hi as Dr,hr as Or,ht as kr,i as Ar,ia as jr,ii as Mr,in as Nr,ir as Pr,j as Fr,jn as Ir,k as Lr,ki as Rr,kn as zr,kr as Br,kt as Vr,l as Hr,la as Ur,li as Wr,ln as Gr,lt as Kr,m as qr,mr as Jr,na as Yr,ni as Xr,nn as Zr,nt as Qr,o as $r,oa as ei,oi as ti,on as ni,or as ri,p as ii,pa as ai,pi as oi,pn as si,pt as ci,q as li,qi as ui,qr as di,ri as fi,rr as pi,rt as mi,s as hi,si as gi,sn as _i,sr as vi,st as yi,ta as bi,tn as xi,u as Si,ua as Ci,ui as wi,un as Ti,ur as Ei,ut as Di,v as Oi,va as ki,vn as Ai,vr as ji,vt as Mi,w as Ni,wi as Pi,wn as Fi,wr as Ii,wt as Li,x as Ri,xa as zi,xn as Bi,xr as Vi,xt as Hi,y as Ui,ya as Wi,yi as Gi,yn as Ki,yr as qi,yt as Ji,z as Yi,zi as Xi,zr as Zi,zt as Qi}from"./vendor-BshlG0z-.js";import{i as $i,n as W,r as ea}from"./i18n-tRUjoMoU.js";import{t as ta}from"./vite-preload-Czpn1I53.js";import{a as na,c as ra,d as ia,f as aa,h as oa,i as sa,l as ca,m as la,n as ua,o as da,p as fa,r as pa,s as ma,t as ha,u as ga}from"./useWebSocket-L5s7ggJm.js";import{t as G}from"./utils-BpBOwXlT.js";import{a as _a,i as va,n as K,r as ya,t as ba}from"./ui-store-CLXDcLPI.js";import{t as q}from"./chat-store-BbBGSliF.js";import{C as xa,_ as Sa,b as Ca,d as wa,g as Ta,i as Ea,m as Da,p as Oa,s as ka,t as Aa,v as ja,x as Ma,y as Na}from"./stores-B7GcARdp.js";import{n as Pa,r as Fa,t as Ia}from"./mailbox-store-yydAVjyj.js";import{a as La,i as Ra,n as za,o as J,r as Ba,s as Va,t as Ha}from"./view-navigation-CvWJeGMc.js";import{a as Ua,i as Wa,n as Ga,o as Ka,r as qa,t as Ja}from"./dialog-xJxaQi60.js";import{t as Y}from"./button-rqi3MczV.js";import{t as Ya}from"./input-ClZR-odw.js";import{i as Xa,n as Za,o as Qa,r as $a,t as eo}from"./ConfirmModal-C_KAUjBK.js";import{n as to,r as no,t as ro}from"./ModelPicker-CXQR8UbH.js";import{c as io,u as ao}from"./markdown-BP6Z3HKc.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),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var X=e(we(),1),oo=e(Te(),1),so=new Set([`chat`,`settings`,`goal`,`kanban`,`sddhub`,`files`,`changes`,`sessions`,`setup`,`skill`,`roster`,`mailbox`,`debug`,`design-gallery`,`refresh-debug`,`analytics`]),co=new Set([`goal`,`fleet`,`work`,`worktrees`,`collab`]),lo=new Set([`todos`,`tasks`,`plan`]);function uo(){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 fo(e){typeof window>`u`||window.wrongstackDesktopHost?.setReady?.(e)}function po(e,t,n){typeof window>`u`||typeof e!=`string`||window.wrongstackDesktopHost?.ackCommand?.(e,t,n)}var Z=Ee(),mo=Yi,ho=un,go=X.forwardRef(({className:e,inset:t,children:n,...r},i)=>(0,Z.jsxs)(lt,{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,Z.jsx)(ot,{className:`ml-auto h-4 w-4`})]}));go.displayName=lt.displayName;var _o=X.forwardRef(({className:e,...t},n)=>(0,Z.jsx)(hn,{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}));_o.displayName=hn.displayName;var vo=X.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,Z.jsx)(Tt,{children:(0,Z.jsx)(Ft,{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})}));vo.displayName=Ft.displayName;var yo=X.forwardRef(({className:e,inset:t,...n},r)=>(0,Z.jsx)(Gt,{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}));yo.displayName=Gt.displayName;var bo=X.forwardRef(({className:e,children:t,checked:n,...r},i)=>(0,Z.jsxs)(At,{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,Z.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,Z.jsx)(tt,{children:(0,Z.jsx)(ui,{className:`h-4 w-4`})})}),t]}));bo.displayName=At.displayName;var xo=X.forwardRef(({className:e,children:t,...n},r)=>(0,Z.jsxs)(Qt,{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,Z.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,Z.jsx)(tt,{children:(0,Z.jsx)(Vt,{className:`h-2 w-2 fill-current`})})}),t]}));xo.displayName=Qt.displayName;var So=X.forwardRef(({className:e,inset:t,...n},r)=>(0,Z.jsx)(pt,{ref:r,className:G(`px-2 py-1.5 text-sm font-semibold`,t&&`pl-8`,e),...n}));So.displayName=pt.displayName;var Co=X.forwardRef(({className:e,...t},n)=>(0,Z.jsx)(Fe,{ref:n,className:G(`-mx-1 my-1 h-px bg-muted`,e),...t}));Co.displayName=Fe.displayName;var wo=({className:e,...t})=>(0,Z.jsx)(`span`,{className:G(`ml-auto text-xs tracking-widest opacity-60`,e),...t});wo.displayName=`DropdownMenuShortcut`;var To=[{id:`chat`,icon:(0,Z.jsx)(Lt,{size:16}),label:`Session`},{id:`files`,icon:(0,Z.jsx)(Rt,{size:16}),label:`Files`},{id:`changes`,icon:(0,Z.jsx)(qi,{size:16}),label:`Changes`},{id:`mailbox`,icon:(0,Z.jsx)(Le,{size:16}),label:`Mailbox`},{id:`skills`,icon:(0,Z.jsx)(et,{size:16}),label:`Skills`},{id:`design`,icon:(0,Z.jsx)(Jn,{size:16}),label:`Design Studio`}],Eo=[{id:`roster`,icon:(0,Z.jsx)(jr,{size:16}),label:`Agent Roster`},{id:`sddhub`,icon:(0,Z.jsx)(Cn,{size:16}),label:`SDD`},{id:`kanban`,icon:(0,Z.jsx)(Rn,{size:16}),label:`Kanban`},{id:`goal`,icon:(0,Z.jsx)(Zt,{size:16}),label:`Goal`},{id:`codemap`,icon:(0,Z.jsx)(Fi,{size:16}),label:`CodeMap`},{id:`techstack`,icon:(0,Z.jsx)(Yr,{size:16}),label:`TechStack`},{id:`chronicle`,icon:(0,Z.jsx)(Dn,{size:16}),label:`Chronicle`},{id:`prompts`,icon:(0,Z.jsx)(mn,{size:16}),label:`Prompt Journal`},{id:`chimera`,icon:(0,Z.jsx)(qt,{size:16}),label:`Chimera Reviews`},{id:`intake`,icon:(0,Z.jsx)(Ze,{size:16}),label:`Requirements`},{id:`memory`,icon:(0,Z.jsx)(bi,{size:16}),label:`Memory`}],Do=[`chat`,`files`,`changes`,`mailbox`],Oo=[...Do,`skills`,`design`],ko=132,Ao=38,jo=165,Mo=46;function No(e,t){let n=To.length+Eo.length,r=Number.isFinite(e)?e:720,i=t?ko:jo,a=t?Ao:Mo,o=Math.floor((r-i)/a);return Math.max(Do.length,Math.min(n,o))}function Po(e){let t=To.length+Eo.length,n=Math.max(Do.length,Math.min(t,Math.floor(e))),r=Math.min(To.length,n),i=new Set(Oo.slice(0,r)),a=To.map(e=>e.id).filter(e=>i.has(e)),o=To.map(e=>e.id).filter(e=>!i.has(e)),s=Math.max(0,n-a.length),c=Eo.slice(0,s).map(e=>e.id),l=new Set(c);return{visiblePanelIds:a,overflowPanelIds:o,visibleViewIds:c,overflowViewIds:Eo.map(e=>e.id).filter(e=>!l.has(e))}}var Fo=To.map(e=>e.id);function Io(){return typeof window>`u`?720:window.visualViewport?.height??window.innerHeight}function Lo(e){let[t,n]=(0,X.useState)(Io);return(0,X.useEffect)(()=>{if(typeof window>`u`)return;let e=()=>n(Io());return e(),window.addEventListener(`resize`,e),window.visualViewport?.addEventListener(`resize`,e),()=>{window.removeEventListener(`resize`,e),window.visualViewport?.removeEventListener(`resize`,e)}},[]),No(t,e)}function Ro({desktopShell:e=!1}){let t=K(e=>e.activeActivity),n=K(e=>e.sidebarOpen),r=K(e=>e.currentView),i=N(e=>e.projectName),a=R(e=>e.wsConnected),{t:o}=H(),s=(e,t)=>o(`activity:nav.${e}`,t),c=Fa(Pa),l=P(e=>e.openTabIds.length),u=K(e=>e.inspectorOpen),d=Lo(e),f=(0,X.useMemo)(()=>Po(d),[d]),p=(0,X.useMemo)(()=>new Set(f.visiblePanelIds),[f.visiblePanelIds]),m=(0,X.useMemo)(()=>new Set(f.overflowPanelIds),[f.overflowPanelIds]),h=(0,X.useMemo)(()=>new Set(f.visibleViewIds),[f.visibleViewIds]),g=(0,X.useMemo)(()=>new Set(f.overflowViewIds),[f.overflowViewIds]),_=To.filter(e=>p.has(e.id)),v=To.filter(e=>m.has(e.id)),y=Eo.filter(e=>h.has(e.id)),b=Eo.filter(e=>g.has(e.id)),x=e=>{if(e===`mailbox`)return c||void 0;if(e===`chat`)return l>0?l:void 0};return(0,Z.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,Z.jsx)(`div`,{className:`flex flex-col items-center shrink-0 border-b border-border/60`,children:(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{J(`chat`)},title:i?o(`activity:brand.returnToChat`,{name:i}):o(`activity:brand.returnToChatDefault`),className:G(`relative flex items-center justify-center overflow-hidden bg-foreground transition-shadow hover:shadow-[0_3px_12px_-2px_hsl(var(--primary)/0.5)]`,e?`w-full h-8`:`w-full h-11`),children:(0,Z.jsx)(`img`,{src:`/wrongstack.svg`,alt:``,"aria-hidden":`true`,draggable:!1,className:`ws-brand-logo h-full w-full`})})}),(0,Z.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-hidden flex flex-col items-center pt-2 pb-1`,children:[_.map(r=>(0,Z.jsx)(Bo,{compact:e,icon:r.icon,label:`${s(r.id,r.label)} (${La(r.id)})`,active:n&&t===r.id,badge:x(r.id),onClick:()=>Ra(r.id)},r.id)),y.length>0&&(0,Z.jsx)(`div`,{className:`my-1.5 h-px w-6 shrink-0 bg-border/70`}),y.map(t=>(0,Z.jsx)(Bo,{compact:e,icon:t.icon,label:s(t.id,t.label),active:r===t.id,onClick:()=>Ba(t.id)},t.id))]}),(0,Z.jsx)(`div`,{role:`status`,"aria-label":a?o(`activity:connection.connected`,`Connected`):o(`activity:connection.disconnected`,`Disconnected`),className:`flex items-center justify-center py-1`,children:(0,Z.jsx)(`span`,{className:G(`h-1.5 w-1.5 rounded-full`,a?`bg-success`:`bg-muted-foreground/40`),title:a?o(`activity:connection.connected`,`Connected`):o(`activity:connection.disconnected`,`Disconnected`)})}),(0,Z.jsx)(`div`,{className:`flex flex-col items-center shrink-0 pt-1 pb-2 border-t border-border/60`,children:(0,Z.jsx)(zo,{compact:e,monitorOpen:u,overflowPanels:v,overflowViews:b})})]})}function zo({compact:e=!1,monitorOpen:t,overflowPanels:n,overflowViews:r}){let{t:i}=H(),a=K(e=>e.activeActivity),o=K(e=>e.sidebarOpen),s=K(e=>e.currentView),c=K(e=>e.inspectorOpen),l=K(e=>e.inspectorTab),u=n.length+r.length,d=n.some(e=>o&&a===e.id),f=r.some(e=>s===e.id),p=d||f,m=e=>{let t=K.getState();t.inspectorOpen&&t.inspectorTab===e?t.setInspectorOpen(!1):(t.setInspectorTab(e),t.setInspectorOpen(!0))};return(0,Z.jsxs)(mo,{children:[(0,Z.jsx)(ho,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,"aria-label":u>0?i(`activity:menu.moreWithHidden`,{count:u}):i(`activity:menu.moreOptions`),title:e&&u>0?i(`activity:menu.moreCompactHidden`,{count:u}):i(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||p)&&`text-primary`),children:[(0,Z.jsx)(`span`,{className:`h-5 w-5 flex items-center justify-center`,children:(0,Z.jsx)(fi,{size:16})}),u>0&&(0,Z.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`,p?`bg-primary text-primary-foreground`:`bg-muted-foreground text-background`),children:u>9?`9+`:u}),t&&u===0&&(0,Z.jsx)(`span`,{className:`absolute top-1 right-1 h-1.5 w-1.5 rounded-full bg-primary`})]})}),(0,Z.jsxs)(vo,{side:`right`,align:`end`,sideOffset:8,className:`w-56`,children:[(0,Z.jsxs)(yo,{onSelect:()=>K.getState().setPaletteOpen(!0),children:[(0,Z.jsx)(xr,{size:16}),(0,Z.jsx)(`span`,{children:i(`activity:menu.commandPalette`)}),(0,Z.jsx)(wo,{children:`⌘K`})]}),(0,Z.jsxs)(yo,{onSelect:()=>K.getState().setShortcutsOpen(!0),children:[(0,Z.jsx)(Wn,{size:16}),(0,Z.jsx)(`span`,{children:i(`activity:menu.keyboardShortcuts`)}),(0,Z.jsx)(wo,{children:`?`})]}),n.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Co,{}),(0,Z.jsx)(So,{className:`text-[11px] uppercase text-muted-foreground`,children:i(`activity:menu.panels`)}),n.map(e=>(0,Z.jsxs)(yo,{onSelect:()=>J(e.id),children:[e.icon,(0,Z.jsx)(`span`,{children:i(`activity:nav.${e.id}`,e.label)}),o&&a===e.id?(0,Z.jsx)(`span`,{className:`ml-auto w-1.5 h-1.5 rounded-full bg-primary`}):(0,Z.jsx)(wo,{children:La(e.id)})]},e.id))]}),r.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Co,{}),(0,Z.jsx)(So,{className:`text-[11px] uppercase text-muted-foreground`,children:i(`activity:menu.views`)}),r.map(e=>(0,Z.jsxs)(yo,{onSelect:()=>Ba(e.id),children:[e.icon,(0,Z.jsx)(`span`,{children:i(`activity:nav.${e.id}`,e.label)}),s===e.id&&(0,Z.jsx)(`span`,{className:`ml-auto w-1.5 h-1.5 rounded-full bg-primary`})]},e.id))]}),(0,Z.jsx)(Co,{}),(0,Z.jsx)(So,{className:`text-[11px] uppercase text-muted-foreground`,children:i(`activity:nav.settings`,`Settings`)}),(0,Z.jsxs)(yo,{onSelect:()=>Ba(`settings`),children:[(0,Z.jsx)(kt,{size:16}),(0,Z.jsx)(`span`,{children:i(`activity:nav.settings`,`Settings`)}),(0,Z.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:i(`settings:tabs.general`,`overview`)})]}),[{icon:(0,Z.jsx)(Jn,{size:14}),label:`General`,tab:`general`},{icon:(0,Z.jsx)(Fi,{size:14}),label:`Provider`,tab:`provider`},{icon:(0,Z.jsx)(jr,{size:14}),label:`Agent`,tab:`agent`},{icon:(0,Z.jsx)(at,{size:14}),label:`Execution`,tab:`execution`},{icon:(0,Z.jsx)(Pr,{size:14}),label:`Fallbacks`,tab:`fallbacks`}].map(({icon:e,label:t,tab:n})=>(0,Z.jsxs)(yo,{onSelect:()=>{K.getState().setSettingsActiveTab(n),Ba(`settings`)},children:[e,(0,Z.jsx)(`span`,{children:i(`settings:tabs.${n}`,t)})]},n)),(0,Z.jsx)(Co,{}),(0,Z.jsx)(So,{className:`text-[11px] uppercase text-muted-foreground`,children:i(`activity:menu.monitors`)}),(0,Z.jsxs)(yo,{onSelect:()=>m(`fleet`),children:[(0,Z.jsx)(pi,{size:16}),(0,Z.jsx)(`span`,{children:i(`activity:menu.fleetMonitor`)}),c&&l===`fleet`?(0,Z.jsx)(`span`,{className:`ml-auto w-1.5 h-1.5 rounded-full bg-primary`}):(0,Z.jsx)(wo,{children:`⇧⌘M`})]}),(0,Z.jsxs)(yo,{onSelect:()=>m(`sideEffects`),children:[(0,Z.jsx)(at,{size:16}),(0,Z.jsx)(`span`,{children:i(`activity:inspector.tabAudit`)}),c&&l===`sideEffects`?(0,Z.jsx)(`span`,{className:`ml-auto h-1.5 w-1.5 rounded-full bg-primary`}):null]})]})]})}function Bo({compact:e=!1,icon:t,label:n,active:r,badge:i,onClick:a}){return(0,Z.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,Z.jsx)(`span`,{className:`absolute left-0 top-1/2 -translate-y-1/2 w-0.5 h-6 rounded-r-full bg-primary`}),(0,Z.jsx)(`span`,{className:`h-5 w-5 shrink-0`,children:t}),i!==void 0&&i>0&&(0,Z.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 Vo=[{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:`/doctor`,category:`Config`,description:`Check config defaults; use /doctor fix to repair and back up`},{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}],Ho=[`Run`,`Session`,`Inspect`,`Agent`,`Config`,`App`];function Uo(e){let t=e.toLowerCase();return t===`/`||t===``?Vo.filter(e=>!e.hidden):Vo.filter(e=>e.name.startsWith(t)||(e.aliases?.some(e=>e.startsWith(t))??!1))}function Wo(e,t){let n=t-1;for(;n>=0;){let r=k(e[n]);if(r===`@`){let r=n>0?e[n-1]:``;return n===0||/\s/.test(r??``)?{start:n,query:e.slice(n+1,t)}:null}if(/\s/.test(r))return null;n--}return null}function Go(e){let t=e.thinkingLog;if(!t)return``;if(t.replayed)return`replay`;let n=Math.max(.1,t.durationMs/1e3);return`${n.toFixed(+(n<10))}s`}function Ko(e){let t=Math.max(3,...Array.from(e.matchAll(/`+/g),e=>e[0].length+1));return"`".repeat(t)}function qo(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function Jo(){let e=q.getState().messages,t=[],n=new Date().toISOString().slice(0,19).replace(/[:T]/g,`-`),r=N.getState().projectName||`chat`,i=N.getState().session?.title||r;t.push(`# ${i} — chat export`),t.push(`*Exported: ${new Date().toISOString()}*`),t.push(``);for(let n of e)if(n.thinkingLog){let e=Ko(n.thinkingLog.text),r=n.thinkingLog.text.split(`
|
|
3
3
|
`).length;t.push(`### 🧠 Thinking process — iteration ${n.thinkingLog.iteration}`),t.push(``),t.push(`_${Go(n)} · ${r} line${r===1?``:`s`}_`),t.push(``),t.push(`<details><summary>Log</summary>`),t.push(``),t.push(`${e}text`),t.push(n.thinkingLog.text),t.push(e),t.push(``),t.push(`</details>`),t.push(``)}else if(n.role===`user`)t.push(`## 👤 User`),t.push(``),t.push(n.content),t.push(``);else if(n.role===`assistant`)t.push(`## 🤖 Assistant`),t.push(``),t.push(n.content),t.push(``);else if(n.role===`tool`){let e=n.isError?`❌`:n.toolResult===void 0?`⏳`:`✅`;t.push(`### 🔧 Tool: \`${n.toolName??`unknown`}\` ${e}`),n.toolInput!==void 0&&(t.push("```json"),t.push(JSON.stringify(n.toolInput,null,2)),t.push("```")),n.toolResult&&(t.push(`<details><summary>Output</summary>`),t.push(``),t.push("```"),t.push(n.toolResult),t.push("```"),t.push(`</details>`)),t.push(``)}let a=new Blob([t.join(`
|
|
4
4
|
`)],{type:`text/markdown`}),o=URL.createObjectURL(a),s=document.createElement(`a`);s.href=o,s.download=`${r.toLowerCase().replace(/[^a-z0-9]+/g,`-`)}-chat-${n}.md`,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(o)}function Yo(){let e=q.getState().messages,t=N.getState(),n=t.projectName||`chat`,r=qo(t.session?.title||n),i=new Date().toISOString().slice(0,19).replace(/[:T]/g,`-`),a=e.map(e=>{if(e.thinkingLog){let t=e.thinkingLog.text.split(`
|
|
5
5
|
`).length;return`
|
|
@@ -70,7 +70,7 @@ Type while the agent is running to queue messages; they are sent automatically w
|
|
|
70
70
|
`)})]})}let i=e.url;if(typeof i==`string`){let t=e.method??`GET`;return(0,Z.jsxs)(`div`,{className:`rounded-lg border bg-background/40 px-3 py-2 text-xs font-mono`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:t.toUpperCase()}),` `,(0,Z.jsx)(`span`,{className:`break-all`,children:i})]})}}return(0,Z.jsxs)(`div`,{className:`p-3 rounded-lg bg-muted/50 border text-xs font-mono`,children:[(0,Z.jsx)(`div`,{className:`text-muted-foreground mb-2`,children:n(`confirm.inputLabel`)}),(0,Z.jsx)(`pre`,{className:`whitespace-pre-wrap break-all max-h-60 overflow-auto`,children:JSON.stringify(t,null,2)})]})}function ps(){let{showConfirmDialog:e,confirmInfo:t,hideConfirm:n}=K(Me(e=>({showConfirmDialog:e.showConfirmDialog,confirmInfo:e.confirmInfo,hideConfirm:e.hideConfirm}))),{t:r}=H(),i=W(e=>e.yolo),a=W(e=>e.set),{sendConfirm:o,updatePrefs:s}=ha(),c=(0,X.useRef)(null),l=(0,X.useRef)(!1);(0,X.useEffect)(()=>{e&&t&&(l.current=!1)},[e,t?.id,t]);let u=e=>{l.current||(l.current=!0,t&&o(t.id,e),n())},d=e=>{if(!e){if(t){u(`no`);return}n()}},f=()=>{t?.boundaryReason||(a({yolo:!0}),s({yolo:!0}))};if((0,X.useEffect)(()=>{!e||!t||!i||t.boundaryReason||u(`yes`)},[e,t?.id,t?.decisionSource,t?.riskTier,i]),(0,X.useEffect)(()=>{if(!e)return;let t=e=>{let t=e.target?.tagName?.toLowerCase();t!==`input`&&t!==`textarea`&&(e.key===`y`||e.key===`Y`?(e.preventDefault(),u(`yes`)):e.key===`n`||e.key===`N`||e.key===`Escape`?(e.preventDefault(),u(`no`)):e.key===`a`||e.key===`A`?(e.preventDefault(),u(`always`)):(e.key===`d`||e.key===`D`)&&(e.preventDefault(),u(`deny`)))};return window.addEventListener(`keydown`,t),c.current?.focus(),()=>window.removeEventListener(`keydown`,t)},[e,t?.id]),!t)return null;let p=ds(t.toolName),m=/edit|write/i.test(t.toolName),h=t.riskTier??`standard`;return(0,Z.jsx)(Ja,{open:e,onOpenChange:d,children:(0,Z.jsxs)(Ga,{className:`sm:max-w-2xl max-h-[min(88dvh,760px)] overflow-hidden !flex flex-col border-warning/50`,ref:c,tabIndex:-1,children:[(0,Z.jsxs)(Ua,{className:`shrink-0`,children:[(0,Z.jsxs)(Ka,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(qt,{className:`h-5 w-5 text-warning animate-pulse`}),r(`confirm.title`,{tool:t.toolName})]}),(0,Z.jsx)(qa,{children:t.boundaryReason??r(m?`confirm.descriptionEdit`:`confirm.descriptionTool`)})]}),(0,Z.jsxs)(`div`,{className:`py-2 pr-1 space-y-3 overflow-y-auto overscroll-contain min-h-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 p-3 rounded-lg bg-muted`,children:[(0,Z.jsx)(p,{className:`h-5 w-5 text-muted-foreground`}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`font-medium font-mono truncate`,children:t.toolName}),(0,Z.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[r(m?`confirm.fileModification`:`confirm.toolExecution`),` —`,` `,r(`confirm.riskSuffix`,{risk:h})]})]})]}),t.input!==void 0&&(0,Z.jsx)(fs,{toolName:t.toolName,input:t.input}),t.suggestedPattern&&(0,Z.jsxs)(`div`,{className:`flex items-start gap-2 p-3 rounded-lg bg-warning/10 border border-warning/20`,children:[(0,Z.jsx)(Kr,{className:`h-4 w-4 text-warning mt-0.5 shrink-0`}),(0,Z.jsxs)(`div`,{className:`text-sm min-w-0`,children:[(0,Z.jsx)(`div`,{className:`font-medium text-warning`,children:r(`confirm.trustSuggestionTitle`)}),(0,Z.jsx)(`div`,{className:`font-mono text-xs mt-1 break-all`,children:t.suggestedPattern}),(0,Z.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:r(`confirm.trustSuggestionHint`)})]})]}),!i&&!t.boundaryReason&&(0,Z.jsxs)(`div`,{className:`flex items-start gap-2 p-3 rounded-lg bg-primary/5 border border-primary/20`,children:[(0,Z.jsx)(at,{className:`h-4 w-4 text-primary mt-0.5 shrink-0`}),(0,Z.jsxs)(`div`,{className:`text-sm min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`font-medium`,children:r(`confirm.skipApprovalsTitle`)}),(0,Z.jsx)(`div`,{className:`text-xs text-muted-foreground mt-0.5`,children:r(`confirm.skipApprovalsHint`)})]}),(0,Z.jsx)(Y,{variant:`outline`,size:`sm`,onClick:f,title:r(`confirm.enableYoloTitle`),className:`shrink-0`,children:r(`confirm.enableYoloBtn`)})]})]}),(0,Z.jsxs)(Wa,{className:`gap-2 sm:gap-2 flex-wrap shrink-0`,children:[(0,Z.jsxs)(Y,{variant:`outline`,size:`sm`,onClick:()=>u(`deny`),title:r(`confirm.denyAlwaysTitle`),children:[r(`confirm.denyAlways`),` `,(0,Z.jsx)(`kbd`,{className:`ml-1 text-[10px] border rounded px-1 bg-background`,children:`d`})]}),(0,Z.jsxs)(Y,{variant:`outline`,size:`sm`,onClick:()=>u(`no`),title:r(`confirm.noTitle`),children:[r(`action.no`),` `,(0,Z.jsx)(`kbd`,{className:`ml-1 text-[10px] border rounded px-1 bg-background`,children:`n`})]}),(0,Z.jsxs)(Y,{variant:`outline`,size:`sm`,onClick:()=>u(`always`),title:r(`confirm.alwaysTitle`),children:[r(`action.always`),` `,(0,Z.jsx)(`kbd`,{className:`ml-1 text-[10px] border rounded px-1 bg-background`,children:`a`})]}),(0,Z.jsxs)(Y,{size:`sm`,onClick:()=>u(`yes`),title:r(`confirm.yesTitle`),children:[r(`action.yes`),` `,(0,Z.jsx)(`kbd`,{className:`ml-1 text-[10px] border rounded px-1 bg-background/80`,children:`y`})]})]})]})})}function ms(e){if(!e)return``;let t=Date.parse(e);if(!Number.isFinite(t))return``;let n=Math.max(0,Math.round((Date.now()-t)/6e4));if(n<1)return`just now`;if(n<60)return`${n}m ago`;let r=Math.round(n/60);return r<24?`${r}h ago`:`${Math.round(r/24)}d ago`}function hs(){let{t:e}=H(),t=o(e=>e.candidates),n=o(e=>e.dismiss),r=b(e=>e.entries),i=P(e=>e.openTabIds),[a,s]=(0,X.useState)(new Set),c=Math.max(0,ee-i.length);(0,X.useEffect)(()=>{s(new Set(t.slice(0,c)))},[t,c]);let l=(0,X.useMemo)(()=>t.map(e=>{let t=r.find(t=>t.id===e);return{id:e,title:t?.name||t?.title||e,meta:[t?.messageCount?`${t.messageCount} messages`:``,ms(t?.lastActivityAt??t?.startedAt)].filter(Boolean).join(` · `)}}),[t,r]);if(t.length===0)return null;let u=e=>{s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.size<c&&n.add(e),n})};return(0,Z.jsx)(Ja,{open:!0,onOpenChange:e=>{e||n()},children:(0,Z.jsxs)(Ga,{className:`max-w-lg`,children:[(0,Z.jsxs)(Ua,{children:[(0,Z.jsx)(Ka,{children:e(`restoreTabs.title`,{defaultValue:`Restore your previous tabs?`})}),(0,Z.jsx)(qa,{children:e(`restoreTabs.body`,{count:t.length,defaultValue:`This WebUI started fresh. {{count}} session(s) were open in this browser before — they are still on disk. Pick the ones to reopen, or start clean.`})})]}),(0,Z.jsx)(`ul`,{className:`max-h-72 space-y-1 overflow-y-auto rounded-md border border-border/60 bg-muted/30 p-2`,children:l.map(e=>{let t=a.has(e.id),n=!t&&a.size>=c;return(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 rounded px-2 py-1.5 text-left text-xs hover:bg-muted/60 ${n?`opacity-50`:``}`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 shrink-0`,checked:t,disabled:n,onChange:()=>u(e.id)}),(0,Z.jsxs)(`span`,{className:`min-w-0`,children:[(0,Z.jsx)(`span`,{className:`block truncate font-medium text-foreground`,children:e.title}),(0,Z.jsxs)(`span`,{className:`block truncate text-[11px] text-muted-foreground`,children:[e.meta?`${e.meta} · `:``,e.id]})]})]})},e.id)})}),c<t.length&&(0,Z.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e(`restoreTabs.limit`,{room:c,max:ee,defaultValue:`At most {{room}} more can be reopened ({{max}} tabs total). The rest stay in History.`})}),(0,Z.jsxs)(Wa,{className:`gap-2`,children:[(0,Z.jsx)(Y,{variant:`outline`,size:`sm`,onClick:n,children:e(`restoreTabs.fresh`,{defaultValue:`Start fresh`})}),(0,Z.jsx)(Y,{size:`sm`,disabled:a.size===0,onClick:()=>{let e=V(),r=P.getState();for(let n of t)a.has(n)&&r.openTab(n,{resumeSession:t=>e.resumeSessionById(t)});n()},children:e(`restoreTabs.confirm`,{count:a.size,defaultValue:`Reopen {{count}}`})})]})]})})}function gs(){let{t:e}=H(),t=R(e=>e.wsStatus),n=R(e=>e.wsUrl),[r,i]=(0,X.useState)(!1),[a,o]=(0,X.useState)(Date.now());if((0,X.useEffect)(()=>{if(t.state!==`reconnecting`)return;let e=setInterval(()=>o(Date.now()),500);return()=>clearInterval(e)},[t.state]),(0,X.useEffect)(()=>{t.state===`open`&&i(!1)},[t.state]),t.state===`open`||t.state===`connecting`||r)return null;let s=()=>V(n).retryNow(),c=t.state===`reconnecting`,l=t.state===`closed`?t.error:t.state===`reconnecting`?t.lastError:void 0,u=c?Math.max(0,Math.ceil((t.nextRetryAt-a)/1e3)):0;return(0,Z.jsxs)(`div`,{className:G(`flex items-center gap-3 px-4 py-2 border-b text-sm`,c?`bg-warning/10 text-warning border-warning/30`:`bg-destructive/10 text-destructive border-destructive/30`),children:[c?(0,Z.jsx)(wt,{className:`h-4 w-4 animate-spin shrink-0`}):(0,Z.jsx)(En,{className:`h-4 w-4 shrink-0`}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Z.jsx)(`div`,{className:`font-medium`,children:c?e(`activity:connection.reconnecting`,{attempt:t.attempt,remaining:u}):e(`activity:connection.disconnected`)}),l&&(0,Z.jsx)(`div`,{className:`text-xs opacity-80 truncate`,children:l})]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:s,className:G(`inline-flex items-center gap-1 px-2.5 py-1 rounded-md border text-xs font-medium`,`hover:bg-background/30 transition-colors shrink-0`,c?`border-warning/40`:`border-destructive/40`),title:e(`activity:connection.retryTitle`),children:[(0,Z.jsx)(Tn,{className:`h-3 w-3`}),e(`activity:connection.retry`)]}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>i(!0),className:`text-current/60 hover:text-current shrink-0`,title:e(`activity:connection.dismissTitle`),children:(0,Z.jsx)(St,{className:`h-4 w-4`})})]})}function _s(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(e>=1e4?0:1)}k`:String(e)}var vs=e=>{let t=new Date(e);return`${t.getFullYear()}-${t.getMonth()}-${t.getDate()}`};function ys(e,t){let n=new Date(e),r=new Date(t),i=new Date(t-864e5);return vs(e)===vs(r.getTime())?`Today`:vs(e)===vs(i.getTime())?`Yesterday`:n.toLocaleDateString(void 0,{weekday:`short`,month:`short`,day:`numeric`,year:n.getFullYear()===r.getFullYear()?void 0:`numeric`})}function bs(e,t=Date.now()){let n=[];for(let t=0;t<e.length;t++){let r=k(e[t]);if(r.role===`tool`){let e=n[n.length-1];e&&e.kind===`tools`?e.tools.push(r):n.push({kind:`tools`,tools:[r],key:r.id})}else{let i=e[t-1];n.push({kind:`msg`,message:r,isFirst:!i||i.role!==r.role})}}let r=[];for(let e of n){if(e.kind===`msg`&&e.message.role===`user`){r.push({kind:`user`,message:e.message,key:e.message.id});continue}let t=r[r.length-1];if(t&&t.kind===`agent`)t.items.push(e);else{let t=e.kind===`msg`?e.message.id:e.key;r.push({kind:`agent`,items:[e],key:t})}}let i=e=>{if(e.kind===`user`)return e.message.timestamp;let t=k(e.items[0]);return t.kind===`msg`?t.message.timestamp:t.tools[0]?.timestamp??0},a=[],o=null;for(let e=0;e<r.length;e++){let n=k(r[e]),s=i(n),c=vs(s);if(c!==o&&(a.push({kind:`day`,key:`day-${c}-${e}`,label:ys(s,t)}),o=c),n.kind===`user`){a.push({kind:`user`,key:n.key,message:n.message});continue}let l=e===r.length-1,u=n.items.map((e,t)=>{let r=t>0;return e.kind===`msg`?{kind:`msg`,key:e.message.id,message:e.message,isFirst:!r&&e.isFirst,isContinuation:r}:{kind:`tools`,key:e.key,tools:e.tools,isContinuation:r,isLastGroup:t===n.items.length-1,hasRunningTool:e.tools.some(e=>e.toolResult===void 0)}});a.push({kind:`agent`,key:n.key,items:u,isLastTurn:l})}return a}function xs(e,t,n={}){let{sessionId:r,deps:i=[],enabled:a=!0}=n,o=r??void 0,s=(0,X.useRef)(t);s.current=t;let c=(0,X.useRef)(o);c.current=o,(0,X.useEffect)(()=>{if(!a)return;let t=V();if(!t)return;let n=t.on(e,e=>{let t=c.current;if(t!==void 0){let n=ue(e);if(n&&n!==t)return}s.current(e)});return()=>{try{n()}catch{}}},[...i,a])}var Ss=5e3;function Cs(e,t={}){let{active:n=!0,intervalMs:r=2e3,pauseWhenHidden:i=!0}=t,[a,o]=(0,X.useState)(null),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(null),[d,f]=(0,X.useState)(null),[p,m]=(0,X.useState)(0),h=(0,X.useRef)(!1),g=(0,X.useRef)(null),_=(0,X.useCallback)(()=>{m(e=>e+1)},[]),v=ve();return xs(`context.debug`,e=>{if(!F(e))return;let t=e.payload?.sessionId;if(v&&t!==v)return;let n=e.payload;!n||typeof n!=`object`||!(`tools`in n)||!(`messages`in n)||(h.current=!0,o(n),u(null),c(!1),f(Date.now()))},{deps:[v,p],enabled:n}),(0,X.useEffect)(()=>{let t=`${e}|${v??``}`,a=g.current!==t;if(g.current=t,a&&(h.current=!1,o(null),u(null),f(null)),!n){m(0);return}let s=V(e);if(!s?.send){u(`WebSocket not connected`),c(!1);return}h.current||c(!0),u(null);let l=()=>{try{let e=`withSession`in s&&typeof s.withSession==`function`?s.withSession({}):{};s.send({type:`context.debug`,...Object.keys(e).length>0?{payload:e}:{}},{echoToChat:!1,queueIfDisconnected:!1})}catch{}};l();let d=setTimeout(()=>{h.current||(c(!1),u(e=>e??`Timed out waiting for context snapshot`))},Ss),p=null,_=()=>{p===null&&(p=setInterval(()=>{i&&typeof document<`u`&&document.hidden||l()},r))},y=()=>{p!==null&&(clearInterval(p),p=null)},b=()=>{typeof document>`u`||(document.hidden?y():(l(),_()))};return _(),i&&typeof document<`u`&&document.addEventListener(`visibilitychange`,b),()=>{clearTimeout(d),y(),i&&typeof document<`u`&&document.removeEventListener(`visibilitychange`,b)}},[n,e,p,r,i,v]),{data:a,loading:s,error:l,refresh:_,lastUpdatedAt:d}}function ws(e,t){if(t<=0)return`text-muted-foreground`;let n=e/t;return n>.5?`text-destructive`:n>.25?`text-warning`:n>.1?`text-info`:`text-muted-foreground`}function Ts({value:e,total:t,color:n}){let r=t>0?Math.max(2,e/t*100):0;return(0,Z.jsx)(`span`,{className:`relative inline-block h-2 w-12 overflow-hidden rounded-full bg-muted/50 align-middle ring-1 ring-inset ring-border/20`,children:(0,Z.jsx)(`span`,{className:`absolute inset-y-0 left-0 rounded-full transition-all duration-700 ease-out`,style:{width:`${Math.min(100,r)}%`,backgroundColor:n}})})}function Es({open:e,onClose:t}){let n=R(e=>e.wsUrl),{lastInputTokens:r,maxContext:i,cacheStats:a}=N(Me(e=>({lastInputTokens:e.lastInputTokens,maxContext:e.maxContext,cacheStats:e.cacheStats}))),{t:o}=H(),{data:s,loading:c,error:l,refresh:u}=Cs(n,{active:e}),[d,f]=(0,X.useState)(!1);(0,X.useEffect)(()=>{if(!e){f(!1);return}requestAnimationFrame(()=>requestAnimationFrame(()=>f(!0)))},[e]),(0,X.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&t()};return document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[e,t]);let p=(0,X.useMemo)(()=>s?[{label:o(`activity:ctxDash.systemPrompt`),key:`systemPrompt`,value:s.systemPrompt,color:`hsl(var(--info))`},{label:o(`activity:ctxDash.tools`),key:`tools`,value:s.tools.total,color:`hsl(var(--warning))`},{label:o(`activity:ctxDash.messages`),key:`messages`,value:s.messages.total,color:`hsl(var(--success))`}]:null,[s]),m=a&&a.coverageTokens>0&&i>0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,Z.jsx)(at,{className:`h-4 w-4 text-success`}),(0,Z.jsx)(`span`,{className:`text-xs font-bold uppercase tracking-wider text-foreground/80`,children:`Cache coverage`}),(0,Z.jsxs)(`span`,{className:`text-[10px] text-muted-foreground ml-auto`,children:[_s(a.coverageTokens),` of `,_s(i),` (`,(a.coverageTokens/i*100).toFixed(1),`%)`]})]}),(0,Z.jsx)(`div`,{className:`h-3 w-full overflow-hidden rounded-full bg-muted/50 ring-1 ring-inset ring-border/20`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-success transition-all duration-700 ease-out`,style:{width:`${Math.max(2,a.coverageTokens/i*100)}%`},title:`Cached prefix: ${_s(a.coverageTokens)} of ${_s(i)}`})}),(0,Z.jsxs)(`p`,{className:`mt-2 text-[11px] text-muted-foreground`,children:[`The first `,_s(a.coverageTokens),` of this prompt are served from the provider cache; everything past that boundary is fresh and billed at full input rate.`]})]}):null,h=a&&(a.providers?.length??0)>0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,Z.jsx)(at,{className:`h-4 w-4 text-success`}),(0,Z.jsx)(`span`,{className:`text-xs font-bold uppercase tracking-wider text-foreground/80`,children:`Provider cache hit ratio`})]}),(0,Z.jsx)(`div`,{className:`space-y-2`,children:a.providers?.map(e=>(0,Z.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto_auto] items-center gap-3 rounded-md border border-border/70 bg-background/50 px-3 py-2 text-xs`,children:[(0,Z.jsx)(`span`,{className:`truncate font-mono text-foreground`,children:e.provider}),(0,Z.jsxs)(`span`,{className:`tabular-nums text-success`,children:[(e.hitRatio*100).toFixed(1),`% hit`]}),(0,Z.jsxs)(`span`,{className:`tabular-nums text-muted-foreground`,children:[_s(e.cacheRead),` read · `,_s(e.cacheWrite),` write`]})]},e.provider))})]}):null;if(!e)return null;let g=i>0&&r>0?Math.min(100,Math.round(r/i*100)):0;return(0,Z.jsx)(`div`,{className:G(`fixed inset-0 z-50 flex items-start justify-center pt-[6dvh] bg-black/40 backdrop-blur-sm transition-opacity duration-300`,d?`opacity-100`:`opacity-0`),children:(0,Z.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":o(`activity:context.title`),className:G(`w-full max-w-3xl max-h-[85dvh] overflow-hidden rounded-xl border bg-card shadow-2xl`,`flex flex-col`,`transition-all duration-300`,d?`translate-y-0 scale-100`:`translate-y-4 scale-[0.97]`),children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between border-b px-4 py-3 shrink-0`,children:[(0,Z.jsxs)(`h3`,{className:`text-sm font-semibold flex items-center gap-2`,children:[(0,Z.jsx)(wn,{className:`h-4 w-4 text-primary`}),o(`activity:context.title`)]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:u,className:`p-1.5 rounded-md hover:bg-accent transition-colors text-muted-foreground hover:text-foreground`,title:o(`activity:ctxBreakdown.refresh`),children:(0,Z.jsx)(xi,{className:G(`h-3.5 w-3.5`,c&&`animate-spin`)})}),(0,Z.jsx)(`button`,{type:`button`,onClick:t,"aria-label":o(`common:action.close`),className:`p-1.5 rounded-md hover:bg-accent hover:text-accent-foreground transition-colors`,children:(0,Z.jsx)(St,{className:`h-4 w-4`})})]})]}),(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto overscroll-contain`,children:(0,Z.jsxs)(`div`,{className:`p-4 space-y-5`,children:[(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2`,children:[(0,Z.jsx)(Ds,{icon:Kr,label:o(`activity:context.windowUsage`),value:`${_s(r)} / ${_s(i)}`,sub:`${g}%`,accent:g>85?`destructive`:g>60?`warning`:`success`}),(0,Z.jsx)(Ds,{icon:at,label:`Cache hit`,value:a&&a.readTokens+a.writeTokens>0?`${(a.hitRatio*100).toFixed(1)}%`:`—`,sub:a&&a.coverageTokens>0&&i>0?`covers ${_s(a.coverageTokens)}`:`prompt-cache`,accent:a&&a.readTokens+a.writeTokens>0?`success`:`default`}),(0,Z.jsx)(Ds,{icon:on,label:o(`activity:context.contextMode`),value:s?.mode??`—`,sub:`mode`,accent:`default`}),s&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Ds,{icon:li,label:o(`activity:ctxBreakdown.toolsRegistered`),value:String(s.tools.count),sub:`${_s(s.tools.total)} tokens`,accent:`default`}),(0,Z.jsx)(Ds,{icon:Lt,label:o(`activity:ctxDash.messages`),value:String(s.messages.count),sub:`${_s(s.messages.total)} tokens`,accent:`default`})]})]}),c?(0,Z.jsxs)(`div`,{className:`flex items-center justify-center gap-2 text-sm text-muted-foreground py-8`,children:[(0,Z.jsx)(xi,{className:`h-4 w-4 animate-spin`}),o(`activity:context.fetching`)]}):l?(0,Z.jsx)(`div`,{className:`rounded-md bg-destructive/10 border border-destructive/20 p-3 text-sm text-destructive`,children:l}):s?(0,Z.jsxs)(Z.Fragment,{children:[m,h,(0,Z.jsxs)(`section`,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,Z.jsx)(wn,{className:`h-4 w-4 text-primary`}),(0,Z.jsx)(`span`,{className:`text-xs font-bold uppercase tracking-wider text-foreground/80`,children:o(`activity:ctxBreakdown.tokenAllocation`)}),(0,Z.jsxs)(`span`,{className:`text-[10px] text-muted-foreground ml-auto`,children:[_s(s.total),` total`]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-4 items-start`,children:[p&&(0,Z.jsx)(`div`,{className:`relative shrink-0 flex items-center justify-center`,children:(0,Z.jsxs)(`svg`,{width:`96`,height:`96`,viewBox:`0 0 96 96`,className:`drop-shadow-md`,children:[(0,Z.jsxs)(`title`,{children:[`Token allocation: `,g,`% context usage`]}),(()=>{let e=p.reduce((e,t)=>e+t.value,0)||1,t=0,n=2*Math.PI*36;return p.map(r=>{let i=r.value/e*n,a=`${i} ${n-i}`,o=(0,Z.jsx)(`circle`,{cx:`48`,cy:`48`,r:36,fill:`none`,stroke:r.color,strokeWidth:`10`,strokeDasharray:a,strokeDashoffset:-t,className:`transition-all duration-1000 ease-out`,style:{transformOrigin:`center`,transform:`rotate(-90deg)`}},r.key);return t+=i,o})})(),(0,Z.jsx)(`circle`,{cx:`48`,cy:`48`,r:`24`,fill:`hsl(var(--card))`,className:`drop-shadow-sm`}),(0,Z.jsxs)(`text`,{x:`48`,y:`48`,textAnchor:`middle`,dominantBaseline:`central`,fill:`currentColor`,className:`text-[10px] font-bold font-mono tabular-nums`,children:[g,`%`]})]})}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-2 w-full`,children:[(0,Z.jsx)(`div`,{className:`h-3 w-full overflow-hidden rounded-full bg-muted/50 flex ring-1 ring-inset ring-border/20`,children:s.total>0&&p&&p.map(e=>(0,Z.jsx)(`span`,{className:`h-full transition-all duration-700 last:rounded-r-full`,style:{width:`${e.value/s.total*100}%`,backgroundColor:e.color},title:`${e.label}: ${_s(e.value)}`},e.key))}),(0,Z.jsx)(`div`,{className:`grid grid-cols-3 gap-1 text-[10px]`,children:p?.map(e=>{let t=s.total>0?(e.value/s.total*100).toFixed(1):`0`;return(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0`,style:{backgroundColor:e.color}}),(0,Z.jsx)(`span`,{className:`text-muted-foreground truncate`,children:e.label}),(0,Z.jsxs)(`span`,{className:`font-mono tabular-nums ml-auto`,children:[t,`%`]})]},e.key)})})]})]})]}),s.tools.breakdown.length>0&&(0,Z.jsxs)(`section`,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,Z.jsx)(li,{className:`h-4 w-4 text-warning`}),(0,Z.jsx)(`span`,{className:`text-xs font-bold uppercase tracking-wider text-foreground/80`,children:o(`activity:ctxBreakdown.toolBreakdown`)}),(0,Z.jsxs)(`span`,{className:`text-[10px] text-muted-foreground ml-auto`,children:[s.tools.breakdown.length,` tools · `,_s(s.tools.total),` tokens`]})]}),(0,Z.jsx)(`div`,{className:`max-h-48 overflow-y-auto overscroll-contain space-y-0.5 rounded-lg border bg-muted/20 p-2`,children:s.tools.breakdown.map(e=>{let t=s.tools.total>0?e.tokens/s.tools.total*100:0;return(0,Z.jsxs)(`div`,{className:G(`flex items-center gap-2 text-xs py-1 px-2 rounded`,`hover:bg-muted/40 transition-colors`),children:[(0,Z.jsx)(`span`,{className:`font-mono truncate flex-1 text-foreground/80`,children:e.name}),(0,Z.jsx)(Ts,{value:e.tokens,total:s.tools.total,color:`hsl(var(--warning))`}),(0,Z.jsx)(`span`,{className:G(`tabular-nums w-16 text-right font-mono`,ws(e.tokens,s.tools.total)),children:e.tokens.toLocaleString()}),(0,Z.jsxs)(`span`,{className:`tabular-nums w-10 text-right text-[10px] text-muted-foreground`,children:[t.toFixed(1),`%`]})]},e.name)})})]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,Z.jsx)(Lt,{className:`h-4 w-4 text-success`}),(0,Z.jsx)(`span`,{className:`text-xs font-bold uppercase tracking-wider text-foreground/80`,children:o(`activity:ctxBreakdown.messageBreakdown`)}),(0,Z.jsxs)(`span`,{className:`text-[10px] text-muted-foreground ml-auto`,children:[s.messages.count,` messages · `,_s(s.messages.total),` tokens`]})]}),(0,Z.jsx)(`div`,{className:`max-h-64 overflow-y-auto overscroll-contain space-y-0.5 rounded-lg border bg-muted/20 p-2`,children:s.messages.breakdown.map(e=>(0,Z.jsxs)(`div`,{className:G(`flex items-center gap-2 text-xs py-1 px-2 rounded`,`hover:bg-muted/40 transition-colors`),children:[(0,Z.jsx)(`span`,{className:`font-mono text-muted-foreground w-6 text-right shrink-0`,children:e.index}),(0,Z.jsx)(`span`,{className:G(`font-mono w-14 shrink-0 px-1 rounded text-center text-[10px] font-semibold`,e.role===`assistant`?`bg-accent/30 text-accent-foreground`:e.role===`user`?`bg-primary/10 text-primary`:e.role===`tool`?`bg-warning/10 text-warning`:`bg-muted/50 text-muted-foreground`),children:e.role}),(0,Z.jsx)(Ts,{value:e.tokens,total:s.messages.total,color:e.role===`assistant`?`hsl(var(--accent-foreground))`:e.role===`user`?`hsl(var(--primary))`:`hsl(var(--warning))`}),(0,Z.jsx)(`span`,{className:G(`tabular-nums w-14 text-right font-mono shrink-0`,ws(e.tokens,s.messages.total)),children:e.tokens.toLocaleString()}),(0,Z.jsx)(`span`,{className:`text-muted-foreground/70 truncate flex-1 min-w-0`,children:e.preview.slice(0,100)})]},e.index))})]})]}):null]})})]})})}function Ds({icon:e,label:t,value:n,sub:r,accent:i}){return(0,Z.jsxs)(`div`,{className:G(`rounded-lg border px-3 py-2.5 transition-all duration-300 hover:shadow-sm`,{destructive:`border-destructive/30 bg-destructive/5 text-destructive`,warning:`border-warning/30 bg-warning/5 text-warning`,success:`border-success/30 bg-success/5 text-success`,default:`border-border/50 bg-muted/30 text-muted-foreground`}[i]),children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] text-muted-foreground mb-1`,children:[(0,Z.jsx)(e,{className:`h-3 w-3`}),(0,Z.jsx)(`span`,{className:`truncate`,children:t})]}),(0,Z.jsx)(`div`,{className:`text-sm font-mono font-bold tabular-nums tracking-tight`,children:n}),(0,Z.jsx)(`div`,{className:`text-[10px] text-muted-foreground/70 mt-0.5`,children:r})]})}var Os=class extends X.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(e,t.componentStack),this.props.onError?.(e,t)}handleReset=()=>{this.setState({error:null})};render(){return this.state.error?(this.props.level??`app`)===`panel`?(0,Z.jsxs)(`div`,{role:`alert`,className:`flex min-h-[200px] flex-1 min-h-0 min-w-0 flex-col items-center justify-center gap-3 bg-background p-6 text-center`,children:[(0,Z.jsx)(Kr,{className:`h-8 w-8 text-destructive`}),(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-semibold`,children:this.props.name?U.t(`common:error.panelTitle`,{name:this.props.name,defaultValue:`${this.props.name} hit an error`}):U.t(`common:error.title`)}),(0,Z.jsx)(`pre`,{className:`max-w-md truncate text-xs font-mono text-muted-foreground`,children:this.state.error.message})]}),(0,Z.jsxs)(Y,{size:`sm`,variant:`outline`,onClick:this.handleReset,children:[(0,Z.jsx)(xi,{className:`mr-1 h-3.5 w-3.5`}),U.t(`common:error.tryAgain`)]})]}):(0,Z.jsx)(`div`,{className:`flex min-h-[100dvh] items-center justify-center bg-background`,children:(0,Z.jsxs)(`div`,{className:`flex max-w-md flex-col items-center gap-4 p-8 text-center`,children:[(0,Z.jsx)(Kr,{className:`h-12 w-12 text-destructive`}),(0,Z.jsx)(`h1`,{className:`text-lg font-semibold`,children:U.t(`common:error.title`)}),(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:U.t(`common:error.body`)}),(0,Z.jsx)(`pre`,{className:`max-h-32 w-full overflow-auto rounded bg-muted/50 p-3 text-left text-xs font-mono text-muted-foreground`,children:this.state.error.message}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsxs)(Y,{size:`sm`,variant:`outline`,onClick:()=>window.location.reload(),children:[(0,Z.jsx)(xi,{className:`mr-1 h-4 w-4`}),U.t(`common:error.reload`)]}),(0,Z.jsx)(Y,{size:`sm`,onClick:this.handleReset,children:U.t(`common:error.tryAgain`)})]})]})}):this.props.children}};function ks(){let e=d(e=>e.pending),t=d(e=>e.selected),n=d(e=>e.move),r=d(e=>e.clear),[i,a]=(0,X.useState)(0),o=(0,X.useRef)(!1),s=(0,X.useRef)(t);if((0,X.useEffect)(()=>{s.current=t},[t]),(0,X.useEffect)(()=>{e&&(o.current=!1,a(Math.max(1,e.autoSwitchSeconds)))},[e?.requestId]),(0,X.useEffect)(()=>{if(!e)return;let t=setInterval(()=>{a(n=>{if(n<=1){if(clearInterval(t),!o.current){o.current=!0;let t=e.candidates[s.current]??null;As(e.requestId,t),r()}return 0}return n-1})},1e3);return()=>clearInterval(t)},[e?.requestId]),(0,X.useEffect)(()=>{if(!e)return;let t=t=>{if(!o.current){if(t.key===`ArrowUp`)t.preventDefault(),n(-1);else if(t.key===`ArrowDown`)t.preventDefault(),n(1);else if(t.key===`Enter`){t.preventDefault(),o.current=!0;let n=e.candidates[s.current]??null;As(e.requestId,n),r()}else t.key===`Escape`&&(t.preventDefault(),o.current=!0,As(e.requestId,null),r())}};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e?.requestId,t]),!e)return null;let c=`${e.from.providerId}/${e.from.model}`;return(0,Z.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Model fallback`,className:`fixed inset-0 z-[9999] flex items-center justify-center bg-black/60`,children:(0,Z.jsxs)(`div`,{className:`w-full max-w-md rounded-xl border border-warning/50 bg-card p-5 shadow-2xl`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`h2`,{className:`text-sm font-bold text-warning`,children:`⚠ MODEL FALLBACK`}),(0,Z.jsxs)(`span`,{className:`text-xs text-warning`,children:[i,`s`]})]}),(0,Z.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[(0,Z.jsx)(`span`,{className:`font-mono text-card-foreground`,children:c}),` returned`,` `,(0,Z.jsx)(`span`,{className:`font-mono text-warning`,children:e.status})]}),(0,Z.jsxs)(`div`,{className:`mt-4 space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Select a fallback model (↑/↓ to move, Enter to pick, Esc for auto):`}),e.candidates.map((n,i)=>{let a=i===t,s=`${n.providerId}/${n.model}`;return(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>{o.current||(o.current=!0,As(e.requestId,n),r())},onMouseEnter:()=>d.getState().setSelected(i),className:`flex w-full items-center gap-2 rounded-md px-3 py-2 text-left text-xs transition-colors ${a?`bg-warning/15 text-card-foreground ring-1 ring-warning/50`:`text-muted-foreground hover:bg-muted`}`,children:[(0,Z.jsx)(`span`,{className:a?`text-warning`:`text-transparent`,children:`▸`}),(0,Z.jsx)(`span`,{className:`font-mono`,children:s})]},`fb-${i}`)})]}),(0,Z.jsx)(`p`,{className:`mt-4 text-[10px] text-muted-foreground`,children:`Enter picks · Esc auto-switches · countdown picks highlighted entry`})]})})}function As(e,t){y(e);try{let n=V(),r=t?{requestId:e,providerId:t.providerId,model:t.model}:{requestId:e,autoSwitch:!0};n.send({type:`model.fallback_choice`,payload:n.withSession(r)})}catch{}}var js=X.forwardRef(({className:e,children:t,...n},r)=>(0,Z.jsxs)(Kn,{ref:r,className:G(`relative overflow-hidden`,e),...n,children:[(0,Z.jsx)(Be,{className:`h-full w-full rounded-[inherit]`,children:t}),(0,Z.jsx)(Ms,{}),(0,Z.jsx)(Ui,{})]}));js.displayName=Kn.displayName;var Ms=X.forwardRef(({className:e,orientation:t=`vertical`,...n},r)=>(0,Z.jsx)(Ri,{ref:r,orientation:t,className:G(`flex touch-none select-none transition-colors`,t===`vertical`&&`h-full w-2.5 border-l border-l-transparent p-[1px]`,t===`horizontal`&&`h-2.5 flex-col border-t border-t-transparent p-[1px]`,e),...n,children:(0,Z.jsx)(rn,{className:`relative flex-1 rounded-full bg-border`})}));Ms.displayName=Ri.displayName;var Ns=In,Ps=X.forwardRef(({className:e,...t},n)=>(0,Z.jsx)(yr,{ref:n,className:G(`inline-flex min-h-10 items-center justify-center rounded-md border border-border/60 bg-muted/55 p-1 text-muted-foreground shadow-sm`,e),...t}));Ps.displayName=yr.displayName;var Fs=X.forwardRef(({className:e,...t},n)=>(0,Z.jsx)(Oi,{ref:n,className:G(`inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-card data-[state=active]:text-foreground data-[state=active]:shadow-sm data-[state=active]:ring-1 data-[state=active]:ring-border/60`,e),...t}));Fs.displayName=Oi.displayName;var Is=X.forwardRef(({className:e,...t},n)=>(0,Z.jsx)(Tr,{ref:n,className:G(`mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,e),...t}));Is.displayName=Tr.displayName;var Ls=[` `,`▁`,`▂`,`▃`,`▄`,`▅`,`▆`,`▇`,`█`],Rs=12;function zs(e,t){return t===0?0:Math.min(8,Math.round(e/t*8))}function Bs({bins:e,className:t}){let{t:n}=H(),r=Array.from({length:Rs},(t,n)=>e.at(-(Rs-n))??0),i=Math.max(...r,1);return i===1&&r.every(e=>e===0)?(0,Z.jsx)(`span`,{role:`img`,className:t,"aria-label":n(`common:sparkline.noActivity`),title:n(`common:sparkline.noActivityYet`),children:`—`}):(0,Z.jsx)(`span`,{role:`img`,className:t,"aria-label":n(`common:sparkline.activityMax`,{count:i}),title:n(`common:sparkline.activityPeak`,{count:i}),children:r.map((e,t)=>{let n=zs(e,i),r=Ls[n];return(0,Z.jsx)(`span`,{style:{color:n>=7?`hsl(var(--success))`:`hsl(var(--muted-foreground))`,opacity:n>0?void 0:.3},children:r},t)})})}function Vs({current:e,max:t,className:n,showLabel:r=!0}){let i=Math.min(e,t),a=Math.max(0,t-i),o=t>0?i/t*100:0,s=o>=90?`text-destructive`:o>=70?`text-warning`:`text-success`;return(0,Z.jsxs)(`span`,{className:n,title:`Fleet concurrency: ${e}/${t}`,children:[(0,Z.jsxs)(`span`,{"aria-hidden":`true`,className:`font-mono text-[10px] tracking-tight`,children:[`[`,(0,Z.jsx)(`span`,{className:s,children:`█`.repeat(i)}),(0,Z.jsx)(`span`,{className:`text-[hsl(var(--muted))]`,children:`░`.repeat(a)}),`]`]}),r&&(0,Z.jsxs)(`span`,{className:`ml-1.5 tabular-nums text-[10px] text-muted-foreground font-mono`,children:[e,`/`,t]})]})}function Hs(e){let t=Date.now()-e;return t<5e3?U.t(`common:time.justNow`):t<6e4?U.t(`common:time.compactSecondsAgo`,{count:Math.floor(t/1e3)}):t<36e5?U.t(`common:time.compactMinutesAgo`,{count:Math.floor(t/6e4)}):U.t(`common:time.compactHoursAgo`,{count:Math.floor(t/36e5)})}var Us={spawned:`🚀`,task_started:`▶`,tool_executed:`⚡`,iteration_summary:`🔄`,budget_warning:`!`,budget_extended:`⚡`,task_completed:`✅`,ctx_pct:`💬`,leader_updated:`👑`};function Ws({events:e,max:t=20,className:n}){let{t:r}=H(),i=e.slice(0,t);return i.length===0?(0,Z.jsx)(`div`,{className:`py-4 text-center text-xs text-muted-foreground ${n??``}`,children:r(`activity:timeline.noEvents`)}):(0,Z.jsx)(`div`,{className:`space-y-0.5 overflow-y-auto max-h-48 ${n??``}`,children:i.map(e=>(0,Z.jsxs)(`div`,{className:`flex items-start gap-2 text-[10px] leading-tight py-0.5 px-1 rounded hover:bg-accent/50 transition-colors`,children:[(0,Z.jsx)(`span`,{className:`shrink-0 w-5 text-center`,"aria-hidden":`true`,children:Us[e.kind]??`·`}),(0,Z.jsx)(`span`,{className:`shrink-0 w-12 text-right text-muted-foreground font-mono tabular-nums`,children:Hs(e.timestamp)}),(0,Z.jsx)(`span`,{className:`truncate text-foreground/90`,children:e.message}),e.value!==void 0&&e.kind===`tool_executed`&&(0,Z.jsx)(`span`,{className:`ml-auto shrink-0 tabular-nums text-muted-foreground font-mono`,children:e.value>=1e3?`${(e.value/1e3).toFixed(1)}s`:`${e.value}ms`}),e.value!==void 0&&e.kind===`ctx_pct`&&(0,Z.jsxs)(`span`,{className:`ml-auto shrink-0 tabular-nums text-muted-foreground font-mono`,children:[e.value,`%`]})]},e.id))})}var Gs=cn,Ks=Ye,qs=je,Js=X.forwardRef(({className:e,...t},n)=>(0,Z.jsx)(Lr,{ref:n,className:G(`ws-sheet-overlay fixed inset-0 z-50 bg-black/50 backdrop-blur-sm`,e),...t}));Js.displayName=Lr.displayName;var Ys=Ni(`ws-sheet-content fixed z-50 gap-4 bg-card shadow-2xl`,{variants:{side:{top:`inset-x-0 top-0 border-b`,bottom:`inset-x-0 bottom-0 border-t`,left:`inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-md`,right:`inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-md`}},defaultVariants:{side:`right`}}),Xs=X.forwardRef(({side:e=`right`,className:t,children:n,showOverlay:r=!0,showCloseButton:i=!0,...a},o)=>(0,Z.jsxs)(qs,{children:[r?(0,Z.jsx)(Js,{}):null,(0,Z.jsxs)(We,{ref:o,"data-side":e,className:G(Ys({side:e}),t),...a,children:[n,i?(0,Z.jsxs)(Ye,{className:`absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none`,children:[(0,Z.jsx)(St,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{className:`sr-only`,children:`Close`})]}):null]})]}));Xs.displayName=We.displayName;var Zs=({className:e,...t})=>(0,Z.jsx)(`div`,{className:G(`flex flex-col space-y-1.5 text-left p-4 border-b`,e),...t});Zs.displayName=`SheetHeader`;var Qs=X.forwardRef(({className:e,...t},n)=>(0,Z.jsx)(Fr,{ref:n,className:G(`text-base font-semibold leading-none`,e),...t}));Qs.displayName=Fr.displayName;var $s=X.forwardRef(({className:e,...t},n)=>(0,Z.jsx)(Bt,{ref:n,className:G(`text-xs text-muted-foreground`,e),...t}));$s.displayName=Bt.displayName;function ec(e){return e==null||!Number.isFinite(e)||e<0?`$0.0000`:e<.01?`$${e.toFixed(4)}`:e<1?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}function tc(e){return e==null||!Number.isFinite(e)?`0`:e<1e3?String(Math.round(e)):e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(1)}M`}function nc(e){if(e==null||!Number.isFinite(e)||e<0)return`—`;let t=Math.round(e/1e3);return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m`:`${Math.floor(t/3600)}h`}var rc={running:{led:`bg-success`,labelKey:`statusRunning`,pulse:!0,color:`text-success`},completed:{led:`bg-success`,labelKey:`statusDone`,pulse:!1,color:`text-success`},failed:{led:`bg-destructive`,labelKey:`statusFailed`,pulse:!1,color:`text-destructive`},timeout:{led:`bg-warning`,labelKey:`statusTimeout`,pulse:!1,color:`text-warning`},stopped:{led:`bg-muted-foreground`,labelKey:`statusStopped`,pulse:!1,color:`text-muted-foreground`}};function ic({agent:e,isSelected:t,isLeader:n,onClick:r}){let{t:i}=H(),a=rc[e.status],o=e.status===`running`,s=Math.min(100,Math.max(0,e.ctxPct));return(0,Z.jsxs)(`button`,{type:`button`,onClick:r,className:G(`min-w-[650px] w-full text-left grid grid-cols-[140px_60px_1fr_60px_60px_60px_60px_50px_50px] items-center gap-x-2 px-3 py-1.5 rounded-md text-xs transition-colors`,t?`bg-primary/15 ring-1 ring-primary/40`:`hover:bg-accent/50`,o&&!t&&`bg-muted/30`),children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1 min-w-0`,children:[(0,Z.jsx)(`span`,{className:G(`led shrink-0`,a.led,a.pulse&&`led-pulse`)}),(0,Z.jsx)(`span`,{className:`truncate font-medium`,children:e.name}),n&&(0,Z.jsx)(Wr,{className:`h-3 w-3 shrink-0 text-warning`,"aria-label":i(`activity:fleet.leader`)})]}),(0,Z.jsx)(`span`,{className:G(`text-[10px] tabular-nums`,o?`text-success`:`text-muted-foreground`),children:i(`activity:fleet.${a.labelKey}`)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1 min-w-0`,children:[(0,Z.jsx)(Bs,{bins:e.sparklineBins,className:`font-mono text-[9px]`}),e.budgetWarning&&(0,Z.jsx)(`span`,{title:i(`activity:fleet.hittingLimitTitle`,{kind:e.budgetWarning.kind,used:e.budgetWarning.used,limit:e.budgetWarning.limit}),children:(0,Z.jsx)(at,{className:`h-3 w-3 shrink-0 text-warning`,"aria-label":i(`common:status.budgetWarning`)})})]}),(0,Z.jsxs)(`span`,{className:`tabular-nums text-muted-foreground text-[10px]`,children:[e.iteration,`it`]}),(0,Z.jsxs)(`span`,{className:`tabular-nums text-muted-foreground text-[10px]`,children:[e.toolCalls,`tc`]}),(0,Z.jsx)(`span`,{className:`tabular-nums font-mono text-[10px]`,children:ec(e.costUsd)}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5 min-w-0`,children:[(0,Z.jsx)(`div`,{className:`h-1.5 w-full rounded-full bg-muted overflow-hidden`,children:(0,Z.jsx)(`div`,{className:G(`h-full rounded-full transition-all`,s>=85?`bg-destructive`:s>=70?`bg-warning`:`bg-success`),style:{width:`${s}%`}})}),(0,Z.jsx)(`span`,{className:`text-[9px] tabular-nums text-muted-foreground font-mono leading-none`,children:e.maxContext>0?`${s}%`:`—`})]}),(0,Z.jsx)(`span`,{className:`tabular-nums text-[10px] text-muted-foreground`,children:e.extensions>0?`\u26A1\u00D7${e.extensions}`:`—`}),(0,Z.jsx)(`span`,{className:`text-[9px] text-destructive truncate`,title:e.failureReason,children:e.failureReason??``})]})}var ac={0:``,1:`▏`,2:`▎`,3:`▍`,4:`▌`,5:`▋`,6:`▊`,7:`▉`,8:`█`};function oc(e){return e>=85?`bg-destructive`:e>=60?`bg-warning`:`bg-success`}function sc(e){return e>=85?`text-destructive`:e>=60?`text-warning`:`text-success`}function cc(e){return e>=85?`shadow-[0_0_8px_-1px_hsl(var(--destructive)/0.5)] ring-1 ring-destructive/30`:e>=60?`shadow-[0_0_6px_-2px_hsl(var(--warning)/0.4)]`:``}function lc(e){return e>=85?Kr:e>=60?at:ln}function uc(e){let t=fc(e),n=[[0,142],[45,125],[60,78],[72,35],[85,0],[100,-40]];for(let e=0;e<n.length-1;e++){let[r,i]=n[e],[a,o]=n[e+1];if(t<=a){let e=(t-r)/(a-r||1);return Math.round(i+e*(o-i))}}return-40}function dc(e,t=55,n=75){return`hsl(${uc(e)}, ${n}%, ${t}%)`}function fc(e){return Number.isFinite(e)?Math.max(0,Math.min(100,e)):0}function pc({pct:e,tokens:t,maxTokens:n,cache:r,segments:i=10,showTokens:a=!0,className:o,onClick:s,variant:c=`solid`}){let{t:l}=H(),u=fc(e),d=Math.round(u/100*i*8),f=u>=85,p=u>=60&&u<85,m=lc(u),h=c===`iridescent`,g=!!r&&r.readTokens+r.writeTokens>0,_=[],v=d;for(let e=0;e<i;e++){let t=Math.min(8,v),n=(e+.5)/i*100;_.push({fill:t,positionPct:n}),v-=t}let y=`${Math.round(u)}%`,b=a&&t!==void 0&&n!==void 0&&n>0?` ${_s(t)}/${_s(n)}`:``;return(0,Z.jsxs)(s?`button`:`span`,{role:`progressbar`,"aria-valuenow":Math.round(u),"aria-valuemin":0,"aria-valuemax":100,"aria-valuetext":`${Math.round(u)}%`,className:G(`inline-flex items-center gap-1.5 px-2 py-1 rounded-lg text-[11px] font-mono font-medium shrink-0 transition-all duration-300`,s&&`cursor-pointer hover:scale-[1.02] hover:ring-1 hover:ring-ring`,sc(u),f?`bg-destructive/10`:p?`bg-warning/10`:`bg-success/10`,cc(u),f&&`animate-pulse`,o),title:(t!==void 0&&n!==void 0?l(`activity:context.barWithTokens`,{tokens:t.toLocaleString(),max:n.toLocaleString(),pct:y}):l(`activity:context.barPct`,{pct:y}))+(s?l(`activity:context.barClick`):``),onClick:s?e=>{e.stopPropagation(),s()}:void 0,type:s?`button`:void 0,children:[(0,Z.jsx)(m,{className:G(`h-3 w-3 shrink-0`,sc(u))}),(0,Z.jsx)(`span`,{className:`inline-flex font-mono text-[10px] leading-none tracking-tight`,children:_.map((e,t)=>(0,Z.jsx)(`span`,{className:G(`tabular-nums w-[0.55em] text-center transition-colors duration-300`,!h&&(e.fill>0?sc(u):`text-muted-foreground/40`)),style:h&&e.fill>0?{color:dc(e.positionPct,58,80)}:h?{color:`hsl(var(--muted-foreground) / 0.4)`}:void 0,children:ac[e.fill]??` `},t))}),(0,Z.jsx)(`span`,{className:`font-bold tracking-tight`,children:y}),b&&(0,Z.jsx)(`span`,{className:`tabular-nums opacity-80`,children:b}),g&&r?(0,Z.jsxs)(`span`,{className:`ml-1 inline-flex items-center gap-1 text-[10px] font-mono tabular-nums text-success`,title:r.coverageTokens>0&&n!==void 0&&n>0?`Cache covers ${r.coverageTokens.toLocaleString()} of ${n.toLocaleString()} tokens`:`Prompt cache: ${(r.hitRatio*100).toFixed(1)}% hit`,children:[`· `,(r.hitRatio*100).toFixed(1),`% hit`,r.coverageTokens>0&&n!==void 0&&n>0?` · covers ${_s(r.coverageTokens)}`:``]}):null]})}function mc({pct:e,tokens:t,maxTokens:n,cache:r,showTokens:i=!0,className:a,onClick:o}){let{t:s}=H(),c=fc(e),l=`${Math.round(c)}%`,u=i&&t!==void 0&&n!==void 0&&n>0?` ${_s(t)}/${_s(n)}`:``,d=!!r&&r.readTokens+r.writeTokens>0,f=c>=85,p=c>=60&&c<85,m=lc(c);return(0,Z.jsxs)(o?`button`:`span`,{role:`progressbar`,"aria-valuenow":Math.round(c),"aria-valuemin":0,"aria-valuemax":100,"aria-valuetext":`${Math.round(c)}%`,className:G(`inline-flex items-center gap-2 group`,o&&`cursor-pointer hover:opacity-90 transition-opacity`,a),title:(t!==void 0&&n!==void 0?s(`activity:context.barWithTokens`,{tokens:t.toLocaleString(),max:n.toLocaleString(),pct:l}):s(`activity:context.barPct`,{pct:l}))+(o?s(`activity:context.barClick`):``),onClick:o?e=>{e.stopPropagation(),o()}:void 0,type:o?`button`:void 0,children:[(0,Z.jsx)(`span`,{className:G(`relative h-2 w-20 overflow-hidden rounded-full shrink-0 transition-shadow duration-300`,`bg-muted/60 ring-1 ring-inset ring-border/30`,f&&`ring-destructive/30`),children:(0,Z.jsx)(`span`,{className:G(`h-full rounded-full transition-all duration-500 ease-out`,oc(c),f&&`animate-pulse`),style:{width:`${Math.max(3,c)}%`,background:f?`linear-gradient(90deg, hsl(var(--destructive)) 0%, hsl(var(--destructive) / 0.72) 100%)`:p?`linear-gradient(90deg, hsl(var(--warning)) 0%, hsl(var(--warning) / 0.72) 100%)`:`linear-gradient(90deg, hsl(var(--success)) 0%, hsl(var(--success) / 0.72) 100%)`},children:(0,Z.jsx)(`span`,{className:G(`absolute inset-0 opacity-30 bg-gradient-to-r from-transparent via-white/40 to-transparent`,`animate-[shimmer_2s_ease-in-out_infinite]`)})})}),(0,Z.jsx)(m,{className:G(`h-3 w-3 shrink-0 transition-colors`,sc(c))}),(0,Z.jsx)(`span`,{className:G(`text-[11px] font-mono tabular-nums font-bold tracking-tight transition-colors`,sc(c)),children:l}),u&&(0,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:u}),d&&r?(0,Z.jsxs)(`span`,{className:`text-[10px] font-mono tabular-nums text-success`,title:r.coverageTokens>0&&n!==void 0&&n>0?`Cache covers ${r.coverageTokens.toLocaleString()} of ${n.toLocaleString()} tokens`:`Prompt cache: ${(r.hitRatio*100).toFixed(1)}% hit`,children:[`· `,(r.hitRatio*100).toFixed(1),`% hit`,r.coverageTokens>0&&n!==void 0&&n>0?` · covers ${_s(r.coverageTokens)}`:``]}):null]})}var hc={text:{labelKey:`kindAssistant`,icon:nt,tone:`text-primary`,bubble:`border-border bg-card`},thinking:{labelKey:`kindThinking`,icon:lr,tone:`text-primary`,bubble:`border-primary/20 bg-primary/5`},tool_use:{labelKey:`kindToolCall`,icon:li,tone:`text-warning`,bubble:`border-warning/20 bg-warning/5`},tool_result:{labelKey:`kindToolResult`,icon:ui,tone:`text-success`,bubble:`border-success/20 bg-success/5`},error:{labelKey:`kindError`,icon:Ie,tone:`text-destructive`,bubble:`border-destructive/25 bg-destructive/5`},status:{labelKey:`kindStatus`,icon:tr,tone:`text-muted-foreground`,bubble:`border-border bg-muted/25`},system:{labelKey:`kindSystem`,icon:Et,tone:`text-muted-foreground`,bubble:`border-border bg-muted/25`}};function gc(e){let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}):``}function _c(e){return e.map(e=>{let t=hc[e.kind]??hc.status,n=gc(e.ts),r=e.toolName?` [${e.toolName}]`:``;return`[${n}] ${e.agentName} · ${U.t(`activity:transcript.${t.labelKey}`)}${r}\n${e.content}`}).join(`
|
|
71
71
|
|
|
72
72
|
`)}function vc({entries:e,agentName:t,className:n,compact:r=!1,maxHeightClassName:i,title:a,showHeader:o=!0}){let{t:s}=H(),[c,l]=(0,X.useState)(!1),u=(0,X.useMemo)(()=>_c(e),[e]),d=(0,X.useCallback)(async()=>{if(u)try{await navigator.clipboard.writeText(u),l(!0),setTimeout(()=>l(!1),1600)}catch{}},[u]);return(0,Z.jsxs)(`div`,{className:G(`rounded-lg border bg-card`,n),children:[o&&(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b bg-muted/25 px-3 py-2`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(jr,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,Z.jsx)(`span`,{className:`truncate text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:a??s(`activity:transcript.title`)}),t&&(0,Z.jsx)(`span`,{className:`truncate text-[10px] text-muted-foreground`,children:t}),(0,Z.jsx)(`span`,{className:`shrink-0 rounded bg-muted px-1.5 py-0.5 text-[9px] tabular-nums text-muted-foreground`,children:e.length})]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:d,disabled:e.length===0,className:`flex shrink-0 items-center gap-1 rounded px-1.5 py-0.5 text-[10px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40`,title:s(`activity:transcript.copyTitle`),children:[c?(0,Z.jsx)(ui,{className:`h-3 w-3 text-success`}):(0,Z.jsx)(oi,{className:`h-3 w-3`}),s(c?`common:action.copied`:`common:action.copy`)]})]}),(0,Z.jsx)(`div`,{className:G(`space-y-2 overflow-y-auto p-2`,i??(r?`max-h-72`:`max-h-[32rem]`)),children:e.length===0?(0,Z.jsx)(`div`,{className:`rounded-md border border-dashed border-border p-3 text-center text-xs text-muted-foreground`,children:s(`activity:transcript.empty`)}):e.map(e=>{let t=hc[e.kind]??hc.status,n=t.icon;return(0,Z.jsxs)(`div`,{className:G(`rounded-md border px-3 py-2`,t.bubble,r?`space-y-1`:`space-y-1.5`),children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(n,{className:G(`h-3.5 w-3.5 shrink-0`,t.tone)}),(0,Z.jsx)(`span`,{className:`shrink-0 text-[10px] font-medium uppercase tracking-wider text-muted-foreground`,children:s(`activity:transcript.${t.labelKey}`)}),e.toolName&&(0,Z.jsx)(`span`,{className:`min-w-0 truncate rounded bg-background/70 px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground`,children:e.toolName}),(0,Z.jsx)(`span`,{className:`ml-auto shrink-0 font-mono text-[9px] tabular-nums text-muted-foreground`,children:gc(e.ts)})]}),(0,Z.jsx)(`pre`,{className:G(`whitespace-pre-wrap break-words font-mono text-foreground/85`,r?`text-[10px] leading-relaxed`:`text-xs leading-relaxed`),children:e.content})]},e.id)})})]})}var yc={running:{led:`bg-success`,pulse:!0,badge:`bg-success/15 text-success`},completed:{led:`bg-success`,pulse:!1,badge:`bg-muted text-muted-foreground`},failed:{led:`bg-destructive`,pulse:!1,badge:`bg-destructive/15 text-destructive`},timeout:{led:`bg-warning`,pulse:!1,badge:`bg-warning/15 text-warning`},stopped:{led:`bg-muted-foreground`,pulse:!1,badge:`bg-muted text-muted-foreground`}};function bc({agent:e,isLeader:t}){let n=yc[e.status],{t:r}=H(),i=e.status===`running`,[a,o]=(0,X.useState)(Date.now());(0,X.useEffect)(()=>{if(e.status!==`running`)return;o(Date.now());let t=window.setInterval(()=>o(Date.now()),1e3);return()=>window.clearInterval(t)},[e.status]);let s=p(e,a),c=_(t=>t.agentTranscripts.get(e.id)??oe),l=[...e.toolLog.slice(0,8)].reverse();return(0,Z.jsxs)(`div`,{className:G(`rounded-xl border p-4 space-y-3`,i?`border-primary/20 bg-primary/[0.02]`:`border-border bg-card`,t&&`ring-2 ring-warning/30`),children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:G(`led`,n.led,n.pulse&&`led-pulse`,`mt-0.5`)}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-semibold`,children:e.name}),t&&(0,Z.jsx)(Wr,{className:`h-3.5 w-3.5 text-warning`,"aria-label":r(`activity:fleet.leader`)}),e.extensions>0&&(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded-full bg-warning/15 text-[10px] text-warning font-medium`,children:[(0,Z.jsx)(at,{className:`h-2.5 w-2.5`}),`×`,e.extensions]})]}),(0,Z.jsx)(`span`,{className:G(`inline-block mt-0.5 px-1.5 py-0.5 rounded text-[10px] font-medium`,n.badge),children:r(`activity:fleet.status.${e.status}`)})]})]}),(0,Z.jsx)(`div`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground`,children:t&&(0,Z.jsx)(`span`,{className:`text-[9px] bg-warning/15 text-warning px-1.5 py-0.5 rounded`,children:r(`activity:agentsMonitor.leaderBadge`)})})]}),e.description&&(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed line-clamp-2`,children:e.description}),e.budgetWarning&&(0,Z.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,Z.jsx)(at,{className:`h-3.5 w-3.5 text-warning shrink-0`}),(0,Z.jsx)(`span`,{className:`text-warning`,children:r(`activity:fleet.hittingLimitTitle`,{kind:e.budgetWarning.kind,used:e.budgetWarning.used,limit:e.budgetWarning.limit})})]}),e.failureReason&&(0,Z.jsx)(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg bg-destructive/10 border border-destructive/20 text-xs`,children:(0,Z.jsxs)(`span`,{className:`text-destructive font-medium`,children:[`✗ `,e.failureReason]})}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-4 gap-2`,children:[(0,Z.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 px-2 py-1.5 text-center`,children:[(0,Z.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:r(`activity:agentsMonitor.iters`)}),(0,Z.jsx)(`div`,{className:`text-xs font-mono font-semibold tabular-nums`,children:e.iteration})]}),(0,Z.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 px-2 py-1.5 text-center`,children:[(0,Z.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:r(`activity:agentsMonitor.tools`)}),(0,Z.jsx)(`div`,{className:`text-xs font-mono font-semibold tabular-nums`,children:e.toolCalls})]}),(0,Z.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 px-2 py-1.5 text-center`,children:[(0,Z.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:r(`activity:fleet.cost`)}),(0,Z.jsx)(`div`,{className:`text-xs font-mono font-semibold tabular-nums`,children:s.cost})]}),(0,Z.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 px-2 py-1.5 text-center`,children:[(0,Z.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:r(`activity:fleet.elapsed`)}),(0,Z.jsx)(`div`,{className:`text-xs font-mono font-semibold tabular-nums`,children:s.elapsed})]})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:r(`activity:agentsMonitor.activityBins`)}),(0,Z.jsx)(Bs,{bins:e.sparklineBins,className:`font-mono text-[9px]`})]}),(0,Z.jsx)(pc,{pct:e.ctxPct,tokens:e.ctxTokens,maxTokens:e.maxContext})]}),(e.provider||e.model)&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] text-muted-foreground`,children:[(0,Z.jsx)(ar,{className:`h-3 w-3`}),(0,Z.jsxs)(`span`,{className:`font-mono`,children:[e.provider??`?`,`/`,e.model??`?`]})]}),(e.currentTool||e.lastTool)&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] text-muted-foreground`,children:[(0,Z.jsx)(li,{className:G(`h-3 w-3`,i&&`animate-pulse text-primary`)}),(0,Z.jsx)(`span`,{className:`font-mono`,children:e.currentTool??e.lastTool}),i&&(0,Z.jsx)(wt,{className:`h-3 w-3 animate-spin`})]}),(0,Z.jsx)(vc,{entries:c,agentName:e.name,compact:!0,maxHeightClassName:`max-h-80`}),e.partialText&&i&&(0,Z.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 p-2`,children:[(0,Z.jsx)(`div`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider mb-1`,children:r(`activity:agentsMonitor.streamingOutput`)}),(0,Z.jsx)(`pre`,{className:`text-[10px] font-mono text-foreground/80 whitespace-pre-wrap line-clamp-3 leading-relaxed`,children:e.partialText})]}),l.length>0&&(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`div`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:r(`activity:agentsMonitor.recentTools`)}),(0,Z.jsx)(`div`,{className:`space-y-0.5`,children:l.map(e=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] font-mono`,children:[(0,Z.jsx)(`span`,{className:G(`shrink-0`,e.ok?`text-success`:`text-destructive`),children:e.ok?`✓`:`✗`}),(0,Z.jsx)(`span`,{className:`text-muted-foreground truncate`,children:e.name}),(0,Z.jsx)(`span`,{className:`ml-auto tabular-nums text-muted-foreground shrink-0`,children:e.durationMs>=1e3?`${(e.durationMs/1e3).toFixed(1)}s`:`${e.durationMs}ms`})]},`${e.name}-${e.at}`))})]}),e.finalText&&!i&&(0,Z.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 p-2`,children:[(0,Z.jsx)(`div`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider mb-1`,children:r(`activity:agentsMonitor.finalOutput`)}),(0,Z.jsx)(`pre`,{className:`text-[10px] font-mono text-foreground/80 whitespace-pre-wrap line-clamp-4 leading-relaxed`,children:e.finalText})]})]})}function xc(){let{t:e}=H(),t=Ma(e=>e.panels),n=Ma(e=>e.clear);return t.length===0?(0,Z.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 p-6 text-center`,children:[(0,Z.jsx)(ct,{className:`h-6 w-6 text-muted-foreground/60`}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`activity:inspector.councilEmpty`,{defaultValue:`No council has convened yet in this session.`})}),(0,Z.jsx)(`p`,{className:`max-w-[22rem] text-[11px] text-muted-foreground/70`,children:e(`activity:inspector.councilEmptyHint`,{defaultValue:`The Brain convenes a multi-model panel for questions at or above its council risk floor. Configure it under Settings › Brain › Council.`})})]}):(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-col`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/60 px-3 py-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:e(`activity:inspector.councilCount`,{defaultValue:`{{count}} panel(s)`,count:t.length})}),(0,Z.jsx)(`button`,{type:`button`,onClick:n,className:`rounded px-1.5 py-0.5 text-[10px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:e(`activity:inspector.councilClear`,{defaultValue:`Clear`})})]}),(0,Z.jsx)(`ul`,{className:`flex min-h-0 flex-col divide-y divide-border/50`,children:t.map(e=>(0,Z.jsx)(Sc,{panel:e},e.requestId))})]})}function Sc({panel:e}){let{t}=H(),n=e.phase===`voting`,r=!n&&(e.validVoteCount??0)>1&&(e.distinctTargetCount??0)<(e.validVoteCount??0);return(0,Z.jsx)(`li`,{className:`px-3 py-2`,children:(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(ct,{className:G(`mt-0.5 h-3.5 w-3.5 shrink-0`,n?`animate-pulse text-primary`:e.status===`denied`?`text-destructive`:`text-muted-foreground`)}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:G(`truncate text-[11px] font-medium`,n?`text-primary`:`text-foreground`),children:Ca(e)}),e.judgeUsed?(0,Z.jsx)(Ii,{className:`h-3 w-3 shrink-0 text-info`,"aria-label":t(`activity:councilLogTimeline.judgeUsed`)}):null,r?(0,Z.jsx)(Kr,{className:`h-3 w-3 shrink-0 text-warning`,"aria-label":t(`activity:councilLogTimeline.panelNotDiverse`)}):null]}),e.question?(0,Z.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-[11px] text-muted-foreground`,children:e.question}):null,(0,Z.jsx)(`ul`,{className:`mt-1 flex flex-col gap-0.5`,children:e.seats.map(e=>(0,Z.jsx)(Cc,{seat:e},e.seatId))}),e.reason&&e.status!==`decided`?(0,Z.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground/80`,children:e.reason}):null,(e.warnings??[]).map(e=>(0,Z.jsxs)(`p`,{className:`mt-1 flex items-start gap-1 text-[10px] text-warning`,children:[(0,Z.jsx)(Kr,{className:`mt-px h-3 w-3 shrink-0`}),(0,Z.jsx)(`span`,{children:e})]},e))]})]})})}function Cc({seat:e}){let{t}=H(),n=e.status!==`valid`,r=n?e.error??e.status:e.optionId??e.stance??`stance`;return(0,Z.jsxs)(`li`,{className:`flex items-baseline gap-1.5 font-mono text-[10px]`,children:[(0,Z.jsx)(`span`,{className:n?`text-destructive`:`text-muted-foreground/70`,children:n?`×`:`•`}),(0,Z.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:e.persona}),e.veto?(0,Z.jsx)(qt,{className:`h-2.5 w-2.5 shrink-0 text-warning`,"aria-label":t(`activity:councilLogTimeline.veto`)}):null,(0,Z.jsx)(`span`,{className:`text-muted-foreground/50`,children:`→`}),(0,Z.jsx)(`span`,{className:G(`truncate`,n?`text-destructive`:`text-foreground`),children:r}),e.model?(0,Z.jsx)(`span`,{className:`ml-auto shrink-0 pl-2 text-muted-foreground/60`,children:e.model}):null]})}function wc(e,t=20,n){let[r,i]=(0,X.useState)(1),a=e.length,o=Math.max(1,Math.ceil(a/t));return(0,X.useEffect)(()=>{i(e=>Math.min(e,o))},[o]),(0,X.useEffect)(()=>{i(1)},[n]),{page:r,pageSize:t,totalItems:a,pageItems:(0,X.useMemo)(()=>Array.from(e.slice((r-1)*t,r*t)),[e,r,t]),setPage:i}}function Tc({page:e,pageSize:t,totalItems:n,onPageChange:r,className:i,compact:a=!1,itemLabel:o=`items`}){let{t:s}=H(),c=Math.max(1,Math.ceil(n/t)),l=Math.min(Math.max(1,e),c);if(n<=t)return null;let u=(l-1)*t+1,d=Math.min(n,l*t);return(0,Z.jsxs)(`nav`,{"aria-label":`${o} pagination`,className:G(`flex shrink-0 items-center justify-between gap-2 border-t border-border/75 bg-card/80 px-2 py-2`,i),children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-label":s(`activity:pagination.previousPage`),disabled:l<=1,onClick:()=>r(l-1),className:`inline-flex h-8 items-center gap-1 border border-border/75 px-2 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-35`,children:[(0,Z.jsx)(yn,{className:`h-3.5 w-3.5`}),!a&&(0,Z.jsx)(`span`,{children:s(`activity:pagination.previous`)})]}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate text-center font-mono text-[10px] tabular-nums text-muted-foreground`,children:a?`${l} / ${c}`:`${u}–${d} of ${n} ${o}`}),(0,Z.jsxs)(`button`,{type:`button`,"aria-label":s(`activity:pagination.nextPage`),disabled:l>=c,onClick:()=>r(l+1),className:`inline-flex h-8 items-center gap-1 border border-border/75 px-2 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-35`,children:[!a&&(0,Z.jsx)(`span`,{children:s(`activity:pagination.next`)}),(0,Z.jsx)(ot,{className:`h-3.5 w-3.5`})]})]})}var Ec={shell:kr,package:Bi,network:Bn,"fs.write":Ge,config:Ge},Dc={shell:`text-warning`,package:`text-info`,network:`text-success`,"fs.write":`text-primary`,config:`text-muted-foreground`},Oc=[`all`,`shell`,`package`,`network`,`fs.write`,`config`];function kc(e){try{return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}catch{return e.slice(11,19)}}function Ac(e){if(e.input.command)return String(e.input.command).slice(0,80);if(e.input.url)return String(e.input.url).slice(0,80);if(e.input.packages){let t=e.input.packages;return Array.isArray(t)?t.join(`, `).slice(0,80):String(t).slice(0,80)}return JSON.stringify(e.input).slice(0,80)}function jc(e){return/[",\n]/.test(e)?`"${e.replace(/"/g,`""`)}"`:e}function Mc(e){let t=[`timestamp,tool,risk,detail,outcome`,...e.map(e=>{let t=e.input.command??e.input.url??e.input.packages??JSON.stringify(e.input);return[jc(e.ts),jc(e.toolName),jc(e.risk),jc(String(t)),jc(e.outcome??``)].join(`,`)})].join(`
|
|
73
|
-
`),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 Nc(){let e=Ea(e=>e.sideEffects),t=Ea(e=>e.loading),{t:n}=H(),[r,i]=(0,X.useState)(`all`),[a,o]=(0,X.useState)(`time`),[s,c]=(0,X.useState)(`desc`),l=ve();(0,X.useEffect)(()=>{Ea.getState().setLoading(!0),ta(async()=>{let{getWSClient:e}=await import(`./ws-client-C_IqS0t4.js`).then(e=>e.n);return{getWSClient:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16])).then(({getWSClient:e})=>{e().send({type:`side_effects.list`,...l?{payload:{sessionId:l}}:{}})})},[l]);let u=()=>{Ea.getState().setLoading(!0),ta(async()=>{let{getWSClient:e}=await import(`./ws-client-C_IqS0t4.js`).then(e=>e.n);return{getWSClient:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16])).then(({getWSClient:e})=>{e().send({type:`side_effects.list`,...l?{payload:{sessionId:l}}:{}})})},d=e=>{a===e?c(s===`asc`?`desc`:`asc`):(o(e),c(e===`time`?`desc`:`asc`))},f=(0,X.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]),p=wc(f,20,`${r}:${a}:${s}`);if(e.length===0&&!t)return(0,Z.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 py-8 text-muted-foreground`,children:[(0,Z.jsx)(Ge,{className:`h-8 w-8 opacity-40`}),(0,Z.jsx)(`p`,{className:`text-sm`,children:n(`activity:sideEffects.empty`)}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground/75`,children:n(`activity:sideEffects.emptyHint`)})]});let m=({column:e})=>a===e?s===`asc`?(0,Z.jsx)(dn,{className:`inline h-3 w-3`}):(0,Z.jsx)(Ct,{className:`inline h-3 w-3`}):(0,Z.jsx)(`span`,{className:`opacity-30`,children:`↕`});return(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/70 bg-card/70 px-3 py-2`,children:[(0,Z.jsxs)(`h3`,{className:`text-xs font-semibold uppercase text-muted-foreground`,children:[n(`activity:sideEffects.heading`),` (`,f.length,r===`all`?``:`/${e.length}`,`)`]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>Mc(f),disabled:f.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,Z.jsx)(ti,{className:`h-3 w-3`}),`CSV`]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:u,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,Z.jsx)(xi,{className:G(`h-3 w-3`,t&&`animate-spin`)}),n(`common:action.refresh`)]})]})]}),(0,Z.jsx)(`div`,{className:`flex items-center gap-1 border-b border-border/60 bg-muted/20 px-2 py-1`,children:Oc.map(e=>(0,Z.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,Z.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Z.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,Z.jsx)(`thead`,{className:`sticky top-0 bg-card/95 text-muted-foreground backdrop-blur`,children:(0,Z.jsxs)(`tr`,{children:[(0,Z.jsxs)(`th`,{className:`cursor-pointer select-none px-2 py-1 text-left font-medium hover:text-foreground`,onClick:()=>d(`time`),children:[n(`activity:sideEffects.colTime`),` `,(0,Z.jsx)(m,{column:`time`})]}),(0,Z.jsxs)(`th`,{className:`cursor-pointer select-none px-2 py-1 text-left font-medium hover:text-foreground`,onClick:()=>d(`tool`),children:[n(`activity:sideEffects.colTool`),` `,(0,Z.jsx)(m,{column:`tool`})]}),(0,Z.jsxs)(`th`,{className:`cursor-pointer select-none px-2 py-1 text-left font-medium hover:text-foreground`,onClick:()=>d(`risk`),children:[n(`activity:sideEffects.colRisk`),` `,(0,Z.jsx)(m,{column:`risk`})]}),(0,Z.jsx)(`th`,{className:`px-2 py-1 text-left font-medium`,children:n(`activity:sideEffects.colDetail`)}),(0,Z.jsx)(`th`,{className:`px-2 py-1 text-left font-medium`,children:n(`activity:sideEffects.colOutcome`)})]})}),(0,Z.jsx)(`tbody`,{children:p.pageItems.map((e,t)=>{let n=Ec[e.risk]??Ge,r=Dc[e.risk]??`text-muted-foreground`;return(0,Z.jsxs)(`tr`,{className:`border-b border-border/45 hover:bg-muted/45`,children:[(0,Z.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1.5 text-muted-foreground`,children:kc(e.ts)}),(0,Z.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1.5 font-medium text-foreground`,children:e.toolName}),(0,Z.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1.5`,children:(0,Z.jsxs)(`span`,{className:G(`flex items-center gap-1`,r),children:[(0,Z.jsx)(n,{className:`h-3 w-3`}),e.risk]})}),(0,Z.jsx)(`td`,{className:`max-w-xs truncate px-2 py-1.5 font-mono text-muted-foreground`,children:Ac(e)}),(0,Z.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1.5 text-muted-foreground`,children:e.outcome??``})]},`${e.toolUseId}-${t}`)})})]})}),(0,Z.jsx)(Tc,{page:p.page,pageSize:p.pageSize,totalItems:p.totalItems,onPageChange:p.setPage,itemLabel:`side effects`})]})}function Pc(e){return e<=0?`$0`:e>=.01?`$${e.toFixed(3)}`:`$${e.toFixed(5)}`.replace(/0+$/,``).replace(/\.$/,``)}function Fc(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function Ic(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 Lc({showCountWhenZero:e=!1}){let{t}=H(),n=K(e=>e.sidebarOpen),r=K(e=>e.activeActivity),i=ve(),a=n&&r===`agents`,o=_(e=>Array.from(e.agents.values()).filter(e=>A(e.sessionId,i)&&e.status===`running`).length);return(0,Z.jsxs)(`button`,{type:`button`,"data-testid":`inspector-trigger`,"aria-expanded":a,"aria-label":t(`activity:inspector.openAgentsPanel`),onClick:()=>Ra(`agents`),className:G(`relative inline-flex h-8 items-center gap-1.5 rounded-md border px-2 text-xs transition-colors`,a?`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:t(`activity:inspector.openAgentsPanel`),children:[(0,Z.jsx)(jr,{className:`h-3.5 w-3.5`}),(0,Z.jsx)(`span`,{className:`hidden lg:inline`,children:t(`activity:nav.agents`)}),o>0||e?(0,Z.jsx)(`span`,{className:G(`min-w-4 px-1 text-center text-[10px] font-semibold tabular-nums`,o>0?`bg-primary/15 text-primary`:`text-muted-foreground`),children:o>99?`99+`:o}):null]})}function Rc(){let e=K(e=>e.inspectorOpen),t=K(e=>e.inspectorTab),n=K(e=>e.setInspectorOpen),r=K(e=>e.setInspectorTab),i=K(e=>e.inspectorFocusedAgentId),a=K(e=>e.setInspectorFocusedAgentId),o=ve(),{t:s}=H(),c=_(e=>e.agents),l=v(o??void 0),u=l.leaderId,d=l.tokensIn,f=l.tokensOut,p=_(e=>e.eventTimeline),m=(0,X.useMemo)(()=>{let e=new Map;for(let[t,n]of c)A(n.sessionId,o)&&e.set(t,n);return e},[c,o]),h=(0,X.useMemo)(()=>Ic(m,u),[m,u]),g=(0,X.useMemo)(()=>p.filter(e=>(e.agentId?m.get(e.agentId):void 0)!==void 0),[p,m]),y=h.filter(e=>e.status===`running`).length,b=h.reduce((e,t)=>e+t.costUsd,0),x=h.length,[S,C]=(0,X.useState)(null),w=(0,X.useMemo)(()=>S?m.get(S)??h[0]??null:h[0]??null,[S,h,m]),T=Ea(e=>e.sideEffects.length),E=Ma(e=>e.panels.length),D=Ma(e=>e.panels.filter(e=>e.phase===`voting`).length),O=e=>{C(e.id),r(`agents`)};(0,X.useEffect)(()=>{i&&e&&(C(i),r(`agents`),a(null))},[i,e,r,a]);let k=K(e=>e.inspectorTarget),j=K(e=>e.openInspectorTarget);return(0,Z.jsx)(Gs,{open:e,onOpenChange:n,modal:!1,children:(0,Z.jsx)(Xs,{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:k?.kind===`task`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Zs,{className:`relative gap-1 border-b border-border/70 bg-muted/20 px-4 py-3 pr-12`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>j({kind:`fleet`,tab:`fleet`}),className:`inline-flex h-6 items-center gap-1 rounded px-1.5 text-xs text-muted-foreground hover:bg-muted hover:text-foreground transition-colors`,title:`Back to Fleet`,children:[(0,Z.jsx)(yn,{className:`h-3.5 w-3.5`}),(0,Z.jsx)(`span`,{children:`Fleet`})]}),(0,Z.jsx)(`span`,{className:`text-muted-foreground/40`,children:`/`}),(0,Z.jsxs)(Qs,{className:`flex items-center gap-1.5 text-sm font-semibold truncate`,children:[(0,Z.jsx)(Rn,{className:`h-4 w-4 text-primary shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate`,children:k.title||k.taskId})]})]}),(0,Z.jsxs)($s,{className:`text-[11px] font-mono text-muted-foreground truncate`,children:[`Task ID: `,k.taskId,` `,k.boardId?`· Board: ${k.boardId}`:``]}),(0,Z.jsx)(Ks,{asChild:!0,children:(0,Z.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":s(`activity:inspector.collapseAria`),title:s(`activity:inspector.collapseTitle`),children:(0,Z.jsx)(St,{className:`h-4 w-4`})})})]}),(0,Z.jsx)(zc,{taskId:k.taskId,boardId:k.boardId,onBack:()=>j({kind:`fleet`,tab:`fleet`})})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Zs,{className:`relative gap-1 border-b border-border/70 bg-muted/20 px-4 py-3 pr-12`,children:[(0,Z.jsxs)(Qs,{className:`flex items-center gap-2 text-sm`,children:[(0,Z.jsx)(Sr,{className:`h-4 w-4 text-primary`}),s(`activity:inspector.label`)]}),(0,Z.jsx)($s,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px]`,children:x>0?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Z.jsx)(`span`,{className:G(`h-1.5 w-1.5 rounded-full`,y>0?`bg-success animate-pulse`:`bg-muted-foreground/50`)}),(0,Z.jsxs)(`span`,{className:`tabular-nums`,children:[y,`/`,x]})]}),(0,Z.jsxs)(`span`,{className:`font-mono tabular-nums`,children:[`↓`,Fc(d),` ↑`,Fc(f),` · `,Pc(b)]})]}):(0,Z.jsx)(`span`,{children:s(`activity:inspector.agentsAppearHint`)})}),(0,Z.jsx)(Ks,{asChild:!0,children:(0,Z.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":s(`activity:inspector.collapseAria`),title:s(`activity:inspector.collapseTitle`),children:(0,Z.jsx)(St,{className:`h-4 w-4`})})})]}),(0,Z.jsxs)(Ns,{value:t,onValueChange:e=>r(e),className:`flex min-h-0 flex-1 flex-col`,children:[(0,Z.jsxs)(Ps,{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":s(`activity:inspector.label`),children:[(0,Z.jsx)(Bc,{value:`fleet`,icon:(0,Z.jsx)(jr,{className:`h-3.5 w-3.5`}),label:s(`activity:inspector.tabFleet`),count:x,running:y}),(0,Z.jsx)(Bc,{value:`agents`,icon:(0,Z.jsx)(fr,{className:`h-3.5 w-3.5`}),label:s(`activity:inspector.tabAgents`),count:x}),(0,Z.jsx)(Bc,{value:`sideEffects`,icon:(0,Z.jsx)(Ge,{className:`h-3.5 w-3.5`}),label:s(`activity:inspector.tabAudit`),count:T}),(0,Z.jsx)(Bc,{value:`council`,icon:(0,Z.jsx)(ct,{className:`h-3.5 w-3.5`}),label:s(`activity:inspector.tabCouncil`,{defaultValue:`Council`}),count:E,running:D})]}),(0,Z.jsx)(Is,{value:`fleet`,className:`mt-0 min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Z.jsx)(Vc,{fleetList:h,leaderId:u,selectedAgentId:S,eventTimeline:g,onSelectAgent:O})}),(0,Z.jsx)(Is,{value:`agents`,className:`mt-0 min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Z.jsx)(Hc,{fleetList:h,selectedAgent:w,leaderId:u,selectedAgentId:w?.id??null,onSelectAgent:C})}),(0,Z.jsx)(Is,{value:`sideEffects`,className:`mt-0 min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Z.jsx)(Nc,{})}),(0,Z.jsx)(Is,{value:`council`,className:`mt-0 min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Z.jsx)(xc,{})})]})]})})})}function zc({taskId:e,boardId:t,onBack:n}){let r=wa(e=>e.activeBoard),i=(0,X.useMemo)(()=>r?.tasks.find(t=>t.id===e)??null,[r,e]);return i?(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto overscroll-contain p-4 space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[10px] font-mono text-muted-foreground uppercase`,children:i.id}),(0,Z.jsx)(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-semibold text-primary uppercase`,children:i.columnId||`todo`})]}),(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:i.title})]}),i.description&&(0,Z.jsx)(`div`,{className:`rounded-md border border-border/70 bg-muted/30 p-3 text-xs text-foreground/90 whitespace-pre-wrap`,children:i.description}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-xs`,children:[(0,Z.jsxs)(`div`,{className:`rounded border border-border/60 p-2 bg-card/40`,children:[(0,Z.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground font-semibold`,children:`Priority`}),(0,Z.jsx)(`div`,{className:`font-mono text-xs text-foreground mt-0.5 capitalize`,children:i.priority||`Medium`})]}),(0,Z.jsxs)(`div`,{className:`rounded border border-border/60 p-2 bg-card/40`,children:[(0,Z.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground font-semibold`,children:`Assigned Agent`}),(0,Z.jsx)(`div`,{className:`font-mono text-xs text-foreground mt-0.5`,children:i.assignedAgent||i.assignee||i.assignment?.agentId||`Unassigned`})]})]})]}):(0,Z.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 text-center text-muted-foreground p-4`,children:[(0,Z.jsx)(Rn,{className:`h-8 w-8 mb-2 opacity-30 text-primary`}),(0,Z.jsxs)(`p`,{className:`text-xs font-medium`,children:[`Task details (`,e,`)`]}),(0,Z.jsx)(`p`,{className:`text-[11px] text-muted-foreground mt-1`,children:`Select a task from Kanban or SDD to inspect full parameters.`}),(0,Z.jsx)(`button`,{type:`button`,onClick:n,className:`mt-4 px-3 py-1 text-xs rounded bg-muted hover:bg-muted/80 text-foreground transition-colors`,children:`Back to Fleet`})]})}function Bc({value:e,icon:t,label:n,count:r,running:i}){return(0,Z.jsxs)(Fs,{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,Z.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 Vc({fleetList:e,leaderId:t,selectedAgentId:n,eventTimeline:r,onSelectAgent:i}){let{t:a}=H();return(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[e.length===0?(0,Z.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground`,children:[(0,Z.jsx)(fr,{className:`h-8 w-8 mb-2 opacity-20`}),(0,Z.jsx)(`p`,{className:`text-xs font-medium`,children:a(`activity:inspector.noAgentsActive`)}),(0,Z.jsx)(`p`,{className:`text-[11px] mt-0.5`,children:a(`activity:inspector.agentsAppearHint`)})]}):(0,Z.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain p-1.5`,children:e.map(e=>(0,Z.jsx)(ic,{agent:e,isSelected:n===e.id,isLeader:e.id===t,onClick:()=>i(e)},e.id))}),r.length>0&&(0,Z.jsx)(`div`,{className:`border-t px-3 py-1.5 shrink-0`,children:(0,Z.jsx)(Ws,{events:r,max:4})})]})}function Hc({fleetList:e,selectedAgent:t,leaderId:n,selectedAgentId:r,onSelectAgent:i}){let{t:a}=H();if(e.length===0)return(0,Z.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground`,children:[(0,Z.jsx)(jr,{className:`h-8 w-8 mb-2 opacity-20`}),(0,Z.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,Z.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,Z.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain p-3`,children:(0,Z.jsx)(`div`,{className:`max-w-2xl mx-auto`,children:(0,Z.jsx)(bc,{agent:t,isLeader:t.id===n})})}),(0,Z.jsx)(`div`,{className:`border-t px-2 py-1.5 shrink-0`,children:(0,Z.jsx)(`div`,{className:`flex items-center gap-1 overflow-x-auto pb-0.5`,children:e.map((e,n)=>(0,Z.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,Z.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,Z.jsx)(`span`,{className:`truncate max-w-[8rem]`,children:e.name})]},e.id))})})]})}var Uc={builtin:`📦`,user:`👤`,project:`📁`,synced:`☁`},Wc={title:``,description:``,category:``,tagsCsv:``,content:``,vars:[]};function Gc(e,t){return e.replace(/\{\{\s*([\w.-]+)\s*\}\}/g,(e,n)=>Object.hasOwn(t,n.trim())&&t[n.trim()]?t[n.trim()]:e)}function Kc(){let{t:e}=H(),{client:t}=ha(),n=K(e=>e.promptLibraryOpen),r=K(e=>e.setPromptLibraryOpen),i=K(e=>e.requestPromptInsert),[a,o]=(0,X.useState)([]),[s,c]=(0,X.useState)([]),[l,u]=(0,X.useState)(``),[d,f]=(0,X.useState)(null),[p,m]=(0,X.useState)(!1),[h,g]=(0,X.useState)(!1),[_,v]=(0,X.useState)([]),[y,b]=(0,X.useState)(null),[x,S]=(0,X.useState)(``),[C,w]=(0,X.useState)({}),T=(0,X.useRef)(null),[E,D]=(0,X.useState)(!1),[O,k]=(0,X.useState)(Wc),[A,j]=(0,X.useState)(null);(0,X.useEffect)(()=>{if(!n||!t)return;let e=e=>{let t=e.payload;o(t.prompts??[]),c(t.categories??[])};return t.on(`prompts.list`,e),t.send({type:`prompts.list`}),setTimeout(()=>T.current?.focus(),50),()=>t.off(`prompts.list`,e)},[n,t]),(0,X.useEffect)(()=>{if(!y||!t)return;S(``),w(Object.fromEntries((y.variables??[]).map(e=>[e.name,e.default??``])));let e=e=>{let t=e.payload;t.slug===y.slug&&t.found&&S(t.content)};return t.on(`prompts.content`,e),t.send({type:`prompts.content`,payload:{slug:y.slug}}),()=>t.off(`prompts.content`,e)},[y,t]),(0,X.useEffect)(()=>{if(!n)return;let e=e=>{e.key===`Escape`&&r(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n,r]),(0,X.useEffect)(()=>{if(!n||!t||!h)return;let e=e=>{let t=e.payload.slugs??[];v(t)};return t.on(`prompts.recent`,e),t.send({type:`prompts.recent`}),()=>t.off(`prompts.recent`,e)},[n,t,h]);let M=(0,X.useMemo)(()=>{let e=l.trim().toLowerCase(),t=t=>!e||t.title.toLowerCase().includes(e)||t.description.toLowerCase().includes(e)||t.slug.includes(e)||t.tags.some(t=>t.toLowerCase().includes(e));if(h){let e=new Map(a.map(e=>[e.slug,e]));return _.map(t=>e.get(t)).filter(e=>!!e).filter(t)}return a.filter(e=>p&&!e.favorite||d&&e.category!==d?!1:t(e))},[a,l,d,p,h,_]),N=(0,X.useMemo)(()=>(y?.variables??[]).filter(e=>e.required&&!C[e.name]).map(e=>e.name),[y,C]),P=(0,X.useCallback)(()=>{!y||!x||(t?.send({type:`prompts.used`,payload:{slug:y.slug}}),i(Gc(x,C)))},[y,x,C,i,t]),F=(0,X.useCallback)(e=>{t&&(t.send({type:`prompts.favorite`,payload:{slug:e.slug,favorite:!e.favorite}}),o(t=>t.map(t=>t.slug===e.slug?{...t,favorite:!t.favorite}:t)))},[t]);(0,X.useEffect)(()=>{if(!n||!t)return;let e=e=>{let n=e.payload;n.success?(D(!1),k(Wc),j(null),t.send({type:`prompts.list`})):j(n.error??U.t(`activity:promptLib.saveFailed`))};return t.on(`prompts.created`,e),()=>t.off(`prompts.created`,e)},[n,t]);let I=(0,X.useCallback)(()=>{if(!t)return;if(!O.title.trim()||!O.content.trim()){j(U.t(`activity:promptLib.titleContentRequired`));return}let e=O.vars.filter(e=>e.name.trim()).map(e=>{let t=e.enumCsv.split(`,`).map(e=>e.trim()).filter(Boolean);return{name:e.name.trim(),...e.description.trim()?{description:e.description.trim()}:{},required:e.required,...e.multiline?{multiline:!0}:{},...t.length>0?{enum:t}:{}}});t.send({type:`prompts.create`,payload:{title:O.title.trim(),content:O.content,description:O.description.trim(),category:O.category.trim()||void 0,tags:O.tagsCsv.split(`,`).map(e=>e.trim()).filter(Boolean),...e.length>0?{variables:e}:{}}})},[t,O]);return(0,Z.jsx)(Ja,{open:n,onOpenChange:e=>{e||r(!1)},children:(0,Z.jsxs)(Ga,{className:`max-w-4xl h-[80dvh] p-0 gap-0 overflow-hidden`,showCloseButton:!1,onOpenAutoFocus:e=>{e.preventDefault(),T.current?.focus()},children:[(0,Z.jsx)(Ka,{className:`sr-only`,children:e(`activity:promptLib.heading`)}),(0,Z.jsx)(qa,{className:`sr-only`,children:e(`activity:promptLib.searchPlaceholder`)}),(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 w-full overflow-hidden`,children:[(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 w-1/2 flex-col border-r border-border`,children:[(0,Z.jsxs)(`div`,{className:`border-b border-border p-3`,children:[(0,Z.jsx)(`input`,{ref:T,value:l,onChange:e=>u(e.target.value),placeholder:e(`activity:promptLib.searchPlaceholder`),className:`w-full rounded border border-border bg-background px-3 py-2 text-sm outline-none focus:ring-1 focus:ring-primary`}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{D(!0),b(null),j(null),k(Wc)},className:`mt-2 w-full rounded border border-dashed border-border px-2 py-1 text-xs text-muted-foreground hover:bg-accent hover:text-foreground`,children:e(`activity:promptLib.newPrompt`)}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{f(null),m(!1),g(!1)},className:`rounded px-2 py-0.5 text-xs ${d===null&&!p&&!h?`bg-primary text-primary-foreground`:`bg-muted text-muted-foreground hover:bg-accent`}`,children:e(`activity:promptLib.all`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{g(e=>!e),m(!1),f(null)},className:`rounded px-2 py-0.5 text-xs ${h?`bg-primary text-primary-foreground`:`bg-muted text-muted-foreground hover:bg-accent`}`,children:e(`activity:promptLib.recent`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{m(e=>!e),g(!1),f(null)},className:`rounded px-2 py-0.5 text-xs ${p?`bg-warning text-primary-foreground`:`bg-muted text-muted-foreground hover:bg-accent`}`,children:e(`activity:promptLib.favorites`)}),s.map(e=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>{f(e.id),g(!1),m(!1)},className:`rounded px-2 py-0.5 text-xs ${d===e.id?`bg-primary text-primary-foreground`:`bg-muted text-muted-foreground hover:bg-accent`}`,children:[e.label,` (`,e.count,`)`]},e.id))]})]}),(0,Z.jsxs)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-auto overscroll-contain`,children:[M.map(e=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>b(e),className:`flex w-full flex-col items-start gap-0.5 border-b border-border/50 px-3 py-2 text-left hover:bg-accent ${y?.slug===e.slug?`bg-accent`:``}`,children:[(0,Z.jsxs)(`div`,{className:`flex w-full items-center gap-1 text-sm`,children:[(0,Z.jsx)(`span`,{children:Uc[e.source]??`•`}),(0,Z.jsx)(`span`,{className:`font-medium`,children:e.title}),e.favorite&&(0,Z.jsx)(`span`,{className:`text-warning`,children:`★`})]}),(0,Z.jsx)(`div`,{className:`line-clamp-1 text-xs text-muted-foreground`,children:e.description})]},e.slug)),M.length===0&&(0,Z.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:e(`activity:promptLib.noMatch`)})]})]}),(0,Z.jsx)(`div`,{className:`flex min-h-0 min-w-0 w-1/2 flex-col`,children:E?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border p-3`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold`,children:e(`activity:promptLib.newPromptHeading`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{D(!1),j(null)},className:`text-xs text-muted-foreground hover:text-foreground`,children:e(`common:action.cancel`)})]}),(0,Z.jsxs)(`div`,{className:`min-h-0 min-w-0 flex-1 space-y-2 overflow-auto overscroll-contain p-3 text-xs`,children:[(0,Z.jsx)(`input`,{value:O.title,onChange:e=>k(t=>({...t,title:e.target.value})),placeholder:e(`activity:promptLib.titlePlaceholder`),className:`w-full rounded border border-border bg-background px-2 py-1 outline-none focus:ring-1 focus:ring-primary`}),(0,Z.jsx)(`input`,{value:O.description,onChange:e=>k(t=>({...t,description:e.target.value})),placeholder:e(`activity:promptLib.descPlaceholder`),className:`w-full rounded border border-border bg-background px-2 py-1 outline-none focus:ring-1 focus:ring-primary`}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(`input`,{list:`prompt-category-list`,value:O.category,onChange:e=>k(t=>({...t,category:e.target.value})),placeholder:e(`activity:promptLib.categoryPlaceholder`),className:`w-1/2 rounded border border-border bg-background px-2 py-1 outline-none focus:ring-1 focus:ring-primary`}),(0,Z.jsx)(`datalist`,{id:`prompt-category-list`,children:s.map(e=>(0,Z.jsx)(`option`,{value:e.id},e.id))}),(0,Z.jsx)(`input`,{value:O.tagsCsv,onChange:e=>k(t=>({...t,tagsCsv:e.target.value})),placeholder:e(`activity:promptLib.tagsPlaceholder`),className:`w-1/2 rounded border border-border bg-background px-2 py-1 outline-none focus:ring-1 focus:ring-primary`})]}),(0,Z.jsx)(`textarea`,{value:O.content,onChange:e=>k(t=>({...t,content:e.target.value})),placeholder:e(`activity:promptLib.contentPlaceholder`),rows:6,className:`w-full resize-y rounded border border-border bg-background px-2 py-1 font-mono outline-none focus:ring-1 focus:ring-primary`}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between pt-1`,children:[(0,Z.jsx)(`span`,{className:`font-semibold text-muted-foreground`,children:e(`activity:promptLib.variables`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>k(e=>({...e,vars:[...e.vars,{name:``,description:``,required:!0,multiline:!1,enumCsv:``}]})),className:`rounded border border-border px-1.5 py-0.5 hover:bg-accent`,children:e(`activity:promptLib.addVar`)})]}),O.vars.map((t,n)=>(0,Z.jsxs)(`div`,{className:`space-y-1 rounded border border-border/60 p-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex gap-1`,children:[(0,Z.jsx)(`input`,{value:t.name,onChange:e=>k(t=>({...t,vars:t.vars.map((t,r)=>r===n?{...t,name:e.target.value}:t)})),placeholder:e(`activity:promptLib.varNamePlaceholder`),className:`w-1/3 rounded border border-border bg-background px-1.5 py-0.5 outline-none focus:ring-1 focus:ring-primary`}),(0,Z.jsx)(`input`,{value:t.description,onChange:e=>k(t=>({...t,vars:t.vars.map((t,r)=>r===n?{...t,description:e.target.value}:t)})),placeholder:e(`activity:promptLib.varDescPlaceholder`),className:`flex-1 rounded border border-border bg-background px-1.5 py-0.5 outline-none focus:ring-1 focus:ring-primary`}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>k(e=>({...e,vars:e.vars.filter((e,t)=>t!==n)})),className:`rounded border border-border px-1.5 text-muted-foreground hover:bg-accent`,title:e(`activity:promptLib.removeVarTitle`),children:`✕`})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsxs)(`label`,{className:`flex items-center gap-1 text-muted-foreground`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:t.required,onChange:e=>k(t=>({...t,vars:t.vars.map((t,r)=>r===n?{...t,required:e.target.checked}:t)}))}),e(`activity:promptLib.required`)]}),(0,Z.jsxs)(`label`,{className:`flex items-center gap-1 text-muted-foreground`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:t.multiline,onChange:e=>k(t=>({...t,vars:t.vars.map((t,r)=>r===n?{...t,multiline:e.target.checked}:t)}))}),e(`activity:promptLib.multiline`)]}),(0,Z.jsx)(`input`,{value:t.enumCsv,onChange:e=>k(t=>({...t,vars:t.vars.map((t,r)=>r===n?{...t,enumCsv:e.target.value}:t)})),placeholder:e(`activity:promptLib.enumPlaceholder`),className:`flex-1 rounded border border-border bg-background px-1.5 py-0.5 outline-none focus:ring-1 focus:ring-primary`})]})]},t.name||`var-${n}`))]}),(0,Z.jsxs)(`div`,{className:`border-t border-border p-3`,children:[A&&(0,Z.jsx)(`div`,{className:`mb-2 text-xs text-destructive`,children:A}),(0,Z.jsx)(`button`,{type:`button`,onClick:I,disabled:!O.title.trim()||!O.content.trim(),className:`w-full rounded bg-primary px-3 py-2 text-sm text-primary-foreground disabled:opacity-50`,children:e(`activity:promptLib.savePrompt`)})]})]}):y?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between border-b border-border p-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold`,children:y.title}),(0,Z.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[y.category,` · `,y.slug]})]}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>F(y),className:`text-lg`,title:e(`activity:promptLib.toggleFavoriteTitle`),children:y.favorite?`★`:`☆`})]}),(0,Z.jsxs)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-auto overscroll-contain p-3`,children:[(0,Z.jsx)(`pre`,{className:`whitespace-pre-wrap break-words text-xs text-foreground`,children:x||`…`}),(y.variables??[]).length>0&&(0,Z.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-semibold text-muted-foreground`,children:e(`activity:promptLib.variables`)}),y.variables.map(t=>{let n=(0,Z.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[t.name,t.required?` *`:``,t.description?` — ${t.description}`:``]}),r=e=>w(n=>({...n,[t.name]:e})),i=`mt-0.5 w-full rounded border border-border bg-background px-2 py-1 text-xs outline-none focus:ring-1 focus:ring-primary`;return t.enum&&t.enum.length>0?(0,Z.jsxs)(`div`,{children:[n,(0,Z.jsxs)(`select`,{value:C[t.name]??``,onChange:e=>r(e.target.value),className:i,children:[(0,Z.jsx)(`option`,{value:``,children:e(`activity:promptLib.selectOption`)}),t.enum.map(e=>(0,Z.jsx)(`option`,{value:e,children:e},e))]})]},t.name):t.multiline?(0,Z.jsxs)(`div`,{children:[n,(0,Z.jsx)(`textarea`,{value:C[t.name]??``,onChange:e=>r(e.target.value),rows:4,className:`${i} resize-y font-mono`})]},t.name):(0,Z.jsxs)(`div`,{children:[n,(0,Z.jsx)(`input`,{value:C[t.name]??``,onChange:e=>r(e.target.value),className:i})]},t.name)})]})]}),(0,Z.jsx)(`div`,{className:`border-t border-border p-3`,children:(0,Z.jsx)(`button`,{type:`button`,onClick:P,disabled:!x||N.length>0,className:`w-full rounded bg-primary px-3 py-2 text-sm text-primary-foreground disabled:opacity-50`,children:N.length>0?e(`activity:promptLib.fillMissing`,{missing:N.join(`, `)}):e(`activity:promptLib.insertIntoChat`)})})]}):(0,Z.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-4 text-sm text-muted-foreground`,children:e(`activity:promptLib.selectPromptHint`)})})]})]})})}var qc=[`none`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],Jc=`auto`,Yc=new Set(qc);function Xc(e){return Yc.has(e)}var Zc={none:`settings:agent.reasoningEffortNone`,minimal:`settings:agent.reasoningEffortMinimal`,low:`settings:agent.reasoningEffortLow`,medium:`settings:agent.reasoningEffortMedium`,high:`settings:agent.reasoningEffortHigh`,xhigh:`settings:agent.reasoningEffortXhigh`,max:`settings:agent.reasoningEffortMax`},Qc=`settings:agent.reasoningEffortAuto`;function $c(e){return e===`auto`?Qc:Zc[e]}function el(e,t){let n=[Jc,...e?.length?e.filter(Xc):[...qc]];return Xc(t)&&!n.includes(t)&&n.push(t),n}function tl(e,t){return t!==`auto`&&!!e?.length&&!e.includes(t)}function nl(e){return e===!1}function rl(){let{t:e}=H(),t=K(e=>e.modelSwitcherOpen),n=K(e=>e.setModelSwitcherOpen),r=W(e=>e.favoriteModels),i=W(e=>e.keyboardShortcuts),[a,o]=(0,X.useState)(``),[s,c]=(0,X.useState)(null),[l,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(0),[p,m]=(0,X.useState)([]),[h,g]=(0,X.useState)({}),[_,v]=(0,X.useState)(null),y=(0,X.useRef)(null),b=(0,X.useRef)(t);(0,X.useEffect)(()=>{b.current=t},[t]);let x=R(e=>e.wsUrl),S=R(e=>e.provider),C=R(e=>e.model),w=N(e=>e.session?.provider??S),T=N(e=>e.session?.model??C),E=N(e=>e.reasoningEffortLevels),D=N(e=>e.projectReasoningEffort),O=W(e=>e.reasoningEffort),k=(0,X.useMemo)(()=>el(E,O),[E,O]),A=O===`auto`&&D?e(`settings:agent.reasoningEffortAutoHint`,{value:Xc(D)?e($c(D)):D}):void 0,j=K(e=>e.paletteOpen),{listSavedProviders:P,listProviderModels:F,switchModel:I,updatePrefs:L}=ha();(0,X.useEffect)(()=>{let e=e=>{let r=e.ctrlKey||e.metaKey;if(i&&r&&e.key.toLowerCase()===`m`&&!e.shiftKey&&!e.altKey){if(j)return;e.preventDefault(),n(!t);return}e.key===`Escape`&&t&&(e.preventDefault(),n(!1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,j,n,i]),(0,X.useEffect)(()=>{let e=V(x),t=e.on(`providers.saved`,e=>{let t=e.payload;m(t.providers??[])}),n=e.on(`provider.models`,e=>{let t=e.payload;g(e=>({...e,[t.provider]:t.models}))});return()=>{t(),n()}},[x]),(0,X.useEffect)(()=>{t&&(o(``),c(null),u(!1),f(0),P(),requestAnimationFrame(()=>y.current?.focus()))},[t,P]),(0,X.useEffect)(()=>{if(t)for(let e of p)h[e.id]||F(e.id)},[t,p,h,F]);let ee=(0,X.useMemo)(()=>[...new Set(p.map(e=>e.id))].sort((e,t)=>e.localeCompare(t)),[p]),te=(0,X.useMemo)(()=>no(p,h,a,w,T,s,l,r),[p,h,a,w,T,s,l,r]);(0,X.useEffect)(()=>{d>=te.length&&f(0)},[te.length,d]);let z=async t=>{let r=te[t];if(!r||_)return;if(r.isCurrent){n(!1);return}let i=`${r.provider} / ${r.model}`;v(i);let a=await I(r.provider,r.model);if(a.success){let e=N.getState().session;if(e){N.getState().setSession({...e,provider:r.provider,model:r.model}),(r.reasoningEffortLevels||r.effortSupported!==void 0)&&N.getState().setEnv({reasoningEffortLevels:r.reasoningEffortLevels,effortSupported:r.effortSupported});let t=M.get(e.id);t&&(t.provider=r.provider,t.model=r.model,t.session&&(t.session.provider=r.provider,t.session.model=r.model))}}b.current&&(a.success?(B.success(e(a.runActive?`settings:toast.modelSwitchedRunActive`:`settings:toast.modelSwitchedNextRequest`,{from:`${w} / ${T}`,to:i})),n(!1)):B.error(a.message)),v(null)};return(0,Z.jsx)(Ja,{open:t,onOpenChange:e=>{e||(v(null),n(!1))},children:(0,Z.jsxs)(Ga,{className:`max-w-xl gap-0 p-0 overflow-hidden pt-[15dvh]`,showCloseButton:!1,onOpenAutoFocus:e=>{e.preventDefault(),y.current?.focus()},"aria-busy":_!==null,children:[(0,Z.jsx)(Ka,{className:`sr-only`,children:e(`activity:modelSwitcher.heading`)}),(0,Z.jsx)(qa,{className:`sr-only`,children:e(`activity:modelSwitcher.filterPlaceholder`)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 border-b px-3 py-2`,children:[(0,Z.jsx)(vn,{className:`h-4 w-4 text-muted-foreground shrink-0`}),(0,Z.jsx)(`input`,{ref:y,value:a,onChange:e=>{o(e.target.value),f(0)},onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),f(e=>Math.min(te.length-1,e+1))):e.key===`ArrowUp`?(e.preventDefault(),f(e=>Math.max(0,e-1))):e.key===`Enter`&&(e.preventDefault(),z(d))},placeholder:e(`activity:modelSwitcher.filterPlaceholder`),"aria-label":e(`activity:modelSwitcher.filterPlaceholder`),className:`flex-1 bg-transparent outline-none text-sm placeholder:text-muted-foreground min-w-0`}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>{u(e=>!e),f(0)},title:e(`activity:modelSwitcher.favoritesOnly`),"aria-label":e(`activity:modelSwitcher.favoritesOnly`),"aria-pressed":l,className:G(`flex items-center gap-1 rounded-md px-2 py-1 text-xs transition-colors border shrink-0`,l?`bg-warning/15 border-warning/40 text-warning font-medium`:`bg-transparent border-border/70 text-muted-foreground hover:text-foreground hover:bg-muted/50`),children:[(0,Z.jsx)(Hi,{className:G(`h-3.5 w-3.5`,l?`fill-warning text-warning`:`text-muted-foreground`)}),(0,Z.jsx)(`span`,{className:`text-[11px] whitespace-nowrap`,children:e(`activity:modelSwitcher.favoritesOnly`)})]}),ee.length>1&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,Z.jsx)($e,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,Z.jsxs)(`select`,{value:s??``,onChange:e=>{c(e.target.value||null),f(0)},"aria-label":e(`activity:modelSwitcher.providerFilter`),className:`bg-transparent text-xs text-muted-foreground outline-none cursor-pointer border-0 min-w-0 truncate`,children:[(0,Z.jsx)(`option`,{value:``,children:e(`activity:modelSwitcher.providerFilterAll`)}),ee.map(e=>(0,Z.jsx)(`option`,{value:e,children:e},e))]})]}),(0,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground font-mono shrink-0`,children:_?e(`settings:toast.switchingToTarget`,{target:_}):`↑↓ · Enter · Esc`})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 border-b px-3 py-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`quick-model-effort`,className:`text-[11px] text-muted-foreground shrink-0`,children:e(`settings:agent.reasoningEffortLabel`)}),(0,Z.jsx)(`select`,{id:`quick-model-effort`,value:O,onChange:e=>{let t=e.target.value;W.getState().set({reasoningEffort:t}),L({reasoningEffort:t})},className:`bg-transparent text-xs outline-none cursor-pointer border-0`,children:k.map(t=>(0,Z.jsx)(`option`,{value:t,children:e($c(t))},t))}),tl(E,O)&&(0,Z.jsx)(`span`,{className:`text-[10px] text-warning truncate min-w-0`,title:e(`settings:agent.reasoningEffortUnsupported`,{levels:(E??[]).join(`, `)}),children:e(`settings:agent.reasoningEffortUnsupported`,{levels:(E??[]).join(`, `)})}),A&&(0,Z.jsx)(`span`,{className:`ml-auto shrink-0 text-[10px] text-muted-foreground`,children:A})]}),(0,Z.jsx)(`div`,{className:`max-h-[50dvh] overflow-y-auto py-1`,children:te.length===0?(0,Z.jsx)(`div`,{className:`px-4 py-8 text-center text-sm text-muted-foreground`,children:p.length===0?e(`activity:modelSwitcher.noSavedProviders`):Object.keys(h).length===0?e(`activity:model.loading`):l?r?.length===0?e(`activity:modelSwitcher.noFavoritesConfigured`):e(`activity:modelSwitcher.noFavoritesMatch`):e(`activity:modelSwitcher.noMatch`)}):te.map((t,n)=>(0,Z.jsxs)(`button`,{type:`button`,"data-model-candidate":`true`,onClick:()=>void z(n),disabled:_!==null,onMouseEnter:()=>f(n),className:G(`w-full flex items-center gap-3 px-3 py-2 text-left text-sm transition-colors`,n===d?`bg-accent text-accent-foreground`:`hover:bg-accent/40`,t.isCurrent&&`font-medium`),children:[(0,Z.jsx)(ar,{className:G(`h-4 w-4 shrink-0`,t.isCurrent?`text-primary`:`text-muted-foreground`)}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 break-words`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:t.provider}),(0,Z.jsx)(`span`,{className:`text-muted-foreground/65`,children:`·`}),(0,Z.jsx)(`span`,{children:t.modelName}),t.isFavorite&&(0,Z.jsx)(`span`,{title:e(`activity:modelSwitcher.favoriteModel`),children:(0,Z.jsx)(Hi,{className:`h-3 w-3 fill-warning text-warning shrink-0`})})]}),(t.contextWindow||t.reasoningEffortLevels)&&(0,Z.jsxs)(`div`,{className:`text-[10px] text-muted-foreground font-mono break-words`,children:[t.model,t.contextWindow?` · ctx ${t.contextWindow.toLocaleString()}`:``,t.reasoningEffortLevels?` · effort ${t.reasoningEffortLevels.join(`/`)}`:``]})]}),t.isCurrent?(0,Z.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-primary font-semibold`,children:e(`activity:modelSwitcher.active`)}):(0,Z.jsx)(Ln,{className:`h-3.5 w-3.5 text-muted-foreground opacity-0 group-hover:opacity-100`})]},`${t.provider}:${t.model}`))})]})})}var il=[{name:`primary`,dot:`bg-primary`,text:`text-primary`,border:`border-primary`,soft:`bg-primary/10`},{name:`info`,dot:`bg-info`,text:`text-info`,border:`border-info`,soft:`bg-info/10`},{name:`warning`,dot:`bg-warning`,text:`text-warning`,border:`border-warning`,soft:`bg-warning/10`},{name:`success`,dot:`bg-success`,text:`text-success`,border:`border-success`,soft:`bg-success/10`}];function al(e){return il[e%il.length]}function ol(e){let t=P(e=>e.openTabIds),n=P(e=>e.lastSeenCounts),r=P(e=>e.attention),i=l(e=>e.lanes),a=l(e=>e.activeSessionId),o=Se(e=>e.lanes),s=_(e=>e.agents),c=K(e=>e.sessionNicknames);return(0,X.useMemo)(()=>{let l=new Map;for(let e of s.values()){if(!e.sessionId)continue;let t=l.get(e.sessionId)??{running:0,total:0};t.total+=1,e.status===`running`&&(t.running+=1),l.set(e.sessionId,t)}return t.map((t,s)=>{let u=i[t],d=o[t],f=l.get(t)??{running:0,total:0},p=u?.messages.length??0,m=n[t]??p,h=t===a,g=d?.maxContext??0,_=d?.lastInputTokens??0;return{slot:s,sessionId:t,isActive:h,title:c[t]||e?.get(t)||d?.session?.title||t.slice(0,8),provider:d?.session?.provider??``,model:d?.session?.model??``,mode:d?.mode??`default`,isRunning:u?.isLoading??!1,messageCount:p,unread:h?0:Math.max(0,p-m),queued:u?.queue.length??0,agentsRunning:f.running,agentsTotal:f.total,tokens:(d?.totalTokens.input??0)+(d?.totalTokens.output??0),cost:d?.cost??0,contextPct:g>0&&_>0?Math.min(100,Math.round(_/g*100)):0,needsAttention:!h&&r[t]===!0}})},[t,n,r,i,o,a,s,c,e])}function sl(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function cl({tabs:e,onSelect:t,onNew:n}){let r=Array.from({length:ee},(t,n)=>e[n]??null);return(0,Z.jsxs)(`div`,{className:`w-[min(92vw,760px)] p-2`,children:[(0,Z.jsxs)(`div`,{className:`px-1 pb-2 text-[10px] uppercase tracking-wider text-muted-foreground`,children:[`Tab map — `,e.length,`/`,ee,` slots · one session per tab, nothing shared`]}),(0,Z.jsx)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:r.map((e,r)=>e?(0,Z.jsx)(ll,{tab:e,onSelect:t},e.sessionId):(0,Z.jsx)(dl,{slot:r,onNew:n},`empty-${r}`))})]})}function ll({tab:e,onSelect:t}){let n=al(e.slot);return(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>t(e.sessionId),className:G(`group flex w-full flex-col gap-1.5 rounded-md border p-2.5 text-left transition-colors`,e.isActive?G(`border-border/80 bg-background shadow-xs`,n.border):`border-border/40 bg-muted/20 hover:bg-muted/40`),children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:G(`inline-flex h-5 w-5 shrink-0 items-center justify-center rounded text-[10px] font-bold`,n.soft,n.text),children:e.slot+1}),(0,Z.jsx)(`span`,{className:`truncate text-xs font-medium`,children:e.title}),e.isActive&&(0,Z.jsx)(`span`,{className:G(`shrink-0 text-[9px] font-semibold uppercase`,n.text),children:`on screen`}),(0,Z.jsx)(`span`,{className:`ml-auto shrink-0`,children:e.needsAttention?(0,Z.jsx)(Kr,{className:`h-3.5 w-3.5 text-warning`}):e.isRunning?(0,Z.jsx)(wt,{className:`h-3.5 w-3.5 animate-spin text-primary`}):(0,Z.jsx)(Et,{className:`h-3.5 w-3.5 text-muted-foreground/50`})})]}),(0,Z.jsxs)(`div`,{className:`truncate font-mono text-[10px] text-muted-foreground`,children:[e.provider||`—`,` / `,e.model||`—`,` · `,e.mode]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-[10px] text-muted-foreground`,children:[(0,Z.jsx)(ul,{icon:(0,Z.jsx)(Lt,{className:`h-3 w-3`}),label:`${e.messageCount} msg`}),e.unread>0&&(0,Z.jsxs)(`span`,{className:`rounded bg-primary/15 px-1 font-semibold text-primary`,children:[`+`,e.unread,` new`]}),e.queued>0&&(0,Z.jsxs)(`span`,{children:[e.queued,` queued`]}),(0,Z.jsx)(ul,{icon:(0,Z.jsx)(jr,{className:`h-3 w-3`}),label:e.agentsTotal===0?`no agents`:`${e.agentsRunning}/${e.agentsTotal} agents`,tone:e.agentsRunning>0?`text-success`:void 0}),e.tokens>0&&(0,Z.jsxs)(`span`,{children:[sl(e.tokens),` tok`]}),e.cost>0&&(0,Z.jsxs)(`span`,{children:[`$`,e.cost.toFixed(4)]}),e.contextPct>0&&(0,Z.jsxs)(`span`,{children:[e.contextPct,`% ctx`]})]}),(0,Z.jsx)(`div`,{className:`truncate font-mono text-[9px] text-muted-foreground/60`,children:e.sessionId})]})}function ul({icon:e,label:t,tone:n}){return(0,Z.jsxs)(`span`,{className:G(`inline-flex items-center gap-1`,n),children:[e,t]})}function dl({slot:e,onNew:t}){let n=al(e);return(0,Z.jsxs)(`button`,{type:`button`,onClick:t,className:`flex w-full items-center gap-2 rounded-md border border-dashed border-border/50 p-2.5 text-left text-muted-foreground transition-colors hover:border-border hover:text-foreground`,children:[(0,Z.jsx)(`span`,{className:G(`inline-flex h-5 w-5 shrink-0 items-center justify-center rounded text-[10px] font-bold opacity-50`,n.soft,n.text),children:e+1}),(0,Z.jsx)(`span`,{className:`text-xs`,children:`Empty slot`}),(0,Z.jsx)(_i,{className:`ml-auto h-3.5 w-3.5`})]})}function fl(){let{t:e}=H(),{resumeSession:t,listSessions:n}=ha(),r=ve(),i=b(e=>e.entries),a=P(e=>e.openTabIds),o=P(e=>e.openTab),s=P(e=>e.closeTab),[c,l]=(0,X.useState)(!1),u=ol((0,X.useMemo)(()=>{let e=new Map;for(let t of i)e.set(t.id,t.name||t.title||t.id.slice(0,8));return e},[i]));(0,X.useEffect)(()=>{i.length===0&&n?.()},[i.length,n]);let d=e=>{l(!1),o(e,{resumeSession:t})},f=async(n,r)=>{r.stopPropagation();let i=fe(n);if(i.isEmpty){s(n);return}if(u.find(e=>e.sessionId===n)?.isActive||o(n,{resumeSession:t}),i.isBusy){if(!await $a({title:e(`activity:sessions.closeOngoingTabTitle`,{defaultValue:`There is an ongoing operation in this session`}),message:e(`activity:sessions.closeOngoingTabQuestion`,{defaultValue:`Are you sure you want to close this tab?`}),details:i.lines,confirmLabel:e(`activity:sessions.interruptAndClose`,{defaultValue:`Interrupt and Close`}),cancelLabel:e(`common:action.cancel`,{defaultValue:`Cancel`}),danger:!0,defaultAction:`cancel`}))return;try{V().sendAbort(n)}catch{}}else if(!await $a({title:e(`activity:sessions.closeHistoryTabTitle`,{defaultValue:`Close this tab?`}),message:e(`activity:sessions.closeHistoryTabMessage`,{defaultValue:`This tab contains agent history. Are you sure you want to close it?`}),details:i.lines,confirmLabel:e(`activity:sessions.closeTabAction`,{defaultValue:`Close Tab`}),cancelLabel:e(`common:action.cancel`,{defaultValue:`Cancel`}),danger:!0,defaultAction:`cancel`}))return;s(n)},p=()=>{if(l(!1),a.length<ee){T.getState().openPicker({startsSession:!0});return}B.info(e(`activity:sessions.allTabsRunning`,{defaultValue:`All 4 tab slots are full. Close a tab before opening a new session.`}))};return u.length===0&&!r?null:(0,Z.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center justify-between border-b border-border/70 bg-card/60 px-2 text-xs backdrop-blur-md`,children:[(0,Z.jsxs)(`div`,{role:`tablist`,"aria-label":`Open session tabs`,className:`flex min-w-0 flex-1 items-center gap-1 overflow-x-auto overscroll-contain [scrollbar-gutter:stable] no-scrollbar`,children:[u.map(e=>{let t=al(e.slot);return(0,Z.jsxs)(`div`,{role:`tab`,tabIndex:0,"aria-selected":e.isActive,onClick:()=>d(e.sessionId),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),d(e.sessionId))},className:G(`group relative flex h-7 max-w-[220px] min-w-[126px] cursor-pointer items-center gap-1.5 rounded-t-md border-t border-x px-2 transition-colors select-none`,e.isActive?`border-border/80 bg-background text-foreground font-medium shadow-xs`:`border-transparent bg-transparent text-muted-foreground hover:bg-muted/40 hover:text-foreground`),title:`Slot ${e.slot+1} · ${e.title}\n${e.provider}/${e.model}\n${e.sessionId}`,children:[(0,Z.jsx)(`span`,{className:G(`inline-flex h-4 w-4 shrink-0 items-center justify-center rounded text-[9px] font-bold`,t.soft,t.text),children:e.slot+1}),(0,Z.jsx)(`span`,{className:`shrink-0`,children:e.needsAttention?(0,Z.jsx)(Kr,{className:`h-3 w-3 text-warning`}):e.isRunning?(0,Z.jsx)(wt,{className:`h-3 w-3 animate-spin text-primary`}):(0,Z.jsx)(Lt,{className:`h-3 w-3 opacity-50`})}),(0,Z.jsx)(`span`,{className:`truncate text-[11px] font-mono leading-tight`,children:e.title}),e.unread>0&&(0,Z.jsxs)(`span`,{className:`shrink-0 rounded bg-primary/15 px-1 text-[9px] font-semibold text-primary`,title:`${e.unread} new message(s) since you last looked`,children:[`+`,e.unread]}),(0,Z.jsxs)(`span`,{className:G(`inline-flex shrink-0 items-center gap-0.5 rounded px-1 text-[9px] font-semibold`,e.agentsRunning>0?`bg-success/15 text-success`:e.agentsTotal>0?`bg-muted/60 font-mono text-muted-foreground`:`bg-muted/30 font-mono text-muted-foreground/65`),title:e.agentsRunning>0?`${e.agentsRunning} running agent(s) in this tab, ${e.agentsTotal} total`:`${e.agentsTotal} agent(s) in this tab`,children:[(0,Z.jsx)(jr,{className:`h-2.5 w-2.5`}),e.agentsRunning>0?`${e.agentsRunning}/${e.agentsTotal}`:e.agentsTotal]}),u.length>1&&(0,Z.jsx)(`button`,{type:`button`,onClick:t=>f(e.sessionId,t),title:`Close tab`,className:G(`ml-auto h-4 w-4 shrink-0 inline-flex items-center justify-center rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors`,e.isActive?`opacity-70 hover:opacity-100`:`opacity-0 group-hover:opacity-100`),children:(0,Z.jsx)(St,{className:`h-2.5 w-2.5`})}),e.isActive&&(0,Z.jsx)(`div`,{className:G(`absolute inset-x-0 -bottom-[1px] h-[2px]`,t.dot)})]},e.sessionId)}),(0,Z.jsx)(`button`,{type:`button`,onClick:p,title:e(`chat:newSession`,`New Session`),className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors`,children:(0,Z.jsx)(_i,{className:`h-3.5 w-3.5`})})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 pl-1`,children:[(0,Z.jsxs)(mo,{open:c,onOpenChange:l,children:[(0,Z.jsx)(ho,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex h-7 items-center gap-1 rounded px-2 text-[11px] text-muted-foreground hover:bg-muted hover:text-foreground transition-colors`,title:`What is in each tab`,children:[(0,Z.jsxs)(`span`,{className:`font-mono`,children:[u.length,`/`,ee]}),(0,Z.jsx)(`span`,{className:`hidden sm:inline`,children:`Map`}),(0,Z.jsx)(Ct,{className:`h-3 w-3 opacity-60`})]})}),(0,Z.jsx)(vo,{align:`end`,className:`p-0`,children:(0,Z.jsx)(cl,{tabs:u,onSelect:d,onNew:p})})]}),(0,Z.jsxs)(mo,{children:[(0,Z.jsx)(ho,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex h-7 items-center gap-1 rounded px-2 text-[11px] text-muted-foreground hover:bg-muted hover:text-foreground transition-colors`,title:`All Sessions`,children:[(0,Z.jsx)(Fn,{className:`h-3 w-3`}),(0,Z.jsx)(`span`,{className:`hidden sm:inline`,children:`Sessions`}),(0,Z.jsx)(Ct,{className:`h-3 w-3 opacity-60`})]})}),(0,Z.jsxs)(vo,{align:`end`,className:`w-64 max-h-80 overflow-y-auto`,children:[(0,Z.jsxs)(So,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:[`Recent Sessions (`,i.length,`)`]}),(0,Z.jsx)(Co,{}),i.slice(0,15).map(e=>{let t=a.indexOf(e.id),n=e.name||e.title||e.id.slice(0,8);return(0,Z.jsxs)(yo,{onSelect:()=>d(e.id),className:`flex items-center justify-between text-xs font-mono`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 truncate`,children:[(0,Z.jsx)(Lt,{className:G(`h-3.5 w-3.5 shrink-0`,e.id===r?`text-primary`:`text-muted-foreground`)}),(0,Z.jsx)(`span`,{className:G(`truncate`,e.id===r&&`text-primary font-medium`),children:n})]}),t>=0&&(0,Z.jsxs)(`span`,{className:G(`ml-1 text-[10px] font-semibold`,al(t).text),title:`Already open in slot ${t+1}`,children:[`▪ `,t+1]})]},e.id)})]})]})]})]})}var pl=[{sectionKey:`sectionGlobal`,items:[{keys:[`Ctrl`,`K`],descKey:`dCommandPalette`},{keys:[`?`],descKey:`dShowOverlay`},{keys:[`Ctrl`,`\\`],descKey:`dToggleSidebar`},{keys:[`Ctrl`,`1-8`],descKey:`dOpenPanel`},{keys:[`Ctrl`,`9`],descKey:`dSettings`},{keys:[`Ctrl`,`0`],descKey:`dDesignStudio`},{keys:[`Ctrl`,`Shift`,`W`],descKey:`dWorktrees`},{keys:[`Ctrl`,`Shift`,`K`],descKey:`dMemory`},{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:[`Alt`,`Enter`],descKey:`dFastSend`},{keys:[`↑`],descKey:`dPreviousPrompt`},{keys:[`↓`],descKey:`dNextPrompt`},{keys:[`Esc`],descKey:`dAbortStream`}]},{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 ml(){let{t:e}=H(),t=K(e=>e.shortcutsOpen),n=K(e=>e.setShortcutsOpen),r=W(e=>e.keyboardShortcuts);return(0,X.useEffect)(()=>{if(!r)return;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(!K.getState().shortcutsOpen))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n,r]),(0,Z.jsx)(Ja,{open:t,onOpenChange:e=>{e||n(!1)},children:(0,Z.jsxs)(Ga,{className:`max-w-2xl gap-0 p-0 overflow-hidden flex flex-col max-h-[80dvh]`,children:[(0,Z.jsx)(`div`,{className:`flex items-center justify-between px-5 py-4 border-b`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Wn,{className:`h-4 w-4 text-muted-foreground`}),(0,Z.jsx)(Ka,{className:`text-sm font-semibold`,children:e(`activity:shortcuts.heading`)})]})}),(0,Z.jsx)(qa,{className:`sr-only`,children:e(`activity:shortcuts.heading`)}),(0,Z.jsx)(`div`,{className:`overflow-y-auto overscroll-contain px-5 py-4 space-y-6`,children:pl.map(t=>(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground mb-2`,children:e(`activity:shortcuts.${t.sectionKey}`)}),(0,Z.jsx)(`div`,{className:`grid grid-cols-1 gap-1.5`,children:t.items.map(t=>(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-sm px-2 py-1.5 rounded hover:bg-muted/40`,children:[(0,Z.jsx)(`span`,{className:`text-foreground/80`,children:e(`activity:shortcuts.${t.descKey}`)}),(0,Z.jsx)(`span`,{className:`flex items-center gap-1 shrink-0`,children:t.keys.map((e,t)=>(0,Z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[t>0&&(0,Z.jsx)(`span`,{className:`text-muted-foreground/65 text-xs`,children:`+`}),(0,Z.jsx)(`kbd`,{className:`font-mono text-[10px] border rounded px-1.5 py-0.5 bg-background`,children:Va(e)})]},e))})]},t.descKey))})]},t.sectionKey))}),(0,Z.jsxs)(`div`,{className:`border-t px-5 py-3 text-xs text-muted-foreground`,children:[e(`activity:shortcuts.footerPre`),` `,(0,Z.jsx)(`kbd`,{className:`font-mono text-[10px] border rounded px-1 py-0.5 bg-background`,children:`?`}),` `,e(`activity:shortcuts.footerPost`)]})]})})}function hl(){document.querySelector(`[role="dialog"]`)||document.getElementById(`ws-file-tree`)?.focus()}function gl({contextMenu:e,onClose:t,copyToClipboard:n,handleStartCreate:r,handleShellOpen:i}){let{t:a}=H(),o=e.crumb;return(0,Z.jsxs)(mo,{open:!0,onOpenChange:e=>{e||t()},children:[(0,Z.jsx)(ho,{asChild:!0,children:(0,Z.jsx)(`span`,{"aria-hidden":`true`,tabIndex:-1,style:{position:`fixed`,left:e.x,top:e.y,width:1,height:1}})}),(0,Z.jsxs)(vo,{side:`right`,align:`start`,className:`min-w-[160px]`,onCloseAutoFocus:e=>{e.preventDefault(),hl()},children:[(0,Z.jsx)(yo,{onSelect:()=>n(o.absPath),children:a(`activity:fileExplorer.copyAbsPath`)}),(0,Z.jsx)(yo,{onSelect:()=>n(o.relPath),children:a(`activity:fileExplorer.copyRelPath`)}),(0,Z.jsx)(Co,{}),(0,Z.jsxs)(yo,{onSelect:()=>r(o.relPath===`.`?``:o.relPath,`file`),children:[(0,Z.jsx)(Re,{}),a(`activity:fileExplorer.newFile`)]}),(0,Z.jsxs)(yo,{onSelect:()=>r(o.relPath===`.`?``:o.relPath,`directory`),children:[(0,Z.jsx)(Nt,{}),a(`activity:fileExplorer.newFolder`)]}),(0,Z.jsx)(Co,{}),(0,Z.jsx)(yo,{onSelect:()=>i(o.absPath,`terminal`),children:a(`activity:fileExplorer.openInTerminal`)}),(0,Z.jsx)(yo,{onSelect:()=>i(o.absPath,`file-manager`),children:a(`activity:fileExplorer.openInFileManager`)}),(0,Z.jsx)(Co,{}),(0,Z.jsx)(So,{className:`max-w-[220px] truncate text-[9px] font-normal text-muted-foreground/70`,children:o.absPath})]})]})}function _l({nodeMenu:e,onClose:t,handleMentionInChat:n,copyNodePath:r,handleStartCreate:i,handleStartRename:a,handleDelete:o}){let{t:s}=H(),c=e.node;return(0,Z.jsxs)(mo,{open:!0,onOpenChange:e=>{e||t()},children:[(0,Z.jsx)(ho,{asChild:!0,children:(0,Z.jsx)(`span`,{"aria-hidden":`true`,tabIndex:-1,style:{position:`fixed`,left:e.x,top:e.y,width:1,height:1}})}),(0,Z.jsxs)(vo,{side:`right`,align:`start`,className:`min-w-[170px]`,onCloseAutoFocus:e=>{e.preventDefault(),hl()},children:[c.type===`file`&&(0,Z.jsx)(yo,{onSelect:()=>n(c),children:s(`activity:fileExplorer.mentionInChat`)}),(0,Z.jsx)(yo,{onSelect:()=>r(c.path),children:s(`activity:fileExplorer.copyPath`)}),(0,Z.jsx)(Co,{}),c.type===`directory`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(yo,{onSelect:()=>i(c.path,`file`),children:[(0,Z.jsx)(Re,{}),s(`activity:fileExplorer.newFile`)]}),(0,Z.jsxs)(yo,{onSelect:()=>i(c.path,`directory`),children:[(0,Z.jsx)(Nt,{}),s(`activity:fileExplorer.newFolder`)]})]}),(0,Z.jsx)(yo,{onSelect:()=>a(c),children:s(`activity:fileExplorer.rename`)}),(0,Z.jsxs)(yo,{onSelect:()=>o(c),className:`text-destructive focus:bg-destructive/10`,children:[(0,Z.jsx)(vr,{}),s(`activity:fileExplorer.delete`)]}),(0,Z.jsx)(Co,{}),(0,Z.jsx)(So,{className:`max-w-[220px] truncate text-[9px] font-normal text-muted-foreground/70`,children:c.path})]})]})}function vl({createPrompt:e,createName:t,setCreateName:n,onCancel:r,onConfirm:i}){let{t:a}=H();return(0,Z.jsx)(Ja,{open:!0,onOpenChange:e=>{e||r()},children:(0,Z.jsxs)(Ga,{showCloseButton:!1,className:`max-w-[340px] gap-3 p-4`,children:[(0,Z.jsxs)(Ua,{children:[(0,Z.jsx)(Ka,{className:`text-[13px]`,children:e.type===`file`?a(`activity:fileExplorer.newFileTitle`):a(`activity:fileExplorer.newFolderTitle`)}),(0,Z.jsx)(qa,{className:`truncate text-[11px]`,children:e.dirPath||`.`})]}),(0,Z.jsx)(`input`,{type:`text`,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{e.key===`Enter`&&i()},placeholder:e.type===`file`?a(`activity:fileExplorer.newFileNamePlaceholder`):a(`activity:fileExplorer.newFolderNamePlaceholder`),className:`w-full px-2 py-1 text-[11px] border rounded bg-background outline-none focus:ring-1 ring-primary`}),(0,Z.jsxs)(Wa,{className:`gap-2`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:r,className:`px-2 py-1 text-[10px] rounded border text-muted-foreground hover:text-foreground`,children:a(`common:action.cancel`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:i,disabled:!t.trim(),className:`px-2 py-1 text-[10px] rounded border border-primary text-primary font-medium hover:bg-primary hover:text-primary-foreground disabled:opacity-40`,children:a(`common:action.create`)})]})]})})}function yl({renamePrompt:e,renameValue:t,setRenameValue:n,onCancel:r,onConfirm:i}){let{t:a}=H();return(0,Z.jsx)(Ja,{open:!0,onOpenChange:e=>{e||r()},children:(0,Z.jsxs)(Ga,{showCloseButton:!1,className:`max-w-[340px] gap-3 p-4`,children:[(0,Z.jsxs)(Ua,{children:[(0,Z.jsx)(Ka,{className:`text-[13px]`,children:a(`activity:fileExplorer.renameTitle`)}),(0,Z.jsx)(qa,{className:`truncate text-[11px]`,children:e.oldPath})]}),(0,Z.jsx)(`input`,{type:`text`,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{e.key===`Enter`&&i()},className:`w-full px-2 py-1 text-[11px] border rounded bg-background outline-none focus:ring-1 ring-primary`}),(0,Z.jsxs)(Wa,{className:`gap-2`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:r,className:`px-2 py-1 text-[10px] rounded border text-muted-foreground hover:text-foreground`,children:a(`common:action.cancel`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:i,disabled:!t.trim()||t.trim()===e.initialName,className:`px-2 py-1 text-[10px] rounded border border-primary text-primary font-medium hover:bg-primary hover:text-primary-foreground disabled:opacity-40`,children:a(`common:action.rename`)})]})]})})}var bl={ts:kn,tsx:kn,js:kn,jsx:kn,mjs:kn,cjs:kn,json:Pn,lock:pn,css:tn,scss:tn,less:tn,html:Ot,htm:Ot,svg:xn,xml:Ot,md:tn,mdx:tn,txt:tn,yml:tn,yaml:tn,toml:di,env:di,gitignore:di,editorconfig:di,sh:kn,bash:kn,zsh:kn,fish:kn,ps1:kn,bat:kn,py:kn,pyi:kn,pyx:kn,rs:kn,go:kn,rb:kn,java:kn,c:kn,cpp:kn,h:kn,hpp:kn,sql:kn,graphql:kn,png:xn,jpg:xn,jpeg:xn,gif:xn,webp:xn,ico:xn};function xl(e,t){if(t){let t=e.toLowerCase();return t===`.git`?`text-primary/80`:t===`node_modules`?`text-destructive/70`:t===`src`||t===`lib`||t===`packages`?`text-warning/80`:t===`tests`||t===`test`||t===`__tests__`?`text-success/80`:t===`dist`||t===`build`||t===`.next`?`text-muted-foreground/70`:`text-warning/80`}let n=e.split(`.`).pop()?.toLowerCase()??``;return/^(ts|tsx|js|jsx|mjs|cjs|py|pyi|pyx|go)$/.test(n)?`text-info`:/^(json|lock)$/.test(n)?`text-warning`:/^(css|scss|less|sass)$/.test(n)?`text-accent-foreground`:/^(html|htm|xml|svg|rb)$/.test(n)?`text-destructive`:/^(md|mdx|png|jpe?g|gif|webp|ico)$/.test(n)?`text-primary`:/^(yml|yaml|toml|env)$/.test(n)?`text-success`:/^(sh|bash|zsh|fish|ps1|bat|rs)$/.test(n)?`text-brand-orange`:/^(c|h|cpp|hpp|cc|hh)$/.test(n)?`text-muted-foreground/80`:/^(gitignore|editorconfig|prettierrc|eslintrc)$/.test(n)?`text-muted-foreground/75`:`text-muted-foreground`}function Sl(e){return bl[e.split(`.`).pop()?.toLowerCase()??``]??gt}function Cl(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 wl(e,t){let n=e.toLowerCase(),r=n.split(`/`).pop()??n,i=0;if(r===t)i=100;else if(r.startsWith(t))i=60;else if(n.includes(t))i=20;else return-1;return i-=n.split(`/`).length,i}function Tl(e){let t=[],n=e=>{for(let r of e)r.type===`file`?t.push(r):r.children&&n(r.children)};return n(e),t}function El(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}function Dl(e){return`ws-file-row-${encodeURIComponent(e)}`}var Ol={M:`text-warning`,A:`text-success`,D:`text-destructive`,R:`text-info`,C:`text-info`,U:`text-destructive`,"?":`text-primary`},kl={M:`Modified`,A:`Added`,D:`Deleted`,R:`Renamed`,C:`Copied`,U:`Unmerged`,"?":`Untracked`};function Al({status:e}){let t=e[0]??`?`,n=Ol[t]??`text-muted-foreground`,r=kl[t]??`Unknown`;return(0,Z.jsx)(`span`,{role:`img`,"aria-label":r,className:G(`shrink-0 text-[8px] font-bold tabular-nums`,n),title:r,children:t})}var jl=(0,X.memo)(function({node:e,depth:t,emptyPlaceholder:n,expanded:r,isActive:i,isSelected:a,isFocused:o,gitStatus:s,onToggle:c,onSelect:l,onOpen:u,onContextMenu:d}){let{t:f}=H();if(n)return(0,Z.jsx)(`div`,{role:`treeitem`,"aria-disabled":`true`,"aria-level":t+1,className:`text-[10px] text-muted-foreground italic py-0.5`,style:{paddingLeft:`${t*14+4}px`},children:f(`activity:fileExplorer.emptyDir`)});if(e.type===`directory`){let n=r?Rt:Br,i=xl(e.name,!0);return(0,Z.jsxs)(`button`,{type:`button`,id:Dl(e.path),title:e.path,role:`treeitem`,"aria-expanded":r,"aria-level":t+1,tabIndex:-1,onClick:()=>c(e.path),onContextMenu:t=>d(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,Z.jsx)(ot,{className:G(`h-3 w-3 shrink-0 text-muted-foreground transition-transform`,r&&`rotate-90`)}),(0,Z.jsx)(n,{className:G(`h-3.5 w-3.5 shrink-0`,i)}),(0,Z.jsx)(`span`,{className:G(`truncate font-medium flex-1 min-w-0`,s===`M`&&`text-warning/80`),children:e.name}),s&&(0,Z.jsx)(Al,{status:s})]})}let p=Sl(e.name),m=xl(e.name,!1);return(0,Z.jsxs)(`button`,{type:`button`,id:Dl(e.path),title:e.path,role:`treeitem`,"aria-level":t+1,"aria-selected":i||a,tabIndex:-1,onClick:()=>{l(e.path),u(e.path)},onContextMenu:t=>d(t,e),onDoubleClick:t=>{t.preventDefault(),u(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,Z.jsx)(`span`,{className:`w-3 shrink-0`}),(0,Z.jsx)(p,{className:G(`h-3.5 w-3.5 shrink-0`,m)}),(0,Z.jsx)(`span`,{className:G(`truncate flex-1 min-w-0`,!i&&s===`M`&&`text-warning/90`,!i&&(s===`A`||s===`?`)&&`text-success/90`,s===`D`&&`line-through opacity-70 text-destructive/90`),children:e.name}),s&&(0,Z.jsx)(Al,{status:s})]})});async function Ml(e){try{if(typeof navigator<`u`&&navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),n}catch{return!1}}function Nl(e,t){if(typeof document>`u`)return;let n=new Blob([t],{type:`text/plain;charset=utf-8`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i),setTimeout(()=>URL.revokeObjectURL(r),1e3)}function Pl(e){let t=(e??``).toLowerCase();return/bash|shell|exec|run/.test(t)?`log`:(/grep|search|find/.test(t),`txt`)}function Fl(e){return e<1e3?`${e} ms`:e<6e4?`${(e/1e3).toFixed(e<1e4?2:1)}s`:`${Math.floor(e/6e4)}m ${Math.floor(e%6e4/1e3)}s`}function Il(e){if(!e)return;let t=e.match(/(?:^|\n)\s*(?:\[?exit(?:\s*code)?\]?\s*[:=]?\s*)(\d+)\s*$/i);return t?Number(t[1]):void 0}var Ll=[ao];function Rl(e){return typeof e==`string`||typeof e==`number`?String(e):Array.isArray(e)?e.map(Rl).join(``):(0,X.isValidElement)(e)?Rl(e.props.children):``}function zl({text:e}){let{t}=H(),[n,r]=(0,X.useState)(!1),i=(0,X.useCallback)(async()=>{await Ml(e)&&(r(!0),setTimeout(()=>r(!1),1500))},[e]);return(0,Z.jsxs)(`button`,{type:`button`,onClick:i,className:G(`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] transition-colors`,`hover:bg-muted-foreground/10`,n?`text-success`:`text-muted-foreground hover:text-foreground`),title:t(n?`common:action.copied`:`common:action.copy`),children:[n?(0,Z.jsx)(ui,{className:`h-3 w-3`}):(0,Z.jsx)(oi,{className:`h-3 w-3`}),(0,Z.jsx)(`span`,{children:t(n?`common:action.copied`:`common:action.copy`)})]})}var Bl={code({inline:e,className:t,children:n,...r}){let i=/language-(\w+)/.exec(t??``),a=Rl(n).replace(/\n$/,``);if(e||!i)return(0,Z.jsx)(`code`,{className:G(`rounded border border-border/60 px-1.5 py-0.5 text-[0.85em] font-mono`,t),...r,children:n});let o=(0,X.useMemo)(()=>a.split(`
|
|
73
|
+
`),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 Nc(){let e=Ea(e=>e.sideEffects),t=Ea(e=>e.loading),{t:n}=H(),[r,i]=(0,X.useState)(`all`),[a,o]=(0,X.useState)(`time`),[s,c]=(0,X.useState)(`desc`),l=ve();(0,X.useEffect)(()=>{Ea.getState().setLoading(!0),ta(async()=>{let{getWSClient:e}=await import(`./ws-client-BR51gfnV.js`).then(e=>e.n);return{getWSClient:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16])).then(({getWSClient:e})=>{e().send({type:`side_effects.list`,...l?{payload:{sessionId:l}}:{}})})},[l]);let u=()=>{Ea.getState().setLoading(!0),ta(async()=>{let{getWSClient:e}=await import(`./ws-client-BR51gfnV.js`).then(e=>e.n);return{getWSClient:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16])).then(({getWSClient:e})=>{e().send({type:`side_effects.list`,...l?{payload:{sessionId:l}}:{}})})},d=e=>{a===e?c(s===`asc`?`desc`:`asc`):(o(e),c(e===`time`?`desc`:`asc`))},f=(0,X.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]),p=wc(f,20,`${r}:${a}:${s}`);if(e.length===0&&!t)return(0,Z.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 py-8 text-muted-foreground`,children:[(0,Z.jsx)(Ge,{className:`h-8 w-8 opacity-40`}),(0,Z.jsx)(`p`,{className:`text-sm`,children:n(`activity:sideEffects.empty`)}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground/75`,children:n(`activity:sideEffects.emptyHint`)})]});let m=({column:e})=>a===e?s===`asc`?(0,Z.jsx)(dn,{className:`inline h-3 w-3`}):(0,Z.jsx)(Ct,{className:`inline h-3 w-3`}):(0,Z.jsx)(`span`,{className:`opacity-30`,children:`↕`});return(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/70 bg-card/70 px-3 py-2`,children:[(0,Z.jsxs)(`h3`,{className:`text-xs font-semibold uppercase text-muted-foreground`,children:[n(`activity:sideEffects.heading`),` (`,f.length,r===`all`?``:`/${e.length}`,`)`]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>Mc(f),disabled:f.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,Z.jsx)(ti,{className:`h-3 w-3`}),`CSV`]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:u,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,Z.jsx)(xi,{className:G(`h-3 w-3`,t&&`animate-spin`)}),n(`common:action.refresh`)]})]})]}),(0,Z.jsx)(`div`,{className:`flex items-center gap-1 border-b border-border/60 bg-muted/20 px-2 py-1`,children:Oc.map(e=>(0,Z.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,Z.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Z.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,Z.jsx)(`thead`,{className:`sticky top-0 bg-card/95 text-muted-foreground backdrop-blur`,children:(0,Z.jsxs)(`tr`,{children:[(0,Z.jsxs)(`th`,{className:`cursor-pointer select-none px-2 py-1 text-left font-medium hover:text-foreground`,onClick:()=>d(`time`),children:[n(`activity:sideEffects.colTime`),` `,(0,Z.jsx)(m,{column:`time`})]}),(0,Z.jsxs)(`th`,{className:`cursor-pointer select-none px-2 py-1 text-left font-medium hover:text-foreground`,onClick:()=>d(`tool`),children:[n(`activity:sideEffects.colTool`),` `,(0,Z.jsx)(m,{column:`tool`})]}),(0,Z.jsxs)(`th`,{className:`cursor-pointer select-none px-2 py-1 text-left font-medium hover:text-foreground`,onClick:()=>d(`risk`),children:[n(`activity:sideEffects.colRisk`),` `,(0,Z.jsx)(m,{column:`risk`})]}),(0,Z.jsx)(`th`,{className:`px-2 py-1 text-left font-medium`,children:n(`activity:sideEffects.colDetail`)}),(0,Z.jsx)(`th`,{className:`px-2 py-1 text-left font-medium`,children:n(`activity:sideEffects.colOutcome`)})]})}),(0,Z.jsx)(`tbody`,{children:p.pageItems.map((e,t)=>{let n=Ec[e.risk]??Ge,r=Dc[e.risk]??`text-muted-foreground`;return(0,Z.jsxs)(`tr`,{className:`border-b border-border/45 hover:bg-muted/45`,children:[(0,Z.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1.5 text-muted-foreground`,children:kc(e.ts)}),(0,Z.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1.5 font-medium text-foreground`,children:e.toolName}),(0,Z.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1.5`,children:(0,Z.jsxs)(`span`,{className:G(`flex items-center gap-1`,r),children:[(0,Z.jsx)(n,{className:`h-3 w-3`}),e.risk]})}),(0,Z.jsx)(`td`,{className:`max-w-xs truncate px-2 py-1.5 font-mono text-muted-foreground`,children:Ac(e)}),(0,Z.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1.5 text-muted-foreground`,children:e.outcome??``})]},`${e.toolUseId}-${t}`)})})]})}),(0,Z.jsx)(Tc,{page:p.page,pageSize:p.pageSize,totalItems:p.totalItems,onPageChange:p.setPage,itemLabel:`side effects`})]})}function Pc(e){return e<=0?`$0`:e>=.01?`$${e.toFixed(3)}`:`$${e.toFixed(5)}`.replace(/0+$/,``).replace(/\.$/,``)}function Fc(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function Ic(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 Lc({showCountWhenZero:e=!1}){let{t}=H(),n=K(e=>e.sidebarOpen),r=K(e=>e.activeActivity),i=ve(),a=n&&r===`agents`,o=_(e=>Array.from(e.agents.values()).filter(e=>A(e.sessionId,i)&&e.status===`running`).length);return(0,Z.jsxs)(`button`,{type:`button`,"data-testid":`inspector-trigger`,"aria-expanded":a,"aria-label":t(`activity:inspector.openAgentsPanel`),onClick:()=>Ra(`agents`),className:G(`relative inline-flex h-8 items-center gap-1.5 rounded-md border px-2 text-xs transition-colors`,a?`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:t(`activity:inspector.openAgentsPanel`),children:[(0,Z.jsx)(jr,{className:`h-3.5 w-3.5`}),(0,Z.jsx)(`span`,{className:`hidden lg:inline`,children:t(`activity:nav.agents`)}),o>0||e?(0,Z.jsx)(`span`,{className:G(`min-w-4 px-1 text-center text-[10px] font-semibold tabular-nums`,o>0?`bg-primary/15 text-primary`:`text-muted-foreground`),children:o>99?`99+`:o}):null]})}function Rc(){let e=K(e=>e.inspectorOpen),t=K(e=>e.inspectorTab),n=K(e=>e.setInspectorOpen),r=K(e=>e.setInspectorTab),i=K(e=>e.inspectorFocusedAgentId),a=K(e=>e.setInspectorFocusedAgentId),o=ve(),{t:s}=H(),c=_(e=>e.agents),l=v(o??void 0),u=l.leaderId,d=l.tokensIn,f=l.tokensOut,p=_(e=>e.eventTimeline),m=(0,X.useMemo)(()=>{let e=new Map;for(let[t,n]of c)A(n.sessionId,o)&&e.set(t,n);return e},[c,o]),h=(0,X.useMemo)(()=>Ic(m,u),[m,u]),g=(0,X.useMemo)(()=>p.filter(e=>(e.agentId?m.get(e.agentId):void 0)!==void 0),[p,m]),y=h.filter(e=>e.status===`running`).length,b=h.reduce((e,t)=>e+t.costUsd,0),x=h.length,[S,C]=(0,X.useState)(null),w=(0,X.useMemo)(()=>S?m.get(S)??h[0]??null:h[0]??null,[S,h,m]),T=Ea(e=>e.sideEffects.length),E=Ma(e=>e.panels.length),D=Ma(e=>e.panels.filter(e=>e.phase===`voting`).length),O=e=>{C(e.id),r(`agents`)};(0,X.useEffect)(()=>{i&&e&&(C(i),r(`agents`),a(null))},[i,e,r,a]);let k=K(e=>e.inspectorTarget),j=K(e=>e.openInspectorTarget);return(0,Z.jsx)(Gs,{open:e,onOpenChange:n,modal:!1,children:(0,Z.jsx)(Xs,{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:k?.kind===`task`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Zs,{className:`relative gap-1 border-b border-border/70 bg-muted/20 px-4 py-3 pr-12`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>j({kind:`fleet`,tab:`fleet`}),className:`inline-flex h-6 items-center gap-1 rounded px-1.5 text-xs text-muted-foreground hover:bg-muted hover:text-foreground transition-colors`,title:`Back to Fleet`,children:[(0,Z.jsx)(yn,{className:`h-3.5 w-3.5`}),(0,Z.jsx)(`span`,{children:`Fleet`})]}),(0,Z.jsx)(`span`,{className:`text-muted-foreground/40`,children:`/`}),(0,Z.jsxs)(Qs,{className:`flex items-center gap-1.5 text-sm font-semibold truncate`,children:[(0,Z.jsx)(Rn,{className:`h-4 w-4 text-primary shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate`,children:k.title||k.taskId})]})]}),(0,Z.jsxs)($s,{className:`text-[11px] font-mono text-muted-foreground truncate`,children:[`Task ID: `,k.taskId,` `,k.boardId?`· Board: ${k.boardId}`:``]}),(0,Z.jsx)(Ks,{asChild:!0,children:(0,Z.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":s(`activity:inspector.collapseAria`),title:s(`activity:inspector.collapseTitle`),children:(0,Z.jsx)(St,{className:`h-4 w-4`})})})]}),(0,Z.jsx)(zc,{taskId:k.taskId,boardId:k.boardId,onBack:()=>j({kind:`fleet`,tab:`fleet`})})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Zs,{className:`relative gap-1 border-b border-border/70 bg-muted/20 px-4 py-3 pr-12`,children:[(0,Z.jsxs)(Qs,{className:`flex items-center gap-2 text-sm`,children:[(0,Z.jsx)(Sr,{className:`h-4 w-4 text-primary`}),s(`activity:inspector.label`)]}),(0,Z.jsx)($s,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px]`,children:x>0?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Z.jsx)(`span`,{className:G(`h-1.5 w-1.5 rounded-full`,y>0?`bg-success animate-pulse`:`bg-muted-foreground/50`)}),(0,Z.jsxs)(`span`,{className:`tabular-nums`,children:[y,`/`,x]})]}),(0,Z.jsxs)(`span`,{className:`font-mono tabular-nums`,children:[`↓`,Fc(d),` ↑`,Fc(f),` · `,Pc(b)]})]}):(0,Z.jsx)(`span`,{children:s(`activity:inspector.agentsAppearHint`)})}),(0,Z.jsx)(Ks,{asChild:!0,children:(0,Z.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":s(`activity:inspector.collapseAria`),title:s(`activity:inspector.collapseTitle`),children:(0,Z.jsx)(St,{className:`h-4 w-4`})})})]}),(0,Z.jsxs)(Ns,{value:t,onValueChange:e=>r(e),className:`flex min-h-0 flex-1 flex-col`,children:[(0,Z.jsxs)(Ps,{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":s(`activity:inspector.label`),children:[(0,Z.jsx)(Bc,{value:`fleet`,icon:(0,Z.jsx)(jr,{className:`h-3.5 w-3.5`}),label:s(`activity:inspector.tabFleet`),count:x,running:y}),(0,Z.jsx)(Bc,{value:`agents`,icon:(0,Z.jsx)(fr,{className:`h-3.5 w-3.5`}),label:s(`activity:inspector.tabAgents`),count:x}),(0,Z.jsx)(Bc,{value:`sideEffects`,icon:(0,Z.jsx)(Ge,{className:`h-3.5 w-3.5`}),label:s(`activity:inspector.tabAudit`),count:T}),(0,Z.jsx)(Bc,{value:`council`,icon:(0,Z.jsx)(ct,{className:`h-3.5 w-3.5`}),label:s(`activity:inspector.tabCouncil`,{defaultValue:`Council`}),count:E,running:D})]}),(0,Z.jsx)(Is,{value:`fleet`,className:`mt-0 min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Z.jsx)(Vc,{fleetList:h,leaderId:u,selectedAgentId:S,eventTimeline:g,onSelectAgent:O})}),(0,Z.jsx)(Is,{value:`agents`,className:`mt-0 min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Z.jsx)(Hc,{fleetList:h,selectedAgent:w,leaderId:u,selectedAgentId:w?.id??null,onSelectAgent:C})}),(0,Z.jsx)(Is,{value:`sideEffects`,className:`mt-0 min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Z.jsx)(Nc,{})}),(0,Z.jsx)(Is,{value:`council`,className:`mt-0 min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Z.jsx)(xc,{})})]})]})})})}function zc({taskId:e,boardId:t,onBack:n}){let r=wa(e=>e.activeBoard),i=(0,X.useMemo)(()=>r?.tasks.find(t=>t.id===e)??null,[r,e]);return i?(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto overscroll-contain p-4 space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[10px] font-mono text-muted-foreground uppercase`,children:i.id}),(0,Z.jsx)(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-semibold text-primary uppercase`,children:i.columnId||`todo`})]}),(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:i.title})]}),i.description&&(0,Z.jsx)(`div`,{className:`rounded-md border border-border/70 bg-muted/30 p-3 text-xs text-foreground/90 whitespace-pre-wrap`,children:i.description}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-xs`,children:[(0,Z.jsxs)(`div`,{className:`rounded border border-border/60 p-2 bg-card/40`,children:[(0,Z.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground font-semibold`,children:`Priority`}),(0,Z.jsx)(`div`,{className:`font-mono text-xs text-foreground mt-0.5 capitalize`,children:i.priority||`Medium`})]}),(0,Z.jsxs)(`div`,{className:`rounded border border-border/60 p-2 bg-card/40`,children:[(0,Z.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground font-semibold`,children:`Assigned Agent`}),(0,Z.jsx)(`div`,{className:`font-mono text-xs text-foreground mt-0.5`,children:i.assignedAgent||i.assignee||i.assignment?.agentId||`Unassigned`})]})]})]}):(0,Z.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 text-center text-muted-foreground p-4`,children:[(0,Z.jsx)(Rn,{className:`h-8 w-8 mb-2 opacity-30 text-primary`}),(0,Z.jsxs)(`p`,{className:`text-xs font-medium`,children:[`Task details (`,e,`)`]}),(0,Z.jsx)(`p`,{className:`text-[11px] text-muted-foreground mt-1`,children:`Select a task from Kanban or SDD to inspect full parameters.`}),(0,Z.jsx)(`button`,{type:`button`,onClick:n,className:`mt-4 px-3 py-1 text-xs rounded bg-muted hover:bg-muted/80 text-foreground transition-colors`,children:`Back to Fleet`})]})}function Bc({value:e,icon:t,label:n,count:r,running:i}){return(0,Z.jsxs)(Fs,{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,Z.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 Vc({fleetList:e,leaderId:t,selectedAgentId:n,eventTimeline:r,onSelectAgent:i}){let{t:a}=H();return(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[e.length===0?(0,Z.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground`,children:[(0,Z.jsx)(fr,{className:`h-8 w-8 mb-2 opacity-20`}),(0,Z.jsx)(`p`,{className:`text-xs font-medium`,children:a(`activity:inspector.noAgentsActive`)}),(0,Z.jsx)(`p`,{className:`text-[11px] mt-0.5`,children:a(`activity:inspector.agentsAppearHint`)})]}):(0,Z.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain p-1.5`,children:e.map(e=>(0,Z.jsx)(ic,{agent:e,isSelected:n===e.id,isLeader:e.id===t,onClick:()=>i(e)},e.id))}),r.length>0&&(0,Z.jsx)(`div`,{className:`border-t px-3 py-1.5 shrink-0`,children:(0,Z.jsx)(Ws,{events:r,max:4})})]})}function Hc({fleetList:e,selectedAgent:t,leaderId:n,selectedAgentId:r,onSelectAgent:i}){let{t:a}=H();if(e.length===0)return(0,Z.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground`,children:[(0,Z.jsx)(jr,{className:`h-8 w-8 mb-2 opacity-20`}),(0,Z.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,Z.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,Z.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain p-3`,children:(0,Z.jsx)(`div`,{className:`max-w-2xl mx-auto`,children:(0,Z.jsx)(bc,{agent:t,isLeader:t.id===n})})}),(0,Z.jsx)(`div`,{className:`border-t px-2 py-1.5 shrink-0`,children:(0,Z.jsx)(`div`,{className:`flex items-center gap-1 overflow-x-auto pb-0.5`,children:e.map((e,n)=>(0,Z.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,Z.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,Z.jsx)(`span`,{className:`truncate max-w-[8rem]`,children:e.name})]},e.id))})})]})}var Uc={builtin:`📦`,user:`👤`,project:`📁`,synced:`☁`},Wc={title:``,description:``,category:``,tagsCsv:``,content:``,vars:[]};function Gc(e,t){return e.replace(/\{\{\s*([\w.-]+)\s*\}\}/g,(e,n)=>Object.hasOwn(t,n.trim())&&t[n.trim()]?t[n.trim()]:e)}function Kc(){let{t:e}=H(),{client:t}=ha(),n=K(e=>e.promptLibraryOpen),r=K(e=>e.setPromptLibraryOpen),i=K(e=>e.requestPromptInsert),[a,o]=(0,X.useState)([]),[s,c]=(0,X.useState)([]),[l,u]=(0,X.useState)(``),[d,f]=(0,X.useState)(null),[p,m]=(0,X.useState)(!1),[h,g]=(0,X.useState)(!1),[_,v]=(0,X.useState)([]),[y,b]=(0,X.useState)(null),[x,S]=(0,X.useState)(``),[C,w]=(0,X.useState)({}),T=(0,X.useRef)(null),[E,D]=(0,X.useState)(!1),[O,k]=(0,X.useState)(Wc),[A,j]=(0,X.useState)(null);(0,X.useEffect)(()=>{if(!n||!t)return;let e=e=>{let t=e.payload;o(t.prompts??[]),c(t.categories??[])};return t.on(`prompts.list`,e),t.send({type:`prompts.list`}),setTimeout(()=>T.current?.focus(),50),()=>t.off(`prompts.list`,e)},[n,t]),(0,X.useEffect)(()=>{if(!y||!t)return;S(``),w(Object.fromEntries((y.variables??[]).map(e=>[e.name,e.default??``])));let e=e=>{let t=e.payload;t.slug===y.slug&&t.found&&S(t.content)};return t.on(`prompts.content`,e),t.send({type:`prompts.content`,payload:{slug:y.slug}}),()=>t.off(`prompts.content`,e)},[y,t]),(0,X.useEffect)(()=>{if(!n)return;let e=e=>{e.key===`Escape`&&r(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n,r]),(0,X.useEffect)(()=>{if(!n||!t||!h)return;let e=e=>{let t=e.payload.slugs??[];v(t)};return t.on(`prompts.recent`,e),t.send({type:`prompts.recent`}),()=>t.off(`prompts.recent`,e)},[n,t,h]);let M=(0,X.useMemo)(()=>{let e=l.trim().toLowerCase(),t=t=>!e||t.title.toLowerCase().includes(e)||t.description.toLowerCase().includes(e)||t.slug.includes(e)||t.tags.some(t=>t.toLowerCase().includes(e));if(h){let e=new Map(a.map(e=>[e.slug,e]));return _.map(t=>e.get(t)).filter(e=>!!e).filter(t)}return a.filter(e=>p&&!e.favorite||d&&e.category!==d?!1:t(e))},[a,l,d,p,h,_]),N=(0,X.useMemo)(()=>(y?.variables??[]).filter(e=>e.required&&!C[e.name]).map(e=>e.name),[y,C]),P=(0,X.useCallback)(()=>{!y||!x||(t?.send({type:`prompts.used`,payload:{slug:y.slug}}),i(Gc(x,C)))},[y,x,C,i,t]),F=(0,X.useCallback)(e=>{t&&(t.send({type:`prompts.favorite`,payload:{slug:e.slug,favorite:!e.favorite}}),o(t=>t.map(t=>t.slug===e.slug?{...t,favorite:!t.favorite}:t)))},[t]);(0,X.useEffect)(()=>{if(!n||!t)return;let e=e=>{let n=e.payload;n.success?(D(!1),k(Wc),j(null),t.send({type:`prompts.list`})):j(n.error??U.t(`activity:promptLib.saveFailed`))};return t.on(`prompts.created`,e),()=>t.off(`prompts.created`,e)},[n,t]);let I=(0,X.useCallback)(()=>{if(!t)return;if(!O.title.trim()||!O.content.trim()){j(U.t(`activity:promptLib.titleContentRequired`));return}let e=O.vars.filter(e=>e.name.trim()).map(e=>{let t=e.enumCsv.split(`,`).map(e=>e.trim()).filter(Boolean);return{name:e.name.trim(),...e.description.trim()?{description:e.description.trim()}:{},required:e.required,...e.multiline?{multiline:!0}:{},...t.length>0?{enum:t}:{}}});t.send({type:`prompts.create`,payload:{title:O.title.trim(),content:O.content,description:O.description.trim(),category:O.category.trim()||void 0,tags:O.tagsCsv.split(`,`).map(e=>e.trim()).filter(Boolean),...e.length>0?{variables:e}:{}}})},[t,O]);return(0,Z.jsx)(Ja,{open:n,onOpenChange:e=>{e||r(!1)},children:(0,Z.jsxs)(Ga,{className:`max-w-4xl h-[80dvh] p-0 gap-0 overflow-hidden`,showCloseButton:!1,onOpenAutoFocus:e=>{e.preventDefault(),T.current?.focus()},children:[(0,Z.jsx)(Ka,{className:`sr-only`,children:e(`activity:promptLib.heading`)}),(0,Z.jsx)(qa,{className:`sr-only`,children:e(`activity:promptLib.searchPlaceholder`)}),(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 w-full overflow-hidden`,children:[(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 w-1/2 flex-col border-r border-border`,children:[(0,Z.jsxs)(`div`,{className:`border-b border-border p-3`,children:[(0,Z.jsx)(`input`,{ref:T,value:l,onChange:e=>u(e.target.value),placeholder:e(`activity:promptLib.searchPlaceholder`),className:`w-full rounded border border-border bg-background px-3 py-2 text-sm outline-none focus:ring-1 focus:ring-primary`}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{D(!0),b(null),j(null),k(Wc)},className:`mt-2 w-full rounded border border-dashed border-border px-2 py-1 text-xs text-muted-foreground hover:bg-accent hover:text-foreground`,children:e(`activity:promptLib.newPrompt`)}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{f(null),m(!1),g(!1)},className:`rounded px-2 py-0.5 text-xs ${d===null&&!p&&!h?`bg-primary text-primary-foreground`:`bg-muted text-muted-foreground hover:bg-accent`}`,children:e(`activity:promptLib.all`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{g(e=>!e),m(!1),f(null)},className:`rounded px-2 py-0.5 text-xs ${h?`bg-primary text-primary-foreground`:`bg-muted text-muted-foreground hover:bg-accent`}`,children:e(`activity:promptLib.recent`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{m(e=>!e),g(!1),f(null)},className:`rounded px-2 py-0.5 text-xs ${p?`bg-warning text-primary-foreground`:`bg-muted text-muted-foreground hover:bg-accent`}`,children:e(`activity:promptLib.favorites`)}),s.map(e=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>{f(e.id),g(!1),m(!1)},className:`rounded px-2 py-0.5 text-xs ${d===e.id?`bg-primary text-primary-foreground`:`bg-muted text-muted-foreground hover:bg-accent`}`,children:[e.label,` (`,e.count,`)`]},e.id))]})]}),(0,Z.jsxs)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-auto overscroll-contain`,children:[M.map(e=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>b(e),className:`flex w-full flex-col items-start gap-0.5 border-b border-border/50 px-3 py-2 text-left hover:bg-accent ${y?.slug===e.slug?`bg-accent`:``}`,children:[(0,Z.jsxs)(`div`,{className:`flex w-full items-center gap-1 text-sm`,children:[(0,Z.jsx)(`span`,{children:Uc[e.source]??`•`}),(0,Z.jsx)(`span`,{className:`font-medium`,children:e.title}),e.favorite&&(0,Z.jsx)(`span`,{className:`text-warning`,children:`★`})]}),(0,Z.jsx)(`div`,{className:`line-clamp-1 text-xs text-muted-foreground`,children:e.description})]},e.slug)),M.length===0&&(0,Z.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:e(`activity:promptLib.noMatch`)})]})]}),(0,Z.jsx)(`div`,{className:`flex min-h-0 min-w-0 w-1/2 flex-col`,children:E?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border p-3`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold`,children:e(`activity:promptLib.newPromptHeading`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{D(!1),j(null)},className:`text-xs text-muted-foreground hover:text-foreground`,children:e(`common:action.cancel`)})]}),(0,Z.jsxs)(`div`,{className:`min-h-0 min-w-0 flex-1 space-y-2 overflow-auto overscroll-contain p-3 text-xs`,children:[(0,Z.jsx)(`input`,{value:O.title,onChange:e=>k(t=>({...t,title:e.target.value})),placeholder:e(`activity:promptLib.titlePlaceholder`),className:`w-full rounded border border-border bg-background px-2 py-1 outline-none focus:ring-1 focus:ring-primary`}),(0,Z.jsx)(`input`,{value:O.description,onChange:e=>k(t=>({...t,description:e.target.value})),placeholder:e(`activity:promptLib.descPlaceholder`),className:`w-full rounded border border-border bg-background px-2 py-1 outline-none focus:ring-1 focus:ring-primary`}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(`input`,{list:`prompt-category-list`,value:O.category,onChange:e=>k(t=>({...t,category:e.target.value})),placeholder:e(`activity:promptLib.categoryPlaceholder`),className:`w-1/2 rounded border border-border bg-background px-2 py-1 outline-none focus:ring-1 focus:ring-primary`}),(0,Z.jsx)(`datalist`,{id:`prompt-category-list`,children:s.map(e=>(0,Z.jsx)(`option`,{value:e.id},e.id))}),(0,Z.jsx)(`input`,{value:O.tagsCsv,onChange:e=>k(t=>({...t,tagsCsv:e.target.value})),placeholder:e(`activity:promptLib.tagsPlaceholder`),className:`w-1/2 rounded border border-border bg-background px-2 py-1 outline-none focus:ring-1 focus:ring-primary`})]}),(0,Z.jsx)(`textarea`,{value:O.content,onChange:e=>k(t=>({...t,content:e.target.value})),placeholder:e(`activity:promptLib.contentPlaceholder`),rows:6,className:`w-full resize-y rounded border border-border bg-background px-2 py-1 font-mono outline-none focus:ring-1 focus:ring-primary`}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between pt-1`,children:[(0,Z.jsx)(`span`,{className:`font-semibold text-muted-foreground`,children:e(`activity:promptLib.variables`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>k(e=>({...e,vars:[...e.vars,{name:``,description:``,required:!0,multiline:!1,enumCsv:``}]})),className:`rounded border border-border px-1.5 py-0.5 hover:bg-accent`,children:e(`activity:promptLib.addVar`)})]}),O.vars.map((t,n)=>(0,Z.jsxs)(`div`,{className:`space-y-1 rounded border border-border/60 p-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex gap-1`,children:[(0,Z.jsx)(`input`,{value:t.name,onChange:e=>k(t=>({...t,vars:t.vars.map((t,r)=>r===n?{...t,name:e.target.value}:t)})),placeholder:e(`activity:promptLib.varNamePlaceholder`),className:`w-1/3 rounded border border-border bg-background px-1.5 py-0.5 outline-none focus:ring-1 focus:ring-primary`}),(0,Z.jsx)(`input`,{value:t.description,onChange:e=>k(t=>({...t,vars:t.vars.map((t,r)=>r===n?{...t,description:e.target.value}:t)})),placeholder:e(`activity:promptLib.varDescPlaceholder`),className:`flex-1 rounded border border-border bg-background px-1.5 py-0.5 outline-none focus:ring-1 focus:ring-primary`}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>k(e=>({...e,vars:e.vars.filter((e,t)=>t!==n)})),className:`rounded border border-border px-1.5 text-muted-foreground hover:bg-accent`,title:e(`activity:promptLib.removeVarTitle`),children:`✕`})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsxs)(`label`,{className:`flex items-center gap-1 text-muted-foreground`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:t.required,onChange:e=>k(t=>({...t,vars:t.vars.map((t,r)=>r===n?{...t,required:e.target.checked}:t)}))}),e(`activity:promptLib.required`)]}),(0,Z.jsxs)(`label`,{className:`flex items-center gap-1 text-muted-foreground`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:t.multiline,onChange:e=>k(t=>({...t,vars:t.vars.map((t,r)=>r===n?{...t,multiline:e.target.checked}:t)}))}),e(`activity:promptLib.multiline`)]}),(0,Z.jsx)(`input`,{value:t.enumCsv,onChange:e=>k(t=>({...t,vars:t.vars.map((t,r)=>r===n?{...t,enumCsv:e.target.value}:t)})),placeholder:e(`activity:promptLib.enumPlaceholder`),className:`flex-1 rounded border border-border bg-background px-1.5 py-0.5 outline-none focus:ring-1 focus:ring-primary`})]})]},t.name||`var-${n}`))]}),(0,Z.jsxs)(`div`,{className:`border-t border-border p-3`,children:[A&&(0,Z.jsx)(`div`,{className:`mb-2 text-xs text-destructive`,children:A}),(0,Z.jsx)(`button`,{type:`button`,onClick:I,disabled:!O.title.trim()||!O.content.trim(),className:`w-full rounded bg-primary px-3 py-2 text-sm text-primary-foreground disabled:opacity-50`,children:e(`activity:promptLib.savePrompt`)})]})]}):y?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between border-b border-border p-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold`,children:y.title}),(0,Z.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[y.category,` · `,y.slug]})]}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>F(y),className:`text-lg`,title:e(`activity:promptLib.toggleFavoriteTitle`),children:y.favorite?`★`:`☆`})]}),(0,Z.jsxs)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-auto overscroll-contain p-3`,children:[(0,Z.jsx)(`pre`,{className:`whitespace-pre-wrap break-words text-xs text-foreground`,children:x||`…`}),(y.variables??[]).length>0&&(0,Z.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-semibold text-muted-foreground`,children:e(`activity:promptLib.variables`)}),y.variables.map(t=>{let n=(0,Z.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[t.name,t.required?` *`:``,t.description?` — ${t.description}`:``]}),r=e=>w(n=>({...n,[t.name]:e})),i=`mt-0.5 w-full rounded border border-border bg-background px-2 py-1 text-xs outline-none focus:ring-1 focus:ring-primary`;return t.enum&&t.enum.length>0?(0,Z.jsxs)(`div`,{children:[n,(0,Z.jsxs)(`select`,{value:C[t.name]??``,onChange:e=>r(e.target.value),className:i,children:[(0,Z.jsx)(`option`,{value:``,children:e(`activity:promptLib.selectOption`)}),t.enum.map(e=>(0,Z.jsx)(`option`,{value:e,children:e},e))]})]},t.name):t.multiline?(0,Z.jsxs)(`div`,{children:[n,(0,Z.jsx)(`textarea`,{value:C[t.name]??``,onChange:e=>r(e.target.value),rows:4,className:`${i} resize-y font-mono`})]},t.name):(0,Z.jsxs)(`div`,{children:[n,(0,Z.jsx)(`input`,{value:C[t.name]??``,onChange:e=>r(e.target.value),className:i})]},t.name)})]})]}),(0,Z.jsx)(`div`,{className:`border-t border-border p-3`,children:(0,Z.jsx)(`button`,{type:`button`,onClick:P,disabled:!x||N.length>0,className:`w-full rounded bg-primary px-3 py-2 text-sm text-primary-foreground disabled:opacity-50`,children:N.length>0?e(`activity:promptLib.fillMissing`,{missing:N.join(`, `)}):e(`activity:promptLib.insertIntoChat`)})})]}):(0,Z.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-4 text-sm text-muted-foreground`,children:e(`activity:promptLib.selectPromptHint`)})})]})]})})}var qc=[`none`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],Jc=`auto`,Yc=new Set(qc);function Xc(e){return Yc.has(e)}var Zc={none:`settings:agent.reasoningEffortNone`,minimal:`settings:agent.reasoningEffortMinimal`,low:`settings:agent.reasoningEffortLow`,medium:`settings:agent.reasoningEffortMedium`,high:`settings:agent.reasoningEffortHigh`,xhigh:`settings:agent.reasoningEffortXhigh`,max:`settings:agent.reasoningEffortMax`},Qc=`settings:agent.reasoningEffortAuto`;function $c(e){return e===`auto`?Qc:Zc[e]}function el(e,t){let n=[Jc,...e?.length?e.filter(Xc):[...qc]];return Xc(t)&&!n.includes(t)&&n.push(t),n}function tl(e,t){return t!==`auto`&&!!e?.length&&!e.includes(t)}function nl(e){return e===!1}function rl(){let{t:e}=H(),t=K(e=>e.modelSwitcherOpen),n=K(e=>e.setModelSwitcherOpen),r=W(e=>e.favoriteModels),i=W(e=>e.keyboardShortcuts),[a,o]=(0,X.useState)(``),[s,c]=(0,X.useState)(null),[l,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(0),[p,m]=(0,X.useState)([]),[h,g]=(0,X.useState)({}),[_,v]=(0,X.useState)(null),y=(0,X.useRef)(null),b=(0,X.useRef)(t);(0,X.useEffect)(()=>{b.current=t},[t]);let x=R(e=>e.wsUrl),S=R(e=>e.provider),C=R(e=>e.model),w=N(e=>e.session?.provider??S),T=N(e=>e.session?.model??C),E=N(e=>e.reasoningEffortLevels),D=N(e=>e.projectReasoningEffort),O=W(e=>e.reasoningEffort),k=(0,X.useMemo)(()=>el(E,O),[E,O]),A=O===`auto`&&D?e(`settings:agent.reasoningEffortAutoHint`,{value:Xc(D)?e($c(D)):D}):void 0,j=K(e=>e.paletteOpen),{listSavedProviders:P,listProviderModels:F,switchModel:I,updatePrefs:L}=ha();(0,X.useEffect)(()=>{let e=e=>{let r=e.ctrlKey||e.metaKey;if(i&&r&&e.key.toLowerCase()===`m`&&!e.shiftKey&&!e.altKey){if(j)return;e.preventDefault(),n(!t);return}e.key===`Escape`&&t&&(e.preventDefault(),n(!1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,j,n,i]),(0,X.useEffect)(()=>{let e=V(x),t=e.on(`providers.saved`,e=>{let t=e.payload;m(t.providers??[])}),n=e.on(`provider.models`,e=>{let t=e.payload;g(e=>({...e,[t.provider]:t.models}))});return()=>{t(),n()}},[x]),(0,X.useEffect)(()=>{t&&(o(``),c(null),u(!1),f(0),P(),requestAnimationFrame(()=>y.current?.focus()))},[t,P]),(0,X.useEffect)(()=>{if(t)for(let e of p)h[e.id]||F(e.id)},[t,p,h,F]);let ee=(0,X.useMemo)(()=>[...new Set(p.map(e=>e.id))].sort((e,t)=>e.localeCompare(t)),[p]),te=(0,X.useMemo)(()=>no(p,h,a,w,T,s,l,r),[p,h,a,w,T,s,l,r]);(0,X.useEffect)(()=>{d>=te.length&&f(0)},[te.length,d]);let z=async t=>{let r=te[t];if(!r||_)return;if(r.isCurrent){n(!1);return}let i=`${r.provider} / ${r.model}`;v(i);let a=await I(r.provider,r.model);if(a.success){let e=N.getState().session;if(e){N.getState().setSession({...e,provider:r.provider,model:r.model}),(r.reasoningEffortLevels||r.effortSupported!==void 0)&&N.getState().setEnv({reasoningEffortLevels:r.reasoningEffortLevels,effortSupported:r.effortSupported});let t=M.get(e.id);t&&(t.provider=r.provider,t.model=r.model,t.session&&(t.session.provider=r.provider,t.session.model=r.model))}}b.current&&(a.success?(B.success(e(a.runActive?`settings:toast.modelSwitchedRunActive`:`settings:toast.modelSwitchedNextRequest`,{from:`${w} / ${T}`,to:i})),n(!1)):B.error(a.message)),v(null)};return(0,Z.jsx)(Ja,{open:t,onOpenChange:e=>{e||(v(null),n(!1))},children:(0,Z.jsxs)(Ga,{className:`max-w-xl gap-0 p-0 overflow-hidden pt-[15dvh]`,showCloseButton:!1,onOpenAutoFocus:e=>{e.preventDefault(),y.current?.focus()},"aria-busy":_!==null,children:[(0,Z.jsx)(Ka,{className:`sr-only`,children:e(`activity:modelSwitcher.heading`)}),(0,Z.jsx)(qa,{className:`sr-only`,children:e(`activity:modelSwitcher.filterPlaceholder`)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 border-b px-3 py-2`,children:[(0,Z.jsx)(vn,{className:`h-4 w-4 text-muted-foreground shrink-0`}),(0,Z.jsx)(`input`,{ref:y,value:a,onChange:e=>{o(e.target.value),f(0)},onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),f(e=>Math.min(te.length-1,e+1))):e.key===`ArrowUp`?(e.preventDefault(),f(e=>Math.max(0,e-1))):e.key===`Enter`&&(e.preventDefault(),z(d))},placeholder:e(`activity:modelSwitcher.filterPlaceholder`),"aria-label":e(`activity:modelSwitcher.filterPlaceholder`),className:`flex-1 bg-transparent outline-none text-sm placeholder:text-muted-foreground min-w-0`}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>{u(e=>!e),f(0)},title:e(`activity:modelSwitcher.favoritesOnly`),"aria-label":e(`activity:modelSwitcher.favoritesOnly`),"aria-pressed":l,className:G(`flex items-center gap-1 rounded-md px-2 py-1 text-xs transition-colors border shrink-0`,l?`bg-warning/15 border-warning/40 text-warning font-medium`:`bg-transparent border-border/70 text-muted-foreground hover:text-foreground hover:bg-muted/50`),children:[(0,Z.jsx)(Hi,{className:G(`h-3.5 w-3.5`,l?`fill-warning text-warning`:`text-muted-foreground`)}),(0,Z.jsx)(`span`,{className:`text-[11px] whitespace-nowrap`,children:e(`activity:modelSwitcher.favoritesOnly`)})]}),ee.length>1&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,Z.jsx)($e,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,Z.jsxs)(`select`,{value:s??``,onChange:e=>{c(e.target.value||null),f(0)},"aria-label":e(`activity:modelSwitcher.providerFilter`),className:`bg-transparent text-xs text-muted-foreground outline-none cursor-pointer border-0 min-w-0 truncate`,children:[(0,Z.jsx)(`option`,{value:``,children:e(`activity:modelSwitcher.providerFilterAll`)}),ee.map(e=>(0,Z.jsx)(`option`,{value:e,children:e},e))]})]}),(0,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground font-mono shrink-0`,children:_?e(`settings:toast.switchingToTarget`,{target:_}):`↑↓ · Enter · Esc`})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 border-b px-3 py-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`quick-model-effort`,className:`text-[11px] text-muted-foreground shrink-0`,children:e(`settings:agent.reasoningEffortLabel`)}),(0,Z.jsx)(`select`,{id:`quick-model-effort`,value:O,onChange:e=>{let t=e.target.value;W.getState().set({reasoningEffort:t}),L({reasoningEffort:t})},className:`bg-transparent text-xs outline-none cursor-pointer border-0`,children:k.map(t=>(0,Z.jsx)(`option`,{value:t,children:e($c(t))},t))}),tl(E,O)&&(0,Z.jsx)(`span`,{className:`text-[10px] text-warning truncate min-w-0`,title:e(`settings:agent.reasoningEffortUnsupported`,{levels:(E??[]).join(`, `)}),children:e(`settings:agent.reasoningEffortUnsupported`,{levels:(E??[]).join(`, `)})}),A&&(0,Z.jsx)(`span`,{className:`ml-auto shrink-0 text-[10px] text-muted-foreground`,children:A})]}),(0,Z.jsx)(`div`,{className:`max-h-[50dvh] overflow-y-auto py-1`,children:te.length===0?(0,Z.jsx)(`div`,{className:`px-4 py-8 text-center text-sm text-muted-foreground`,children:p.length===0?e(`activity:modelSwitcher.noSavedProviders`):Object.keys(h).length===0?e(`activity:model.loading`):l?r?.length===0?e(`activity:modelSwitcher.noFavoritesConfigured`):e(`activity:modelSwitcher.noFavoritesMatch`):e(`activity:modelSwitcher.noMatch`)}):te.map((t,n)=>(0,Z.jsxs)(`button`,{type:`button`,"data-model-candidate":`true`,onClick:()=>void z(n),disabled:_!==null,onMouseEnter:()=>f(n),className:G(`w-full flex items-center gap-3 px-3 py-2 text-left text-sm transition-colors`,n===d?`bg-accent text-accent-foreground`:`hover:bg-accent/40`,t.isCurrent&&`font-medium`),children:[(0,Z.jsx)(ar,{className:G(`h-4 w-4 shrink-0`,t.isCurrent?`text-primary`:`text-muted-foreground`)}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 break-words`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:t.provider}),(0,Z.jsx)(`span`,{className:`text-muted-foreground/65`,children:`·`}),(0,Z.jsx)(`span`,{children:t.modelName}),t.isFavorite&&(0,Z.jsx)(`span`,{title:e(`activity:modelSwitcher.favoriteModel`),children:(0,Z.jsx)(Hi,{className:`h-3 w-3 fill-warning text-warning shrink-0`})})]}),(t.contextWindow||t.reasoningEffortLevels)&&(0,Z.jsxs)(`div`,{className:`text-[10px] text-muted-foreground font-mono break-words`,children:[t.model,t.contextWindow?` · ctx ${t.contextWindow.toLocaleString()}`:``,t.reasoningEffortLevels?` · effort ${t.reasoningEffortLevels.join(`/`)}`:``]})]}),t.isCurrent?(0,Z.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-primary font-semibold`,children:e(`activity:modelSwitcher.active`)}):(0,Z.jsx)(Ln,{className:`h-3.5 w-3.5 text-muted-foreground opacity-0 group-hover:opacity-100`})]},`${t.provider}:${t.model}`))})]})})}var il=[{name:`primary`,dot:`bg-primary`,text:`text-primary`,border:`border-primary`,soft:`bg-primary/10`},{name:`info`,dot:`bg-info`,text:`text-info`,border:`border-info`,soft:`bg-info/10`},{name:`warning`,dot:`bg-warning`,text:`text-warning`,border:`border-warning`,soft:`bg-warning/10`},{name:`success`,dot:`bg-success`,text:`text-success`,border:`border-success`,soft:`bg-success/10`}];function al(e){return il[e%il.length]}function ol(e){let t=P(e=>e.openTabIds),n=P(e=>e.lastSeenCounts),r=P(e=>e.attention),i=l(e=>e.lanes),a=l(e=>e.activeSessionId),o=Se(e=>e.lanes),s=_(e=>e.agents),c=K(e=>e.sessionNicknames);return(0,X.useMemo)(()=>{let l=new Map;for(let e of s.values()){if(!e.sessionId)continue;let t=l.get(e.sessionId)??{running:0,total:0};t.total+=1,e.status===`running`&&(t.running+=1),l.set(e.sessionId,t)}return t.map((t,s)=>{let u=i[t],d=o[t],f=l.get(t)??{running:0,total:0},p=u?.messages.length??0,m=n[t]??p,h=t===a,g=d?.maxContext??0,_=d?.lastInputTokens??0;return{slot:s,sessionId:t,isActive:h,title:c[t]||e?.get(t)||d?.session?.title||t.slice(0,8),provider:d?.session?.provider??``,model:d?.session?.model??``,mode:d?.mode??`default`,isRunning:u?.isLoading??!1,messageCount:p,unread:h?0:Math.max(0,p-m),queued:u?.queue.length??0,agentsRunning:f.running,agentsTotal:f.total,tokens:(d?.totalTokens.input??0)+(d?.totalTokens.output??0),cost:d?.cost??0,contextPct:g>0&&_>0?Math.min(100,Math.round(_/g*100)):0,needsAttention:!h&&r[t]===!0}})},[t,n,r,i,o,a,s,c,e])}function sl(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function cl({tabs:e,onSelect:t,onNew:n}){let r=Array.from({length:ee},(t,n)=>e[n]??null);return(0,Z.jsxs)(`div`,{className:`w-[min(92vw,760px)] p-2`,children:[(0,Z.jsxs)(`div`,{className:`px-1 pb-2 text-[10px] uppercase tracking-wider text-muted-foreground`,children:[`Tab map — `,e.length,`/`,ee,` slots · one session per tab, nothing shared`]}),(0,Z.jsx)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:r.map((e,r)=>e?(0,Z.jsx)(ll,{tab:e,onSelect:t},e.sessionId):(0,Z.jsx)(dl,{slot:r,onNew:n},`empty-${r}`))})]})}function ll({tab:e,onSelect:t}){let n=al(e.slot);return(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>t(e.sessionId),className:G(`group flex w-full flex-col gap-1.5 rounded-md border p-2.5 text-left transition-colors`,e.isActive?G(`border-border/80 bg-background shadow-xs`,n.border):`border-border/40 bg-muted/20 hover:bg-muted/40`),children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:G(`inline-flex h-5 w-5 shrink-0 items-center justify-center rounded text-[10px] font-bold`,n.soft,n.text),children:e.slot+1}),(0,Z.jsx)(`span`,{className:`truncate text-xs font-medium`,children:e.title}),e.isActive&&(0,Z.jsx)(`span`,{className:G(`shrink-0 text-[9px] font-semibold uppercase`,n.text),children:`on screen`}),(0,Z.jsx)(`span`,{className:`ml-auto shrink-0`,children:e.needsAttention?(0,Z.jsx)(Kr,{className:`h-3.5 w-3.5 text-warning`}):e.isRunning?(0,Z.jsx)(wt,{className:`h-3.5 w-3.5 animate-spin text-primary`}):(0,Z.jsx)(Et,{className:`h-3.5 w-3.5 text-muted-foreground/50`})})]}),(0,Z.jsxs)(`div`,{className:`truncate font-mono text-[10px] text-muted-foreground`,children:[e.provider||`—`,` / `,e.model||`—`,` · `,e.mode]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-[10px] text-muted-foreground`,children:[(0,Z.jsx)(ul,{icon:(0,Z.jsx)(Lt,{className:`h-3 w-3`}),label:`${e.messageCount} msg`}),e.unread>0&&(0,Z.jsxs)(`span`,{className:`rounded bg-primary/15 px-1 font-semibold text-primary`,children:[`+`,e.unread,` new`]}),e.queued>0&&(0,Z.jsxs)(`span`,{children:[e.queued,` queued`]}),(0,Z.jsx)(ul,{icon:(0,Z.jsx)(jr,{className:`h-3 w-3`}),label:e.agentsTotal===0?`no agents`:`${e.agentsRunning}/${e.agentsTotal} agents`,tone:e.agentsRunning>0?`text-success`:void 0}),e.tokens>0&&(0,Z.jsxs)(`span`,{children:[sl(e.tokens),` tok`]}),e.cost>0&&(0,Z.jsxs)(`span`,{children:[`$`,e.cost.toFixed(4)]}),e.contextPct>0&&(0,Z.jsxs)(`span`,{children:[e.contextPct,`% ctx`]})]}),(0,Z.jsx)(`div`,{className:`truncate font-mono text-[9px] text-muted-foreground/60`,children:e.sessionId})]})}function ul({icon:e,label:t,tone:n}){return(0,Z.jsxs)(`span`,{className:G(`inline-flex items-center gap-1`,n),children:[e,t]})}function dl({slot:e,onNew:t}){let n=al(e);return(0,Z.jsxs)(`button`,{type:`button`,onClick:t,className:`flex w-full items-center gap-2 rounded-md border border-dashed border-border/50 p-2.5 text-left text-muted-foreground transition-colors hover:border-border hover:text-foreground`,children:[(0,Z.jsx)(`span`,{className:G(`inline-flex h-5 w-5 shrink-0 items-center justify-center rounded text-[10px] font-bold opacity-50`,n.soft,n.text),children:e+1}),(0,Z.jsx)(`span`,{className:`text-xs`,children:`Empty slot`}),(0,Z.jsx)(_i,{className:`ml-auto h-3.5 w-3.5`})]})}function fl(){let{t:e}=H(),{resumeSession:t,listSessions:n}=ha(),r=ve(),i=b(e=>e.entries),a=P(e=>e.openTabIds),o=P(e=>e.openTab),s=P(e=>e.closeTab),[c,l]=(0,X.useState)(!1),u=ol((0,X.useMemo)(()=>{let e=new Map;for(let t of i)e.set(t.id,t.name||t.title||t.id.slice(0,8));return e},[i]));(0,X.useEffect)(()=>{i.length===0&&n?.()},[i.length,n]);let d=e=>{l(!1),o(e,{resumeSession:t})},f=async(n,r)=>{r.stopPropagation();let i=fe(n);if(i.isEmpty){s(n);return}if(u.find(e=>e.sessionId===n)?.isActive||o(n,{resumeSession:t}),i.isBusy){if(!await $a({title:e(`activity:sessions.closeOngoingTabTitle`,{defaultValue:`There is an ongoing operation in this session`}),message:e(`activity:sessions.closeOngoingTabQuestion`,{defaultValue:`Are you sure you want to close this tab?`}),details:i.lines,confirmLabel:e(`activity:sessions.interruptAndClose`,{defaultValue:`Interrupt and Close`}),cancelLabel:e(`common:action.cancel`,{defaultValue:`Cancel`}),danger:!0,defaultAction:`cancel`}))return;try{V().sendAbort(n)}catch{}}else if(!await $a({title:e(`activity:sessions.closeHistoryTabTitle`,{defaultValue:`Close this tab?`}),message:e(`activity:sessions.closeHistoryTabMessage`,{defaultValue:`This tab contains agent history. Are you sure you want to close it?`}),details:i.lines,confirmLabel:e(`activity:sessions.closeTabAction`,{defaultValue:`Close Tab`}),cancelLabel:e(`common:action.cancel`,{defaultValue:`Cancel`}),danger:!0,defaultAction:`cancel`}))return;s(n)},p=()=>{if(l(!1),a.length<ee){T.getState().openPicker({startsSession:!0});return}B.info(e(`activity:sessions.allTabsRunning`,{defaultValue:`All 4 tab slots are full. Close a tab before opening a new session.`}))};return u.length===0&&!r?null:(0,Z.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center justify-between border-b border-border/70 bg-card/60 px-2 text-xs backdrop-blur-md`,children:[(0,Z.jsxs)(`div`,{role:`tablist`,"aria-label":`Open session tabs`,className:`flex min-w-0 flex-1 items-center gap-1 overflow-x-auto overscroll-contain [scrollbar-gutter:stable] no-scrollbar`,children:[u.map(e=>{let t=al(e.slot);return(0,Z.jsxs)(`div`,{role:`tab`,tabIndex:0,"aria-selected":e.isActive,onClick:()=>d(e.sessionId),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),d(e.sessionId))},className:G(`group relative flex h-7 max-w-[220px] min-w-[126px] cursor-pointer items-center gap-1.5 rounded-t-md border-t border-x px-2 transition-colors select-none`,e.isActive?`border-border/80 bg-background text-foreground font-medium shadow-xs`:`border-transparent bg-transparent text-muted-foreground hover:bg-muted/40 hover:text-foreground`),title:`Slot ${e.slot+1} · ${e.title}\n${e.provider}/${e.model}\n${e.sessionId}`,children:[(0,Z.jsx)(`span`,{className:G(`inline-flex h-4 w-4 shrink-0 items-center justify-center rounded text-[9px] font-bold`,t.soft,t.text),children:e.slot+1}),(0,Z.jsx)(`span`,{className:`shrink-0`,children:e.needsAttention?(0,Z.jsx)(Kr,{className:`h-3 w-3 text-warning`}):e.isRunning?(0,Z.jsx)(wt,{className:`h-3 w-3 animate-spin text-primary`}):(0,Z.jsx)(Lt,{className:`h-3 w-3 opacity-50`})}),(0,Z.jsx)(`span`,{className:`truncate text-[11px] font-mono leading-tight`,children:e.title}),e.unread>0&&(0,Z.jsxs)(`span`,{className:`shrink-0 rounded bg-primary/15 px-1 text-[9px] font-semibold text-primary`,title:`${e.unread} new message(s) since you last looked`,children:[`+`,e.unread]}),(0,Z.jsxs)(`span`,{className:G(`inline-flex shrink-0 items-center gap-0.5 rounded px-1 text-[9px] font-semibold`,e.agentsRunning>0?`bg-success/15 text-success`:e.agentsTotal>0?`bg-muted/60 font-mono text-muted-foreground`:`bg-muted/30 font-mono text-muted-foreground/65`),title:e.agentsRunning>0?`${e.agentsRunning} running agent(s) in this tab, ${e.agentsTotal} total`:`${e.agentsTotal} agent(s) in this tab`,children:[(0,Z.jsx)(jr,{className:`h-2.5 w-2.5`}),e.agentsRunning>0?`${e.agentsRunning}/${e.agentsTotal}`:e.agentsTotal]}),u.length>1&&(0,Z.jsx)(`button`,{type:`button`,onClick:t=>f(e.sessionId,t),title:`Close tab`,className:G(`ml-auto h-4 w-4 shrink-0 inline-flex items-center justify-center rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors`,e.isActive?`opacity-70 hover:opacity-100`:`opacity-0 group-hover:opacity-100`),children:(0,Z.jsx)(St,{className:`h-2.5 w-2.5`})}),e.isActive&&(0,Z.jsx)(`div`,{className:G(`absolute inset-x-0 -bottom-[1px] h-[2px]`,t.dot)})]},e.sessionId)}),(0,Z.jsx)(`button`,{type:`button`,onClick:p,title:e(`chat:newSession`,`New Session`),className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors`,children:(0,Z.jsx)(_i,{className:`h-3.5 w-3.5`})})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 pl-1`,children:[(0,Z.jsxs)(mo,{open:c,onOpenChange:l,children:[(0,Z.jsx)(ho,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex h-7 items-center gap-1 rounded px-2 text-[11px] text-muted-foreground hover:bg-muted hover:text-foreground transition-colors`,title:`What is in each tab`,children:[(0,Z.jsxs)(`span`,{className:`font-mono`,children:[u.length,`/`,ee]}),(0,Z.jsx)(`span`,{className:`hidden sm:inline`,children:`Map`}),(0,Z.jsx)(Ct,{className:`h-3 w-3 opacity-60`})]})}),(0,Z.jsx)(vo,{align:`end`,className:`p-0`,children:(0,Z.jsx)(cl,{tabs:u,onSelect:d,onNew:p})})]}),(0,Z.jsxs)(mo,{children:[(0,Z.jsx)(ho,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex h-7 items-center gap-1 rounded px-2 text-[11px] text-muted-foreground hover:bg-muted hover:text-foreground transition-colors`,title:`All Sessions`,children:[(0,Z.jsx)(Fn,{className:`h-3 w-3`}),(0,Z.jsx)(`span`,{className:`hidden sm:inline`,children:`Sessions`}),(0,Z.jsx)(Ct,{className:`h-3 w-3 opacity-60`})]})}),(0,Z.jsxs)(vo,{align:`end`,className:`w-64 max-h-80 overflow-y-auto`,children:[(0,Z.jsxs)(So,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:[`Recent Sessions (`,i.length,`)`]}),(0,Z.jsx)(Co,{}),i.slice(0,15).map(e=>{let t=a.indexOf(e.id),n=e.name||e.title||e.id.slice(0,8);return(0,Z.jsxs)(yo,{onSelect:()=>d(e.id),className:`flex items-center justify-between text-xs font-mono`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 truncate`,children:[(0,Z.jsx)(Lt,{className:G(`h-3.5 w-3.5 shrink-0`,e.id===r?`text-primary`:`text-muted-foreground`)}),(0,Z.jsx)(`span`,{className:G(`truncate`,e.id===r&&`text-primary font-medium`),children:n})]}),t>=0&&(0,Z.jsxs)(`span`,{className:G(`ml-1 text-[10px] font-semibold`,al(t).text),title:`Already open in slot ${t+1}`,children:[`▪ `,t+1]})]},e.id)})]})]})]})]})}var pl=[{sectionKey:`sectionGlobal`,items:[{keys:[`Ctrl`,`K`],descKey:`dCommandPalette`},{keys:[`?`],descKey:`dShowOverlay`},{keys:[`Ctrl`,`\\`],descKey:`dToggleSidebar`},{keys:[`Ctrl`,`1-8`],descKey:`dOpenPanel`},{keys:[`Ctrl`,`9`],descKey:`dSettings`},{keys:[`Ctrl`,`0`],descKey:`dDesignStudio`},{keys:[`Ctrl`,`Shift`,`W`],descKey:`dWorktrees`},{keys:[`Ctrl`,`Shift`,`K`],descKey:`dMemory`},{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:[`Alt`,`Enter`],descKey:`dFastSend`},{keys:[`↑`],descKey:`dPreviousPrompt`},{keys:[`↓`],descKey:`dNextPrompt`},{keys:[`Esc`],descKey:`dAbortStream`}]},{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 ml(){let{t:e}=H(),t=K(e=>e.shortcutsOpen),n=K(e=>e.setShortcutsOpen),r=W(e=>e.keyboardShortcuts);return(0,X.useEffect)(()=>{if(!r)return;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(!K.getState().shortcutsOpen))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n,r]),(0,Z.jsx)(Ja,{open:t,onOpenChange:e=>{e||n(!1)},children:(0,Z.jsxs)(Ga,{className:`max-w-2xl gap-0 p-0 overflow-hidden flex flex-col max-h-[80dvh]`,children:[(0,Z.jsx)(`div`,{className:`flex items-center justify-between px-5 py-4 border-b`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Wn,{className:`h-4 w-4 text-muted-foreground`}),(0,Z.jsx)(Ka,{className:`text-sm font-semibold`,children:e(`activity:shortcuts.heading`)})]})}),(0,Z.jsx)(qa,{className:`sr-only`,children:e(`activity:shortcuts.heading`)}),(0,Z.jsx)(`div`,{className:`overflow-y-auto overscroll-contain px-5 py-4 space-y-6`,children:pl.map(t=>(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground mb-2`,children:e(`activity:shortcuts.${t.sectionKey}`)}),(0,Z.jsx)(`div`,{className:`grid grid-cols-1 gap-1.5`,children:t.items.map(t=>(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-sm px-2 py-1.5 rounded hover:bg-muted/40`,children:[(0,Z.jsx)(`span`,{className:`text-foreground/80`,children:e(`activity:shortcuts.${t.descKey}`)}),(0,Z.jsx)(`span`,{className:`flex items-center gap-1 shrink-0`,children:t.keys.map((e,t)=>(0,Z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[t>0&&(0,Z.jsx)(`span`,{className:`text-muted-foreground/65 text-xs`,children:`+`}),(0,Z.jsx)(`kbd`,{className:`font-mono text-[10px] border rounded px-1.5 py-0.5 bg-background`,children:Va(e)})]},e))})]},t.descKey))})]},t.sectionKey))}),(0,Z.jsxs)(`div`,{className:`border-t px-5 py-3 text-xs text-muted-foreground`,children:[e(`activity:shortcuts.footerPre`),` `,(0,Z.jsx)(`kbd`,{className:`font-mono text-[10px] border rounded px-1 py-0.5 bg-background`,children:`?`}),` `,e(`activity:shortcuts.footerPost`)]})]})})}function hl(){document.querySelector(`[role="dialog"]`)||document.getElementById(`ws-file-tree`)?.focus()}function gl({contextMenu:e,onClose:t,copyToClipboard:n,handleStartCreate:r,handleShellOpen:i}){let{t:a}=H(),o=e.crumb;return(0,Z.jsxs)(mo,{open:!0,onOpenChange:e=>{e||t()},children:[(0,Z.jsx)(ho,{asChild:!0,children:(0,Z.jsx)(`span`,{"aria-hidden":`true`,tabIndex:-1,style:{position:`fixed`,left:e.x,top:e.y,width:1,height:1}})}),(0,Z.jsxs)(vo,{side:`right`,align:`start`,className:`min-w-[160px]`,onCloseAutoFocus:e=>{e.preventDefault(),hl()},children:[(0,Z.jsx)(yo,{onSelect:()=>n(o.absPath),children:a(`activity:fileExplorer.copyAbsPath`)}),(0,Z.jsx)(yo,{onSelect:()=>n(o.relPath),children:a(`activity:fileExplorer.copyRelPath`)}),(0,Z.jsx)(Co,{}),(0,Z.jsxs)(yo,{onSelect:()=>r(o.relPath===`.`?``:o.relPath,`file`),children:[(0,Z.jsx)(Re,{}),a(`activity:fileExplorer.newFile`)]}),(0,Z.jsxs)(yo,{onSelect:()=>r(o.relPath===`.`?``:o.relPath,`directory`),children:[(0,Z.jsx)(Nt,{}),a(`activity:fileExplorer.newFolder`)]}),(0,Z.jsx)(Co,{}),(0,Z.jsx)(yo,{onSelect:()=>i(o.absPath,`terminal`),children:a(`activity:fileExplorer.openInTerminal`)}),(0,Z.jsx)(yo,{onSelect:()=>i(o.absPath,`file-manager`),children:a(`activity:fileExplorer.openInFileManager`)}),(0,Z.jsx)(Co,{}),(0,Z.jsx)(So,{className:`max-w-[220px] truncate text-[9px] font-normal text-muted-foreground/70`,children:o.absPath})]})]})}function _l({nodeMenu:e,onClose:t,handleMentionInChat:n,copyNodePath:r,handleStartCreate:i,handleStartRename:a,handleDelete:o}){let{t:s}=H(),c=e.node;return(0,Z.jsxs)(mo,{open:!0,onOpenChange:e=>{e||t()},children:[(0,Z.jsx)(ho,{asChild:!0,children:(0,Z.jsx)(`span`,{"aria-hidden":`true`,tabIndex:-1,style:{position:`fixed`,left:e.x,top:e.y,width:1,height:1}})}),(0,Z.jsxs)(vo,{side:`right`,align:`start`,className:`min-w-[170px]`,onCloseAutoFocus:e=>{e.preventDefault(),hl()},children:[c.type===`file`&&(0,Z.jsx)(yo,{onSelect:()=>n(c),children:s(`activity:fileExplorer.mentionInChat`)}),(0,Z.jsx)(yo,{onSelect:()=>r(c.path),children:s(`activity:fileExplorer.copyPath`)}),(0,Z.jsx)(Co,{}),c.type===`directory`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(yo,{onSelect:()=>i(c.path,`file`),children:[(0,Z.jsx)(Re,{}),s(`activity:fileExplorer.newFile`)]}),(0,Z.jsxs)(yo,{onSelect:()=>i(c.path,`directory`),children:[(0,Z.jsx)(Nt,{}),s(`activity:fileExplorer.newFolder`)]})]}),(0,Z.jsx)(yo,{onSelect:()=>a(c),children:s(`activity:fileExplorer.rename`)}),(0,Z.jsxs)(yo,{onSelect:()=>o(c),className:`text-destructive focus:bg-destructive/10`,children:[(0,Z.jsx)(vr,{}),s(`activity:fileExplorer.delete`)]}),(0,Z.jsx)(Co,{}),(0,Z.jsx)(So,{className:`max-w-[220px] truncate text-[9px] font-normal text-muted-foreground/70`,children:c.path})]})]})}function vl({createPrompt:e,createName:t,setCreateName:n,onCancel:r,onConfirm:i}){let{t:a}=H();return(0,Z.jsx)(Ja,{open:!0,onOpenChange:e=>{e||r()},children:(0,Z.jsxs)(Ga,{showCloseButton:!1,className:`max-w-[340px] gap-3 p-4`,children:[(0,Z.jsxs)(Ua,{children:[(0,Z.jsx)(Ka,{className:`text-[13px]`,children:e.type===`file`?a(`activity:fileExplorer.newFileTitle`):a(`activity:fileExplorer.newFolderTitle`)}),(0,Z.jsx)(qa,{className:`truncate text-[11px]`,children:e.dirPath||`.`})]}),(0,Z.jsx)(`input`,{type:`text`,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{e.key===`Enter`&&i()},placeholder:e.type===`file`?a(`activity:fileExplorer.newFileNamePlaceholder`):a(`activity:fileExplorer.newFolderNamePlaceholder`),className:`w-full px-2 py-1 text-[11px] border rounded bg-background outline-none focus:ring-1 ring-primary`}),(0,Z.jsxs)(Wa,{className:`gap-2`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:r,className:`px-2 py-1 text-[10px] rounded border text-muted-foreground hover:text-foreground`,children:a(`common:action.cancel`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:i,disabled:!t.trim(),className:`px-2 py-1 text-[10px] rounded border border-primary text-primary font-medium hover:bg-primary hover:text-primary-foreground disabled:opacity-40`,children:a(`common:action.create`)})]})]})})}function yl({renamePrompt:e,renameValue:t,setRenameValue:n,onCancel:r,onConfirm:i}){let{t:a}=H();return(0,Z.jsx)(Ja,{open:!0,onOpenChange:e=>{e||r()},children:(0,Z.jsxs)(Ga,{showCloseButton:!1,className:`max-w-[340px] gap-3 p-4`,children:[(0,Z.jsxs)(Ua,{children:[(0,Z.jsx)(Ka,{className:`text-[13px]`,children:a(`activity:fileExplorer.renameTitle`)}),(0,Z.jsx)(qa,{className:`truncate text-[11px]`,children:e.oldPath})]}),(0,Z.jsx)(`input`,{type:`text`,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{e.key===`Enter`&&i()},className:`w-full px-2 py-1 text-[11px] border rounded bg-background outline-none focus:ring-1 ring-primary`}),(0,Z.jsxs)(Wa,{className:`gap-2`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:r,className:`px-2 py-1 text-[10px] rounded border text-muted-foreground hover:text-foreground`,children:a(`common:action.cancel`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:i,disabled:!t.trim()||t.trim()===e.initialName,className:`px-2 py-1 text-[10px] rounded border border-primary text-primary font-medium hover:bg-primary hover:text-primary-foreground disabled:opacity-40`,children:a(`common:action.rename`)})]})]})})}var bl={ts:kn,tsx:kn,js:kn,jsx:kn,mjs:kn,cjs:kn,json:Pn,lock:pn,css:tn,scss:tn,less:tn,html:Ot,htm:Ot,svg:xn,xml:Ot,md:tn,mdx:tn,txt:tn,yml:tn,yaml:tn,toml:di,env:di,gitignore:di,editorconfig:di,sh:kn,bash:kn,zsh:kn,fish:kn,ps1:kn,bat:kn,py:kn,pyi:kn,pyx:kn,rs:kn,go:kn,rb:kn,java:kn,c:kn,cpp:kn,h:kn,hpp:kn,sql:kn,graphql:kn,png:xn,jpg:xn,jpeg:xn,gif:xn,webp:xn,ico:xn};function xl(e,t){if(t){let t=e.toLowerCase();return t===`.git`?`text-primary/80`:t===`node_modules`?`text-destructive/70`:t===`src`||t===`lib`||t===`packages`?`text-warning/80`:t===`tests`||t===`test`||t===`__tests__`?`text-success/80`:t===`dist`||t===`build`||t===`.next`?`text-muted-foreground/70`:`text-warning/80`}let n=e.split(`.`).pop()?.toLowerCase()??``;return/^(ts|tsx|js|jsx|mjs|cjs|py|pyi|pyx|go)$/.test(n)?`text-info`:/^(json|lock)$/.test(n)?`text-warning`:/^(css|scss|less|sass)$/.test(n)?`text-accent-foreground`:/^(html|htm|xml|svg|rb)$/.test(n)?`text-destructive`:/^(md|mdx|png|jpe?g|gif|webp|ico)$/.test(n)?`text-primary`:/^(yml|yaml|toml|env)$/.test(n)?`text-success`:/^(sh|bash|zsh|fish|ps1|bat|rs)$/.test(n)?`text-brand-orange`:/^(c|h|cpp|hpp|cc|hh)$/.test(n)?`text-muted-foreground/80`:/^(gitignore|editorconfig|prettierrc|eslintrc)$/.test(n)?`text-muted-foreground/75`:`text-muted-foreground`}function Sl(e){return bl[e.split(`.`).pop()?.toLowerCase()??``]??gt}function Cl(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 wl(e,t){let n=e.toLowerCase(),r=n.split(`/`).pop()??n,i=0;if(r===t)i=100;else if(r.startsWith(t))i=60;else if(n.includes(t))i=20;else return-1;return i-=n.split(`/`).length,i}function Tl(e){let t=[],n=e=>{for(let r of e)r.type===`file`?t.push(r):r.children&&n(r.children)};return n(e),t}function El(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}function Dl(e){return`ws-file-row-${encodeURIComponent(e)}`}var Ol={M:`text-warning`,A:`text-success`,D:`text-destructive`,R:`text-info`,C:`text-info`,U:`text-destructive`,"?":`text-primary`},kl={M:`Modified`,A:`Added`,D:`Deleted`,R:`Renamed`,C:`Copied`,U:`Unmerged`,"?":`Untracked`};function Al({status:e}){let t=e[0]??`?`,n=Ol[t]??`text-muted-foreground`,r=kl[t]??`Unknown`;return(0,Z.jsx)(`span`,{role:`img`,"aria-label":r,className:G(`shrink-0 text-[8px] font-bold tabular-nums`,n),title:r,children:t})}var jl=(0,X.memo)(function({node:e,depth:t,emptyPlaceholder:n,expanded:r,isActive:i,isSelected:a,isFocused:o,gitStatus:s,onToggle:c,onSelect:l,onOpen:u,onContextMenu:d}){let{t:f}=H();if(n)return(0,Z.jsx)(`div`,{role:`treeitem`,"aria-disabled":`true`,"aria-level":t+1,className:`text-[10px] text-muted-foreground italic py-0.5`,style:{paddingLeft:`${t*14+4}px`},children:f(`activity:fileExplorer.emptyDir`)});if(e.type===`directory`){let n=r?Rt:Br,i=xl(e.name,!0);return(0,Z.jsxs)(`button`,{type:`button`,id:Dl(e.path),title:e.path,role:`treeitem`,"aria-expanded":r,"aria-level":t+1,tabIndex:-1,onClick:()=>c(e.path),onContextMenu:t=>d(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,Z.jsx)(ot,{className:G(`h-3 w-3 shrink-0 text-muted-foreground transition-transform`,r&&`rotate-90`)}),(0,Z.jsx)(n,{className:G(`h-3.5 w-3.5 shrink-0`,i)}),(0,Z.jsx)(`span`,{className:G(`truncate font-medium flex-1 min-w-0`,s===`M`&&`text-warning/80`),children:e.name}),s&&(0,Z.jsx)(Al,{status:s})]})}let p=Sl(e.name),m=xl(e.name,!1);return(0,Z.jsxs)(`button`,{type:`button`,id:Dl(e.path),title:e.path,role:`treeitem`,"aria-level":t+1,"aria-selected":i||a,tabIndex:-1,onClick:()=>{l(e.path),u(e.path)},onContextMenu:t=>d(t,e),onDoubleClick:t=>{t.preventDefault(),u(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,Z.jsx)(`span`,{className:`w-3 shrink-0`}),(0,Z.jsx)(p,{className:G(`h-3.5 w-3.5 shrink-0`,m)}),(0,Z.jsx)(`span`,{className:G(`truncate flex-1 min-w-0`,!i&&s===`M`&&`text-warning/90`,!i&&(s===`A`||s===`?`)&&`text-success/90`,s===`D`&&`line-through opacity-70 text-destructive/90`),children:e.name}),s&&(0,Z.jsx)(Al,{status:s})]})});async function Ml(e){try{if(typeof navigator<`u`&&navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),n}catch{return!1}}function Nl(e,t){if(typeof document>`u`)return;let n=new Blob([t],{type:`text/plain;charset=utf-8`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i),setTimeout(()=>URL.revokeObjectURL(r),1e3)}function Pl(e){let t=(e??``).toLowerCase();return/bash|shell|exec|run/.test(t)?`log`:(/grep|search|find/.test(t),`txt`)}function Fl(e){return e<1e3?`${e} ms`:e<6e4?`${(e/1e3).toFixed(e<1e4?2:1)}s`:`${Math.floor(e/6e4)}m ${Math.floor(e%6e4/1e3)}s`}function Il(e){if(!e)return;let t=e.match(/(?:^|\n)\s*(?:\[?exit(?:\s*code)?\]?\s*[:=]?\s*)(\d+)\s*$/i);return t?Number(t[1]):void 0}var Ll=[ao];function Rl(e){return typeof e==`string`||typeof e==`number`?String(e):Array.isArray(e)?e.map(Rl).join(``):(0,X.isValidElement)(e)?Rl(e.props.children):``}function zl({text:e}){let{t}=H(),[n,r]=(0,X.useState)(!1),i=(0,X.useCallback)(async()=>{await Ml(e)&&(r(!0),setTimeout(()=>r(!1),1500))},[e]);return(0,Z.jsxs)(`button`,{type:`button`,onClick:i,className:G(`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] transition-colors`,`hover:bg-muted-foreground/10`,n?`text-success`:`text-muted-foreground hover:text-foreground`),title:t(n?`common:action.copied`:`common:action.copy`),children:[n?(0,Z.jsx)(ui,{className:`h-3 w-3`}):(0,Z.jsx)(oi,{className:`h-3 w-3`}),(0,Z.jsx)(`span`,{children:t(n?`common:action.copied`:`common:action.copy`)})]})}var Bl={code({inline:e,className:t,children:n,...r}){let i=/language-(\w+)/.exec(t??``),a=Rl(n).replace(/\n$/,``);if(e||!i)return(0,Z.jsx)(`code`,{className:G(`rounded border border-border/60 px-1.5 py-0.5 text-[0.85em] font-mono`,t),...r,children:n});let o=(0,X.useMemo)(()=>a.split(`
|
|
74
74
|
`),[a]),s=o.length>1;return(0,Z.jsxs)(`div`,{className:`not-prose relative my-3 rounded-lg border border-border overflow-hidden group/codeblock`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-1 border-b border-border text-xs`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(bt,{className:`h-3 w-3 text-muted-foreground`}),(0,Z.jsx)(`span`,{className:`font-mono text-muted-foreground font-medium`,children:i[1]}),o.length>0&&(0,Z.jsxs)(`span`,{className:`text-[10px] text-muted-foreground/75 tabular-nums`,children:[o.length,` line`,o.length===1?``:`s`]})]}),(0,Z.jsx)(zl,{text:a})]}),s?(0,Z.jsxs)(`div`,{className:`flex max-h-[40rem] overflow-auto`,children:[(0,Z.jsx)(`pre`,{"aria-hidden":!0,className:`text-xs font-mono leading-[1.55] py-3 pl-3 pr-2 text-muted-foreground/65 select-none border-r border-border/30 tabular-nums text-right shrink-0`,children:o.map((e,t)=>(0,Z.jsx)(`div`,{children:t+1},t))}),(0,Z.jsx)(`pre`,{className:`overflow-x-auto py-3 px-3 text-xs leading-[1.55] font-mono flex-1`,children:(0,Z.jsx)(`code`,{className:G(`hljs`,t),...r,children:n})})]}):(0,Z.jsx)(`pre`,{className:`overflow-x-auto p-3 text-xs leading-relaxed font-mono max-h-[40rem]`,children:(0,Z.jsx)(`code`,{className:G(`hljs`,t),...r,children:n})}),(0,Z.jsx)(`div`,{className:`pointer-events-none absolute bottom-8 left-0 right-0 h-8 opacity-0 group-hover/codeblock:opacity-100 transition-opacity`,style:{background:`linear-gradient(to top, hsl(var(--foreground) / 0.08), transparent)`}})]})},table({className:e,children:t,...n}){return(0,Z.jsx)(`div`,{className:`not-prose my-3 w-full max-w-full overflow-x-auto rounded-lg border border-border/80 bg-card/40 shadow-sm scrollbar-thin`,children:(0,Z.jsx)(`table`,{className:G(`w-full min-w-full table-auto border-collapse text-left text-xs`,e),...n,children:t})})},thead({className:e,children:t,...n}){return(0,Z.jsx)(`thead`,{className:G(`border-b border-border/80 bg-muted/60 text-foreground font-semibold`,e),...n,children:t})},tbody({className:e,children:t,...n}){return(0,Z.jsx)(`tbody`,{className:G(`divide-y divide-border/40 text-foreground/90`,e),...n,children:t})},tr({className:e,children:t,...n}){return(0,Z.jsx)(`tr`,{className:G(`transition-colors hover:bg-muted/30 even:bg-muted/10`,e),...n,children:t})},th({className:e,children:t,...n}){return(0,Z.jsx)(`th`,{className:G(`px-3 py-2 text-xs font-semibold text-foreground whitespace-nowrap`,e),...n,children:t})},td({className:e,children:t,...n}){return(0,Z.jsx)(`td`,{className:G(`px-3 py-2 text-xs text-foreground/90 break-words align-top`,e),...n,children:t})}},Vl=`__no_session__`,Hl=new Map,Ul=new Set;se(e=>{Hl.delete(e),Ul.add(e)});function Wl(){let{t:e}=H(),n=ve(),r=t(e=>e.tree),i=t(e=>e.treeLoading),a=t(e=>e.error),o=t(e=>e.openFiles),s=t(e=>e.activeFilePath),c=N(e=>e.cwd),l=N(e=>e.projectName),u=C(e=>e.files),d=C(e=>e.repoPrefix),f=C(e=>e.dirs),p=(0,X.useMemo)(()=>{let e=new Map;for(let t of u){let n=t.path.replace(/\\/g,`/`).replace(/^\//,``);e.set(n,t.status)}return e},[u]),m=(0,X.useMemo)(()=>new Map(Object.entries(f)),[f]),h=(0,X.useCallback)((e,t)=>{let n=(c||l||``).replace(/\\/g,`/`).replace(/^\//,``).replace(/\/$/,``),r=e.replace(/\\/g,`/`).replace(/^\//,``);n&&r.startsWith(n+`/`)&&(r=r.slice(n.length+1));let i=d+r,a=p.get(i);if(a)return a;if(t)return m.get(i)},[p,m,d,c,l]),g=c?.includes(`\\`)?`\\`:`/`,_=(e,t=8,n=4)=>e.length<=t+n+2?e:`${e.slice(0,t)}…${e.slice(-n)}`,v=(()=>{if(!c||!l)return!0;let e=c.replace(/\\/g,`/`).split(`/`).filter(Boolean);return(e[e.length-1]??``)===l})(),y=(0,X.useMemo)(()=>{if(!c||!l)return[];let e=c.replace(/\\/g,`/`).split(`/`).filter(Boolean),t=-1;for(let n=e.length-1;n>=0;n--)if(e[n]===l){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}))},[c,l]),b=(0,X.useRef)(null);(0,X.useEffect)(()=>{let e=b.current;e&&y.length>1&&(e.scrollLeft=e.scrollWidth)},[y]);let x=(0,X.useCallback)(e=>{V().send({type:`working_dir.set`,payload:{path:e}})},[]),[S,w]=(0,X.useState)(null),[T,E]=(0,X.useState)(null),D=(0,X.useCallback)((e,t)=>{e.preventDefault(),e.stopPropagation(),E({x:e.clientX,y:e.clientY,node:t})},[]),O=(0,X.useCallback)(e=>{e.type===`file`&&(ja.getState().addRef({kind:`file`,path:e.path}),J(`chat`)),E(null)},[]),k=(0,X.useCallback)((e,t)=>{e.preventDefault(),e.stopPropagation(),w({x:e.clientX,y:e.clientY,crumb:t})},[]),A=(0,X.useCallback)(t=>{Ml(t).then(t=>{t?B.success(e(`common:action.copied`)):B.error(e(`common:action.copyFailed`))}),w(null)},[e]),j=(0,X.useCallback)(()=>{if(!s)return;let e=s.replace(/\\/g,`/`).split(`/`).slice(0,-1).join(`/`)||`.`;V().send({type:`working_dir.set`,payload:{path:e}})},[s]),M=(0,X.useCallback)((e,t)=>{V().send({type:`shell.open`,payload:{path:e,target:t}}),w(null)},[]),[P,F]=(0,X.useState)(null),[I,L]=(0,X.useState)(``),R=(0,X.useCallback)((e,t)=>{E(null),L(``),F({dirPath:e,type:t})},[]),ee=(0,X.useCallback)(()=>{if(!P||!I.trim())return;let e=P.dirPath?`${P.dirPath}/${I.trim()}`:I.trim();V().send({type:`files.create`,payload:V().withSession({filePath:e,type:P.type})}),F(null),L(``)},[P,I]),te=(0,X.useCallback)(t=>{E(null);let n=t.type===`directory`;window.confirm(e(n?`activity:fileExplorer.confirmDeleteDir`:`activity:fileExplorer.confirmDeleteFile`,{name:t.name}))&&V().send({type:`files.delete`,payload:V().withSession({filePath:t.path,recursive:n})})},[e]),[z,ne]=(0,X.useState)(null),[re,ie]=(0,X.useState)(``),ae=(0,X.useCallback)(e=>{E(null),ie(e.name),ne({oldPath:e.path,initialName:e.name})},[]),oe=(0,X.useCallback)(()=>{if(!z||!re.trim())return;let e=z.oldPath.replace(/\\/g,`/`).split(`/`).slice(0,-1).join(`/`),t=e?`${e}/${re.trim()}`:re.trim();if(t===z.oldPath){ne(null);return}V().send({type:`files.rename`,payload:V().withSession({oldPath:z.oldPath,newPath:t})}),ne(null),ie(``)},[z,re]),se=(0,X.useCallback)(()=>{if(!c)return;let e=c.replace(/\\/g,`/`),t=e.split(`/`).slice(0,-1).join(`/`)||e;V().send({type:`working_dir.set`,payload:{path:t}})},[c]),[ce,le]=(0,X.useState)(!1),ue=(0,X.useRef)(null);(0,X.useEffect)(()=>(i?ue.current=setTimeout(()=>le(!0),150):(ue.current&&clearTimeout(ue.current),le(!1)),()=>{ue.current&&clearTimeout(ue.current)}),[i]);let[de,fe]=(0,X.useState)(null),[pe,me]=(0,X.useState)(new Set),he=(0,X.useRef)(null);(0,X.useEffect)(()=>{he.current!==(c??``)&&r.length!==0&&(he.current=c??``)},[c,r]);let ge=(0,X.useCallback)(e=>{me(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),_e=(0,X.useMemo)(()=>El(r),[r]),ye=_e.length,[be,xe]=(0,X.useState)(!1),[Se,Ce]=(0,X.useState)(``),[we,Te]=(0,X.useState)(-1),Ee=(0,X.useRef)(n??Vl);(0,X.useLayoutEffect)(()=>{Ul.has(Ee.current)||Hl.set(Ee.current,{contextMenu:S,nodeMenu:T,createPrompt:P,createName:I,renamePrompt:z,renameValue:re,selectedPath:de,expandedDirs:[...pe],sortBySize:be,searchQuery:Se,focusedIdx:we});let e=n??Vl,t=Hl.get(e);Ul.delete(e),w(t?.contextMenu??null),E(t?.nodeMenu??null),F(t?.createPrompt??null),L(t?.createName??``),ne(t?.renamePrompt??null),ie(t?.renameValue??``),fe(t?.selectedPath??null),me(new Set(t?.expandedDirs??[])),xe(t?.sortBySize??!1),Ce(t?.searchQuery??``),Te(t?.focusedIdx??-1),Ee.current=e},[n]);let De=(0,X.useMemo)(()=>be?[...r].sort((e,t)=>{if(e.type===`directory`&&t.type===`file`)return-1;if(e.type===`file`&&t.type===`directory`)return 1;if(e.type===`directory`)return e.name.localeCompare(t.name);let n=e.size??0,r=t.size??0;return r===n?e.name.localeCompare(t.name):r-n}):r,[r,be]),Oe=(0,X.useMemo)(()=>{if(Se.trim()){let e=Se.trim().toLowerCase();return Tl(De).map(t=>({node:t,score:wl(t.path,e)})).filter(e=>e.score>=0).sort((e,t)=>t.score-e.score||e.node.path.localeCompare(t.node.path)).slice(0,200).map(e=>({node:e.node,depth:0}))}return Cl(De,pe)},[De,pe,Se]),ke=(0,X.useMemo)(()=>{let e=0,t=0;for(let n of r)n.type===`directory`?t++:e++;return{files:e,dirs:t}},[r]),Ae=(0,X.useCallback)(()=>{me(new Set)},[]),je=(0,X.useCallback)(()=>{me(new Set(_e))},[_e]),Me=(0,X.useCallback)(e=>{if(o.find(t=>t.path===e)){t.getState().setActiveFile(e),K.getState().setCurrentView(`files`);return}fe(t=>t===e?null:e)},[o]),Pe=(0,X.useCallback)(e=>{K.getState().setCurrentView(`files`),window.dispatchEvent(new CustomEvent(`wrongstack:open-file`,{detail:{filePath:e}})),fe(null)},[]);(0,X.useEffect)(()=>{s&&fe(null)},[s]);let Fe=(0,X.useRef)(null),Ie=we>=0&&we<Oe.length&&!Oe[we]?.emptyPlaceholder?Oe[we]?.node.path??null:null,Le=(0,X.useCallback)(e=>{if(Oe.length===0)return;let t=(e,t)=>{let n=e+t;for(;n>=0&&n<Oe.length&&Oe[n]?.emptyPlaceholder;)n+=t;return n<0||n>=Oe.length?e:n},n=e=>{Te(e),Fe.current?.scrollToIndex(e,{align:`nearest`})},r=we,i=r>=0&&r<Oe.length?Oe[r]:void 0;switch(e.key){case`ArrowDown`:e.preventDefault(),n(t(r,1));break;case`ArrowUp`:e.preventDefault(),n(t(r===-1?Oe.length:r,-1));break;case`ArrowRight`:if(!i||i.emptyPlaceholder)break;e.preventDefault(),i.node.type===`directory`&&(pe.has(i.node.path)?n(t(r,1)):ge(i.node.path));break;case`ArrowLeft`:if(!i||i.emptyPlaceholder)break;if(e.preventDefault(),i.node.type===`directory`&&pe.has(i.node.path)){ge(i.node.path);break}for(let e=r-1;e>=0;e--){let t=Oe[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`?ge(i.node.path):Pe(i.node.path);break;case` `:if(!i||i.emptyPlaceholder)break;e.preventDefault(),i.node.type===`directory`?ge(i.node.path):Me(i.node.path);break;case`F10`:case`ContextMenu`:{if(e.key===`F10`&&!e.shiftKey||!i||i.emptyPlaceholder)break;e.preventDefault();let t=document.getElementById(Dl(i.node.path))?.getBoundingClientRect();E({x:t?.left??window.innerWidth/2,y:t?t.bottom+2:window.innerHeight/2,node:i.node});break}case`Home`:e.preventDefault(),n(t(-1,1));break;case`End`:e.preventDefault(),n(t(Oe.length,-1))}},[Oe,we,pe,ge,Pe,Me]),Re=(0,X.useCallback)(()=>{Te(e=>e===-1&&Oe.length>0?0:e)},[Oe.length]);return ce?(0,Z.jsx)(`div`,{className:`flex items-center justify-center h-full py-8`,children:(0,Z.jsx)(wt,{className:`h-5 w-5 animate-spin text-muted-foreground`})}):(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col overflow-hidden`,children:[a&&(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 px-2 py-1 border-b border-destructive/30 bg-destructive/5 text-[10px] text-destructive`,children:[(0,Z.jsx)(`span`,{className:`truncate flex-1 min-w-0`,children:e(`activity:fileExplorer.loadFailed`,{error:a})}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>t.getState().setError(null),className:`shrink-0 text-destructive/70 hover:text-destructive text-[10px]`,title:e(`common:action.dismiss`),"aria-label":e(`common:action.dismiss`),children:`✕`})]}),r.length>0&&ye>0&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-0.5 px-2 py-0.5 border-b shrink-0`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:je,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,Z.jsx)(Ut,{className:`h-3 w-3`}),(0,Z.jsx)(`span`,{children:e(`activity:fileExplorer.expandAll`)})]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:Ae,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,Z.jsx)(Ne,{className:`h-3 w-3`}),(0,Z.jsx)(`span`,{children:e(`activity:fileExplorer.collapse`)})]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>xe(e=>!e),className:G(`flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] transition-colors`,`hover:bg-muted/60`,be?`text-primary`:`text-muted-foreground hover:text-foreground`),title:e(be?`activity:fileExplorer.sortByNameTitle`:`activity:fileExplorer.sortBySizeTitle`),children:[(0,Z.jsx)(zi,{className:`h-3 w-3`}),(0,Z.jsx)(`span`,{children:e(be?`activity:fileExplorer.sortBySize`:`activity:fileExplorer.sortByName`)})]}),(0,Z.jsxs)(`div`,{className:`relative flex items-center`,children:[(0,Z.jsx)(vn,{className:`absolute left-1 h-3 w-3 text-muted-foreground/60 pointer-events-none`}),(0,Z.jsx)(`input`,{type:`text`,value:Se,onChange:e=>Ce(e.target.value),placeholder:e(`activity:fileExplorer.searchPlaceholder`),className:`w-28 rounded bg-muted/40 px-1 py-0.5 pl-4 text-[10px] text-foreground placeholder:text-muted-foreground/50 outline-none focus:w-40 focus:bg-muted/70 focus:ring-1 focus:ring-primary/30 transition-all`,"aria-label":e(`activity:fileExplorer.search`)}),Se&&(0,Z.jsx)(`button`,{type:`button`,onClick:()=>Ce(``),className:`absolute right-0.5 text-muted-foreground/60 hover:text-foreground text-[10px]`,"aria-label":e(`common:action.clear`),children:`✕`})]}),(0,Z.jsx)(`span`,{className:`ml-auto text-[9px] text-muted-foreground/70 tabular-nums`,children:e(`activity:fileExplorer.folders`,{count:ye})})]}),(0,Z.jsxs)(`div`,{className:`min-h-0 min-w-0 flex flex-1 flex-col py-1`,children:[y.length>0&&(0,Z.jsxs)(`div`,{ref:b,className:`relative flex shrink-0 items-center gap-0.5 px-1 pb-1 border-b border-border/30 overflow-x-auto`,children:[(0,Z.jsx)(`span`,{className:`sticky left-0 shrink-0 w-3 h-full bg-gradient-to-r from-background to-transparent pointer-events-none`}),y.map((t,n)=>{let r=t.isLast?t.label:_(t.label),i=t.path.replace(/\//g,g),a=c?c.replace(/\\/g,`/`).split(`/`).filter(Boolean):[],o=(()=>{for(let e=a.length-1;e>=0;e--)if(a[e]===l)return e;return-1})(),s=o>=0?a.slice(0,o+n+1):a.slice(0,n+1),u=g===`\\`?s.join(`\\`):`/`+s.join(`/`),d=(o>=0?a.slice(o+1,o+n+1):[]).join(g)||`.`;return(0,Z.jsxs)(`span`,{className:`flex items-center gap-0.5 shrink-0`,children:[n>0&&(0,Z.jsx)(`span`,{className:`text-[9px] text-muted-foreground/65 select-none`,children:g}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>x(t.path),onContextMenu:e=>k(e,{absPath:u,relPath:d}),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)}),r.length>0&&(0,Z.jsxs)(`span`,{className:`ml-auto shrink-0 text-[9px] text-muted-foreground/70 tabular-nums pl-2`,children:[ke.files>0&&e(`activity:fileExplorer.filesSuffix`,{count:ke.files}),ke.files>0&&ke.dirs>0&&`, `,ke.dirs>0&&e(`activity:fileExplorer.folders`,{count:ke.dirs})]})]}),s&&(0,Z.jsxs)(`button`,{type:`button`,onClick:j,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:s.replace(/\//g,g)}),children:[(0,Z.jsx)(kn,{className:`h-3 w-3 shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate`,children:(()=>{let e=s.replace(/\\/g,`/`).split(`/`);return e[e.length-1]??s})()}),(0,Z.jsx)(`span`,{className:`ml-auto text-[8px] text-muted-foreground/65 shrink-0`,children:e(`activity:fileExplorer.goToDir`)})]}),y.length===0&&!v&&(0,Z.jsxs)(`button`,{type:`button`,onClick:se,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,Z.jsx)(hr,{className:`h-3.5 w-3.5 shrink-0`}),(0,Z.jsx)(`span`,{children:`..`}),(0,Z.jsx)(`span`,{className:`text-[9px] text-muted-foreground/70 ml-auto`,children:e(`activity:fileExplorer.parentDirectory`)})]}),r.length>0?(0,Z.jsx)(`div`,{id:`ws-file-tree`,role:`tree`,"aria-label":e(`activity:fileExplorer.folders`,{count:ye}),"aria-activedescendant":Ie?Dl(Ie):void 0,tabIndex:0,onKeyDown:Le,onFocus:Re,className:`min-h-0 min-w-0 flex-1 outline-none`,children:(0,Z.jsx)(qr,{ref:Fe,className:`h-full`,children:Oe.map(e=>(0,Z.jsx)(jl,{node:e.node,depth:e.depth,emptyPlaceholder:e.emptyPlaceholder,expanded:e.node.type===`directory`&&pe.has(e.node.path),isActive:e.node.type===`file`&&e.node.path===s,isSelected:!e.emptyPlaceholder&&e.node.path===de,isFocused:!e.emptyPlaceholder&&e.node.path===Ie,gitStatus:e.emptyPlaceholder?void 0:h(e.node.path,e.node.type===`directory`),onToggle:ge,onSelect:Me,onOpen:Pe,onContextMenu:D},e.emptyPlaceholder?`${e.node.path}#empty`:e.node.path))})}):(0,Z.jsx)(`p`,{className:`text-[11px] text-muted-foreground italic p-2`,children:e(`activity:fileExplorer.noFiles`)})]}),S&&(0,Z.jsx)(gl,{contextMenu:S,onClose:()=>w(null),copyToClipboard:A,handleStartCreate:R,handleShellOpen:M}),T&&(0,Z.jsx)(_l,{nodeMenu:T,onClose:()=>E(null),handleMentionInChat:O,copyNodePath:t=>{Ml(t).then(t=>{t?B.success(e(`common:action.copied`)):B.error(e(`common:action.copyFailed`))}),E(null)},handleStartCreate:R,handleStartRename:ae,handleDelete:te}),P&&(0,Z.jsx)(vl,{createPrompt:P,createName:I,setCreateName:L,onCancel:()=>{F(null),L(``)},onConfirm:ee}),z&&(0,Z.jsx)(yl,{renamePrompt:z,renameValue:re,setRenameValue:ie,onCancel:()=>{ne(null),ie(``)},onConfirm:oe})]})}var Gl=[`note`,`ask`,`assign`,`steer`,`btw`,`broadcast`,`status`,`result`,`review`],Kl=`__no_session__`,ql=new Map,Jl=new Set;se(e=>{ql.delete(e),Jl.add(e)});var Yl={note:tn,ask:It,assign:ze,steer:An,btw:Qn,broadcast:ze,status:Vt,result:$t,review:vn};function Xl(e){let t=new Date(e),n=Date.now()-t.getTime();return n<6e4?U.t(`activity:mailbox.timeNow`):n<36e5?`${Math.round(n/6e4)}m`:n<864e5?`${Math.round(n/36e5)}h`:t.toLocaleDateString()}function Zl(e,t){if(!t||e.senderSessionId===t||e.recipientSessionId===t||e.to.includes(`@session:${t}`)||e.from.includes(`@session:${t}`))return!0;let n=Ia(e.to);return n.scope===`project`||n.recipientSessionId===t}function Ql({className:e}){let t=ve(),n=Fa(e=>e.messages),r=Fa(e=>e.agents),i=Fa(e=>e.lastCompaction),[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)(!1),[h,g]=(0,X.useState)(`leader`),[_,v]=(0,X.useState)(`note`),[y,b]=(0,X.useState)(`all`),[x,S]=(0,X.useState)(`normal`),[C,w]=(0,X.useState)(``),[T,E]=(0,X.useState)(``),[D,O]=(0,X.useState)({phase:`idle`}),k=(0,X.useRef)(t??Kl),{client:A}=ha(),{t:j}=H();(0,X.useLayoutEffect)(()=>{Jl.has(k.current)||ql.set(k.current,{collapsed:a,deleting:s,purging:l,compacting:d,composeOpen:p,composeTo:h,composeType:_,composeAudience:y,composePriority:x,composeSubject:C,composeBody:T,sendState:D});let e=t??Kl,n=ql.get(e);Jl.delete(e),o(n?.collapsed??!1),c(n?.deleting??!1),u(n?.purging??!1),f(n?.compacting??!1),m(n?.composeOpen??!1),g(n?.composeTo??`leader`),v(n?.composeType??`note`),b(n?.composeAudience??`all`),S(n?.composePriority??`normal`),w(n?.composeSubject??``),E(n?.composeBody??``),O(n?.sendState??{phase:`idle`}),k.current=e},[t]);let[M,N]=(0,X.useState)(A.status.state===`open`);(0,X.useEffect)(()=>{let e=A.onStatus(e=>N(e.state===`open`));return()=>e()},[A]),(0,X.useEffect)(()=>A.on(`mailbox.sent`,e=>{let t=e.payload;O(e=>e.phase!==`sending`||t.requestId!==e.requestId?e:t.success===!0?(E(``),{phase:`sent`,messageId:t.messageId}):{phase:`error`,message:t.error??j(`activity:mailbox.sendFailed`)})}),[A,j]),(0,X.useEffect)(()=>{M&&(A.send({type:`mailbox.messages`,payload:{limit:30}}),A.send({type:`mailbox.agents`,payload:{}}))},[M,A]);let P=K(e=>e.selectedMailMessage),F=K(e=>e.setSelectedMailMessage);function I(e){if(P?.id===e.id){F(null),J(`chat`);return}F(e),J(`mailbox`)}let L=n.filter(e=>Zl(e,t)),R=t?r.filter(e=>e.sessionId===t):r,ee=L.filter(e=>!e.completed).length,te=R.filter(e=>e.online).length,z=wc(L,8),ne=wc(R.filter(e=>e.online),5);async function re(){L.length!==0&&await $a({title:j(`activity:mailbox.deleteAllConfirmTitle`,{count:L.length}),message:j(`activity:mailbox.deleteAllConfirmBody`),confirmLabel:j(`activity:mailbox.deleteAll`),danger:!0})&&(c(!0),A.send({type:`mailbox.clear`}))}(0,X.useEffect)(()=>{s&&L.length===0&&c(!1)},[s,L.length]),(0,X.useEffect)(()=>{if(s){let e=setTimeout(()=>c(!1),3e3);return()=>clearTimeout(e)}},[s]);async function ie(){await $a({title:j(`activity:mailbox.purgeConfirmTitle`),message:j(`activity:mailbox.purgeConfirmBody`),confirmLabel:j(`activity:mailbox.purge`),danger:!1})&&(u(!0),A.send({type:`mailbox.purge`}))}(0,X.useEffect)(()=>{if(l){let e=setTimeout(()=>u(!1),3e3);return()=>clearTimeout(e)}},[l]);async function ae(){f(!0),A.send({type:`mailbox.compact`})}(0,X.useEffect)(()=>{if(d){let e=setTimeout(()=>f(!1),3e3);return()=>clearTimeout(e)}},[d]);function oe(){let e=T.trim(),n=_===`broadcast`?`*`:h.trim();if(!M||e.length===0||n.length===0||D.phase===`sending`)return;let r=`webui-mail-${Date.now()}-${Math.random().toString(36).slice(2,9)}`;O({phase:`sending`,requestId:r}),A.send({type:`mailbox.send`,payload:{requestId:r,to:n,type:_,audience:y,subject:C.trim()||j(`activity:mailbox.defaultSubject`),body:e,priority:x,...t?{sessionId:t}:{}}})}return(0,Z.jsxs)(`div`,{className:G(`rounded-lg border border-border bg-card/60 backdrop-blur-sm`,e),children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>o(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,Z.jsx)(Le,{className:`h-4 w-4 text-primary`}),(0,Z.jsx)(`span`,{className:`text-xs font-semibold text-foreground flex-1 min-w-0 truncate`,children:j(`activity:nav.mailbox`)}),ee>0&&(0,Z.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:ee}),(0,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:j(`activity:mailbox.onlineCount`,{count:te})})]}),!a&&(0,Z.jsxs)(`div`,{className:`px-3 pb-3 space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`border-b border-border pb-2`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>m(e=>!e),className:`flex w-full items-center gap-1.5 rounded px-1 py-1 text-[10px] font-semibold text-primary hover:bg-primary/5`,"aria-expanded":p,children:[(0,Z.jsx)(_n,{className:`h-3.5 w-3.5`}),j(`activity:mailbox.compose`),(0,Z.jsx)(`span`,{className:`ml-auto text-muted-foreground`,children:p?`−`:`+`})]}),p&&(0,Z.jsxs)(`div`,{className:`mt-2 space-y-2 rounded-md border border-border bg-background/60 p-2`,children:[(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,Z.jsxs)(`label`,{className:`space-y-1 text-[10px] text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:j(`activity:mailbox.recipient`)}),(0,Z.jsx)(`input`,{className:`h-7 w-full rounded border border-border bg-background px-2 text-xs text-foreground disabled:opacity-50`,value:_===`broadcast`?`*`:h,list:`mailbox-agent-recipients`,disabled:_===`broadcast`,placeholder:`leader`,onChange:e=>g(e.target.value)}),(0,Z.jsxs)(`datalist`,{id:`mailbox-agent-recipients`,children:[(0,Z.jsx)(`option`,{value:`leader`}),(0,Z.jsx)(`option`,{value:`*`}),R.map(e=>(0,Z.jsx)(`option`,{value:e.agentId},e.agentId))]})]}),(0,Z.jsxs)(`label`,{className:`space-y-1 text-[10px] text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:j(`activity:mailbox.messageType`)}),(0,Z.jsx)(`select`,{className:`h-7 w-full rounded border border-border bg-background px-2 text-xs text-foreground`,value:_,onChange:e=>v(e.target.value),children:Gl.map(e=>(0,Z.jsx)(`option`,{value:e,children:j(`activity:mailbox.type.${e}`)},e))})]}),(0,Z.jsxs)(`label`,{className:`space-y-1 text-[10px] text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:j(`activity:mailbox.audience`)}),(0,Z.jsxs)(`select`,{className:`h-7 w-full rounded border border-border bg-background px-2 text-xs text-foreground`,value:y,onChange:e=>b(e.target.value),children:[(0,Z.jsx)(`option`,{value:`all`,children:j(`activity:mailbox.audienceAll`)}),(0,Z.jsx)(`option`,{value:`leaders`,children:j(`activity:mailbox.audienceLeaders`)})]})]}),(0,Z.jsxs)(`label`,{className:`space-y-1 text-[10px] text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:j(`activity:mailbox.priority`)}),(0,Z.jsxs)(`select`,{className:`h-7 w-full rounded border border-border bg-background px-2 text-xs text-foreground`,value:x,onChange:e=>S(e.target.value),children:[(0,Z.jsx)(`option`,{value:`low`,children:j(`activity:mailbox.priorityLow`)}),(0,Z.jsx)(`option`,{value:`normal`,children:j(`activity:mailbox.priorityNormal`)}),(0,Z.jsx)(`option`,{value:`high`,children:j(`activity:mailbox.priorityHigh`)})]})]})]}),(0,Z.jsx)(`input`,{className:`h-7 w-full rounded border border-border bg-background px-2 text-xs text-foreground`,value:C,placeholder:j(`activity:mailbox.subjectPlaceholder`),onChange:e=>w(e.target.value)}),(0,Z.jsx)(`textarea`,{className:`min-h-16 w-full resize-y rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,value:T,placeholder:j(`activity:mailbox.bodyPlaceholder`),onChange:e=>E(e.target.value)}),y===`leaders`&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] text-primary`,children:[(0,Z.jsx)(bn,{className:`h-3 w-3`}),j(`activity:mailbox.leadersOnlyHint`)]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex h-7 items-center gap-1 rounded bg-primary px-2 text-[10px] font-semibold text-primary-foreground disabled:opacity-40`,disabled:!M||T.trim().length===0||_!==`broadcast`&&h.trim().length===0||D.phase===`sending`,onClick:oe,children:[(0,Z.jsx)(ze,{className:`h-3 w-3`}),D.phase===`sending`?j(`activity:mailbox.sending`):j(`activity:mailbox.send`)]}),D.phase===`sent`&&(0,Z.jsxs)(`span`,{className:`text-[10px] text-success`,children:[j(`activity:mailbox.sent`),D.messageId?` · ${D.messageId.slice(0,8)}`:``]}),D.phase===`error`&&(0,Z.jsx)(`span`,{className:`truncate text-[10px] text-destructive`,title:D.message,children:D.message})]})]})]}),L.length>0?(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`span`,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wide`,children:j(`activity:mailbox.messages`)}),(0,Z.jsxs)(`button`,{type:`button`,onClick:re,disabled:s,className:`flex items-center gap-1 text-[10px] text-muted-foreground hover:text-destructive disabled:opacity-40 transition-colors`,title:j(`activity:mailbox.deleteAllTitle`),children:[(0,Z.jsx)(vr,{className:`h-3 w-3`}),j(s?`activity:mailbox.deleting`:`activity:mailbox.deleteAll`)]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:ie,disabled:l,className:`flex items-center gap-1 text-[10px] text-muted-foreground hover:text-primary disabled:opacity-40 transition-colors`,title:j(`activity:mailbox.purgeTitle`),children:[(0,Z.jsx)(et,{className:`h-3 w-3`}),j(l?`activity:mailbox.purging`:`activity:mailbox.purge`)]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:ae,disabled:d,className:`flex items-center gap-1 text-[10px] text-muted-foreground hover:text-primary disabled:opacity-40 transition-colors`,title:j(`activity:mailbox.compactTitle`),children:[(0,Z.jsx)(at,{className:`h-3 w-3`}),j(d?`activity:mailbox.compacting`:`activity:mailbox.compact`)]})]}),i&&i.totalRemoved>0&&(0,Z.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,Z.jsx)(at,{className:`h-3 w-3 shrink-0`}),(0,Z.jsxs)(`span`,{children:[j(`activity:mailbox.compactRemoved`,{count:i.totalRemoved}),i.expiredRemoved>0&&` (${j(`activity:mailbox.compactExpired`,{count:i.expiredRemoved})})`,i.readByAllRemoved>0&&` (${j(`activity:mailbox.compactReadByAll`,{count:i.readByAllRemoved})})`,i.stalePurged>0&&` (${j(`activity:mailbox.compactStale`,{count:i.stalePurged})})`,` — `,j(`activity:mailbox.compactRemaining`,{count:i.remaining})]})]}),z.pageItems.map(e=>{let t=Yl[e.type]??Lt,n=e.readByCount>0,r=P?.id===e.id,i=e.scope?{scope:e.scope,recipientSessionId:e.recipientSessionId}:Ia(e.to);return(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>I(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,Z.jsx)(t,{className:G(`h-3.5 w-3.5 mt-0.5 shrink-0`,n?`text-muted-foreground`:`text-warning`)}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:G(`font-medium truncate`,!n&&`text-warning`),children:e.from}),e.completed&&(0,Z.jsx)($t,{className:`h-3 w-3 text-success shrink-0`}),e.audience===`leaders`&&(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 rounded bg-primary/10 px-1 text-[9px] font-semibold text-primary`,children:[(0,Z.jsx)(bn,{className:`h-2.5 w-2.5`}),j(`activity:mailbox.leadersLabel`)]}),!n&&(0,Z.jsx)(`span`,{className:`text-[9px] text-warning font-bold`,children:j(`activity:mailbox.newLabel`)}),i.scope===`session`&&(0,Z.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:j(`activity:mailbox.sessionScopeTitle`,{sid:i.recipientSessionId??``}),children:[(0,Z.jsx)(bn,{className:`h-2.5 w-2.5`}),j(`activity:mailbox.sessionLabel`)]}),i.scope===`project`&&(0,Z.jsx)(`span`,{className:`inline-flex items-center px-1 py-0 rounded text-[9px] font-semibold bg-primary/12 text-primary`,children:j(`activity:mailbox.projectLabel`)})]}),(0,Z.jsx)(`div`,{className:`text-muted-foreground truncate`,children:e.subject}),(0,Z.jsxs)(`div`,{className:`text-[10px] text-muted-foreground/70 truncate`,children:[e.body.slice(0,60),e.body.length>60?`…`:``]})]}),(0,Z.jsxs)(`div`,{className:`shrink-0 text-[10px] text-muted-foreground flex flex-col items-end gap-0.5`,children:[(0,Z.jsx)(`span`,{children:Xl(e.timestamp)}),n&&(0,Z.jsxs)(`span`,{className:`flex items-center gap-0.5`,children:[(0,Z.jsx)(Gn,{className:`h-3 w-3`}),e.readByCount]})]})]},e.id)}),(0,Z.jsx)(Tc,{page:z.page,pageSize:z.pageSize,totalItems:z.totalItems,onPageChange:z.setPage,compact:!0,itemLabel:`messages`})]}):(0,Z.jsxs)(`div`,{className:`text-xs text-muted-foreground py-2 text-center`,children:[(0,Z.jsx)(dt,{className:`h-4 w-4 mx-auto mb-1 opacity-40`}),j(`activity:mailbox.empty`)]}),R.length>0&&(0,Z.jsxs)(`div`,{className:`border-t border-border pt-2`,children:[(0,Z.jsxs)(`div`,{className:`text-[10px] font-semibold text-muted-foreground mb-1 flex items-center gap-1`,children:[(0,Z.jsx)(fr,{className:`h-3 w-3`}),` `,j(`activity:nav.agents`)]}),ne.pageItems.map(e=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] text-muted-foreground py-0.5`,children:[(0,Z.jsx)(`span`,{className:G(`h-1.5 w-1.5 rounded-full`,e.online?`bg-success`:`bg-muted-foreground/30`)}),(0,Z.jsx)(`span`,{className:`font-medium text-foreground/80`,children:e.name}),e.role&&(0,Z.jsxs)(`span`,{className:`opacity-60`,children:[`(`,e.role,`)`]}),(0,Z.jsx)(`span`,{className:`opacity-50`,children:e.status}),e.currentTool&&(0,Z.jsx)(`span`,{className:`text-primary`,children:e.currentTool}),(0,Z.jsx)(`span`,{className:`ml-auto opacity-50`,children:Xl(e.lastSeenAt)})]},e.agentId)),(0,Z.jsx)(Tc,{page:ne.page,pageSize:ne.pageSize,totalItems:ne.totalItems,onPageChange:ne.setPage,compact:!0,itemLabel:`online agents`}),R.filter(e=>!e.online).length>0&&(0,Z.jsx)(`div`,{className:`text-[10px] text-muted-foreground/70 mt-0.5`,children:j(`activity:mailbox.offlineCount`,{count:R.filter(e=>!e.online).length})})]})]})]})}function $l({agent:e,isExpanded:t,onOpenInspector:r}){let{t:i}=H(),[a,o]=(0,X.useState)(!1),s=(0,X.useRef)(null),c=(0,X.useRef)(null),[l,u]=(0,X.useState)(0);(0,X.useEffect)(()=>{c.current&&u(t?c.current.scrollHeight:0)},[t,e]),(0,X.useEffect)(()=>{t&&s.current&&e.status===`running`&&(s.current.scrollTop=s.current.scrollHeight)},[t,e.partialText,e.status]);let d=e.toolLog??[],f=a?d:d.slice(0,10),p=[{label:i(`activity:agents.configProvider`),value:e.provider},{label:i(`activity:agents.configModel`),value:e.model},{label:i(`activity:agents.configDescription`),value:e.description},{label:i(`activity:agents.configTaskId`),value:e.taskId}].filter(e=>e.value!=null&&e.value!==``),m=e.partialText&&e.partialText.length>0&&e.status===`running`,h=_(t=>t.agentTranscripts.get(e.id)??oe),[g,v]=(0,X.useState)(!1),y=g?h:h.slice(-20);return(0,Z.jsx)(`div`,{className:`overflow-hidden transition-all duration-[250ms] ease-out`,style:{maxHeight:t?l:0,opacity:+!!t},children:(0,Z.jsxs)(`div`,{ref:c,className:`space-y-2 px-3 pb-3 pt-0.5`,children:[d.length>0&&(0,Z.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,Z.jsxs)(`span`,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wider`,children:[i(`activity:agents.toolLog`),` (`,d.length,`)`]}),(0,Z.jsxs)(`div`,{className:`space-y-0.5`,children:[f.map(e=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] font-mono min-w-0`,children:[e.ok?(0,Z.jsx)(ui,{className:`h-2.5 w-2.5 shrink-0 text-success`}):(0,Z.jsx)(St,{className:`h-2.5 w-2.5 shrink-0 text-destructive`}),(0,Z.jsx)(`span`,{className:G(`truncate`,e.ok?``:`text-destructive`),children:e.name}),(0,Z.jsx)(`span`,{className:`tabular-nums text-muted-foreground ml-auto shrink-0`,children:w(e.durationMs)})]},e.at)),d.length>10&&(0,Z.jsx)(`button`,{type:`button`,onClick:()=>o(!a),"aria-label":i(a?`activity:agents.showFewer`:`activity:agents.showAll`),className:`flex items-center gap-0.5 text-[10px] text-primary hover:text-primary/80 transition-colors`,children:a?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(dn,{className:`h-2.5 w-2.5`}),` `,i(`activity:agents.showFewer`)]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Ct,{className:`h-2.5 w-2.5`}),` `,i(`activity:agents.showAll`),` (`,d.length,`)`]})})]})]}),m&&(0,Z.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,Z.jsx)(`span`,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wider`,children:i(`activity:agents.streaming`)}),(0,Z.jsx)(`div`,{ref:s,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,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Z.jsx)(`span`,{className:G(`text-[10px] font-semibold uppercase tracking-wider`,e.status===`failed`?`text-destructive`:`text-warning`),children:e.status===`failed`?i(`activity:agents.failure`):i(`activity:agents.timeout`)}),(0,Z.jsx)(`span`,{className:`flex-1`}),(0,Z.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:i(`activity:agents.reRunTitle`),children:[(0,Z.jsx)(Tn,{className:`h-2.5 w-2.5`}),i(`activity:agents.reRun`)]})]}),(e.failureReason||e.error)&&(0,Z.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,Z.jsx)(`div`,{className:`font-medium`,children:e.failureReason}),e.error&&(0,Z.jsxs)(`div`,{className:G(`mt-0.5`,e.status===`failed`?`text-destructive/80`:`text-warning/80`),children:[e.error.kind&&(0,Z.jsxs)(`span`,{className:`font-mono`,children:[`[`,e.error.kind,`] `]}),e.error.message]})]}),d.length>0&&(0,Z.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:i(`activity:agents.lastToolCalls`,{count:Math.min(3,d.length)})}),(0,Z.jsx)(`div`,{className:`space-y-0.5`,children:d.slice(0,3).map(e=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] font-mono min-w-0`,children:[e.ok?(0,Z.jsx)(ui,{className:`h-2.5 w-2.5 shrink-0 text-success`}):(0,Z.jsx)(St,{className:`h-2.5 w-2.5 shrink-0 text-destructive`}),(0,Z.jsx)(`span`,{className:G(`truncate`,e.ok?``:`text-destructive`),children:e.name}),(0,Z.jsx)(`span`,{className:`tabular-nums text-muted-foreground ml-auto shrink-0`,children:w(e.durationMs)})]},e.at))})]})]}),p.length>0&&(0,Z.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,Z.jsx)(`span`,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wider`,children:i(`activity:agents.config`)}),(0,Z.jsx)(`div`,{className:`rounded bg-muted/30 p-1.5 space-y-0.5`,children:p.map(e=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] min-w-0`,children:[(0,Z.jsxs)(`span`,{className:`text-muted-foreground shrink-0`,children:[e.label,`:`]}),(0,Z.jsx)(`span`,{className:`font-mono truncate text-foreground/90`,children:e.value})]},e.label))})]}),h.length>0&&(0,Z.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Z.jsxs)(`span`,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wider`,children:[i(`activity:agents.transcript`),` (`,h.length,`)`]}),h.length>20&&(0,Z.jsx)(`button`,{type:`button`,onClick:()=>v(!g),className:`ml-auto flex items-center gap-0.5 text-[10px] text-primary hover:text-primary/80 transition-colors`,children:g?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(dn,{className:`h-2.5 w-2.5`}),` `,i(`activity:agents.showFewer`)]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Ct,{className:`h-2.5 w-2.5`}),` `,i(`activity:agents.showAll`)]})})]}),(0,Z.jsx)(vc,{entries:y,agentName:e.name,compact:!0,maxHeightClassName:`max-h-32`,showHeader:!1})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[r&&(0,Z.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),r()},className:`flex items-center gap-1 text-[10px] text-primary hover:text-primary/80 transition-colors`,children:[(0,Z.jsx)(ur,{className:`h-2.5 w-2.5`}),i(`activity:agents.openInspector`)]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:t=>{if(t.stopPropagation(),n(_.getState(),e.sessionId)===e.id)return;let r=K.getState();r.setSubagentChatFocus(e.id,e.sessionId),r.setCurrentView(`chat`)},className:`flex items-center gap-1 text-[10px] text-primary hover:text-primary/80 transition-colors`,children:[(0,Z.jsx)(Lt,{className:`h-2.5 w-2.5`}),i(`activity:agents.openChat`)]})]})]})})}var eu={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 tu({agent:e,isLeader:t,isExpanded:n,isFocused:r,onToggle:i,onOpenInspector:a,now:o}){let{t:s}=H(),[c,l]=(0,X.useState)(Date.now()),u=(0,X.useRef)(null);(0,X.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,X.useMemo)(()=>p(e,d),[e,d]),m=eu[e.status],h=e.status===`running`,g=e.currentTool||e.lastTool;return(0,Z.jsxs)(`div`,{className:G(`animate-message`,n&&`rounded-lg ring-1 ring-primary/20`),children:[(0,Z.jsxs)(`button`,{type:`button`,id:`agent-card-${e.id}`,"data-agent-card":!0,role:`option`,"aria-selected":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`,h&&`border-primary/40 bg-primary/[0.03]`,!h&&e.status===`completed`&&`border-success/30 bg-success/[0.02]`,!h&&e.status===`failed`&&`border-destructive/30 bg-destructive/[0.02]`,!h&&e.status===`timeout`&&`border-warning/30 bg-warning/[0.02]`,!h&&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,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,Z.jsx)(`span`,{className:G(`led shrink-0`,m.led,m.pulse&&`led-pulse`),"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`truncate text-[11px] font-semibold`,title:e.name,children:e.name}),t&&(0,Z.jsx)(Wr,{className:`h-3 w-3 shrink-0 text-warning`,"aria-label":s(`activity:fleet.leader`)}),(0,Z.jsx)(`span`,{className:`flex-1 min-w-0`}),(0,Z.jsx)(`span`,{className:`tabular-nums font-mono text-[10px] text-muted-foreground shrink-0`,children:f.cost}),(0,Z.jsx)(Ct,{className:G(`h-3 w-3 shrink-0 text-muted-foreground/50 transition-transform duration-200`,n&&`rotate-180`)})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[e.model?(0,Z.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,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground italic`,children:s(`activity:agents.pending`)}),(0,Z.jsxs)(`span`,{className:`tabular-nums text-[10px] text-muted-foreground`,children:[f.iterationCount,s(`activity:agents.itSuffix`),` · `,f.toolCount,s(`activity:agents.tcSuffix`)]}),(0,Z.jsx)(`span`,{className:`ml-auto tabular-nums text-[10px] text-muted-foreground/70 shrink-0`,children:f.elapsed})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,Z.jsx)(Bs,{bins:e.sparklineBins,className:`text-[9px] font-mono min-w-0`}),(0,Z.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,Z.jsx)(mc,{pct:f.ctxClamped,tokens:e.ctxTokens,maxTokens:e.maxContext,showTokens:!0})}),e.budgetWarning&&(0,Z.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,Z.jsx)(at,{className:`h-2.5 w-2.5`}),e.budgetWarning.kind]})]}),g&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground min-w-0`,children:[(0,Z.jsx)(li,{className:G(`h-2.5 w-2.5 shrink-0`,h&&`animate-pulse text-primary`)}),(0,Z.jsx)(`span`,{className:`truncate font-mono`,children:e.currentTool??e.lastTool})]})]}),(0,Z.jsx)($l,{agent:e,isExpanded:!!n,onOpenInspector:a})]})}function nu({className:e,sessionId:t,leaderName:n}){let r=ve(),i=t??r??void 0,a=v(i),o=_(Me(e=>({concurrencyMax:e.fleetConcurrencyMax,maxSpawns:e.fleetMaxSpawns,usedSpawns:e.fleetUsedSpawns,remainingSpawns:e.fleetRemainingSpawns,budgetSource:e.fleetBudgetSource,ceilingMismatch:e.fleetCeilingMismatch||void 0,checkpointMaxSpawns:e.fleetCheckpointMaxSpawns}))),s=_(Me(e=>e.eventTimeline.filter(t=>(t.agentId?e.agents.get(t.agentId):void 0)?.sessionId===i).slice(0,3))),{t:c}=H(),l={...a,concurrency:a.running,...o},u=l.total>0,d=(0,X.useCallback)(()=>{Ba(`roster`)},[]);return(0,Z.jsxs)(`div`,{"data-testid":`fleet-summary-bar`,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,Z.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0 flex-wrap`,children:[(0,Z.jsx)(ru,{label:String(l.running),ledClass:`bg-success`,pulse:l.running>0}),(0,Z.jsx)(`span`,{className:`tabular-nums text-success count-transition`,children:c(`activity:agents.runningCount`,{count:l.running})}),l.completed>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,Z.jsxs)(`span`,{className:`tabular-nums text-muted-foreground count-transition`,children:[l.completed,` done`]})]}),l.failed>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,Z.jsx)(ru,{label:String(l.failed),ledClass:`bg-destructive`,pulse:!1})]}),(0,Z.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,Z.jsx)(`span`,{className:`tabular-nums text-muted-foreground count-transition`,children:c(`activity:agents.totalCount`,{count:l.total})}),(0,Z.jsx)(`span`,{className:`flex-1 min-w-0`}),l.totalCost>0&&(0,Z.jsx)(`span`,{className:`tabular-nums font-mono text-muted-foreground ml-auto shrink-0 count-transition`,children:ec(l.totalCost)}),n&&(0,Z.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,Z.jsx)(Wr,{className:`h-2.5 w-2.5`}),n]})]}),(u||l.maxSpawns!==void 0)&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0 flex-wrap`,children:[(0,Z.jsx)(Vs,{current:l.concurrency,max:l.concurrencyMax,showLabel:!0}),l.maxSpawns!==void 0&&l.usedSpawns!==void 0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,Z.jsxs)(`span`,{className:G(`tabular-nums font-mono count-transition`,l.ceilingMismatch?`text-warning`:`text-muted-foreground`),title:l.ceilingMismatch&&l.checkpointMaxSpawns!==void 0?`Checkpoint maxSpawns was ${l.checkpointMaxSpawns}; live ceiling is ${l.maxSpawns}${l.budgetSource?` (${l.budgetSource})`:``}`:l.budgetSource?`Lifetime spawns · ${l.budgetSource}`:`Lifetime spawn budget`,children:[`spawns `,l.usedSpawns,`/`,Number.isFinite(l.maxSpawns)?l.maxSpawns:`∞`,l.remainingSpawns===void 0?``:` (${Number.isFinite(l.remainingSpawns)?l.remainingSpawns:`∞`} left)`]})]}),l.tokensIn+l.tokensOut>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,Z.jsxs)(`span`,{className:`tabular-nums font-mono text-muted-foreground count-transition`,children:[`↓`,Ce(l.tokensIn),` `,`↑`,Ce(l.tokensOut)]})]})]}),s.length>0&&(0,Z.jsx)(`div`,{className:`flex items-center gap-1 min-w-0 overflow-x-auto no-scrollbar`,children:s.map(e=>(0,Z.jsxs)(`button`,{type:`button`,onClick:d,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":`${iu[e.kind]??e.kind}: ${e.message}`,children:[(0,Z.jsx)(ou,{kind:e.kind}),iu[e.kind]??e.kind]},e.id))}),!u&&(0,Z.jsx)(`div`,{className:`flex items-center gap-2 min-w-0`,children:(0,Z.jsx)(`span`,{className:`text-muted-foreground italic`,children:c(`activity:fleetSummaryBar.fleetIdle`)})})]})}function ru({label:e,ledClass:t,pulse:n}){return(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 shrink-0`,children:[(0,Z.jsx)(`span`,{className:G(`led h-1.5 w-1.5`,t,n&&`led-pulse`),"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`tabular-nums font-medium`,children:e})]})}var iu={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`},au={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 ou({kind:e}){return(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:G(`inline-block h-1.5 w-1.5 rounded-full shrink-0`,au[e]??`bg-muted-foreground`)})}var su=`__no_session__`,cu=new Map,lu=new Set;se(e=>{cu.delete(e),lu.add(e)});var uu=[{value:`all`,translationKey:`activity:agents.filterAll`},{value:`running`,translationKey:`activity:agents.filterRunning`},{value:`completed`,translationKey:`activity:agents.filterCompleted`},{value:`failed`,translationKey:`activity:agents.filterFailed`}];function du(){let e=_(Me(ae)),t=_(e=>e.clearFinishedAgents),n=ve(),r=S(n??void 0),i=_(e=>r?e.agents.get(r)?.name:void 0),{t:a}=H(),[o,s]=(0,X.useState)(`all`),[c,l]=(0,X.useState)(null),[u,d]=(0,X.useState)(-1),f=(0,X.useRef)(null),[p,m]=(0,X.useState)(!0),h=n??su,g=(0,X.useRef)(h);(0,X.useLayoutEffect)(()=>{if(g.current===h)return;lu.has(g.current)||cu.set(g.current,{filter:o,expandedAgentId:c,focusedIndex:u,showHint:p});let e=cu.get(h)??{filter:`all`,expandedAgentId:null,focusedIndex:-1,showHint:!0};lu.delete(h),g.current=h,s(e.filter),l(e.expandedAgentId),d(e.focusedIndex),m(e.showHint)},[h,c,o,u,p]);let v=(0,X.useMemo)(()=>e.filter(e=>A(e.sessionId,n)),[e,n]),y=(0,X.useMemo)(()=>o===`all`?v:v.filter(e=>o===`running`?e.status===`running`:o===`completed`?e.status===`completed`:o!==`failed`||e.status===`failed`||e.status===`timeout`),[v,o]),b=v.some(e=>e.status!==`running`),x=(0,X.useCallback)(e=>{e?(K.getState().setSubagentChatFocus(e,n??void 0),J(`chat`)):Ba(`roster`)},[n]),C=(0,X.useCallback)(e=>{l(t=>t===e?null:e)},[]),w=(0,X.useCallback)(e=>{let t=y;if(t.length!==0)switch(e.key){case`ArrowDown`:e.preventDefault(),d(e=>{let n=Math.min(e+1,t.length-1);return m(!1),n});break;case`ArrowUp`:e.preventDefault(),d(e=>{let t=Math.max(e-1,0);return m(!1),t});break;case`Enter`:case` `:e.preventDefault(),u>=0&&u<t.length&&C(t[u].id);break;case`Escape`:e.preventDefault(),c&&l(null)}},[y,u,C,c]);(0,X.useEffect)(()=>{u>=0&&f.current&&f.current.querySelectorAll(`[data-agent-card]`)[u]?.focus()},[u]),(0,X.useEffect)(()=>{u>=y.length&&d(-1)},[y.length,u]);let T=v.length>0&&v.every(e=>e.status!==`running`),E=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 border-b border-border/70 px-2 py-1`,children:[uu.map(e=>(0,Z.jsx)(`button`,{type:`button`,onClick:()=>s(e.value),"aria-pressed":o===e.value,className:G(`rounded px-1.5 py-0.5 text-[10px] font-medium transition-colors`,o===e.value?`bg-primary/10 text-primary`:`text-muted-foreground hover:bg-muted/50 hover:text-foreground`),children:a(e.translationKey)},e.value)),(0,Z.jsx)(`span`,{className:`flex-1`}),b&&(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>t(n),"aria-label":a(`activity:agents.clearFinishedTitle`),title:a(`activity:agents.clearFinishedTitle`),className:`inline-flex items-center gap-0.5 rounded px-1.5 py-0.5 text-[10px] text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive`,children:[(0,Z.jsx)(vr,{className:`h-2.5 w-2.5`}),a(`activity:agents.clearFinished`)]})]});return v.length===0?(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center bg-[hsl(var(--surface-2)/0.35)] p-3`,children:(0,Z.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,Z.jsx)(`span`,{className:`flex h-11 w-11 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,Z.jsx)(jr,{className:`h-5 w-5`})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`text-sm font-semibold text-foreground`,children:a(`activity:agents.empty`)}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs`,children:a(`activity:agents.emptyHint`)})]})]})}):y.length===0&&o!==`all`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(nu,{sessionId:n??void 0,leaderName:i}),E,(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center bg-[hsl(var(--surface-2)/0.35)] p-3`,children:(0,Z.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,Z.jsx)(`span`,{className:`flex h-11 w-11 items-center justify-center rounded-lg bg-muted/60 text-muted-foreground`,children:(0,Z.jsx)(Nn,{className:`h-5 w-5`})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`text-sm font-semibold text-foreground`,children:a(`activity:agents.emptyFilteredTitle`)}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs`,children:a(`activity:agents.emptyFilteredHint`)})]}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>s(`all`),className:`h-7 rounded-md border border-border px-3 text-[11px] font-medium text-foreground hover:bg-accent transition-colors`,children:a(`activity:agents.emptyFilteredClear`)})]})})]}):T&&o===`all`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(nu,{sessionId:n??void 0,leaderName:i}),(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center bg-[hsl(var(--surface-2)/0.35)] p-3`,children:(0,Z.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,Z.jsx)(`span`,{className:`flex h-11 w-11 items-center justify-center rounded-lg bg-success/10 text-success`,children:(0,Z.jsx)($t,{className:`h-5 w-5`})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`text-sm font-semibold text-foreground`,children:a(`activity:agents.emptyFinishedTitle`)}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs`,children:a(`activity:agents.emptyFinishedHint`)}),(0,Z.jsx)(`p`,{className:`mt-2 text-[11px] tabular-nums text-muted-foreground`,children:a(`activity:agents.emptyFinishedStats`,{completed:v.filter(e=>e.status===`completed`).length,failed:v.filter(e=>e.status===`failed`||e.status===`timeout`).length})})]})]})}),(0,Z.jsx)(`div`,{className:`shrink-0 border-t border-border/70 bg-card/75 px-3 py-2`,children:(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>t(n),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,Z.jsx)(vr,{className:`h-3 w-3`}),a(`activity:agents.clearFinished`)]})})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(nu,{sessionId:n??void 0,leaderName:i}),E,(0,Z.jsxs)(`div`,{ref:f,role:`listbox`,"aria-label":a(`activity:agentsPanel.agentRoster`),"aria-activedescendant":u>=0?`agent-card-${y[u]?.id}`:void 0,tabIndex:0,onKeyDown:w,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:[p&&u===-1&&(0,Z.jsx)(`div`,{className:`text-[9px] text-muted-foreground/60 text-center py-1 italic select-none`,children:a(`activity:agents.rosterHint`)}),y.map(e=>(0,Z.jsx)(tu,{agent:e,isLeader:e.id===r,isExpanded:c===e.id,isFocused:u>=0&&y[u]?.id===e.id,onToggle:()=>C(e.id),onOpenInspector:()=>x(e.id)},e.id))]}),(0,Z.jsx)(`div`,{className:`shrink-0 border-t border-border/70 bg-card/75 px-3 py-2`,children:(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>x(),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,Z.jsx)(pi,{className:`h-3 w-3`}),a(`activity:agents.openFull`)]})})]})}var fu=new Set([`allocating`,`active`,`committing`,`merging`]),pu={active:`text-warning`,committing:`text-primary`,merging:`text-info`,merged:`text-success`,"needs-review":`text-destructive`,failed:`text-destructive`,orphan:`text-muted-foreground`};function mu(){let{client:e}=ha(),{t}=H(),n=e=>e?e.replace(/^wstack\/ap\//,``):t(`activity:worktrees.detached`),r=Aa(e=>e.worktrees),i=Aa(e=>e.orphans),a=Aa(e=>e.baseBranch),o=Aa(e=>e.canClean),s=Aa(e=>e.cleanResult),c=Aa(e=>e.mergeResult),l=Aa(e=>e.diffByDir),[u,d]=(0,X.useState)(null),[f,p]=(0,X.useState)(null),m=(0,X.useMemo)(()=>e?e.send.bind(e):void 0,[e]);(0,X.useEffect)(()=>{m?.({type:`worktree.scan`})},[m]),(0,X.useEffect)(()=>{d(null)},[c,s]);let h=(0,X.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:fu.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]),g=(e,t)=>{e&&m?.({type:`shell.open`,payload:{path:e,target:t}})},_=e=>{e&&(m?.({type:`worktree.diff`,payload:{dir:e}}),p(t=>t===e?null:e))},v=async e=>{e&&await $a({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}}))},y=async e=>{await $a({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,Z.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2`,children:[(0,Z.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[t(`activity:worktrees.count`,{count:h.length}),a?t(`activity:worktrees.baseSuffix`,{base:a}):``]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[i.length>0&&(0,Z.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,Z.jsx)(Xr,{className:`h-3 w-3`}),` `,t(`activity:worktrees.cleanOrphans`)]}),(0,Z.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,Z.jsx)(xi,{className:`h-3.5 w-3.5`})})]})]}),s&&(0,Z.jsx)(gu,{ok:s.ok,children:s.ok?t(`activity:worktrees.removed`,{count:s.removed}):s.reason??t(`activity:worktrees.failed`)}),c&&(0,Z.jsx)(gu,{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,Z.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,Z.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 text-center text-xs text-muted-foreground`,children:[(0,Z.jsx)(Vi,{className:`h-8 w-8 opacity-30`}),(0,Z.jsx)(`p`,{children:t(`activity:worktrees.empty`)}),(0,Z.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,Z.jsxs)(`div`,{className:`mb-1.5 rounded-md border border-border bg-card/60 px-2.5 py-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Vi,{className:G(`h-3.5 w-3.5 shrink-0`,pu[e.status]??`text-muted-foreground`)}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-foreground`,title:e.branch,children:n(e.branch)}),(0,Z.jsx)(`span`,{className:G(`shrink-0 text-[10px] uppercase`,pu[e.status]??`text-muted-foreground`),children:e.status})]}),(0,Z.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-2 pl-5 text-[10px] text-muted-foreground`,children:[e.owner&&(0,Z.jsx)(`span`,{className:`truncate`,children:e.owner}),(e.insertions>0||e.deletions>0)&&(0,Z.jsxs)(`span`,{className:`shrink-0`,children:[(0,Z.jsxs)(`span`,{className:`text-success`,children:[`+`,e.insertions]}),` `,(0,Z.jsxs)(`span`,{className:`text-destructive`,children:[`−`,e.deletions]}),` · `,e.files,`f`]})]}),(0,Z.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-0.5 pl-5`,children:[(0,Z.jsx)(hu,{title:t(`activity:worktrees.actOpenTerm`),disabled:!e.dir,onClick:()=>g(e.dir,`terminal`),children:(0,Z.jsx)(kr,{className:`h-3.5 w-3.5`})}),(0,Z.jsx)(hu,{title:t(`activity:worktrees.actOpenFolder`),disabled:!e.dir,onClick:()=>g(e.dir,`file-manager`),children:(0,Z.jsx)(Rt,{className:`h-3.5 w-3.5`})}),(0,Z.jsx)(hu,{title:t(`activity:worktrees.actViewChanges`),disabled:!e.dir,onClick:()=>_(e.dir),children:(0,Z.jsx)(Xt,{className:`h-3.5 w-3.5`})}),(0,Z.jsx)(hu,{title:t(`activity:worktrees.actMerge`),disabled:e.live||!e.branch,onClick:()=>v(e.branch),children:i?(0,Z.jsx)(wt,{className:`h-3.5 w-3.5 animate-spin`}):(0,Z.jsx)(ji,{className:`h-3.5 w-3.5`})}),(0,Z.jsx)(hu,{title:t(`activity:worktrees.actRemove`),danger:!0,disabled:e.live,onClick:()=>y(e),children:(0,Z.jsx)(vr,{className:`h-3.5 w-3.5`})}),e.live&&(0,Z.jsx)(`span`,{className:`ml-1 text-[10px] text-warning`,children:t(`activity:worktrees.live`)})]}),f===e.dir&&a!==void 0&&(0,Z.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,Z.jsxs)(`span`,{className:`text-muted-foreground`,children:[t(`activity:worktrees.noUncommitted`),a&&a.commits>0?` · ${t(`activity:worktrees.commitsAhead`,{count:a.commits})}`:``,`.`]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`mb-1 text-muted-foreground`,children:[a.commits>0?`${t(`activity:worktrees.commitsAhead`,{count:a.commits})} · `:``,(0,Z.jsxs)(`span`,{className:`text-success`,children:[`+`,a.insertions]}),` `,(0,Z.jsxs)(`span`,{className:`text-destructive`,children:[`−`,a.deletions]})]}),a.files.slice(0,12).map(e=>(0,Z.jsxs)(`div`,{className:`truncate font-mono`,children:[(0,Z.jsxs)(`span`,{className:`text-success`,children:[`+`,e.insertions]}),` `,(0,Z.jsxs)(`span`,{className:`text-destructive`,children:[`−`,e.deletions]}),` `,e.path]},e.path)),a.files.length>12&&(0,Z.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:worktrees.more`,{count:a.files.length-12})})]})})]},`${e.branch??e.dir??r}`)})})]})}function hu({title:e,onClick:t,disabled:n,danger:r,children:i}){return(0,Z.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 gu({ok:e,children:t}){return(0,Z.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,Z.jsx)($t,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}):(0,Z.jsx)(Kr,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1`,children:t}),!e&&(0,Z.jsx)(Rr,{className:`mt-0.5 h-3 w-3 shrink-0 opacity-40`})]})}var _u={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 vu(e){let t=e.lastIndexOf(`/`);return t<0?{name:e,dir:``}:{name:e.slice(t+1),dir:e.slice(0,t+1)}}function yu({file:e,active:t,onSelect:n,onStage:r,onUnstage:i,onDiscard:a}){let o=_u[e.status]??_u.M,{name:s,dir:c}=vu(e.path);return(0,Z.jsxs)(`div`,{className:G(`group flex items-center gap-1.5 w-full px-2 py-1 text-left text-xs rounded hover:bg-accent/60 transition-colors`,t&&`bg-accent`),children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:n,title:e.path,className:`flex min-w-0 flex-1 items-center gap-2 text-left`,children:[(0,Z.jsx)(`span`,{className:G(`w-3 shrink-0 text-center font-mono font-bold`,o?.cls),children:o?.label}),(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-baseline gap-1 overflow-hidden`,children:[(0,Z.jsx)(`span`,{className:G(`min-w-0 truncate`,e.status===`D`&&`line-through opacity-70`),children:s}),c&&(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-muted-foreground/75`,children:c})]}),(0,Z.jsxs)(`span`,{className:`shrink-0 font-mono text-[10px] tabular-nums mr-1`,children:[e.added>0&&(0,Z.jsxs)(`span`,{className:`text-success`,children:[`+`,e.added]}),e.deleted>0&&(0,Z.jsxs)(`span`,{className:`text-destructive ml-1`,children:[`-`,e.deleted]})]})]}),(0,Z.jsx)(`div`,{className:`shrink-0 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity`,children:e.staged?i&&(0,Z.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),i()},title:`Unstage changes`,className:`h-5 w-5 inline-flex items-center justify-center rounded hover:bg-background/80 text-muted-foreground hover:text-foreground`,children:(0,Z.jsx)(zr,{className:`h-3 w-3`})}):(0,Z.jsxs)(Z.Fragment,{children:[r&&(0,Z.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),r()},title:`Stage changes`,className:`h-5 w-5 inline-flex items-center justify-center rounded hover:bg-background/80 text-muted-foreground hover:text-foreground`,children:(0,Z.jsx)(_i,{className:`h-3 w-3`})}),a&&(0,Z.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),window.confirm(`Discard changes in ${e.path}? This cannot be undone.`)&&a()},title:`Discard changes`,className:`h-5 w-5 inline-flex items-center justify-center rounded hover:bg-destructive/10 text-muted-foreground hover:text-destructive`,children:(0,Z.jsx)(yi,{className:`h-3 w-3`})})]})})]})}function bu(){let{client:e,stageGit:t,unstageGit:n,discardGit:r,commitGit:i}=ha(),{t:a}=H(),o=R(e=>e.wsConnected),s=C(e=>e.files),c=C(e=>e.error),l=C(e=>e.loadingList),u=C(e=>e.selectedPath),d=K(e=>e.changesPanelTab),f=K(e=>e.setChangesPanelTab),[p,m]=(0,X.useState)(``),[h,g]=(0,X.useState)(!1),_=(0,X.useCallback)(()=>{o&&(C.getState().setListLoading(!0),e?.getGitChanges?.())},[e,o]);(0,X.useEffect)(()=>{_()},[_]);let v=t=>{C.getState().select(t),e?.getGitDiff?.(t),J(`changes`)},y=async()=>{let e=p.trim();if(!(!e||h)){g(!0);try{i?.(e),m(``)}finally{g(!1)}}},b=s.filter(e=>e.staged),x=s.filter(e=>!e.staged),S=s.reduce((e,t)=>e+t.added,0),w=s.reduce((e,t)=>e+t.deleted,0);return(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col overflow-hidden`,children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 border-b border-border/60 px-2 py-1.5`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>f(`changes`),className:G(`h-6 rounded px-2 text-[11px] font-medium transition-colors`,d===`changes`?`bg-primary/10 text-primary`:`text-muted-foreground hover:bg-accent hover:text-foreground`),children:a(`activity:nav.changes`,`Changes`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>f(`worktrees`),className:G(`h-6 rounded px-2 text-[11px] font-medium transition-colors`,d===`worktrees`?`bg-primary/10 text-primary`:`text-muted-foreground hover:bg-accent hover:text-foreground`),children:a(`activity:nav.worktrees`,`Worktrees`)})]}),d===`worktrees`?(0,Z.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-hidden`,children:(0,Z.jsx)(mu,{})}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b shrink-0 bg-background/50`,children:[(0,Z.jsxs)(`span`,{className:`text-[11px] text-muted-foreground font-mono`,children:[a(`activity:changes.fileCount`,{count:s.length}),s.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[` · `,(0,Z.jsxs)(`span`,{className:`text-success`,children:[`+`,S]}),` `,(0,Z.jsxs)(`span`,{className:`text-destructive`,children:[`-`,w]})]})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[x.length>0&&(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>t?.([]),title:`Stage all changes`,className:`h-6 px-1.5 inline-flex items-center gap-1 rounded text-[11px] text-muted-foreground hover:text-foreground hover:bg-accent`,children:[(0,Z.jsx)(_i,{className:`h-3 w-3`}),(0,Z.jsx)(`span`,{children:`Stage All`})]}),b.length>0&&(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>n?.([]),title:`Unstage all changes`,className:`h-6 px-1.5 inline-flex items-center gap-1 rounded text-[11px] text-muted-foreground hover:text-foreground hover:bg-accent`,children:[(0,Z.jsx)(zr,{className:`h-3 w-3`}),(0,Z.jsx)(`span`,{children:`Unstage All`})]}),(0,Z.jsx)(`button`,{type:`button`,onClick:_,title:a(`activity:changes.refreshTitle`),className:`h-6 w-6 inline-flex items-center justify-center rounded hover:bg-accent text-muted-foreground`,children:l?(0,Z.jsx)(wt,{className:`h-3.5 w-3.5 animate-spin`}):(0,Z.jsx)(xi,{className:`h-3.5 w-3.5`})})]})]}),(0,Z.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain p-1.5 space-y-3`,children:c?(0,Z.jsx)(`div`,{className:`px-2 py-6 text-center text-xs text-muted-foreground`,children:c}):s.length===0?(0,Z.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-2 py-10 text-center text-xs text-muted-foreground`,children:[(0,Z.jsx)(qi,{className:`h-6 w-6 opacity-40`}),a(l?`activity:changes.loading`:`activity:changes.clean`)]}):(0,Z.jsxs)(Z.Fragment,{children:[b.length>0&&(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`flex items-center justify-between px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-primary`,children:(0,Z.jsxs)(`span`,{children:[`Staged Changes (`,b.length,`)`]})}),(0,Z.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:b.map(e=>(0,Z.jsx)(yu,{file:e,active:e.path===u,onSelect:()=>v(e.path),onUnstage:()=>n?.(e.path)},`staged-${e.path}`))})]}),x.length>0&&(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`flex items-center justify-between px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:(0,Z.jsxs)(`span`,{children:[`Changes (`,x.length,`)`]})}),(0,Z.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:x.map(e=>(0,Z.jsx)(yu,{file:e,active:e.path===u,onSelect:()=>v(e.path),onStage:()=>t?.(e.path),onDiscard:()=>r?.(e.path)},`unstaged-${e.path}`))})]})]})}),s.length>0&&(0,Z.jsxs)(`div`,{className:`p-2 border-t border-border/70 bg-card/40 shrink-0 space-y-1.5`,children:[(0,Z.jsx)(`div`,{className:`relative`,children:(0,Z.jsx)(`textarea`,{value:p,onChange:e=>m(e.target.value),onKeyDown:e=>{(e.ctrlKey||e.metaKey)&&e.key===`Enter`&&(e.preventDefault(),y())},placeholder:b.length>0?`Commit message (Ctrl+Enter)...`:`Stage changes to commit...`,rows:2,className:`w-full resize-none rounded-md border border-input bg-background/80 px-2.5 py-1.5 text-xs text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary`})}),(0,Z.jsxs)(`button`,{type:`button`,onClick:y,disabled:b.length===0||!p.trim()||h,className:`w-full h-7 inline-flex items-center justify-center gap-1.5 rounded-md bg-primary text-primary-foreground text-xs font-medium transition-colors hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed shadow-sm`,children:[h?(0,Z.jsx)(wt,{className:`h-3.5 w-3.5 animate-spin`}):(0,Z.jsx)(Yn,{className:`h-3.5 w-3.5`}),(0,Z.jsxs)(`span`,{children:[`Commit `,b.length>0?`(${b.length})`:``]})]})]})]})]})}var xu=[`web`,`react-native`,`flutter`,`swiftui`,`compose`],Su=[`bg`,`surface`,`primary`,`accent`,`fg`,`border`];function Cu({tokens:e,label:t}){let n=Su.filter(t=>e[t]);return n.length===0?null:(0,Z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-[9px] uppercase tracking-wide text-muted-foreground w-7`,children:t}),(0,Z.jsx)(`div`,{className:`flex gap-0.5`,children:n.map(t=>(0,Z.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 wu({className:e}){let{client:t}=ha(),{t:n}=H(),[r,i]=(0,X.useState)([]),[a,o]=(0,X.useState)(null),[s,c]=(0,X.useState)(!0),[l,u]=(0,X.useState)(`web`),[d,f]=(0,X.useState)(null),p=ve();(0,X.useEffect)(()=>{if(!t)return;let e=e=>!e?.sessionId||!p||e.sessionId===p,n=t=>{let n=t.payload;e(n)&&(i(n?.kits??[]),o(n?.activeKit??null),c(!1))},r=t=>{let n=t.payload;e(n)&&(f(null),n?.ok&&n.kit&&o(n.kit))};return t.on(`design.list`,n),t.on(`design.use`,r),c(!0),t.send({type:`design.list`,payload:t.withSession({})}),()=>{t.off(`design.list`,n),t.off(`design.use`,r)}},[t,p]);let m=(0,X.useCallback)(e=>{t&&(f(e),t.send({type:`design.use`,payload:t.withSession({kit:e,stack:l})}))},[t,l]),h=(0,X.useMemo)(()=>[...r].sort((e,t)=>e.name.localeCompare(t.name)),[r]),g=wc(h,10,l);return(0,Z.jsxs)(`div`,{className:G(`flex h-full min-h-0 min-w-0 flex-col`,e),children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 border-b border-border/50`,children:[(0,Z.jsx)(Jn,{className:`w-4 h-4 text-muted-foreground`}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground flex-1`,children:n(`activity:designStudio.pickHint`)}),(0,Z.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,Z.jsx)(pi,{className:`w-3 h-3`}),` `,n(`activity:designStudio.gallery`)]}),(0,Z.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:xu.map(e=>(0,Z.jsx)(`option`,{value:e,children:e},e))})]}),(0,Z.jsxs)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain p-2 space-y-2`,children:[s&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground p-3`,children:[(0,Z.jsx)(wt,{className:`w-4 h-4 animate-spin`}),` `,n(`activity:designStudio.loading`)]}),!s&&h.length===0&&(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground p-3`,children:n(`activity:designStudio.notFound`)}),g.pageItems.map(e=>{let t=a===e.id;return(0,Z.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,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold truncate`,children:e.name}),t&&(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-[9px] font-semibold uppercase text-primary`,children:[(0,Z.jsx)(ui,{className:`w-3 h-3`}),` `,n(`activity:design.active`)]})]}),(0,Z.jsx)(`p`,{className:`text-[11px] text-muted-foreground leading-snug mt-0.5`,children:e.aesthetic})]}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>m(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,Z.jsxs)(`div`,{className:`mt-2 space-y-1`,children:[(0,Z.jsx)(Cu,{tokens:e.light,label:n(`activity:designStudio.light`)}),(0,Z.jsx)(Cu,{tokens:e.dark,label:n(`activity:designStudio.dark`)})]}),e.bestFor&&(0,Z.jsxs)(`p`,{className:`text-[10px] text-muted-foreground mt-2 leading-snug`,children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:n(`activity:designStudio.bestFor`)}),` `,e.bestFor]}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-1.5`,children:e.stacks.map(e=>(0,Z.jsx)(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-muted text-muted-foreground`,children:e},e))})]},e.id)})]}),(0,Z.jsx)(Tc,{page:g.page,pageSize:g.pageSize,totalItems:g.totalItems,onPageChange:g.setPage,compact:!0,itemLabel:`design kits`})]})}function Tu(e){return e<=0?`$0.000`:e>=.01?`$${e.toFixed(3)}`:`$${e.toFixed(4)}`}function Eu(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 Du({icon:e,label:t,onClick:n,disabled:r,tone:i,title:a}){return(0,Z.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 Ou({label:e,value:t,sub:n}){return(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col rounded-lg border border-border/60 bg-card/65 p-2 shadow-sm`,children:[(0,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:e}),(0,Z.jsx)(`span`,{className:`text-sm font-semibold tabular-nums truncate`,children:t}),n&&(0,Z.jsx)(`span`,{className:`text-[9px] text-muted-foreground/70 truncate`,children:n})]})}function ku({icon:e,label:t,right:n}){return(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[10px] uppercase text-muted-foreground font-semibold`,children:[e,t]}),n]})}function Au({label:e,value:t,onChange:n,title:r}){return(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 py-1`,title:r,children:[(0,Z.jsx)(`span`,{className:`text-xs text-foreground/80`,children:e}),(0,Z.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,Z.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{updatePrefs:e,switchAutonomy:t}=ha(),{t:n}=H(),r=R(e=>e.wsConnected),i=R(e=>e.wsUrl),a=R(e=>e.soundOnComplete),o=N(e=>e.session),s=N(e=>e.totalTokens),c=N(e=>e.cost),l=N(e=>e.iteration),u=N(e=>e.todos),d=q(e=>e.messages),f=q(e=>e.isLoading),p=_(e=>e.agents),m=K(e=>e.pinnedIds),h=K(e=>e.unpinAll),g=b(e=>e.entries),v=W(),y=(0,X.useRef)(v.autonomy===`off`?`auto`:v.autonomy),x=(0,X.useCallback)((t,n)=>{v.set({[t]:n}),e({[t]:n})},[v,e]),S=o?.startedAt??null,[C,w]=(0,X.useState)(()=>Date.now());(0,X.useEffect)(()=>{if(!S)return;let e=setInterval(()=>w(Date.now()),1e3);return()=>clearInterval(e)},[S]);let E=ve()??o?.id,D=(0,X.useMemo)(()=>Array.from(p.values()).filter(e=>e.status===`running`&&A(e.sessionId,E)).length,[p,E]),O=(0,X.useMemo)(()=>Array.from(p.values()).filter(e=>A(e.sessionId,E)),[p,E]);(0,X.useEffect)(()=>{y.current=v.autonomy===`off`?`auto`:v.autonomy},[E]);let k=m.map(e=>d.find(t=>t.id===e)).filter(e=>!!e&&e.content.length>0),j=wc(u,12,o?.id),M=wc(k,8,o?.id),F=(0,X.useCallback)(e=>{let t=V(i);t?.send&&t.send({...e,payload:t.withSession({...e.payload??{}})})},[i]),I=(0,X.useCallback)(()=>{let{openTabIds:e}=P.getState();if(e.length<ee){T.getState().openPicker({startsSession:!0});return}B.info(n(`activity:sessions.allTabsRunning`,{defaultValue:`All 4 tab slots are full. Close a tab before opening a new session.`}))},[n]),L=(0,X.useCallback)(async()=>{let e=V(i);if(!e?.newSession||!r||!E)return;if(ce(E)){let e=fe(E);if(!await $a({title:n(`activity:sessionPanel.actions.newSessionConfirm`),message:n(`activity:sessionPanel.actions.newSessionConfirmMessage`),details:e.lines,confirmLabel:n(`common:action.clear`),cancelLabel:n(`common:action.cancel`,{defaultValue:`Cancel`}),danger:!0,defaultAction:`cancel`}))return}let t=K.getState();t.setDraftInput(``),t.setDraftImages([]),t.setRefinePanel(null),t.setQueuePanelOpen(!1),e.newSession({replaceSessionId:E})},[i,r,E,n]);return(0,X.useEffect)(()=>{r&&F({type:`sessions.list`,payload:{limit:8}})},[r,F]),(0,Z.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,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-1.5 border-b border-border/70 bg-card/55 px-3 py-2.5`,children:[f&&(0,Z.jsx)(Du,{icon:(0,Z.jsx)(sn,{className:`h-3 w-3`}),label:n(`activity:sessionPanel.actions.abort`),tone:`danger`,onClick:()=>F({type:`abort`,payload:{}}),disabled:!r}),(0,Z.jsx)(Du,{icon:(0,Z.jsx)(_i,{className:`h-3 w-3`}),label:n(`activity:sessionPanel.actions.newSession`),onClick:I,disabled:!r,title:n(`activity:sessionPanel.actions.newSessionTitle`)}),(0,Z.jsx)(Du,{icon:(0,Z.jsx)(ti,{className:`h-3 w-3`}),label:n(`activity:sessionPanel.actions.export`),onClick:()=>Jo(),title:n(`activity:sessionPanel.actions.exportTitle`)}),(0,Z.jsx)(Du,{icon:(0,Z.jsx)(Wt,{className:`h-3 w-3`}),label:n(`activity:sessionPanel.actions.compact`),onClick:()=>F({type:`context.compact`,payload:{aggressive:!1}}),disabled:!r,title:n(`activity:sessionPanel.actions.compactTitle`)}),(0,Z.jsx)(Du,{icon:(0,Z.jsx)(Xr,{className:`h-3 w-3`}),label:n(`common:action.clear`),onClick:L,disabled:!r,title:n(`activity:sessionPanel.actions.clearTitle`)})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5 border-b border-border/70 px-3 py-2.5`,children:[(0,Z.jsx)(ku,{icon:(0,Z.jsx)(ar,{className:`h-3 w-3`}),label:n(`activity:sessionPanel.sessionLabel`)}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-1.5`,children:[(0,Z.jsx)(Ou,{label:n(`activity:sessionPanel.stats.messages`),value:d.length}),(0,Z.jsx)(Ou,{label:n(`activity:sessionPanel.stats.elapsed`),value:S?Eu(C-S):`--`}),(0,Z.jsx)(Ou,{label:n(`activity:sessionPanel.stats.tokens`),value:_s(s.input+s.output),sub:n(`activity:sessionPanel.stats.tokensSub`,{in:_s(s.input),out:_s(s.output)})}),(0,Z.jsx)(Ou,{label:n(`activity:sessionPanel.stats.cost`),value:Tu(c)}),l&&(0,Z.jsx)(Ou,{label:n(`activity:sessionPanel.stats.iteration`),value:l.index,sub:l.max?n(`activity:sessionPanel.stats.iterationOf`,{max:l.max}):void 0}),O.length>0&&(0,Z.jsx)(Ou,{label:n(`activity:sessionPanel.stats.agents`),value:O.length,sub:D>0?n(`activity:sessionPanel.stats.agentsRunning`,{count:D}):void 0})]})]}),u.length>0&&(()=>{let e=u.filter(e=>e.status===`completed`).length,t=u.filter(e=>e.status===`in_progress`).length,r=Math.round(e/u.length*100),i=e===u.length;return(0,Z.jsxs)(`div`,{className:`space-y-1.5 border-b border-border/70 px-3 py-2.5`,children:[(0,Z.jsx)(ku,{icon:(0,Z.jsx)(yt,{className:`h-3 w-3`}),label:n(`activity:sessionPanel.plan`),right:(0,Z.jsxs)(`span`,{className:`tabular-nums text-[10px] text-muted-foreground`,children:[e,`/`,u.length]})}),(0,Z.jsx)(`div`,{className:G(`relative h-1.5 w-full overflow-hidden rounded-full bg-muted`,t>0&&`bar-sweep`),title:n(`activity:sessionPanel.planComplete`,{pct:r}),children:(0,Z.jsx)(`div`,{className:G(`h-full rounded-full transition-all duration-500`,i?`bg-success`:`bg-primary`),style:{width:`${Math.max(r,t>0?4:0)}%`}})}),(0,Z.jsx)(`ul`,{className:`space-y-0.5 max-h-56 overflow-y-auto pr-1 -mx-1`,children:j.pageItems.map(e=>{let t=e.status===`completed`?$t:e.status===`in_progress`?Et:Vt,n=e.status===`in_progress`,r=e.status===`completed`?`text-success line-through opacity-60`:n?`text-foreground`:`text-muted-foreground`;return(0,Z.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,Z.jsx)(t,{className:G(`h-3.5 w-3.5 mt-0.5 shrink-0`,n&&`text-primary animate-pulse`)}),(0,Z.jsx)(`span`,{className:`break-words`,children:n&&e.activeForm?e.activeForm:e.content})]},e.id)})}),(0,Z.jsx)(Tc,{page:j.page,pageSize:j.pageSize,totalItems:j.totalItems,onPageChange:j.setPage,compact:!0,itemLabel:`todos`})]})})(),k.length>0&&(0,Z.jsxs)(`div`,{className:`space-y-1.5 border-b border-border/70 px-3 py-2.5`,children:[(0,Z.jsx)(ku,{icon:(0,Z.jsx)(Gr,{className:`h-3 w-3 text-warning`}),label:n(`activity:sessionPanel.pinned`),right:(0,Z.jsx)(`button`,{type:`button`,onClick:h,className:`text-[10px] text-muted-foreground hover:text-destructive`,children:n(`common:action.clear`)})}),(0,Z.jsx)(`ul`,{className:`space-y-1 max-h-48 overflow-y-auto pr-1`,children:M.pageItems.map(e=>{let t=e.content.replace(/\s+/g,` `).slice(0,80);return(0,Z.jsx)(`li`,{children:(0,Z.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,Z.jsx)(Tc,{page:M.page,pageSize:M.pageSize,totalItems:M.totalItems,onPageChange:M.setPage,compact:!0,itemLabel:`pinned answers`})]}),(0,Z.jsxs)(`div`,{className:`space-y-1 border-b border-border/70 px-3 py-2.5`,children:[(0,Z.jsx)(ku,{icon:(0,Z.jsx)(Je,{className:`h-3 w-3`}),label:n(`activity:sessionPanel.quickSettings`)}),(0,Z.jsx)(Au,{label:n(`activity:sessionPanel.autonomy`),title:n(`activity:sessionPanel.autonomyTitle`),value:v.autonomy!==`off`,onChange:()=>{let e=v.autonomy===`off`?y.current:`off`;e!==`off`&&(y.current=e),v.set({autonomy:e}),t(e)}}),(0,Z.jsx)(Au,{label:n(`activity:sessionPanel.yolo`),title:n(`activity:sessionPanel.yoloTitle`),value:v.yolo,onChange:()=>x(`yolo`,!v.yolo)}),(0,Z.jsx)(Au,{label:n(`activity:sessionPanel.sound`),title:n(`activity:sessionPanel.soundTitle`),value:a,onChange:()=>{let e=!R.getState().soundOnComplete;R.getState().setSoundOnComplete(e),e&&la()}})]}),(()=>{let e=g.slice(0,8);return e.length===0?null:(0,Z.jsxs)(`div`,{className:`space-y-1 border-b border-border/70 px-3 py-2.5`,children:[(0,Z.jsx)(ku,{icon:(0,Z.jsx)(Fn,{className:`h-3 w-3`}),label:n(`activity:nav.history`,`History`),right:(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{let e=K.getState();e.setCurrentView(`sessions`),e.setSidebarOpen(!1)},className:`text-[10px] text-muted-foreground hover:text-foreground`,children:n(`activity:history.openDashboard`,`Open Dashboard`)})}),(0,Z.jsx)(`div`,{className:`space-y-0.5 max-h-40 overflow-y-auto`,children:e.map(e=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>{let t=V(R.getState().wsUrl);P.getState().openTab(e.id,{resumeSession:e=>t?.resumeSession?.(e)})},className:G(`w-full text-left px-2 py-1.5 rounded text-xs leading-snug transition-colors`,e.isCurrent?`bg-primary/10 text-primary`:`hover:bg-muted/60 text-muted-foreground hover:text-foreground`),children:[(0,Z.jsx)(`div`,{className:`font-medium truncate`,children:e.title||n(`chat:empty`,`Untitled`)}),(0,Z.jsxs)(`div`,{className:`text-[10px] text-muted-foreground/70 font-mono truncate`,children:[e.provider,`/`,e.model,` · `,e.tokenTotal.toLocaleString(),` tok`]})]},e.id))})]})})()]})}function Mu(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 Nu(e){return e===`project`||e===`user`||e===`bundled`?e:`foreign`}function Pu({source:e}){let{t}=H(),n=Nu(e);return(0,Z.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:Mu(t,n)})}function Fu({className:e}){let{t}=H(),{client:n}=ha(),r=K(e=>e.skillsState),i=K(e=>e.setSkillsState),[a,o]=(0,X.useState)([]),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(`all`),[d,f]=(0,X.useState)(``),p=(0,X.useRef)(r);p.current=r;let[m,h]=(0,X.useState)(!1),[g,_]=(0,X.useState)(``),[v,y]=(0,X.useState)(!1),[b,x]=(0,X.useState)(!1),[S,C]=(0,X.useState)(null),[w,T]=(0,X.useState)(null),[E,D]=(0,X.useState)(!1),[O,k]=(0,X.useState)(``),[A,j]=(0,X.useState)(``),[M,N]=(0,X.useState)(`project`),[P,F]=(0,X.useState)(!1),[I,L]=(0,X.useState)(null),[R,ee]=(0,X.useState)(null),[te,z]=(0,X.useState)(!1),[ne,re]=(0,X.useState)(!1);(0,X.useEffect)(()=>{if(!m&&!E)return;let e=e=>{e.key===`Escape`&&(m&&h(!1),E&&D(!1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[m,E]);let ie=(0,X.useRef)(new Map);(0,X.useEffect)(()=>{let e=ie.current;return()=>{for(let t of e.values())t();e.clear()}},[]);let ae=(0,X.useCallback)((e,t,r,i=15e3)=>{if(!n)return;ie.current.get(e)?.();let a=null,o=e=>{s(),t(e)},s=()=>{a&&clearTimeout(a),n.off(e,o),ie.current.delete(e)};a=setTimeout(()=>{s(),r()},i),n.on(e,o),ie.current.set(e,s)},[n]),oe=(0,X.useCallback)(()=>{!n||!g.trim()||(x(!0),C(null),T(null),ae(`skills.installed`,e=>{let t=e;if(x(!1),t.payload.success){let e=t.payload.results?.map(e=>e.name).join(`, `)??g;T(U.t(`activity:skillsList.installedMsg`,{names:e})),n.send({type:`skills.list`},{echoToChat:!1})}else C(t.payload.error??U.t(`activity:skillsList.installFailed`))},()=>{x(!1),C(U.t(`activity:skillsList.installFailed`))}),n.installSkill(g.trim(),v))},[n,g,v,ae]),se=(0,X.useCallback)(()=>{!n||!O.trim()||!A.trim()||(F(!0),L(null),ee(null),ae(`skills.created`,e=>{let t=e;F(!1),t.payload.success?(ee(U.t(`activity:skillsList.createdMsg`,{name:t.payload.skill?.name??``})),n.send({type:`skills.list`},{echoToChat:!1})):L(t.payload.error??U.t(`activity:skillsList.createFailed`))},()=>{F(!1),L(U.t(`activity:skillsList.createFailed`))}),n.createSkill(O.trim(),A.trim(),M))},[n,O,A,M,ae]),ce=(0,X.useCallback)(()=>{n&&(re(!0),n.checkForUpdates(void 0,void 0))},[n]),le=(0,X.useCallback)(()=>{n&&(z(!0),ae(`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,ae]);(0,X.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=p.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(re(!1),t.payload.success){let e=p.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 ue=(0,X.useCallback)(e=>{i({...p.current,selectedSkill:e,navHistory:[e],historyIndex:0,detailOpen:!0}),J(`skills`)},[i]),de=(0,X.useMemo)(()=>{let e=a;if(l!==`all`&&(e=e.filter(e=>Nu(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]),fe=(0,X.useMemo)(()=>{let e={project:[],user:[],foreign:[],bundled:[]};for(let t of de)e[Nu(t.source)].push(t);return e},[de]),B=r.selectedSkill?.name;return(0,Z.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,Z.jsxs)(`div`,{className:`flex w-full items-center gap-1 border-b border-border/60 bg-card/65 px-2 py-2`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{_(``),C(null),T(null),y(!1),h(!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,Z.jsx)(_i,{className:`h-4 w-4`})}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{k(``),j(``),N(`project`),L(null),ee(null),D(!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,Z.jsx)(tn,{className:`h-4 w-4`})}),(0,Z.jsx)(`button`,{type:`button`,onClick:le,disabled:te||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:te?(0,Z.jsx)(wt,{className:`h-4 w-4 animate-spin`}):(0,Z.jsx)(ti,{className:`h-4 w-4`})}),(0,Z.jsxs)(`button`,{type:`button`,onClick:ce,disabled:ne,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:[ne?(0,Z.jsx)(wt,{className:`h-4 w-4 animate-spin`}):(0,Z.jsx)(xi,{className:`h-4 w-4`}),!ne&&r.updateAvailableCount>0&&(0,Z.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,Z.jsxs)(`div`,{className:`shrink-0 space-y-2 border-b border-border/60 bg-card/45 p-2`,children:[(0,Z.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,Z.jsx)(`div`,{className:`flex gap-1 flex-wrap`,children:[`all`,`project`,`user`,`foreign`,`bundled`].map(e=>{let n=e===`all`?de.length:de.filter(t=>Nu(t.source)===e).length;return(0,Z.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`):Mu(t,e),(0,Z.jsxs)(`span`,{className:G(`ml-1 font-medium`,l===e?`opacity-90`:`opacity-60`,n===0&&`line-through`),children:[`(`,n,`)`]})]},e)})})]}),(0,Z.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain p-2 [scrollbar-gutter:stable]`,children:s?(0,Z.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`)}):de.length===0?(0,Z.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,Z.jsx)(`div`,{className:`space-y-2`,children:[`project`,`user`,`foreign`,`bundled`].map(e=>{let n=fe[e];return n.length===0?null:(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1 px-1 py-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[(0,Z.jsx)(Pu,{source:e}),(0,Z.jsx)(`span`,{className:`ml-auto opacity-60`,children:n.length})]}),n.map(e=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>ue(e),className:G(`w-full rounded-lg border px-2.5 py-2 text-left text-xs transition-colors`,B===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,Z.jsxs)(`div`,{className:`font-medium truncate flex items-center gap-1`,children:[(0,Z.jsx)(et,{className:`h-3 w-3 shrink-0`}),e.name]}),(0,Z.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,Z.jsx)(Ja,{open:m,onOpenChange:h,children:(0,Z.jsxs)(Ga,{className:`flex max-h-[calc(100dvh-2rem)] w-[420px] max-w-[90vw] flex-col gap-0 overflow-hidden p-0`,showCloseButton:!1,children:[(0,Z.jsxs)(Ua,{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,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(ti,{className:`h-4 w-4 text-primary`}),(0,Z.jsx)(Ka,{className:`font-semibold text-sm`,children:t(`activity:skillsList.installHeading`)})]}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>h(!1),"aria-label":t(`common:action.close`),className:`rounded p-1 text-muted-foreground hover:bg-accent hover:text-accent-foreground`,children:(0,Z.jsx)(St,{className:`h-4 w-4`})})]}),(0,Z.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-4 space-y-3`,children:[(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`activity:skillsList.installHint`)}),(0,Z.jsx)(`input`,{type:`text`,value:g,onChange:e=>{_(e.target.value),C(null),T(null)},onKeyDown:e=>{e.key===`Enter`&&!b&&oe()},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,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t(`activity:skillsList.installScope`)}),(0,Z.jsxs)(`div`,{className:`flex overflow-hidden rounded-md border border-border/70`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>y(!1),className:G(`px-2 py-1 text-[10px] transition-colors`,v?`bg-background hover:bg-accent`:`bg-primary text-primary-foreground`),children:t(`activity:skillDetail.scopeProject`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>y(!0),className:G(`px-2 py-1 text-[10px] transition-colors border-l border-border`,v?`bg-primary text-primary-foreground`:`bg-background hover:bg-accent`),children:t(`activity:skillDetail.scopeGlobal`)})]})]}),S&&(0,Z.jsx)(`p`,{className:`rounded-md bg-destructive/10 px-2 py-1 text-xs text-destructive`,children:S}),w&&(0,Z.jsx)(`p`,{className:`rounded-md bg-success/10 px-2 py-1 text-xs text-success`,children:w})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-border/70 bg-muted/20 p-4`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>h(!1),className:`rounded-md border border-border/70 px-3 py-1.5 text-xs transition-colors hover:bg-accent`,children:t(w?`common:action.close`:`common:action.cancel`)}),!w&&(0,Z.jsxs)(`button`,{type:`button`,onClick:oe,disabled:b||!g.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:[b&&(0,Z.jsx)(wt,{className:`h-3 w-3 animate-spin`}),t(`activity:skillsList.installBtn`)]})]})]})}),(0,Z.jsx)(Ja,{open:E,onOpenChange:D,children:(0,Z.jsxs)(Ga,{className:`flex max-h-[calc(100dvh-2rem)] w-[480px] max-w-[90vw] flex-col gap-0 overflow-hidden p-0`,showCloseButton:!1,children:[(0,Z.jsxs)(Ua,{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,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(tn,{className:`h-4 w-4 text-primary`}),(0,Z.jsx)(Ka,{className:`font-semibold text-sm`,children:t(`activity:skillsList.createHeading`)})]}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>D(!1),"aria-label":t(`common:action.close`),className:`rounded p-1 text-muted-foreground hover:bg-accent hover:text-accent-foreground`,children:(0,Z.jsx)(St,{className:`h-4 w-4`})})]}),(0,Z.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-4 space-y-3`,children:[(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`activity:skillsList.createHint`)}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`span`,{className:`block text-xs font-medium mb-1`,children:[t(`activity:skillsList.nameLabel`),` `,(0,Z.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,Z.jsx)(`input`,{type:`text`,value:O,onChange:e=>{let t=e.target.value.trim().toLowerCase().replace(/\s+/g,`-`).replace(/[^a-z0-9-]/g,``);k(t),L(null),ee(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,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`span`,{className:`block text-xs font-medium mb-1`,children:[t(`activity:skillsList.descLabel`),` `,(0,Z.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,Z.jsx)(`textarea`,{value:A,onChange:e=>{j(e.target.value),L(null),ee(null)},onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&!P&&se()},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,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t(`activity:skillsList.saveIn`)}),(0,Z.jsxs)(`div`,{className:`flex overflow-hidden rounded-md border border-border/70`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>N(`project`),className:G(`px-2 py-1 text-[10px] transition-colors`,M===`project`?`bg-primary text-primary-foreground`:`bg-background hover:bg-accent`),children:t(`activity:skillDetail.scopeProject`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>N(`global`),className:G(`px-2 py-1 text-[10px] transition-colors border-l border-border`,M===`global`?`bg-primary text-primary-foreground`:`bg-background hover:bg-accent`),children:t(`activity:skillDetail.scopeGlobal`)})]})]}),I&&(0,Z.jsx)(`p`,{className:`rounded-md bg-destructive/10 px-2 py-1 text-xs text-destructive`,children:I}),R&&(0,Z.jsx)(`p`,{className:`rounded-md bg-success/10 px-2 py-1 text-xs text-success`,children:R})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-border/70 bg-muted/20 p-4`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>D(!1),className:`rounded-md border border-border/70 px-3 py-1.5 text-xs transition-colors hover:bg-accent`,children:t(R?`common:action.close`:`common:action.cancel`)}),!R&&(0,Z.jsxs)(`button`,{type:`button`,onClick:se,disabled:P||!O.trim()||!A.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:[P&&(0,Z.jsx)(wt,{className:`h-3 w-3 animate-spin`}),t(`activity:skillsList.createBtn`)]})]})]})})]})}var Iu={chat:`Run state, model, context and quick controls`,agents:`Live fleet roster and agent monitoring`,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`};function Lu({desktopShell:e=!1}){let n=K(e=>e.activeActivity),r=K(e=>e.setSidebarOpen),i=K(e=>e.sidebarWidth),a=K(e=>e.setSidebarWidth),o=R(e=>e.wsConnected),{client:s}=ha(),{t:c}=H(),l=e?`min(${Math.min(i,280)}px, calc(100vw - 2.5rem))`:`min(${i}px, calc(100vw - 3rem))`;return(0,X.useEffect)(()=>{if(n!==`files`||!o)return;t.getState().setTreeLoading(!0);let e=N.getState().cwd;s?.send({type:`files.tree`,payload:s.withSession(e?{path:e}:{})})},[n,o,s]),(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.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:()=>r(!1),"aria-hidden":`true`}),(0,Z.jsxs)(`aside`,{style:{width:l},role:`dialog`,"aria-modal":`true`,"aria-label":c(`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,Z.jsx)(`hr`,{"aria-orientation":`vertical`,"aria-valuemin":240,"aria-valuemax":560,"aria-valuenow":i,tabIndex:0,onMouseDown:e=>{e.preventDefault();let t=e.clientX,n=i,r=e=>a(n+(e.clientX-t)),o=()=>{window.removeEventListener(`mousemove`,r),window.removeEventListener(`mouseup`,o),document.body.style.cursor=``,document.body.style.userSelect=``};window.addEventListener(`mousemove`,r),window.addEventListener(`mouseup`,o),document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`},onDoubleClick:()=>a(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:c(`activity:sidePanel.dragHint`)}),(0,Z.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,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-foreground`,children:c(`activity:nav.${n}`)}),(0,Z.jsx)(`div`,{className:`mt-0.5 truncate text-[11px] text-muted-foreground`,children:Iu[n]})]}),(0,Z.jsx)(Y,{variant:`ghost`,size:`icon`,className:`h-7 w-7 shrink-0`,onClick:()=>r(!1),title:c(`activity:sidePanel.collapse`),children:(0,Z.jsx)(Ki,{className:`h-3.5 w-3.5`})})]}),(0,Z.jsxs)(`div`,{className:`flex-1 min-h-0 min-w-0 flex flex-col overflow-hidden`,children:[n===`chat`&&(0,Z.jsx)(ju,{}),n===`agents`&&(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-y-auto overscroll-contain`,children:(0,Z.jsx)(du,{})}),n===`files`&&(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-y-auto overscroll-contain`,children:(0,Z.jsx)(Wl,{})}),n===`changes`&&(0,Z.jsx)(bu,{}),n===`mailbox`&&(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-y-auto overscroll-contain p-3`,children:(0,Z.jsx)(Ql,{})}),n===`skills`&&(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Fu,{className:`h-full`})}),n===`design`&&(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(wu,{className:`h-full`})})]})]})]})}function Ru(){let{t:e}=H(),{wsUrl:t}=R(),{info:n,pickerOpen:r,pickerStartsSession:i,closePicker:a}=T(),o=ve(),s=T(e=>be(e,o)),[c,l]=(0,X.useState)(null);(0,X.useEffect)(()=>{r&&l(s)},[r,s]),(0,X.useEffect)(()=>{!r||!o||T.getState().currentBySession[o]===void 0&&V(t).getSystemPrompt()},[r,o,t]);let u=n?.variants??[],d=u.length===0;return(0,Z.jsx)(Ja,{open:r,onOpenChange:e=>!e&&a(),children:(0,Z.jsxs)(Ga,{className:`sm:max-w-lg`,children:[(0,Z.jsxs)(Ua,{children:[(0,Z.jsxs)(Ka,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(tn,{className:`h-4 w-4`}),e(`activity:systemPrompt.title`)]}),(0,Z.jsx)(qa,{children:n?.chosen===!1?e(`activity:systemPrompt.firstRunDescription`):e(`activity:systemPrompt.description`)})]}),d?(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground py-2`,children:e(`activity:systemPrompt.unavailable`)}):(0,Z.jsx)(`div`,{className:`flex flex-col gap-2 py-1`,children:u.map(t=>{let n=c===t.variant;return(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>l(t.variant),"aria-pressed":n,className:`flex items-start gap-3 rounded-lg border p-3 text-left transition-colors ${n?`border-primary bg-primary/5`:`border-border hover:bg-muted/40`}`,children:[(0,Z.jsx)(`span`,{className:`mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-full border ${n?`border-primary bg-primary text-primary-foreground`:`border-border`}`,children:n&&(0,Z.jsx)(ui,{className:`h-3 w-3`})}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:t.label}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:e(`activity:systemPrompt.tokens`,{count:t.tokens})}),t.variant===s&&(0,Z.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-muted-foreground`,children:e(`activity:systemPrompt.current`)})]}),(0,Z.jsx)(`span`,{className:`mt-0.5 block text-xs text-muted-foreground`,children:t.hint})]})]},t.variant)})}),(0,Z.jsxs)(Wa,{children:[(0,Z.jsx)(Y,{variant:`ghost`,onClick:a,children:e(`activity:systemPrompt.cancel`)}),(0,Z.jsx)(Y,{onClick:()=>{let e=V(t);c&&c!==s&&e.setSystemPromptVariant(c),i&&e.newSession({systemPromptVariant:c??void 0}),a()},disabled:d,children:e(i?`activity:systemPrompt.applyAndStart`:`activity:systemPrompt.apply`)})]})]})})}var zu=(0,X.createContext)(void 0);function Bu({children:e,defaultTheme:t=`system`,storageKey:n=`wrongstack-theme`,defaultPalette:r=he,paletteStorageKey:i=pe}){let a=R(e=>e.setTheme),o=R(e=>e.setPalette),[s,c]=(0,X.useState)(()=>typeof window<`u`&&localStorage.getItem(n)||t),[l,u]=(0,X.useState)(()=>me(i,r));(0,X.useEffect)(()=>{let e=window.document.documentElement;if(e.classList.remove(`light`,`dark`),s===`system`){let t=window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`;e.classList.add(t)}else e.classList.add(s)},[s]),(0,X.useEffect)(()=>{ie(window.document.documentElement,l)},[l]),(0,X.useEffect)(()=>{let e=e=>{e.key===i&&de(e.newValue)&&(u(e.newValue),o(e.newValue))};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[i,o]);let d={theme:s,setTheme:e=>{localStorage.setItem(n,e),c(e),a(e)},palette:l,setPalette:e=>{try{localStorage.setItem(i,e)}catch{}u(e),o(e)}};return(0,Z.jsx)(zu.Provider,{value:d,children:e})}function Vu(){let e=(0,X.useContext)(zu);if(e===void 0)throw Error(`useTheme must be used within a ThemeProvider`);return e}var Hu=`wrongstack_app_cached_version`;function Uu(){let{t:e}=H(),t=N(e=>e.appVersion),n=N(e=>e.latestVersion),r=N(e=>e.updateAvailable),[i,a]=(0,X.useState)(!1),[o,s]=(0,X.useState)(!1);return(0,X.useEffect)(()=>{if(t)try{let e=localStorage.getItem(Hu);e?e!==t&&(typeof window<`u`&&`caches`in window&&window.caches.keys().then(e=>{for(let t of e)window.caches.delete(t)}),s(!0),localStorage.setItem(Hu,t)):localStorage.setItem(Hu,t)}catch{}},[t]),(0,X.useEffect)(()=>{(r||o)&&a(!1)},[t,n,r,o]),!i&&(o||r&&n)?(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2 border-b text-sm bg-warning/10 text-warning border-warning/30 backdrop-blur-md`,children:[o?(0,Z.jsx)(et,{className:`h-4 w-4 shrink-0 text-primary`}):(0,Z.jsx)(Xi,{className:`h-4 w-4 shrink-0`}),(0,Z.jsx)(`div`,{className:`flex-1 min-w-0 flex flex-wrap items-center gap-x-2 gap-y-1`,children:o?(0,Z.jsxs)(`span`,{className:`font-medium text-foreground`,children:[e(`activity:updateBanner.newBuildReady`,`New build ready. Cache cleared.`),` (v`,t,`)`]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`span`,{className:`font-medium`,children:[`Update available: v`,t||`?`,` → v`,n]}),(0,Z.jsxs)(`span`,{className:`text-xs opacity-80`,children:[e(`activity:updateBanner.run`),` `,(0,Z.jsx)(`code`,{className:`font-mono text-[inherit]`,children:e(`activity:updateBanner.wstackUpdate`)}),` `,e(`activity:updateBanner.orYourPackageManagerToUpgrade`)]})]})}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>{typeof window<`u`&&window.location.reload()},className:`inline-flex items-center gap-1 px-2 py-1 rounded bg-warning/20 hover:bg-warning/30 text-warning text-xs font-medium transition-colors`,title:e(`activity:updateBanner.refresh`,`Refresh`),children:[(0,Z.jsx)(xi,{className:`h-3 w-3`}),(0,Z.jsx)(`span`,{children:e(`activity:updateBanner.refresh`,`Refresh`)})]}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>a(!0),className:`text-current/60 hover:text-current p-1 rounded hover:bg-warning/20 transition-colors`,title:e(`activity:updateBanner.dismiss`),"aria-label":e(`activity:updateBanner.dismiss`),children:(0,Z.jsx)(St,{className:`h-4 w-4`})})]})]}):null}function Wu({label:e}){return(0,Z.jsx)(`div`,{className:`flex flex-1 min-h-0 min-w-0 items-center justify-center bg-background text-muted-foreground`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[(0,Z.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-muted-foreground/30 border-t-primary`}),e?(0,Z.jsx)(`span`,{className:`text-xs`,children:e}):null]})})}function Gu(e,t=!0){let n=(0,X.useRef)(null);return(0,X.useEffect)(()=>{if(!t)return;let r=n.current;if(!r)return;let i=requestAnimationFrame(()=>{let t=K.getState().scrollPositions[e];typeof t==`number`&&t>0&&(r.scrollTop=t)});return()=>cancelAnimationFrame(i)},[]),(0,X.useEffect)(()=>{if(!t)return;let r=n.current;if(!r)return;let{setScrollPosition:i}=K.getState();return()=>{i(e,r.scrollTop)}},[e]),n}function Ku(){let{t:e}=H(),t=fa(e=>e.contextMemories),n=fa(e=>e.transitions),r=Object.values(t).sort((e,t)=>t.lastSeenAt.localeCompare(e.lastSeenAt)),i=r.filter(e=>e.state===`active`),a=r.filter(e=>e.state===`injected`),o=r.filter(e=>e.state===`exited`);return(0,Z.jsxs)(`section`,{className:`rounded-md border border-primary/20 bg-primary/[0.025]`,"aria-label":e(`activity:ctxMonitor.contextMemoryMonitor`),children:[(0,Z.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-border/60 px-3 py-2`,children:[(0,Z.jsx)(bi,{className:`size-4 text-primary`}),(0,Z.jsx)(`h2`,{className:`text-xs font-semibold`,children:e(`activity:ctxMonitor.contextMemoryMonitor`)}),(0,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:e(`activity:ctxMonitor.exactProviderBoundPresence`)}),(0,Z.jsxs)(`div`,{className:`ml-auto flex gap-2 font-mono text-[10px]`,children:[(0,Z.jsxs)(`span`,{className:`text-success`,children:[i.length,` ctx`]}),(0,Z.jsxs)(`span`,{className:`text-warning`,children:[a.length,` pending`]}),(0,Z.jsxs)(`span`,{className:`text-muted-foreground`,children:[o.length,` left`]})]})]}),r.length===0?(0,Z.jsx)(`p`,{className:`px-3 py-4 text-xs text-muted-foreground`,children:e(`activity:ctxMonitor.noSageHasEnteredThisSession`)}):(0,Z.jsxs)(`div`,{className:`grid gap-3 p-3 xl:grid-cols-[minmax(0,2fr)_minmax(260px,1fr)]`,children:[(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-wide text-muted-foreground`,children:e(`activity:ctxMonitor.memoryPresence`)}),r.slice(0,20).map(e=>(0,Z.jsxs)(`article`,{className:G(`border px-3 py-2 text-[10px]`,e.state===`exited`?`border-border/50 bg-muted/20 opacity-65`:`border-primary/25 bg-background/55`),children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:G(`border px-1.5 py-0.5 font-bold uppercase`,e.state===`exited`?`border-border text-muted-foreground`:e.state===`active`?`border-success/35 text-success`:`border-warning/35 text-warning`),children:e.state}),(0,Z.jsx)(`span`,{className:`font-mono font-bold text-primary`,children:e.id}),(0,Z.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[e.kind,` · `,e.persistence]}),(0,Z.jsxs)(`span`,{className:`ml-auto font-mono text-muted-foreground`,children:[`score `,e.score.toFixed(2),` · conf `,e.confidence.toFixed(2),` · fresh`,` `,e.freshness.toFixed(2)]})]}),(0,Z.jsx)(`p`,{className:`mt-1.5 text-[11px] leading-5 text-foreground`,children:e.text}),(0,Z.jsxs)(`p`,{className:`mt-1 text-muted-foreground`,children:[`why: `,e.activationReasons.join(` · `)||`context snapshot`]}),(e.anchors.length>0||e.tags.length>0)&&(0,Z.jsx)(`p`,{className:`mt-1 truncate font-mono text-muted-foreground`,title:[...e.anchors,...e.tags.map(e=>`#${e}`)].join(` · `),children:[...e.anchors,...e.tags.map(e=>`#${e}`)].join(` · `)})]},e.id))]}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-wide text-muted-foreground`,children:e(`activity:ctxMonitor.cameWent`)}),n.slice(0,30).map(e=>(0,Z.jsxs)(`div`,{className:`flex gap-2 border-b border-border/40 py-1.5 text-[10px] last:border-b-0`,children:[e.action===`exited`?(0,Z.jsx)(Er,{className:`mt-0.5 size-3 shrink-0 text-muted-foreground`}):(0,Z.jsx)(an,{className:`mt-0.5 size-3 shrink-0 text-success`}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`p`,{className:`font-mono`,children:[(0,Z.jsx)(`span`,{className:e.action===`exited`?`text-muted-foreground`:`text-success`,children:e.action}),` `,e.memoryId]}),(0,Z.jsx)(`p`,{className:`truncate text-muted-foreground`,children:e.reason})]}),(0,Z.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1 text-muted-foreground`,children:[(0,Z.jsx)(Pi,{className:`size-2.5`}),` `,new Date(e.at).toLocaleTimeString()]})]},e.id))]})]})]})}function qu(){let{t:e}=H(),t=aa(e=>e.items),n=aa(e=>e.clear);return(0,Z.jsxs)(`section`,{className:`shrink-0 border-b border-border/60 bg-info/[0.025]`,"aria-label":e(`activity:memoryManager.lifecycleAria`),children:[(0,Z.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-4`,children:[(0,Z.jsx)(Ge,{className:`size-3.5 text-info`}),(0,Z.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-wide text-info`,children:e(`activity:memoryManager.lifecycleHeading`)}),(0,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:t.length===0?e(`activity:memoryManager.statusWaiting`):e(`activity:memoryManager.statusLive`,{count:t.length})}),t.length>0&&(0,Z.jsxs)(Y,{type:`button`,variant:`ghost`,size:`sm`,className:`ml-auto h-6 px-2 text-[10px]`,onClick:n,children:[(0,Z.jsx)(vr,{className:`size-3`}),` `,e(`common:action.clear`)]})]}),t.length>0?(0,Z.jsx)(`div`,{className:`max-h-20 overflow-y-auto border-t border-border/40`,children:t.slice(0,8).map(e=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/30 px-4 py-1 text-[10px] last:border-b-0`,children:[(0,Z.jsx)(Ju,{action:e.action}),(0,Z.jsx)(`span`,{className:G(`font-mono font-semibold`,Yu(e.action)),children:e.label}),e.detail&&(0,Z.jsx)(`span`,{className:`min-w-0 truncate text-muted-foreground`,title:e.detail,children:e.detail}),(0,Z.jsx)(`time`,{className:`ml-auto shrink-0 text-muted-foreground`,children:new Date(e.at).toLocaleTimeString()})]},e.id))}):null]})}function Ju({action:e}){let t=G(`size-3 shrink-0`,Yu(e));return e===`entered`||e===`recovered`?(0,Z.jsx)(st,{className:t}):e===`exited`?(0,Z.jsx)(fn,{className:t}):e===`related`?(0,Z.jsx)(Vi,{className:t}):(0,Z.jsx)(xi,{className:t})}function Yu(e){return e===`entered`||e===`recovered`?`text-success`:e===`exited`?`text-destructive`:e===`related`?`text-primary`:`text-info`}var Xu=[{labelKey:`activity:ctxDash.zoneSafe`,emoji:`🟢`,color:`text-success`,bg:`bg-success/10`,text:`text-success`,cssColor:`hsl(var(--success))`,from:0,to:60,descKey:`activity:ctxDash.zoneSafeDesc`},{labelKey:`activity:ctxDash.zoneWarning`,emoji:`🟡`,color:`text-warning`,bg:`bg-warning/10`,text:`text-warning`,cssColor:`hsl(var(--warning))`,from:60,to:85,descKey:`activity:ctxDash.zoneWarningDesc`},{labelKey:`activity:ctxDash.zoneCritical`,emoji:`🔴`,color:`text-destructive`,bg:`bg-destructive/10`,text:`text-destructive`,cssColor:`hsl(var(--destructive))`,from:85,to:95,descKey:`activity:ctxDash.zoneCriticalDesc`},{labelKey:`activity:ctxDash.zoneDanger`,emoji:`⚫`,color:`text-brand-orange`,bg:`bg-brand-orange/15`,text:`text-brand-orange`,cssColor:`hsl(var(--brand-orange))`,from:95,to:100,descKey:`activity:ctxDash.zoneDangerDesc`}];function Zu(e){return e>95?Xu[3]:e>85?Xu[2]:e>60?Xu[1]:Xu[0]}function Qu(e){if(!e)return`—`;let t=Date.now()-e,n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4),i=Math.floor(t%6e4/1e3);return n>0?`${n}h ${r}m`:r>0?`${r}m ${i}s`:`${i}s`}function $u({title:e,icon:t,children:n,className:r,accent:i}){let a=i===`danger`?`text-destructive`:i===`warning`?`text-warning`:i===`success`?`text-success`:`text-muted-foreground`,o=i===`danger`?`bg-destructive/5`:i===`warning`?`bg-warning/5`:i===`success`?`bg-success/5`:``;return(0,Z.jsxs)(`div`,{className:G(`rounded-xl border bg-card/80 backdrop-blur-sm p-4 space-y-3`,`shadow-sm transition-shadow hover:shadow-md`,`ring-1 ring-border/40`,o,r),children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-bold tracking-tight text-foreground`,children:[(0,Z.jsx)(`span`,{className:G(`flex items-center justify-center h-6 w-6 rounded-lg`,o,i!=="default"&&`ring-1 ring-inset`),children:(0,Z.jsx)(t,{className:G(`h-3.5 w-3.5`,a)})}),e]}),n]})}function ed({label:e,value:t,color:n}){return(0,Z.jsxs)(`div`,{className:`flex items-center justify-between text-xs py-0.5`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,Z.jsx)(`span`,{className:G(`tabular-nums font-mono font-semibold px-1.5 py-0.5 rounded`,n??`text-foreground`),children:t})]})}function td({pct:e,size:t=96,strokeWidth:n=10}){let r=Math.max(0,Math.min(100,e)),i=(t-n)/2,a=2*Math.PI*i,o=r/100*a,s=Zu(r).cssColor;return(0,Z.jsxs)(`svg`,{width:t,height:t,viewBox:`0 0 ${t} ${t}`,className:`drop-shadow-lg`,children:[(0,Z.jsxs)(`title`,{children:[`Context usage: `,r.toFixed(0),`%`]}),(0,Z.jsx)(`circle`,{cx:t/2,cy:t/2,r:i,fill:`none`,stroke:`hsl(var(--muted))`,strokeWidth:n,opacity:.3}),(0,Z.jsx)(`circle`,{cx:t/2,cy:t/2,r:i,fill:`none`,stroke:s,strokeWidth:n,strokeLinecap:`round`,strokeDasharray:`${o} ${a-o}`,strokeDashoffset:0,className:`transition-all duration-1000 ease-out`,style:{transformOrigin:`center`,transform:`rotate(-90deg)`}}),(0,Z.jsx)(`circle`,{cx:t/2,cy:t/2,r:i-n/2+2,fill:`hsl(var(--card))`,className:`drop-shadow-sm`}),(0,Z.jsxs)(`text`,{x:t/2,y:t/2,textAnchor:`middle`,dominantBaseline:`central`,fill:s,className:`text-lg font-bold font-mono tabular-nums`,style:{fontSize:t*.16},children:[r.toFixed(0),`%`]})]})}function nd({value:e,suffix:t=``,duration:n=800}){let[r,i]=(0,X.useState)(0),a=(0,X.useRef)(0),o=(0,X.useRef)(void 0);return(0,X.useEffect)(()=>{let t=a.current,r=performance.now(),s=e-t;if(Math.abs(s)<1){i(e),a.current=e;return}let c=l=>{let u=l-r,d=Math.min(1,u/n),f=1-(1-d)**3;i(Math.round(t+s*f)),d<1?o.current=requestAnimationFrame(c):a.current=e};return o.current=requestAnimationFrame(c),()=>{o.current&&cancelAnimationFrame(o.current)}},[e,n]),(0,Z.jsxs)(Z.Fragment,{children:[r.toLocaleString(),t]})}function rd({pct:e,tokens:t,maxTokens:n}){let{t:r}=H(),i=Zu(e),a=e>85?`danger`:e>60?`warning`:`success`;return(0,Z.jsxs)($u,{title:r(`activity:ctxDash.contextPressure`),icon:ln,accent:a,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-center gap-4`,children:[(0,Z.jsx)(`div`,{className:G(`shrink-0 transition-all duration-500`,e>85&&`animate-[pulse_2s_ease-in-out_infinite] drop-shadow-[0_0_12px_hsl(var(--destructive)/0.35)]`),children:(0,Z.jsx)(td,{pct:e,size:96,strokeWidth:10})}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-2 w-full`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(`span`,{className:`text-xl`,children:i.emoji}),(0,Z.jsx)(`div`,{className:`flex-1`,children:(0,Z.jsx)(pc,{pct:Math.round(e),tokens:t,maxTokens:n,segments:10,variant:`iridescent`})})]}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-3 gap-1 text-[10px] font-mono tabular-nums`,children:[(0,Z.jsxs)(`div`,{className:`rounded bg-muted/30 px-2 py-1 text-center`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground block text-[9px]`,children:r(`activity:ctxDash.used`)}),(0,Z.jsx)(`span`,{className:G(`font-bold`,i.color),children:(0,Z.jsx)(nd,{value:t})})]}),(0,Z.jsxs)(`div`,{className:`rounded bg-muted/30 px-2 py-1 text-center`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground block text-[9px]`,children:r(`activity:ctxDash.free`)}),(0,Z.jsx)(`span`,{className:`font-bold text-muted-foreground/80`,children:(0,Z.jsx)(nd,{value:Math.max(0,n-t)})})]}),(0,Z.jsxs)(`div`,{className:`rounded bg-muted/30 px-2 py-1 text-center`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground block text-[9px]`,children:r(`activity:ctxDash.capacity`)}),(0,Z.jsx)(`span`,{className:`font-bold text-muted-foreground/80`,children:(0,Z.jsx)(nd,{value:n})})]})]})]})]}),(0,Z.jsxs)(`div`,{className:`relative h-4 mt-1`,children:[(0,Z.jsx)(`div`,{className:`absolute inset-x-0 top-0 h-2 rounded-full overflow-hidden flex`,children:Xu.map(e=>{let t=(e.to-e.from)/100*100;return(0,Z.jsx)(`div`,{className:`h-full first:rounded-l-full last:rounded-r-full opacity-60`,style:{width:`${t}%`,backgroundColor:e.cssColor}},r(e.labelKey))})}),(0,Z.jsxs)(`div`,{className:`absolute top-3 text-[10px] text-muted-foreground flex w-full`,children:[(0,Z.jsx)(`span`,{children:`0%`}),(0,Z.jsx)(`span`,{className:`ml-[56%]`,children:`soft`}),(0,Z.jsx)(`span`,{className:`ml-[12%]`,children:`hard`}),(0,Z.jsx)(`span`,{className:`ml-[8%]`,children:`max`}),(0,Z.jsx)(`span`,{className:`ml-auto`,children:`100%`})]})]}),(0,Z.jsx)(`div`,{className:`relative h-5 mt-1`,children:(0,Z.jsx)(`div`,{className:`absolute top-0 -translate-x-1/2 flex flex-col items-center transition-all duration-500`,style:{left:`${Math.min(95,e)}%`},children:(0,Z.jsxs)(`span`,{className:G(`text-[9px] font-mono px-1.5 py-0.5 rounded border transition-colors`,i.bg,i.text,`border-current/30`),children:[`◀ `,e.toFixed(0),`%`]})})})]})}function id({data:e,loading:t}){let{t:n}=H();if(t)return(0,Z.jsx)($u,{title:n(`activity:ctxDash.contextComposition`),icon:Pr,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground py-2`,children:[(0,Z.jsx)(xi,{className:`h-3 w-3 animate-spin`}),n(`activity:ctxDash.fetchingCompositionData`)]})});if(!e||e.total<=0)return(0,Z.jsx)($u,{title:n(`activity:ctxDash.contextComposition`),icon:Pr,children:(0,Z.jsx)(`div`,{className:`text-xs text-muted-foreground py-1`,children:n(`activity:ctxDash.noCompositionDataAvailableYetRun`)})});let r=[{icon:tn,label:n(`activity:ctxDash.systemPrompt`),value:e.systemPrompt,className:`bg-info`},{icon:li,label:n(`activity:ctxDash.tools`),value:e.tools.total,className:`bg-warning`},{icon:Lt,label:n(`activity:ctxDash.messages`),value:e.messages.total,className:`bg-success`}];return(0,Z.jsxs)($u,{title:n(`activity:ctxDash.contextComposition`),icon:Pr,children:[(0,Z.jsx)(`div`,{className:`h-3 w-full overflow-hidden rounded-full bg-muted flex`,children:r.map(t=>{let n=t.value/e.total*100;return n<=0?null:(0,Z.jsx)(`span`,{className:G(`h-full first:rounded-l-full last:rounded-r-full transition-all`,t.className),style:{width:`${n}%`}},t.label)})}),(0,Z.jsx)(`div`,{className:`space-y-1`,children:r.map(t=>{let n=(t.value/e.total*100).toFixed(1);return(0,Z.jsx)(ed,{label:`${t.label}`,value:`${tc(t.value)} (${n}%)`},t.label)})}),e.tools.breakdown.length>0&&(0,Z.jsxs)(`div`,{className:`pt-1 border-t border-border/50`,children:[(0,Z.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground font-semibold`,children:n(`activity:ctxDash.toolBreakdown`)}),(0,Z.jsx)(`div`,{className:`mt-1 space-y-0.5`,children:e.tools.breakdown.slice(0,5).map(e=>(0,Z.jsxs)(`div`,{className:`flex items-center justify-between text-xs py-0.5`,children:[(0,Z.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:e.name}),(0,Z.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:tc(e.tokens)})]},e.name))})]})]})}function ad({pct:e}){let{t}=H();return(0,Z.jsxs)($u,{title:t(`activity:ctxDash.thresholdMap`),icon:Kr,children:[(0,Z.jsx)(`div`,{className:`flex h-2 rounded-full overflow-hidden`,children:Xu.map(e=>(0,Z.jsx)(`div`,{className:`h-full first:rounded-l-full last:rounded-r-full opacity-80`,style:{width:`${(e.to-e.from)/100*100}%`,backgroundColor:e.cssColor}},t(e.labelKey)))}),(0,Z.jsx)(`div`,{className:`space-y-0.5 text-xs`,children:Xu.map(n=>{let r=e>=n.from&&e<n.to;return(0,Z.jsxs)(`div`,{className:G(`flex items-center px-2 py-1 rounded`,r?n.bg:``),children:[(0,Z.jsx)(`span`,{className:`w-5`,children:n.emoji}),(0,Z.jsx)(`span`,{className:G(`w-20 font-medium`,r?n.text:`text-muted-foreground`),children:t(n.labelKey)}),(0,Z.jsxs)(`span`,{className:`w-16 text-muted-foreground`,children:[n.from,`%–`,n.to,`%`]}),(0,Z.jsx)(`span`,{className:`flex-1 text-muted-foreground`,children:t(n.descKey)}),r&&(0,Z.jsx)(`span`,{className:`text-xs font-mono`,children:`◀`})]},t(n.labelKey))})}),(0,Z.jsx)(ed,{label:t(`activity:ctxDash.currentPosition`),value:`${e.toFixed(1)}% → ${Zu(e).emoji} ${t(Zu(e).labelKey)}`,color:Zu(e).color}),(0,Z.jsx)(ed,{label:t(`activity:ctxDash.compactTrigger`),value:`85%`}),(0,Z.jsx)(ed,{label:t(`activity:ctxDash.hardLimit`),value:`100%`})]})}function od({pct:e,maxTokens:t}){let{t:n}=H(),r=Math.round(t*.18),i=Math.round(t*.85),a=e>65,o=t>0?e/100:0;return(0,Z.jsx)($u,{title:n(`activity:ctxDash.compactionEngine`),icon:Or,accent:a?`warning`:`success`,children:(0,Z.jsxs)(`div`,{className:`space-y-2 text-xs`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:n(`activity:ctxDash.strategy`)}),(0,Z.jsx)(`span`,{className:`font-semibold text-foreground/90`,children:`hybrid`}),(0,Z.jsx)(`span`,{className:`text-success bg-success/10 px-1.5 rounded text-[9px] font-semibold`,children:n(`activity:ctxDash.auto`)})]}),(0,Z.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,Z.jsxs)(`div`,{className:`flex justify-between text-[9px] text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:n(`activity:ctxDash.current`)}),(0,Z.jsxs)(`span`,{children:[`Trigger (`,tc(i),`)`]})]}),(0,Z.jsxs)(`div`,{className:`relative h-2 w-full overflow-hidden rounded-full bg-muted/50 ring-1 ring-inset ring-border/20`,children:[(0,Z.jsx)(`span`,{className:G(`absolute inset-y-0 left-0 rounded-full transition-all duration-700`,a?`bg-warning`:`bg-success`),style:{width:`${Math.max(2,o*100)}%`}}),(0,Z.jsx)(`span`,{className:`absolute top-0 bottom-0 w-0.5 bg-destructive/60`,style:{left:`85%`}})]}),(0,Z.jsxs)(`div`,{className:`flex justify-between text-[9px] text-foreground/70`,children:[(0,Z.jsx)(`span`,{children:tc(Math.round(t*o))}),(0,Z.jsx)(`span`,{className:`text-destructive/70`,children:tc(i)})]})]}),(0,Z.jsx)(ed,{label:n(`activity:ctxDash.nextTrigger`),value:`${tc(i)} (85%)`}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between text-xs py-0.5`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:n(`activity:ctxDash.estRecovery`)}),(0,Z.jsxs)(`span`,{className:`tabular-nums font-mono font-semibold px-1.5 py-0.5 rounded text-success bg-success/10`,children:[`~`,tc(r)]})]}),(0,Z.jsx)(ed,{label:n(`activity:ctxDash.recommendation`),value:a?`⚠️ Compact now`:`✅ No compaction needed`,color:a?`text-warning`:`text-success`}),a&&(0,Z.jsxs)(`div`,{className:`bg-warning/5 border border-warning/20 rounded p-2 text-[10px] text-warning/90 mt-1`,children:[`Context at `,e.toFixed(1),`% — compacting recovers ~`,tc(r),` tokens.`]})]})})}function sd({agents:e}){let{t}=H(),n=e.filter(e=>e.ctxPct!=null&&e.ctxPct>0);return n.length===0?null:(0,Z.jsx)($u,{title:t(`activity:ctxDash.perAgentFootprint`),icon:fr,children:(0,Z.jsx)(`div`,{className:`space-y-2`,children:n.map(e=>{let t=Zu(e.ctxPct),n=e.name||e.id,r=e.id===`__leader__`;return(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,Z.jsx)(`span`,{className:`w-4`,children:r?`👑`:` `}),(0,Z.jsx)(`span`,{className:`w-24 truncate font-mono text-muted-foreground`,title:n,children:n}),(0,Z.jsx)(`div`,{className:`flex-1 max-w-[200px]`,children:(0,Z.jsx)(mc,{pct:Math.round(e.ctxPct),tokens:e.ctxTokens,maxTokens:e.maxContext,showTokens:!1})}),(0,Z.jsxs)(`span`,{className:G(`tabular-nums w-10 text-right`,t.color),children:[Math.round(e.ctxPct),`%`]})]},e.id)})})})}function cd({tokens:e,maxTokens:t,pct:n,model:r,provider:i,mode:a,uptime:o,iteration:s,contextMode:c}){let{t:l}=H(),u=t-e,d=t>0?(u/t*100).toFixed(1):`0.0`;return(0,Z.jsx)($u,{title:l(`activity:ctxDash.tokenMetrics`),icon:wn,children:(0,Z.jsxs)(`div`,{className:`space-y-1 text-xs`,children:[(0,Z.jsx)(ed,{label:l(`activity:ctxDash.used`),value:tc(e)}),(0,Z.jsx)(ed,{label:l(`activity:ctxDash.free`),value:`${tc(u)} (${d}%)`}),(0,Z.jsx)(ed,{label:l(`activity:ctxDash.capacity`),value:tc(t)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:l(`activity:ctxDash.utilization`)}),(0,Z.jsx)(`div`,{className:`flex-1 max-w-[200px]`,children:(0,Z.jsx)(mc,{pct:Math.round(n),tokens:e,maxTokens:t})})]}),(0,Z.jsx)(`div`,{className:`border-t border-border/50 pt-1 mt-1`}),(0,Z.jsx)(ed,{label:l(`activity:ctxDash.model`),value:`${r} · ${i}`}),(0,Z.jsx)(ed,{label:l(`activity:ctxDash.mode`),value:a}),(0,Z.jsx)(ed,{label:l(`activity:ctxDash.contextMode`),value:c}),(0,Z.jsx)(ed,{label:l(`activity:ctxDash.iteration`),value:s}),(0,Z.jsx)(ed,{label:l(`activity:ctxDash.uptime`),value:o})]})})}function ld({model:e,provider:t,mode:n,uptime:r,projectName:i,cwd:a,contextMode:o}){let{t:s}=H();return(0,Z.jsx)($u,{title:s(`activity:ctxDash.session`),icon:ar,children:(0,Z.jsxs)(`div`,{className:`space-y-1 text-xs`,children:[(0,Z.jsx)(ed,{label:s(`activity:ctxDash.provider`),value:t}),(0,Z.jsx)(ed,{label:s(`activity:ctxDash.model`),value:e}),(0,Z.jsx)(ed,{label:s(`activity:ctxDash.mode`),value:n}),(0,Z.jsx)(ed,{label:s(`activity:ctxDash.contextMode`),value:o}),(0,Z.jsx)(ed,{label:s(`activity:ctxDash.project`),value:i||a}),(0,Z.jsx)(ed,{label:s(`activity:ctxDash.uptime`),value:r})]})})}function ud(){let{t:e}=H(),t=K(e=>e.setCurrentView),{lastInputTokens:n,maxContext:r,mode:i,contextMode:a,startTime:o,session:s,iteration:c,projectName:l,cwd:u}=N(Me(e=>({lastInputTokens:e.lastInputTokens,maxContext:e.maxContext,mode:e.mode,contextMode:e.contextMode,startTime:e.startTime,session:e.session,iteration:e.iteration,projectName:e.projectName,cwd:e.cwd}))),d=ve(),f=_(Me(e=>[...e.agents.values()].filter(e=>A(e.sessionId,d)))),p=R(e=>e.wsUrl),[m,h]=(0,X.useState)(null),[g,v]=(0,X.useState)(!1),[y,b]=(0,X.useState)(null),x=(0,X.useRef)(0),S=(0,X.useRef)(null),C=()=>{S.current?.(),S.current=null;let e=V(p);if(!e?.send){b(`WebSocket not connected`);return}let t=++x.current;v(!0),b(null);let n=e.withSession({}).sessionId;e.send({type:`context.debug`,payload:e.withSession({})},{echoToChat:!1});let r=!1,i,a=e.on(`context.debug`,e=>{if(r||e.type!==`context.debug`||x.current!==t)return;let o=e.payload?.sessionId;(n===void 0||o===void 0||o===n)&&(r=!0,i!==void 0&&clearTimeout(i),h(e.payload),v(!1),a())});S.current=a,i=setTimeout(()=>{r||(r=!0,x.current===t&&(v(!1),b(`No response from server`),a()))},5e3)};(0,X.useEffect)(()=>(h(null),C(),()=>{x.current++,S.current?.(),S.current=null}),[p,d]);let w=s?.model??`—`,T=s?.provider??`—`,E=r>0?Math.min(100,n/r*100):0,D=Qu(o),O=c?`${c.index} / ${c.max}`:`—`,k=Zu(E),j=e=>({animation:`fadeInUp 0.4s ease-out ${e*.08}s both`});return(0,Z.jsxs)(`div`,{ref:Gu(`context`),className:`flex-1 min-h-0 overflow-y-auto overscroll-contain`,children:[(0,Z.jsx)(`style`,{children:`
|
|
75
75
|
@keyframes fadeInUp {
|
|
76
76
|
from { opacity: 0; transform: translateY(12px); }
|
|
@@ -80,7 +80,7 @@ Type while the agent is running to queue messages; they are sent automatically w
|
|
|
80
80
|
`):``),y(n.url??``)):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(`
|
|
81
81
|
`):``),y(i.url??``)):(s(``),l(`stdio`),d(``),x(!0),C(!1),p(``),h(``),_(``),y(``)))},[n,i,e]);let w=()=>{if(!o.trim()){B.error(a(`settings:mcp.serverNameRequired`));return}let e={};if(g.trim())for(let t of g.trim().split(`
|
|
82
82
|
`)){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,Z.jsx)(Ja,{open:e,onOpenChange:t,children:(0,Z.jsxs)(Ga,{children:[(0,Z.jsx)(Ua,{children:(0,Z.jsx)(Ka,{children:a(T?`settings:mcp.dialogTitleEdit`:E?`settings:mcp.dialogTitleAdd`:`settings:mcp.dialogTitleAddCustom`)})}),(0,Z.jsxs)(`div`,{className:`space-y-4 py-4`,children:[(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:a(`settings:mcp.fieldName`)}),(0,Z.jsx)(Ya,{value:o,onChange:e=>s(e.target.value),placeholder:a(`settings:mcp.fieldNamePlaceholder`),disabled:T||E})]}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:a(`settings:mcp.fieldTransport`)}),(0,Z.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,Z.jsx)(`option`,{value:`stdio`,children:`stdio`}),(0,Z.jsx)(`option`,{value:`sse`,children:`sse`}),(0,Z.jsx)(`option`,{value:`streamable-http`,children:`streamable-http`}),(0,Z.jsx)(`option`,{value:`http`,children:`http`})]})]}),(c===`streamable-http`||c===`sse`||c===`http`)&&(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:a(`settings:mcp.fieldUrl`)}),(0,Z.jsx)(Ya,{value:v,onChange:e=>y(e.target.value),placeholder:a(`activity:mCPSection.httpsMcpExampleComMcp`),disabled:E})]}),c===`stdio`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:a(`settings:mcp.fieldCommand`)}),(0,Z.jsx)(Ya,{value:f,onChange:e=>p(e.target.value),placeholder:a(`settings:mcp.fieldCommandPlaceholder`),disabled:E})]}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsxs)(`span`,{className:`text-sm font-medium`,children:[a(`settings:mcp.fieldArgs`),` `,(0,Z.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:a(`settings:mcp.fieldArgsHint`)})]}),(0,Z.jsx)(Ya,{value:m,onChange:e=>h(e.target.value),placeholder:a(`settings:mcp.fieldArgsPlaceholder`),disabled:E})]})]}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsxs)(`span`,{className:`text-sm font-medium`,children:[a(`settings:mcp.fieldEnv`),` `,(0,Z.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:a(`settings:mcp.fieldEnvHint`)})]}),(0,Z.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_...
|
|
83
|
-
AWS_REGION=us-east-1`})]}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:a(`settings:mcp.fieldDescription`)}),(0,Z.jsx)(Ya,{value:u,onChange:e=>d(e.target.value),placeholder:a(`settings:mcp.fieldDescriptionPlaceholder`)})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,id:`server-enabled`,checked:b,onChange:e=>x(e.target.checked),className:`rounded`}),(0,Z.jsx)(`label`,{htmlFor:`server-enabled`,className:`text-sm`,children:a(`settings:mcp.enableServer`)})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,id:`server-lazy`,checked:S,onChange:e=>C(e.target.checked),className:`rounded`}),(0,Z.jsxs)(`label`,{htmlFor:`server-lazy`,className:`text-sm`,children:[a(`settings:mcp.lazyConnect`),` `,(0,Z.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:a(`settings:mcp.lazyConnectHint`)})]})]})]}),(0,Z.jsxs)(Wa,{children:[(0,Z.jsx)(Y,{variant:`outline`,onClick:()=>t(!1),children:a(`common:action.cancel`)}),(0,Z.jsx)(Y,{onClick:w,children:a(T?`settings:mcp.saveChanges`:`settings:mcp.addServer`)})]})]})})}function pf({server:e,isAdded:t,onAdd:n}){let{t:r}=H();return(0,Z.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,Z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-sm`,children:e.name}),e.badge&&(0,Z.jsx)(wd,{variant:`secondary`,className:`text-xs shrink-0`,children:e.badge}),(0,Z.jsx)(wd,{variant:`outline`,className:`text-xs shrink-0`,children:e.transport})]}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e.description}),e.requiresEnvVars&&e.requiresEnvVars.length>0&&(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-warning`,children:r(`settings:mcp.requires`,{vars:e.requiresEnvVars.join(`, `)})})]}),(0,Z.jsx)(`div`,{className:`shrink-0`,children:t?(0,Z.jsxs)(Y,{variant:`ghost`,size:`sm`,disabled:!0,children:[(0,Z.jsx)(ui,{className:`w-4 h-4 mr-1`}),r(`settings:mcp.added`)]}):(0,Z.jsxs)(Y,{size:`sm`,variant:`outline`,onClick:n,children:[(0,Z.jsx)(_i,{className:`w-4 h-4 mr-1`}),r(`common:action.add`)]})})]})}function mf(){let e=ha(),{t}=H(),[n,r]=(0,X.useState)([]),[i,a]=(0,X.useState)(!1),[o,s]=(0,X.useState)(`list`),[c,l]=(0,X.useState)(),[u,d]=(0,X.useState)(!1),[f,p]=(0,X.useState)(!1),[m,h]=(0,X.useState)(),[g,_]=(0,X.useState)(null);(0,X.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]),B.success(U.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)),B.success(U.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)),_(null),B.success(U.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)),_(null),B.info(U.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)),_(null),B.success(U.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)),_(null),B.success(U.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)),_(null),B.warn(U.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)),_(null),B.error(U.t(`settings:mcp.toastError`,{name:t.name,error:t.error}))}},m=e=>{if(e.type===`mcp.operation_result`){let t=e.payload;t.success||B.error(t.message),_(null)}},h=e.client.on(`mcp.list`,t),g=e.client.on(`mcp.server.added`,n),v=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?.(),v?.(),y?.(),b?.(),x?.(),S?.(),C?.(),w?.(),T?.(),E?.(),D?.()}},[e.client]);let v=(0,X.useCallback)(t=>{e.client?.addMcpServer(t)},[e]),y=(0,X.useCallback)(e=>{h(cf(e,!1)),p(!0)},[]),b=(0,X.useCallback)(n=>{$a({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]),x=(0,X.useCallback)(e=>{l(e),h(void 0),d(!0)},[]),S=(0,X.useCallback)(t=>{e.client?.updateMcpServer(t)},[e]),C=(0,X.useCallback)(t=>{_(t),e.client?.wakeMcpServer(t)},[e]),w=(0,X.useCallback)(t=>{_(t),e.client?.sleepMcpServer(t)},[e]),T=(0,X.useCallback)(t=>{_(t),e.client?.discoverMcpServer(t)},[e]),E=(0,X.useCallback)(()=>{a(!0),e.client?.listMcpServers()},[e]),D=n.filter(e=>e.status===`connected`).length,O=n.filter(e=>e.status===`sleeping`).length,k=new Set(n.map(e=>e.name));return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Z.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,Z.jsx)(Qi,{className:`h-5 w-5`})}),(0,Z.jsx)(`h2`,{className:`text-base font-semibold`,children:t(`settings:mcp.heading`)}),n.length>0&&(0,Z.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:D,sleeping:O,total:n.length})})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsxs)(Y,{variant:`outline`,size:`sm`,onClick:E,disabled:i,children:[i?(0,Z.jsx)(wt,{className:`w-4 h-4 animate-spin`}):null,t(`common:action.refresh`)]}),(0,Z.jsxs)(Y,{size:`sm`,onClick:()=>{h(void 0),p(!0)},children:[(0,Z.jsx)(_i,{className:`w-4 h-4 mr-1`}),t(`settings:mcp.addCustom`)]})]})]}),(0,Z.jsxs)(Ns,{value:o,onValueChange:e=>s(e),children:[(0,Z.jsxs)(Ps,{children:[(0,Z.jsxs)(Fs,{value:`recommended`,children:[(0,Z.jsx)(Hi,{className:`w-3.5 h-3.5 mr-1`}),t(`settings:mcp.tabRecommended`)]}),(0,Z.jsx)(Fs,{value:`list`,children:t(`settings:mcp.tabServers`)}),(0,Z.jsx)(Fs,{value:`add`,children:t(`settings:mcp.tabAddCustom`)})]}),(0,Z.jsxs)(Is,{value:`recommended`,className:`space-y-3`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`settings:mcp.recommendedBody`)}),(0,Z.jsx)(`div`,{className:`grid gap-2`,children:sf.map(e=>(0,Z.jsx)(pf,{server:e,isAdded:k.has(e.name),onAdd:()=>y(e)},e.name))})]}),(0,Z.jsx)(Is,{value:`list`,className:`space-y-3`,children:i&&n.length===0?(0,Z.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground`,children:[(0,Z.jsx)(wt,{className:`w-5 h-5 animate-spin mr-2`}),t(`settings:mcp.loadingServers`)]}):n.length===0?(0,Z.jsxs)(`div`,{className:`text-center py-8 text-muted-foreground`,children:[(0,Z.jsx)(Qi,{className:`w-10 h-10 mx-auto mb-2 opacity-50`}),(0,Z.jsx)(`p`,{children:t(`settings:mcp.noServers`)}),(0,Z.jsx)(`p`,{className:`text-sm`,children:t(`settings:mcp.noServersHint`)})]}):n.map(e=>(0,Z.jsx)(df,{server:e,onWake:()=>C(e.name),onSleep:()=>w(e.name),onDiscover:()=>T(e.name),onEdit:()=>x(e),onRemove:()=>b(e.name)},e.name))}),(0,Z.jsx)(Is,{value:`add`,children:(0,Z.jsxs)(`div`,{className:`text-sm text-muted-foreground`,children:[(0,Z.jsx)(`p`,{children:t(`settings:mcp.addCustomBody`)}),(0,Z.jsx)(`p`,{className:`mt-1`,children:t(`settings:mcp.addCustomBodyHint`)})]})})]}),(0,Z.jsx)(ff,{open:f,onOpenChange:e=>{e||(p(!1),h(void 0))},prefillConfig:m,onSave:v}),(0,Z.jsx)(ff,{open:u,onOpenChange:d,server:c,onSave:S})]})}function hf({syncPref:e}){let{t}=H(),n=W();return(0,Z.jsxs)(`div`,{className:`space-y-6`,children:[(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,Z.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,Z.jsx)(Qi,{className:`h-5 w-5`})}),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:t(`settings:integrations.wrongProxyHeading`)})})]}),(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)($,{label:t(`settings:integrations.wrongProxyEnabledLabel`),hint:t(`settings:integrations.wrongProxyEnabledHint`),value:n.wrongProxyEnabled,onChange:()=>e(`wrongProxyEnabled`,!n.wrongProxyEnabled)}),(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:t(`settings:integrations.wrongProxyUrlLabel`)}),(0,Z.jsx)(Ya,{value:n.wrongProxyUrl,placeholder:`http://localhost:3444`,onChange:t=>e(`wrongProxyUrl`,t.target.value)}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`settings:integrations.wrongProxyUrlHint`)})]}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`settings:integrations.wrongProxyChangesApply`)})]})]}),(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,Z.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,Z.jsx)(Qi,{className:`h-5 w-5`})}),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:t(`settings:integrations.hqHeading`)})})]}),(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)($,{label:t(`settings:integrations.hqPublishingLabel`),hint:t(`settings:integrations.hqPublishingHint`),value:n.hqEnabled,onChange:()=>e(`hqEnabled`,!n.hqEnabled)}),(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:t(`settings:integrations.hqUrlLabel`)}),(0,Z.jsx)(Ya,{value:n.hqUrl,placeholder:t(`activity:integrationsSection.httpHost3499`),onChange:t=>e(`hqUrl`,t.target.value)}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`settings:integrations.hqUrlHint`)})]}),(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:t(`settings:integrations.hqTokenLabel`)}),(0,Z.jsx)(Ya,{type:`password`,value:n.hqToken,placeholder:t(`activity:integrationsSection.clientTokenFromWstackHq`),onChange:t=>e(`hqToken`,t.target.value)})]}),(0,Z.jsx)($,{label:t(`settings:integrations.hqRawContentLabel`),hint:t(`settings:integrations.hqRawContentHint`),value:n.hqRawContent,onChange:()=>e(`hqRawContent`,!n.hqRawContent)})]})]}),(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,Z.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,Z.jsx)(Qi,{className:`h-5 w-5`})}),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:t(`activity:integrationsSection.mcpServers`)})})]}),n.featureMcp?(0,Z.jsx)(mf,{}):(0,Z.jsxs)(`div`,{className:`text-center py-6 text-muted-foreground`,children:[(0,Z.jsx)(Qi,{className:`w-8 h-8 mx-auto mb-2 opacity-50`}),(0,Z.jsx)(`p`,{className:`text-sm`,children:t(`settings:mcp.disabled`)}),(0,Z.jsx)(`p`,{className:`text-xs mt-1`,children:t(`settings:integrations.disabledHint`)})]})]}),(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,Z.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,Z.jsx)(ze,{className:`h-5 w-5`})}),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:t(`settings:integrations.telegramHeading`)})})]}),n.tgConfigured?(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)($,{label:t(`settings:integrations.telegramSessionEndLabel`),hint:t(`settings:integrations.telegramSessionEndHint`),value:n.tgSessionEnd,onChange:()=>e(`tgSessionEnd`,!n.tgSessionEnd)}),(0,Z.jsx)($,{label:t(`settings:integrations.telegramDelegateLabel`),hint:t(`settings:integrations.telegramDelegateHint`),value:n.tgDelegate,onChange:()=>e(`tgDelegate`,!n.tgDelegate)}),(0,Z.jsx)($,{label:t(`settings:integrations.telegramLongToolLabel`),hint:t(`settings:integrations.telegramLongToolHint`,{ms:n.tgLongToolMs}),value:n.tgLongToolMs>0,onChange:()=>e(`tgLongToolMs`,n.tgLongToolMs>0?0:3e4)}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`settings:integrations.telegramChangesApply`)})]}):(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`settings:integrations.telegramNotConfigured`)})]})]})}function gf({syncPref:e}){let{t}=H(),n=W();return(0,Z.jsx)(`div`,{className:`space-y-6`,children:(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,Z.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,Z.jsx)(Oe,{className:`h-5 w-5`})}),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:t(`settings:logs.heading`)})})]}),(0,Z.jsx)(Q,{label:t(`settings:logs.logLevelLabel`),hint:t(`settings:logs.logLevelHint`),value:n.logLevel,options:[{value:`debug`,label:t(`settings:logs.logLevelDebug`)},{value:`info`,label:t(`settings:logs.logLevelInfo`)},{value:`warn`,label:t(`settings:logs.logLevelWarn`)},{value:`error`,label:t(`settings:logs.logLevelError`)}],onChange:t=>e(`logLevel`,t)}),(0,Z.jsx)(Q,{label:t(`settings:logs.auditLevelLabel`),hint:t(`settings:logs.auditLevelHint`),value:n.auditLevel,options:[{value:`minimal`,label:t(`settings:logs.auditLevelMinimal`)},{value:`standard`,label:t(`settings:logs.auditLevelStandard`)},{value:`full`,label:t(`settings:logs.auditLevelFull`)}],onChange:t=>e(`auditLevel`,t)}),(0,Z.jsx)(Q,{label:t(`settings:logs.fsAccessLabel`),hint:t(`settings:logs.fsAccessHint`),value:n.fsAccess,options:[{value:`unrestricted`,label:t(`settings:logs.fsAccessUnrestricted`)},{value:`project`,label:t(`settings:logs.fsAccessProject`)}],onChange:t=>e(`fsAccess`,t)}),(0,Z.jsx)($,{label:t(`settings:logs.debugStreamLabel`),hint:t(`settings:logs.debugStreamHint`),value:n.debugStream,onChange:()=>e(`debugStream`,!n.debugStream)})]})})}function _f({syncPref:e}){let{t}=H(),n=W(e=>e.reasoningEffort),r=N(e=>e.reasoningEffortLevels),i=el(r,n).map(e=>({value:e,label:t($c(e))}));return(0,Z.jsx)(`div`,{className:`mt-4 border-t border-border/60 pt-4`,children:(0,Z.jsx)(Q,{label:t(`settings:agent.reasoningEffortLabel`),hint:tl(r,n)?t(`settings:agent.reasoningEffortUnsupported`,{levels:(r??[]).join(`, `)}):r?`${t(`settings:agent.reasoningEffortHint`)} (${t(`settings:agent.reasoningEffortModelSet`)})`:t(`settings:agent.reasoningEffortHint`),value:n,options:i,onChange:t=>e(`reasoningEffort`,t)})})}function vf({provider:e,catalogModels:t,currentCatalogProvider:n,isLoadingModels:r,isSwitching:i,setIsLoadingModels:a,onModelSelect:o,refreshModels:s}){let c=R(e=>e.model),{t:l}=H();return(0,Z.jsx)(`div`,{className:`space-y-4`,children:e?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium`,children:n?.name||e}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e})]}),(0,Z.jsx)(Y,{variant:`ghost`,size:`sm`,onClick:()=>{a(!0),s(e)},children:(0,Z.jsx)(xi,{className:G(`h-4 w-4`,r&&`animate-spin`)})})]}),r&&!t[e]?(0,Z.jsxs)(`div`,{className:`flex items-center justify-center py-8`,children:[(0,Z.jsx)(wt,{className:`h-6 w-6 animate-spin text-muted-foreground`}),(0,Z.jsx)(`span`,{className:`ml-2 text-muted-foreground`,children:l(`settings:model.loading`)})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(dd,{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}`,e.reasoningEffortLevels?.length?`effort ${e.reasoningEffortLevels.join(`/`)}`:``].filter(Boolean).join(` · `),detailHighlight:!0})),selectedId:c,onSelect:o,disabled:i,emptyMessage:l(`settings:model.notFound`)}),i?(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:l(`settings:toast.switching`)}):null]})]}):(0,Z.jsxs)(`div`,{className:`text-center py-8 text-muted-foreground`,children:[(0,Z.jsx)(ar,{className:`h-8 w-8 mx-auto mb-2 opacity-50`}),(0,Z.jsx)(`p`,{children:l(`settings:model.selectProviderFirst`)})]})})}var yf=[{value:`off`,label:`Off`,hint:`The leader never changes its own tier.`},{value:`propose`,label:`Propose`,hint:`The leader asks before switching. Recommended.`},{value:`auto`,label:`Auto`,hint:`The leader switches on its own, still bounded by the guard rails below.`}],bf={};function xf({syncPref:e}){let t=W(),n=t.modelTiers??{},r=n.levels??{},i=n.routing??{},a=n.leader??{},o=Object.keys(r),s=Object.keys(t.fallbackProfiles??{}),[c,l]=(0,X.useState)(``),[u,d]=(0,X.useState)(``),[f,p]=(0,X.useState)(``),m=(0,X.useCallback)(t=>e(`modelTiers`,{...n,...t}),[e,n]),h=(0,X.useCallback)((t,i)=>e(`modelTiers`,{...n,levels:{...r,[t]:{...r[t]??{},...i}}}),[e,n,r]),g=(0,X.useCallback)(t=>{let a={...r};delete a[t];let o=Object.fromEntries(Object.entries(i).filter(([,e])=>e!==t));e(`modelTiers`,{...n,levels:a,routing:o})},[e,n,r,i]),_=()=>{let e=c.trim();!e||r[e]||(h(e,bf),l(``))},v=()=>{let e=u.trim();!e||!f||(m({routing:{...i,[e]:f}}),d(``),p(``))},y=e=>{let t={...i};delete t[e],m({routing:t})},b=e=>{let t=e.trim();if(!t)return;let n=Number.parseFloat(t);return Number.isFinite(n)&&n>=0?n:void 0};return(0,Z.jsxs)(`section`,{className:`space-y-3`,"data-testid":`model-tiers-section`,children:[(0,Z.jsxs)(`header`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Gi,{className:`h-4 w-4 text-muted-foreground`}),(0,Z.jsx)(`h3`,{className:`text-sm font-medium text-foreground`,children:`Model cost tiers`}),(0,Z.jsxs)(`label`,{className:`ml-auto flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:n.enabled===!0,onChange:e=>m({enabled:e.target.checked}),"data-testid":`model-tiers-enabled`}),`Enabled`]})]}),(0,Z.jsx)(`p`,{className:`text-[11px] leading-relaxed text-muted-foreground`,children:`A tier binds a fallback profile, a spend budget and a runtime setting under one name, then routes work to it by role or phase. Subagents, Kanban dispatch and the leader all read this table. While disabled, everything resolves exactly as it did before tiers existed.`}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-baseline justify-between`,children:[(0,Z.jsx)(`h4`,{className:`text-xs font-medium text-foreground`,children:`Levels`}),(0,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:`Order is the ladder — the first row is the cheapest rung.`})]}),o.length===0&&(0,Z.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`No levels yet. Add one below, then point it at a fallback profile.`}),o.map((e,t)=>{let n=r[e]??{};return(0,Z.jsxs)(`div`,{className:`space-y-1.5 rounded-md border border-border bg-muted px-2 py-1.5`,"data-testid":`model-tier-row-${e}`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs`,children:[(0,Z.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:t+1}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 break-words font-mono font-medium text-foreground`,children:e}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>g(e),className:`text-muted-foreground hover:text-destructive`,title:`Remove level`,"data-testid":`model-tier-remove-${e}`,children:(0,Z.jsx)(St,{className:`h-3 w-3`})})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,Z.jsxs)(`select`,{value:n.fallbackProfile??``,onChange:t=>h(e,{fallbackProfile:t.target.value||void 0}),className:`rounded-sm border border-border bg-background px-1.5 py-0.5 text-[11px]`,"data-testid":`model-tier-profile-${e}`,children:[(0,Z.jsx)(`option`,{value:``,children:`profile: (none)`}),s.map(e=>(0,Z.jsxs)(`option`,{value:e,children:[`profile: `,e]},e))]}),(0,Z.jsx)(`input`,{type:`number`,min:0,step:`0.01`,value:n.maxCostUsd??``,onChange:t=>h(e,{maxCostUsd:b(t.target.value)}),placeholder:`max $`,className:`w-20 rounded-sm border border-border bg-background px-1.5 py-0.5 text-[11px]`,"data-testid":`model-tier-cost-${e}`}),(0,Z.jsx)(`input`,{type:`number`,min:0,value:n.maxIterations??``,onChange:t=>h(e,{maxIterations:b(t.target.value)}),placeholder:`iters`,className:`w-16 rounded-sm border border-border bg-background px-1.5 py-0.5 text-[11px]`}),(0,Z.jsx)(`input`,{type:`number`,min:0,value:n.maxToolCalls??``,onChange:t=>h(e,{maxToolCalls:b(t.target.value)}),placeholder:`tools`,className:`w-16 rounded-sm border border-border bg-background px-1.5 py-0.5 text-[11px]`})]}),n.maxCostUsd!==void 0&&(0,Z.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Tightens a role's default budget down to this ceiling; it never raises one, and never overrides a budget passed explicitly to the spawn.`})]},e)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&_()},placeholder:`new level name (e.g. budget)`,className:`min-w-0 flex-1 rounded-sm border border-border bg-background px-1.5 py-0.5 text-[11px]`,"data-testid":`model-tier-new-name`}),(0,Z.jsxs)(Y,{size:`sm`,variant:`outline`,onClick:_,disabled:!c.trim(),children:[(0,Z.jsx)(_i,{className:`mr-1 h-3 w-3`}),` Add`]})]})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`h4`,{className:`text-xs font-medium text-foreground`,children:`Routing`}),Object.keys(i).length===0?(0,Z.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,children:[`No rules — everything uses the default tier`,n.default?` (${n.default})`:` (standard)`,`.`]}):(0,Z.jsx)(`ul`,{className:`space-y-1`,children:Object.entries(i).map(([e,t])=>(0,Z.jsxs)(`li`,{className:`flex items-center gap-1.5 rounded-md border border-border bg-muted px-2 py-1 text-[11px]`,"data-testid":`model-tier-route-${e}`,children:[(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1 break-words font-mono text-foreground`,children:[e,` → `,t]}),!r[t]&&(0,Z.jsx)(`span`,{className:`rounded-sm bg-warning/15 px-1 py-0.5 text-[10px] text-foreground`,children:`missing level`}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>y(e),className:`text-muted-foreground hover:text-destructive`,title:`Remove rule`,children:(0,Z.jsx)(St,{className:`h-3 w-3`})})]},e))}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(`input`,{value:u,onChange:e=>d(e.target.value),placeholder:`role, phase, or *`,className:`min-w-0 flex-1 rounded-sm border border-border bg-background px-1.5 py-0.5 text-[11px]`,"data-testid":`model-tier-new-route-key`}),(0,Z.jsxs)(`select`,{value:f,onChange:e=>p(e.target.value),className:`rounded-sm border border-border bg-background px-1.5 py-0.5 text-[11px]`,"data-testid":`model-tier-new-route-tier`,children:[(0,Z.jsx)(`option`,{value:``,children:`tier…`}),o.map(e=>(0,Z.jsx)(`option`,{value:e,children:e},e))]}),(0,Z.jsx)(Y,{size:`sm`,variant:`outline`,onClick:v,disabled:!u.trim()||!f,children:(0,Z.jsx)(_i,{className:`h-3 w-3`})})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px]`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:`Default tier`}),(0,Z.jsxs)(`select`,{value:n.default??``,onChange:e=>m({default:e.target.value||void 0}),className:`rounded-sm border border-border bg-background px-1.5 py-0.5 text-[11px]`,"data-testid":`model-tier-default`,children:[(0,Z.jsx)(`option`,{value:``,children:`standard`}),o.map(e=>(0,Z.jsx)(`option`,{value:e,children:e},e))]})]})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`h4`,{className:`text-xs font-medium text-foreground`,children:`Leader self-switching`}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:yf.map(e=>{let t=(a.mode??`propose`)===e.value;return(0,Z.jsx)(`button`,{type:`button`,title:e.hint,onClick:()=>m({leader:{...a,mode:e.value}}),className:t?`rounded-sm border border-primary bg-primary/10 px-2 py-0.5 text-[11px] text-foreground`:`rounded-sm border border-border bg-background px-2 py-0.5 text-[11px] text-muted-foreground hover:text-foreground`,"data-testid":`model-tier-leader-${e.value}`,children:e.label},e.value)})}),(0,Z.jsx)(`p`,{className:`text-[11px] leading-relaxed text-muted-foreground`,children:yf.find(e=>e.value===(a.mode??`propose`))?.hint}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 text-[11px]`,children:[(0,Z.jsxs)(`label`,{className:`flex items-center gap-1 text-muted-foreground`,children:[`dwell`,(0,Z.jsx)(`input`,{type:`number`,min:0,value:a.dwellTurns??``,onChange:e=>m({leader:{...a,dwellTurns:b(e.target.value)}}),placeholder:`6`,className:`w-14 rounded-sm border border-border bg-background px-1.5 py-0.5`,"data-testid":`model-tier-leader-dwell`}),`turns`]}),(0,Z.jsxs)(`label`,{className:`flex items-center gap-1 text-muted-foreground`,children:[`min saving $`,(0,Z.jsx)(`input`,{type:`number`,min:0,step:`0.01`,value:a.minSavingsUsd??``,onChange:e=>m({leader:{...a,minSavingsUsd:b(e.target.value)}}),placeholder:`0.10`,className:`w-16 rounded-sm border border-border bg-background px-1.5 py-0.5`})]}),(0,Z.jsxs)(`label`,{className:`flex items-center gap-1 text-muted-foreground`,children:[`ceiling`,(0,Z.jsxs)(`select`,{value:a.maxTier??``,onChange:e=>m({leader:{...a,maxTier:e.target.value||void 0}}),className:`rounded-sm border border-border bg-background px-1.5 py-0.5`,"data-testid":`model-tier-leader-ceiling`,children:[(0,Z.jsx)(`option`,{value:``,children:`none`}),o.map(e=>(0,Z.jsx)(`option`,{value:e,children:e},e))]})]})]}),(0,Z.jsx)(`p`,{className:`text-[10px] leading-relaxed text-muted-foreground`,children:`A switch invalidates the prompt cache, so a downgrade is refused unless the projected saving over the dwell window covers re-reading the conversation on the new model. A downgrade into a context window the session no longer fits is refused outright.`})]})]})}function Sf(){let e=(0,X.useRef)([]);return{setFieldRef:(0,X.useCallback)(t=>n=>{e.current[t]=n},[]),handleKeyDown:(0,X.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())},[])}}function Cf({models:e,onChange:t}){let{t:n}=H(),[r,i]=(0,X.useState)(!1),[a,o]=(0,X.useState)(``),[s,c]=(0,X.useState)([]),[l,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)(``),h=(0,X.useRef)(void 0),g=(0,X.useRef)(null),_=R(e=>e.wsUrl),v=(0,X.useCallback)(e=>{if(!e.trim()){c([]);return}u(!0);let t=V(_),n=t.on(`provider.models.search_result`,t=>{let n=t.payload;!n||n.query!==e.trim()||(c(n.matches??[]),u(!1))});t.searchProviderModels(e.trim(),8),setTimeout(()=>{n?.(),u(!1)},5e3)},[_]);(0,X.useEffect)(()=>{if(h.current&&clearTimeout(h.current),!a.trim()){c([]);return}return h.current=setTimeout(()=>v(a),250),()=>{h.current&&clearTimeout(h.current)}},[a,v]);let y=(0,X.useCallback)((n,r)=>{if(!n||e.some(e=>e.id===n))return;let a={id:n,name:r?.name??r?.modelId??n,...r?.maxOutput?{maxOutput:r.maxOutput}:{},capabilities:{...r?.contextWindow?{maxContext:r.contextWindow}:{},...r?.capabilities.includes(`tools`)?{tools:!0}:{},...r?.capabilities.includes(`vision`)?{vision:!0}:{},...r?.capabilities.includes(`reasoning`)?{reasoning:!0}:{}}};t([...e,a]),o(``),c([]),i(!1)},[e,t]),b=(0,X.useCallback)(n=>{t(e.filter(e=>e.id!==n))},[e,t]),x=(0,X.useCallback)(()=>{let e=p.trim();e&&(y(e),m(``),f(!1))},[p,y]);return(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground block`,children:n(`setup:screen.custom.models`)}),e.length>0&&(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map(e=>(0,Z.jsxs)(`div`,{className:G(`group inline-flex items-center gap-1 px-2 py-1 text-xs rounded`,`bg-accent/10 text-accent border border-accent/20`),title:e.name&&e.name!==e.id?`${e.name}\n${e.capabilities?.maxContext?`maxContext: ${e.capabilities.maxContext}`:``}${e.maxOutput?`\nmaxOutput: ${e.maxOutput}`:``}`:void 0,children:[(0,Z.jsx)(`span`,{className:`truncate max-w-[120px]`,children:e.name&&e.name!==e.id?e.name:e.id}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>b(e.id),className:`opacity-0 group-hover:opacity-100 transition-opacity text-muted-foreground hover:text-destructive`,children:(0,Z.jsx)(St,{className:`h-3 w-3`})})]},e.id))}),r?(0,Z.jsxs)(`div`,{className:`space-y-2 p-3 rounded border border-border/60 bg-muted/20`,children:[(0,Z.jsxs)(`div`,{className:`relative`,children:[(0,Z.jsx)(vn,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,Z.jsx)(Ya,{placeholder:n(`setup:screen.custom.modelSearchPlaceholder`),value:a,onChange:e=>o(e.target.value),className:`text-sm pl-8`,autoFocus:!0}),l&&(0,Z.jsx)(wt,{className:`absolute right-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 animate-spin text-muted-foreground`})]}),s.length>0&&(0,Z.jsx)(`div`,{className:`space-y-1 max-h-40 overflow-y-auto`,children:s.map(e=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>y(e.modelId,e),className:G(`w-full flex items-start gap-2 p-2 text-left text-xs rounded transition-colors`,`hover:bg-accent/10 border border-transparent hover:border-accent/30`),children:[(0,Z.jsx)(ui,{className:`h-3.5 w-3.5 mt-0.5 shrink-0 text-muted-foreground`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`font-medium block truncate`,children:e.name}),(0,Z.jsxs)(`span`,{className:`text-muted-foreground block`,children:[e.providerName,` · `,e.modelId,e.contextWindow?` · ${(e.contextWindow/1e3).toFixed(0)}K ctx`:``,e.maxOutput?` · ${e.maxOutput.toLocaleString()} out`:``]})]})]},`${e.providerId}\u0000${e.modelId}`))}),!l&&a.trim()&&s.length===0&&(0,Z.jsxs)(`div`,{className:`text-xs text-muted-foreground text-center py-2`,children:[n(`setup:screen.custom.noCatalogMatch`),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{f(!0),setTimeout(()=>g.current?.focus(),50)},className:`ml-1 text-accent underline underline-offset-2 hover:text-accent/80`,children:n(`setup:screen.custom.useCustomId`)})]}),d&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Ya,{ref:g,placeholder:n(`setup:screen.custom.customModelIdPlaceholder`),value:p,onChange:e=>m(e.target.value),className:`text-sm flex-1`,onKeyDown:e=>{e.key===`Enter`&&x()}}),(0,Z.jsxs)(Y,{type:`button`,size:`sm`,onClick:x,disabled:!p.trim(),children:[(0,Z.jsx)(ui,{className:`h-3.5 w-3.5 mr-1`}),n(`setup:screen.custom.add`)]})]}),(0,Z.jsx)(`div`,{className:`flex items-center gap-2 pt-1`,children:(0,Z.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>{i(!1),o(``),c([]),f(!1),m(``)},className:`text-xs`,children:n(`setup:screen.custom.cancel`)})})]}):(0,Z.jsxs)(Y,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>i(!0),className:`text-xs`,children:[(0,Z.jsx)(_i,{className:`h-3.5 w-3.5 mr-1`}),n(`setup:screen.custom.addModel`)]}),e.length>0&&(0,Z.jsxs)(`p`,{className:`text-[10px] text-muted-foreground`,children:[e.length,` `,e.length===1?n(`setup:screen.custom.modelSingular`):n(`setup:screen.custom.modelPlural`)]})]})}function wf({maskedKey:e,className:t}){let{t:n}=H(),[r,i]=(0,X.useState)(!1),a=(0,X.useCallback)(()=>{navigator.clipboard.writeText(e).then(()=>{i(!0),setTimeout(()=>i(!1),1500)})},[e]);return(0,Z.jsxs)(`div`,{className:G(`group flex items-center gap-1.5 rounded-md border border-border/50 bg-background/50 px-2 py-1 font-mono text-xs text-muted-foreground`,t),children:[(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate tracking-wide`,children:e}),(0,Z.jsx)(`button`,{type:`button`,onClick:a,className:`shrink-0 rounded p-0.5 text-muted-foreground/50 opacity-0 transition-all hover:text-foreground group-hover:opacity-100 focus:opacity-100`,title:r?`Copied`:`Copy key preview`,"aria-label":n(`activity:apikeydisplay.copyApiKeyToClipboard`),children:r?(0,Z.jsx)(ui,{className:`h-3 w-3 text-success`}):(0,Z.jsx)(oi,{className:`h-3 w-3`})})]})}var Tf={openrouter:{id:`openrouter`,name:`OpenRouter (Metered)`,family:`openai-compatible`,baseUrl:`https://openrouter.ai/api/v1`,envVars:[`OPENROUTER_API_KEY`],models:[`openai/gpt-4o`,`openai/gpt-4o-mini`,`anthropic/claude-sonnet-4-20250514`,`google/gemini-2.0-flash-001`,`meta-llama/llama-4-scout`,`deepseek/deepseek-chat`],usage:`metered-api`,docsUrl:`https://openrouter.ai/docs/quickstart`,autoDiscover:!0,requestPolicy:`openrouter`,catalog:{description:`All models via one key`,icon:`🔀`,color:`from-primary/12 to-primary/5 border-primary/30 hover:border-primary/50`,keyPlaceholder:`sk-or-...`}},"kimi-for-coding":{id:`kimi-for-coding`,name:`Kimi Code (Subscription)`,family:`openai-compatible`,baseUrl:`https://api.kimi.com/coding/v1`,envVars:[`KIMI_API_KEY`],models:[`kimi-for-coding`,`kimi-for-coding-highspeed`],quirks:{thinkingParam:`kimi-toggle`},usage:`subscription-interactive`,docsUrl:`https://www.kimi.com/code/docs/en/third-party-tools/other-coding-agents.html`,requestPolicy:`kimi`,catalog:{description:`Personal interactive coding with the Kimi Code subscription key. Generate the API key at kimi.com/code/console.`,icon:`🌙`,color:`from-info/12 to-info/5 border-info/30 hover:border-info/50`,keyPlaceholder:`sk-...`}},moonshotai:{id:`moonshotai`,name:`Moonshot Platform (Metered)`,family:`openai-compatible`,baseUrl:`https://api.moonshot.ai/v1`,envVars:[`MOONSHOT_API_KEY`],models:[`kimi-k2.7-code`,`kimi-k2.7-code-highspeed`],quirks:{thinkingParam:`always-on`},usage:`metered-api`,docsUrl:`https://platform.kimi.ai/docs/api/overview`,requestPolicy:`kimi`,catalog:{description:`Metered Moonshot Platform API — pay-as-you-go for automation, background work, and commercial use.`,icon:`🌑`,color:`from-info/12 to-info/5 border-info/30 hover:border-info/50`,keyPlaceholder:`sk-...`}},"zai-coding-plan":{id:`zai-coding-plan`,name:`Z.AI Coding Plan (Subscription)`,family:`openai-compatible`,baseUrl:`https://api.z.ai/api/coding/paas/v4`,envVars:[`ZHIPU_API_KEY`],models:[`glm-5.2`,`glm-5-turbo`,`glm-4.7`],quirks:{thinkingParam:`zai-glm`},usage:`subscription-interactive`,docsUrl:`https://docs.z.ai/devpack/quick-start`,requestPolicy:`zai`,catalog:{description:`Use your Z.AI Coding Plan subscription. Generate an API key from your Z.AI dashboard.`,icon:`🔷`,color:`from-primary/12 to-primary/5 border-primary/30 hover:border-primary/50`,keyPlaceholder:`...`}},zai:{id:`zai`,name:`Z.AI API (Metered)`,family:`openai-compatible`,baseUrl:`https://api.z.ai/api/paas/v4`,envVars:[`ZHIPU_API_KEY`],models:[`glm-4.7`,`glm-5-turbo`,`glm-5.2`],quirks:{thinkingParam:`zai-glm`},usage:`metered-api`,docsUrl:`https://docs.z.ai/guides/overview/quick-start`,requestPolicy:`zai`,catalog:{description:`Pay-as-you-go Z.AI GLM access for automation and commercial use.`,icon:`🔷`,color:`from-primary/12 to-primary/5 border-primary/30 hover:border-primary/50`,keyPlaceholder:`...`,referral:{code:`JQZ7TPPRA6`,reward:`Limited-time deal for GLM Coding Plan subscription`,url:`https://z.ai/subscribe?ic=JQZ7TPPRA6`}}},minimax:{id:`minimax`,name:`MiniMax Token Plan (Subscription)`,family:`openai-compatible`,baseUrl:`https://api.minimax.io/v1`,envVars:[`MINIMAX_API_KEY`],models:[`MiniMax-M3`,`MiniMax-M2.7`,`MiniMax-M2.5`,`MiniMax-M2`],usage:`subscription-interactive`,docsUrl:`https://platform.minimax.io/docs/api-reference/text-chat-openai`,catalog:{description:`Subscribe to one plan and unlock frontier coding, 1M context, and native multimodality.`,icon:`🔮`,color:`from-destructive/10 to-destructive/5 border-destructive/25 hover:border-destructive/45`,keyPlaceholder:`eyJ...`,referral:{code:`JrA4R9QAEn`,reward:`Friends get 10% off + Builder benefits. Referrers earn 10% cashback + community perks.`,url:`https://platform.minimax.io/subscribe/token-plan?code=JrA4R9QAEn&source=link`}}},mistral:{id:`mistral`,name:`Mistral AI API (Metered)`,family:`openai-compatible`,baseUrl:`https://api.mistral.ai/v1`,envVars:[`MISTRAL_API_KEY`],models:[`mistral-large-latest`,`codestral-latest`,`ministral-8b-latest`],usage:`metered-api`,docsUrl:`https://docs.mistral.ai/`,catalog:{description:`Mistral Large, Codestral, and Ministral — open-weight frontier models.`,icon:`🌬️`,color:`from-info/12 to-info/5 border-info/30 hover:border-info/50`,keyPlaceholder:`Vz8d...`}},deepseek:{id:`deepseek`,name:`DeepSeek API (Metered)`,family:`openai-compatible`,baseUrl:`https://api.deepseek.com`,envVars:[`DEEPSEEK_API_KEY`],models:[`deepseek-v4-flash`,`deepseek-v4-pro`],usage:`metered-api`,docsUrl:`https://api-docs.deepseek.com/`,requestPolicy:`deepseek`,catalog:{description:`High-performance reasoning at low cost`,icon:`🐋`,color:`from-primary/12 to-primary/5 border-primary/30 hover:border-primary/50`,keyPlaceholder:`sk-...`}},groq:{id:`groq`,name:`GroqCloud (Metered)`,family:`openai-compatible`,baseUrl:`https://api.groq.com/openai/v1`,envVars:[`GROQ_API_KEY`],models:[`llama-3.3-70b-versatile`,`llama-3.1-8b-instant`,`mixtral-8x7b-32768`,`gemma2-9b-it`],usage:`metered-api`,docsUrl:`https://console.groq.com/docs/api-reference`,requestPolicy:`groq`,catalog:{description:`Ultra-fast inference via LPU hardware — Llama, Mixtral, Gemma, and Qwen models.`,icon:`⚡`,color:`from-warning/12 to-warning/5 border-warning/30 hover:border-warning/50`,keyPlaceholder:`gsk_...`}},perplexity:{id:`perplexity`,name:`Perplexity Sonar API (Metered)`,family:`openai-compatible`,baseUrl:`https://api.perplexity.ai`,envVars:[`PERPLEXITY_API_KEY`],models:[`sonar-pro`,`sonar`,`sonar-reasoning-pro`,`sonar-reasoning`],usage:`metered-api`,docsUrl:`https://docs.perplexity.ai/`,requestPolicy:`perplexity`,catalog:{description:`Web-augmented chat models with built-in search and citations.`,icon:`🔍`,color:`from-info/12 to-info/5 border-info/30 hover:border-info/50`,keyPlaceholder:`pplx-...`}},"alibaba-token-plan":{id:`alibaba-token-plan`,name:`Alibaba Token Plan (Personal Edition)`,family:`openai-compatible`,baseUrl:`https://dashscope.aliyuncs.com/compatible-mode/v1`,envVars:[`ALIBABA_API_KEY`,`DASHSCOPE_API_KEY`],models:[`qwen3.8-max-preview`,`qwen3.7-max`,`qwen3.7-plus`,`qwen3.6-flash`,`glm-5.2`,`deepseek-v4-pro`,`wan2.7-image`,`wan2.7-image-pro`,`happyhorse-1.1-t2v`,`happyhorse-1.1-i2v`,`happyhorse-1.1-r2v`],customModels:{"qwen3.8-max-preview":{capabilities:{tools:!0,vision:!0,reasoning:!0,streaming:!0,systemPrompt:!0,jsonMode:!0,promptCache:!0,parallelTools:!0,cacheControl:`auto`}},"qwen3.7-max":{capabilities:{tools:!0,vision:!1,reasoning:!0,streaming:!0,systemPrompt:!0,jsonMode:!0,promptCache:!0,parallelTools:!0,cacheControl:`auto`}},"qwen3.7-plus":{capabilities:{tools:!0,vision:!0,reasoning:!0,streaming:!0,systemPrompt:!0,jsonMode:!0,promptCache:!0,parallelTools:!0,cacheControl:`auto`}},"qwen3.6-flash":{capabilities:{tools:!0,vision:!0,reasoning:!0,streaming:!0,systemPrompt:!0,jsonMode:!0,promptCache:!0,parallelTools:!0,cacheControl:`auto`}},"glm-5.2":{capabilities:{tools:!0,vision:!1,reasoning:!0,streaming:!0,systemPrompt:!0,jsonMode:!0,promptCache:!0,parallelTools:!0,cacheControl:`auto`}},"deepseek-v4-pro":{capabilities:{tools:!0,vision:!1,reasoning:!0,streaming:!0,systemPrompt:!0,jsonMode:!1,promptCache:!0,parallelTools:!0,cacheControl:`auto`}},"wan2.7-image":{capabilities:{tools:!1,vision:!0,reasoning:!1,streaming:!0,systemPrompt:!1,jsonMode:!1,promptCache:!1,parallelTools:!1,cacheControl:`none`}},"wan2.7-image-pro":{capabilities:{tools:!1,vision:!0,reasoning:!1,streaming:!0,systemPrompt:!1,jsonMode:!1,promptCache:!1,parallelTools:!1,cacheControl:`none`}},"happyhorse-1.1-t2v":{capabilities:{tools:!1,vision:!0,reasoning:!1,streaming:!0,systemPrompt:!1,jsonMode:!1,promptCache:!1,parallelTools:!1,cacheControl:`none`}},"happyhorse-1.1-i2v":{capabilities:{tools:!1,vision:!0,reasoning:!1,streaming:!0,systemPrompt:!1,jsonMode:!1,promptCache:!1,parallelTools:!1,cacheControl:`none`}},"happyhorse-1.1-r2v":{capabilities:{tools:!1,vision:!0,reasoning:!1,streaming:!0,systemPrompt:!1,jsonMode:!1,promptCache:!1,parallelTools:!1,cacheControl:`none`}}},usage:`subscription-interactive`,docsUrl:`https://www.alibabacloud.com/help/en/model-studio/token-plan-personal-overview`,requestPolicy:`alibaba`,catalog:{description:`Monthly Credits subscription for Qwen, DeepSeek, GLM, Wanx image, and HappyHorse video models.`,icon:`☁️`,color:`from-warning/12 to-warning/5 border-warning/30 hover:border-warning/50`,keyPlaceholder:`sk-...`}}};Object.keys(Tf);var Ef=[{id:`openai`,name:`OpenAI`,family:`openai`,envVars:[`OPENAI_API_KEY`],models:[],usage:`metered-api`,docsUrl:`https://platform.openai.com/api-keys`,catalog:{description:`GPT, o-series, and Codex models`,icon:`🤖`,color:`from-success/12 to-success/5 border-success/30 hover:border-success/50`,keyPlaceholder:`sk-...`}},{id:`anthropic`,name:`Anthropic`,family:`anthropic`,envVars:[`ANTHROPIC_API_KEY`],models:[],usage:`metered-api`,docsUrl:`https://console.anthropic.com/settings/keys`,catalog:{description:`Claude model access`,icon:`🧠`,color:`from-warning/12 to-warning/5 border-warning/30 hover:border-warning/50`,keyPlaceholder:`sk-ant-...`}},{id:`google`,name:`Google`,family:`google`,envVars:[`GOOGLE_GENERATIVE_AI_API_KEY`,`GEMINI_API_KEY`],models:[],usage:`metered-api`,docsUrl:`https://aistudio.google.com/apikey`,catalog:{description:`Gemini Pro, Flash, and Nano`,icon:`✨`,color:`from-info/12 to-info/5 border-info/30 hover:border-info/50`,keyPlaceholder:`AIza...`}},{id:`openai-codex`,name:`OpenAI Codex OAuth`,family:`openai-codex`,envVars:[],models:[],usage:`subscription-interactive`,docsUrl:`https://developers.openai.com/codex/`},{id:`anthropic-oauth`,name:`Anthropic OAuth`,family:`anthropic-oauth`,envVars:[],models:[],usage:`subscription-interactive`,docsUrl:`https://docs.anthropic.com/`},{id:`github-copilot`,name:`GitHub Copilot`,family:`github-copilot`,envVars:[],models:[],usage:`subscription-interactive`,docsUrl:`https://docs.github.com/en/copilot`},{id:`opencode-go`,name:`OpenCode Go`,family:`openai-compatible`,baseUrl:`https://opencode.ai/zen/go/v1`,envVars:[`OPENCODE_API_KEY`],models:[],usage:`subscription-interactive`,docsUrl:`https://opencode.ai/go?ref=6VZAER87H4`,catalog:{description:`Global hosted API for 75+ LLM providers — stable access from US, EU, and Singapore`,icon:`🌍`,color:`from-success/12 to-success/5 border-success/30 hover:border-success/50`,keyPlaceholder:`oc-...`,referral:{code:`6VZAER87H4`,reward:`Support the project by signing up with this referral link`,url:`https://opencode.ai/go?ref=6VZAER87H4`}}},{id:`xai`,name:`xAI`,family:`openai-compatible`,baseUrl:`https://api.x.ai/v1`,envVars:[`XAI_API_KEY`],models:[],usage:`metered-api`,docsUrl:`https://docs.x.ai/`,requestPolicy:`xai`},{id:`ai-gateway`,name:`Vercel AI Gateway`,family:`openai-compatible`,baseUrl:`https://ai-gateway.vercel.sh/v1`,discoveryOnlyBaseUrl:!0,envVars:[`AI_GATEWAY_API_KEY`],models:[],usage:`metered-api`,docsUrl:`https://vercel.com/docs/ai-gateway`,autoDiscover:!0,catalog:{description:`Every model behind one key — routed by Vercel AI Gateway`,icon:`▲`,color:`from-primary/12 to-primary/5 border-primary/30 hover:border-primary/50`,keyPlaceholder:`vck_...`}}],Df=[{id:`omniroute`,name:`OmniRoute`,family:`openai-compatible`,baseUrl:`http://localhost:20128/v1`,envVars:[],models:[],usage:`local`,quirks:{stripThinkTags:!0},autoDiscover:!0,local:{noAuth:!0,hint:`WrongStack local gateway · port 20128 · no key · auto-discovers models`}},{id:`ollama`,name:`Ollama`,family:`openai-compatible`,baseUrl:`http://localhost:11434/v1`,envVars:[],models:[],usage:`local`,docsUrl:`https://ollama.com`,local:{noAuth:!0,hint:`ollama.com · port 11434 · no key`}},{id:`vllm`,name:`vLLM`,family:`openai-compatible`,baseUrl:`http://localhost:8000/v1`,envVars:[],models:[],usage:`local`,docsUrl:`https://docs.vllm.ai`,local:{noAuth:!1,hint:`docs.vllm.ai · port 8000 · optional key`}},{id:`lmstudio`,name:`LM Studio`,family:`openai-compatible`,baseUrl:`http://localhost:1234/v1`,envVars:[],models:[],usage:`local`,docsUrl:`https://lmstudio.ai`,local:{noAuth:!1,hint:`lmstudio.ai · port 1234 · optional key`}}],Of=Object.fromEntries([...Ef,...Object.values(Tf),...Df].map(e=>[e.id,e]));function kf(){return Df.map(e=>{if(!e.baseUrl||!e.local)throw Error(`Local provider definition is incomplete: ${e.id}`);return{id:e.id,label:e.name,defaultBaseUrl:e.baseUrl,noAuth:e.local.noAuth,hint:e.local.hint}})}function Af(){return Object.values(Of).filter(e=>e.catalog!==void 0).map(e=>({id:e.id,name:e.name,family:e.family,description:e.catalog.description,icon:e.catalog.icon,color:e.catalog.color,keyPlaceholder:e.catalog.keyPlaceholder,...e.docsUrl?{docsUrl:e.docsUrl}:{},...e.catalog.referral?{referral:{...e.catalog.referral}}:{}}))}var jf=`openai-compatible`,Mf=kf(),Nf=[{kind:`chatgpt`,label:`ChatGPT`,subtitle:`Plus / Pro / Team → openai-codex`,icon:(0,Z.jsx)(et,{className:`h-5 w-5`})},{kind:`claude`,label:`Claude`,subtitle:`Pro / Max → anthropic-oauth`,icon:(0,Z.jsx)(jr,{className:`h-5 w-5`})},{kind:`copilot`,label:`GitHub Copilot`,subtitle:`Copilot → github-copilot`,icon:(0,Z.jsx)(on,{className:`h-5 w-5`})}],Pf=[`awaiting_browser`,`awaiting_code`,`exchanging`,`fetching_models`];function Ff({ws:e,savedByKind:t}){let{t:n}=H(),[r,i]=(0,X.useState)({chatgpt:{phase:`idle`},claude:{phase:`idle`},copilot:{phase:`idle`}}),[a,o]=(0,X.useState)(``),[s,c]=(0,X.useState)(null),[l,u]=(0,X.useState)(null),[d,f]=(0,X.useState)(``),[p,m]=(0,X.useState)(null);(0,X.useEffect)(()=>{let t=e.on(`auth.oauth.status`,e=>{if(e.type!==`auth.oauth.status`)return;let t=e.payload;i(e=>({...e,[t.kind]:{...t}})),t.phase===`success`?(B.success(t.message??U.t(`settings:oauth.signedInToast`,{provider:t.providerId??t.kind})),c(null),o(``),u(null),f(``)):t.phase===`error`&&B.error(t.message??U.t(`settings:oauth.signInFailed`))});return()=>t?.()},[e]);let h=(0,X.useCallback)(t=>{i(e=>({...e,[t]:{phase:t===`copilot`?`awaiting_code`:`awaiting_browser`}})),e.startOAuth(t)},[e]),g=(0,X.useCallback)((t,n)=>{i(e=>({...e,[t]:{phase:t===`copilot`?`awaiting_code`:`awaiting_browser`}})),e.startOAuth(t,n)},[e]),_=(0,X.useCallback)(t=>{let n=d.trim();n&&(i(e=>({...e,[t]:{phase:t===`copilot`?`awaiting_code`:`awaiting_browser`}})),e.startOAuth(t,n),u(null),f(``))},[e,d]),v=(0,X.useCallback)(t=>{e.cancelOAuth(t),i(e=>({...e,[t]:{phase:`idle`}})),c(null)},[e]),y=(0,X.useCallback)(t=>{let n=a.trim();n&&(e.submitOAuthCode(t,n),i(e=>({...e,[t]:{...e[t],phase:`exchanging`}})))},[a,e]),b=t??{};return(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(`div`,{className:`rounded-md border border-warning/30 bg-warning/5 p-3`,children:(0,Z.jsx)(`p`,{className:`text-xs leading-5 text-warning`,children:n(`settings:oauth.termsWarning`)})}),(0,Z.jsx)(`div`,{className:`grid grid-cols-1 gap-2 lg:grid-cols-3`,children:Nf.map(e=>{let t=r[e.kind],i=Pf.includes(t.phase),x=b[e.kind],S=x?.length??0,C=p===e.kind;return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-border bg-background/70 p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 lg:flex-col lg:items-stretch`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`font-medium`,children:e.label}),(0,Z.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.subtitle})]})]}),i?(0,Z.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>v(e.kind),className:`shrink-0 lg:w-full`,children:n(`common:action.cancel`)}):(0,Z.jsx)(Y,{size:`sm`,onClick:()=>h(e.kind),className:`shrink-0 lg:w-full`,children:n(`settings:oauth.signIn`)})]}),t.phase===`awaiting_browser`&&(0,Z.jsxs)(`div`,{className:`mt-3 space-y-2 border-t pt-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,Z.jsx)(wt,{className:`h-4 w-4 animate-spin text-muted-foreground`}),(0,Z.jsx)(`span`,{children:n(`settings:oauth.waitingBrowser`)})]}),t.authorizeUrl&&(0,Z.jsxs)(Y,{size:`sm`,variant:`outline`,onClick:()=>window.open(t.authorizeUrl,`_blank`,`noopener,noreferrer`),children:[(0,Z.jsx)(ur,{className:`h-3.5 w-3.5 mr-1`}),n(`settings:oauth.openSignIn`)]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`button`,{type:`button`,className:`text-xs text-muted-foreground underline`,onClick:()=>c(s===e.kind?null:e.kind),children:t.bound===!1?n(`settings:oauth.pasteLoopbackBusy`):n(`settings:oauth.pasteCantReach`)}),s===e.kind&&(0,Z.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,Z.jsx)(Ya,{placeholder:n(`activity:oauth.httpLocalhostCallbackCode`),value:a,onChange:e=>o(e.target.value),className:`font-mono text-xs`,onKeyDown:t=>{t.key===`Enter`&&y(e.kind)}}),(0,Z.jsx)(Y,{size:`sm`,onClick:()=>y(e.kind),disabled:!a.trim(),children:n(`settings:oauth.submit`)})]})]})]}),t.phase===`awaiting_code`&&(0,Z.jsxs)(`div`,{className:`mt-3 space-y-2 border-t pt-3`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(`settings:oauth.enterCode`)}),(0,Z.jsx)(`div`,{className:`font-mono text-2xl font-bold tracking-widest`,children:t.userCode??`…`}),t.verificationUri&&(0,Z.jsxs)(Y,{size:`sm`,variant:`outline`,onClick:()=>window.open(t.verificationUri,`_blank`,`noopener,noreferrer`),children:[(0,Z.jsx)(ur,{className:`h-3.5 w-3.5 mr-1`}),n(`settings:oauth.openVerification`)]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,Z.jsx)(wt,{className:`h-3.5 w-3.5 animate-spin`}),(0,Z.jsx)(`span`,{children:n(`settings:oauth.waitingCode`)})]})]}),(t.phase===`exchanging`||t.phase===`fetching_models`)&&(0,Z.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 border-t pt-3 text-sm`,children:[(0,Z.jsx)(wt,{className:`h-4 w-4 animate-spin text-muted-foreground`}),(0,Z.jsx)(`span`,{children:t.phase===`exchanging`?n(`settings:oauth.exchanging`):n(`settings:oauth.fetchingModels`)})]}),t.phase===`success`&&(0,Z.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 border-t pt-3 text-sm text-success`,children:[(0,Z.jsx)($t,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:t.message??n(`settings:oauth.signedIn`)})]}),t.phase===`error`&&t.message&&(0,Z.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 border-t pt-3 text-sm text-destructive`,children:[(0,Z.jsx)(Rr,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:t.message})]}),S>0&&!i&&(0,Z.jsxs)(`div`,{className:`mt-3 border-t pt-3`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>m(C?null:e.kind),className:`flex w-full items-center justify-between text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Z.jsx)(Qr,{className:`h-3.5 w-3.5`}),(0,Z.jsx)(`span`,{children:n(`settings:oauth.accountCount`,{count:S})})]}),(0,Z.jsx)(`span`,{className:`text-[10px]`,children:C?`▲`:`▼`})]}),C&&x&&(0,Z.jsxs)(`div`,{className:`mt-2 space-y-1.5`,children:[x.map(t=>(0,Z.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-border/60 bg-muted/20 px-2.5 py-1.5`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs`,children:t.id}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[t.hasActiveKey?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-success`,children:[(0,Z.jsx)($t,{className:`h-3 w-3`}),n(`settings:oauth.active`)]}):(0,Z.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:n(`settings:oauth.inactive`)}),(0,Z.jsxs)(Y,{size:`sm`,variant:`ghost`,onClick:()=>g(e.kind,t.id),className:`h-6 px-1.5 text-[11px]`,title:n(`settings:oauth.retryLogin`),children:[(0,Z.jsx)(xi,{className:`h-3 w-3 mr-0.5`}),n(`settings:oauth.retry`)]})]})]},t.id)),(0,Z.jsx)(`div`,{className:`pt-1`,children:l===e.kind?(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(Ya,{autoFocus:!0,placeholder:n(`settings:oauth.aliasPlaceholder`,{default:e.kind===`chatgpt`?`openai-codex-1`:`${e.kind}-2`}),value:d,onChange:e=>f(e.target.value),className:`text-xs font-mono`,onKeyDown:t=>{t.key===`Enter`&&_(e.kind)}}),(0,Z.jsx)(Y,{size:`sm`,onClick:()=>_(e.kind),disabled:!d.trim(),children:n(`settings:oauth.signIn`)}),(0,Z.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>{u(null),f(``)},children:n(`common:action.cancel`)})]}):(0,Z.jsxs)(Y,{size:`sm`,variant:`outline`,onClick:()=>u(e.kind),className:`w-full text-xs`,children:[(0,Z.jsx)(_i,{className:`h-3.5 w-3.5 mr-1`}),n(`settings:oauth.newAccount`)]})})]})]}),S===0&&!i&&(0,Z.jsx)(`div`,{className:`mt-3 border-t pt-3`,children:l===e.kind?(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(Ya,{autoFocus:!0,placeholder:n(`settings:oauth.aliasPlaceholder`,{default:e.kind===`chatgpt`?`openai-codex-1`:`${e.kind}-2`}),value:d,onChange:e=>f(e.target.value),className:`text-xs font-mono`,onKeyDown:t=>{t.key===`Enter`&&_(e.kind)}}),(0,Z.jsx)(Y,{size:`sm`,onClick:()=>_(e.kind),disabled:!d.trim(),children:n(`settings:oauth.signIn`)}),(0,Z.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>{u(null),f(``)},children:n(`common:action.cancel`)})]}):(0,Z.jsxs)(Y,{size:`sm`,variant:`outline`,onClick:()=>u(e.kind),className:`w-full text-xs`,children:[(0,Z.jsx)(_i,{className:`h-3.5 w-3.5 mr-1`}),n(`settings:oauth.newAccount`)]})})]},e.kind)})})]})}function If({open:e,providerId:t,modelCount:n,onConfirm:r,onCancel:i}){let a=(0,X.useRef)(null),{t:o}=H();return(0,X.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,Z.jsx)(Ja,{open:e,onOpenChange:e=>{e||i()},children:(0,Z.jsxs)(Ga,{className:`sm:max-w-md border-warning/50`,ref:a,tabIndex:-1,"data-clear-allowlist-dialog":!0,children:[(0,Z.jsxs)(Ua,{children:[(0,Z.jsxs)(Ka,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Kr,{className:`h-5 w-5 text-warning`}),o(`settings:allowlist.title`)]}),(0,Z.jsx)(qa,{children:o(`settings:allowlist.body`,{count:n,provider:t})})]}),(0,Z.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,Z.jsxs)(Wa,{className:`gap-2 sm:gap-2 flex-wrap`,children:[(0,Z.jsxs)(Y,{variant:`outline`,size:`sm`,onClick:i,title:o(`settings:allowlist.keepTitle`),"data-action":`cancel`,children:[o(`common:action.cancel`),` `,(0,Z.jsx)(`kbd`,{className:`ml-1 text-[10px] border rounded px-1 bg-background`,children:`Esc`})]}),(0,Z.jsxs)(Y,{variant:`destructive`,size:`sm`,onClick:r,title:o(`settings:allowlist.clearTitle`),"data-action":`confirm`,children:[o(`settings:allowlist.clear`),` `,(0,Z.jsx)(`kbd`,{className:`ml-1 text-[10px] border rounded px-1 bg-background/80`,children:`↵`})]})]})]})})}function Lf({ws:e,onSelect:t,onClose:n}){let{t:r}=H(),[i,a]=(0,X.useState)(``),[o,s]=(0,X.useState)([]),[c,l]=(0,X.useState)(!1),u=(0,X.useRef)(null),d=(0,X.useRef)(``);(0,X.useEffect)(()=>e.on(`provider.models.search_result`,e=>{if(e.type!==`provider.models.search_result`)return;let t=e.payload;(t.query===void 0||t.query===d.current)&&(s(t.matches??[]),l(!1))}),[e]);let f=(0,X.useCallback)(t=>{if(!t.trim()){s([]),d.current=``;return}d.current=t,l(!0),e.searchProviderModels(t,8)},[e]);(0,X.useEffect)(()=>(u.current&&clearTimeout(u.current),u.current=setTimeout(()=>f(i),300),()=>{u.current&&clearTimeout(u.current)}),[i,f]);let p=(0,X.useCallback)(e=>{let n={name:e.name,...e.description?{description:e.description}:{},...e.releaseDate?{release_date:e.releaseDate}:{},...e.contextWindow||e.maxOutput?{limit:{...e.contextWindow?{context:e.contextWindow}:{},...e.maxOutput?{output:e.maxOutput}:{}}}:{},...e.inputCost||e.outputCost?{cost:{...e.inputCost?{input:e.inputCost}:{},...e.outputCost?{output:e.outputCost}:{}}}:{},...e.capabilities.length>0?{tool_call:e.capabilities.includes(`tools`),reasoning:e.capabilities.includes(`reasoning`),...e.capabilities.includes(`vision`)?{modalities:{input:[`text`,`image`]}}:{}}:{}};t(e.modelId,n)},[t]);return(0,Z.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`absolute inset-0 bg-black/50`,onClick:n,"aria-label":r(`common:action.close`)}),(0,Z.jsxs)(`div`,{className:`relative max-h-[80vh] w-full max-w-xl overflow-y-auto rounded-lg border border-border bg-background p-4 shadow-lg`,children:[(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:r(`settings:providerModels.catalogSearchTitle`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:n,className:`text-muted-foreground hover:text-foreground`,children:(0,Z.jsx)(St,{className:`h-4 w-4`})})]}),(0,Z.jsxs)(`div`,{className:`relative mb-3`,children:[(0,Z.jsx)(vn,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground/60`}),(0,Z.jsx)(`input`,{type:`text`,value:i,onChange:e=>a(e.target.value),placeholder:r(`settings:providerModels.catalogSearchPlaceholder`),className:`h-10 w-full rounded-md border border-border bg-background pl-9 pr-3 text-sm focus:outline-none focus:ring-1 focus:ring-ring`})]}),c?(0,Z.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,Z.jsx)(wt,{className:`h-5 w-5 animate-spin text-muted-foreground`})}):o.length>0?(0,Z.jsx)(`div`,{className:`space-y-1.5`,children:o.map(e=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>p(e),className:`block w-full rounded-md border border-border/60 p-2.5 text-left transition-colors hover:border-primary/40 hover:bg-primary/5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`span`,{className:`font-mono text-sm font-medium text-foreground`,children:e.modelId}),e.name!==e.modelId&&(0,Z.jsx)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:e.name})]}),(0,Z.jsx)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground`,children:e.providerName})]}),e.description&&(0,Z.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-xs text-muted-foreground`,children:e.description}),(0,Z.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:[e.contextWindow?(0,Z.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:e.contextWindow>=1e6?`${(e.contextWindow/1e6).toFixed(1)}M ctx`:`${Math.round(e.contextWindow/1e3)}K ctx`}):null,e.capabilities.map(e=>(0,Z.jsx)(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 text-[10px] text-primary`,children:e},e))]})]},`${e.providerId}:${e.modelId}`))}):i.trim()?(0,Z.jsx)(`p`,{className:`py-8 text-center text-sm text-muted-foreground`,children:r(`settings:providerModels.noResults`)}):(0,Z.jsx)(`p`,{className:`py-8 text-center text-sm text-muted-foreground`,children:r(`settings:providerModels.typeToSearch`)})]})]})}var Rf=new Set([`__proto__`,`constructor`,`prototype`,`__defineGetter__`,`__defineSetter__`,`__lookupGetter__`,`__lookupSetter__`]);`document`in globalThis&&ii({jitless:!0});var zf=[`text`,`image`,`audio`,`video`,`pdf`],Bf=[`none`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],Vf=Hr().int().nonnegative(),Hf=Hr().finite(),Uf=Zn({context:Vf.optional(),output:Vf.optional(),input:Vf.optional()}),Wf=Zn({input:Hf.optional(),output:Hf.optional(),cache_read:Hf.optional(),cache_write:Hf.optional(),cache_write_5m:Hf.optional(),cache_write_1h:Hf.optional(),context_over_200k:Hf.optional(),reasoning:Hf.optional(),input_audio:Hf.optional(),output_audio:Hf.optional()}),Gf=Zn({input:Hn(rr().min(1)).optional(),output:Hn(rr().min(1)).optional()}),Kf=pr([Zn({type:hi(`toggle`)}),Zn({type:hi(`effort`),values:Hn(Ar(Bf)).optional()}),Zn({type:hi(`budget_tokens`),min:Hr().optional(),max:Hr().optional()})]),qf=e=>({message:`${e} id is a forbidden prototype-pollution key`}),Jf=Zn({id:rr().min(1).refine(e=>!Rf.has(e),qf(`Model`)),name:rr().min(1),description:rr().optional(),family:rr().optional(),attachment:$r().optional(),reasoning:$r().optional(),reasoning_options:pr([Kf,Hn(Kf)]).optional(),interleaved:pr([$r(),Zn({field:rr().optional()})]).optional(),tool_call:$r().optional(),structured_output:$r().optional(),temperature:$r().optional(),knowledge:rr().optional(),release_date:rr().optional(),last_updated:rr().optional(),open_weights:$r().optional(),modalities:Gf.optional(),cost:Wf.optional(),limit:Uf.optional(),status:rr().optional(),experimental:$r().optional()}),Yf=Zn({id:rr().min(1).refine(e=>!Rf.has(e),qf(`Provider`)),name:rr().min(1),env:Hn(rr()).optional(),npm:rr().optional(),api:rr().optional(),doc:rr().optional(),models:Si(rr(),Jf)});Si(rr(),Yf);function Xf(e,t){let n=t.limit,r=t.cost,i=t.modalities;return{id:e,name:t.name??``,description:t.description??``,family:t.family??``,limitContext:n?.context==null?``:String(n.context),limitOutput:n?.output==null?``:String(n.output),limitInput:n?.input==null?``:String(n.input),costInput:r?.input==null?``:String(r.input),costOutput:r?.output==null?``:String(r.output),inputModalities:Array.isArray(i?.input)?i.input:[],outputModalities:Array.isArray(i?.output)?i.output:[],toolCall:t.tool_call===!0,reasoning:t.reasoning===!0,temperature:t.temperature===!0,attachment:t.attachment===!0,structuredOutput:t.structured_output===!0,openWeights:t.open_weights===!0,releaseDate:t.release_date??``,lastUpdated:t.last_updated??``,knowledge:t.knowledge??``}}function Zf(e,t){let n={...t};e.name&&(n.name=e.name),e.description&&(n.description=e.description),e.family&&(n.family=e.family),e.knowledge&&(n.knowledge=e.knowledge);let r={};if(e.limitContext){let t=Number(e.limitContext);Number.isFinite(t)&&t>=0&&(r.context=t)}if(e.limitOutput){let t=Number(e.limitOutput);Number.isFinite(t)&&t>=0&&(r.output=t)}if(e.limitInput){let t=Number(e.limitInput);Number.isFinite(t)&&t>=0&&(r.input=t)}Object.keys(r).length>0&&(n.limit={...t.limit??{},...r});let i={};if(e.costInput){let t=Number(e.costInput);Number.isFinite(t)&&t>=0&&(i.input=t)}if(e.costOutput){let t=Number(e.costOutput);Number.isFinite(t)&&t>=0&&(i.output=t)}Object.keys(i).length>0&&(n.cost={...t.cost??{},...i});let a={};e.inputModalities.length>0&&(a.input=e.inputModalities),e.outputModalities.length>0&&(a.output=e.outputModalities),Object.keys(a).length>0&&(n.modalities={...t.modalities??{},...a});for(let[r,i]of[[`toolCall`,`tool_call`],[`reasoning`,`reasoning`],[`temperature`,`temperature`],[`attachment`,`attachment`],[`structuredOutput`,`structured_output`],[`openWeights`,`open_weights`]]){let a=t[i]===!0;e[r]!==a&&(n[i]=e[r])}return e.releaseDate&&(n.release_date=e.releaseDate),e.lastUpdated&&(n.last_updated=e.lastUpdated),n}var Qf=[{key:`toolCall`,labelKey:`settings:modelSchema.capToolCall`},{key:`reasoning`,labelKey:`settings:modelSchema.capReasoning`},{key:`temperature`,labelKey:`settings:modelSchema.capTemperature`},{key:`attachment`,labelKey:`settings:modelSchema.capAttachment`},{key:`structuredOutput`,labelKey:`settings:modelSchema.capStructuredOutput`},{key:`openWeights`,labelKey:`settings:modelSchema.capOpenWeights`}];function $f({providerId:e,modelId:t,initialModelsDev:n,onSave:r,onCancel:i}){let{t:a}=H(),[o,s]=(0,X.useState)(!1),[c,l]=(0,X.useState)(()=>Xf(t,n)),[u,d]=(0,X.useState)([]),[f,p]=(0,X.useState)(JSON.stringify({...n,...t?{id:t}:{}},null,2)),[m,h]=(0,X.useState)(null),g=(0,X.useCallback)((e,t)=>{l(n=>({...n,[e]:t}))},[]),_=(0,X.useCallback)((e,t)=>{l(n=>{let r=n[e];return{...n,[e]:r.includes(t)?r.filter(e=>e!==t):[...r,t]}})},[]),v=(0,X.useCallback)(()=>{let e=Zf(c,n),i=Jf.safeParse({...e,id:c.id||t});if(!i.success){d(i.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`));return}d([]),r(c.id||t,e)},[c,n,t,r]),y=(0,X.useCallback)(()=>{try{let e=JSON.parse(f),n=Jf.safeParse({...e,id:t||e.id});if(!n.success){h(n.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`; `));return}let{id:i,...a}=n.data;h(null),r(t||n.data.id,a)}catch(e){h(e instanceof Error?e.message:String(e))}},[f,t,r]),b=`h-8 w-full rounded-md border border-border bg-background px-2.5 text-sm focus:outline-none focus:ring-1 focus:ring-ring`,x=`mb-1 block text-[11px] font-medium uppercase tracking-wide text-muted-foreground`;return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`flex gap-1 border-b border-border/50`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>s(!1),className:G(`border-b-2 px-3 py-1 text-xs font-medium transition-colors`,o?`border-transparent text-muted-foreground hover:text-foreground`:`border-primary text-primary`),children:a(`settings:providerModels.tabForm`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>s(!0),className:G(`border-b-2 px-3 py-1 text-xs font-medium transition-colors`,o?`border-primary text-primary`:`border-transparent text-muted-foreground hover:text-foreground`),children:a(`settings:providerModels.tabRawJson`)})]}),o?(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`textarea`,{value:f,onChange:e=>p(e.target.value),rows:16,className:`w-full rounded-md border border-border bg-muted/20 p-2 font-mono text-xs`,spellCheck:!1}),m&&(0,Z.jsx)(`p`,{className:`text-xs text-destructive`,children:m})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,Z.jsx)(`legend`,{className:`text-xs font-semibold text-foreground`,children:a(`settings:providerModels.sectionIdentity`)}),!t&&(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:x,htmlFor:`mse-id`,children:`ID`}),(0,Z.jsx)(`input`,{id:`mse-id`,className:b,value:c.id,onChange:e=>g(`id`,e.target.value),placeholder:a(`activity:modelSchema.modelId`)})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:x,htmlFor:`mse-name`,children:a(`settings:providerModels.fieldName`)}),(0,Z.jsx)(`input`,{id:`mse-name`,className:b,value:c.name,onChange:e=>g(`name`,e.target.value)})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:x,htmlFor:`mse-desc`,children:a(`settings:providerModels.fieldDescription`)}),(0,Z.jsx)(`input`,{id:`mse-desc`,className:b,value:c.description,onChange:e=>g(`description`,e.target.value)})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:x,htmlFor:`mse-family`,children:a(`settings:providerModels.fieldFamily`)}),(0,Z.jsx)(`input`,{id:`mse-family`,className:b,value:c.family,onChange:e=>g(`family`,e.target.value)})]})]}),(0,Z.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,Z.jsx)(`legend`,{className:`text-xs font-semibold text-foreground`,children:a(`settings:providerModels.sectionLimits`)}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:x,htmlFor:`mse-ctx`,children:a(`settings:providerModels.fieldContext`)}),(0,Z.jsx)(`input`,{id:`mse-ctx`,type:`number`,className:b,value:c.limitContext,onChange:e=>g(`limitContext`,e.target.value)})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:x,htmlFor:`mse-out`,children:a(`settings:providerModels.fieldOutput`)}),(0,Z.jsx)(`input`,{id:`mse-out`,type:`number`,className:b,value:c.limitOutput,onChange:e=>g(`limitOutput`,e.target.value)})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:x,htmlFor:`mse-inlim`,children:a(`settings:providerModels.fieldInputLimit`)}),(0,Z.jsx)(`input`,{id:`mse-inlim`,type:`number`,className:b,value:c.limitInput,onChange:e=>g(`limitInput`,e.target.value)})]})]})]}),(0,Z.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,Z.jsx)(`legend`,{className:`text-xs font-semibold text-foreground`,children:a(`settings:providerModels.sectionPricing`)}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:x,htmlFor:`mse-costin`,children:a(`settings:providerModels.fieldCostInput`)}),(0,Z.jsx)(`input`,{id:`mse-costin`,type:`number`,step:`0.01`,className:b,value:c.costInput,onChange:e=>g(`costInput`,e.target.value)})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:x,htmlFor:`mse-costout`,children:a(`settings:providerModels.fieldCostOutput`)}),(0,Z.jsx)(`input`,{id:`mse-costout`,type:`number`,step:`0.01`,className:b,value:c.costOutput,onChange:e=>g(`costOutput`,e.target.value)})]})]})]}),(0,Z.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,Z.jsx)(`legend`,{className:`text-xs font-semibold text-foreground`,children:a(`settings:providerModels.sectionModalities`)}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`span`,{className:x,children:a(`settings:providerModels.fieldInputModalities`)}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:zf.map(e=>{let t=c.inputModalities.includes(e);return(0,Z.jsx)(`button`,{type:`button`,onClick:()=>_(`inputModalities`,e),className:G(`rounded-md border px-2 py-1 text-xs transition-colors`,t?`border-primary bg-primary/10 text-primary`:`border-border text-muted-foreground hover:border-primary/30`),children:e},`in-mod-${e}`)})})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`span`,{className:x,children:a(`settings:providerModels.fieldOutputModalities`)}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:zf.map(e=>{let t=c.outputModalities.includes(e);return(0,Z.jsx)(`button`,{type:`button`,onClick:()=>_(`outputModalities`,e),className:G(`rounded-md border px-2 py-1 text-xs transition-colors`,t?`border-primary bg-primary/10 text-primary`:`border-border text-muted-foreground hover:border-primary/30`),children:e},`out-mod-${e}`)})})]})]}),(0,Z.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,Z.jsx)(`legend`,{className:`text-xs font-semibold text-foreground`,children:a(`settings:providerModels.sectionCapabilities`)}),(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:Qf.map(({key:e,labelKey:t})=>(0,Z.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`h-4 w-4 rounded border-border`,checked:c[e],onChange:t=>g(e,t.target.checked)}),a(t)]},String(e)))})]}),(0,Z.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,Z.jsx)(`legend`,{className:`text-xs font-semibold text-foreground`,children:a(`settings:providerModels.sectionDates`)}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:x,htmlFor:`mse-release`,children:a(`settings:providerModels.fieldReleaseDate`)}),(0,Z.jsx)(`input`,{id:`mse-release`,type:`date`,className:b,value:c.releaseDate,onChange:e=>g(`releaseDate`,e.target.value)})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:x,htmlFor:`mse-updated`,children:a(`settings:providerModels.fieldLastUpdated`)}),(0,Z.jsx)(`input`,{id:`mse-updated`,type:`date`,className:b,value:c.lastUpdated,onChange:e=>g(`lastUpdated`,e.target.value)})]})]})]}),u.length>0&&(0,Z.jsx)(`div`,{className:`rounded-md border border-destructive/30 bg-destructive/5 p-2`,children:(0,Z.jsx)(`ul`,{className:`space-y-0.5 text-xs text-destructive`,children:u.map((e,t)=>(0,Z.jsx)(`li`,{children:e},t))})})]}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-border/50 pt-3`,children:[(0,Z.jsxs)(Y,{type:`button`,variant:`ghost`,size:`sm`,onClick:i,className:`h-8 gap-1.5 text-xs`,children:[(0,Z.jsx)(St,{className:`h-3.5 w-3.5`}),a(`common:action.cancel`)]}),(0,Z.jsxs)(Y,{type:`button`,size:`sm`,onClick:o?y:v,className:`h-8 gap-1.5 text-xs`,children:[(0,Z.jsx)(ui,{className:`h-3.5 w-3.5`}),a(`common:action.save`)]})]})]})}function ep(e,t){return e.map(e=>{let n=t?.[e],r=n?.modelsDev,i=!!(n&&(n.name||n.maxOutput||n.capabilities||r));return{modelId:e,name:r?.name??n?.name??e,modelsDev:r,maxOutput:n?.maxOutput??r?.limit?.output,capabilities:n?.capabilities,source:i?`overridden`:`catalog`}})}function tp(e){let t=e?.limit?.context;if(typeof t==`number`&&t>0)return t>=1e6?`${(t/1e6).toFixed(1)}M`:`${Math.round(t/1e3)}K`}function np(e){let t=e?.cost,n=e=>typeof e==`number`&&e>=0?`$${e}`:void 0;return{input:n(t?.input),output:n(t?.output)}}function rp(e){let t=e?.modalities;return{input:Array.isArray(t?.input)?t.input:[],output:Array.isArray(t?.output)?t.output:[]}}var ip={text:tn,image:Ei,audio:Ir,video:De,pdf:tn};function ap({providerId:e,models:t,customModels:n,ws:r,pickedModelId:i,onPickModel:a}){let{t:o}=H(),[s,c]=(0,X.useState)(null),[l,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)(``),h=(0,X.useMemo)(()=>ep(t,n),[t,n]),g=(0,X.useMemo)(()=>{let e=p.trim().toLowerCase();return e?h.filter(t=>t.modelId.toLowerCase().includes(e)||(t.name?.toLowerCase().includes(e)??!1)):h},[h,p]),_=(0,X.useCallback)(t=>{r.removeCustomModel(e,t),B.success(o(`settings:providerModels.modelRemoved`,{model:t}))},[r,e,o]),v=(0,X.useCallback)((t,n)=>{r.setCustomModel(e,t,{modelsDev:n}),c(null),B.success(o(`settings:providerModels.modelSaved`,{model:t}))},[r,e,o]),y=(0,X.useCallback)((t,n)=>{r.setCustomModel(e,t,{modelsDev:n}),u(!1),B.success(o(`settings:providerModels.modelAdded`,{model:t}))},[r,e,o]);return(0,Z.jsxs)(`div`,{className:`space-y-3`,"data-model-list-editor":e,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(Y,{variant:`outline`,size:`sm`,onClick:()=>u(!0),className:`h-8 gap-1.5 text-xs`,children:[(0,Z.jsx)(_i,{className:`h-3.5 w-3.5`}),o(`settings:providerModels.addFromCatalog`)]}),(0,Z.jsxs)(Y,{variant:`ghost`,size:`sm`,onClick:()=>f(!0),className:`h-8 gap-1.5 text-xs`,children:[(0,Z.jsx)(_i,{className:`h-3.5 w-3.5`}),o(`settings:providerModels.addCustom`)]})]}),h.length>0&&(0,Z.jsxs)(`div`,{className:`overflow-hidden rounded-lg border border-border/70`,children:[h.length>8&&(0,Z.jsxs)(`div`,{className:`relative border-b border-border/40 bg-muted/10`,children:[(0,Z.jsx)(vn,{className:`pointer-events-none absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground/60`}),(0,Z.jsx)(`input`,{type:`text`,value:p,onChange:e=>m(e.target.value),placeholder:o(`settings:providerModels.filterPlaceholder`),"aria-label":o(`settings:providerModels.filterPlaceholder`),className:`h-8 w-full bg-transparent pl-9 pr-3 text-xs text-foreground placeholder:text-muted-foreground/50 focus:outline-none focus:ring-1 focus:ring-ring`})]}),(0,Z.jsx)(`div`,{className:`max-h-80 overflow-y-auto`,children:(0,Z.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,Z.jsx)(`thead`,{children:(0,Z.jsxs)(`tr`,{className:`border-b border-border/70 bg-muted/30 text-left text-[11px] uppercase tracking-wide text-muted-foreground`,children:[(0,Z.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:o(`settings:providerModels.colModel`)}),(0,Z.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:o(`settings:providerModels.colContext`)}),(0,Z.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:o(`settings:providerModels.colOutput`)}),(0,Z.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:o(`settings:providerModels.colCost`)}),(0,Z.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:o(`settings:providerModels.colModalities`)}),(0,Z.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:o(`settings:providerModels.colCaps`)}),(0,Z.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:o(`settings:providerModels.colSource`)}),(0,Z.jsx)(`th`,{className:`px-3 py-2`,"aria-label":o(`settings:providerModels.colActions`)})]})}),(0,Z.jsx)(`tbody`,{children:g.map(t=>{let n=tp(t.modelsDev),r=t.maxOutput??t.modelsDev?.limit?.output,l=typeof r==`number`?r.toLocaleString():void 0,u=np(t.modelsDev),d=rp(t.modelsDev),f=t.capabilities,p=s===t.modelId;return(0,Z.jsxs)(X.Fragment,{children:[(0,Z.jsxs)(`tr`,{className:`border-b border-border/40 transition-colors hover:bg-muted/20`,children:[(0,Z.jsx)(`td`,{className:`px-3 py-2`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Z.jsx)(`span`,{className:`font-mono text-xs font-medium text-foreground`,children:t.modelId}),t.name&&t.name!==t.modelId&&(0,Z.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:t.name})]})}),(0,Z.jsx)(`td`,{className:`px-3 py-2 text-xs text-muted-foreground`,children:n?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Z.jsx)(He,{className:`h-3 w-3`}),n]}):(0,Z.jsx)(`span`,{className:`text-muted-foreground/40`,children:`—`})}),(0,Z.jsx)(`td`,{className:`px-3 py-2 text-xs text-muted-foreground`,children:l?(0,Z.jsx)(`span`,{children:l}):(0,Z.jsx)(`span`,{className:`text-muted-foreground/40`,children:`—`})}),(0,Z.jsx)(`td`,{className:`px-3 py-2 text-xs`,children:u.input||u.output?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-muted-foreground`,children:[(0,Z.jsx)(gi,{className:`h-3 w-3`}),u.input&&u.output?`${u.input}/${u.output}`:u.input??u.output]}):(0,Z.jsx)(`span`,{className:`text-muted-foreground/40`,children:`—`})}),(0,Z.jsx)(`td`,{className:`px-3 py-2`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[d.input.map(e=>{let t=ip[e]??tn;return(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 rounded bg-primary/10 px-1 py-0.5 text-[10px] text-primary`,title:`input: ${e}`,children:[(0,Z.jsx)(t,{className:`h-2.5 w-2.5`}),e]},`in-${e}`)}),d.output.map(e=>(0,Z.jsx)(`span`,{className:`inline-flex items-center gap-0.5 rounded bg-secondary/20 px-1 py-0.5 text-[10px] text-secondary-foreground`,title:`output: ${e}`,children:e},`out-${e}`))]})}),(0,Z.jsx)(`td`,{className:`px-3 py-2`,children:(0,Z.jsxs)(`div`,{className:`flex gap-1`,children:[f?.tools&&(0,Z.jsx)(li,{className:`h-3.5 w-3.5 text-muted-foreground`,"aria-label":o(`activity:modelListEditor.tools`)}),f?.reasoning&&(0,Z.jsx)(lr,{className:`h-3.5 w-3.5 text-muted-foreground`,"aria-label":o(`activity:modelListEditor.reasoning`)}),f?.vision&&(0,Z.jsx)(Xt,{className:`h-3.5 w-3.5 text-muted-foreground`,"aria-label":o(`activity:modelListEditor.vision`)})]})}),(0,Z.jsx)(`td`,{className:`px-3 py-2`,children:(0,Z.jsx)(`span`,{className:G(`inline-flex items-center rounded-full px-2 py-0.5 text-[10px] font-medium`,t.source===`custom`&&`bg-warning/10 text-warning`,t.source===`catalog`&&`bg-info/10 text-info`,t.source===`overridden`&&`bg-primary/10 text-primary`),children:t.source})}),(0,Z.jsx)(`td`,{className:`px-3 py-2`,children:(0,Z.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[a&&(t.modelId===i?(0,Z.jsx)(`span`,{className:`inline-flex items-center rounded p-1 text-primary`,title:o(`settings:providerModels.usingModel`,{model:t.modelId}),role:`img`,"aria-label":o(`settings:providerModels.usingModel`,{model:t.modelId}),children:(0,Z.jsx)(ui,{className:`h-3.5 w-3.5`})}):(0,Z.jsx)(`button`,{type:`button`,onClick:()=>a(e,t.modelId),className:`rounded p-1 text-muted-foreground transition-colors hover:bg-primary/10 hover:text-primary`,"aria-label":o(`settings:providerModels.useModel`,{model:t.modelId}),title:o(`settings:providerModels.useModel`,{model:t.modelId}),children:(0,Z.jsx)(ui,{className:`h-3.5 w-3.5`})})),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>c(p?null:t.modelId),className:`rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,"aria-label":o(`settings:providerModels.editModel`,{model:t.modelId}),children:(0,Z.jsx)(or,{className:`h-3.5 w-3.5`})}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>_(t.modelId),className:`rounded p-1 text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive`,"aria-label":o(`settings:providerModels.removeModel`,{model:t.modelId}),children:(0,Z.jsx)(vr,{className:`h-3.5 w-3.5`})})]})})]}),p&&(0,Z.jsx)(`tr`,{className:`border-b border-border/40 bg-muted/10`,children:(0,Z.jsx)(`td`,{colSpan:8,className:`p-3`,children:(0,Z.jsx)($f,{providerId:e,modelId:t.modelId,initialModelsDev:t.modelsDev??{},onSave:v,onCancel:()=>c(null)})})},`${t.modelId}-edit`)]},t.modelId)})})]})})]}),h.length===0&&(0,Z.jsx)(`div`,{className:`rounded-lg border border-dashed border-border/50 p-8 text-center`,children:(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o(`settings:providerModels.emptyState`)})}),l&&(0,Z.jsx)(Lf,{ws:r,onSelect:y,onClose:()=>u(!1)}),d&&(0,Z.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`absolute inset-0 bg-black/50`,onClick:()=>f(!1),"aria-label":o(`common:action.close`)}),(0,Z.jsxs)(`div`,{className:`relative max-h-[80vh] w-full max-w-2xl overflow-y-auto rounded-lg border border-border bg-background p-4 shadow-lg`,children:[(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:o(`settings:providerModels.addCustomTitle`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>f(!1),className:`text-muted-foreground hover:text-foreground`,children:(0,Z.jsx)(St,{className:`h-4 w-4`})})]}),(0,Z.jsx)($f,{providerId:e,modelId:``,initialModelsDev:{},onSave:v,onCancel:()=>f(!1)})]})]})]})}function op(){return{inFlight:!1,last:null,picked:null}}function sp(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 cp(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 lp(e){return(e?.length??0)>0}function up(e,t){return`Allowlist cleared for ${e} — ${t} model${t===1?``:`s`} removed`}function dp(e){return e.length>0}function fp(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 pp=3e3;function mp({providerId:e,savedPickedModelId:t,savedModels:n,savedCustomModels:r,ws:i,onPickModel:a,onClearModels:o,onUndoClear:s}){let[c,l]=(0,X.useState)(()=>op()),{t:u}=H(),[d,f]=(0,X.useState)(!1);(0,X.useEffect)(()=>i.on(`provider.probe`,t=>{t.type===`provider.probe`&&t.payload.providerId===e&&l(e=>({...e,inFlight:!1,last:sp(t.payload)}))}),[i,e]);let p=(0,X.useCallback)(()=>{l(e=>({...e,inFlight:!0})),i.probeProvider(e,pp)},[i,e]),m=(0,X.useCallback)((e,t)=>{l(e=>({...e,picked:t})),a?.(e,t)},[a]),h=(0,X.useCallback)(()=>{f(!0)},[]),g=(0,X.useCallback)(()=>{f(!1)},[]),_=(0,X.useCallback)(()=>{f(!1);let t=n?[...n]:[];l(e=>({...e,picked:null,last:null})),o?o(e):i.clearProviderModels(e),dp(t)&&B.undoable(up(e,t.length),()=>{let n=fp({providerId:e,previousModels:t,onUndoClear:s});switch(n.kind){case`skip`:return;case`callback`:s?.(n.providerId,n.previousModels);return;case`ws-default`:i.undoProviderClear(n.providerId,n.previousModels);return}})},[o,s,i,e,n]),v=(0,X.useMemo)(()=>c.picked??t??n?.[0]??``,[c.picked,t,n]),y=(0,X.useMemo)(()=>cp(c),[c]),b=(0,X.useMemo)(()=>lp(n),[n]);return(0,Z.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,Z.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[(0,Z.jsx)(Yt,{className:`h-3.5 w-3.5`}),u(`activity:providerModels.allowlistTitle`)]}),n&&n.length>0&&(0,Z.jsx)(`span`,{className:`rounded-full border border-border/70 bg-muted/40 px-2 py-0.5 text-[11px] text-muted-foreground`,children:u(`activity:providerModels.modelCount`,{count:n.length})})]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:u(`activity:providerModels.using`)}),v?(0,Z.jsx)(`span`,{className:`max-w-full break-words rounded-md bg-primary/10 px-2 py-0.5 font-mono text-xs text-primary`,children:v}):(0,Z.jsx)(`span`,{className:`text-xs italic text-muted-foreground`,children:u(`activity:providerModels.noModelPicked`)})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 sm:justify-end`,children:[(0,Z.jsxs)(Y,{variant:`outline`,size:`sm`,onClick:p,disabled:c.inFlight,"aria-label":u(`activity:providerModels.refreshAria`,{provider:e}),className:`h-8 px-2 text-xs`,children:[c.inFlight?(0,Z.jsx)(wt,{className:`h-3.5 w-3.5 animate-spin`}):(0,Z.jsx)(xi,{className:`h-3.5 w-3.5`}),c.inFlight?u(`activity:providerModels.probing`):u(`activity:providerModels.refresh`)]}),b&&(0,Z.jsx)(Y,{variant:`ghost`,size:`sm`,onClick:h,"aria-label":u(`activity:providerModels.clearAllowlistAria`,{provider:e}),"data-action":`clear-models`,className:`h-8 px-2 text-xs`,children:u(`activity:providerModels.clearAllowlist`)})]})]}),(0,Z.jsx)(hp,{formatted:y}),(0,Z.jsx)(`div`,{className:`mt-3`,children:(0,Z.jsx)(ap,{providerId:e,models:n??[],customModels:r,ws:i,pickedModelId:v??void 0,onPickModel:m})}),(0,Z.jsx)(If,{open:d,providerId:e,modelCount:n?.length??0,onConfirm:_,onCancel:g})]})}function hp({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,Z.jsxs)(`p`,{className:`mt-2 flex items-center gap-1.5 text-xs ${t}`,"data-probe-tone":e.tone,children:[(0,Z.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full ${n}`}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:e.text})]})}var gp=[`anthropic`,`openai`,`google`,`openai-compatible`];function _p({activeProvider:e,catalogProviders:t,isLoadingCatalog:n,savedProviders:r,isLoadingSaved:i,providerTab:a,setProviderTab:o,onSelectProvider:s,onAddKey:c,onDeleteKey:l,onSetActiveKey:u,onAddProvider:d,onRemoveProvider:f,onPickProviderModel:p,ws:m,catalogQuery:h,setCatalogQuery:g}){let{t:_}=H(),[v,y]=(0,X.useState)(null),[b,x]=(0,X.useState)(``),[S,C]=(0,X.useState)(``),[w,T]=(0,X.useState)(!1),[E,D]=(0,X.useState)(!1),[O,k]=(0,X.useState)(``),[A,j]=(0,X.useState)(`openai-compatible`),[M,N]=(0,X.useState)(``),[P,F]=(0,X.useState)(``),[I,L]=(0,X.useState)([]),R=Sf(),ee=Sf(),te=(0,X.useCallback)(e=>{!b.trim()||!S.trim()||(c(e,b.trim(),S.trim()),x(``),C(``),y(null))},[c,b,S]),z=(0,X.useCallback)(()=>{O.trim()&&(d(O.trim(),A,M||void 0,P||void 0,I.length>0?I.map(e=>e.id):void 0,I.length>0?Object.fromEntries(I.filter(e=>e.name||e.maxOutput||e.capabilities&&Object.keys(e.capabilities).length>0).map(e=>[e.id,{...e.name&&e.name!==e.id?{name:e.name}:{},...e.maxOutput?{maxOutput:e.maxOutput}:{},...e.capabilities&&Object.keys(e.capabilities).length>0?{capabilities:e.capabilities}:{}}])):void 0),k(``),j(`openai-compatible`),N(``),F(``),L([]),D(!1))},[d,O,A,M,P,I]),ne=(0,X.useCallback)(e=>{k(e.id),j(jf),N(e.defaultBaseUrl),e.noAuth&&F(``),L([])},[]),[re,ie]=(0,X.useState)(null),[ae,oe]=(0,X.useState)(``),[se,ce]=(0,X.useState)(!1),[le,ue]=(0,X.useState)({}),de=(0,X.useMemo)(()=>new Set(r.map(e=>e.id)),[r]),fe=(0,X.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,X.useEffect)(()=>{let e=m.on(`provider.probe`,e=>{if(e.type!==`provider.probe`)return;let t=e.payload;t.status!==`no_base_url`&&t.status!==`no_provider`&&ue(e=>({...e,[t.providerId]:{ok:t.ok,status:t.status,detail:t.detail}}))});return()=>e?.()},[m]);let pe=(0,X.useCallback)(e=>{let t=ae.trim();t&&(de.has(e.id)?c(e.id,`default`,t):d(e.id,e.family,e.apiBase??void 0,t),oe(``),ie(null),ce(!1),B.success(_(`settings:provider.savedToast`,{name:e.name})),e.apiBase&&setTimeout(()=>m.probeProvider(e.id,6e3),700))},[ae,de,c,d,m]),me=h.trim()?t.filter(e=>{let t=h.trim().toLowerCase();return e.id.toLowerCase().includes(t)||e.name.toLowerCase().includes(t)||e.family.toLowerCase().includes(t)}):t,V=me.reduce((e,t)=>(e[t.family]||(e[t.family]=[]),e[t.family]?.push(t),e),{});return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsxs)(`h3`,{className:`text-sm font-semibold flex items-center gap-2`,children:[(0,Z.jsx)(ri,{className:`h-4 w-4 text-muted-foreground`}),_(`settings:provider.subscriptionHeading`)]}),(0,Z.jsx)(Ff,{ws:m,savedByKind:{chatgpt:r.filter(e=>e.id===`openai-codex`||e.id.startsWith(`openai-codex-`)).map(e=>({id:e.id,hasActiveKey:e.apiKeys.some(e=>e.isActive)})),claude:r.filter(e=>e.id===`anthropic-oauth`||e.id.startsWith(`anthropic-oauth-`)).map(e=>({id:e.id,hasActiveKey:e.apiKeys.some(e=>e.isActive)})),copilot:r.filter(e=>e.id===`github-copilot`).map(e=>({id:e.id,hasActiveKey:e.apiKeys.some(e=>e.isActive)}))}})]}),(0,Z.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Z.jsxs)(`h3`,{className:`text-sm font-semibold mb-1 flex items-center gap-2`,children:[(0,Z.jsx)(Bn,{className:`h-4 w-4 text-muted-foreground`}),_(`settings:provider.apiKeysHeading`)]}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground mb-3`,children:_(`settings:provider.apiKeysBody`)})]}),(0,Z.jsxs)(`div`,{className:`flex gap-2 mb-4`,children:[(0,Z.jsxs)(Y,{variant:a===`catalog`?`default`:`outline`,size:`sm`,onClick:()=>o(`catalog`),children:[(0,Z.jsx)(Bn,{className:`h-4 w-4 mr-1`}),_(`settings:provider.tabCatalog`)]}),(0,Z.jsxs)(Y,{variant:a===`saved`?`default`:`outline`,size:`sm`,onClick:()=>o(`saved`),children:[(0,Z.jsx)(ri,{className:`h-4 w-4 mr-1`}),_(`settings:provider.tabSaved`,{count:r.length})]})]}),a===`catalog`&&(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(Ya,{placeholder:_(`settings:provider.searchPlaceholder`,{count:t.length}),value:h,onChange:e=>g(e.target.value),className:`text-sm`}),n&&t.length===0?(0,Z.jsxs)(`div`,{className:`flex items-center justify-center py-8`,children:[(0,Z.jsx)(wt,{className:`h-6 w-6 animate-spin text-muted-foreground`}),(0,Z.jsx)(`span`,{className:`ml-2 text-muted-foreground`,children:_(`settings:provider.loadingCatalog`)})]}):me.length===0&&h?(0,Z.jsx)(`div`,{className:`text-center py-8 text-muted-foreground text-sm`,children:_(`settings:provider.noMatch`,{query:h})}):gp.map(t=>{let n=V[t];return n?.length?(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-muted-foreground uppercase tracking-wider`,children:t}),(0,Z.jsx)(`div`,{className:`grid grid-cols-1 gap-2`,children:n.map(t=>{let n=le[t.id],r=e===t.id;return(0,Z.jsxs)(`div`,{className:G(`rounded-lg border transition-all`,r?`border-primary bg-primary/5 ring-2 ring-primary/20`:`border-border`),children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>s(t.id),className:G(`flex w-full flex-col items-start p-3 text-left rounded-lg`,!r&&`hover:bg-muted`),children:[(0,Z.jsxs)(`div`,{className:`flex w-full justify-between items-start`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:t.name}),(0,Z.jsxs)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:[`(`,t.id,`)`]})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t.hasApiKey&&(0,Z.jsxs)(`span`,{className:`text-xs bg-success/10 text-success px-2 py-0.5 rounded`,children:[(0,Z.jsx)(ri,{className:`h-3 w-3 inline mr-1`}),_(`settings:provider.configured`)]}),n&&(0,Z.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,Z.jsx)($t,{className:`h-3 w-3`}):(0,Z.jsx)(Rr,{className:`h-3 w-3`}),n.ok?_(`settings:provider.reachable`):n.status]}),t.envVars[0]&&(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:_(`settings:provider.envVar`,{var:t.envVars[0]})}),r&&(0,Z.jsx)($t,{className:`h-4 w-4 text-primary`})]})]}),(0,Z.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[_(`settings:provider.modelCount`,{count:t.modelCount}),t.apiBase&&` · ${t.apiBase}`]})]}),r&&!t.hasApiKey&&(0,Z.jsx)(`div`,{className:`px-3 pb-3 -mt-1 space-y-2`,children:re===t.id?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(Ya,{autoFocus:!0,type:se?`text`:`password`,placeholder:_(`settings:provider.keyPlaceholder`,{name:t.name}),value:ae,onChange:e=>oe(e.target.value),className:`text-sm`,onKeyDown:e=>{e.key===`Enter`&&pe(t)}}),(0,Z.jsx)(Y,{size:`icon`,variant:`ghost`,onClick:()=>ce(e=>!e),children:se?(0,Z.jsx)(ke,{className:`h-4 w-4`}):(0,Z.jsx)(Xt,{className:`h-4 w-4`})}),(0,Z.jsx)(Y,{size:`sm`,onClick:()=>pe(t),disabled:!ae.trim(),children:_(`common:action.save`)})]}),t.envVars[0]&&(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:_(`settings:provider.orEnv`,{env:t.envVars[0]})})]}):(0,Z.jsxs)(Y,{size:`sm`,variant:`outline`,onClick:()=>{ie(t.id),oe(``)},children:[(0,Z.jsx)(ri,{className:`h-3.5 w-3.5 mr-1`}),_(`settings:provider.addApiKey`)]})})]},t.id)})})]},t):null})]}),a===`saved`&&(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:_(`settings:provider.manageKeys`)}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2 text-xs text-muted-foreground`,children:[(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-muted/30 px-2 py-1`,children:[(0,Z.jsx)(Qi,{className:`h-3.5 w-3.5`}),_(`settings:provider.savedProviderCount`,{count:r.length})]}),(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-muted/30 px-2 py-1`,children:[(0,Z.jsx)(ri,{className:`h-3.5 w-3.5`}),_(`settings:provider.keyCount`,{count:fe.keys})]}),(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-muted/30 px-2 py-1`,children:[(0,Z.jsx)(zt,{className:`h-3.5 w-3.5`}),_(`settings:provider.activeKeyCount`,{count:fe.activeKeys})]}),(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-muted/30 px-2 py-1`,children:[(0,Z.jsx)(ar,{className:`h-3.5 w-3.5`}),_(`settings:provider.modelCount`,{count:fe.models})]})]})]}),(0,Z.jsxs)(Y,{size:`sm`,variant:`outline`,onClick:()=>D(!E),children:[(0,Z.jsx)(_i,{className:`h-4 w-4 mr-1`}),_(`settings:provider.addProvider`)]})]}),E&&(0,Z.jsxs)(`div`,{className:`p-4 border rounded-lg space-y-3 bg-muted/50`,children:[(0,Z.jsx)(`h4`,{className:`font-medium`,children:_(`settings:provider.addCustomHeading`)}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:_(`settings:provider.localServers`)}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:Mf.map(e=>(0,Z.jsx)(Y,{type:`button`,size:`sm`,variant:O===e.id?`default`:`outline`,onClick:()=>ne(e),title:e.hint,children:e.label},e.id))})]}),(0,Z.jsx)(Ya,{placeholder:_(`settings:provider.providerIdPlaceholder`),value:O,onChange:e=>k(e.target.value),ref:R.setFieldRef(0),onKeyDown:e=>R.handleKeyDown(e,0)}),(0,Z.jsxs)(`select`,{className:`flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm`,value:A,onChange:e=>j(e.target.value),ref:R.setFieldRef(1),onKeyDown:e=>R.handleKeyDown(e,1),children:[(0,Z.jsx)(`option`,{value:`anthropic`,children:_(`activity:provider.anthropic`)}),(0,Z.jsx)(`option`,{value:`openai`,children:_(`activity:provider.openai`)}),(0,Z.jsx)(`option`,{value:`openai-compatible`,children:_(`activity:provider.openaiCompatible`)}),(0,Z.jsx)(`option`,{value:`google`,children:_(`activity:provider.google`)})]}),(0,Z.jsx)(Ya,{placeholder:_(`activity:provider.baseUrlOptionalEGHttpLocalhost11434V1`),value:M,onChange:e=>N(e.target.value),ref:R.setFieldRef(2),onKeyDown:e=>R.handleKeyDown(e,2)}),(0,Z.jsx)(Ya,{type:`password`,placeholder:_(`settings:provider.apiKeyOptionalPlaceholder`),value:P,onChange:e=>F(e.target.value),ref:R.setFieldRef(3),onKeyDown:e=>R.handleKeyDown(e,3)}),(0,Z.jsx)(Cf,{models:I,onChange:L}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(Y,{size:`sm`,onClick:z,disabled:!O.trim(),ref:R.setFieldRef(4),onKeyDown:e=>R.handleKeyDown(e,4,z),children:_(`common:action.add`)}),(0,Z.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>D(!1),ref:R.setFieldRef(5),onKeyDown:e=>R.handleKeyDown(e,5),children:_(`common:action.cancel`)})]})]}),i?(0,Z.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,Z.jsx)(wt,{className:`h-6 w-6 animate-spin text-muted-foreground`})}):r.length===0?(0,Z.jsxs)(`div`,{className:`text-center py-8 text-muted-foreground`,children:[(0,Z.jsx)(ri,{className:`h-8 w-8 mx-auto mb-2 opacity-50`}),(0,Z.jsx)(`p`,{children:_(`settings:provider.noSaved`)}),(0,Z.jsx)(`p`,{className:`text-sm`,children:_(`settings:provider.noSavedHint`)})]}):r.map(e=>(0,Z.jsxs)(`div`,{className:`rounded-lg border border-border/80 bg-card/70 p-4 shadow-sm shadow-black/[0.02]`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`h4`,{className:`min-w-0 break-words font-mono text-sm font-semibold text-foreground`,children:e.id}),e.family&&(0,Z.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,Z.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,Z.jsx)(zt,{className:`h-3 w-3`}),_(`settings:provider.active`)]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-xs text-muted-foreground`,children:[e.baseUrl&&(0,Z.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,Z.jsx)(Bn,{className:`h-3.5 w-3.5 shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.baseUrl})]}),(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-background/60 px-2 py-1`,children:[(0,Z.jsx)(ar,{className:`h-3.5 w-3.5`}),_(`settings:provider.modelCount`,{count:e.models?.length??0})]}),(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-background/60 px-2 py-1`,children:[(0,Z.jsx)(ri,{className:`h-3.5 w-3.5`}),_(`settings:provider.keyCount`,{count:e.apiKeys.length})]})]})]}),(0,Z.jsx)(`div`,{className:`flex gap-2 sm:justify-end`,children:(0,Z.jsx)(Y,{size:`icon`,variant:`ghost`,onClick:()=>f(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,Z.jsx)(vr,{className:`h-4 w-4 text-destructive`})})})]}),(0,Z.jsxs)(`div`,{className:`mt-4 grid gap-4 xl:grid-cols-[minmax(0,1.35fr)_minmax(280px,0.85fr)]`,children:[(0,Z.jsx)(mp,{providerId:e.id,savedPickedModelId:e.pickedModelId,savedModels:e.models,savedCustomModels:e.customModels,ws:m,onPickModel:p}),(0,Z.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-background/75 p-3 shadow-sm shadow-black/[0.02]`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-semibold`,children:_(`settings:provider.apiKeysLabel`)}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:_(`settings:provider.keyCount`,{count:e.apiKeys.length})})]}),(0,Z.jsxs)(Y,{size:`sm`,variant:`ghost`,onClick:()=>y(v===e.id?null:e.id),className:`h-8 px-2 text-xs`,children:[(0,Z.jsx)(_i,{className:`h-3.5 w-3.5`}),_(`settings:provider.addKey`)]})]}),e.apiKeys.length===0&&!v&&(0,Z.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:_(`settings:provider.noKeys`)}),e.apiKeys.length>0&&(0,Z.jsx)(`div`,{className:`mt-3 space-y-2`,children:e.apiKeys.map(t=>(0,Z.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,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,Z.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,Z.jsx)(ri,{className:`h-3.5 w-3.5`})}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate text-sm font-medium`,children:t.label}),t.isActive&&(0,Z.jsx)(`span`,{className:`rounded-full bg-success/10 px-2 py-0.5 text-[11px] font-medium text-success`,children:_(`settings:provider.active`)})]}),(0,Z.jsx)(`div`,{className:`mt-0.5`,children:(0,Z.jsx)(wf,{maskedKey:t.maskedKey})})]})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-1`,children:[!t.isActive&&(0,Z.jsx)(Y,{size:`sm`,variant:`outline`,onClick:()=>u(e.id,t.label),className:`h-8 px-2 text-xs`,children:_(`settings:provider.setActive`)}),(0,Z.jsx)(Y,{size:`icon`,variant:`ghost`,onClick:()=>l(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,Z.jsx)(vr,{className:`h-3.5 w-3.5 text-destructive`})})]})]},t.label))}),v===e.id&&(0,Z.jsxs)(`div`,{className:`mt-3 space-y-2 rounded-lg border border-border/70 bg-background p-3`,children:[(0,Z.jsx)(Ya,{placeholder:_(`settings:provider.keyLabelPlaceholder`),value:b,onChange:e=>x(e.target.value),ref:ee.setFieldRef(0),onKeyDown:e=>ee.handleKeyDown(e,0)}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(Ya,{type:w?`text`:`password`,placeholder:_(`settings:provider.apiKeyPlaceholder`),value:S,onChange:e=>C(e.target.value),ref:ee.setFieldRef(1),onKeyDown:e=>ee.handleKeyDown(e,1)}),(0,Z.jsx)(Y,{size:`icon`,variant:`ghost`,onClick:()=>T(!w),children:w?(0,Z.jsx)(ke,{className:`h-4 w-4`}):(0,Z.jsx)(Xt,{className:`h-4 w-4`})})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(Y,{size:`sm`,onClick:()=>te(e.id),disabled:!b.trim()||!S.trim(),ref:ee.setFieldRef(2),onKeyDown:t=>ee.handleKeyDown(t,2,()=>te(e.id)),children:_(`settings:provider.saveKey`)}),(0,Z.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>{y(null),x(``),C(``)},ref:ee.setFieldRef(3),onKeyDown:e=>ee.handleKeyDown(e,3),children:_(`common:action.cancel`)})]})]})]})]})]},e.id))]})]})}var vp=Object.entries({discovery:[[`explore`,`Explore`],[`search`,`Search`],[`research`,`Research`]],planning:[[`analyst`,`Analyst`],[`planner`,`Planner`],[`architect`,`Architect`],[`critic`,`Critic`],[`refactor-planner`,`Refactor Planner`]],build:[[`executor`,`Executor`],[`refactor`,`Refactor`],[`simplifier`,`Simplifier`],[`migration`,`Migration`],[`vision`,`Vision`],[`debugger`,`Debugger`],[`tracer`,`Tracer`],[`concurrency`,`Concurrency`]],verify:[[`realtime`,`Realtime`],[`resilience-engineer`,`Resilience Engineer`],[`chaos-engineer`,`Chaos Engineer`],[`verifier`,`Verifier`],[`test`,`Test`],[`e2e`,`E2E`],[`browser`,`Browser`],[`performance`,`Performance`],[`chaos`,`Chaos`],[`security-scanner`,`Security Scanner`],[`bug-hunter`,`Bug Hunter`],[`audit-log`,`Audit Log`]],review:[[`threat-modeler`,`Threat Modeler`],[`secure-coding-coach`,`Secure Coding Coach`],[`compliance-auditor`,`Compliance Auditor`],[`privacy-engineer`,`Privacy Engineer`],[`reviewer`,`Reviewer`],[`code-reviewer`,`Code Reviewer`],[`security-reviewer`,`Security Reviewer`],[`accessibility`,`Accessibility`],[`compliance`,`Compliance`]],domain:[[`android`,`Android`],[`desktop`,`Desktop`],[`distributed-systems`,`Distributed Systems`],[`database`,`Database`],[`api`,`API`],[`auth`,`Auth`],[`data`,`Data`],[`frontend`,`Frontend`],[`backend`,`Backend`],[`designer`,`Designer`],[`ios`,`iOS`],[`payments`,`Payments`],[`messaging`,`Messaging`],[`search-relevance`,`Search Relevance`],[`storage`,`Storage`],[`ml-engineer`,`ML Engineer`],[`data-governance`,`Data Governance`]],knowledge:[[`document`,`Document`],[`uml`,`UML`],[`i18n`,`I18n`],[`prompt`,`Prompt`]],delivery:[[`platform-engineer`,`Platform Engineer`],[`git`,`Git`],[`release`,`Release`],[`devops`,`DevOps`],[`observability`,`Observability`],[`dependency`,`Dependency`]],meta:[[`skill-manage`,`Skill Manager`],[`self-improving`,`Self-Improving`],[`context`,`Context`],[`cost`,`Cost`],[`tech-stack`,`Tech Stack Validator`],[`plugin-author`,`Plugin Author`],[`tool-author`,`Tool Author`],[`prompt-evaluator`,`Prompt Evaluator`],[`benchmark-engineer`,`Benchmark Engineer`],[`memory-curator`,`Memory Curator`],[`fleet-coordinator`,`Fleet Coordinator`]]}).map(([e,t])=>({phase:e,label:`${e.charAt(0).toUpperCase()}${e.slice(1)}`,roles:t.map(([e,t])=>({role:e,name:t}))})),yp=vp.map(e=>e.phase),bp=vp.flatMap(e=>[...e.roles]),xp=bp.map(e=>e.role),Sp=[`*`,...yp,...xp];function Cp(e){if(e===`*`)return`Default (*)`;let t=vp.find(t=>t.phase===e);if(t)return`Phase: ${t.label} (${t.phase})`;let n=bp.find(t=>t.role===e);return n?`${n.name} (${n.role})`:`Custom: ${e}`}var wp=[{value:``,label:`mode: inherit`},{value:`auto`,label:`mode: auto`},{value:`on`,label:`mode: on`},{value:`off`,label:`mode: off`}],Tp=[{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`}],Ep=[{value:``,label:`preserve: inherit`},{value:`on`,label:`preserve: on`},{value:`off`,label:`preserve: off`}],Dp=new Set(Sp);function Op(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 kp(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 Ap({syncPref:e,candidates:t}){let n=W(),{t:r}=H(),[i,a]=(0,X.useState)(`*`),[o,s]=(0,X.useState)(``),[c,l]=(0,X.useState)(``),[u,d]=(0,X.useState)(``),[f,p]=(0,X.useState)(``),m=(0,X.useCallback)(t=>e(`modelMatrix`,t),[e]),h=(0,X.useCallback)(()=>{let e=i.trim(),t=o.trim(),r=Op(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,X.useCallback)(e=>{let{[e]:t,...r}=n.modelMatrix;m(r)},[n.modelMatrix,m]),_=(0,X.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}`:``,...kp(n)].filter(Boolean).join(` + `)},y=Array.from(new Set([...Object.keys(n.modelMatrix),i].filter(e=>e&&!Dp.has(e)))).sort((e,t)=>e.localeCompare(t));return(0,Z.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Z.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 mt-3 flex items-center gap-2`,children:[(0,Z.jsx)(Pr,{className:`h-4 w-4 text-muted-foreground`}),r(`settings:agent.routingHeading`)]}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-[minmax(0,180px)_1fr_auto]`,children:[(0,Z.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,Z.jsx)(`option`,{value:`*`,children:Cp(`*`)}),(0,Z.jsx)(`optgroup`,{label:r(`settings:agent.routingPhasesGroup`),children:vp.map(e=>(0,Z.jsx)(`option`,{value:e.phase,children:Cp(e.phase)},e.phase))}),vp.map(e=>(0,Z.jsx)(`optgroup`,{label:r(`settings:agent.routingRolesGroup`,{label:e.label}),children:e.roles.map(e=>(0,Z.jsx)(`option`,{value:e.role,children:Cp(e.role)},e.role))},e.phase)),y.length>0?(0,Z.jsx)(`optgroup`,{label:r(`settings:agent.routingCustomGroup`),children:y.map(e=>(0,Z.jsx)(`option`,{value:e,children:Cp(e)},e))}):null]}),(0,Z.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,Z.jsx)(`option`,{value:``,children:r(`settings:agent.routingTargetEmpty`)}),Object.keys(n.fallbackProfiles).length>0&&(0,Z.jsx)(`optgroup`,{label:r(`settings:agent.routingTargetProfilesGroup`),children:Object.keys(n.fallbackProfiles).map(e=>(0,Z.jsx)(`option`,{value:e,children:e},e))}),t&&t.length>0&&(0,Z.jsx)(`optgroup`,{label:r(`settings:agent.routingTargetModelsGroup`),children:t.map(e=>(0,Z.jsxs)(`option`,{value:`${e.provider}/${e.model}`,children:[e.provider,`/`,e.model]},`${e.provider}/${e.model}`))})]}),(0,Z.jsx)(Y,{type:`button`,variant:`outline`,onClick:h,children:r(`settings:agent.routingSet`)})]}),(0,Z.jsxs)(`div`,{className:`mt-2 grid grid-cols-1 gap-2 sm:grid-cols-3`,children:[(0,Z.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:wp.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))}),(0,Z.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:Tp.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))}),(0,Z.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:Ep.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))})]}),(0,Z.jsx)(`div`,{className:`mt-3 space-y-1.5`,children:Object.keys(n.modelMatrix).length===0?(0,Z.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,Z.jsxs)(`div`,{className:`rounded-md border border-border bg-muted px-2 py-1.5 text-xs`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`w-40 shrink-0 break-words font-mono text-muted-foreground`,title:e,children:Cp(e)}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 break-words font-mono`,children:v(t)}),(0,Z.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>g(e),children:r(`common:action.remove`)})]}),(0,Z.jsxs)(`div`,{className:`mt-2 grid grid-cols-1 gap-2 sm:grid-cols-3`,children:[(0,Z.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:wp.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))}),(0,Z.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:Tp.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))}),(0,Z.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:Ep.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))})]})]},e))})]})}var jp=[`off`,`low`,`medium`,`high`,`all`],Mp={off:`bg-muted-foreground`,low:`bg-success`,medium:`bg-warning`,high:`bg-warning ring-2 ring-warning/25`,all:`bg-destructive`},Np={off:`settings:brain.riskCopy.off`,low:`settings:brain.riskCopy.low`,medium:`settings:brain.riskCopy.medium`,high:`settings:brain.riskCopy.high`,all:`settings:brain.riskCopy.all`},Pp=[`executor`,`skeptic`,`auditor`];function Fp(e){return e&&e.length>0?e.map(e=>({id:e.id,name:e.name,description:e.description})):Pp.map(e=>({id:e,name:e}))}var Ip=[{value:`default`,labelKey:`settings:brainOpt.default15s`},{value:`5000`,label:`5s`},{value:`10000`,label:`10s`},{value:`20000`,label:`20s`},{value:`30000`,label:`30s`},{value:`60000`,label:`60s`}],Lp=[{value:`off`,labelKey:`settings:brainOpt.waitForever`},{value:`30000`,label:`30s`},{value:`60000`,label:`1m`},{value:`120000`,label:`2m`},{value:`300000`,label:`5m`}],Rp=[{value:`default`,labelKey:`settings:brainOpt.defaultHalf`},{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`,labelKey:`settings:brainOpt.all`}],zp=[{value:`100`,label:`100`},{value:`200`,labelKey:`settings:brainOpt.n200Default`},{value:`400`,label:`400`},{value:`800`,label:`800`},{value:`1600`,label:`1600`}],Bp=[{value:`0`,labelKey:`settings:brainOpt.offDefault`},{value:`0.3`,label:`0.3`},{value:`0.5`,label:`0.5`},{value:`0.7`,label:`0.7`},{value:`0.9`,label:`0.9`}],Vp=[{value:`10`,label:`10`},{value:`20`,labelKey:`settings:brainOpt.n20Default`},{value:`50`,label:`50`},{value:`100`,label:`100`}],Hp=[{value:`60000`,label:`1m`},{value:`300000`,labelKey:`settings:brainOpt.m5Default`},{value:`900000`,label:`15m`},{value:`3600000`,label:`1h`}],Up=[{value:`50`,label:`50`},{value:`200`,labelKey:`settings:brainOpt.n200Default`},{value:`500`,label:`500`},{value:`1000`,label:`1000`}],Wp=[{value:`default`,labelKey:`settings:brainOpt.default`},{value:`10000`,label:`10s`},{value:`20000`,label:`20s`},{value:`30000`,label:`30s`},{value:`60000`,label:`60s`}],Gp=[{value:`default`,labelKey:`settings:brainOpt.default`},{value:`1`,labelKey:`settings:brainOpt.oneSerial`},{value:`2`,label:`2`},{value:`3`,label:`3`},{value:`5`,label:`5`}],Kp=[{value:`default`,labelKey:`settings:brainOpt.default`},{value:`500`,label:`500`},{value:`1000`,label:`1000`},{value:`2000`,label:`2000`},{value:`4000`,label:`4000`},{value:`8000`,label:`8000`}],qp=[{value:`default`,labelKey:`settings:brainOpt.default`},{value:`1`,labelKey:`settings:brainOpt.roundsOff`},{value:`2`,label:`2`},{value:`3`,label:`3`}],Jp=[{value:`default`,labelKey:`settings:brainOpt.default`},{value:`200`,label:`200`},{value:`400`,label:`400`},{value:`800`,label:`800`},{value:`1600`,label:`1600`}],Yp=[{value:`default`,labelKey:`settings:brainOpt.default500`},{value:`100`,label:`100`},{value:`500`,label:`500`},{value:`1000`,label:`1000`},{value:`5000`,label:`5000`}],Xp=[{value:`default`,labelKey:`settings:brainOpt.default10m`},{value:`120000`,label:`2m`},{value:`600000`,label:`10m`},{value:`1800000`,label:`30m`},{value:`3600000`,label:`1h`}];function Zp(e,t){return e.some(e=>e.value===t)?e:[...e,{value:t,label:t}]}function Qp(e,t){return e.map(e=>({value:e.value,label:e.labelKey?t(e.labelKey):e.label??e.value}))}function $p(e){return e===void 0?`default`:String(e)}function em({level:e}){return(0,Z.jsx)(`span`,{className:G(`inline-block h-2.5 w-2.5 rounded-full`,Mp[e])})}function tm(e){return e.provider?`${e.provider}/${e.model}`:e.model}var nm={pool:{title:`settings:brain.pickPoolTitle`,hint:`settings:brain.pickPoolHint`},voter:{title:`settings:brain.pickVoterTitle`,hint:`settings:brain.pickVoterHint`},judge:{title:`settings:brain.pickJudgeTitle`,hint:`settings:brain.pickJudgeHint`}};function rm(){let{t:e}=H(),{client:t}=ha(),[n,r]=(0,X.useState)(null),[i,a]=(0,X.useState)([]),[o,s]=(0,X.useState)(!0),[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(null),[f,p]=(0,X.useState)(null),m=ve();(0,X.useEffect)(()=>{t.send({type:`brain.status`,payload:t.withSession({})}),t.send({type:`brain.config.get`})},[t,m]),(0,X.useEffect)(()=>{let n=t.on(`brain.status`,e=>{let t=e.payload;if(t.sessionId&&m&&t.sessionId!==m)return;let n=Date.now();a(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}})),s(!1)}),i=t.on(`brain.config`,t=>{let n=t.payload;r(n.config),d(n.persisted?null:n.error??e(`settings:brain.persistError`)),l(!1),s(!1)});return()=>{n(),i()}},[t,e,m]);let h=(0,X.useCallback)(e=>{l(!0),t.send({type:`brain.config.set`,payload:t.withSession({patch:e})})},[t]),g=(0,X.useCallback)(e=>{r(t=>t&&{...t,maxAutoRisk:e}),h({maxAutoRisk:e})},[h]),_=(0,X.useMemo)(()=>n?.council.voters??[],[n]),v=(0,X.useCallback)(e=>{h({council:{voters:e.length>0?e:null}})},[h]),y=(0,X.useMemo)(()=>Fp(n?.personaCatalog),[n?.personaCatalog]),b=jp.includes(n?.maxAutoRisk??``)?n?.maxAutoRisk??`medium`:`medium`,x=(0,X.useCallback)(e=>{if(!n||!f)return;let t=`${e.provider}/${e.model}`;if(f===`pool`){h({models:[...n.models.map(tm),t]});return}if(f===`judge`){h({council:{judge:t}});return}return v([..._,{provider:e.provider,model:e.model,persona:y[_.length%y.length]?.id??`executor`}]),!0},[n,y,f,h,v,_]);return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(fd,{open:f!==null,mode:`provider-model`,title:f?e(nm[f].title):``,hint:f?e(nm[f].hint):void 0,onPick:e=>{if(e.type===`provider-model`)return x(e)},onClose:()=>p(null)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.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,Z.jsx)(lr,{className:`h-5 w-5`})}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`h3`,{className:`text-base font-semibold`,children:e(`settings:brain.heading`)}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings:brain.headingHint`)})]}),(o||c)&&(0,Z.jsx)(wt,{className:`ml-auto h-4 w-4 animate-spin text-muted-foreground`})]}),u&&(0,Z.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:u}),(0,Z.jsxs)(`div`,{className:`space-y-2 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.riskHeading`)}),(0,Z.jsx)(`div`,{className:`flex gap-2 flex-wrap`,children:jp.map(e=>(0,Z.jsxs)(Y,{variant:b===e?`default`:`outline`,size:`sm`,className:G(`gap-1.5 text-xs`,b===e&&`shadow-sm`),disabled:c,onClick:()=>g(e),children:[(0,Z.jsx)(em,{level:e}),e.toUpperCase()]},e))}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(Np[b])})]}),n&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.escalationHeading`)}),(0,Z.jsx)(Q,{label:e(`settings:brain.escalationModeLabel`),hint:e(`settings:brain.escalationModeHint`),value:n.mode,options:[{value:`interactive`,label:e(`settings:brain.optInteractive`)},{value:`headless`,label:e(`settings:brain.optHeadless`)}],onChange:e=>h({mode:e}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.escalationDecisionTimeoutLabel`),hint:e(`settings:brain.escalationDecisionTimeoutHint`),value:n.decisionTimeoutMs?String(n.decisionTimeoutMs):`default`,options:Qp(Ip,e),onChange:e=>h({decisionTimeoutMs:e==="default"?null:Number(e)}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.escalationHumanTimeoutLabel`),hint:e(`settings:brain.escalationHumanTimeoutHint`),value:n.humanTimeoutMs?String(n.humanTimeoutMs):`off`,options:Qp(Lp,e),onChange:e=>h({humanTimeoutMs:e===`off`?null:Number(e)}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.escalationTerminalPolicyLabel`),hint:e(`settings:brain.escalationTerminalPolicyHint`),value:n.terminalPolicy,options:[{value:`conservative`,label:e(`settings:brain.optConservative`)},{value:`deny-all`,label:e(`settings:brain.optDenyAll`)},{value:`continue-on-recommended`,label:e(`settings:brain.optContinueRecommended`)}],onChange:e=>h({terminalPolicy:e}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.escalationDecisionLogSizeLabel`),hint:e(`settings:brain.escalationDecisionLogSizeHint`),value:String(n.decisionLogMaxEntries),options:Qp(Zp(Vp,String(n.decisionLogMaxEntries)),e),onChange:e=>h({decisionLogMaxEntries:Number(e)}),disabled:c})]}),(0,Z.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.rulesHeading`)}),(0,Z.jsx)(wd,{variant:`outline`,className:`text-[10px]`,children:e(`settings:brain.rulesConfigured`,{count:n.rules.length})})]}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings:brain.rulesBody`)}),n.rules.length>0&&(0,Z.jsx)(`div`,{className:`space-y-1`,children:n.rules.map((t,n)=>(0,Z.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,Z.jsxs)(`span`,{className:`text-muted-foreground w-4 shrink-0`,children:[n+1,`.`]}),(0,Z.jsx)(`span`,{className:`flex-1 truncate font-mono`,children:t.id}),(0,Z.jsx)(wd,{variant:`outline`,className:`text-[10px] shrink-0`,children:t.then.action}),t.enabled===!1&&(0,Z.jsx)(wd,{variant:`outline`,className:`text-[10px] shrink-0`,children:e(`settings:brain.rulesOff`)})]},`${t.id}-${n}`))}),n.ruleErrors.length>0&&(0,Z.jsxs)(`div`,{className:`space-y-1 rounded-md border border-warning/40 bg-warning/10 px-2 py-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-warning`,children:e(`settings:brain.rulesDropped`,{count:n.ruleErrors.length})}),n.ruleErrors.map(e=>(0,Z.jsx)(`p`,{className:`text-xs text-warning`,children:e},e))]})]}),(0,Z.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.heuristicsHeading`)}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings:brain.heuristicsBody`)}),(0,Z.jsx)($,{label:e(`settings:brain.heuristicsLowRiskLabel`),hint:e(`settings:brain.heuristicsLowRiskHint`),value:n.heuristics.lowRiskAutoAnswer,onChange:()=>h({heuristics:{lowRiskAutoAnswer:!n.heuristics.lowRiskAutoAnswer}}),disabled:c}),(0,Z.jsx)($,{label:e(`settings:brain.heuristicsBlockedLabel`),hint:e(`settings:brain.heuristicsBlockedHint`),value:n.heuristics.blockedResolved,onChange:()=>h({heuristics:{blockedResolved:!n.heuristics.blockedResolved}}),disabled:c}),(0,Z.jsx)($,{label:e(`settings:brain.heuristicsDeadlockLabel`),hint:e(`settings:brain.heuristicsDeadlockHint`),value:n.heuristics.deadlockSkip,onChange:()=>h({heuristics:{deadlockSkip:!n.heuristics.deadlockSkip}}),disabled:c}),(0,Z.jsx)($,{label:e(`settings:brain.heuristicsRetryLabel`),hint:e(`settings:brain.heuristicsRetryHint`),value:n.heuristics.retryExhausted,onChange:()=>h({heuristics:{retryExhausted:!n.heuristics.retryExhausted}}),disabled:c}),(0,Z.jsx)($,{label:e(`settings:brain.heuristicsPingLabel`),hint:e(`settings:brain.heuristicsPingHint`),value:n.heuristics.continuePing,onChange:()=>h({heuristics:{continuePing:!n.heuristics.continuePing}}),disabled:c}),n.heuristics.blockedResolvedMarkers&&n.heuristics.blockedResolvedMarkers.length>0&&(0,Z.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:e(`settings:brain.heuristicsMarkers`,{markers:n.heuristics.blockedResolvedMarkers.join(`, `)})})]}),(0,Z.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.qualityHeading`)}),n.circuit&&(0,Z.jsx)(wd,{variant:n.circuit.state===`closed`?`outline`:`default`,className:`text-[10px]`,children:e(`settings:brain.qualityCircuit`,{state:n.circuit.state,count:n.circuit.consecutiveFailures})})]}),(0,Z.jsx)(Q,{label:e(`settings:brain.qualityResponseBudgetLabel`),hint:e(`settings:brain.qualityResponseBudgetHint`),value:String(n.llm.maxTokens),options:Qp(Zp(zp,String(n.llm.maxTokens)),e),onChange:e=>h({llm:{maxTokens:Number(e)}}),disabled:c}),(0,Z.jsx)($,{label:e(`settings:brain.qualityRejectLabel`),hint:e(`settings:brain.qualityRejectHint`),value:n.llm.rejectUncertain,onChange:()=>h({llm:{rejectUncertain:!n.llm.rejectUncertain}}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.qualityMinConfidenceLabel`),hint:e(`settings:brain.qualityMinConfidenceHint`),value:String(n.llm.minConfidence),options:Qp(Zp(Bp,String(n.llm.minConfidence)),e),onChange:e=>h({llm:{minConfidence:Number(e)}}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.qualityDenyTerminalLabel`),hint:e(`settings:brain.qualityDenyTerminalHint`),value:n.llm.denyIsTerminal,options:[{value:`never`,label:e(`settings:brain.optNeverDefault`)},{value:`when-decided`,label:e(`settings:brain.optWhenDecided`)},{value:`always`,label:e(`settings:brain.optAlways`)}],onChange:e=>h({llm:{denyIsTerminal:e}}),disabled:c})]}),(0,Z.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.traceHeading`)}),(0,Z.jsx)($,{label:e(`settings:brain.traceRecordLabel`),hint:e(`settings:brain.traceRecordHint`),value:n.trace.enabled,onChange:()=>h({trace:{enabled:!n.trace.enabled}}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.traceContentLabel`),hint:e(`settings:brain.traceContentHint`),value:n.trace.content,options:[{value:`full`,label:e(`settings:brain.optFullDefault`)},{value:`redacted`,label:e(`settings:brain.optRedacted`)},{value:`none`,label:e(`settings:brain.optMetadataOnly`)}],onChange:e=>h({trace:{content:e}}),disabled:c}),n.trace.path&&(0,Z.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:n.trace.path})]}),(0,Z.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.cacheHeading`)}),(0,Z.jsx)(wd,{variant:`outline`,className:`text-[10px]`,children:e(`settings:brain.cacheStats`,{hits:n.cache.hits,misses:n.cache.misses,size:n.cache.size})})]}),(0,Z.jsx)($,{label:e(`settings:brain.cacheReplayLabel`),hint:e(`settings:brain.cacheReplayHint`),value:n.cache.enabled,onChange:()=>h({cache:{enabled:!n.cache.enabled}}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.cacheLifetimeLabel`),hint:e(`settings:brain.cacheLifetimeHint`),value:String(n.cache.ttlMs),options:Qp(Zp(Hp,String(n.cache.ttlMs)),e),onChange:e=>h({cache:{ttlMs:Number(e)}}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.cacheMaxEntriesLabel`),hint:e(`settings:brain.cacheMaxEntriesHint`),value:String(n.cache.maxEntries),options:Qp(Zp(Up,String(n.cache.maxEntries)),e),onChange:e=>h({cache:{maxEntries:Number(e)}}),disabled:c})]}),(0,Z.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.monitorHeading`)}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings:brain.monitorBody`)}),(0,Z.jsx)($,{label:e(`settings:brain.monitorWatchLabel`),hint:e(`settings:brain.monitorWatchHint`),value:n.monitor.enabled!==!1,onChange:()=>h({monitor:{enabled:n.monitor.enabled===!1}}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.monitorPolicyLabel`),hint:e(`settings:brain.monitorPolicyHint`),value:n.monitor.policy??`llm`,options:[{value:`llm`,label:e(`settings:brain.optConsultBrain`)},{value:`steer`,label:e(`settings:brain.optAlwaysSteer`)},{value:`observe`,label:e(`settings:brain.optObserveOnly`)}],onChange:e=>h({monitor:{policy:e}}),disabled:c})]}),(0,Z.jsxs)(`div`,{className:`space-y-2 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.modelsHeading`)}),(0,Z.jsx)(wd,{variant:`outline`,className:`text-[10px]`,children:n.usingSessionModel?e(`settings:brain.modelsSessionBadge`):e(`settings:brain.modelsResolvedBadge`,{resolved:n.poolLabels.length,total:n.models.length})})]}),(0,Z.jsx)($,{label:e(`settings:brain.modelsUseSessionLabel`),hint:e(`settings:brain.modelsUseSessionHint`),value:n.usingSessionModel,onChange:()=>{n.usingSessionModel||h({models:null})},disabled:c}),n.models.length>0&&(0,Z.jsx)(`div`,{className:`space-y-1`,children:n.models.map((e,t)=>(0,Z.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,Z.jsxs)(`span`,{className:`text-muted-foreground w-4 shrink-0`,children:[t+1,`.`]}),(0,Z.jsx)(`span`,{className:`flex-1 truncate font-mono`,children:tm(e)}),(0,Z.jsx)(Y,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0`,disabled:c||t===0,onClick:()=>{let e=n.models.map(tm),r=e.splice(t,1)[0];r&&e.splice(t-1,0,r),h({models:e})},children:(0,Z.jsx)(ai,{className:`h-3 w-3`})}),(0,Z.jsx)(Y,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0`,disabled:c||t===n.models.length-1,onClick:()=>{let e=n.models.map(tm),r=e.splice(t,1)[0];r&&e.splice(t+1,0,r),h({models:e})},children:(0,Z.jsx)(qn,{className:`h-3 w-3`})}),(0,Z.jsx)(Y,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 text-destructive`,disabled:c,onClick:()=>{let e=n.models.map(tm).filter((e,n)=>n!==t);h({models:e.length>0?e:null})},children:(0,Z.jsx)(St,{className:`h-3 w-3`})})]},`${tm(e)}-${t}`))}),(0,Z.jsxs)(Y,{variant:`outline`,size:`sm`,className:`gap-1.5 text-xs`,disabled:c,onClick:()=>p(`pool`),children:[(0,Z.jsx)(_i,{className:`h-3.5 w-3.5`}),` `,e(`settings:brain.modelsAddModel`)]}),n.models.length>1&&(0,Z.jsx)(Q,{label:e(`settings:brain.modelsPoolStrategyLabel`),hint:e(`settings:brain.modelsPoolStrategyHint`),value:n.strategy,options:[{value:`fallback`,label:e(`settings:brain.optFallback`)},{value:`round-robin`,label:e(`settings:brain.optRoundRobin`)}],onChange:e=>h({strategy:e}),disabled:c})]}),(0,Z.jsxs)(`div`,{className:`space-y-2 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.councilHeading`)}),(0,Z.jsx)(wd,{variant:n.council.enabled?`default`:`outline`,className:`text-[10px]`,children:n.council.enabled?e(`settings:brain.councilConvened`):e(`settings:brain.councilDisabled`)})]}),(0,Z.jsx)($,{label:e(`settings:brain.councilEnableLabel`),hint:e(`settings:brain.councilEnableHint`),value:n.council.enabled,onChange:()=>h({council:{enabled:!n.council.enabled}}),disabled:c}),n.council.enabled&&n.councilLabels.length>0&&_.length===0&&(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings:brain.councilSeatsDerived`,{seats:n.councilLabels.join(`, `)})}),_.length>0&&(0,Z.jsx)(`div`,{className:`space-y-1`,children:_.map((t,n)=>(0,Z.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,Z.jsx)(`span`,{className:`flex-1 truncate font-mono`,children:tm(t)}),(0,Z.jsxs)(`select`,{value:t.persona??y[n%y.length]?.id??``,onChange:e=>v(_.map((t,r)=>r===n?{...t,persona:e.target.value}:t)),className:`h-6 rounded border bg-background px-1 text-[10px]`,title:y.find(e=>e.id===t.persona)?.description??e(`settings:brain.councilCustomLens`),children:[y.map(e=>(0,Z.jsx)(`option`,{value:e.id,children:e.name},e.id)),t.persona&&!y.some(e=>e.id===t.persona)&&(0,Z.jsx)(`option`,{value:t.persona,children:e(`settings:brain.councilCustomOption`,{persona:t.persona})})]}),(0,Z.jsx)(Y,{variant:t.veto?`default`:`outline`,size:`sm`,className:`h-6 px-1.5 text-[10px]`,disabled:c,onClick:()=>v(_.map((e,t)=>t===n?{...e,veto:!e.veto}:e)),children:e(`settings:brain.councilVeto`)}),(0,Z.jsx)(Y,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 text-destructive`,disabled:c,onClick:()=>v(_.filter((e,t)=>t!==n)),children:(0,Z.jsx)(St,{className:`h-3 w-3`})})]},`${tm(t)}-${n}`))}),(0,Z.jsxs)(Y,{variant:`outline`,size:`sm`,className:`gap-1.5 text-xs`,disabled:c,onClick:()=>p(`voter`),children:[(0,Z.jsx)(_i,{className:`h-3.5 w-3.5`}),` `,e(`settings:brain.councilAddVoter`)]}),(0,Z.jsx)(Q,{label:e(`settings:brain.councilRiskFloorLabel`),hint:e(`settings:brain.councilRiskFloorHint`),value:n.council.minRisk,options:[{value:`medium`,label:e(`settings:brain.optMediumPlus`)},{value:`high`,label:e(`settings:brain.optHighPlus`)},{value:`critical`,label:e(`settings:brain.optCriticalOnly`)}],onChange:e=>h({council:{minRisk:e}}),disabled:c}),(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3 py-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium`,children:e(`settings:brain.councilJudge`)}),(0,Z.jsx)(`div`,{className:`mt-0.5 text-xs text-muted-foreground`,children:e(`settings:brain.councilJudgeDesc`)}),!n.council.judge&&n.judgeLabel&&(0,Z.jsxs)(`div`,{className:`mt-0.5 font-mono text-xs text-muted-foreground`,children:[e(`settings:brain.councilResolved`,{model:n.judgeLabel}),n.judgeIsVoter&&(0,Z.jsx)(`span`,{className:`ml-1 font-sans text-warning`,children:e(`settings:brain.councilAlsoVoter`)})]})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`max-w-[180px] truncate font-mono text-xs`,children:n.council.judge?tm(n.council.judge):e(`settings:brain.councilAuto`)}),(0,Z.jsx)(Y,{variant:`outline`,size:`sm`,className:`h-7 text-xs`,disabled:c,onClick:()=>p(`judge`),children:e(`settings:brain.councilPick`)}),n.council.judge&&(0,Z.jsx)(Y,{variant:`ghost`,size:`sm`,className:`h-7 text-xs`,disabled:c,onClick:()=>h({council:{judge:null}}),children:e(`settings:brain.councilAutoReset`)})]})]}),(0,Z.jsx)(Q,{label:e(`settings:brain.councilQuorumLabel`),hint:e(`settings:brain.councilQuorumHint`),value:n.council.quorum===void 0?`default`:String(n.council.quorum),options:Qp(Rp,e),onChange:e=>h({council:{quorum:e==="default"?null:Number(e)}}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.councilApprovalLabel`),hint:e(`settings:brain.councilApprovalHint`),value:n.council.approval===void 0?`default`:String(n.council.approval),options:Qp(Rp,e),onChange:e=>h({council:{approval:e==="default"?null:Number(e)}}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.councilPerSeatTimeoutLabel`),hint:e(`settings:brain.councilPerSeatTimeoutHint`),value:$p(n.council.perCallTimeoutMs),options:Qp(Zp(Wp,$p(n.council.perCallTimeoutMs)),e),onChange:e=>h({council:{perCallTimeoutMs:e==="default"?null:Number(e)}}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.councilMaxConcurrencyLabel`),hint:e(`settings:brain.councilMaxConcurrencyHint`),value:$p(n.council.maxConcurrency),options:Qp(Zp(Gp,$p(n.council.maxConcurrency)),e),onChange:e=>h({council:{maxConcurrency:e==="default"?null:Number(e)}}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.councilDistinctnessLabel`),hint:e(`settings:brain.councilDistinctnessHint`),value:n.council.distinctness,options:[{value:`none`,label:e(`settings:brain.optNoneDefault`)},{value:`model`,label:e(`settings:brain.optDistinctModels`)},{value:`provider`,label:e(`settings:brain.optDistinctProviders`)}],onChange:e=>h({council:{distinctness:e}}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.councilVoterBudgetLabel`),hint:e(`settings:brain.councilVoterBudgetHint`),value:$p(n.council.voterMaxTokens),options:Qp(Zp(Kp,$p(n.council.voterMaxTokens)),e),onChange:e=>h({council:{voterMaxTokens:e==="default"?null:Number(e)}}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.councilRoundsLabel`),hint:e(`settings:brain.councilRoundsHint`),value:$p(n.council.deliberationRounds),options:Qp(Zp(qp,$p(n.council.deliberationRounds)),e),onChange:e=>h({council:{deliberationRounds:e==="default"?null:Number(e)}}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.councilJudgeBudgetLabel`),hint:e(`settings:brain.councilJudgeBudgetHint`),value:$p(n.council.judgeMaxTokens),options:Qp(Zp(Jp,$p(n.council.judgeMaxTokens)),e),onChange:e=>h({council:{judgeMaxTokens:e==="default"?null:Number(e)}}),disabled:c}),n.council.seats.length>0&&(0,Z.jsxs)(`p`,{className:`truncate text-xs text-muted-foreground`,children:[e(`settings:brain.councilSeatTemplate`),` `,n.council.seats.map(t=>t.veto?`${t.persona} (${e(`settings:brain.councilVeto`)})`:t.persona).join(`, `)]})]}),(0,Z.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.ledgerHeading`)}),(0,Z.jsx)($,{label:e(`settings:brain.ledgerRecordLabel`),hint:e(`settings:brain.ledgerRecordHint`),value:n.ledger.enabled,onChange:()=>h({ledger:{enabled:!n.ledger.enabled}}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.ledgerAutoDenyLabel`),hint:e(`settings:brain.ledgerAutoDenyHint`),value:n.ledger.autoDenyAfterFailures===void 0?`default`:String(n.ledger.autoDenyAfterFailures),options:[{value:`default`,label:e(`settings:brain.optDefault3`)},{value:`0`,label:e(`settings:brain.optOff`)},{value:`2`,label:`2`},{value:`3`,label:`3`},{value:`5`,label:`5`}],onChange:e=>h({ledger:{autoDenyAfterFailures:e==="default"?null:Number(e)}}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.ledgerMemoryEntriesLabel`),hint:e(`settings:brain.ledgerMemoryEntriesHint`),value:$p(n.ledger.maxMemoryEntries),options:Qp(Zp(Yp,$p(n.ledger.maxMemoryEntries)),e),onChange:e=>h({ledger:{maxMemoryEntries:e==="default"?null:Number(e)}}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.ledgerRetryWindowLabel`),hint:e(`settings:brain.ledgerRetryWindowHint`),value:$p(n.ledger.interventionRetryWindowMs),options:Qp(Zp(Xp,$p(n.ledger.interventionRetryWindowMs)),e),onChange:e=>h({ledger:{interventionRetryWindowMs:e==="default"?null:Number(e)}}),disabled:c}),n.ledger.path&&(0,Z.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:n.ledger.path})]})]}),(0,Z.jsxs)(`div`,{className:`space-y-2 rounded-md border border-border/70 bg-card/70 p-3`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.recentHeading`,{count:i.length})}),(0,Z.jsx)(`div`,{className:`space-y-1 max-h-[300px] overflow-y-auto`,children:i.length===0?(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground py-2`,children:e(`settings:brain.recentEmpty`)}):i.map(e=>(0,Z.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,Z.jsx)(`span`,{className:`text-muted-foreground shrink-0 w-8`,children:e.age}),(0,Z.jsx)(wd,{variant:`outline`,className:`text-[10px] shrink-0`,children:e.kind}),(0,Z.jsx)(`span`,{className:`flex-1 truncate`,children:e.question}),e.outcome&&(0,Z.jsx)(`span`,{className:`text-muted-foreground shrink-0 italic`,children:e.outcome})]},`${e.age}-${e.kind}-${e.question.slice(0,32)}`))})]})]})}function im(){let{t:e}=H();return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Xt,{className:`h-5 w-5 text-info`}),(0,Z.jsx)(`h3`,{className:`text-lg font-semibold`,children:e(`activity:shadow.shadowAgent`)})]}),(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`activity:shadow.theShadowAgentMonitorsAllFleet`)}),(0,Z.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Start and stop it from the chat with`,` `,(0,Z.jsx)(`code`,{className:`font-mono text-xs`,children:`/shadow start`}),` and`,` `,(0,Z.jsx)(`code`,{className:`font-mono text-xs`,children:`/shadow stop`}),`. This panel cannot control it yet.`]})]})}function am({disabled:e,direct:t}){let n=e?`bg-muted-foreground`:t?`bg-success`:`bg-info`,r=e?`disabled`:t?`direct provider tool`:`lazy catalog tool`;return(0,Z.jsx)(`span`,{className:`inline-block h-2 w-2 shrink-0 rounded-full ${n}`,title:r})}function om({tool:e,onToggle:t,busy:n}){let{t:r}=H(),[i,a]=(0,X.useState)(!1);return(0,Z.jsxs)(`div`,{className:`space-y-2 rounded-md border border-border/70 bg-card/70 p-3 transition-colors hover:bg-card`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 sm:flex-row sm:items-start`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-2`,children:[(0,Z.jsx)(am,{disabled:e.disabled,direct:e.direct}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`code`,{className:`block truncate text-sm font-mono font-semibold`,title:e.name,children:e.name}),(0,Z.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1.5`,children:[(0,Z.jsx)(wd,{variant:`outline`,className:`px-1.5 text-[10px]`,children:e.permission}),(0,Z.jsx)(wd,{variant:`outline`,className:`px-1.5 text-[10px]`,children:e.mutating?`mutating`:`read-only`}),(0,Z.jsx)(wd,{variant:`outline`,className:`px-1.5 text-[10px]`,children:e.disabled?`disabled`:e.direct?`direct`:`lazy`}),(0,Z.jsx)(`span`,{className:`truncate text-[11px] text-muted-foreground`,title:e.owner,children:e.owner})]})]})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-1`,children:[(0,Z.jsxs)(Y,{variant:e.disabled?`default`:`secondary`,size:`sm`,className:`h-7 gap-1 px-2 text-xs`,onClick:t,disabled:n,children:[n?(0,Z.jsx)(wt,{className:`h-3 w-3 animate-spin`}):e.disabled?(0,Z.jsx)(ni,{className:`h-3 w-3`}):(0,Z.jsx)(Un,{className:`h-3 w-3`}),e.disabled?`Enable`:`Disable`]}),(0,Z.jsx)(`button`,{type:`button`,className:`rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,onClick:()=>a(!i),"aria-label":i?`Collapse`:`Expand`,children:(0,Z.jsx)(Ct,{className:`h-4 w-4 transition-transform ${i?`rotate-180`:``}`})})]})]}),i&&(0,Z.jsxs)(`div`,{className:`space-y-1 border-t border-border/60 pt-2 text-xs text-muted-foreground sm:ml-4`,children:[(0,Z.jsx)(`p`,{children:e.description}),e.params.length>0&&(0,Z.jsxs)(`p`,{children:[r(`activity:toolsSec.params`),` `,(0,Z.jsx)(`code`,{className:`break-all font-mono`,children:e.params.join(`, `)})]})]})]})}function sm(){let{t:e}=H(),{client:t}=ha(),[n,r]=(0,X.useState)([]),[i,a]=(0,X.useState)(!0),[o,s]=(0,X.useState)(``),[c,l]=(0,X.useState)(new Set);(0,X.useEffect)(()=>{let e=t.on(`tools.list`,e=>{let t=e.payload;r(t.tools),a(!1)}),n=e=>{if(e.type===`tool.disabled`||e.type===`tool.enabled`){let n=e.payload;l(e=>{let t=new Set(e);return t.delete(n.name),t}),n.ok?t.send({type:`tools.list`},{echoToChat:!1}):B.error(`Tool "${n.name}" ${e.type===`tool.disabled`?`disable`:`enable`} failed.`)}},i=t.on(`tool.disabled`,n),o=t.on(`tool.enabled`,n);return()=>{e(),i(),o()}},[t]),(0,X.useEffect)(()=>{t.send({type:`tools.list`},{echoToChat:!1})},[t]);let u=(0,X.useCallback)((e,n)=>{l(t=>new Set(t).add(e)),t.send({type:n?`tool.enable`:`tool.disable`,payload:{name:e}})},[t]),d=o?n.filter(e=>e.name.toLowerCase().includes(o.toLowerCase())||e.owner.toLowerCase().includes(o.toLowerCase())):n,f=n.filter(e=>!e.disabled&&e.direct).length,p=n.filter(e=>!e.disabled&&!e.direct).length,m=n.filter(e=>e.disabled).length;return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Z.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,Z.jsx)(li,{className:`h-5 w-5`})}),(0,Z.jsx)(`h3`,{className:`text-base font-semibold`,children:e(`activity:toolsSec.tools`)})]}),!i&&(0,Z.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:[f,` direct · `,p,` lazy · `,m,` disabled · `,n.length,` `,`total`]})]}),(0,Z.jsxs)(`div`,{className:`relative`,children:[(0,Z.jsx)(vn,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground`}),(0,Z.jsx)(Ya,{placeholder:e(`activity:toolsSec.filterToolsByNameOrOwner`),value:o,onChange:e=>s(e.target.value),className:`pl-8 h-9 text-sm`})]}),i?(0,Z.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground gap-2`,children:[(0,Z.jsx)(wt,{className:`h-4 w-4 animate-spin`}),e(`activity:toolsSec.loadingTools`)]}):d.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground py-4 text-center`,children:o?`No tools matching "${o}".`:`No tools registered.`}):(0,Z.jsxs)(`div`,{className:`relative overflow-hidden rounded-lg border border-border/70 bg-background/35 shadow-inner`,children:[(0,Z.jsx)(`ul`,{className:`max-h-[min(58dvh,660px)] space-y-2 overflow-y-auto p-2 pr-3 [scrollbar-gutter:stable]`,"aria-label":e(`activity:toolsSec.toolsList`),children:d.map(e=>(0,Z.jsx)(`li`,{children:(0,Z.jsx)(om,{tool:e,onToggle:()=>u(e.name,e.disabled),busy:c.has(e.name)})},e.name))}),(0,Z.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 top-0 h-4 bg-gradient-to-b from-background/90 to-transparent`}),(0,Z.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 h-8 bg-gradient-to-t from-background/95 to-transparent`})]})]})}function cm(){let{t:e}=H();return(0,Z.jsxs)(`div`,{className:`space-y-6`,children:[(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 mb-4 pb-3 border-b border-border/50`,children:[(0,Z.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,Z.jsx)(Xt,{className:`h-5 w-5`})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:e(`settings:security.brainHeading`)}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e(`settings:security.brainHint`)})]})]}),(0,Z.jsx)(rm,{})]}),(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 mb-4 pb-3 border-b border-border/50`,children:[(0,Z.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,Z.jsx)(Xt,{className:`h-5 w-5`})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:e(`settings:security.shadowHeading`)}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e(`settings:security.shadowHint`)})]})]}),(0,Z.jsx)(im,{})]}),(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 mb-4 pb-3 border-b border-border/50`,children:[(0,Z.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,Z.jsx)(Xt,{className:`h-5 w-5`})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:e(`settings:security.toolsHeading`)}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e(`settings:security.toolsHint`)})]})]}),(0,Z.jsx)(sm,{})]})]})}function lm(e,t,n,r,i){e.set({[r]:i}),t({[r]:i}),r===`contextMode`&&typeof i==`string`&&n(i)}var um=[{id:`general`,icon:(0,Z.jsx)(Jn,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.general`,descKey:`settings:tabs.generalDesc`},{id:`provider`,icon:(0,Z.jsx)(Fi,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.provider`,descKey:`settings:tabs.providerDesc`},{id:`connection`,icon:(0,Z.jsx)(Bn,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.connection`,descKey:`settings:tabs.connectionDesc`},{id:`agent`,icon:(0,Z.jsx)(jr,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.agent`,descKey:`settings:tabs.agentDesc`},{id:`execution`,icon:(0,Z.jsx)(at,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.execution`,descKey:`settings:tabs.executionDesc`},{id:`fallbacks`,icon:(0,Z.jsx)(Pr,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.fallbacks`,descKey:`settings:tabs.fallbacksDesc`},{id:`routing`,icon:(0,Z.jsx)(On,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.routing`,descKey:`settings:tabs.routingDesc`},{id:`fleet`,icon:(0,Z.jsx)(Zr,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.fleet`,descKey:`settings:tabs.fleetDesc`},{id:`integrations`,icon:(0,Z.jsx)(Nr,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.integrations`,descKey:`settings:tabs.integrationsDesc`},{id:`chimera`,icon:(0,Z.jsx)(lr,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.chimera`,descKey:`settings:tabs.chimeraDesc`},{id:`context`,icon:(0,Z.jsx)(tn,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.context`,descKey:`settings:tabs.contextDesc`},{id:`logs`,icon:(0,Z.jsx)(Oe,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.logs`,descKey:`settings:tabs.logsDesc`},{id:`security`,icon:(0,Z.jsx)(Vr,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.security`,descKey:`settings:tabs.securityDesc`},{id:`display`,icon:(0,Z.jsx)(Jn,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.display`,descKey:`settings:tabs.displayDesc`}];function dm(){let{settingsActiveTab:e,setSettingsActiveTab:t}=K(Me(e=>({settingsActiveTab:e.settingsActiveTab,setSettingsActiveTab:e.setSettingsActiveTab}))),n=Gu(`settings`),r=(0,X.useRef)(!1),[i,a]=(0,X.useState)(!1),{provider:o,model:s,setProvider:c,setModel:l,wsConnected:u}=R(Me(e=>({provider:e.provider,model:e.model,setProvider:e.setProvider,setModel:e.setModel,wsConnected:e.wsConnected}))),d=ha(),f=d.client,{updatePrefs:p,switchAutonomy:m,switchContextMode:h}=d,g=W(),{t:_}=H(),v=to(!0),y=(0,X.useCallback)((e,t)=>{lm(g,p,h,e,t)},[g,p,h]),[b,x]=(0,X.useState)([]),[S,C]=(0,X.useState)({}),[w,T]=(0,X.useState)([]),[E,D]=(0,X.useState)(!1),[O,k]=(0,X.useState)(!1),[A,j]=(0,X.useState)(!1),[M,N]=(0,X.useState)(`catalog`),[P,F]=(0,X.useState)(``),[I,L]=(0,X.useState)(!1),ee=(0,X.useCallback)(()=>{g.reset(),L(!1),window.location.reload()},[g]),te=b.find(e=>e.id===o),z=um.find(t=>t.id===e);(0,X.useEffect)(()=>{let e=e=>{if(e.type===`provider.catalog`){let t=e.payload;x(t.providers.sort((e,t)=>e.id.localeCompare(t.id))),D(!1)}},t=e=>{if(e.type===`provider.models`){let t=e.payload;C(e=>({...e,[t.provider]:t.models})),k(!1)}},n=e=>{if(e.type===`providers.saved`){let t=e.payload.providers.sort((e,t)=>e.id.localeCompare(t.id));T(t),j(!1),t.length>0&&N(`saved`)}};if(!u||!f)return;let r=f.on(`provider.catalog`,e),i=f.on(`provider.models`,t),a=f.on(`providers.saved`,n);return D(!0),j(!0),f.listProviders(),f.listSavedProviders(),()=>{r?.(),i?.(),a?.()}},[u,f]);let ne=(0,X.useCallback)(e=>{c(e),S[e]||(k(!0),d.listProviderModels?.(e))},[S,c,d]),re=(0,X.useCallback)(async e=>{if(r.current)return;let t=R.getState().model,n=R.getState().provider;if(!(!n||e===t)){r.current=!0,a(!0),l(e);try{B.info(U.t(`settings:toast.switchingTo`,{provider:n,model:e}));let r=await d.switchModel?.(n,e);r?.success?B.success(U.t(r.runActive?`settings:toast.modelSwitchedRunActive`:`settings:toast.modelSwitchedNextRequest`,{from:`${n} / ${t}`,to:`${n} / ${e}`})):(l(t),B.error(r?.message??U.t(`settings:toast.modelSwitchTimeout`)))}finally{r.current=!1,a(!1)}}},[l,d]),ie=(0,X.useCallback)((e,t,n)=>{d.addKey?.(e,t,n)},[d]),ae=(0,X.useCallback)((e,t)=>{d.deleteKey?.(e,t)},[d]),oe=(0,X.useCallback)((e,t)=>{d.setActiveKey?.(e,t)},[d]),se=(0,X.useCallback)((e,t,n,r,i,a)=>{d.addProvider?.(e,t,n,r,i,a)},[d]),ce=(0,X.useCallback)(e=>{d.removeProvider?.(e)},[d]),le=(0,X.useCallback)((e,t)=>{d.client.updateProvider({id:e,models:[t]}),e===R.getState().provider&&l(t)},[l,d.client]);return(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col bg-gradient-to-b from-background/90 via-background/60 to-background/80`,children:[(0,Z.jsxs)(`header`,{className:`flex items-center justify-between px-4 py-3 border-b border-border/60 bg-card/60 backdrop-blur-xl shrink-0 shadow-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(`span`,{className:`flex h-9 w-9 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,Z.jsx)(nn,{className:`h-5 w-5`})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h1`,{className:`text-lg font-semibold bg-gradient-to-r from-foreground to-foreground/70 bg-clip-text text-transparent`,children:_(`settings:title`)}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-[11px] text-muted-foreground`,children:o&&s?`${o} / ${s}`:_(`settings:subtitle`)})]})]}),(0,Z.jsx)(Y,{variant:`ghost`,size:`icon`,onClick:()=>J(`chat`),children:(0,Z.jsx)(St,{className:`h-4 w-4`})}),(0,Z.jsx)(Y,{variant:`ghost`,size:`sm`,onClick:()=>L(!0),children:_(`settings:resetLabel`)})]}),(0,Z.jsx)(js,{className:`min-h-0 flex-1`,ref:n,children:(0,Z.jsx)(`div`,{className:`mx-auto max-w-7xl p-4 sm:p-6`,children:(0,Z.jsxs)(Ns,{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,Z.jsxs)(`div`,{className:`relative min-w-0`,children:[(0,Z.jsx)(Ps,{className:`flex h-auto w-full justify-start gap-0.5 overflow-x-auto rounded-lg border border-border/60 bg-card/60 p-1.5 shadow-sm [scrollbar-gutter:stable] lg:sticky lg:top-4 lg:flex-col lg:overflow-visible lg:rounded-xl lg:bg-card/60 lg:p-2`,children:um.map(e=>(0,Z.jsxs)(Fs,{value:e.id,className:`h-9 shrink-0 gap-2.5 rounded-md px-3 text-xs scroll-mt-2 data-[state=active]:bg-primary/10 data-[state=active]:text-primary data-[state=active]:shadow-sm lg:w-full lg:justify-start lg:px-3`,children:[(0,Z.jsx)(`span`,{className:`shrink-0`,children:e.icon}),(0,Z.jsx)(`span`,{className:`truncate`,children:_(e.labelKey)})]},e.id))}),(0,Z.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,Z.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,Z.jsxs)(`div`,{className:`min-w-0 space-y-0`,children:[z?.descKey&&(0,Z.jsxs)(`div`,{className:`mb-4 flex items-start gap-3 rounded-xl border border-border/60 bg-card/50 px-4 py-3`,children:[(0,Z.jsx)(`span`,{className:`mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:z.icon}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-semibold`,children:_(z.labelKey)}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:_(z.descKey)})]})]}),(0,Z.jsx)(Is,{value:`general`,className:`mt-0`,children:(0,Z.jsx)(jd,{})}),(0,Z.jsxs)(Is,{value:`provider`,className:`mt-0 space-y-4`,children:[(0,Z.jsx)(_p,{activeProvider:o,catalogProviders:b,isLoadingCatalog:E,savedProviders:w,isLoadingSaved:A,providerTab:M,setProviderTab:N,onSelectProvider:ne,onAddKey:ie,onDeleteKey:ae,onSetActiveKey:oe,onAddProvider:se,onRemoveProvider:ce,onPickProviderModel:le,ws:d.client,catalogQuery:P,setCatalogQuery:F}),(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,Z.jsxs)(`h3`,{className:`text-sm font-semibold mb-4 flex items-center gap-2`,children:[(0,Z.jsx)(ar,{className:`h-4 w-4 text-muted-foreground`}),_(`settings:model.heading`)]}),(0,Z.jsx)(vf,{provider:o,catalogModels:S,currentCatalogProvider:te,isLoadingModels:O,setIsLoadingModels:k,onModelSelect:re,isSwitching:i,refreshModels:e=>d.listProviderModels?.(e)}),(0,Z.jsx)(_f,{syncPref:y})]})]}),(0,Z.jsx)(Is,{value:`connection`,className:`mt-0`,children:(0,Z.jsx)(Ad,{})}),(0,Z.jsx)(Is,{value:`agent`,className:`mt-0 space-y-6`,children:(0,Z.jsx)(md,{syncPref:y,switchAutonomy:m})}),(0,Z.jsx)(Is,{value:`execution`,className:`mt-0 space-y-6`,children:(0,Z.jsx)(Qd,{syncPref:y,fallbackCandidates:v})}),(0,Z.jsx)(Is,{value:`fallbacks`,className:`mt-0`,children:(0,Z.jsx)(af,{syncPref:y,candidates:v,provider:o,activeModel:s,setProvider:c,setModel:l,switchModel:d.switchModel})}),(0,Z.jsxs)(Is,{value:`routing`,className:`mt-0`,children:[(0,Z.jsx)(Ap,{syncPref:y,candidates:v}),(0,Z.jsx)(`div`,{className:`mt-6 border-t border-border pt-6`,children:(0,Z.jsx)(xf,{syncPref:y})})]}),(0,Z.jsx)(Is,{value:`fleet`,className:`mt-0`,children:(0,Z.jsx)(of,{syncPref:y})}),(0,Z.jsx)(Is,{value:`integrations`,className:`mt-0`,children:(0,Z.jsx)(hf,{syncPref:y})}),(0,Z.jsx)(Is,{value:`chimera`,className:`mt-0 space-y-6`,children:(0,Z.jsx)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:(0,Z.jsx)(Md,{syncPref:y,sessionProvider:o,sessionModel:s})})}),(0,Z.jsx)(Is,{value:`context`,className:`mt-0 space-y-6`,children:(0,Z.jsx)(Rd,{syncPref:y})}),(0,Z.jsx)(Is,{value:`logs`,className:`mt-0 space-y-6`,children:(0,Z.jsx)(gf,{syncPref:y})}),(0,Z.jsx)(Is,{value:`security`,className:`mt-0`,children:(0,Z.jsx)(cm,{})}),(0,Z.jsx)(Is,{value:`display`,className:`mt-0`,children:(0,Z.jsx)(Ud,{syncPref:y})})]})]})})}),(0,Z.jsx)(Ja,{open:I,onOpenChange:L,children:(0,Z.jsxs)(Ga,{showCloseButton:!1,children:[(0,Z.jsxs)(Ua,{children:[(0,Z.jsx)(Ka,{children:_(`settings:resetConfirmTitle`)}),(0,Z.jsx)(qa,{children:_(`settings:resetConfirmBody`)})]}),(0,Z.jsxs)(Wa,{className:`gap-2 sm:gap-0`,children:[(0,Z.jsx)(Y,{variant:`outline`,onClick:()=>L(!1),children:_(`settings:cancel`)}),(0,Z.jsx)(Y,{variant:`destructive`,onClick:ee,children:_(`settings:resetConfirmAction`)})]})]})})]})}var fm=(0,X.lazy)(()=>ta(()=>import(`./AnalyticsDashboard-BgZiiiDb.js`).then(e=>({default:e.AnalyticsDashboard})),__vite__mapDeps([17,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,19,20,21]))),pm=(0,X.lazy)(()=>ta(()=>import(`./AgentRosterView-B_J6SvVF.js`).then(e=>({default:e.AgentRosterView})),__vite__mapDeps([22,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,19,18,20,21,23,24,25,26,27,28,29,30,31,32,33]))),mm=(0,X.lazy)(()=>ta(()=>import(`./ChangesView-CmZeNwbw.js`).then(e=>({default:e.ChangesView})),__vite__mapDeps([34,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,25,20,18,19,21,23,26,35,36,37,38]))),hm=(0,X.lazy)(()=>ta(()=>import(`./ChronicleDashboard-B6lhZGjz.js`).then(e=>({default:e.ChronicleDashboard})),__vite__mapDeps([39,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]))),gm=(0,X.lazy)(()=>ta(()=>import(`./CodeEditor-Daz1yqjF.js`).then(e=>({default:e.CodeEditor})),__vite__mapDeps([40,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,20,18,19,21,23,35,36,37,38,41,30,32]))),_m=(0,X.lazy)(()=>ta(()=>import(`./CodeMap-D-H9FNUJ.js`).then(e=>({default:e.CodeMap})),__vite__mapDeps([42,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,20,26]))),vm=(0,X.lazy)(()=>ta(()=>import(`./DebugDashboard-Uh9QLbEk.js`).then(e=>({default:e.DebugDashboard})),__vite__mapDeps([43,1,2,3,4,5,6,7,8,9,10,11,12,13,14]))),ym=(0,X.lazy)(()=>ta(()=>import(`./DesignGalleryView-Da1QtI5b.js`).then(e=>({default:e.DesignGalleryView})),__vite__mapDeps([44,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,25,20,18,19,21,23,26]))),bm=(0,X.lazy)(()=>ta(()=>import(`./GoalView-BgVxzzzS.js`).then(e=>({default:e.GoalView})),__vite__mapDeps([45,1,2,3,4,5,6,7,8,9,10,11,12,13,14,25,0,15,16,20,18,19,21,23,26,30,46,29,31]))),xm=(0,X.lazy)(()=>ta(()=>import(`./KanbanView-_JvZKFyI.js`).then(e=>({default:e.KanbanView})),__vite__mapDeps([47,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,19,20,21,29,24,25,23,26,48]))),Sm=(0,X.lazy)(()=>ta(()=>import(`./MailboxDetailView-26bVSSbU.js`).then(e=>({default:e.MailboxDetailView})),__vite__mapDeps([49,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,21,23,37]))),Cm=(0,X.lazy)(()=>ta(()=>import(`./PromptJournalView-B65KxlYi.js`).then(e=>({default:e.PromptJournalView})),__vite__mapDeps([50,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]))),wm=(0,X.lazy)(()=>ta(()=>import(`./RefreshDebugView-CNovrSAn.js`).then(e=>({default:e.RefreshDebugView})),__vite__mapDeps([51,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,19]))),Tm=(0,X.lazy)(()=>ta(()=>import(`./SageTabs-CJqOqiY7.js`).then(e=>({default:e.SageTabs})),__vite__mapDeps([52,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]))),Em=(0,X.lazy)(()=>ta(()=>import(`./RequirementIntakeView-BnrQSVE_.js`).then(e=>({default:e.RequirementIntakeView})),__vite__mapDeps([53,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,30,31]))),Dm=(0,X.lazy)(()=>ta(()=>import(`./SddHub-mFjsa_Zl.js`).then(e=>({default:e.SddHub})),__vite__mapDeps([54,1,2,3,4,5,6,7,8,9,10,11,12,13,14,25,0,15,16,20,18,19,21,23,26,29,30,24,48]))),Om=(0,X.lazy)(()=>ta(()=>import(`./SessionsDashboard-BCYViJlx.js`).then(e=>({default:e.SessionsDashboard})),__vite__mapDeps([55,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,25,20,18,19,21,23,26,56,46,29,30,31]))),km=(0,X.lazy)(()=>ta(()=>import(`./SessionInspectView-MEmxIEzB.js`).then(e=>({default:e.SessionInspectView})),__vite__mapDeps([57,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,25,20,18,19,21,23,26,56,46,29,30,31]))),Am=(0,X.lazy)(()=>ta(()=>import(`./SkillDetailView-ebz2dRUQ.js`).then(e=>({default:e.SkillDetailView})),__vite__mapDeps([58,1,2,3,4,5,6,7,8,9,10,11,12,13,14,25,0,15,16,20,18,19,21,23,26,29,37]))),jm=(0,X.lazy)(()=>ta(()=>import(`./TechStackView-DESDpUDA.js`).then(e=>({default:e.TechStackView})),__vite__mapDeps([59,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,18,0,16,19,20,21,30,31]))),Mm=(0,X.lazy)(()=>ta(()=>import(`./DeadCodeScanPanel-Cn5bSfLv.js`).then(e=>({default:e.DeadCodeScanPanel})),__vite__mapDeps([60,1,2,3,4,5,6,7,8,9,10,11,12,13,14]))),Nm=(0,X.lazy)(()=>ta(()=>import(`./ChimeraReviewsView-CpfSkgQ2.js`).then(e=>({default:e.ChimeraReviewsView})),__vite__mapDeps([61,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,37]))),Pm=(0,X.lazy)(()=>ta(()=>import(`./SetupScreen-BwnSJt7v.js`).then(e=>({default:e.SetupScreen})),__vite__mapDeps([62,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,25,20,18,19,21,23,26,29,30,31]))),Fm={settings:{Component:dm,wrapperClassName:`flex-1 min-h-0 min-w-0 overflow-hidden`,boundaryNameKey:`activity:panels.settings`,loadingLabelKey:null},memory:{Component:Tm,wrapperClassName:``,boundaryNameKey:`activity:panels.sageMemory`,loadingLabelKey:`activity:panels.sageMemory`},roster:{Component:pm,wrapperClassName:`flex min-h-0 min-w-0 flex-1 overflow-hidden`,boundaryNameKey:`activity:panels.agentRoster`,loadingLabelKey:`activity:panels.agentRoster`},context:{Component:ud,wrapperClassName:``,boundaryNameKey:`activity:panels.contextDashboard`,loadingLabelKey:null},setup:{Component:Pm,wrapperClassName:`flex-1 min-h-0 min-w-0 overflow-hidden`,boundaryNameKey:`activity:panels.setup`,loadingLabelKey:null},goal:{Component:bm,wrapperClassName:`flex-1 min-h-0 min-w-0 overflow-hidden`,boundaryNameKey:`activity:panels.goal`,loadingLabelKey:null,props:{onClose:`PANEL_CLOSE_TO_CHAT`}},sddhub:{Component:Dm,wrapperClassName:`flex-1 min-h-0 min-w-0 overflow-hidden`,boundaryNameKey:`activity:panels.sddHub`,loadingLabelKey:null},kanban:{Component:xm,wrapperClassName:`flex-1 min-h-0 min-w-0 overflow-hidden`,boundaryNameKey:`activity:panels.kanban`,loadingLabelKey:null,props:{onClose:`PANEL_CLOSE_TO_CHAT`}},sessions:{Component:Om,wrapperClassName:`flex-1 min-h-0 min-w-0 overflow-hidden`,boundaryNameKey:`activity:panels.sessions`,loadingLabelKey:null},"session-inspect":{Component:km,wrapperClassName:`flex-1 min-h-0 min-w-0 overflow-hidden`,boundaryNameKey:`activity:panels.sessionInspect`,loadingLabelKey:`activity:panels.sessionInspect`},chronicle:{Component:hm,wrapperClassName:`flex-1 min-h-0 min-w-0 overflow-hidden`,boundaryNameKey:`activity:panels.chronicle`,loadingLabelKey:null},intake:{Component:Em,wrapperClassName:`flex-1 min-h-0 min-w-0 overflow-hidden`,boundaryNameKey:`activity:panels.requirementsIntake`,loadingLabelKey:null},prompts:{Component:Cm,wrapperClassName:`flex-1 min-h-0 min-w-0 overflow-hidden`,boundaryNameKey:`activity:nav.prompts`,loadingLabelKey:`activity:nav.prompts`},debug:{Component:vm,wrapperClassName:`flex-1 min-h-0 min-w-0 overflow-hidden`,boundaryNameKey:`activity:panels.debugDashboard`,loadingLabelKey:null},"refresh-debug":{Component:wm,wrapperClassName:`flex-1 min-h-0 min-w-0 overflow-hidden`,boundaryNameKey:`activity:panels.refreshDebug`,loadingLabelKey:`activity:panels.refreshDebug`},files:{Component:gm,wrapperClassName:`flex-1 min-h-0 min-w-0 overflow-hidden`,boundaryNameKey:`activity:panels.editor`,loadingLabelKey:`activity:panels.editor`},changes:{Component:mm,wrapperClassName:`flex-1 min-h-0 min-w-0 overflow-hidden`,boundaryNameKey:`activity:panels.changes`,loadingLabelKey:`activity:panels.changes`,props:{className:`h-full min-h-0`}},mailbox:{Component:Sm,wrapperClassName:`flex-1 min-h-0 min-w-0 overflow-hidden`,boundaryNameKey:`activity:panels.mailbox`,loadingLabelKey:null,props:{className:`h-full min-h-0`}},"design-gallery":{Component:ym,wrapperClassName:`flex-1 min-h-0 min-w-0 overflow-hidden`,boundaryNameKey:`activity:panels.designGallery`,loadingLabelKey:null,props:{className:`h-full`}},skill:{Component:Am,wrapperClassName:`flex-1 min-h-0 min-w-0 overflow-hidden`,boundaryNameKey:`activity:panels.skill`,loadingLabelKey:null,props:{className:`h-full`}},analytics:{Component:fm,wrapperClassName:`flex-1 min-h-0 min-w-0 overflow-hidden`,boundaryNameKey:`activity:panels.analytics`,loadingLabelKey:null},codemap:{Component:_m,wrapperClassName:`flex-1 min-h-0 min-w-0 overflow-hidden`,boundaryNameKey:`activity:panels.codemap`,loadingLabelKey:`activity:panels.codemap`},techstack:{Component:jm,wrapperClassName:`flex-1 min-h-0 min-w-0 overflow-hidden`,boundaryNameKey:`activity:panels.techstack`,loadingLabelKey:`activity:panels.techstack`},deadcode:{Component:Mm,wrapperClassName:`flex-1 min-h-0 min-w-0 overflow-y-auto`,boundaryNameKey:`activity:panels.deadcode`,loadingLabelKey:`activity:panels.deadcode`},chimera:{Component:Nm,wrapperClassName:`flex-1 min-h-0 min-w-0 overflow-hidden`,boundaryNameKey:`activity:nav.chimera`,loadingLabelKey:null}};function Im({view:e,onCloseToChat:t}){let{t:n}=H(),r=Fm[e];if(!r)return null;let i=r.Component,a={...r.props??{}};for(let[e,n]of Object.entries(a))n===`PANEL_CLOSE_TO_CHAT`&&(a[e]=t);let o=r.wrapperClassName?(0,Z.jsx)(`div`,{className:r.wrapperClassName,children:(0,Z.jsx)(i,{...a})}):(0,Z.jsx)(i,{...a}),s=r.loadingLabelKey?(0,Z.jsx)(Wu,{label:n(`common:loadingNamed`,{name:n(r.loadingLabelKey)})}):(0,Z.jsx)(Wu,{});return(0,Z.jsx)(Os,{level:`panel`,name:n(r.boundaryNameKey),children:(0,Z.jsx)(X.Suspense,{fallback:s,children:o})})}function Lm(){J(`chat`)}function Rm(e){try{return new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}catch{return e}}function zm(e){switch(e){case`active`:return`text-success border-success/30 bg-success/[0.06]`;case`injected`:return`text-primary border-primary/30 bg-primary/[0.06]`;case`exited`:return`text-muted-foreground border-border/40 bg-muted/20`;default:return`text-muted-foreground border-border/40 bg-muted/20`}}function Bm(e){switch(e){case`fact`:return`text-primary`;case`decision`:return`text-accent2`;case`convention`:return`text-ring`;case`warning`:case`anti_pattern`:return`text-warning`;case`bug_root_cause`:return`text-destructive`;case`preference`:return`text-accent`;default:return`text-muted-foreground`}}function Vm(e){return e>=.9?`crit`:e>=.6?`high`:e>=.3?`med`:`low`}var Hm=(0,X.memo)(function({open:e,onClose:t}){let{t:n}=H(),r=fa(e=>e.traces),i=fa(e=>e.contextMemories),a=fa(e=>e.transitions),o=fa(e=>e.clear);(0,X.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t]);let s=r[0],c=Object.values(i),l=c.filter(e=>e.state!==`exited`),u=c.length-l.length,d=s?Object.values(s.rejected).reduce((e,t)=>e+t,0):0;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:G(`fixed inset-0 z-40 bg-background/50 backdrop-blur-[1px] transition-opacity duration-200`,e?`opacity-100`:`pointer-events-none opacity-0`),onClick:t,"aria-hidden":!0}),(0,Z.jsx)(`aside`,{className:G(`fixed right-0 top-0 z-50 h-full w-full max-w-md border-l border-border/60 bg-card/95 backdrop-blur-xl shadow-2xl`,`transition-transform duration-300 ease-out`,e?`translate-x-0`:`translate-x-full`),role:`dialog`,"aria-label":n(`activity:sageMemory.injectedHeading`,`Memory Context`),"data-testid":`memory-injector-panel`,children:(0,Z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/60 px-4 py-3 shrink-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(lr,{className:`size-4 text-primary`}),(0,Z.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:n(`activity:sageMemory.injectedHeading`,`Memory Context`)}),l.length>0&&(0,Z.jsxs)(`span`,{className:`rounded-full bg-primary/10 px-2 py-0.5 text-[10px] font-bold text-primary tabular-nums`,children:[l.length,` active`]})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[r.length>0&&(0,Z.jsx)(`button`,{type:`button`,onClick:o,className:`rounded-md px-2 py-1 text-[10px] text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-colors`,title:n(`activity:memoryManager.clearTracesTitle`),children:`Clear`}),(0,Z.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-md p-1.5 text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-colors`,title:n(`activity:memoryManager.closePanelTitle`),children:(0,Z.jsx)(zn,{className:`size-4`})})]})]}),s&&(0,Z.jsxs)(`div`,{className:`shrink-0 border-b border-border/40 bg-muted/20 px-4 py-2`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1 text-[11px] tabular-nums`,children:[(0,Z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Z.jsx)(Ge,{className:`size-3 text-muted-foreground`}),(0,Z.jsx)(`span`,{className:`font-mono text-foreground`,children:s.candidates}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:n(`activity:memoryManager.traceMatched`)})]}),(0,Z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Z.jsx)(`span`,{className:`font-mono text-success`,children:s.injected.length}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:n(`activity:memoryManager.traceInjected`)})]}),(0,Z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Z.jsx)(`span`,{className:`font-mono text-warning`,children:d}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:n(`activity:memoryManager.traceFiltered`)})]}),(0,Z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Z.jsx)(`span`,{className:`font-mono text-ring`,children:l.length}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:n(`activity:memoryManager.traceActive`)})]}),u>0&&(0,Z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Z.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:u}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:n(`activity:memoryManager.traceExited`)})]})]}),(0,Z.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-[10px] text-muted-foreground/80`,children:[(0,Z.jsx)(He,{className:`size-3`}),(0,Z.jsx)(`span`,{children:Rm(s.at)}),(0,Z.jsx)(`span`,{className:`opacity-40`,children:`·`}),(0,Z.jsx)(`span`,{className:`font-mono`,children:s.trigger}),s.toolName&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`opacity-40`,children:`·`}),(0,Z.jsx)(`span`,{className:`font-mono`,children:s.toolName})]}),(0,Z.jsx)(`span`,{className:`opacity-40`,children:`·`}),(0,Z.jsxs)(`span`,{children:[`ctx `,Math.round(s.contextPressure*100),`%`]})]})]}),(0,Z.jsxs)(`div`,{className:`flex-1 overflow-y-auto overscroll-contain`,children:[l.length>0?(0,Z.jsxs)(`div`,{className:`space-y-0`,children:[(0,Z.jsx)(`div`,{className:`sticky top-0 z-10 bg-card/95 backdrop-blur-sm px-4 py-2 text-[10px] font-bold uppercase tracking-wider text-muted-foreground border-b border-border/40`,children:n(`activity:memoryManager.injectorActiveInContext`)}),l.map(e=>(0,Z.jsxs)(`div`,{className:`border-b border-border/30 px-4 py-3 hover:bg-muted/15 transition-colors`,children:[(0,Z.jsx)(`div`,{className:`flex items-start gap-2`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 shrink-0`,children:[(0,Z.jsx)(`span`,{className:G(`rounded border px-1 py-0.5 text-[9px] font-bold uppercase`,Bm(e.kind)),children:e.kind}),(0,Z.jsx)(`span`,{className:G(`rounded border px-1 py-0.5 text-[9px] font-bold uppercase`,zm(e.state)),children:Vm(e.importance)})]})}),(0,Z.jsx)(`p`,{className:`mt-1.5 text-[12px] leading-relaxed text-foreground/90 break-words`,children:e.isPlaceholder?(0,Z.jsx)(`span`,{className:`italic text-muted-foreground`,children:e.text}):e.text}),(0,Z.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-0.5 text-[10px] text-muted-foreground/70`,children:[(0,Z.jsxs)(`span`,{className:`font-mono`,children:[e.id.slice(0,16),`…`]}),(0,Z.jsxs)(`span`,{className:`flex items-center gap-0.5`,children:[(0,Z.jsx)(`span`,{className:`opacity-60`,children:n(`activity:memoryManager.traceScore`)}),(0,Z.jsx)(`span`,{className:`font-mono text-foreground/60`,children:e.score.toFixed(2)})]}),e.trigger&&(0,Z.jsx)(`span`,{className:`font-mono`,children:e.trigger}),(0,Z.jsx)(`span`,{children:Rm(e.lastSeenAt)})]}),e.tags.length>0&&(0,Z.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1`,children:[(0,Z.jsx)(Vn,{className:`size-2.5 text-muted-foreground/50`}),e.tags.slice(0,6).map(e=>(0,Z.jsx)(`span`,{className:`rounded bg-muted/40 px-1 py-0.5 text-[9px] text-muted-foreground/80`,children:e},e))]}),e.anchors.length>0&&(0,Z.jsxs)(`div`,{className:`mt-1 text-[10px] text-muted-foreground/60 font-mono truncate`,children:[`↳ `,e.anchors.slice(0,2).join(`, `)]})]},e.id))]}):(0,Z.jsx)(`div`,{className:`px-4 py-8 text-center text-[12px] text-muted-foreground/60`,children:r.length===0?`No memory injections yet. Memories will appear here when the agent reads files or searches code.`:`No memories currently active in provider context.`}),r.length>0&&(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`sticky top-0 z-10 bg-card/95 backdrop-blur-sm px-4 py-2 text-[10px] font-bold uppercase tracking-wider text-muted-foreground border-t border-border/40 border-b`,children:n(`activity:memoryManager.injectorInjectionHistory`)}),r.slice(0,20).map(e=>{let t=Object.values(e.rejected).reduce((e,t)=>e+t,0);return(0,Z.jsxs)(`div`,{className:`border-b border-border/30 px-4 py-2.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] tabular-nums`,children:[(0,Z.jsx)(He,{className:`size-3 text-muted-foreground/60`}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:Rm(e.at)}),(0,Z.jsx)(`span`,{className:`opacity-30`,children:`·`}),(0,Z.jsx)(`span`,{className:`font-mono text-foreground/80`,children:e.trigger}),e.toolName&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`opacity-30`,children:`·`}),(0,Z.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:e.toolName})]})]}),(0,Z.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-3 text-[10px] tabular-nums text-muted-foreground/70`,children:[(0,Z.jsxs)(`span`,{className:`text-success`,children:[e.injected.length,` injected`]}),(0,Z.jsxs)(`span`,{className:`text-warning`,children:[t,` filtered`]}),(0,Z.jsxs)(`span`,{children:[e.candidates,` candidates`]}),(0,Z.jsxs)(`span`,{children:[`ctx `,Math.round(e.contextPressure*100),`%`]}),e.outcome===`error`&&(0,Z.jsx)(`span`,{className:`text-destructive`,children:n(`activity:memoryManager.traceError`)})]})]},e.runId)})]}),a.length>0&&(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`sticky top-0 z-10 bg-card/95 backdrop-blur-sm px-4 py-2 text-[10px] font-bold uppercase tracking-wider text-muted-foreground border-t border-border/40 border-b`,children:n(`activity:memoryManager.injectorContextTransitions`)}),a.slice(0,15).map(e=>(0,Z.jsxs)(`div`,{className:`border-b border-border/20 px-4 py-1.5 flex items-center gap-2 text-[10px] tabular-nums`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground/60`,children:Rm(e.at)}),(0,Z.jsx)(`span`,{className:G(`rounded px-1 py-0.5 text-[9px] font-bold uppercase`,e.action===`injected`&&`bg-primary/10 text-primary`,e.action===`entered`&&`bg-success/10 text-success`,e.action===`exited`&&`bg-muted/40 text-muted-foreground`),children:e.action}),(0,Z.jsxs)(`span`,{className:`font-mono text-muted-foreground truncate`,children:[e.memoryId.slice(0,14),`…`]}),(0,Z.jsx)(`span`,{className:`text-muted-foreground/50 truncate ml-auto`,children:e.reason})]},e.id))]})]})]})})]})});function Um(e){return e.replace(/\\/g,`/`).split(`/`).pop()??e}function Wm(e){if(e.kind===`file`)return e.path;let t=e.kind===`snippet`?e.content:e.preview,n=t.split(`
|
|
83
|
+
AWS_REGION=us-east-1`})]}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:a(`settings:mcp.fieldDescription`)}),(0,Z.jsx)(Ya,{value:u,onChange:e=>d(e.target.value),placeholder:a(`settings:mcp.fieldDescriptionPlaceholder`)})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,id:`server-enabled`,checked:b,onChange:e=>x(e.target.checked),className:`rounded`}),(0,Z.jsx)(`label`,{htmlFor:`server-enabled`,className:`text-sm`,children:a(`settings:mcp.enableServer`)})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,id:`server-lazy`,checked:S,onChange:e=>C(e.target.checked),className:`rounded`}),(0,Z.jsxs)(`label`,{htmlFor:`server-lazy`,className:`text-sm`,children:[a(`settings:mcp.lazyConnect`),` `,(0,Z.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:a(`settings:mcp.lazyConnectHint`)})]})]})]}),(0,Z.jsxs)(Wa,{children:[(0,Z.jsx)(Y,{variant:`outline`,onClick:()=>t(!1),children:a(`common:action.cancel`)}),(0,Z.jsx)(Y,{onClick:w,children:a(T?`settings:mcp.saveChanges`:`settings:mcp.addServer`)})]})]})})}function pf({server:e,isAdded:t,onAdd:n}){let{t:r}=H();return(0,Z.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,Z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-sm`,children:e.name}),e.badge&&(0,Z.jsx)(wd,{variant:`secondary`,className:`text-xs shrink-0`,children:e.badge}),(0,Z.jsx)(wd,{variant:`outline`,className:`text-xs shrink-0`,children:e.transport})]}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e.description}),e.requiresEnvVars&&e.requiresEnvVars.length>0&&(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-warning`,children:r(`settings:mcp.requires`,{vars:e.requiresEnvVars.join(`, `)})})]}),(0,Z.jsx)(`div`,{className:`shrink-0`,children:t?(0,Z.jsxs)(Y,{variant:`ghost`,size:`sm`,disabled:!0,children:[(0,Z.jsx)(ui,{className:`w-4 h-4 mr-1`}),r(`settings:mcp.added`)]}):(0,Z.jsxs)(Y,{size:`sm`,variant:`outline`,onClick:n,children:[(0,Z.jsx)(_i,{className:`w-4 h-4 mr-1`}),r(`common:action.add`)]})})]})}function mf(){let e=ha(),{t}=H(),[n,r]=(0,X.useState)([]),[i,a]=(0,X.useState)(!1),[o,s]=(0,X.useState)(`list`),[c,l]=(0,X.useState)(),[u,d]=(0,X.useState)(!1),[f,p]=(0,X.useState)(!1),[m,h]=(0,X.useState)(),[g,_]=(0,X.useState)(null);(0,X.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]),B.success(U.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)),B.success(U.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)),_(null),B.success(U.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)),_(null),B.info(U.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)),_(null),B.success(U.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)),_(null),B.success(U.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)),_(null),B.warn(U.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)),_(null),B.error(U.t(`settings:mcp.toastError`,{name:t.name,error:t.error}))}},m=e=>{if(e.type===`mcp.operation_result`){let t=e.payload;t.success||B.error(t.message),_(null)}},h=e.client.on(`mcp.list`,t),g=e.client.on(`mcp.server.added`,n),v=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?.(),v?.(),y?.(),b?.(),x?.(),S?.(),C?.(),w?.(),T?.(),E?.(),D?.()}},[e.client]);let v=(0,X.useCallback)(t=>{e.client?.addMcpServer(t)},[e]),y=(0,X.useCallback)(e=>{h(cf(e,!1)),p(!0)},[]),b=(0,X.useCallback)(n=>{$a({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]),x=(0,X.useCallback)(e=>{l(e),h(void 0),d(!0)},[]),S=(0,X.useCallback)(t=>{e.client?.updateMcpServer(t)},[e]),C=(0,X.useCallback)(t=>{_(t),e.client?.wakeMcpServer(t)},[e]),w=(0,X.useCallback)(t=>{_(t),e.client?.sleepMcpServer(t)},[e]),T=(0,X.useCallback)(t=>{_(t),e.client?.discoverMcpServer(t)},[e]),E=(0,X.useCallback)(()=>{a(!0),e.client?.listMcpServers()},[e]),D=n.filter(e=>e.status===`connected`).length,O=n.filter(e=>e.status===`sleeping`).length,k=new Set(n.map(e=>e.name));return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Z.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,Z.jsx)(Qi,{className:`h-5 w-5`})}),(0,Z.jsx)(`h2`,{className:`text-base font-semibold`,children:t(`settings:mcp.heading`)}),n.length>0&&(0,Z.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:D,sleeping:O,total:n.length})})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsxs)(Y,{variant:`outline`,size:`sm`,onClick:E,disabled:i,children:[i?(0,Z.jsx)(wt,{className:`w-4 h-4 animate-spin`}):null,t(`common:action.refresh`)]}),(0,Z.jsxs)(Y,{size:`sm`,onClick:()=>{h(void 0),p(!0)},children:[(0,Z.jsx)(_i,{className:`w-4 h-4 mr-1`}),t(`settings:mcp.addCustom`)]})]})]}),(0,Z.jsxs)(Ns,{value:o,onValueChange:e=>s(e),children:[(0,Z.jsxs)(Ps,{children:[(0,Z.jsxs)(Fs,{value:`recommended`,children:[(0,Z.jsx)(Hi,{className:`w-3.5 h-3.5 mr-1`}),t(`settings:mcp.tabRecommended`)]}),(0,Z.jsx)(Fs,{value:`list`,children:t(`settings:mcp.tabServers`)}),(0,Z.jsx)(Fs,{value:`add`,children:t(`settings:mcp.tabAddCustom`)})]}),(0,Z.jsxs)(Is,{value:`recommended`,className:`space-y-3`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`settings:mcp.recommendedBody`)}),(0,Z.jsx)(`div`,{className:`grid gap-2`,children:sf.map(e=>(0,Z.jsx)(pf,{server:e,isAdded:k.has(e.name),onAdd:()=>y(e)},e.name))})]}),(0,Z.jsx)(Is,{value:`list`,className:`space-y-3`,children:i&&n.length===0?(0,Z.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground`,children:[(0,Z.jsx)(wt,{className:`w-5 h-5 animate-spin mr-2`}),t(`settings:mcp.loadingServers`)]}):n.length===0?(0,Z.jsxs)(`div`,{className:`text-center py-8 text-muted-foreground`,children:[(0,Z.jsx)(Qi,{className:`w-10 h-10 mx-auto mb-2 opacity-50`}),(0,Z.jsx)(`p`,{children:t(`settings:mcp.noServers`)}),(0,Z.jsx)(`p`,{className:`text-sm`,children:t(`settings:mcp.noServersHint`)})]}):n.map(e=>(0,Z.jsx)(df,{server:e,onWake:()=>C(e.name),onSleep:()=>w(e.name),onDiscover:()=>T(e.name),onEdit:()=>x(e),onRemove:()=>b(e.name)},e.name))}),(0,Z.jsx)(Is,{value:`add`,children:(0,Z.jsxs)(`div`,{className:`text-sm text-muted-foreground`,children:[(0,Z.jsx)(`p`,{children:t(`settings:mcp.addCustomBody`)}),(0,Z.jsx)(`p`,{className:`mt-1`,children:t(`settings:mcp.addCustomBodyHint`)})]})})]}),(0,Z.jsx)(ff,{open:f,onOpenChange:e=>{e||(p(!1),h(void 0))},prefillConfig:m,onSave:v}),(0,Z.jsx)(ff,{open:u,onOpenChange:d,server:c,onSave:S})]})}function hf({syncPref:e}){let{t}=H(),n=W();return(0,Z.jsxs)(`div`,{className:`space-y-6`,children:[(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,Z.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,Z.jsx)(Qi,{className:`h-5 w-5`})}),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:t(`settings:integrations.wrongProxyHeading`)})})]}),(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)($,{label:t(`settings:integrations.wrongProxyEnabledLabel`),hint:t(`settings:integrations.wrongProxyEnabledHint`),value:n.wrongProxyEnabled,onChange:()=>e(`wrongProxyEnabled`,!n.wrongProxyEnabled)}),(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:t(`settings:integrations.wrongProxyUrlLabel`)}),(0,Z.jsx)(Ya,{value:n.wrongProxyUrl,placeholder:`http://localhost:3444`,onChange:t=>e(`wrongProxyUrl`,t.target.value)}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`settings:integrations.wrongProxyUrlHint`)})]}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`settings:integrations.wrongProxyChangesApply`)})]})]}),(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,Z.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,Z.jsx)(Qi,{className:`h-5 w-5`})}),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:t(`settings:integrations.hqHeading`)})})]}),(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)($,{label:t(`settings:integrations.hqPublishingLabel`),hint:t(`settings:integrations.hqPublishingHint`),value:n.hqEnabled,onChange:()=>e(`hqEnabled`,!n.hqEnabled)}),(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:t(`settings:integrations.hqUrlLabel`)}),(0,Z.jsx)(Ya,{value:n.hqUrl,placeholder:t(`activity:integrationsSection.httpHost3499`),onChange:t=>e(`hqUrl`,t.target.value)}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`settings:integrations.hqUrlHint`)})]}),(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:t(`settings:integrations.hqTokenLabel`)}),(0,Z.jsx)(Ya,{type:`password`,value:n.hqToken,placeholder:t(`activity:integrationsSection.clientTokenFromWstackHq`),onChange:t=>e(`hqToken`,t.target.value)})]}),(0,Z.jsx)($,{label:t(`settings:integrations.hqRawContentLabel`),hint:t(`settings:integrations.hqRawContentHint`),value:n.hqRawContent,onChange:()=>e(`hqRawContent`,!n.hqRawContent)})]})]}),(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,Z.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,Z.jsx)(Qi,{className:`h-5 w-5`})}),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:t(`activity:integrationsSection.mcpServers`)})})]}),n.featureMcp?(0,Z.jsx)(mf,{}):(0,Z.jsxs)(`div`,{className:`text-center py-6 text-muted-foreground`,children:[(0,Z.jsx)(Qi,{className:`w-8 h-8 mx-auto mb-2 opacity-50`}),(0,Z.jsx)(`p`,{className:`text-sm`,children:t(`settings:mcp.disabled`)}),(0,Z.jsx)(`p`,{className:`text-xs mt-1`,children:t(`settings:integrations.disabledHint`)})]})]}),(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,Z.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,Z.jsx)(ze,{className:`h-5 w-5`})}),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:t(`settings:integrations.telegramHeading`)})})]}),n.tgConfigured?(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)($,{label:t(`settings:integrations.telegramSessionEndLabel`),hint:t(`settings:integrations.telegramSessionEndHint`),value:n.tgSessionEnd,onChange:()=>e(`tgSessionEnd`,!n.tgSessionEnd)}),(0,Z.jsx)($,{label:t(`settings:integrations.telegramDelegateLabel`),hint:t(`settings:integrations.telegramDelegateHint`),value:n.tgDelegate,onChange:()=>e(`tgDelegate`,!n.tgDelegate)}),(0,Z.jsx)($,{label:t(`settings:integrations.telegramLongToolLabel`),hint:t(`settings:integrations.telegramLongToolHint`,{ms:n.tgLongToolMs}),value:n.tgLongToolMs>0,onChange:()=>e(`tgLongToolMs`,n.tgLongToolMs>0?0:3e4)}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`settings:integrations.telegramChangesApply`)})]}):(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`settings:integrations.telegramNotConfigured`)})]})]})}function gf({syncPref:e}){let{t}=H(),n=W();return(0,Z.jsx)(`div`,{className:`space-y-6`,children:(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,Z.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,Z.jsx)(Oe,{className:`h-5 w-5`})}),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:t(`settings:logs.heading`)})})]}),(0,Z.jsx)(Q,{label:t(`settings:logs.logLevelLabel`),hint:t(`settings:logs.logLevelHint`),value:n.logLevel,options:[{value:`debug`,label:t(`settings:logs.logLevelDebug`)},{value:`info`,label:t(`settings:logs.logLevelInfo`)},{value:`warn`,label:t(`settings:logs.logLevelWarn`)},{value:`error`,label:t(`settings:logs.logLevelError`)}],onChange:t=>e(`logLevel`,t)}),(0,Z.jsx)(Q,{label:t(`settings:logs.auditLevelLabel`),hint:t(`settings:logs.auditLevelHint`),value:n.auditLevel,options:[{value:`minimal`,label:t(`settings:logs.auditLevelMinimal`)},{value:`standard`,label:t(`settings:logs.auditLevelStandard`)},{value:`full`,label:t(`settings:logs.auditLevelFull`)}],onChange:t=>e(`auditLevel`,t)}),(0,Z.jsx)(Q,{label:t(`settings:logs.fsAccessLabel`),hint:t(`settings:logs.fsAccessHint`),value:n.fsAccess,options:[{value:`unrestricted`,label:t(`settings:logs.fsAccessUnrestricted`)},{value:`project`,label:t(`settings:logs.fsAccessProject`)}],onChange:t=>e(`fsAccess`,t)}),(0,Z.jsx)($,{label:t(`settings:logs.debugStreamLabel`),hint:t(`settings:logs.debugStreamHint`),value:n.debugStream,onChange:()=>e(`debugStream`,!n.debugStream)})]})})}function _f({syncPref:e}){let{t}=H(),n=W(e=>e.reasoningEffort),r=N(e=>e.reasoningEffortLevels),i=el(r,n).map(e=>({value:e,label:t($c(e))}));return(0,Z.jsx)(`div`,{className:`mt-4 border-t border-border/60 pt-4`,children:(0,Z.jsx)(Q,{label:t(`settings:agent.reasoningEffortLabel`),hint:tl(r,n)?t(`settings:agent.reasoningEffortUnsupported`,{levels:(r??[]).join(`, `)}):r?`${t(`settings:agent.reasoningEffortHint`)} (${t(`settings:agent.reasoningEffortModelSet`)})`:t(`settings:agent.reasoningEffortHint`),value:n,options:i,onChange:t=>e(`reasoningEffort`,t)})})}function vf({provider:e,catalogModels:t,currentCatalogProvider:n,isLoadingModels:r,isSwitching:i,setIsLoadingModels:a,onModelSelect:o,refreshModels:s}){let c=R(e=>e.model),{t:l}=H();return(0,Z.jsx)(`div`,{className:`space-y-4`,children:e?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium`,children:n?.name||e}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e})]}),(0,Z.jsx)(Y,{variant:`ghost`,size:`sm`,onClick:()=>{a(!0),s(e)},children:(0,Z.jsx)(xi,{className:G(`h-4 w-4`,r&&`animate-spin`)})})]}),r&&!t[e]?(0,Z.jsxs)(`div`,{className:`flex items-center justify-center py-8`,children:[(0,Z.jsx)(wt,{className:`h-6 w-6 animate-spin text-muted-foreground`}),(0,Z.jsx)(`span`,{className:`ml-2 text-muted-foreground`,children:l(`settings:model.loading`)})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(dd,{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}`,e.reasoningEffortLevels?.length?`effort ${e.reasoningEffortLevels.join(`/`)}`:``].filter(Boolean).join(` · `),detailHighlight:!0})),selectedId:c,onSelect:o,disabled:i,emptyMessage:l(`settings:model.notFound`)}),i?(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:l(`settings:toast.switching`)}):null]})]}):(0,Z.jsxs)(`div`,{className:`text-center py-8 text-muted-foreground`,children:[(0,Z.jsx)(ar,{className:`h-8 w-8 mx-auto mb-2 opacity-50`}),(0,Z.jsx)(`p`,{children:l(`settings:model.selectProviderFirst`)})]})})}var yf=[{value:`off`,label:`Off`,hint:`The leader never changes its own tier.`},{value:`propose`,label:`Propose`,hint:`The leader asks before switching. Recommended.`},{value:`auto`,label:`Auto`,hint:`The leader switches on its own, still bounded by the guard rails below.`}],bf={};function xf({syncPref:e}){let t=W(),n=t.modelTiers??{},r=n.levels??{},i=n.routing??{},a=n.leader??{},o=Object.keys(r),s=Object.keys(t.fallbackProfiles??{}),[c,l]=(0,X.useState)(``),[u,d]=(0,X.useState)(``),[f,p]=(0,X.useState)(``),m=(0,X.useCallback)(t=>e(`modelTiers`,{...n,...t}),[e,n]),h=(0,X.useCallback)((t,i)=>e(`modelTiers`,{...n,levels:{...r,[t]:{...r[t]??{},...i}}}),[e,n,r]),g=(0,X.useCallback)(t=>{let a={...r};delete a[t];let o=Object.fromEntries(Object.entries(i).filter(([,e])=>e!==t));e(`modelTiers`,{...n,levels:a,routing:o})},[e,n,r,i]),_=()=>{let e=c.trim();!e||r[e]||(h(e,bf),l(``))},v=()=>{let e=u.trim();!e||!f||(m({routing:{...i,[e]:f}}),d(``),p(``))},y=e=>{let t={...i};delete t[e],m({routing:t})},b=e=>{let t=e.trim();if(!t)return;let n=Number.parseFloat(t);return Number.isFinite(n)&&n>=0?n:void 0};return(0,Z.jsxs)(`section`,{className:`space-y-3`,"data-testid":`model-tiers-section`,children:[(0,Z.jsxs)(`header`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Gi,{className:`h-4 w-4 text-muted-foreground`}),(0,Z.jsx)(`h3`,{className:`text-sm font-medium text-foreground`,children:`Model cost tiers`}),(0,Z.jsxs)(`label`,{className:`ml-auto flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:n.enabled===!0,onChange:e=>m({enabled:e.target.checked}),"data-testid":`model-tiers-enabled`}),`Enabled`]})]}),(0,Z.jsx)(`p`,{className:`text-[11px] leading-relaxed text-muted-foreground`,children:`A tier binds a fallback profile, a spend budget and a runtime setting under one name, then routes work to it by role or phase. Subagents, Kanban dispatch and the leader all read this table. While disabled, everything resolves exactly as it did before tiers existed.`}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-baseline justify-between`,children:[(0,Z.jsx)(`h4`,{className:`text-xs font-medium text-foreground`,children:`Levels`}),(0,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:`Order is the ladder — the first row is the cheapest rung.`})]}),o.length===0&&(0,Z.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`No levels yet. Add one below, then point it at a fallback profile.`}),o.map((e,t)=>{let n=r[e]??{};return(0,Z.jsxs)(`div`,{className:`space-y-1.5 rounded-md border border-border bg-muted px-2 py-1.5`,"data-testid":`model-tier-row-${e}`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs`,children:[(0,Z.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:t+1}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 break-words font-mono font-medium text-foreground`,children:e}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>g(e),className:`text-muted-foreground hover:text-destructive`,title:`Remove level`,"data-testid":`model-tier-remove-${e}`,children:(0,Z.jsx)(St,{className:`h-3 w-3`})})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,Z.jsxs)(`select`,{value:n.fallbackProfile??``,onChange:t=>h(e,{fallbackProfile:t.target.value||void 0}),className:`rounded-sm border border-border bg-background px-1.5 py-0.5 text-[11px]`,"data-testid":`model-tier-profile-${e}`,children:[(0,Z.jsx)(`option`,{value:``,children:`profile: (none)`}),s.map(e=>(0,Z.jsxs)(`option`,{value:e,children:[`profile: `,e]},e))]}),(0,Z.jsx)(`input`,{type:`number`,min:0,step:`0.01`,value:n.maxCostUsd??``,onChange:t=>h(e,{maxCostUsd:b(t.target.value)}),placeholder:`max $`,className:`w-20 rounded-sm border border-border bg-background px-1.5 py-0.5 text-[11px]`,"data-testid":`model-tier-cost-${e}`}),(0,Z.jsx)(`input`,{type:`number`,min:0,value:n.maxIterations??``,onChange:t=>h(e,{maxIterations:b(t.target.value)}),placeholder:`iters`,className:`w-16 rounded-sm border border-border bg-background px-1.5 py-0.5 text-[11px]`}),(0,Z.jsx)(`input`,{type:`number`,min:0,value:n.maxToolCalls??``,onChange:t=>h(e,{maxToolCalls:b(t.target.value)}),placeholder:`tools`,className:`w-16 rounded-sm border border-border bg-background px-1.5 py-0.5 text-[11px]`})]}),n.maxCostUsd!==void 0&&(0,Z.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Tightens a role's default budget down to this ceiling; it never raises one, and never overrides a budget passed explicitly to the spawn.`})]},e)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&_()},placeholder:`new level name (e.g. budget)`,className:`min-w-0 flex-1 rounded-sm border border-border bg-background px-1.5 py-0.5 text-[11px]`,"data-testid":`model-tier-new-name`}),(0,Z.jsxs)(Y,{size:`sm`,variant:`outline`,onClick:_,disabled:!c.trim(),children:[(0,Z.jsx)(_i,{className:`mr-1 h-3 w-3`}),` Add`]})]})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`h4`,{className:`text-xs font-medium text-foreground`,children:`Routing`}),Object.keys(i).length===0?(0,Z.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,children:[`No rules — everything uses the default tier`,n.default?` (${n.default})`:` (standard)`,`.`]}):(0,Z.jsx)(`ul`,{className:`space-y-1`,children:Object.entries(i).map(([e,t])=>(0,Z.jsxs)(`li`,{className:`flex items-center gap-1.5 rounded-md border border-border bg-muted px-2 py-1 text-[11px]`,"data-testid":`model-tier-route-${e}`,children:[(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1 break-words font-mono text-foreground`,children:[e,` → `,t]}),!r[t]&&(0,Z.jsx)(`span`,{className:`rounded-sm bg-warning/15 px-1 py-0.5 text-[10px] text-foreground`,children:`missing level`}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>y(e),className:`text-muted-foreground hover:text-destructive`,title:`Remove rule`,children:(0,Z.jsx)(St,{className:`h-3 w-3`})})]},e))}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(`input`,{value:u,onChange:e=>d(e.target.value),placeholder:`role, phase, or *`,className:`min-w-0 flex-1 rounded-sm border border-border bg-background px-1.5 py-0.5 text-[11px]`,"data-testid":`model-tier-new-route-key`}),(0,Z.jsxs)(`select`,{value:f,onChange:e=>p(e.target.value),className:`rounded-sm border border-border bg-background px-1.5 py-0.5 text-[11px]`,"data-testid":`model-tier-new-route-tier`,children:[(0,Z.jsx)(`option`,{value:``,children:`tier…`}),o.map(e=>(0,Z.jsx)(`option`,{value:e,children:e},e))]}),(0,Z.jsx)(Y,{size:`sm`,variant:`outline`,onClick:v,disabled:!u.trim()||!f,children:(0,Z.jsx)(_i,{className:`h-3 w-3`})})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px]`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:`Default tier`}),(0,Z.jsxs)(`select`,{value:n.default??``,onChange:e=>m({default:e.target.value||void 0}),className:`rounded-sm border border-border bg-background px-1.5 py-0.5 text-[11px]`,"data-testid":`model-tier-default`,children:[(0,Z.jsx)(`option`,{value:``,children:`standard`}),o.map(e=>(0,Z.jsx)(`option`,{value:e,children:e},e))]})]})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`h4`,{className:`text-xs font-medium text-foreground`,children:`Leader self-switching`}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:yf.map(e=>{let t=(a.mode??`propose`)===e.value;return(0,Z.jsx)(`button`,{type:`button`,title:e.hint,onClick:()=>m({leader:{...a,mode:e.value}}),className:t?`rounded-sm border border-primary bg-primary/10 px-2 py-0.5 text-[11px] text-foreground`:`rounded-sm border border-border bg-background px-2 py-0.5 text-[11px] text-muted-foreground hover:text-foreground`,"data-testid":`model-tier-leader-${e.value}`,children:e.label},e.value)})}),(0,Z.jsx)(`p`,{className:`text-[11px] leading-relaxed text-muted-foreground`,children:yf.find(e=>e.value===(a.mode??`propose`))?.hint}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 text-[11px]`,children:[(0,Z.jsxs)(`label`,{className:`flex items-center gap-1 text-muted-foreground`,children:[`dwell`,(0,Z.jsx)(`input`,{type:`number`,min:0,value:a.dwellTurns??``,onChange:e=>m({leader:{...a,dwellTurns:b(e.target.value)}}),placeholder:`6`,className:`w-14 rounded-sm border border-border bg-background px-1.5 py-0.5`,"data-testid":`model-tier-leader-dwell`}),`turns`]}),(0,Z.jsxs)(`label`,{className:`flex items-center gap-1 text-muted-foreground`,children:[`min saving $`,(0,Z.jsx)(`input`,{type:`number`,min:0,step:`0.01`,value:a.minSavingsUsd??``,onChange:e=>m({leader:{...a,minSavingsUsd:b(e.target.value)}}),placeholder:`0.10`,className:`w-16 rounded-sm border border-border bg-background px-1.5 py-0.5`})]}),(0,Z.jsxs)(`label`,{className:`flex items-center gap-1 text-muted-foreground`,children:[`ceiling`,(0,Z.jsxs)(`select`,{value:a.maxTier??``,onChange:e=>m({leader:{...a,maxTier:e.target.value||void 0}}),className:`rounded-sm border border-border bg-background px-1.5 py-0.5`,"data-testid":`model-tier-leader-ceiling`,children:[(0,Z.jsx)(`option`,{value:``,children:`none`}),o.map(e=>(0,Z.jsx)(`option`,{value:e,children:e},e))]})]})]}),(0,Z.jsx)(`p`,{className:`text-[10px] leading-relaxed text-muted-foreground`,children:`A switch invalidates the prompt cache, so a downgrade is refused unless the projected saving over the dwell window covers re-reading the conversation on the new model. A downgrade into a context window the session no longer fits is refused outright.`})]})]})}function Sf(){let e=(0,X.useRef)([]);return{setFieldRef:(0,X.useCallback)(t=>n=>{e.current[t]=n},[]),handleKeyDown:(0,X.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())},[])}}function Cf({models:e,onChange:t}){let{t:n}=H(),[r,i]=(0,X.useState)(!1),[a,o]=(0,X.useState)(``),[s,c]=(0,X.useState)([]),[l,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)(``),h=(0,X.useRef)(void 0),g=(0,X.useRef)(null),_=R(e=>e.wsUrl),v=(0,X.useCallback)(e=>{if(!e.trim()){c([]);return}u(!0);let t=V(_),n=t.on(`provider.models.search_result`,t=>{let n=t.payload;!n||n.query!==e.trim()||(c(n.matches??[]),u(!1))});t.searchProviderModels(e.trim(),8),setTimeout(()=>{n?.(),u(!1)},5e3)},[_]);(0,X.useEffect)(()=>{if(h.current&&clearTimeout(h.current),!a.trim()){c([]);return}return h.current=setTimeout(()=>v(a),250),()=>{h.current&&clearTimeout(h.current)}},[a,v]);let y=(0,X.useCallback)((n,r)=>{if(!n||e.some(e=>e.id===n))return;let a={id:n,name:r?.name??r?.modelId??n,...r?.maxOutput?{maxOutput:r.maxOutput}:{},capabilities:{...r?.contextWindow?{maxContext:r.contextWindow}:{},...r?.capabilities.includes(`tools`)?{tools:!0}:{},...r?.capabilities.includes(`vision`)?{vision:!0}:{},...r?.capabilities.includes(`reasoning`)?{reasoning:!0}:{}}};t([...e,a]),o(``),c([]),i(!1)},[e,t]),b=(0,X.useCallback)(n=>{t(e.filter(e=>e.id!==n))},[e,t]),x=(0,X.useCallback)(()=>{let e=p.trim();e&&(y(e),m(``),f(!1))},[p,y]);return(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground block`,children:n(`setup:screen.custom.models`)}),e.length>0&&(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map(e=>(0,Z.jsxs)(`div`,{className:G(`group inline-flex items-center gap-1 px-2 py-1 text-xs rounded`,`bg-accent/10 text-accent border border-accent/20`),title:e.name&&e.name!==e.id?`${e.name}\n${e.capabilities?.maxContext?`maxContext: ${e.capabilities.maxContext}`:``}${e.maxOutput?`\nmaxOutput: ${e.maxOutput}`:``}`:void 0,children:[(0,Z.jsx)(`span`,{className:`truncate max-w-[120px]`,children:e.name&&e.name!==e.id?e.name:e.id}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>b(e.id),className:`opacity-0 group-hover:opacity-100 transition-opacity text-muted-foreground hover:text-destructive`,children:(0,Z.jsx)(St,{className:`h-3 w-3`})})]},e.id))}),r?(0,Z.jsxs)(`div`,{className:`space-y-2 p-3 rounded border border-border/60 bg-muted/20`,children:[(0,Z.jsxs)(`div`,{className:`relative`,children:[(0,Z.jsx)(vn,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,Z.jsx)(Ya,{placeholder:n(`setup:screen.custom.modelSearchPlaceholder`),value:a,onChange:e=>o(e.target.value),className:`text-sm pl-8`,autoFocus:!0}),l&&(0,Z.jsx)(wt,{className:`absolute right-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 animate-spin text-muted-foreground`})]}),s.length>0&&(0,Z.jsx)(`div`,{className:`space-y-1 max-h-40 overflow-y-auto`,children:s.map(e=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>y(e.modelId,e),className:G(`w-full flex items-start gap-2 p-2 text-left text-xs rounded transition-colors`,`hover:bg-accent/10 border border-transparent hover:border-accent/30`),children:[(0,Z.jsx)(ui,{className:`h-3.5 w-3.5 mt-0.5 shrink-0 text-muted-foreground`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`font-medium block truncate`,children:e.name}),(0,Z.jsxs)(`span`,{className:`text-muted-foreground block`,children:[e.providerName,` · `,e.modelId,e.contextWindow?` · ${(e.contextWindow/1e3).toFixed(0)}K ctx`:``,e.maxOutput?` · ${e.maxOutput.toLocaleString()} out`:``]})]})]},`${e.providerId}\u0000${e.modelId}`))}),!l&&a.trim()&&s.length===0&&(0,Z.jsxs)(`div`,{className:`text-xs text-muted-foreground text-center py-2`,children:[n(`setup:screen.custom.noCatalogMatch`),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{f(!0),setTimeout(()=>g.current?.focus(),50)},className:`ml-1 text-accent underline underline-offset-2 hover:text-accent/80`,children:n(`setup:screen.custom.useCustomId`)})]}),d&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Ya,{ref:g,placeholder:n(`setup:screen.custom.customModelIdPlaceholder`),value:p,onChange:e=>m(e.target.value),className:`text-sm flex-1`,onKeyDown:e=>{e.key===`Enter`&&x()}}),(0,Z.jsxs)(Y,{type:`button`,size:`sm`,onClick:x,disabled:!p.trim(),children:[(0,Z.jsx)(ui,{className:`h-3.5 w-3.5 mr-1`}),n(`setup:screen.custom.add`)]})]}),(0,Z.jsx)(`div`,{className:`flex items-center gap-2 pt-1`,children:(0,Z.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>{i(!1),o(``),c([]),f(!1),m(``)},className:`text-xs`,children:n(`setup:screen.custom.cancel`)})})]}):(0,Z.jsxs)(Y,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>i(!0),className:`text-xs`,children:[(0,Z.jsx)(_i,{className:`h-3.5 w-3.5 mr-1`}),n(`setup:screen.custom.addModel`)]}),e.length>0&&(0,Z.jsxs)(`p`,{className:`text-[10px] text-muted-foreground`,children:[e.length,` `,e.length===1?n(`setup:screen.custom.modelSingular`):n(`setup:screen.custom.modelPlural`)]})]})}function wf({maskedKey:e,className:t}){let{t:n}=H(),[r,i]=(0,X.useState)(!1),a=(0,X.useCallback)(()=>{navigator.clipboard.writeText(e).then(()=>{i(!0),setTimeout(()=>i(!1),1500)})},[e]);return(0,Z.jsxs)(`div`,{className:G(`group flex items-center gap-1.5 rounded-md border border-border/50 bg-background/50 px-2 py-1 font-mono text-xs text-muted-foreground`,t),children:[(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate tracking-wide`,children:e}),(0,Z.jsx)(`button`,{type:`button`,onClick:a,className:`shrink-0 rounded p-0.5 text-muted-foreground/50 opacity-0 transition-all hover:text-foreground group-hover:opacity-100 focus:opacity-100`,title:r?`Copied`:`Copy key preview`,"aria-label":n(`activity:apikeydisplay.copyApiKeyToClipboard`),children:r?(0,Z.jsx)(ui,{className:`h-3 w-3 text-success`}):(0,Z.jsx)(oi,{className:`h-3 w-3`})})]})}var Tf={openrouter:{id:`openrouter`,name:`OpenRouter (Metered)`,family:`openai-compatible`,baseUrl:`https://openrouter.ai/api/v1`,envVars:[`OPENROUTER_API_KEY`],models:[`openai/gpt-4o`,`openai/gpt-4o-mini`,`anthropic/claude-sonnet-4-20250514`,`google/gemini-2.0-flash-001`,`meta-llama/llama-4-scout`,`deepseek/deepseek-chat`],usage:`metered-api`,docsUrl:`https://openrouter.ai/docs/quickstart`,autoDiscover:!0,requestPolicy:`openrouter`,catalog:{description:`All models via one key`,icon:`🔀`,color:`from-primary/12 to-primary/5 border-primary/30 hover:border-primary/50`,keyPlaceholder:`sk-or-...`}},"kimi-for-coding":{id:`kimi-for-coding`,name:`Kimi Code (Subscription)`,family:`openai-compatible`,baseUrl:`https://api.kimi.com/coding/v1`,envVars:[`KIMI_API_KEY`],models:[`kimi-for-coding`,`kimi-for-coding-highspeed`],quirks:{thinkingParam:`kimi-toggle`},usage:`subscription-interactive`,docsUrl:`https://www.kimi.com/code/docs/en/third-party-tools/other-coding-agents.html`,requestPolicy:`kimi`,catalog:{description:`Personal interactive coding with the Kimi Code subscription key. Generate the API key at kimi.com/code/console.`,icon:`🌙`,color:`from-info/12 to-info/5 border-info/30 hover:border-info/50`,keyPlaceholder:`sk-...`}},moonshotai:{id:`moonshotai`,name:`Moonshot Platform (Metered)`,family:`openai-compatible`,baseUrl:`https://api.moonshot.ai/v1`,envVars:[`MOONSHOT_API_KEY`],models:[`kimi-k2.7-code`,`kimi-k2.7-code-highspeed`],quirks:{thinkingParam:`always-on`},usage:`metered-api`,docsUrl:`https://platform.kimi.ai/docs/api/overview`,requestPolicy:`kimi`,catalog:{description:`Metered Moonshot Platform API — pay-as-you-go for automation, background work, and commercial use.`,icon:`🌑`,color:`from-info/12 to-info/5 border-info/30 hover:border-info/50`,keyPlaceholder:`sk-...`}},"zai-coding-plan":{id:`zai-coding-plan`,name:`Z.AI Coding Plan (Subscription)`,family:`openai-compatible`,baseUrl:`https://api.z.ai/api/coding/paas/v4`,envVars:[`ZHIPU_API_KEY`],models:[`glm-5.2`,`glm-5-turbo`,`glm-4.7`],quirks:{thinkingParam:`zai-glm`},usage:`subscription-interactive`,docsUrl:`https://docs.z.ai/devpack/quick-start`,requestPolicy:`zai`,catalog:{description:`Use your Z.AI Coding Plan subscription. Generate an API key from your Z.AI dashboard.`,icon:`🔷`,color:`from-primary/12 to-primary/5 border-primary/30 hover:border-primary/50`,keyPlaceholder:`...`}},zai:{id:`zai`,name:`Z.AI API (Metered)`,family:`openai-compatible`,baseUrl:`https://api.z.ai/api/paas/v4`,envVars:[`ZHIPU_API_KEY`],models:[`glm-4.7`,`glm-5-turbo`,`glm-5.2`],quirks:{thinkingParam:`zai-glm`},usage:`metered-api`,docsUrl:`https://docs.z.ai/guides/overview/quick-start`,requestPolicy:`zai`,catalog:{description:`Pay-as-you-go Z.AI GLM access for automation and commercial use.`,icon:`🔷`,color:`from-primary/12 to-primary/5 border-primary/30 hover:border-primary/50`,keyPlaceholder:`...`,referral:{code:`JQZ7TPPRA6`,reward:`Limited-time deal for GLM Coding Plan subscription`,url:`https://z.ai/subscribe?ic=JQZ7TPPRA6`}}},minimax:{id:`minimax`,name:`MiniMax Token Plan (Subscription)`,family:`openai-compatible`,baseUrl:`https://api.minimax.io/v1`,envVars:[`MINIMAX_API_KEY`],models:[`MiniMax-M3`,`MiniMax-M2.7`,`MiniMax-M2.5`,`MiniMax-M2`],usage:`subscription-interactive`,docsUrl:`https://platform.minimax.io/docs/api-reference/text-chat-openai`,catalog:{description:`Subscribe to one plan and unlock frontier coding, 1M context, and native multimodality.`,icon:`🔮`,color:`from-destructive/10 to-destructive/5 border-destructive/25 hover:border-destructive/45`,keyPlaceholder:`eyJ...`,referral:{code:`JrA4R9QAEn`,reward:`Friends get 10% off + Builder benefits. Referrers earn 10% cashback + community perks.`,url:`https://platform.minimax.io/subscribe/token-plan?code=JrA4R9QAEn&source=link`}}},mistral:{id:`mistral`,name:`Mistral AI API (Metered)`,family:`openai-compatible`,baseUrl:`https://api.mistral.ai/v1`,envVars:[`MISTRAL_API_KEY`],models:[`mistral-large-latest`,`codestral-latest`,`ministral-8b-latest`],usage:`metered-api`,docsUrl:`https://docs.mistral.ai/`,catalog:{description:`Mistral Large, Codestral, and Ministral — open-weight frontier models.`,icon:`🌬️`,color:`from-info/12 to-info/5 border-info/30 hover:border-info/50`,keyPlaceholder:`Vz8d...`}},deepseek:{id:`deepseek`,name:`DeepSeek API (Metered)`,family:`openai-compatible`,baseUrl:`https://api.deepseek.com`,envVars:[`DEEPSEEK_API_KEY`],models:[`deepseek-v4-flash`,`deepseek-v4-pro`],usage:`metered-api`,docsUrl:`https://api-docs.deepseek.com/`,requestPolicy:`deepseek`,catalog:{description:`High-performance reasoning at low cost`,icon:`🐋`,color:`from-primary/12 to-primary/5 border-primary/30 hover:border-primary/50`,keyPlaceholder:`sk-...`}},groq:{id:`groq`,name:`GroqCloud (Metered)`,family:`openai-compatible`,baseUrl:`https://api.groq.com/openai/v1`,envVars:[`GROQ_API_KEY`],models:[`llama-3.3-70b-versatile`,`llama-3.1-8b-instant`,`mixtral-8x7b-32768`,`gemma2-9b-it`],usage:`metered-api`,docsUrl:`https://console.groq.com/docs/api-reference`,requestPolicy:`groq`,catalog:{description:`Ultra-fast inference via LPU hardware — Llama, Mixtral, Gemma, and Qwen models.`,icon:`⚡`,color:`from-warning/12 to-warning/5 border-warning/30 hover:border-warning/50`,keyPlaceholder:`gsk_...`}},perplexity:{id:`perplexity`,name:`Perplexity Sonar API (Metered)`,family:`openai-compatible`,baseUrl:`https://api.perplexity.ai`,envVars:[`PERPLEXITY_API_KEY`],models:[`sonar-pro`,`sonar`,`sonar-reasoning-pro`,`sonar-reasoning`],usage:`metered-api`,docsUrl:`https://docs.perplexity.ai/`,requestPolicy:`perplexity`,catalog:{description:`Web-augmented chat models with built-in search and citations.`,icon:`🔍`,color:`from-info/12 to-info/5 border-info/30 hover:border-info/50`,keyPlaceholder:`pplx-...`}},"alibaba-token-plan":{id:`alibaba-token-plan`,name:`Alibaba Token Plan (Personal Edition)`,family:`openai-compatible`,baseUrl:`https://dashscope.aliyuncs.com/compatible-mode/v1`,envVars:[`ALIBABA_API_KEY`,`DASHSCOPE_API_KEY`],models:[`qwen3.8-max-preview`,`qwen3.7-max`,`qwen3.7-plus`,`qwen3.6-flash`,`glm-5.2`,`deepseek-v4-pro`,`wan2.7-image`,`wan2.7-image-pro`,`happyhorse-1.1-t2v`,`happyhorse-1.1-i2v`,`happyhorse-1.1-r2v`],customModels:{"qwen3.8-max-preview":{capabilities:{tools:!0,vision:!0,reasoning:!0,streaming:!0,systemPrompt:!0,jsonMode:!0,promptCache:!0,parallelTools:!0,cacheControl:`auto`}},"qwen3.7-max":{capabilities:{tools:!0,vision:!1,reasoning:!0,streaming:!0,systemPrompt:!0,jsonMode:!0,promptCache:!0,parallelTools:!0,cacheControl:`auto`}},"qwen3.7-plus":{capabilities:{tools:!0,vision:!0,reasoning:!0,streaming:!0,systemPrompt:!0,jsonMode:!0,promptCache:!0,parallelTools:!0,cacheControl:`auto`}},"qwen3.6-flash":{capabilities:{tools:!0,vision:!0,reasoning:!0,streaming:!0,systemPrompt:!0,jsonMode:!0,promptCache:!0,parallelTools:!0,cacheControl:`auto`}},"glm-5.2":{capabilities:{tools:!0,vision:!1,reasoning:!0,streaming:!0,systemPrompt:!0,jsonMode:!0,promptCache:!0,parallelTools:!0,cacheControl:`auto`}},"deepseek-v4-pro":{capabilities:{tools:!0,vision:!1,reasoning:!0,streaming:!0,systemPrompt:!0,jsonMode:!1,promptCache:!0,parallelTools:!0,cacheControl:`auto`}},"wan2.7-image":{capabilities:{tools:!1,vision:!0,reasoning:!1,streaming:!0,systemPrompt:!1,jsonMode:!1,promptCache:!1,parallelTools:!1,cacheControl:`none`}},"wan2.7-image-pro":{capabilities:{tools:!1,vision:!0,reasoning:!1,streaming:!0,systemPrompt:!1,jsonMode:!1,promptCache:!1,parallelTools:!1,cacheControl:`none`}},"happyhorse-1.1-t2v":{capabilities:{tools:!1,vision:!0,reasoning:!1,streaming:!0,systemPrompt:!1,jsonMode:!1,promptCache:!1,parallelTools:!1,cacheControl:`none`}},"happyhorse-1.1-i2v":{capabilities:{tools:!1,vision:!0,reasoning:!1,streaming:!0,systemPrompt:!1,jsonMode:!1,promptCache:!1,parallelTools:!1,cacheControl:`none`}},"happyhorse-1.1-r2v":{capabilities:{tools:!1,vision:!0,reasoning:!1,streaming:!0,systemPrompt:!1,jsonMode:!1,promptCache:!1,parallelTools:!1,cacheControl:`none`}}},usage:`subscription-interactive`,docsUrl:`https://www.alibabacloud.com/help/en/model-studio/token-plan-personal-overview`,requestPolicy:`alibaba`,catalog:{description:`Monthly Credits subscription for Qwen, DeepSeek, GLM, Wanx image, and HappyHorse video models.`,icon:`☁️`,color:`from-warning/12 to-warning/5 border-warning/30 hover:border-warning/50`,keyPlaceholder:`sk-...`}}};Object.keys(Tf);var Ef=[{id:`openai`,name:`OpenAI`,family:`openai`,envVars:[`OPENAI_API_KEY`],models:[],usage:`metered-api`,docsUrl:`https://platform.openai.com/api-keys`,catalog:{description:`GPT, o-series, and Codex models`,icon:`🤖`,color:`from-success/12 to-success/5 border-success/30 hover:border-success/50`,keyPlaceholder:`sk-...`}},{id:`anthropic`,name:`Anthropic`,family:`anthropic`,envVars:[`ANTHROPIC_API_KEY`],models:[],usage:`metered-api`,docsUrl:`https://console.anthropic.com/settings/keys`,catalog:{description:`Claude model access`,icon:`🧠`,color:`from-warning/12 to-warning/5 border-warning/30 hover:border-warning/50`,keyPlaceholder:`sk-ant-...`}},{id:`google`,name:`Google`,family:`google`,envVars:[`GOOGLE_GENERATIVE_AI_API_KEY`,`GEMINI_API_KEY`],models:[],usage:`metered-api`,docsUrl:`https://aistudio.google.com/apikey`,catalog:{description:`Gemini Pro, Flash, and Nano`,icon:`✨`,color:`from-info/12 to-info/5 border-info/30 hover:border-info/50`,keyPlaceholder:`AIza...`}},{id:`openai-codex`,name:`OpenAI Codex OAuth`,family:`openai-codex`,envVars:[],models:[],usage:`subscription-interactive`,docsUrl:`https://developers.openai.com/codex/`},{id:`anthropic-oauth`,name:`Anthropic OAuth`,family:`anthropic-oauth`,envVars:[],models:[],usage:`subscription-interactive`,docsUrl:`https://docs.anthropic.com/`},{id:`github-copilot`,name:`GitHub Copilot`,family:`github-copilot`,envVars:[],models:[],usage:`subscription-interactive`,docsUrl:`https://docs.github.com/en/copilot`},{id:`opencode-go`,name:`OpenCode Go`,family:`openai-compatible`,baseUrl:`https://opencode.ai/zen/go/v1`,envVars:[`OPENCODE_API_KEY`],models:[],usage:`subscription-interactive`,docsUrl:`https://opencode.ai/go?ref=6VZAER87H4`,catalog:{description:`Global hosted API for 75+ LLM providers — stable access from US, EU, and Singapore`,icon:`🌍`,color:`from-success/12 to-success/5 border-success/30 hover:border-success/50`,keyPlaceholder:`oc-...`,referral:{code:`6VZAER87H4`,reward:`Support the project by signing up with this referral link`,url:`https://opencode.ai/go?ref=6VZAER87H4`}}},{id:`xai`,name:`xAI`,family:`openai-compatible`,baseUrl:`https://api.x.ai/v1`,envVars:[`XAI_API_KEY`],models:[],usage:`metered-api`,docsUrl:`https://docs.x.ai/`,requestPolicy:`xai`},{id:`ai-gateway`,name:`Vercel AI Gateway`,family:`openai-compatible`,baseUrl:`https://ai-gateway.vercel.sh/v1`,discoveryOnlyBaseUrl:!0,envVars:[`AI_GATEWAY_API_KEY`],models:[],usage:`metered-api`,docsUrl:`https://vercel.com/docs/ai-gateway`,autoDiscover:!0,catalog:{description:`Every model behind one key — routed by Vercel AI Gateway`,icon:`▲`,color:`from-primary/12 to-primary/5 border-primary/30 hover:border-primary/50`,keyPlaceholder:`vck_...`}}],Df=[{id:`omniroute`,name:`OmniRoute`,family:`openai-compatible`,baseUrl:`http://localhost:20128/v1`,envVars:[],models:[],usage:`local`,quirks:{stripThinkTags:!0},autoDiscover:!0,local:{noAuth:!0,hint:`WrongStack local gateway · port 20128 · no key · auto-discovers models`}},{id:`ollama`,name:`Ollama`,family:`openai-compatible`,baseUrl:`http://localhost:11434/v1`,envVars:[],models:[],usage:`local`,docsUrl:`https://ollama.com`,local:{noAuth:!0,hint:`ollama.com · port 11434 · no key`}},{id:`vllm`,name:`vLLM`,family:`openai-compatible`,baseUrl:`http://localhost:8000/v1`,envVars:[],models:[],usage:`local`,docsUrl:`https://docs.vllm.ai`,local:{noAuth:!1,hint:`docs.vllm.ai · port 8000 · optional key`}},{id:`lmstudio`,name:`LM Studio`,family:`openai-compatible`,baseUrl:`http://localhost:1234/v1`,envVars:[],models:[],usage:`local`,docsUrl:`https://lmstudio.ai`,local:{noAuth:!1,hint:`lmstudio.ai · port 1234 · optional key`}}],Of=Object.fromEntries([...Ef,...Object.values(Tf),...Df].map(e=>[e.id,e]));function kf(){return Df.map(e=>{if(!e.baseUrl||!e.local)throw Error(`Local provider definition is incomplete: ${e.id}`);return{id:e.id,label:e.name,defaultBaseUrl:e.baseUrl,noAuth:e.local.noAuth,hint:e.local.hint}})}function Af(){return Object.values(Of).filter(e=>e.catalog!==void 0).map(e=>({id:e.id,name:e.name,family:e.family,description:e.catalog.description,icon:e.catalog.icon,color:e.catalog.color,keyPlaceholder:e.catalog.keyPlaceholder,...e.docsUrl?{docsUrl:e.docsUrl}:{},...e.catalog.referral?{referral:{...e.catalog.referral}}:{}}))}var jf=`openai-compatible`,Mf=kf(),Nf=[{kind:`chatgpt`,label:`ChatGPT`,subtitle:`Plus / Pro / Team → openai-codex`,icon:(0,Z.jsx)(et,{className:`h-5 w-5`})},{kind:`claude`,label:`Claude`,subtitle:`Pro / Max → anthropic-oauth`,icon:(0,Z.jsx)(jr,{className:`h-5 w-5`})},{kind:`copilot`,label:`GitHub Copilot`,subtitle:`Copilot → github-copilot`,icon:(0,Z.jsx)(on,{className:`h-5 w-5`})}],Pf=[`awaiting_browser`,`awaiting_code`,`exchanging`,`fetching_models`];function Ff({ws:e,savedByKind:t}){let{t:n}=H(),[r,i]=(0,X.useState)({chatgpt:{phase:`idle`},claude:{phase:`idle`},copilot:{phase:`idle`}}),[a,o]=(0,X.useState)(``),[s,c]=(0,X.useState)(null),[l,u]=(0,X.useState)(null),[d,f]=(0,X.useState)(``),[p,m]=(0,X.useState)(null);(0,X.useEffect)(()=>{let t=e.on(`auth.oauth.status`,e=>{if(e.type!==`auth.oauth.status`)return;let t=e.payload;i(e=>({...e,[t.kind]:{...t}})),t.phase===`success`?(B.success(t.message??U.t(`settings:oauth.signedInToast`,{provider:t.providerId??t.kind})),c(null),o(``),u(null),f(``)):t.phase===`error`&&B.error(t.message??U.t(`settings:oauth.signInFailed`))});return()=>t?.()},[e]);let h=(0,X.useCallback)(t=>{i(e=>({...e,[t]:{phase:t===`copilot`?`awaiting_code`:`awaiting_browser`}})),e.startOAuth(t)},[e]),g=(0,X.useCallback)((t,n)=>{i(e=>({...e,[t]:{phase:t===`copilot`?`awaiting_code`:`awaiting_browser`}})),e.startOAuth(t,n)},[e]),_=(0,X.useCallback)(t=>{let n=d.trim();n&&(i(e=>({...e,[t]:{phase:t===`copilot`?`awaiting_code`:`awaiting_browser`}})),e.startOAuth(t,n),u(null),f(``))},[e,d]),v=(0,X.useCallback)(t=>{e.cancelOAuth(t),i(e=>({...e,[t]:{phase:`idle`}})),c(null)},[e]),y=(0,X.useCallback)(t=>{let n=a.trim();n&&(e.submitOAuthCode(t,n),i(e=>({...e,[t]:{...e[t],phase:`exchanging`}})))},[a,e]),b=t??{};return(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(`div`,{className:`rounded-md border border-warning/30 bg-warning/5 p-3`,children:(0,Z.jsx)(`p`,{className:`text-xs leading-5 text-warning`,children:n(`settings:oauth.termsWarning`)})}),(0,Z.jsx)(`div`,{className:`grid grid-cols-1 gap-2 lg:grid-cols-3`,children:Nf.map(e=>{let t=r[e.kind],i=Pf.includes(t.phase),x=b[e.kind],S=x?.length??0,C=p===e.kind;return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-border bg-background/70 p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 lg:flex-col lg:items-stretch`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`font-medium`,children:e.label}),(0,Z.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.subtitle})]})]}),i?(0,Z.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>v(e.kind),className:`shrink-0 lg:w-full`,children:n(`common:action.cancel`)}):(0,Z.jsx)(Y,{size:`sm`,onClick:()=>h(e.kind),className:`shrink-0 lg:w-full`,children:n(`settings:oauth.signIn`)})]}),t.phase===`awaiting_browser`&&(0,Z.jsxs)(`div`,{className:`mt-3 space-y-2 border-t pt-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,Z.jsx)(wt,{className:`h-4 w-4 animate-spin text-muted-foreground`}),(0,Z.jsx)(`span`,{children:n(`settings:oauth.waitingBrowser`)})]}),t.authorizeUrl&&(0,Z.jsxs)(Y,{size:`sm`,variant:`outline`,onClick:()=>window.open(t.authorizeUrl,`_blank`,`noopener,noreferrer`),children:[(0,Z.jsx)(ur,{className:`h-3.5 w-3.5 mr-1`}),n(`settings:oauth.openSignIn`)]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`button`,{type:`button`,className:`text-xs text-muted-foreground underline`,onClick:()=>c(s===e.kind?null:e.kind),children:t.bound===!1?n(`settings:oauth.pasteLoopbackBusy`):n(`settings:oauth.pasteCantReach`)}),s===e.kind&&(0,Z.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,Z.jsx)(Ya,{placeholder:n(`activity:oauth.httpLocalhostCallbackCode`),value:a,onChange:e=>o(e.target.value),className:`font-mono text-xs`,onKeyDown:t=>{t.key===`Enter`&&y(e.kind)}}),(0,Z.jsx)(Y,{size:`sm`,onClick:()=>y(e.kind),disabled:!a.trim(),children:n(`settings:oauth.submit`)})]})]})]}),t.phase===`awaiting_code`&&(0,Z.jsxs)(`div`,{className:`mt-3 space-y-2 border-t pt-3`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(`settings:oauth.enterCode`)}),(0,Z.jsx)(`div`,{className:`font-mono text-2xl font-bold tracking-widest`,children:t.userCode??`…`}),t.verificationUri&&(0,Z.jsxs)(Y,{size:`sm`,variant:`outline`,onClick:()=>window.open(t.verificationUri,`_blank`,`noopener,noreferrer`),children:[(0,Z.jsx)(ur,{className:`h-3.5 w-3.5 mr-1`}),n(`settings:oauth.openVerification`)]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,Z.jsx)(wt,{className:`h-3.5 w-3.5 animate-spin`}),(0,Z.jsx)(`span`,{children:n(`settings:oauth.waitingCode`)})]})]}),(t.phase===`exchanging`||t.phase===`fetching_models`)&&(0,Z.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 border-t pt-3 text-sm`,children:[(0,Z.jsx)(wt,{className:`h-4 w-4 animate-spin text-muted-foreground`}),(0,Z.jsx)(`span`,{children:t.phase===`exchanging`?n(`settings:oauth.exchanging`):n(`settings:oauth.fetchingModels`)})]}),t.phase===`success`&&(0,Z.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 border-t pt-3 text-sm text-success`,children:[(0,Z.jsx)($t,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:t.message??n(`settings:oauth.signedIn`)})]}),t.phase===`error`&&t.message&&(0,Z.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 border-t pt-3 text-sm text-destructive`,children:[(0,Z.jsx)(Rr,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:t.message})]}),S>0&&!i&&(0,Z.jsxs)(`div`,{className:`mt-3 border-t pt-3`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>m(C?null:e.kind),className:`flex w-full items-center justify-between text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Z.jsx)(Qr,{className:`h-3.5 w-3.5`}),(0,Z.jsx)(`span`,{children:n(`settings:oauth.accountCount`,{count:S})})]}),(0,Z.jsx)(`span`,{className:`text-[10px]`,children:C?`▲`:`▼`})]}),C&&x&&(0,Z.jsxs)(`div`,{className:`mt-2 space-y-1.5`,children:[x.map(t=>(0,Z.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-border/60 bg-muted/20 px-2.5 py-1.5`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs`,children:t.id}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[t.hasActiveKey?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-success`,children:[(0,Z.jsx)($t,{className:`h-3 w-3`}),n(`settings:oauth.active`)]}):(0,Z.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:n(`settings:oauth.inactive`)}),(0,Z.jsxs)(Y,{size:`sm`,variant:`ghost`,onClick:()=>g(e.kind,t.id),className:`h-6 px-1.5 text-[11px]`,title:n(`settings:oauth.retryLogin`),children:[(0,Z.jsx)(xi,{className:`h-3 w-3 mr-0.5`}),n(`settings:oauth.retry`)]})]})]},t.id)),(0,Z.jsx)(`div`,{className:`pt-1`,children:l===e.kind?(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(Ya,{autoFocus:!0,placeholder:n(`settings:oauth.aliasPlaceholder`,{default:e.kind===`chatgpt`?`openai-codex-1`:`${e.kind}-2`}),value:d,onChange:e=>f(e.target.value),className:`text-xs font-mono`,onKeyDown:t=>{t.key===`Enter`&&_(e.kind)}}),(0,Z.jsx)(Y,{size:`sm`,onClick:()=>_(e.kind),disabled:!d.trim(),children:n(`settings:oauth.signIn`)}),(0,Z.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>{u(null),f(``)},children:n(`common:action.cancel`)})]}):(0,Z.jsxs)(Y,{size:`sm`,variant:`outline`,onClick:()=>u(e.kind),className:`w-full text-xs`,children:[(0,Z.jsx)(_i,{className:`h-3.5 w-3.5 mr-1`}),n(`settings:oauth.newAccount`)]})})]})]}),S===0&&!i&&(0,Z.jsx)(`div`,{className:`mt-3 border-t pt-3`,children:l===e.kind?(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(Ya,{autoFocus:!0,placeholder:n(`settings:oauth.aliasPlaceholder`,{default:e.kind===`chatgpt`?`openai-codex-1`:`${e.kind}-2`}),value:d,onChange:e=>f(e.target.value),className:`text-xs font-mono`,onKeyDown:t=>{t.key===`Enter`&&_(e.kind)}}),(0,Z.jsx)(Y,{size:`sm`,onClick:()=>_(e.kind),disabled:!d.trim(),children:n(`settings:oauth.signIn`)}),(0,Z.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>{u(null),f(``)},children:n(`common:action.cancel`)})]}):(0,Z.jsxs)(Y,{size:`sm`,variant:`outline`,onClick:()=>u(e.kind),className:`w-full text-xs`,children:[(0,Z.jsx)(_i,{className:`h-3.5 w-3.5 mr-1`}),n(`settings:oauth.newAccount`)]})})]},e.kind)})})]})}function If({open:e,providerId:t,modelCount:n,onConfirm:r,onCancel:i}){let a=(0,X.useRef)(null),{t:o}=H();return(0,X.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,Z.jsx)(Ja,{open:e,onOpenChange:e=>{e||i()},children:(0,Z.jsxs)(Ga,{className:`sm:max-w-md border-warning/50`,ref:a,tabIndex:-1,"data-clear-allowlist-dialog":!0,children:[(0,Z.jsxs)(Ua,{children:[(0,Z.jsxs)(Ka,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Kr,{className:`h-5 w-5 text-warning`}),o(`settings:allowlist.title`)]}),(0,Z.jsx)(qa,{children:o(`settings:allowlist.body`,{count:n,provider:t})})]}),(0,Z.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,Z.jsxs)(Wa,{className:`gap-2 sm:gap-2 flex-wrap`,children:[(0,Z.jsxs)(Y,{variant:`outline`,size:`sm`,onClick:i,title:o(`settings:allowlist.keepTitle`),"data-action":`cancel`,children:[o(`common:action.cancel`),` `,(0,Z.jsx)(`kbd`,{className:`ml-1 text-[10px] border rounded px-1 bg-background`,children:`Esc`})]}),(0,Z.jsxs)(Y,{variant:`destructive`,size:`sm`,onClick:r,title:o(`settings:allowlist.clearTitle`),"data-action":`confirm`,children:[o(`settings:allowlist.clear`),` `,(0,Z.jsx)(`kbd`,{className:`ml-1 text-[10px] border rounded px-1 bg-background/80`,children:`↵`})]})]})]})})}function Lf({ws:e,onSelect:t,onClose:n}){let{t:r}=H(),[i,a]=(0,X.useState)(``),[o,s]=(0,X.useState)([]),[c,l]=(0,X.useState)(!1),u=(0,X.useRef)(null),d=(0,X.useRef)(``);(0,X.useEffect)(()=>e.on(`provider.models.search_result`,e=>{if(e.type!==`provider.models.search_result`)return;let t=e.payload;(t.query===void 0||t.query===d.current)&&(s(t.matches??[]),l(!1))}),[e]);let f=(0,X.useCallback)(t=>{if(!t.trim()){s([]),d.current=``;return}d.current=t,l(!0),e.searchProviderModels(t,8)},[e]);(0,X.useEffect)(()=>(u.current&&clearTimeout(u.current),u.current=setTimeout(()=>f(i),300),()=>{u.current&&clearTimeout(u.current)}),[i,f]);let p=(0,X.useCallback)(e=>{let n={name:e.name,...e.description?{description:e.description}:{},...e.releaseDate?{release_date:e.releaseDate}:{},...e.contextWindow||e.maxOutput?{limit:{...e.contextWindow?{context:e.contextWindow}:{},...e.maxOutput?{output:e.maxOutput}:{}}}:{},...e.inputCost||e.outputCost?{cost:{...e.inputCost?{input:e.inputCost}:{},...e.outputCost?{output:e.outputCost}:{}}}:{},...e.capabilities.length>0?{tool_call:e.capabilities.includes(`tools`),reasoning:e.capabilities.includes(`reasoning`),...e.capabilities.includes(`vision`)?{modalities:{input:[`text`,`image`]}}:{}}:{}};t(e.modelId,n)},[t]);return(0,Z.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`absolute inset-0 bg-black/50`,onClick:n,"aria-label":r(`common:action.close`)}),(0,Z.jsxs)(`div`,{className:`relative max-h-[80vh] w-full max-w-xl overflow-y-auto rounded-lg border border-border bg-background p-4 shadow-lg`,children:[(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:r(`settings:providerModels.catalogSearchTitle`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:n,className:`text-muted-foreground hover:text-foreground`,children:(0,Z.jsx)(St,{className:`h-4 w-4`})})]}),(0,Z.jsxs)(`div`,{className:`relative mb-3`,children:[(0,Z.jsx)(vn,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground/60`}),(0,Z.jsx)(`input`,{type:`text`,value:i,onChange:e=>a(e.target.value),placeholder:r(`settings:providerModels.catalogSearchPlaceholder`),className:`h-10 w-full rounded-md border border-border bg-background pl-9 pr-3 text-sm focus:outline-none focus:ring-1 focus:ring-ring`})]}),c?(0,Z.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,Z.jsx)(wt,{className:`h-5 w-5 animate-spin text-muted-foreground`})}):o.length>0?(0,Z.jsx)(`div`,{className:`space-y-1.5`,children:o.map(e=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>p(e),className:`block w-full rounded-md border border-border/60 p-2.5 text-left transition-colors hover:border-primary/40 hover:bg-primary/5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`span`,{className:`font-mono text-sm font-medium text-foreground`,children:e.modelId}),e.name!==e.modelId&&(0,Z.jsx)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:e.name})]}),(0,Z.jsx)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground`,children:e.providerName})]}),e.description&&(0,Z.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-xs text-muted-foreground`,children:e.description}),(0,Z.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:[e.contextWindow?(0,Z.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:e.contextWindow>=1e6?`${(e.contextWindow/1e6).toFixed(1)}M ctx`:`${Math.round(e.contextWindow/1e3)}K ctx`}):null,e.capabilities.map(e=>(0,Z.jsx)(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 text-[10px] text-primary`,children:e},e))]})]},`${e.providerId}:${e.modelId}`))}):i.trim()?(0,Z.jsx)(`p`,{className:`py-8 text-center text-sm text-muted-foreground`,children:r(`settings:providerModels.noResults`)}):(0,Z.jsx)(`p`,{className:`py-8 text-center text-sm text-muted-foreground`,children:r(`settings:providerModels.typeToSearch`)})]})]})}var Rf=new Set([`__proto__`,`constructor`,`prototype`,`__defineGetter__`,`__defineSetter__`,`__lookupGetter__`,`__lookupSetter__`]);`document`in globalThis&&ii({jitless:!0});var zf=[`text`,`image`,`audio`,`video`,`pdf`],Bf=[`none`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],Vf=Hr().int().nonnegative(),Hf=Hr().finite(),Uf=Zn({context:Vf.optional(),output:Vf.optional(),input:Vf.optional()}),Wf=Zn({input:Hf.optional(),output:Hf.optional(),cache_read:Hf.optional(),cache_write:Hf.optional(),cache_write_5m:Hf.optional(),cache_write_1h:Hf.optional(),context_over_200k:Hf.optional(),reasoning:Hf.optional(),input_audio:Hf.optional(),output_audio:Hf.optional()}),Gf=Zn({input:Hn(rr().min(1)).optional(),output:Hn(rr().min(1)).optional()}),Kf=pr([Zn({type:hi(`toggle`)}),Zn({type:hi(`effort`),values:Hn(Ar(Bf)).optional()}),Zn({type:hi(`budget_tokens`),min:Hr().optional(),max:Hr().optional()})]),qf=e=>({message:`${e} id is a forbidden prototype-pollution key`}),Jf=Zn({id:rr().min(1).refine(e=>!Rf.has(e),qf(`Model`)),name:rr().min(1),description:rr().optional(),family:rr().optional(),attachment:$r().optional(),reasoning:$r().optional(),reasoning_options:pr([Kf,Hn(Kf)]).optional(),interleaved:pr([$r(),Zn({field:rr().optional()})]).optional(),tool_call:$r().optional(),structured_output:$r().optional(),temperature:$r().optional(),knowledge:rr().optional(),release_date:rr().optional(),last_updated:rr().optional(),open_weights:$r().optional(),modalities:Gf.optional(),cost:Wf.optional(),limit:Uf.optional(),status:rr().optional(),experimental:$r().optional()}),Yf=Zn({id:rr().min(1).refine(e=>!Rf.has(e),qf(`Provider`)),name:rr().min(1),env:Hn(rr()).optional(),npm:rr().optional(),api:rr().optional(),doc:rr().optional(),models:Si(rr(),Jf)});Si(rr(),Yf);function Xf(e,t){let n=t.limit,r=t.cost,i=t.modalities;return{id:e,name:t.name??``,description:t.description??``,family:t.family??``,limitContext:n?.context==null?``:String(n.context),limitOutput:n?.output==null?``:String(n.output),limitInput:n?.input==null?``:String(n.input),costInput:r?.input==null?``:String(r.input),costOutput:r?.output==null?``:String(r.output),inputModalities:Array.isArray(i?.input)?i.input:[],outputModalities:Array.isArray(i?.output)?i.output:[],toolCall:t.tool_call===!0,reasoning:t.reasoning===!0,temperature:t.temperature===!0,attachment:t.attachment===!0,structuredOutput:t.structured_output===!0,openWeights:t.open_weights===!0,releaseDate:t.release_date??``,lastUpdated:t.last_updated??``,knowledge:t.knowledge??``}}function Zf(e,t){let n={...t};e.name&&(n.name=e.name),e.description&&(n.description=e.description),e.family&&(n.family=e.family),e.knowledge&&(n.knowledge=e.knowledge);let r={};if(e.limitContext){let t=Number(e.limitContext);Number.isFinite(t)&&t>=0&&(r.context=t)}if(e.limitOutput){let t=Number(e.limitOutput);Number.isFinite(t)&&t>=0&&(r.output=t)}if(e.limitInput){let t=Number(e.limitInput);Number.isFinite(t)&&t>=0&&(r.input=t)}Object.keys(r).length>0&&(n.limit={...t.limit??{},...r});let i={};if(e.costInput){let t=Number(e.costInput);Number.isFinite(t)&&t>=0&&(i.input=t)}if(e.costOutput){let t=Number(e.costOutput);Number.isFinite(t)&&t>=0&&(i.output=t)}Object.keys(i).length>0&&(n.cost={...t.cost??{},...i});let a={};e.inputModalities.length>0&&(a.input=e.inputModalities),e.outputModalities.length>0&&(a.output=e.outputModalities),Object.keys(a).length>0&&(n.modalities={...t.modalities??{},...a});for(let[r,i]of[[`toolCall`,`tool_call`],[`reasoning`,`reasoning`],[`temperature`,`temperature`],[`attachment`,`attachment`],[`structuredOutput`,`structured_output`],[`openWeights`,`open_weights`]]){let a=t[i]===!0;e[r]!==a&&(n[i]=e[r])}return e.releaseDate&&(n.release_date=e.releaseDate),e.lastUpdated&&(n.last_updated=e.lastUpdated),n}var Qf=[{key:`toolCall`,labelKey:`settings:modelSchema.capToolCall`},{key:`reasoning`,labelKey:`settings:modelSchema.capReasoning`},{key:`temperature`,labelKey:`settings:modelSchema.capTemperature`},{key:`attachment`,labelKey:`settings:modelSchema.capAttachment`},{key:`structuredOutput`,labelKey:`settings:modelSchema.capStructuredOutput`},{key:`openWeights`,labelKey:`settings:modelSchema.capOpenWeights`}];function $f({providerId:e,modelId:t,initialModelsDev:n,onSave:r,onCancel:i}){let{t:a}=H(),[o,s]=(0,X.useState)(!1),[c,l]=(0,X.useState)(()=>Xf(t,n)),[u,d]=(0,X.useState)([]),[f,p]=(0,X.useState)(JSON.stringify({...n,...t?{id:t}:{}},null,2)),[m,h]=(0,X.useState)(null),g=(0,X.useCallback)((e,t)=>{l(n=>({...n,[e]:t}))},[]),_=(0,X.useCallback)((e,t)=>{l(n=>{let r=n[e];return{...n,[e]:r.includes(t)?r.filter(e=>e!==t):[...r,t]}})},[]),v=(0,X.useCallback)(()=>{let e=Zf(c,n),i=Jf.safeParse({...e,id:c.id||t});if(!i.success){d(i.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`));return}d([]),r(c.id||t,e)},[c,n,t,r]),y=(0,X.useCallback)(()=>{try{let e=JSON.parse(f),n=Jf.safeParse({...e,id:t||e.id});if(!n.success){h(n.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`; `));return}let{id:i,...a}=n.data;h(null),r(t||n.data.id,a)}catch(e){h(e instanceof Error?e.message:String(e))}},[f,t,r]),b=`h-8 w-full rounded-md border border-border bg-background px-2.5 text-sm focus:outline-none focus:ring-1 focus:ring-ring`,x=`mb-1 block text-[11px] font-medium uppercase tracking-wide text-muted-foreground`;return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`flex gap-1 border-b border-border/50`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>s(!1),className:G(`border-b-2 px-3 py-1 text-xs font-medium transition-colors`,o?`border-transparent text-muted-foreground hover:text-foreground`:`border-primary text-primary`),children:a(`settings:providerModels.tabForm`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>s(!0),className:G(`border-b-2 px-3 py-1 text-xs font-medium transition-colors`,o?`border-primary text-primary`:`border-transparent text-muted-foreground hover:text-foreground`),children:a(`settings:providerModels.tabRawJson`)})]}),o?(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`textarea`,{value:f,onChange:e=>p(e.target.value),rows:16,className:`w-full rounded-md border border-border bg-muted/20 p-2 font-mono text-xs`,spellCheck:!1}),m&&(0,Z.jsx)(`p`,{className:`text-xs text-destructive`,children:m})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,Z.jsx)(`legend`,{className:`text-xs font-semibold text-foreground`,children:a(`settings:providerModels.sectionIdentity`)}),!t&&(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:x,htmlFor:`mse-id`,children:`ID`}),(0,Z.jsx)(`input`,{id:`mse-id`,className:b,value:c.id,onChange:e=>g(`id`,e.target.value),placeholder:a(`activity:modelSchema.modelId`)})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:x,htmlFor:`mse-name`,children:a(`settings:providerModels.fieldName`)}),(0,Z.jsx)(`input`,{id:`mse-name`,className:b,value:c.name,onChange:e=>g(`name`,e.target.value)})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:x,htmlFor:`mse-desc`,children:a(`settings:providerModels.fieldDescription`)}),(0,Z.jsx)(`input`,{id:`mse-desc`,className:b,value:c.description,onChange:e=>g(`description`,e.target.value)})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:x,htmlFor:`mse-family`,children:a(`settings:providerModels.fieldFamily`)}),(0,Z.jsx)(`input`,{id:`mse-family`,className:b,value:c.family,onChange:e=>g(`family`,e.target.value)})]})]}),(0,Z.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,Z.jsx)(`legend`,{className:`text-xs font-semibold text-foreground`,children:a(`settings:providerModels.sectionLimits`)}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:x,htmlFor:`mse-ctx`,children:a(`settings:providerModels.fieldContext`)}),(0,Z.jsx)(`input`,{id:`mse-ctx`,type:`number`,className:b,value:c.limitContext,onChange:e=>g(`limitContext`,e.target.value)})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:x,htmlFor:`mse-out`,children:a(`settings:providerModels.fieldOutput`)}),(0,Z.jsx)(`input`,{id:`mse-out`,type:`number`,className:b,value:c.limitOutput,onChange:e=>g(`limitOutput`,e.target.value)})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:x,htmlFor:`mse-inlim`,children:a(`settings:providerModels.fieldInputLimit`)}),(0,Z.jsx)(`input`,{id:`mse-inlim`,type:`number`,className:b,value:c.limitInput,onChange:e=>g(`limitInput`,e.target.value)})]})]})]}),(0,Z.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,Z.jsx)(`legend`,{className:`text-xs font-semibold text-foreground`,children:a(`settings:providerModels.sectionPricing`)}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:x,htmlFor:`mse-costin`,children:a(`settings:providerModels.fieldCostInput`)}),(0,Z.jsx)(`input`,{id:`mse-costin`,type:`number`,step:`0.01`,className:b,value:c.costInput,onChange:e=>g(`costInput`,e.target.value)})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:x,htmlFor:`mse-costout`,children:a(`settings:providerModels.fieldCostOutput`)}),(0,Z.jsx)(`input`,{id:`mse-costout`,type:`number`,step:`0.01`,className:b,value:c.costOutput,onChange:e=>g(`costOutput`,e.target.value)})]})]})]}),(0,Z.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,Z.jsx)(`legend`,{className:`text-xs font-semibold text-foreground`,children:a(`settings:providerModels.sectionModalities`)}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`span`,{className:x,children:a(`settings:providerModels.fieldInputModalities`)}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:zf.map(e=>{let t=c.inputModalities.includes(e);return(0,Z.jsx)(`button`,{type:`button`,onClick:()=>_(`inputModalities`,e),className:G(`rounded-md border px-2 py-1 text-xs transition-colors`,t?`border-primary bg-primary/10 text-primary`:`border-border text-muted-foreground hover:border-primary/30`),children:e},`in-mod-${e}`)})})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`span`,{className:x,children:a(`settings:providerModels.fieldOutputModalities`)}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:zf.map(e=>{let t=c.outputModalities.includes(e);return(0,Z.jsx)(`button`,{type:`button`,onClick:()=>_(`outputModalities`,e),className:G(`rounded-md border px-2 py-1 text-xs transition-colors`,t?`border-primary bg-primary/10 text-primary`:`border-border text-muted-foreground hover:border-primary/30`),children:e},`out-mod-${e}`)})})]})]}),(0,Z.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,Z.jsx)(`legend`,{className:`text-xs font-semibold text-foreground`,children:a(`settings:providerModels.sectionCapabilities`)}),(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:Qf.map(({key:e,labelKey:t})=>(0,Z.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`h-4 w-4 rounded border-border`,checked:c[e],onChange:t=>g(e,t.target.checked)}),a(t)]},String(e)))})]}),(0,Z.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,Z.jsx)(`legend`,{className:`text-xs font-semibold text-foreground`,children:a(`settings:providerModels.sectionDates`)}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:x,htmlFor:`mse-release`,children:a(`settings:providerModels.fieldReleaseDate`)}),(0,Z.jsx)(`input`,{id:`mse-release`,type:`date`,className:b,value:c.releaseDate,onChange:e=>g(`releaseDate`,e.target.value)})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:x,htmlFor:`mse-updated`,children:a(`settings:providerModels.fieldLastUpdated`)}),(0,Z.jsx)(`input`,{id:`mse-updated`,type:`date`,className:b,value:c.lastUpdated,onChange:e=>g(`lastUpdated`,e.target.value)})]})]})]}),u.length>0&&(0,Z.jsx)(`div`,{className:`rounded-md border border-destructive/30 bg-destructive/5 p-2`,children:(0,Z.jsx)(`ul`,{className:`space-y-0.5 text-xs text-destructive`,children:u.map((e,t)=>(0,Z.jsx)(`li`,{children:e},t))})})]}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-border/50 pt-3`,children:[(0,Z.jsxs)(Y,{type:`button`,variant:`ghost`,size:`sm`,onClick:i,className:`h-8 gap-1.5 text-xs`,children:[(0,Z.jsx)(St,{className:`h-3.5 w-3.5`}),a(`common:action.cancel`)]}),(0,Z.jsxs)(Y,{type:`button`,size:`sm`,onClick:o?y:v,className:`h-8 gap-1.5 text-xs`,children:[(0,Z.jsx)(ui,{className:`h-3.5 w-3.5`}),a(`common:action.save`)]})]})]})}function ep(e,t){return e.map(e=>{let n=t?.[e],r=n?.modelsDev,i=!!(n&&(n.name||n.maxOutput||n.capabilities||r));return{modelId:e,name:r?.name??n?.name??e,modelsDev:r,maxOutput:n?.maxOutput??r?.limit?.output,capabilities:n?.capabilities,source:i?`overridden`:`catalog`}})}function tp(e){let t=e?.limit?.context;if(typeof t==`number`&&t>0)return t>=1e6?`${(t/1e6).toFixed(1)}M`:`${Math.round(t/1e3)}K`}function np(e){let t=e?.cost,n=e=>typeof e==`number`&&e>=0?`$${e}`:void 0;return{input:n(t?.input),output:n(t?.output)}}function rp(e){let t=e?.modalities;return{input:Array.isArray(t?.input)?t.input:[],output:Array.isArray(t?.output)?t.output:[]}}var ip={text:tn,image:Ei,audio:Ir,video:De,pdf:tn};function ap({providerId:e,models:t,customModels:n,ws:r,pickedModelId:i,onPickModel:a}){let{t:o}=H(),[s,c]=(0,X.useState)(null),[l,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)(``),h=(0,X.useMemo)(()=>ep(t,n),[t,n]),g=(0,X.useMemo)(()=>{let e=p.trim().toLowerCase();return e?h.filter(t=>t.modelId.toLowerCase().includes(e)||(t.name?.toLowerCase().includes(e)??!1)):h},[h,p]),_=(0,X.useCallback)(t=>{r.removeCustomModel(e,t),B.success(o(`settings:providerModels.modelRemoved`,{model:t}))},[r,e,o]),v=(0,X.useCallback)((t,n)=>{r.setCustomModel(e,t,{modelsDev:n}),c(null),B.success(o(`settings:providerModels.modelSaved`,{model:t}))},[r,e,o]),y=(0,X.useCallback)((t,n)=>{r.setCustomModel(e,t,{modelsDev:n}),u(!1),B.success(o(`settings:providerModels.modelAdded`,{model:t}))},[r,e,o]);return(0,Z.jsxs)(`div`,{className:`space-y-3`,"data-model-list-editor":e,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(Y,{variant:`outline`,size:`sm`,onClick:()=>u(!0),className:`h-8 gap-1.5 text-xs`,children:[(0,Z.jsx)(_i,{className:`h-3.5 w-3.5`}),o(`settings:providerModels.addFromCatalog`)]}),(0,Z.jsxs)(Y,{variant:`ghost`,size:`sm`,onClick:()=>f(!0),className:`h-8 gap-1.5 text-xs`,children:[(0,Z.jsx)(_i,{className:`h-3.5 w-3.5`}),o(`settings:providerModels.addCustom`)]})]}),h.length>0&&(0,Z.jsxs)(`div`,{className:`overflow-hidden rounded-lg border border-border/70`,children:[h.length>8&&(0,Z.jsxs)(`div`,{className:`relative border-b border-border/40 bg-muted/10`,children:[(0,Z.jsx)(vn,{className:`pointer-events-none absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground/60`}),(0,Z.jsx)(`input`,{type:`text`,value:p,onChange:e=>m(e.target.value),placeholder:o(`settings:providerModels.filterPlaceholder`),"aria-label":o(`settings:providerModels.filterPlaceholder`),className:`h-8 w-full bg-transparent pl-9 pr-3 text-xs text-foreground placeholder:text-muted-foreground/50 focus:outline-none focus:ring-1 focus:ring-ring`})]}),(0,Z.jsx)(`div`,{className:`max-h-80 overflow-y-auto`,children:(0,Z.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,Z.jsx)(`thead`,{children:(0,Z.jsxs)(`tr`,{className:`border-b border-border/70 bg-muted/30 text-left text-[11px] uppercase tracking-wide text-muted-foreground`,children:[(0,Z.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:o(`settings:providerModels.colModel`)}),(0,Z.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:o(`settings:providerModels.colContext`)}),(0,Z.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:o(`settings:providerModels.colOutput`)}),(0,Z.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:o(`settings:providerModels.colCost`)}),(0,Z.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:o(`settings:providerModels.colModalities`)}),(0,Z.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:o(`settings:providerModels.colCaps`)}),(0,Z.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:o(`settings:providerModels.colSource`)}),(0,Z.jsx)(`th`,{className:`px-3 py-2`,"aria-label":o(`settings:providerModels.colActions`)})]})}),(0,Z.jsx)(`tbody`,{children:g.map(t=>{let n=tp(t.modelsDev),r=t.maxOutput??t.modelsDev?.limit?.output,l=typeof r==`number`?r.toLocaleString():void 0,u=np(t.modelsDev),d=rp(t.modelsDev),f=t.capabilities,p=s===t.modelId;return(0,Z.jsxs)(X.Fragment,{children:[(0,Z.jsxs)(`tr`,{className:`border-b border-border/40 transition-colors hover:bg-muted/20`,children:[(0,Z.jsx)(`td`,{className:`px-3 py-2`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Z.jsx)(`span`,{className:`font-mono text-xs font-medium text-foreground`,children:t.modelId}),t.name&&t.name!==t.modelId&&(0,Z.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:t.name})]})}),(0,Z.jsx)(`td`,{className:`px-3 py-2 text-xs text-muted-foreground`,children:n?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Z.jsx)(He,{className:`h-3 w-3`}),n]}):(0,Z.jsx)(`span`,{className:`text-muted-foreground/40`,children:`—`})}),(0,Z.jsx)(`td`,{className:`px-3 py-2 text-xs text-muted-foreground`,children:l?(0,Z.jsx)(`span`,{children:l}):(0,Z.jsx)(`span`,{className:`text-muted-foreground/40`,children:`—`})}),(0,Z.jsx)(`td`,{className:`px-3 py-2 text-xs`,children:u.input||u.output?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-muted-foreground`,children:[(0,Z.jsx)(gi,{className:`h-3 w-3`}),u.input&&u.output?`${u.input}/${u.output}`:u.input??u.output]}):(0,Z.jsx)(`span`,{className:`text-muted-foreground/40`,children:`—`})}),(0,Z.jsx)(`td`,{className:`px-3 py-2`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[d.input.map(e=>{let t=ip[e]??tn;return(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 rounded bg-primary/10 px-1 py-0.5 text-[10px] text-primary`,title:`input: ${e}`,children:[(0,Z.jsx)(t,{className:`h-2.5 w-2.5`}),e]},`in-${e}`)}),d.output.map(e=>(0,Z.jsx)(`span`,{className:`inline-flex items-center gap-0.5 rounded bg-secondary/20 px-1 py-0.5 text-[10px] text-secondary-foreground`,title:`output: ${e}`,children:e},`out-${e}`))]})}),(0,Z.jsx)(`td`,{className:`px-3 py-2`,children:(0,Z.jsxs)(`div`,{className:`flex gap-1`,children:[f?.tools&&(0,Z.jsx)(li,{className:`h-3.5 w-3.5 text-muted-foreground`,"aria-label":o(`activity:modelListEditor.tools`)}),f?.reasoning&&(0,Z.jsx)(lr,{className:`h-3.5 w-3.5 text-muted-foreground`,"aria-label":o(`activity:modelListEditor.reasoning`)}),f?.vision&&(0,Z.jsx)(Xt,{className:`h-3.5 w-3.5 text-muted-foreground`,"aria-label":o(`activity:modelListEditor.vision`)})]})}),(0,Z.jsx)(`td`,{className:`px-3 py-2`,children:(0,Z.jsx)(`span`,{className:G(`inline-flex items-center rounded-full px-2 py-0.5 text-[10px] font-medium`,t.source===`custom`&&`bg-warning/10 text-warning`,t.source===`catalog`&&`bg-info/10 text-info`,t.source===`overridden`&&`bg-primary/10 text-primary`),children:t.source})}),(0,Z.jsx)(`td`,{className:`px-3 py-2`,children:(0,Z.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[a&&(t.modelId===i?(0,Z.jsx)(`span`,{className:`inline-flex items-center rounded p-1 text-primary`,title:o(`settings:providerModels.usingModel`,{model:t.modelId}),role:`img`,"aria-label":o(`settings:providerModels.usingModel`,{model:t.modelId}),children:(0,Z.jsx)(ui,{className:`h-3.5 w-3.5`})}):(0,Z.jsx)(`button`,{type:`button`,onClick:()=>a(e,t.modelId),className:`rounded p-1 text-muted-foreground transition-colors hover:bg-primary/10 hover:text-primary`,"aria-label":o(`settings:providerModels.useModel`,{model:t.modelId}),title:o(`settings:providerModels.useModel`,{model:t.modelId}),children:(0,Z.jsx)(ui,{className:`h-3.5 w-3.5`})})),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>c(p?null:t.modelId),className:`rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,"aria-label":o(`settings:providerModels.editModel`,{model:t.modelId}),children:(0,Z.jsx)(or,{className:`h-3.5 w-3.5`})}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>_(t.modelId),className:`rounded p-1 text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive`,"aria-label":o(`settings:providerModels.removeModel`,{model:t.modelId}),children:(0,Z.jsx)(vr,{className:`h-3.5 w-3.5`})})]})})]}),p&&(0,Z.jsx)(`tr`,{className:`border-b border-border/40 bg-muted/10`,children:(0,Z.jsx)(`td`,{colSpan:8,className:`p-3`,children:(0,Z.jsx)($f,{providerId:e,modelId:t.modelId,initialModelsDev:t.modelsDev??{},onSave:v,onCancel:()=>c(null)})})},`${t.modelId}-edit`)]},t.modelId)})})]})})]}),h.length===0&&(0,Z.jsx)(`div`,{className:`rounded-lg border border-dashed border-border/50 p-8 text-center`,children:(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o(`settings:providerModels.emptyState`)})}),l&&(0,Z.jsx)(Lf,{ws:r,onSelect:y,onClose:()=>u(!1)}),d&&(0,Z.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`absolute inset-0 bg-black/50`,onClick:()=>f(!1),"aria-label":o(`common:action.close`)}),(0,Z.jsxs)(`div`,{className:`relative max-h-[80vh] w-full max-w-2xl overflow-y-auto rounded-lg border border-border bg-background p-4 shadow-lg`,children:[(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:o(`settings:providerModels.addCustomTitle`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>f(!1),className:`text-muted-foreground hover:text-foreground`,children:(0,Z.jsx)(St,{className:`h-4 w-4`})})]}),(0,Z.jsx)($f,{providerId:e,modelId:``,initialModelsDev:{},onSave:v,onCancel:()=>f(!1)})]})]})]})}function op(){return{inFlight:!1,last:null,picked:null}}function sp(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 cp(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 lp(e){return(e?.length??0)>0}function up(e,t){return`Allowlist cleared for ${e} — ${t} model${t===1?``:`s`} removed`}function dp(e){return e.length>0}function fp(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 pp=3e3;function mp({providerId:e,savedPickedModelId:t,savedModels:n,savedCustomModels:r,ws:i,onPickModel:a,onClearModels:o,onUndoClear:s}){let[c,l]=(0,X.useState)(()=>op()),{t:u}=H(),[d,f]=(0,X.useState)(!1);(0,X.useEffect)(()=>i.on(`provider.probe`,t=>{t.type===`provider.probe`&&t.payload.providerId===e&&l(e=>({...e,inFlight:!1,last:sp(t.payload)}))}),[i,e]);let p=(0,X.useCallback)(()=>{l(e=>({...e,inFlight:!0})),i.probeProvider(e,pp)},[i,e]),m=(0,X.useCallback)((e,t)=>{l(e=>({...e,picked:t})),a?.(e,t)},[a]),h=(0,X.useCallback)(()=>{f(!0)},[]),g=(0,X.useCallback)(()=>{f(!1)},[]),_=(0,X.useCallback)(()=>{f(!1);let t=n?[...n]:[];l(e=>({...e,picked:null,last:null})),o?o(e):i.clearProviderModels(e),dp(t)&&B.undoable(up(e,t.length),()=>{let n=fp({providerId:e,previousModels:t,onUndoClear:s});switch(n.kind){case`skip`:return;case`callback`:s?.(n.providerId,n.previousModels);return;case`ws-default`:i.undoProviderClear(n.providerId,n.previousModels);return}})},[o,s,i,e,n]),v=(0,X.useMemo)(()=>c.picked??t??n?.[0]??``,[c.picked,t,n]),y=(0,X.useMemo)(()=>cp(c),[c]),b=(0,X.useMemo)(()=>lp(n),[n]);return(0,Z.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,Z.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[(0,Z.jsx)(Yt,{className:`h-3.5 w-3.5`}),u(`activity:providerModels.allowlistTitle`)]}),n&&n.length>0&&(0,Z.jsx)(`span`,{className:`rounded-full border border-border/70 bg-muted/40 px-2 py-0.5 text-[11px] text-muted-foreground`,children:u(`activity:providerModels.modelCount`,{count:n.length})})]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:u(`activity:providerModels.using`)}),v?(0,Z.jsx)(`span`,{className:`max-w-full break-words rounded-md bg-primary/10 px-2 py-0.5 font-mono text-xs text-primary`,children:v}):(0,Z.jsx)(`span`,{className:`text-xs italic text-muted-foreground`,children:u(`activity:providerModels.noModelPicked`)})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 sm:justify-end`,children:[(0,Z.jsxs)(Y,{variant:`outline`,size:`sm`,onClick:p,disabled:c.inFlight,"aria-label":u(`activity:providerModels.refreshAria`,{provider:e}),className:`h-8 px-2 text-xs`,children:[c.inFlight?(0,Z.jsx)(wt,{className:`h-3.5 w-3.5 animate-spin`}):(0,Z.jsx)(xi,{className:`h-3.5 w-3.5`}),c.inFlight?u(`activity:providerModels.probing`):u(`activity:providerModels.refresh`)]}),b&&(0,Z.jsx)(Y,{variant:`ghost`,size:`sm`,onClick:h,"aria-label":u(`activity:providerModels.clearAllowlistAria`,{provider:e}),"data-action":`clear-models`,className:`h-8 px-2 text-xs`,children:u(`activity:providerModels.clearAllowlist`)})]})]}),(0,Z.jsx)(hp,{formatted:y}),(0,Z.jsx)(`div`,{className:`mt-3`,children:(0,Z.jsx)(ap,{providerId:e,models:n??[],customModels:r,ws:i,pickedModelId:v??void 0,onPickModel:m})}),(0,Z.jsx)(If,{open:d,providerId:e,modelCount:n?.length??0,onConfirm:_,onCancel:g})]})}function hp({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,Z.jsxs)(`p`,{className:`mt-2 flex items-center gap-1.5 text-xs ${t}`,"data-probe-tone":e.tone,children:[(0,Z.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full ${n}`}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:e.text})]})}var gp=[`anthropic`,`openai`,`google`,`openai-compatible`];function _p({activeProvider:e,catalogProviders:t,isLoadingCatalog:n,savedProviders:r,isLoadingSaved:i,providerTab:a,setProviderTab:o,onSelectProvider:s,onAddKey:c,onDeleteKey:l,onSetActiveKey:u,onAddProvider:d,onRemoveProvider:f,onPickProviderModel:p,ws:m,catalogQuery:h,setCatalogQuery:g}){let{t:_}=H(),[v,y]=(0,X.useState)(null),[b,x]=(0,X.useState)(``),[S,C]=(0,X.useState)(``),[w,T]=(0,X.useState)(!1),[E,D]=(0,X.useState)(!1),[O,k]=(0,X.useState)(``),[A,j]=(0,X.useState)(`openai-compatible`),[M,N]=(0,X.useState)(``),[P,F]=(0,X.useState)(``),[I,L]=(0,X.useState)([]),R=Sf(),ee=Sf(),te=(0,X.useCallback)(e=>{!b.trim()||!S.trim()||(c(e,b.trim(),S.trim()),x(``),C(``),y(null))},[c,b,S]),z=(0,X.useCallback)(()=>{O.trim()&&(d(O.trim(),A,M||void 0,P||void 0,I.length>0?I.map(e=>e.id):void 0,I.length>0?Object.fromEntries(I.filter(e=>e.name||e.maxOutput||e.capabilities&&Object.keys(e.capabilities).length>0).map(e=>[e.id,{...e.name&&e.name!==e.id?{name:e.name}:{},...e.maxOutput?{maxOutput:e.maxOutput}:{},...e.capabilities&&Object.keys(e.capabilities).length>0?{capabilities:e.capabilities}:{}}])):void 0),k(``),j(`openai-compatible`),N(``),F(``),L([]),D(!1))},[d,O,A,M,P,I]),ne=(0,X.useCallback)(e=>{k(e.id),j(jf),N(e.defaultBaseUrl),e.noAuth&&F(``),L([])},[]),[re,ie]=(0,X.useState)(null),[ae,oe]=(0,X.useState)(``),[se,ce]=(0,X.useState)(!1),[le,ue]=(0,X.useState)({}),de=(0,X.useMemo)(()=>new Set(r.map(e=>e.id)),[r]),fe=(0,X.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,X.useEffect)(()=>{let e=m.on(`provider.probe`,e=>{if(e.type!==`provider.probe`)return;let t=e.payload;t.status!==`no_base_url`&&t.status!==`no_provider`&&ue(e=>({...e,[t.providerId]:{ok:t.ok,status:t.status,detail:t.detail}}))});return()=>e?.()},[m]);let pe=(0,X.useCallback)(e=>{let t=ae.trim();t&&(de.has(e.id)?c(e.id,`default`,t):d(e.id,e.family,e.apiBase??void 0,t),oe(``),ie(null),ce(!1),B.success(_(`settings:provider.savedToast`,{name:e.name})),e.apiBase&&setTimeout(()=>m.probeProvider(e.id,6e3),700))},[ae,de,c,d,m]),me=h.trim()?t.filter(e=>{let t=h.trim().toLowerCase();return e.id.toLowerCase().includes(t)||e.name.toLowerCase().includes(t)||e.family.toLowerCase().includes(t)}):t,V=me.reduce((e,t)=>(e[t.family]||(e[t.family]=[]),e[t.family]?.push(t),e),{});return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsxs)(`h3`,{className:`text-sm font-semibold flex items-center gap-2`,children:[(0,Z.jsx)(ri,{className:`h-4 w-4 text-muted-foreground`}),_(`settings:provider.subscriptionHeading`)]}),(0,Z.jsx)(Ff,{ws:m,savedByKind:{chatgpt:r.filter(e=>e.id===`openai-codex`||e.id.startsWith(`openai-codex-`)).map(e=>({id:e.id,hasActiveKey:e.apiKeys.some(e=>e.isActive)})),claude:r.filter(e=>e.id===`anthropic-oauth`||e.id.startsWith(`anthropic-oauth-`)).map(e=>({id:e.id,hasActiveKey:e.apiKeys.some(e=>e.isActive)})),copilot:r.filter(e=>e.id===`github-copilot`).map(e=>({id:e.id,hasActiveKey:e.apiKeys.some(e=>e.isActive)}))}})]}),(0,Z.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Z.jsxs)(`h3`,{className:`text-sm font-semibold mb-1 flex items-center gap-2`,children:[(0,Z.jsx)(Bn,{className:`h-4 w-4 text-muted-foreground`}),_(`settings:provider.apiKeysHeading`)]}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground mb-3`,children:_(`settings:provider.apiKeysBody`)})]}),(0,Z.jsxs)(`div`,{className:`flex gap-2 mb-4`,children:[(0,Z.jsxs)(Y,{variant:a===`catalog`?`default`:`outline`,size:`sm`,onClick:()=>o(`catalog`),children:[(0,Z.jsx)(Bn,{className:`h-4 w-4 mr-1`}),_(`settings:provider.tabCatalog`)]}),(0,Z.jsxs)(Y,{variant:a===`saved`?`default`:`outline`,size:`sm`,onClick:()=>o(`saved`),children:[(0,Z.jsx)(ri,{className:`h-4 w-4 mr-1`}),_(`settings:provider.tabSaved`,{count:r.length})]})]}),a===`catalog`&&(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(Ya,{placeholder:_(`settings:provider.searchPlaceholder`,{count:t.length}),value:h,onChange:e=>g(e.target.value),className:`text-sm`}),n&&t.length===0?(0,Z.jsxs)(`div`,{className:`flex items-center justify-center py-8`,children:[(0,Z.jsx)(wt,{className:`h-6 w-6 animate-spin text-muted-foreground`}),(0,Z.jsx)(`span`,{className:`ml-2 text-muted-foreground`,children:_(`settings:provider.loadingCatalog`)})]}):me.length===0&&h?(0,Z.jsx)(`div`,{className:`text-center py-8 text-muted-foreground text-sm`,children:_(`settings:provider.noMatch`,{query:h})}):gp.map(t=>{let n=V[t];return n?.length?(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-muted-foreground uppercase tracking-wider`,children:t}),(0,Z.jsx)(`div`,{className:`grid grid-cols-1 gap-2`,children:n.map(t=>{let n=le[t.id],r=e===t.id;return(0,Z.jsxs)(`div`,{className:G(`rounded-lg border transition-all`,r?`border-primary bg-primary/5 ring-2 ring-primary/20`:`border-border`),children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>s(t.id),className:G(`flex w-full flex-col items-start p-3 text-left rounded-lg`,!r&&`hover:bg-muted`),children:[(0,Z.jsxs)(`div`,{className:`flex w-full justify-between items-start`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:t.name}),(0,Z.jsxs)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:[`(`,t.id,`)`]})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t.hasApiKey&&(0,Z.jsxs)(`span`,{className:`text-xs bg-success/10 text-success px-2 py-0.5 rounded`,children:[(0,Z.jsx)(ri,{className:`h-3 w-3 inline mr-1`}),_(`settings:provider.configured`)]}),n&&(0,Z.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,Z.jsx)($t,{className:`h-3 w-3`}):(0,Z.jsx)(Rr,{className:`h-3 w-3`}),n.ok?_(`settings:provider.reachable`):n.status]}),t.envVars[0]&&(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:_(`settings:provider.envVar`,{var:t.envVars[0]})}),r&&(0,Z.jsx)($t,{className:`h-4 w-4 text-primary`})]})]}),(0,Z.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[_(`settings:provider.modelCount`,{count:t.modelCount}),t.apiBase&&` · ${t.apiBase}`]})]}),r&&!t.hasApiKey&&(0,Z.jsx)(`div`,{className:`px-3 pb-3 -mt-1 space-y-2`,children:re===t.id?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(Ya,{autoFocus:!0,type:se?`text`:`password`,placeholder:_(`settings:provider.keyPlaceholder`,{name:t.name}),value:ae,onChange:e=>oe(e.target.value),className:`text-sm`,onKeyDown:e=>{e.key===`Enter`&&pe(t)}}),(0,Z.jsx)(Y,{size:`icon`,variant:`ghost`,onClick:()=>ce(e=>!e),children:se?(0,Z.jsx)(ke,{className:`h-4 w-4`}):(0,Z.jsx)(Xt,{className:`h-4 w-4`})}),(0,Z.jsx)(Y,{size:`sm`,onClick:()=>pe(t),disabled:!ae.trim(),children:_(`common:action.save`)})]}),t.envVars[0]&&(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:_(`settings:provider.orEnv`,{env:t.envVars[0]})})]}):(0,Z.jsxs)(Y,{size:`sm`,variant:`outline`,onClick:()=>{ie(t.id),oe(``)},children:[(0,Z.jsx)(ri,{className:`h-3.5 w-3.5 mr-1`}),_(`settings:provider.addApiKey`)]})})]},t.id)})})]},t):null})]}),a===`saved`&&(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:_(`settings:provider.manageKeys`)}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2 text-xs text-muted-foreground`,children:[(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-muted/30 px-2 py-1`,children:[(0,Z.jsx)(Qi,{className:`h-3.5 w-3.5`}),_(`settings:provider.savedProviderCount`,{count:r.length})]}),(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-muted/30 px-2 py-1`,children:[(0,Z.jsx)(ri,{className:`h-3.5 w-3.5`}),_(`settings:provider.keyCount`,{count:fe.keys})]}),(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-muted/30 px-2 py-1`,children:[(0,Z.jsx)(zt,{className:`h-3.5 w-3.5`}),_(`settings:provider.activeKeyCount`,{count:fe.activeKeys})]}),(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-muted/30 px-2 py-1`,children:[(0,Z.jsx)(ar,{className:`h-3.5 w-3.5`}),_(`settings:provider.modelCount`,{count:fe.models})]})]})]}),(0,Z.jsxs)(Y,{size:`sm`,variant:`outline`,onClick:()=>D(!E),children:[(0,Z.jsx)(_i,{className:`h-4 w-4 mr-1`}),_(`settings:provider.addProvider`)]})]}),E&&(0,Z.jsxs)(`div`,{className:`p-4 border rounded-lg space-y-3 bg-muted/50`,children:[(0,Z.jsx)(`h4`,{className:`font-medium`,children:_(`settings:provider.addCustomHeading`)}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:_(`settings:provider.localServers`)}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:Mf.map(e=>(0,Z.jsx)(Y,{type:`button`,size:`sm`,variant:O===e.id?`default`:`outline`,onClick:()=>ne(e),title:e.hint,children:e.label},e.id))})]}),(0,Z.jsx)(Ya,{placeholder:_(`settings:provider.providerIdPlaceholder`),value:O,onChange:e=>k(e.target.value),ref:R.setFieldRef(0),onKeyDown:e=>R.handleKeyDown(e,0)}),(0,Z.jsxs)(`select`,{className:`flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm`,value:A,onChange:e=>j(e.target.value),ref:R.setFieldRef(1),onKeyDown:e=>R.handleKeyDown(e,1),children:[(0,Z.jsx)(`option`,{value:`anthropic`,children:_(`activity:provider.anthropic`)}),(0,Z.jsx)(`option`,{value:`openai`,children:_(`activity:provider.openai`)}),(0,Z.jsx)(`option`,{value:`openai-compatible`,children:_(`activity:provider.openaiCompatible`)}),(0,Z.jsx)(`option`,{value:`google`,children:_(`activity:provider.google`)})]}),(0,Z.jsx)(Ya,{placeholder:_(`activity:provider.baseUrlOptionalEGHttpLocalhost11434V1`),value:M,onChange:e=>N(e.target.value),ref:R.setFieldRef(2),onKeyDown:e=>R.handleKeyDown(e,2)}),(0,Z.jsx)(Ya,{type:`password`,placeholder:_(`settings:provider.apiKeyOptionalPlaceholder`),value:P,onChange:e=>F(e.target.value),ref:R.setFieldRef(3),onKeyDown:e=>R.handleKeyDown(e,3)}),(0,Z.jsx)(Cf,{models:I,onChange:L}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(Y,{size:`sm`,onClick:z,disabled:!O.trim(),ref:R.setFieldRef(4),onKeyDown:e=>R.handleKeyDown(e,4,z),children:_(`common:action.add`)}),(0,Z.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>D(!1),ref:R.setFieldRef(5),onKeyDown:e=>R.handleKeyDown(e,5),children:_(`common:action.cancel`)})]})]}),i?(0,Z.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,Z.jsx)(wt,{className:`h-6 w-6 animate-spin text-muted-foreground`})}):r.length===0?(0,Z.jsxs)(`div`,{className:`text-center py-8 text-muted-foreground`,children:[(0,Z.jsx)(ri,{className:`h-8 w-8 mx-auto mb-2 opacity-50`}),(0,Z.jsx)(`p`,{children:_(`settings:provider.noSaved`)}),(0,Z.jsx)(`p`,{className:`text-sm`,children:_(`settings:provider.noSavedHint`)})]}):r.map(e=>(0,Z.jsxs)(`div`,{className:`rounded-lg border border-border/80 bg-card/70 p-4 shadow-sm shadow-black/[0.02]`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`h4`,{className:`min-w-0 break-words font-mono text-sm font-semibold text-foreground`,children:e.id}),e.family&&(0,Z.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,Z.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,Z.jsx)(zt,{className:`h-3 w-3`}),_(`settings:provider.active`)]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-xs text-muted-foreground`,children:[e.baseUrl&&(0,Z.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,Z.jsx)(Bn,{className:`h-3.5 w-3.5 shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.baseUrl})]}),(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-background/60 px-2 py-1`,children:[(0,Z.jsx)(ar,{className:`h-3.5 w-3.5`}),_(`settings:provider.modelCount`,{count:e.models?.length??0})]}),(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/70 bg-background/60 px-2 py-1`,children:[(0,Z.jsx)(ri,{className:`h-3.5 w-3.5`}),_(`settings:provider.keyCount`,{count:e.apiKeys.length})]})]})]}),(0,Z.jsx)(`div`,{className:`flex gap-2 sm:justify-end`,children:(0,Z.jsx)(Y,{size:`icon`,variant:`ghost`,onClick:()=>f(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,Z.jsx)(vr,{className:`h-4 w-4 text-destructive`})})})]}),(0,Z.jsxs)(`div`,{className:`mt-4 grid gap-4 xl:grid-cols-[minmax(0,1.35fr)_minmax(280px,0.85fr)]`,children:[(0,Z.jsx)(mp,{providerId:e.id,savedPickedModelId:e.pickedModelId,savedModels:e.models,savedCustomModels:e.customModels,ws:m,onPickModel:p}),(0,Z.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-background/75 p-3 shadow-sm shadow-black/[0.02]`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-semibold`,children:_(`settings:provider.apiKeysLabel`)}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:_(`settings:provider.keyCount`,{count:e.apiKeys.length})})]}),(0,Z.jsxs)(Y,{size:`sm`,variant:`ghost`,onClick:()=>y(v===e.id?null:e.id),className:`h-8 px-2 text-xs`,children:[(0,Z.jsx)(_i,{className:`h-3.5 w-3.5`}),_(`settings:provider.addKey`)]})]}),e.apiKeys.length===0&&!v&&(0,Z.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:_(`settings:provider.noKeys`)}),e.apiKeys.length>0&&(0,Z.jsx)(`div`,{className:`mt-3 space-y-2`,children:e.apiKeys.map(t=>(0,Z.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,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,Z.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,Z.jsx)(ri,{className:`h-3.5 w-3.5`})}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate text-sm font-medium`,children:t.label}),t.isActive&&(0,Z.jsx)(`span`,{className:`rounded-full bg-success/10 px-2 py-0.5 text-[11px] font-medium text-success`,children:_(`settings:provider.active`)})]}),(0,Z.jsx)(`div`,{className:`mt-0.5`,children:(0,Z.jsx)(wf,{maskedKey:t.maskedKey})})]})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-1`,children:[!t.isActive&&(0,Z.jsx)(Y,{size:`sm`,variant:`outline`,onClick:()=>u(e.id,t.label),className:`h-8 px-2 text-xs`,children:_(`settings:provider.setActive`)}),(0,Z.jsx)(Y,{size:`icon`,variant:`ghost`,onClick:()=>l(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,Z.jsx)(vr,{className:`h-3.5 w-3.5 text-destructive`})})]})]},t.label))}),v===e.id&&(0,Z.jsxs)(`div`,{className:`mt-3 space-y-2 rounded-lg border border-border/70 bg-background p-3`,children:[(0,Z.jsx)(Ya,{placeholder:_(`settings:provider.keyLabelPlaceholder`),value:b,onChange:e=>x(e.target.value),ref:ee.setFieldRef(0),onKeyDown:e=>ee.handleKeyDown(e,0)}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(Ya,{type:w?`text`:`password`,placeholder:_(`settings:provider.apiKeyPlaceholder`),value:S,onChange:e=>C(e.target.value),ref:ee.setFieldRef(1),onKeyDown:e=>ee.handleKeyDown(e,1)}),(0,Z.jsx)(Y,{size:`icon`,variant:`ghost`,onClick:()=>T(!w),children:w?(0,Z.jsx)(ke,{className:`h-4 w-4`}):(0,Z.jsx)(Xt,{className:`h-4 w-4`})})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(Y,{size:`sm`,onClick:()=>te(e.id),disabled:!b.trim()||!S.trim(),ref:ee.setFieldRef(2),onKeyDown:t=>ee.handleKeyDown(t,2,()=>te(e.id)),children:_(`settings:provider.saveKey`)}),(0,Z.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>{y(null),x(``),C(``)},ref:ee.setFieldRef(3),onKeyDown:e=>ee.handleKeyDown(e,3),children:_(`common:action.cancel`)})]})]})]})]})]},e.id))]})]})}var vp=Object.entries({discovery:[[`explore`,`Explore`],[`search`,`Search`],[`research`,`Research`]],planning:[[`analyst`,`Analyst`],[`planner`,`Planner`],[`architect`,`Architect`],[`critic`,`Critic`],[`refactor-planner`,`Refactor Planner`]],build:[[`executor`,`Executor`],[`refactor`,`Refactor`],[`simplifier`,`Simplifier`],[`migration`,`Migration`],[`vision`,`Vision`],[`debugger`,`Debugger`],[`tracer`,`Tracer`],[`concurrency`,`Concurrency`]],verify:[[`realtime`,`Realtime`],[`resilience-engineer`,`Resilience Engineer`],[`chaos-engineer`,`Chaos Engineer`],[`verifier`,`Verifier`],[`test`,`Test`],[`e2e`,`E2E`],[`browser`,`Browser`],[`performance`,`Performance`],[`chaos`,`Chaos`],[`security-scanner`,`Security Scanner`],[`bug-hunter`,`Bug Hunter`],[`audit-log`,`Audit Log`]],review:[[`threat-modeler`,`Threat Modeler`],[`secure-coding-coach`,`Secure Coding Coach`],[`compliance-auditor`,`Compliance Auditor`],[`privacy-engineer`,`Privacy Engineer`],[`reviewer`,`Reviewer`],[`code-reviewer`,`Code Reviewer`],[`security-reviewer`,`Security Reviewer`],[`accessibility`,`Accessibility`],[`compliance`,`Compliance`]],domain:[[`android`,`Android`],[`desktop`,`Desktop`],[`distributed-systems`,`Distributed Systems`],[`database`,`Database`],[`api`,`API`],[`auth`,`Auth`],[`data`,`Data`],[`frontend`,`Frontend`],[`backend`,`Backend`],[`designer`,`Designer`],[`ios`,`iOS`],[`payments`,`Payments`],[`messaging`,`Messaging`],[`search-relevance`,`Search Relevance`],[`storage`,`Storage`],[`ml-engineer`,`ML Engineer`],[`data-governance`,`Data Governance`]],knowledge:[[`document`,`Document`],[`uml`,`UML`],[`i18n`,`I18n`],[`prompt`,`Prompt`]],delivery:[[`platform-engineer`,`Platform Engineer`],[`git`,`Git`],[`release`,`Release`],[`devops`,`DevOps`],[`observability`,`Observability`],[`dependency`,`Dependency`]],meta:[[`skill-manage`,`Skill Manager`],[`self-improving`,`Self-Improving`],[`context`,`Context`],[`cost`,`Cost`],[`tech-stack`,`Tech Stack Validator`],[`plugin-author`,`Plugin Author`],[`tool-author`,`Tool Author`],[`prompt-evaluator`,`Prompt Evaluator`],[`benchmark-engineer`,`Benchmark Engineer`],[`memory-curator`,`Memory Curator`],[`fleet-coordinator`,`Fleet Coordinator`]]}).map(([e,t])=>({phase:e,label:`${e.charAt(0).toUpperCase()}${e.slice(1)}`,roles:t.map(([e,t])=>({role:e,name:t}))})),yp=vp.map(e=>e.phase),bp=vp.flatMap(e=>[...e.roles]),xp=bp.map(e=>e.role),Sp=[`*`,...yp,...xp];function Cp(e){if(e===`*`)return`Default (*)`;let t=vp.find(t=>t.phase===e);if(t)return`Phase: ${t.label} (${t.phase})`;let n=bp.find(t=>t.role===e);return n?`${n.name} (${n.role})`:`Custom: ${e}`}var wp=[{value:``,label:`mode: inherit`},{value:`auto`,label:`mode: auto`},{value:`on`,label:`mode: on`},{value:`off`,label:`mode: off`}],Tp=[{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`}],Ep=[{value:``,label:`preserve: inherit`},{value:`on`,label:`preserve: on`},{value:`off`,label:`preserve: off`}],Dp=new Set(Sp);function Op(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 kp(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 Ap({syncPref:e,candidates:t}){let n=W(),{t:r}=H(),[i,a]=(0,X.useState)(`*`),[o,s]=(0,X.useState)(``),[c,l]=(0,X.useState)(``),[u,d]=(0,X.useState)(``),[f,p]=(0,X.useState)(``),m=(0,X.useCallback)(t=>e(`modelMatrix`,t),[e]),h=(0,X.useCallback)(()=>{let e=i.trim(),t=o.trim(),r=Op(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,X.useCallback)(e=>{let{[e]:t,...r}=n.modelMatrix;m(r)},[n.modelMatrix,m]),_=(0,X.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}`:``,...kp(n)].filter(Boolean).join(` + `)},y=Array.from(new Set([...Object.keys(n.modelMatrix),i].filter(e=>e&&!Dp.has(e)))).sort((e,t)=>e.localeCompare(t));return(0,Z.jsxs)(`div`,{className:`pt-2 border-t`,children:[(0,Z.jsxs)(`h3`,{className:`text-sm font-semibold mb-3 mt-3 flex items-center gap-2`,children:[(0,Z.jsx)(Pr,{className:`h-4 w-4 text-muted-foreground`}),r(`settings:agent.routingHeading`)]}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-[minmax(0,180px)_1fr_auto]`,children:[(0,Z.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,Z.jsx)(`option`,{value:`*`,children:Cp(`*`)}),(0,Z.jsx)(`optgroup`,{label:r(`settings:agent.routingPhasesGroup`),children:vp.map(e=>(0,Z.jsx)(`option`,{value:e.phase,children:Cp(e.phase)},e.phase))}),vp.map(e=>(0,Z.jsx)(`optgroup`,{label:r(`settings:agent.routingRolesGroup`,{label:e.label}),children:e.roles.map(e=>(0,Z.jsx)(`option`,{value:e.role,children:Cp(e.role)},e.role))},e.phase)),y.length>0?(0,Z.jsx)(`optgroup`,{label:r(`settings:agent.routingCustomGroup`),children:y.map(e=>(0,Z.jsx)(`option`,{value:e,children:Cp(e)},e))}):null]}),(0,Z.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,Z.jsx)(`option`,{value:``,children:r(`settings:agent.routingTargetEmpty`)}),Object.keys(n.fallbackProfiles).length>0&&(0,Z.jsx)(`optgroup`,{label:r(`settings:agent.routingTargetProfilesGroup`),children:Object.keys(n.fallbackProfiles).map(e=>(0,Z.jsx)(`option`,{value:e,children:e},e))}),t&&t.length>0&&(0,Z.jsx)(`optgroup`,{label:r(`settings:agent.routingTargetModelsGroup`),children:t.map(e=>(0,Z.jsxs)(`option`,{value:`${e.provider}/${e.model}`,children:[e.provider,`/`,e.model]},`${e.provider}/${e.model}`))})]}),(0,Z.jsx)(Y,{type:`button`,variant:`outline`,onClick:h,children:r(`settings:agent.routingSet`)})]}),(0,Z.jsxs)(`div`,{className:`mt-2 grid grid-cols-1 gap-2 sm:grid-cols-3`,children:[(0,Z.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:wp.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))}),(0,Z.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:Tp.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))}),(0,Z.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:Ep.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))})]}),(0,Z.jsx)(`div`,{className:`mt-3 space-y-1.5`,children:Object.keys(n.modelMatrix).length===0?(0,Z.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,Z.jsxs)(`div`,{className:`rounded-md border border-border bg-muted px-2 py-1.5 text-xs`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`w-40 shrink-0 break-words font-mono text-muted-foreground`,title:e,children:Cp(e)}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 break-words font-mono`,children:v(t)}),(0,Z.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>g(e),children:r(`common:action.remove`)})]}),(0,Z.jsxs)(`div`,{className:`mt-2 grid grid-cols-1 gap-2 sm:grid-cols-3`,children:[(0,Z.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:wp.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))}),(0,Z.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:Tp.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))}),(0,Z.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:Ep.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))})]})]},e))})]})}var jp=[`off`,`low`,`medium`,`high`,`all`],Mp={off:`bg-muted-foreground`,low:`bg-success`,medium:`bg-warning`,high:`bg-warning ring-2 ring-warning/25`,all:`bg-destructive`},Np={off:`settings:brain.riskCopy.off`,low:`settings:brain.riskCopy.low`,medium:`settings:brain.riskCopy.medium`,high:`settings:brain.riskCopy.high`,all:`settings:brain.riskCopy.all`},Pp=[`executor`,`skeptic`,`auditor`];function Fp(e){return e&&e.length>0?e.map(e=>({id:e.id,name:e.name,description:e.description})):Pp.map(e=>({id:e,name:e}))}var Ip=[{value:`default`,labelKey:`settings:brainOpt.default15s`},{value:`5000`,label:`5s`},{value:`10000`,label:`10s`},{value:`20000`,label:`20s`},{value:`30000`,label:`30s`},{value:`60000`,label:`60s`}],Lp=[{value:`off`,labelKey:`settings:brainOpt.waitForever`},{value:`30000`,label:`30s`},{value:`60000`,label:`1m`},{value:`120000`,label:`2m`},{value:`300000`,label:`5m`}],Rp=[{value:`default`,labelKey:`settings:brainOpt.defaultHalf`},{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`,labelKey:`settings:brainOpt.all`}],zp=[{value:`100`,label:`100`},{value:`200`,labelKey:`settings:brainOpt.n200Default`},{value:`400`,label:`400`},{value:`800`,label:`800`},{value:`1600`,label:`1600`}],Bp=[{value:`0`,labelKey:`settings:brainOpt.offDefault`},{value:`0.3`,label:`0.3`},{value:`0.5`,label:`0.5`},{value:`0.7`,label:`0.7`},{value:`0.9`,label:`0.9`}],Vp=[{value:`10`,label:`10`},{value:`20`,labelKey:`settings:brainOpt.n20Default`},{value:`50`,label:`50`},{value:`100`,label:`100`}],Hp=[{value:`60000`,label:`1m`},{value:`300000`,labelKey:`settings:brainOpt.m5Default`},{value:`900000`,label:`15m`},{value:`3600000`,label:`1h`}],Up=[{value:`50`,label:`50`},{value:`200`,labelKey:`settings:brainOpt.n200Default`},{value:`500`,label:`500`},{value:`1000`,label:`1000`}],Wp=[{value:`default`,labelKey:`settings:brainOpt.default`},{value:`10000`,label:`10s`},{value:`20000`,label:`20s`},{value:`30000`,label:`30s`},{value:`60000`,label:`60s`}],Gp=[{value:`default`,labelKey:`settings:brainOpt.default`},{value:`1`,labelKey:`settings:brainOpt.oneSerial`},{value:`2`,label:`2`},{value:`3`,label:`3`},{value:`5`,label:`5`}],Kp=[{value:`default`,labelKey:`settings:brainOpt.default`},{value:`500`,label:`500`},{value:`1000`,label:`1000`},{value:`2000`,label:`2000`},{value:`4000`,label:`4000`},{value:`8000`,label:`8000`}],qp=[{value:`default`,labelKey:`settings:brainOpt.default`},{value:`1`,labelKey:`settings:brainOpt.roundsOff`},{value:`2`,label:`2`},{value:`3`,label:`3`}],Jp=[{value:`default`,labelKey:`settings:brainOpt.default`},{value:`200`,label:`200`},{value:`400`,label:`400`},{value:`800`,label:`800`},{value:`1600`,label:`1600`}],Yp=[{value:`default`,labelKey:`settings:brainOpt.default500`},{value:`100`,label:`100`},{value:`500`,label:`500`},{value:`1000`,label:`1000`},{value:`5000`,label:`5000`}],Xp=[{value:`default`,labelKey:`settings:brainOpt.default10m`},{value:`120000`,label:`2m`},{value:`600000`,label:`10m`},{value:`1800000`,label:`30m`},{value:`3600000`,label:`1h`}];function Zp(e,t){return e.some(e=>e.value===t)?e:[...e,{value:t,label:t}]}function Qp(e,t){return e.map(e=>({value:e.value,label:e.labelKey?t(e.labelKey):e.label??e.value}))}function $p(e){return e===void 0?`default`:String(e)}function em({level:e}){return(0,Z.jsx)(`span`,{className:G(`inline-block h-2.5 w-2.5 rounded-full`,Mp[e])})}function tm(e){return e.provider?`${e.provider}/${e.model}`:e.model}var nm={pool:{title:`settings:brain.pickPoolTitle`,hint:`settings:brain.pickPoolHint`},voter:{title:`settings:brain.pickVoterTitle`,hint:`settings:brain.pickVoterHint`},judge:{title:`settings:brain.pickJudgeTitle`,hint:`settings:brain.pickJudgeHint`}};function rm(){let{t:e}=H(),{client:t}=ha(),[n,r]=(0,X.useState)(null),[i,a]=(0,X.useState)([]),[o,s]=(0,X.useState)(!0),[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(null),[f,p]=(0,X.useState)(null),m=ve();(0,X.useEffect)(()=>{t.send({type:`brain.status`,payload:t.withSession({})}),t.send({type:`brain.config.get`})},[t,m]),(0,X.useEffect)(()=>{let n=t.on(`brain.status`,e=>{let t=e.payload;if(t.sessionId&&m&&t.sessionId!==m)return;let n=Date.now();a(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}})),s(!1)}),i=t.on(`brain.config`,t=>{let n=t.payload;r(n.config),d(n.persisted?null:n.error??e(`settings:brain.persistError`)),l(!1),s(!1)});return()=>{n(),i()}},[t,e,m]);let h=(0,X.useCallback)(e=>{l(!0),t.send({type:`brain.config.set`,payload:t.withSession({patch:e})})},[t]),g=(0,X.useCallback)(e=>{r(t=>t&&{...t,maxAutoRisk:e}),h({maxAutoRisk:e})},[h]),_=(0,X.useMemo)(()=>n?.council.voters??[],[n]),v=(0,X.useCallback)(e=>{h({council:{voters:e.length>0?e:null}})},[h]),y=(0,X.useMemo)(()=>Fp(n?.personaCatalog),[n?.personaCatalog]),b=jp.includes(n?.maxAutoRisk??``)?n?.maxAutoRisk??`medium`:`medium`,x=(0,X.useCallback)(e=>{if(!n||!f)return;let t=`${e.provider}/${e.model}`;if(f===`pool`){h({models:[...n.models.map(tm),t]});return}if(f===`judge`){h({council:{judge:t}});return}return v([..._,{provider:e.provider,model:e.model,persona:y[_.length%y.length]?.id??`executor`}]),!0},[n,y,f,h,v,_]);return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(fd,{open:f!==null,mode:`provider-model`,title:f?e(nm[f].title):``,hint:f?e(nm[f].hint):void 0,onPick:e=>{if(e.type===`provider-model`)return x(e)},onClose:()=>p(null)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.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,Z.jsx)(lr,{className:`h-5 w-5`})}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`h3`,{className:`text-base font-semibold`,children:e(`settings:brain.heading`)}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings:brain.headingHint`)})]}),(o||c)&&(0,Z.jsx)(wt,{className:`ml-auto h-4 w-4 animate-spin text-muted-foreground`})]}),u&&(0,Z.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:u}),(0,Z.jsxs)(`div`,{className:`space-y-2 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.riskHeading`)}),(0,Z.jsx)(`div`,{className:`flex gap-2 flex-wrap`,children:jp.map(e=>(0,Z.jsxs)(Y,{variant:b===e?`default`:`outline`,size:`sm`,className:G(`gap-1.5 text-xs`,b===e&&`shadow-sm`),disabled:c,onClick:()=>g(e),children:[(0,Z.jsx)(em,{level:e}),e.toUpperCase()]},e))}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(Np[b])})]}),n&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.escalationHeading`)}),(0,Z.jsx)(Q,{label:e(`settings:brain.escalationModeLabel`),hint:e(`settings:brain.escalationModeHint`),value:n.mode,options:[{value:`interactive`,label:e(`settings:brain.optInteractive`)},{value:`headless`,label:e(`settings:brain.optHeadless`)}],onChange:e=>h({mode:e}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.escalationDecisionTimeoutLabel`),hint:e(`settings:brain.escalationDecisionTimeoutHint`),value:n.decisionTimeoutMs?String(n.decisionTimeoutMs):`default`,options:Qp(Ip,e),onChange:e=>h({decisionTimeoutMs:e==="default"?null:Number(e)}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.escalationHumanTimeoutLabel`),hint:e(`settings:brain.escalationHumanTimeoutHint`),value:n.humanTimeoutMs?String(n.humanTimeoutMs):`off`,options:Qp(Lp,e),onChange:e=>h({humanTimeoutMs:e===`off`?null:Number(e)}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.escalationTerminalPolicyLabel`),hint:e(`settings:brain.escalationTerminalPolicyHint`),value:n.terminalPolicy,options:[{value:`conservative`,label:e(`settings:brain.optConservative`)},{value:`deny-all`,label:e(`settings:brain.optDenyAll`)},{value:`continue-on-recommended`,label:e(`settings:brain.optContinueRecommended`)}],onChange:e=>h({terminalPolicy:e}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.escalationDecisionLogSizeLabel`),hint:e(`settings:brain.escalationDecisionLogSizeHint`),value:String(n.decisionLogMaxEntries),options:Qp(Zp(Vp,String(n.decisionLogMaxEntries)),e),onChange:e=>h({decisionLogMaxEntries:Number(e)}),disabled:c})]}),(0,Z.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.rulesHeading`)}),(0,Z.jsx)(wd,{variant:`outline`,className:`text-[10px]`,children:e(`settings:brain.rulesConfigured`,{count:n.rules.length})})]}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings:brain.rulesBody`)}),n.rules.length>0&&(0,Z.jsx)(`div`,{className:`space-y-1`,children:n.rules.map((t,n)=>(0,Z.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,Z.jsxs)(`span`,{className:`text-muted-foreground w-4 shrink-0`,children:[n+1,`.`]}),(0,Z.jsx)(`span`,{className:`flex-1 truncate font-mono`,children:t.id}),(0,Z.jsx)(wd,{variant:`outline`,className:`text-[10px] shrink-0`,children:t.then.action}),t.enabled===!1&&(0,Z.jsx)(wd,{variant:`outline`,className:`text-[10px] shrink-0`,children:e(`settings:brain.rulesOff`)})]},`${t.id}-${n}`))}),n.ruleErrors.length>0&&(0,Z.jsxs)(`div`,{className:`space-y-1 rounded-md border border-warning/40 bg-warning/10 px-2 py-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-warning`,children:e(`settings:brain.rulesDropped`,{count:n.ruleErrors.length})}),n.ruleErrors.map(e=>(0,Z.jsx)(`p`,{className:`text-xs text-warning`,children:e},e))]})]}),(0,Z.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.heuristicsHeading`)}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings:brain.heuristicsBody`)}),(0,Z.jsx)($,{label:e(`settings:brain.heuristicsLowRiskLabel`),hint:e(`settings:brain.heuristicsLowRiskHint`),value:n.heuristics.lowRiskAutoAnswer,onChange:()=>h({heuristics:{lowRiskAutoAnswer:!n.heuristics.lowRiskAutoAnswer}}),disabled:c}),(0,Z.jsx)($,{label:e(`settings:brain.heuristicsBlockedLabel`),hint:e(`settings:brain.heuristicsBlockedHint`),value:n.heuristics.blockedResolved,onChange:()=>h({heuristics:{blockedResolved:!n.heuristics.blockedResolved}}),disabled:c}),(0,Z.jsx)($,{label:e(`settings:brain.heuristicsDeadlockLabel`),hint:e(`settings:brain.heuristicsDeadlockHint`),value:n.heuristics.deadlockSkip,onChange:()=>h({heuristics:{deadlockSkip:!n.heuristics.deadlockSkip}}),disabled:c}),(0,Z.jsx)($,{label:e(`settings:brain.heuristicsRetryLabel`),hint:e(`settings:brain.heuristicsRetryHint`),value:n.heuristics.retryExhausted,onChange:()=>h({heuristics:{retryExhausted:!n.heuristics.retryExhausted}}),disabled:c}),(0,Z.jsx)($,{label:e(`settings:brain.heuristicsPingLabel`),hint:e(`settings:brain.heuristicsPingHint`),value:n.heuristics.continuePing,onChange:()=>h({heuristics:{continuePing:!n.heuristics.continuePing}}),disabled:c}),n.heuristics.blockedResolvedMarkers&&n.heuristics.blockedResolvedMarkers.length>0&&(0,Z.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:e(`settings:brain.heuristicsMarkers`,{markers:n.heuristics.blockedResolvedMarkers.join(`, `)})})]}),(0,Z.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.qualityHeading`)}),n.circuit&&(0,Z.jsx)(wd,{variant:n.circuit.state===`closed`?`outline`:`default`,className:`text-[10px]`,children:e(`settings:brain.qualityCircuit`,{state:n.circuit.state,count:n.circuit.consecutiveFailures})})]}),(0,Z.jsx)(Q,{label:e(`settings:brain.qualityResponseBudgetLabel`),hint:e(`settings:brain.qualityResponseBudgetHint`),value:String(n.llm.maxTokens),options:Qp(Zp(zp,String(n.llm.maxTokens)),e),onChange:e=>h({llm:{maxTokens:Number(e)}}),disabled:c}),(0,Z.jsx)($,{label:e(`settings:brain.qualityRejectLabel`),hint:e(`settings:brain.qualityRejectHint`),value:n.llm.rejectUncertain,onChange:()=>h({llm:{rejectUncertain:!n.llm.rejectUncertain}}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.qualityMinConfidenceLabel`),hint:e(`settings:brain.qualityMinConfidenceHint`),value:String(n.llm.minConfidence),options:Qp(Zp(Bp,String(n.llm.minConfidence)),e),onChange:e=>h({llm:{minConfidence:Number(e)}}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.qualityDenyTerminalLabel`),hint:e(`settings:brain.qualityDenyTerminalHint`),value:n.llm.denyIsTerminal,options:[{value:`never`,label:e(`settings:brain.optNeverDefault`)},{value:`when-decided`,label:e(`settings:brain.optWhenDecided`)},{value:`always`,label:e(`settings:brain.optAlways`)}],onChange:e=>h({llm:{denyIsTerminal:e}}),disabled:c})]}),(0,Z.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.traceHeading`)}),(0,Z.jsx)($,{label:e(`settings:brain.traceRecordLabel`),hint:e(`settings:brain.traceRecordHint`),value:n.trace.enabled,onChange:()=>h({trace:{enabled:!n.trace.enabled}}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.traceContentLabel`),hint:e(`settings:brain.traceContentHint`),value:n.trace.content,options:[{value:`full`,label:e(`settings:brain.optFullDefault`)},{value:`redacted`,label:e(`settings:brain.optRedacted`)},{value:`none`,label:e(`settings:brain.optMetadataOnly`)}],onChange:e=>h({trace:{content:e}}),disabled:c}),n.trace.path&&(0,Z.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:n.trace.path})]}),(0,Z.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.cacheHeading`)}),(0,Z.jsx)(wd,{variant:`outline`,className:`text-[10px]`,children:e(`settings:brain.cacheStats`,{hits:n.cache.hits,misses:n.cache.misses,size:n.cache.size})})]}),(0,Z.jsx)($,{label:e(`settings:brain.cacheReplayLabel`),hint:e(`settings:brain.cacheReplayHint`),value:n.cache.enabled,onChange:()=>h({cache:{enabled:!n.cache.enabled}}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.cacheLifetimeLabel`),hint:e(`settings:brain.cacheLifetimeHint`),value:String(n.cache.ttlMs),options:Qp(Zp(Hp,String(n.cache.ttlMs)),e),onChange:e=>h({cache:{ttlMs:Number(e)}}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.cacheMaxEntriesLabel`),hint:e(`settings:brain.cacheMaxEntriesHint`),value:String(n.cache.maxEntries),options:Qp(Zp(Up,String(n.cache.maxEntries)),e),onChange:e=>h({cache:{maxEntries:Number(e)}}),disabled:c})]}),(0,Z.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.monitorHeading`)}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings:brain.monitorBody`)}),(0,Z.jsx)($,{label:e(`settings:brain.monitorWatchLabel`),hint:e(`settings:brain.monitorWatchHint`),value:n.monitor.enabled!==!1,onChange:()=>h({monitor:{enabled:n.monitor.enabled===!1}}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.monitorPolicyLabel`),hint:e(`settings:brain.monitorPolicyHint`),value:n.monitor.policy??`llm`,options:[{value:`llm`,label:e(`settings:brain.optConsultBrain`)},{value:`steer`,label:e(`settings:brain.optAlwaysSteer`)},{value:`observe`,label:e(`settings:brain.optObserveOnly`)}],onChange:e=>h({monitor:{policy:e}}),disabled:c})]}),(0,Z.jsxs)(`div`,{className:`space-y-2 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.modelsHeading`)}),(0,Z.jsx)(wd,{variant:`outline`,className:`text-[10px]`,children:n.usingSessionModel?e(`settings:brain.modelsSessionBadge`):e(`settings:brain.modelsResolvedBadge`,{resolved:n.poolLabels.length,total:n.models.length})})]}),(0,Z.jsx)($,{label:e(`settings:brain.modelsUseSessionLabel`),hint:e(`settings:brain.modelsUseSessionHint`),value:n.usingSessionModel,onChange:()=>{n.usingSessionModel||h({models:null})},disabled:c}),n.models.length>0&&(0,Z.jsx)(`div`,{className:`space-y-1`,children:n.models.map((e,t)=>(0,Z.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,Z.jsxs)(`span`,{className:`text-muted-foreground w-4 shrink-0`,children:[t+1,`.`]}),(0,Z.jsx)(`span`,{className:`flex-1 truncate font-mono`,children:tm(e)}),(0,Z.jsx)(Y,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0`,disabled:c||t===0,onClick:()=>{let e=n.models.map(tm),r=e.splice(t,1)[0];r&&e.splice(t-1,0,r),h({models:e})},children:(0,Z.jsx)(ai,{className:`h-3 w-3`})}),(0,Z.jsx)(Y,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0`,disabled:c||t===n.models.length-1,onClick:()=>{let e=n.models.map(tm),r=e.splice(t,1)[0];r&&e.splice(t+1,0,r),h({models:e})},children:(0,Z.jsx)(qn,{className:`h-3 w-3`})}),(0,Z.jsx)(Y,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 text-destructive`,disabled:c,onClick:()=>{let e=n.models.map(tm).filter((e,n)=>n!==t);h({models:e.length>0?e:null})},children:(0,Z.jsx)(St,{className:`h-3 w-3`})})]},`${tm(e)}-${t}`))}),(0,Z.jsxs)(Y,{variant:`outline`,size:`sm`,className:`gap-1.5 text-xs`,disabled:c,onClick:()=>p(`pool`),children:[(0,Z.jsx)(_i,{className:`h-3.5 w-3.5`}),` `,e(`settings:brain.modelsAddModel`)]}),n.models.length>1&&(0,Z.jsx)(Q,{label:e(`settings:brain.modelsPoolStrategyLabel`),hint:e(`settings:brain.modelsPoolStrategyHint`),value:n.strategy,options:[{value:`fallback`,label:e(`settings:brain.optFallback`)},{value:`round-robin`,label:e(`settings:brain.optRoundRobin`)}],onChange:e=>h({strategy:e}),disabled:c})]}),(0,Z.jsxs)(`div`,{className:`space-y-2 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.councilHeading`)}),(0,Z.jsx)(wd,{variant:n.council.enabled?`default`:`outline`,className:`text-[10px]`,children:n.council.enabled?e(`settings:brain.councilConvened`):e(`settings:brain.councilDisabled`)})]}),(0,Z.jsx)($,{label:e(`settings:brain.councilEnableLabel`),hint:e(`settings:brain.councilEnableHint`),value:n.council.enabled,onChange:()=>h({council:{enabled:!n.council.enabled}}),disabled:c}),n.council.enabled&&n.councilLabels.length>0&&_.length===0&&(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings:brain.councilSeatsDerived`,{seats:n.councilLabels.join(`, `)})}),_.length>0&&(0,Z.jsx)(`div`,{className:`space-y-1`,children:_.map((t,n)=>(0,Z.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,Z.jsx)(`span`,{className:`flex-1 truncate font-mono`,children:tm(t)}),(0,Z.jsxs)(`select`,{value:t.persona??y[n%y.length]?.id??``,onChange:e=>v(_.map((t,r)=>r===n?{...t,persona:e.target.value}:t)),className:`h-6 rounded border bg-background px-1 text-[10px]`,title:y.find(e=>e.id===t.persona)?.description??e(`settings:brain.councilCustomLens`),children:[y.map(e=>(0,Z.jsx)(`option`,{value:e.id,children:e.name},e.id)),t.persona&&!y.some(e=>e.id===t.persona)&&(0,Z.jsx)(`option`,{value:t.persona,children:e(`settings:brain.councilCustomOption`,{persona:t.persona})})]}),(0,Z.jsx)(Y,{variant:t.veto?`default`:`outline`,size:`sm`,className:`h-6 px-1.5 text-[10px]`,disabled:c,onClick:()=>v(_.map((e,t)=>t===n?{...e,veto:!e.veto}:e)),children:e(`settings:brain.councilVeto`)}),(0,Z.jsx)(Y,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 text-destructive`,disabled:c,onClick:()=>v(_.filter((e,t)=>t!==n)),children:(0,Z.jsx)(St,{className:`h-3 w-3`})})]},`${tm(t)}-${n}`))}),(0,Z.jsxs)(Y,{variant:`outline`,size:`sm`,className:`gap-1.5 text-xs`,disabled:c,onClick:()=>p(`voter`),children:[(0,Z.jsx)(_i,{className:`h-3.5 w-3.5`}),` `,e(`settings:brain.councilAddVoter`)]}),(0,Z.jsx)(Q,{label:e(`settings:brain.councilRiskFloorLabel`),hint:e(`settings:brain.councilRiskFloorHint`),value:n.council.minRisk,options:[{value:`medium`,label:e(`settings:brain.optMediumPlus`)},{value:`high`,label:e(`settings:brain.optHighPlus`)},{value:`critical`,label:e(`settings:brain.optCriticalOnly`)}],onChange:e=>h({council:{minRisk:e}}),disabled:c}),(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3 py-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium`,children:e(`settings:brain.councilJudge`)}),(0,Z.jsx)(`div`,{className:`mt-0.5 text-xs text-muted-foreground`,children:e(`settings:brain.councilJudgeDesc`)}),!n.council.judge&&n.judgeLabel&&(0,Z.jsxs)(`div`,{className:`mt-0.5 font-mono text-xs text-muted-foreground`,children:[e(`settings:brain.councilResolved`,{model:n.judgeLabel}),n.judgeIsVoter&&(0,Z.jsx)(`span`,{className:`ml-1 font-sans text-warning`,children:e(`settings:brain.councilAlsoVoter`)})]})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`max-w-[180px] truncate font-mono text-xs`,children:n.council.judge?tm(n.council.judge):e(`settings:brain.councilAuto`)}),(0,Z.jsx)(Y,{variant:`outline`,size:`sm`,className:`h-7 text-xs`,disabled:c,onClick:()=>p(`judge`),children:e(`settings:brain.councilPick`)}),n.council.judge&&(0,Z.jsx)(Y,{variant:`ghost`,size:`sm`,className:`h-7 text-xs`,disabled:c,onClick:()=>h({council:{judge:null}}),children:e(`settings:brain.councilAutoReset`)})]})]}),(0,Z.jsx)(Q,{label:e(`settings:brain.councilQuorumLabel`),hint:e(`settings:brain.councilQuorumHint`),value:n.council.quorum===void 0?`default`:String(n.council.quorum),options:Qp(Rp,e),onChange:e=>h({council:{quorum:e==="default"?null:Number(e)}}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.councilApprovalLabel`),hint:e(`settings:brain.councilApprovalHint`),value:n.council.approval===void 0?`default`:String(n.council.approval),options:Qp(Rp,e),onChange:e=>h({council:{approval:e==="default"?null:Number(e)}}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.councilPerSeatTimeoutLabel`),hint:e(`settings:brain.councilPerSeatTimeoutHint`),value:$p(n.council.perCallTimeoutMs),options:Qp(Zp(Wp,$p(n.council.perCallTimeoutMs)),e),onChange:e=>h({council:{perCallTimeoutMs:e==="default"?null:Number(e)}}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.councilMaxConcurrencyLabel`),hint:e(`settings:brain.councilMaxConcurrencyHint`),value:$p(n.council.maxConcurrency),options:Qp(Zp(Gp,$p(n.council.maxConcurrency)),e),onChange:e=>h({council:{maxConcurrency:e==="default"?null:Number(e)}}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.councilDistinctnessLabel`),hint:e(`settings:brain.councilDistinctnessHint`),value:n.council.distinctness,options:[{value:`none`,label:e(`settings:brain.optNoneDefault`)},{value:`model`,label:e(`settings:brain.optDistinctModels`)},{value:`provider`,label:e(`settings:brain.optDistinctProviders`)}],onChange:e=>h({council:{distinctness:e}}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.councilVoterBudgetLabel`),hint:e(`settings:brain.councilVoterBudgetHint`),value:$p(n.council.voterMaxTokens),options:Qp(Zp(Kp,$p(n.council.voterMaxTokens)),e),onChange:e=>h({council:{voterMaxTokens:e==="default"?null:Number(e)}}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.councilRoundsLabel`),hint:e(`settings:brain.councilRoundsHint`),value:$p(n.council.deliberationRounds),options:Qp(Zp(qp,$p(n.council.deliberationRounds)),e),onChange:e=>h({council:{deliberationRounds:e==="default"?null:Number(e)}}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.councilJudgeBudgetLabel`),hint:e(`settings:brain.councilJudgeBudgetHint`),value:$p(n.council.judgeMaxTokens),options:Qp(Zp(Jp,$p(n.council.judgeMaxTokens)),e),onChange:e=>h({council:{judgeMaxTokens:e==="default"?null:Number(e)}}),disabled:c}),n.council.seats.length>0&&(0,Z.jsxs)(`p`,{className:`truncate text-xs text-muted-foreground`,children:[e(`settings:brain.councilSeatTemplate`),` `,n.council.seats.map(t=>t.veto?`${t.persona} (${e(`settings:brain.councilVeto`)})`:t.persona).join(`, `)]})]}),(0,Z.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border/70 bg-muted/20 p-3`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.ledgerHeading`)}),(0,Z.jsx)($,{label:e(`settings:brain.ledgerRecordLabel`),hint:e(`settings:brain.ledgerRecordHint`),value:n.ledger.enabled,onChange:()=>h({ledger:{enabled:!n.ledger.enabled}}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.ledgerAutoDenyLabel`),hint:e(`settings:brain.ledgerAutoDenyHint`),value:n.ledger.autoDenyAfterFailures===void 0?`default`:String(n.ledger.autoDenyAfterFailures),options:[{value:`default`,label:e(`settings:brain.optDefault3`)},{value:`0`,label:e(`settings:brain.optOff`)},{value:`2`,label:`2`},{value:`3`,label:`3`},{value:`5`,label:`5`}],onChange:e=>h({ledger:{autoDenyAfterFailures:e==="default"?null:Number(e)}}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.ledgerMemoryEntriesLabel`),hint:e(`settings:brain.ledgerMemoryEntriesHint`),value:$p(n.ledger.maxMemoryEntries),options:Qp(Zp(Yp,$p(n.ledger.maxMemoryEntries)),e),onChange:e=>h({ledger:{maxMemoryEntries:e==="default"?null:Number(e)}}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.ledgerRetryWindowLabel`),hint:e(`settings:brain.ledgerRetryWindowHint`),value:$p(n.ledger.interventionRetryWindowMs),options:Qp(Zp(Xp,$p(n.ledger.interventionRetryWindowMs)),e),onChange:e=>h({ledger:{interventionRetryWindowMs:e==="default"?null:Number(e)}}),disabled:c}),n.ledger.path&&(0,Z.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:n.ledger.path})]})]}),(0,Z.jsxs)(`div`,{className:`space-y-2 rounded-md border border-border/70 bg-card/70 p-3`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings:brain.recentHeading`,{count:i.length})}),(0,Z.jsx)(`div`,{className:`space-y-1 max-h-[300px] overflow-y-auto`,children:i.length===0?(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground py-2`,children:e(`settings:brain.recentEmpty`)}):i.map(e=>(0,Z.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,Z.jsx)(`span`,{className:`text-muted-foreground shrink-0 w-8`,children:e.age}),(0,Z.jsx)(wd,{variant:`outline`,className:`text-[10px] shrink-0`,children:e.kind}),(0,Z.jsx)(`span`,{className:`flex-1 truncate`,children:e.question}),e.outcome&&(0,Z.jsx)(`span`,{className:`text-muted-foreground shrink-0 italic`,children:e.outcome})]},`${e.age}-${e.kind}-${e.question.slice(0,32)}`))})]})]})}function im(){let{t:e}=H();return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Xt,{className:`h-5 w-5 text-info`}),(0,Z.jsx)(`h3`,{className:`text-lg font-semibold`,children:e(`activity:shadow.shadowAgent`)})]}),(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`activity:shadow.theShadowAgentMonitorsAllFleet`)}),(0,Z.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Start and stop it from the chat with`,` `,(0,Z.jsx)(`code`,{className:`font-mono text-xs`,children:`/shadow start`}),` and`,` `,(0,Z.jsx)(`code`,{className:`font-mono text-xs`,children:`/shadow stop`}),`. This panel cannot control it yet.`]})]})}function am({disabled:e,direct:t}){let n=e?`bg-muted-foreground`:t?`bg-success`:`bg-info`,r=e?`disabled`:t?`direct provider tool`:`lazy catalog tool`;return(0,Z.jsx)(`span`,{className:`inline-block h-2 w-2 shrink-0 rounded-full ${n}`,title:r})}function om({tool:e,onToggle:t,busy:n}){let{t:r}=H(),[i,a]=(0,X.useState)(!1);return(0,Z.jsxs)(`div`,{className:`space-y-2 rounded-md border border-border/70 bg-card/70 p-3 transition-colors hover:bg-card`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 sm:flex-row sm:items-start`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-2`,children:[(0,Z.jsx)(am,{disabled:e.disabled,direct:e.direct}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`code`,{className:`block truncate text-sm font-mono font-semibold`,title:e.name,children:e.name}),(0,Z.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1.5`,children:[(0,Z.jsx)(wd,{variant:`outline`,className:`px-1.5 text-[10px]`,children:e.permission}),(0,Z.jsx)(wd,{variant:`outline`,className:`px-1.5 text-[10px]`,children:e.mutating?`mutating`:`read-only`}),(0,Z.jsx)(wd,{variant:`outline`,className:`px-1.5 text-[10px]`,children:e.disabled?`disabled`:e.direct?`direct`:`lazy`}),(0,Z.jsx)(`span`,{className:`truncate text-[11px] text-muted-foreground`,title:e.owner,children:e.owner})]})]})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-1`,children:[(0,Z.jsxs)(Y,{variant:e.disabled?`default`:`secondary`,size:`sm`,className:`h-7 gap-1 px-2 text-xs`,onClick:t,disabled:n,children:[n?(0,Z.jsx)(wt,{className:`h-3 w-3 animate-spin`}):e.disabled?(0,Z.jsx)(ni,{className:`h-3 w-3`}):(0,Z.jsx)(Un,{className:`h-3 w-3`}),e.disabled?`Enable`:`Disable`]}),(0,Z.jsx)(`button`,{type:`button`,className:`rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,onClick:()=>a(!i),"aria-label":i?`Collapse`:`Expand`,children:(0,Z.jsx)(Ct,{className:`h-4 w-4 transition-transform ${i?`rotate-180`:``}`})})]})]}),i&&(0,Z.jsxs)(`div`,{className:`space-y-1 border-t border-border/60 pt-2 text-xs text-muted-foreground sm:ml-4`,children:[(0,Z.jsx)(`p`,{children:e.description}),e.params.length>0&&(0,Z.jsxs)(`p`,{children:[r(`activity:toolsSec.params`),` `,(0,Z.jsx)(`code`,{className:`break-all font-mono`,children:e.params.join(`, `)})]})]})]})}function sm(){let{t:e}=H(),{client:t}=ha(),[n,r]=(0,X.useState)([]),[i,a]=(0,X.useState)(!0),[o,s]=(0,X.useState)(``),[c,l]=(0,X.useState)(new Set);(0,X.useEffect)(()=>{let e=t.on(`tools.list`,e=>{let t=e.payload;r(t.tools),a(!1)}),n=e=>{if(e.type===`tool.disabled`||e.type===`tool.enabled`){let n=e.payload;l(e=>{let t=new Set(e);return t.delete(n.name),t}),n.ok?t.send({type:`tools.list`},{echoToChat:!1}):B.error(`Tool "${n.name}" ${e.type===`tool.disabled`?`disable`:`enable`} failed.`)}},i=t.on(`tool.disabled`,n),o=t.on(`tool.enabled`,n);return()=>{e(),i(),o()}},[t]),(0,X.useEffect)(()=>{t.send({type:`tools.list`},{echoToChat:!1})},[t]);let u=(0,X.useCallback)((e,n)=>{l(t=>new Set(t).add(e)),t.send({type:n?`tool.enable`:`tool.disable`,payload:{name:e}})},[t]),d=o?n.filter(e=>e.name.toLowerCase().includes(o.toLowerCase())||e.owner.toLowerCase().includes(o.toLowerCase())):n,f=n.filter(e=>!e.disabled&&e.direct).length,p=n.filter(e=>!e.disabled&&!e.direct).length,m=n.filter(e=>e.disabled).length;return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Z.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,Z.jsx)(li,{className:`h-5 w-5`})}),(0,Z.jsx)(`h3`,{className:`text-base font-semibold`,children:e(`activity:toolsSec.tools`)})]}),!i&&(0,Z.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:[f,` direct · `,p,` lazy · `,m,` disabled · `,n.length,` `,`total`]})]}),(0,Z.jsxs)(`div`,{className:`relative`,children:[(0,Z.jsx)(vn,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground`}),(0,Z.jsx)(Ya,{placeholder:e(`activity:toolsSec.filterToolsByNameOrOwner`),value:o,onChange:e=>s(e.target.value),className:`pl-8 h-9 text-sm`})]}),i?(0,Z.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground gap-2`,children:[(0,Z.jsx)(wt,{className:`h-4 w-4 animate-spin`}),e(`activity:toolsSec.loadingTools`)]}):d.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground py-4 text-center`,children:o?`No tools matching "${o}".`:`No tools registered.`}):(0,Z.jsxs)(`div`,{className:`relative overflow-hidden rounded-lg border border-border/70 bg-background/35 shadow-inner`,children:[(0,Z.jsx)(`ul`,{className:`max-h-[min(58dvh,660px)] space-y-2 overflow-y-auto p-2 pr-3 [scrollbar-gutter:stable]`,"aria-label":e(`activity:toolsSec.toolsList`),children:d.map(e=>(0,Z.jsx)(`li`,{children:(0,Z.jsx)(om,{tool:e,onToggle:()=>u(e.name,e.disabled),busy:c.has(e.name)})},e.name))}),(0,Z.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 top-0 h-4 bg-gradient-to-b from-background/90 to-transparent`}),(0,Z.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 h-8 bg-gradient-to-t from-background/95 to-transparent`})]})]})}function cm(){let{t:e}=H();return(0,Z.jsxs)(`div`,{className:`space-y-6`,children:[(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 mb-4 pb-3 border-b border-border/50`,children:[(0,Z.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,Z.jsx)(Xt,{className:`h-5 w-5`})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:e(`settings:security.brainHeading`)}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e(`settings:security.brainHint`)})]})]}),(0,Z.jsx)(rm,{})]}),(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 mb-4 pb-3 border-b border-border/50`,children:[(0,Z.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,Z.jsx)(Xt,{className:`h-5 w-5`})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:e(`settings:security.shadowHeading`)}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e(`settings:security.shadowHint`)})]})]}),(0,Z.jsx)(im,{})]}),(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 mb-4 pb-3 border-b border-border/50`,children:[(0,Z.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,Z.jsx)(Xt,{className:`h-5 w-5`})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:e(`settings:security.toolsHeading`)}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e(`settings:security.toolsHint`)})]})]}),(0,Z.jsx)(sm,{})]})]})}function lm(e,t,n,r,i){e.set({[r]:i}),t({[r]:i}),r===`contextMode`&&typeof i==`string`&&n(i)}var um=[{id:`general`,icon:(0,Z.jsx)(Jn,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.general`,descKey:`settings:tabs.generalDesc`},{id:`provider`,icon:(0,Z.jsx)(Fi,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.provider`,descKey:`settings:tabs.providerDesc`},{id:`connection`,icon:(0,Z.jsx)(Bn,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.connection`,descKey:`settings:tabs.connectionDesc`},{id:`agent`,icon:(0,Z.jsx)(jr,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.agent`,descKey:`settings:tabs.agentDesc`},{id:`execution`,icon:(0,Z.jsx)(at,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.execution`,descKey:`settings:tabs.executionDesc`},{id:`fallbacks`,icon:(0,Z.jsx)(Pr,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.fallbacks`,descKey:`settings:tabs.fallbacksDesc`},{id:`routing`,icon:(0,Z.jsx)(On,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.routing`,descKey:`settings:tabs.routingDesc`},{id:`fleet`,icon:(0,Z.jsx)(Zr,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.fleet`,descKey:`settings:tabs.fleetDesc`},{id:`integrations`,icon:(0,Z.jsx)(Nr,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.integrations`,descKey:`settings:tabs.integrationsDesc`},{id:`chimera`,icon:(0,Z.jsx)(lr,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.chimera`,descKey:`settings:tabs.chimeraDesc`},{id:`context`,icon:(0,Z.jsx)(tn,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.context`,descKey:`settings:tabs.contextDesc`},{id:`logs`,icon:(0,Z.jsx)(Oe,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.logs`,descKey:`settings:tabs.logsDesc`},{id:`security`,icon:(0,Z.jsx)(Vr,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.security`,descKey:`settings:tabs.securityDesc`},{id:`display`,icon:(0,Z.jsx)(Jn,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.display`,descKey:`settings:tabs.displayDesc`}];function dm(){let{settingsActiveTab:e,setSettingsActiveTab:t}=K(Me(e=>({settingsActiveTab:e.settingsActiveTab,setSettingsActiveTab:e.setSettingsActiveTab}))),n=Gu(`settings`),r=(0,X.useRef)(!1),[i,a]=(0,X.useState)(!1),{provider:o,model:s,setProvider:c,setModel:l,wsConnected:u}=R(Me(e=>({provider:e.provider,model:e.model,setProvider:e.setProvider,setModel:e.setModel,wsConnected:e.wsConnected}))),d=ha(),f=d.client,{updatePrefs:p,switchAutonomy:m,switchContextMode:h}=d,g=W(),{t:_}=H(),v=to(!0),y=(0,X.useCallback)((e,t)=>{lm(g,p,h,e,t)},[g,p,h]),[b,x]=(0,X.useState)([]),[S,C]=(0,X.useState)({}),[w,T]=(0,X.useState)([]),[E,D]=(0,X.useState)(!1),[O,k]=(0,X.useState)(!1),[A,j]=(0,X.useState)(!1),[M,N]=(0,X.useState)(`catalog`),[P,F]=(0,X.useState)(``),[I,L]=(0,X.useState)(!1),ee=(0,X.useCallback)(()=>{g.reset(),L(!1),window.location.reload()},[g]),te=b.find(e=>e.id===o),z=um.find(t=>t.id===e);(0,X.useEffect)(()=>{let e=e=>{if(e.type===`provider.catalog`){let t=e.payload;x(t.providers.sort((e,t)=>e.id.localeCompare(t.id))),D(!1)}},t=e=>{if(e.type===`provider.models`){let t=e.payload;C(e=>({...e,[t.provider]:t.models})),k(!1)}},n=e=>{if(e.type===`providers.saved`){let t=e.payload.providers.sort((e,t)=>e.id.localeCompare(t.id));T(t),j(!1),t.length>0&&N(`saved`)}};if(!u||!f)return;let r=f.on(`provider.catalog`,e),i=f.on(`provider.models`,t),a=f.on(`providers.saved`,n);return D(!0),j(!0),f.listProviders(),f.listSavedProviders(),()=>{r?.(),i?.(),a?.()}},[u,f]);let ne=(0,X.useCallback)(e=>{c(e),S[e]||(k(!0),d.listProviderModels?.(e))},[S,c,d]),re=(0,X.useCallback)(async e=>{if(r.current)return;let t=R.getState().model,n=R.getState().provider;if(!(!n||e===t)){r.current=!0,a(!0),l(e);try{B.info(U.t(`settings:toast.switchingTo`,{provider:n,model:e}));let r=await d.switchModel?.(n,e);r?.success?B.success(U.t(r.runActive?`settings:toast.modelSwitchedRunActive`:`settings:toast.modelSwitchedNextRequest`,{from:`${n} / ${t}`,to:`${n} / ${e}`})):(l(t),B.error(r?.message??U.t(`settings:toast.modelSwitchTimeout`)))}finally{r.current=!1,a(!1)}}},[l,d]),ie=(0,X.useCallback)((e,t,n)=>{d.addKey?.(e,t,n)},[d]),ae=(0,X.useCallback)((e,t)=>{d.deleteKey?.(e,t)},[d]),oe=(0,X.useCallback)((e,t)=>{d.setActiveKey?.(e,t)},[d]),se=(0,X.useCallback)((e,t,n,r,i,a)=>{d.addProvider?.(e,t,n,r,i,a)},[d]),ce=(0,X.useCallback)(e=>{d.removeProvider?.(e)},[d]),le=(0,X.useCallback)((e,t)=>{d.client.updateProvider({id:e,models:[t]}),e===R.getState().provider&&l(t)},[l,d.client]);return(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col bg-gradient-to-b from-background/90 via-background/60 to-background/80`,children:[(0,Z.jsxs)(`header`,{className:`flex items-center justify-between px-4 py-3 border-b border-border/60 bg-card/60 backdrop-blur-xl shrink-0 shadow-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(`span`,{className:`flex h-9 w-9 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:(0,Z.jsx)(nn,{className:`h-5 w-5`})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h1`,{className:`text-lg font-semibold bg-gradient-to-r from-foreground to-foreground/70 bg-clip-text text-transparent`,children:_(`settings:title`)}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-[11px] text-muted-foreground`,children:o&&s?`${o} / ${s}`:_(`settings:subtitle`)})]})]}),(0,Z.jsx)(Y,{variant:`ghost`,size:`icon`,onClick:()=>J(`chat`),children:(0,Z.jsx)(St,{className:`h-4 w-4`})}),(0,Z.jsx)(Y,{variant:`ghost`,size:`sm`,onClick:()=>L(!0),children:_(`settings:resetLabel`)})]}),(0,Z.jsx)(js,{className:`min-h-0 flex-1`,ref:n,children:(0,Z.jsx)(`div`,{className:`mx-auto max-w-7xl p-4 sm:p-6`,children:(0,Z.jsxs)(Ns,{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,Z.jsxs)(`div`,{className:`relative min-w-0`,children:[(0,Z.jsx)(Ps,{className:`flex h-auto w-full justify-start gap-0.5 overflow-x-auto rounded-lg border border-border/60 bg-card/60 p-1.5 shadow-sm [scrollbar-gutter:stable] lg:sticky lg:top-4 lg:flex-col lg:overflow-visible lg:rounded-xl lg:bg-card/60 lg:p-2`,children:um.map(e=>(0,Z.jsxs)(Fs,{value:e.id,className:`h-9 shrink-0 gap-2.5 rounded-md px-3 text-xs scroll-mt-2 data-[state=active]:bg-primary/10 data-[state=active]:text-primary data-[state=active]:shadow-sm lg:w-full lg:justify-start lg:px-3`,children:[(0,Z.jsx)(`span`,{className:`shrink-0`,children:e.icon}),(0,Z.jsx)(`span`,{className:`truncate`,children:_(e.labelKey)})]},e.id))}),(0,Z.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,Z.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,Z.jsxs)(`div`,{className:`min-w-0 space-y-0`,children:[z?.descKey&&(0,Z.jsxs)(`div`,{className:`mb-4 flex items-start gap-3 rounded-xl border border-border/60 bg-card/50 px-4 py-3`,children:[(0,Z.jsx)(`span`,{className:`mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary`,children:z.icon}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-semibold`,children:_(z.labelKey)}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:_(z.descKey)})]})]}),(0,Z.jsx)(Is,{value:`general`,className:`mt-0`,children:(0,Z.jsx)(jd,{})}),(0,Z.jsxs)(Is,{value:`provider`,className:`mt-0 space-y-4`,children:[(0,Z.jsx)(_p,{activeProvider:o,catalogProviders:b,isLoadingCatalog:E,savedProviders:w,isLoadingSaved:A,providerTab:M,setProviderTab:N,onSelectProvider:ne,onAddKey:ie,onDeleteKey:ae,onSetActiveKey:oe,onAddProvider:se,onRemoveProvider:ce,onPickProviderModel:le,ws:d.client,catalogQuery:P,setCatalogQuery:F}),(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:[(0,Z.jsxs)(`h3`,{className:`text-sm font-semibold mb-4 flex items-center gap-2`,children:[(0,Z.jsx)(ar,{className:`h-4 w-4 text-muted-foreground`}),_(`settings:model.heading`)]}),(0,Z.jsx)(vf,{provider:o,catalogModels:S,currentCatalogProvider:te,isLoadingModels:O,setIsLoadingModels:k,onModelSelect:re,isSwitching:i,refreshModels:e=>d.listProviderModels?.(e)}),(0,Z.jsx)(_f,{syncPref:y})]})]}),(0,Z.jsx)(Is,{value:`connection`,className:`mt-0`,children:(0,Z.jsx)(Ad,{})}),(0,Z.jsx)(Is,{value:`agent`,className:`mt-0 space-y-6`,children:(0,Z.jsx)(md,{syncPref:y,switchAutonomy:m})}),(0,Z.jsx)(Is,{value:`execution`,className:`mt-0 space-y-6`,children:(0,Z.jsx)(Qd,{syncPref:y,fallbackCandidates:v})}),(0,Z.jsx)(Is,{value:`fallbacks`,className:`mt-0`,children:(0,Z.jsx)(af,{syncPref:y,candidates:v,provider:o,activeModel:s,setProvider:c,setModel:l,switchModel:d.switchModel})}),(0,Z.jsxs)(Is,{value:`routing`,className:`mt-0`,children:[(0,Z.jsx)(Ap,{syncPref:y,candidates:v}),(0,Z.jsx)(`div`,{className:`mt-6 border-t border-border pt-6`,children:(0,Z.jsx)(xf,{syncPref:y})})]}),(0,Z.jsx)(Is,{value:`fleet`,className:`mt-0`,children:(0,Z.jsx)(of,{syncPref:y})}),(0,Z.jsx)(Is,{value:`integrations`,className:`mt-0`,children:(0,Z.jsx)(hf,{syncPref:y})}),(0,Z.jsx)(Is,{value:`chimera`,className:`mt-0 space-y-6`,children:(0,Z.jsx)(`div`,{className:`rounded-xl border border-border/70 bg-card/80 p-5 shadow-sm`,children:(0,Z.jsx)(Md,{syncPref:y,sessionProvider:o,sessionModel:s})})}),(0,Z.jsx)(Is,{value:`context`,className:`mt-0 space-y-6`,children:(0,Z.jsx)(Rd,{syncPref:y})}),(0,Z.jsx)(Is,{value:`logs`,className:`mt-0 space-y-6`,children:(0,Z.jsx)(gf,{syncPref:y})}),(0,Z.jsx)(Is,{value:`security`,className:`mt-0`,children:(0,Z.jsx)(cm,{})}),(0,Z.jsx)(Is,{value:`display`,className:`mt-0`,children:(0,Z.jsx)(Ud,{syncPref:y})})]})]})})}),(0,Z.jsx)(Ja,{open:I,onOpenChange:L,children:(0,Z.jsxs)(Ga,{showCloseButton:!1,children:[(0,Z.jsxs)(Ua,{children:[(0,Z.jsx)(Ka,{children:_(`settings:resetConfirmTitle`)}),(0,Z.jsx)(qa,{children:_(`settings:resetConfirmBody`)})]}),(0,Z.jsxs)(Wa,{className:`gap-2 sm:gap-0`,children:[(0,Z.jsx)(Y,{variant:`outline`,onClick:()=>L(!1),children:_(`settings:cancel`)}),(0,Z.jsx)(Y,{variant:`destructive`,onClick:ee,children:_(`settings:resetConfirmAction`)})]})]})})]})}var fm=(0,X.lazy)(()=>ta(()=>import(`./AnalyticsDashboard-yAGcObTd.js`).then(e=>({default:e.AnalyticsDashboard})),__vite__mapDeps([17,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,19,20,21]))),pm=(0,X.lazy)(()=>ta(()=>import(`./AgentRosterView-BXURTwLP.js`).then(e=>({default:e.AgentRosterView})),__vite__mapDeps([22,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,19,18,20,21,23,24,25,26,27,28,29,30,31,32,33]))),mm=(0,X.lazy)(()=>ta(()=>import(`./ChangesView-BgC27G9n.js`).then(e=>({default:e.ChangesView})),__vite__mapDeps([34,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,25,20,18,19,21,23,26,35,36,37,38]))),hm=(0,X.lazy)(()=>ta(()=>import(`./ChronicleDashboard-DVor6J-y.js`).then(e=>({default:e.ChronicleDashboard})),__vite__mapDeps([39,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]))),gm=(0,X.lazy)(()=>ta(()=>import(`./CodeEditor-Dk2WJQks.js`).then(e=>({default:e.CodeEditor})),__vite__mapDeps([40,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,20,18,19,21,23,35,36,37,38,41,30,32]))),_m=(0,X.lazy)(()=>ta(()=>import(`./CodeMap-CjWRQ37U.js`).then(e=>({default:e.CodeMap})),__vite__mapDeps([42,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,20,26]))),vm=(0,X.lazy)(()=>ta(()=>import(`./DebugDashboard-B-aDaDrO.js`).then(e=>({default:e.DebugDashboard})),__vite__mapDeps([43,1,2,3,4,5,6,7,8,9,10,11,12,13,14]))),ym=(0,X.lazy)(()=>ta(()=>import(`./DesignGalleryView-Ex3zW5ci.js`).then(e=>({default:e.DesignGalleryView})),__vite__mapDeps([44,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,25,20,18,19,21,23,26]))),bm=(0,X.lazy)(()=>ta(()=>import(`./GoalView-CBDc5nCD.js`).then(e=>({default:e.GoalView})),__vite__mapDeps([45,1,2,3,4,5,6,7,8,9,10,11,12,13,14,25,0,15,16,20,18,19,21,23,26,30,46,29,31]))),xm=(0,X.lazy)(()=>ta(()=>import(`./KanbanView-azjPGLmM.js`).then(e=>({default:e.KanbanView})),__vite__mapDeps([47,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,19,20,21,29,24,25,23,26,48]))),Sm=(0,X.lazy)(()=>ta(()=>import(`./MailboxDetailView-BXW9zqle.js`).then(e=>({default:e.MailboxDetailView})),__vite__mapDeps([49,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,21,23,37]))),Cm=(0,X.lazy)(()=>ta(()=>import(`./PromptJournalView-C6O40uTv.js`).then(e=>({default:e.PromptJournalView})),__vite__mapDeps([50,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]))),wm=(0,X.lazy)(()=>ta(()=>import(`./RefreshDebugView-DDFD26EI.js`).then(e=>({default:e.RefreshDebugView})),__vite__mapDeps([51,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,19]))),Tm=(0,X.lazy)(()=>ta(()=>import(`./SageTabs-Cx299O-q.js`).then(e=>({default:e.SageTabs})),__vite__mapDeps([52,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]))),Em=(0,X.lazy)(()=>ta(()=>import(`./RequirementIntakeView-BpFyFOlB.js`).then(e=>({default:e.RequirementIntakeView})),__vite__mapDeps([53,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,30,31]))),Dm=(0,X.lazy)(()=>ta(()=>import(`./SddHub-CmSlkvkM.js`).then(e=>({default:e.SddHub})),__vite__mapDeps([54,1,2,3,4,5,6,7,8,9,10,11,12,13,14,25,0,15,16,20,18,19,21,23,26,29,30,24,48]))),Om=(0,X.lazy)(()=>ta(()=>import(`./SessionsDashboard-7C6Fj9pK.js`).then(e=>({default:e.SessionsDashboard})),__vite__mapDeps([55,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,25,20,18,19,21,23,26,56,46,29,30,31]))),km=(0,X.lazy)(()=>ta(()=>import(`./SessionInspectView-CtrlRlJu.js`).then(e=>({default:e.SessionInspectView})),__vite__mapDeps([57,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,25,20,18,19,21,23,26,56,46,29,30,31]))),Am=(0,X.lazy)(()=>ta(()=>import(`./SkillDetailView-C5nOcysX.js`).then(e=>({default:e.SkillDetailView})),__vite__mapDeps([58,1,2,3,4,5,6,7,8,9,10,11,12,13,14,25,0,15,16,20,18,19,21,23,26,29,37]))),jm=(0,X.lazy)(()=>ta(()=>import(`./TechStackView-DkNjeYPK.js`).then(e=>({default:e.TechStackView})),__vite__mapDeps([59,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,18,0,16,19,20,21,30,31]))),Mm=(0,X.lazy)(()=>ta(()=>import(`./DeadCodeScanPanel-CcPRcYm0.js`).then(e=>({default:e.DeadCodeScanPanel})),__vite__mapDeps([60,1,2,3,4,5,6,7,8,9,10,11,12,13,14]))),Nm=(0,X.lazy)(()=>ta(()=>import(`./ChimeraReviewsView-BZ3kmsEA.js`).then(e=>({default:e.ChimeraReviewsView})),__vite__mapDeps([61,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,37]))),Pm=(0,X.lazy)(()=>ta(()=>import(`./SetupScreen-IzaqHJ_O.js`).then(e=>({default:e.SetupScreen})),__vite__mapDeps([62,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,25,20,18,19,21,23,26,29,30,31]))),Fm={settings:{Component:dm,wrapperClassName:`flex-1 min-h-0 min-w-0 overflow-hidden`,boundaryNameKey:`activity:panels.settings`,loadingLabelKey:null},memory:{Component:Tm,wrapperClassName:``,boundaryNameKey:`activity:panels.sageMemory`,loadingLabelKey:`activity:panels.sageMemory`},roster:{Component:pm,wrapperClassName:`flex min-h-0 min-w-0 flex-1 overflow-hidden`,boundaryNameKey:`activity:panels.agentRoster`,loadingLabelKey:`activity:panels.agentRoster`},context:{Component:ud,wrapperClassName:``,boundaryNameKey:`activity:panels.contextDashboard`,loadingLabelKey:null},setup:{Component:Pm,wrapperClassName:`flex-1 min-h-0 min-w-0 overflow-hidden`,boundaryNameKey:`activity:panels.setup`,loadingLabelKey:null},goal:{Component:bm,wrapperClassName:`flex-1 min-h-0 min-w-0 overflow-hidden`,boundaryNameKey:`activity:panels.goal`,loadingLabelKey:null,props:{onClose:`PANEL_CLOSE_TO_CHAT`}},sddhub:{Component:Dm,wrapperClassName:`flex-1 min-h-0 min-w-0 overflow-hidden`,boundaryNameKey:`activity:panels.sddHub`,loadingLabelKey:null},kanban:{Component:xm,wrapperClassName:`flex-1 min-h-0 min-w-0 overflow-hidden`,boundaryNameKey:`activity:panels.kanban`,loadingLabelKey:null,props:{onClose:`PANEL_CLOSE_TO_CHAT`}},sessions:{Component:Om,wrapperClassName:`flex-1 min-h-0 min-w-0 overflow-hidden`,boundaryNameKey:`activity:panels.sessions`,loadingLabelKey:null},"session-inspect":{Component:km,wrapperClassName:`flex-1 min-h-0 min-w-0 overflow-hidden`,boundaryNameKey:`activity:panels.sessionInspect`,loadingLabelKey:`activity:panels.sessionInspect`},chronicle:{Component:hm,wrapperClassName:`flex-1 min-h-0 min-w-0 overflow-hidden`,boundaryNameKey:`activity:panels.chronicle`,loadingLabelKey:null},intake:{Component:Em,wrapperClassName:`flex-1 min-h-0 min-w-0 overflow-hidden`,boundaryNameKey:`activity:panels.requirementsIntake`,loadingLabelKey:null},prompts:{Component:Cm,wrapperClassName:`flex-1 min-h-0 min-w-0 overflow-hidden`,boundaryNameKey:`activity:nav.prompts`,loadingLabelKey:`activity:nav.prompts`},debug:{Component:vm,wrapperClassName:`flex-1 min-h-0 min-w-0 overflow-hidden`,boundaryNameKey:`activity:panels.debugDashboard`,loadingLabelKey:null},"refresh-debug":{Component:wm,wrapperClassName:`flex-1 min-h-0 min-w-0 overflow-hidden`,boundaryNameKey:`activity:panels.refreshDebug`,loadingLabelKey:`activity:panels.refreshDebug`},files:{Component:gm,wrapperClassName:`flex-1 min-h-0 min-w-0 overflow-hidden`,boundaryNameKey:`activity:panels.editor`,loadingLabelKey:`activity:panels.editor`},changes:{Component:mm,wrapperClassName:`flex-1 min-h-0 min-w-0 overflow-hidden`,boundaryNameKey:`activity:panels.changes`,loadingLabelKey:`activity:panels.changes`,props:{className:`h-full min-h-0`}},mailbox:{Component:Sm,wrapperClassName:`flex-1 min-h-0 min-w-0 overflow-hidden`,boundaryNameKey:`activity:panels.mailbox`,loadingLabelKey:null,props:{className:`h-full min-h-0`}},"design-gallery":{Component:ym,wrapperClassName:`flex-1 min-h-0 min-w-0 overflow-hidden`,boundaryNameKey:`activity:panels.designGallery`,loadingLabelKey:null,props:{className:`h-full`}},skill:{Component:Am,wrapperClassName:`flex-1 min-h-0 min-w-0 overflow-hidden`,boundaryNameKey:`activity:panels.skill`,loadingLabelKey:null,props:{className:`h-full`}},analytics:{Component:fm,wrapperClassName:`flex-1 min-h-0 min-w-0 overflow-hidden`,boundaryNameKey:`activity:panels.analytics`,loadingLabelKey:null},codemap:{Component:_m,wrapperClassName:`flex-1 min-h-0 min-w-0 overflow-hidden`,boundaryNameKey:`activity:panels.codemap`,loadingLabelKey:`activity:panels.codemap`},techstack:{Component:jm,wrapperClassName:`flex-1 min-h-0 min-w-0 overflow-hidden`,boundaryNameKey:`activity:panels.techstack`,loadingLabelKey:`activity:panels.techstack`},deadcode:{Component:Mm,wrapperClassName:`flex-1 min-h-0 min-w-0 overflow-y-auto`,boundaryNameKey:`activity:panels.deadcode`,loadingLabelKey:`activity:panels.deadcode`},chimera:{Component:Nm,wrapperClassName:`flex-1 min-h-0 min-w-0 overflow-hidden`,boundaryNameKey:`activity:nav.chimera`,loadingLabelKey:null}};function Im({view:e,onCloseToChat:t}){let{t:n}=H(),r=Fm[e];if(!r)return null;let i=r.Component,a={...r.props??{}};for(let[e,n]of Object.entries(a))n===`PANEL_CLOSE_TO_CHAT`&&(a[e]=t);let o=r.wrapperClassName?(0,Z.jsx)(`div`,{className:r.wrapperClassName,children:(0,Z.jsx)(i,{...a})}):(0,Z.jsx)(i,{...a}),s=r.loadingLabelKey?(0,Z.jsx)(Wu,{label:n(`common:loadingNamed`,{name:n(r.loadingLabelKey)})}):(0,Z.jsx)(Wu,{});return(0,Z.jsx)(Os,{level:`panel`,name:n(r.boundaryNameKey),children:(0,Z.jsx)(X.Suspense,{fallback:s,children:o})})}function Lm(){J(`chat`)}function Rm(e){try{return new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}catch{return e}}function zm(e){switch(e){case`active`:return`text-success border-success/30 bg-success/[0.06]`;case`injected`:return`text-primary border-primary/30 bg-primary/[0.06]`;case`exited`:return`text-muted-foreground border-border/40 bg-muted/20`;default:return`text-muted-foreground border-border/40 bg-muted/20`}}function Bm(e){switch(e){case`fact`:return`text-primary`;case`decision`:return`text-accent2`;case`convention`:return`text-ring`;case`warning`:case`anti_pattern`:return`text-warning`;case`bug_root_cause`:return`text-destructive`;case`preference`:return`text-accent`;default:return`text-muted-foreground`}}function Vm(e){return e>=.9?`crit`:e>=.6?`high`:e>=.3?`med`:`low`}var Hm=(0,X.memo)(function({open:e,onClose:t}){let{t:n}=H(),r=fa(e=>e.traces),i=fa(e=>e.contextMemories),a=fa(e=>e.transitions),o=fa(e=>e.clear);(0,X.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t]);let s=r[0],c=Object.values(i),l=c.filter(e=>e.state!==`exited`),u=c.length-l.length,d=s?Object.values(s.rejected).reduce((e,t)=>e+t,0):0;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:G(`fixed inset-0 z-40 bg-background/50 backdrop-blur-[1px] transition-opacity duration-200`,e?`opacity-100`:`pointer-events-none opacity-0`),onClick:t,"aria-hidden":!0}),(0,Z.jsx)(`aside`,{className:G(`fixed right-0 top-0 z-50 h-full w-full max-w-md border-l border-border/60 bg-card/95 backdrop-blur-xl shadow-2xl`,`transition-transform duration-300 ease-out`,e?`translate-x-0`:`translate-x-full`),role:`dialog`,"aria-label":n(`activity:sageMemory.injectedHeading`,`Memory Context`),"data-testid":`memory-injector-panel`,children:(0,Z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/60 px-4 py-3 shrink-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(lr,{className:`size-4 text-primary`}),(0,Z.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:n(`activity:sageMemory.injectedHeading`,`Memory Context`)}),l.length>0&&(0,Z.jsxs)(`span`,{className:`rounded-full bg-primary/10 px-2 py-0.5 text-[10px] font-bold text-primary tabular-nums`,children:[l.length,` active`]})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[r.length>0&&(0,Z.jsx)(`button`,{type:`button`,onClick:o,className:`rounded-md px-2 py-1 text-[10px] text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-colors`,title:n(`activity:memoryManager.clearTracesTitle`),children:`Clear`}),(0,Z.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-md p-1.5 text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-colors`,title:n(`activity:memoryManager.closePanelTitle`),children:(0,Z.jsx)(zn,{className:`size-4`})})]})]}),s&&(0,Z.jsxs)(`div`,{className:`shrink-0 border-b border-border/40 bg-muted/20 px-4 py-2`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1 text-[11px] tabular-nums`,children:[(0,Z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Z.jsx)(Ge,{className:`size-3 text-muted-foreground`}),(0,Z.jsx)(`span`,{className:`font-mono text-foreground`,children:s.candidates}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:n(`activity:memoryManager.traceMatched`)})]}),(0,Z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Z.jsx)(`span`,{className:`font-mono text-success`,children:s.injected.length}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:n(`activity:memoryManager.traceInjected`)})]}),(0,Z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Z.jsx)(`span`,{className:`font-mono text-warning`,children:d}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:n(`activity:memoryManager.traceFiltered`)})]}),(0,Z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Z.jsx)(`span`,{className:`font-mono text-ring`,children:l.length}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:n(`activity:memoryManager.traceActive`)})]}),u>0&&(0,Z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Z.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:u}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:n(`activity:memoryManager.traceExited`)})]})]}),(0,Z.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-[10px] text-muted-foreground/80`,children:[(0,Z.jsx)(He,{className:`size-3`}),(0,Z.jsx)(`span`,{children:Rm(s.at)}),(0,Z.jsx)(`span`,{className:`opacity-40`,children:`·`}),(0,Z.jsx)(`span`,{className:`font-mono`,children:s.trigger}),s.toolName&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`opacity-40`,children:`·`}),(0,Z.jsx)(`span`,{className:`font-mono`,children:s.toolName})]}),(0,Z.jsx)(`span`,{className:`opacity-40`,children:`·`}),(0,Z.jsxs)(`span`,{children:[`ctx `,Math.round(s.contextPressure*100),`%`]})]})]}),(0,Z.jsxs)(`div`,{className:`flex-1 overflow-y-auto overscroll-contain`,children:[l.length>0?(0,Z.jsxs)(`div`,{className:`space-y-0`,children:[(0,Z.jsx)(`div`,{className:`sticky top-0 z-10 bg-card/95 backdrop-blur-sm px-4 py-2 text-[10px] font-bold uppercase tracking-wider text-muted-foreground border-b border-border/40`,children:n(`activity:memoryManager.injectorActiveInContext`)}),l.map(e=>(0,Z.jsxs)(`div`,{className:`border-b border-border/30 px-4 py-3 hover:bg-muted/15 transition-colors`,children:[(0,Z.jsx)(`div`,{className:`flex items-start gap-2`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 shrink-0`,children:[(0,Z.jsx)(`span`,{className:G(`rounded border px-1 py-0.5 text-[9px] font-bold uppercase`,Bm(e.kind)),children:e.kind}),(0,Z.jsx)(`span`,{className:G(`rounded border px-1 py-0.5 text-[9px] font-bold uppercase`,zm(e.state)),children:Vm(e.importance)})]})}),(0,Z.jsx)(`p`,{className:`mt-1.5 text-[12px] leading-relaxed text-foreground/90 break-words`,children:e.isPlaceholder?(0,Z.jsx)(`span`,{className:`italic text-muted-foreground`,children:e.text}):e.text}),(0,Z.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-0.5 text-[10px] text-muted-foreground/70`,children:[(0,Z.jsxs)(`span`,{className:`font-mono`,children:[e.id.slice(0,16),`…`]}),(0,Z.jsxs)(`span`,{className:`flex items-center gap-0.5`,children:[(0,Z.jsx)(`span`,{className:`opacity-60`,children:n(`activity:memoryManager.traceScore`)}),(0,Z.jsx)(`span`,{className:`font-mono text-foreground/60`,children:e.score.toFixed(2)})]}),e.trigger&&(0,Z.jsx)(`span`,{className:`font-mono`,children:e.trigger}),(0,Z.jsx)(`span`,{children:Rm(e.lastSeenAt)})]}),e.tags.length>0&&(0,Z.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1`,children:[(0,Z.jsx)(Vn,{className:`size-2.5 text-muted-foreground/50`}),e.tags.slice(0,6).map(e=>(0,Z.jsx)(`span`,{className:`rounded bg-muted/40 px-1 py-0.5 text-[9px] text-muted-foreground/80`,children:e},e))]}),e.anchors.length>0&&(0,Z.jsxs)(`div`,{className:`mt-1 text-[10px] text-muted-foreground/60 font-mono truncate`,children:[`↳ `,e.anchors.slice(0,2).join(`, `)]})]},e.id))]}):(0,Z.jsx)(`div`,{className:`px-4 py-8 text-center text-[12px] text-muted-foreground/60`,children:r.length===0?`No memory injections yet. Memories will appear here when the agent reads files or searches code.`:`No memories currently active in provider context.`}),r.length>0&&(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`sticky top-0 z-10 bg-card/95 backdrop-blur-sm px-4 py-2 text-[10px] font-bold uppercase tracking-wider text-muted-foreground border-t border-border/40 border-b`,children:n(`activity:memoryManager.injectorInjectionHistory`)}),r.slice(0,20).map(e=>{let t=Object.values(e.rejected).reduce((e,t)=>e+t,0);return(0,Z.jsxs)(`div`,{className:`border-b border-border/30 px-4 py-2.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] tabular-nums`,children:[(0,Z.jsx)(He,{className:`size-3 text-muted-foreground/60`}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:Rm(e.at)}),(0,Z.jsx)(`span`,{className:`opacity-30`,children:`·`}),(0,Z.jsx)(`span`,{className:`font-mono text-foreground/80`,children:e.trigger}),e.toolName&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`opacity-30`,children:`·`}),(0,Z.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:e.toolName})]})]}),(0,Z.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-3 text-[10px] tabular-nums text-muted-foreground/70`,children:[(0,Z.jsxs)(`span`,{className:`text-success`,children:[e.injected.length,` injected`]}),(0,Z.jsxs)(`span`,{className:`text-warning`,children:[t,` filtered`]}),(0,Z.jsxs)(`span`,{children:[e.candidates,` candidates`]}),(0,Z.jsxs)(`span`,{children:[`ctx `,Math.round(e.contextPressure*100),`%`]}),e.outcome===`error`&&(0,Z.jsx)(`span`,{className:`text-destructive`,children:n(`activity:memoryManager.traceError`)})]})]},e.runId)})]}),a.length>0&&(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`sticky top-0 z-10 bg-card/95 backdrop-blur-sm px-4 py-2 text-[10px] font-bold uppercase tracking-wider text-muted-foreground border-t border-border/40 border-b`,children:n(`activity:memoryManager.injectorContextTransitions`)}),a.slice(0,15).map(e=>(0,Z.jsxs)(`div`,{className:`border-b border-border/20 px-4 py-1.5 flex items-center gap-2 text-[10px] tabular-nums`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground/60`,children:Rm(e.at)}),(0,Z.jsx)(`span`,{className:G(`rounded px-1 py-0.5 text-[9px] font-bold uppercase`,e.action===`injected`&&`bg-primary/10 text-primary`,e.action===`entered`&&`bg-success/10 text-success`,e.action===`exited`&&`bg-muted/40 text-muted-foreground`),children:e.action}),(0,Z.jsxs)(`span`,{className:`font-mono text-muted-foreground truncate`,children:[e.memoryId.slice(0,14),`…`]}),(0,Z.jsx)(`span`,{className:`text-muted-foreground/50 truncate ml-auto`,children:e.reason})]},e.id))]})]})]})})]})});function Um(e){return e.replace(/\\/g,`/`).split(`/`).pop()??e}function Wm(e){if(e.kind===`file`)return e.path;let t=e.kind===`snippet`?e.content:e.preview,n=t.split(`
|
|
84
84
|
`).slice(0,6).join(`
|
|
85
85
|
`);return`${e.path}:${e.startLine}-${e.endLine}\n${n}${t.split(`
|
|
86
86
|
`).length>6?`
|
|
@@ -95,12 +95,12 @@ AWS_REGION=us-east-1`})]}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,
|
|
|
95
95
|
`);if(i.startsWith(`/`)&&b(g)){P(),p(i),n(``),m(-1),h.current=null,x();return}let D=!1,k=A.reduce((e,t)=>e+ +(t.role===`user`),0);if(t===`btw`&&!s&&E?.isConnected&&E.supportsCapability(`context.topic-boundary`)&&k>=5){_.current=!0,y(!0);let e=new AbortController;v.current=e;try{let t=await O(g);if(e.signal.aborted)return;if(t.suggestNewContext){let n=await Xa({title:S(`chat:input.topicShiftTitle`),message:S(`chat:input.topicShiftMessage`,{reason:t.reason,topic:t.nextTopic??S(`chat:input.topicShiftUnnamed`)}),confirmLabel:S(`chat:input.topicShiftFresh`),cancelLabel:S(`chat:input.topicShiftSame`),defaultAction:`cancel`});if(e.signal.aborted||n===`dismiss`)return;D=n===`confirm`}}catch{}finally{_.current=!1,y(!1),v.current===e&&(v.current=null)}}P(),n(``),m(-1),h.current=null,x(),p(i);let j=a.current,R=j.map(e=>({id:e.id,kind:`image`,dataUrl:e.dataUrl,mediaType:e.mediaType,bytes:e.bytes,name:e.name}));if(t===`queue`){u(g,`queue`,j.length>0?j:void 0),o();return}let ne=t===`steer`&&s;if(t===`btw`&&s){if(j.length>0){u(g,`queue`,j),o();return}if(E?.isConnected){let e=!1;try{T({type:`btw`,to:`leader`,subject:`btw from WebUI`,body:g,priority:`normal`,audience:`all`}),e=!0}catch(e){console.warn(JSON.stringify({level:`warn`,event:`ws_btw_send_failed`,reason:`send_error`,error:$i(e),timestamp:new Date().toISOString()}))}u(g,`btw`,void 0,e)}else console.warn(JSON.stringify({level:`warn`,event:`ws_btw_send_failed`,reason:`not_connected`,timestamp:new Date().toISOString()})),u(g,`btw`);o();return}ne&&w();try{if(E?.isConnected){if(f&&j.length===0){let e=te?z[te]?.[0]:void 0,t=e?.indexOf(`/`)??-1,n=e?t>0?e.slice(0,t):F:L||F,i=e?t>0?e.slice(t+1):e:ee||I;re({original:g,refined:g,english:g,status:`countdown`,resolve:e=>{},provider:n,model:i,...r?{sessionId:r}:{},...D?{freshContext:!0}:{}})}else{let e=j.length>0?_a(j):void 0,t=D?C(g,e,!0):C(g,e);if(!t){B.error(S(`chat:input.notConnectedDraftKept`));return}l({id:t,role:`user`,content:g,...R.length>0?{attachments:R}:{}}),c(!0),o()}}else n(g),B.error(S(`chat:input.notConnectedDraftKept`)),console.warn(JSON.stringify({level:`warn`,event:`ws_send_failed`,reason:`not_connected`,timestamp:new Date().toISOString()}))}catch(e){console.warn(JSON.stringify({level:`warn`,event:`ws_send_error`,error:$i(e),timestamp:new Date().toISOString()})),c(!1)}},[e,N,s,u,E,C,w,T,f,re,l,c,b,p,x,ie,o,a,F,I,S,A,O,P,M,z,te,L,ee,r,n,m,h,v,_,y]);return{sendMsg:ae,submitWith:oe,handleSubmit:(0,X.useCallback)(e=>{e.preventDefault(),oe(`btw`)},[oe]),handleBtw:(0,X.useCallback)(()=>{oe(`btw`)},[oe]),handleSteer:(0,X.useCallback)(()=>{oe(`steer`)},[oe]),handleAddQueue:(0,X.useCallback)(()=>{oe(`queue`)},[oe]),handleAbort:(0,X.useCallback)(()=>{w(),c(!1)},[w,c]),handleStopAndEdit:(0,X.useCallback)(()=>{w(),c(!1);let e=q.getState().messages;for(let t=e.length-1;t>=0;t--){let r=k(e[t]);if(r.role===`user`&&r.content){n(r.content),requestAnimationFrame(()=>{let e=i.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,200)}px`,e.focus(),e.setSelectionRange(r.content.length,r.content.length))});return}}},[w,c,n,i])}}var Eh=[{lang:`typescript`,patterns:[{regex:/:\s*(string|number|boolean|void|never|any|unknown|Promise|Array|Record|Map|Set)\b/,weight:4},{regex:/\b(interface|type|enum|namespace|implements|extends|as|satisfies|infer)\b/,weight:3},{regex:/\b(import|export)\s+/,weight:3},{regex:/\b(const|let|var)\s+\w+\s*[:=]/,weight:2},{regex:/=>/,weight:1},{regex:/\.tsx?['"]/,weight:2}]},{lang:`javascript`,patterns:[{regex:/\b(import|export|require)\s*[({]/,weight:3},{regex:/\b(const|let|var)\s+\w+\s*=\s*require/,weight:2},{regex:/\bmodule\.exports/,weight:3},{regex:/\.jsx?['"]/,weight:2}]},{lang:`python`,patterns:[{regex:/^\s*def\s+\w+\s*\(/,weight:4},{regex:/^\s*class\s+\w+.*:/,weight:3},{regex:/\bimport\s+\w+/,weight:2},{regex:/\bfrom\s+\w+\s+import/,weight:3},{regex:/\bprint\(/,weight:1},{regex:/\bself\./,weight:2},{regex:/if\s+__name__\s*==\s*['"]__main__['"]/,weight:4}]},{lang:`rust`,patterns:[{regex:/\bfn\s+\w+\s*[<(]/,weight:4},{regex:/\blet\s+mut\s/,weight:3},{regex:/\b(struct|enum|impl|trait|mod)\s+\w+/,weight:3},{regex:/\bpub\s+(fn|struct|enum)/,weight:3},{regex:/->\s*\w+/,weight:1},{regex:/::\w+/,weight:1}]},{lang:`go`,patterns:[{regex:/\bfunc\s+\w+\s*\(/,weight:4},{regex:/\bpackage\s+\w+/,weight:4},{regex:/\bimport\s*\(/,weight:3},{regex:/\b(err|nil)\b/,weight:2},{regex:/:=/,weight:2},{regex:/\bdefer\s/,weight:2}]},{lang:`json`,patterns:[{regex:/^\s*[{[]/,weight:3},{regex:/"[^"]+"\s*:\s*/,weight:3},{regex:/^\s*[}\]]\s*$/,weight:1}]},{lang:`yaml`,patterns:[{regex:/^---\s*$/,weight:4},{regex:/^\s*\w[\w.-]*:\s/,weight:2},{regex:/^\s*-\s+\w/,weight:1}]},{lang:`html`,patterns:[{regex:/<(!DOCTYPE|html|head|body|div|span|a|p|ul|li|table)/i,weight:4},{regex:/<\/?\w+[\s>]/,weight:2},{regex:/\b(class|id|href|src)="/,weight:2}]},{lang:`css`,patterns:[{regex:/[{]\s*$/,weight:1},{regex:/^\s*[.#@]\S+\s*[{]/,weight:3},{regex:/\b(\d+px|\d+em|\d+rem|\d+vh|\d+vw)\b/,weight:3},{regex:/:\s*\w+\s*!important/,weight:3},{regex:/@(media|keyframes|import|apply)/,weight:3}]},{lang:`sql`,patterns:[{regex:/\b(SELECT|INSERT|UPDATE|DELETE|CREATE TABLE|ALTER TABLE|DROP TABLE)\b/i,weight:4},{regex:/\bFROM\s+\w+/i,weight:2},{regex:/\bWHERE\s+/i,weight:2},{regex:/\b(JOIN|INNER JOIN|LEFT JOIN)\b/i,weight:2}]},{lang:`bash`,patterns:[{regex:/^#!\/.*(bash|sh|zsh)/,weight:5},{regex:/\becho\s/,weight:2},{regex:/\bexport\s+\w+=/,weight:2},{regex:/\bif\s+\[\[?\s/,weight:2},{regex:/\$\{?\w+/,weight:1},{regex:/&&|\|\|/,weight:1}]},{lang:`toml`,patterns:[{regex:/^\s*\[.*\]\s*$/,weight:3},{regex:/^\s*\w+\s*=\s*['"]/,weight:2},{regex:/^\s*\[\[.*\]\]\s*$/,weight:3}]}],Dh=6,Oh=3,kh=180;function Ah(e){let t=e.split(`
|
|
96
96
|
`);if(t.length<Oh)return!1;let n=0,r=0;for(let e of t){let t=e.trim();t.length!==0&&(t.length>kh&&r++,/^ {2,}/.test(e)&&n++,/[.!?]$/.test(t)&&r++,/[{}();=<>[\]]/.test(t)&&n++,/[#$]/.test(t)&&!/^# /.test(t)&&n++)}return n>=r&&n>=2}function jh(e){if(!Ah(e))return null;let t={};for(let n of Eh){let r=0;for(let{regex:t,weight:i}of n.patterns){let n=e.match(new RegExp(t.source,t.flags.includes(`g`)?t.flags:`${t.flags}g`));n&&(r+=n.length*i)}r>0&&(t[n.lang]=r)}t.javascript&&t.typescript&&(t.typescript>=t.javascript?delete t.javascript:t.javascript>t.typescript&&delete t.typescript);let n=null,r=0;for(let[e,i]of Object.entries(t))i>r&&(r=i,n=e);return r>=Dh?n:null}function Mh(e){let t=e.trim();return/^```[\s\S]*```\s*$/.test(t)}function Nh(e){if(Mh(e))return null;let t=jh(e);return t?{fenced:`\`\`\`${t}\n${e}\n\`\`\``,lang:t}:null}function Ph({input:e,textareaRef:t,setInput:n,errorText:r}){let[i,a]=(0,X.useState)(null),[o,s]=(0,X.useState)(!1),c=(0,X.useRef)(K.getState().draftImages),[l,u]=(0,X.useState)(()=>K.getState().draftImages),d=e=>{c.current=e,u(e),K.getState().setDraftImages(e)},f=(0,X.useRef)(r);f.current=r;let p=async e=>{let t=f.current;for(let n of e){if(c.current.length>=8){B.error(t.tooManyImages(8));return}try{let e=await va(n);d([...c.current,e])}catch(e){e instanceof ya&&e.reason===`too_large`?B.error(t.imageTooLarge(n.name||`image`)):B.error(t.imageProcessFailed(n.name||`image`))}}};return(0,X.useEffect)(()=>{let e=t.current;if(!e)return;let n=e=>{let t=e.clipboardData?.items;if(!t)return;let n=[];for(let e of t)if(e.type.startsWith(`image/`)){let t=e.getAsFile();t&&n.push(t)}n.length!==0&&(e.preventDefault(),p(n))};return e.addEventListener(`paste`,n),()=>e.removeEventListener(`paste`,n)},[t]),{draggingOver:o,onDragEnter:e=>{!e.dataTransfer||!Array.from(e.dataTransfer.types).includes(`Files`)||(e.preventDefault(),s(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||s(!1)},onDragOver:e=>{!e.dataTransfer||!Array.from(e.dataTransfer.types).includes(`Files`)||(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)},onDrop:e=>{if(!e.dataTransfer)return;let t=Array.from(e.dataTransfer.files??[]);if(t.length===0){s(!1);return}e.preventDefault(),s(!1);let n=t.filter(e=>e.type?.startsWith(`image/`));n.length>0&&p(n);let r=t.filter(e=>!e.type?.startsWith(`image/`));if(r.length===0)return;let i=r.map(e=>e.name).join(`, `);B.info(`Dropped file(s): ${i} — use @ in chat to pick the correct project path.`)},onTextPaste:r=>{let i=r.clipboardData?.getData(`text`)??``;if(!i)return;let o=Nh(i);if(o){r.preventDefault();let s=t.current;if(!s)return;let c=s.selectionStart,l=s.selectionEnd,u=e.slice(0,c),d=e.slice(l),f=o.fenced;n(u+f+d);let p=i.split(`
|
|
97
97
|
`).length;a({chars:i.length,lines:p,lang:o.lang,undoFence:()=>{n(u+i+d),a(null),requestAnimationFrame(()=>{s&&(s.focus(),s.style.height=`auto`,s.style.height=`${Math.min(s.scrollHeight,200)}px`)})}}),setTimeout(()=>a(null),6e3),requestAnimationFrame(()=>{s.style.height=`auto`,s.style.height=`${Math.min(s.scrollHeight,200)}px`;let e=u.length+f.length;s.setSelectionRange(e,e)});return}if(i.length>800){let e=i.split(`
|
|
98
|
-
`).length;a({chars:i.length,lines:e}),setTimeout(()=>a(null),4e3)}},pasteHint:i,pendingImagesRef:c,pendingImages:l,addImageFiles:p,removeImage:e=>{d(c.current.filter(t=>t.id!==e))},clearPendingImages:()=>d([]),setPendingImages:d,setPasteHint:a}}function Fh({clientConnected:e,t,sendMessage:n,setInput:r}){let i=K(e=>e.refinePanel),a=K(e=>e.setRefinePanel),o=q(e=>e.enqueue),s=q(e=>e.addMessage),c=q(e=>e.setLoading);(0,X.useEffect)(()=>{if(!i||(i.status??`refining`)!==`refining`)return;let l=i.retried?21e4:105e3,u=setTimeout(()=>{let i=K.getState().refinePanel;if(!(!i||(i.status??`refining`)!==`refining`)){if(a(null),B.info(t(`chat:input.refineTimeoutFallback`)),i.mode!==void 0&&q.getState().isLoading){let e=i.images,t=e&&e.length>0&&i.mode===`btw`?`queue`:i.mode;o(i.original,t,e);return}e?(s({role:`user`,content:i.original}),c(!0),i.freshContext===!0?n(i.original,void 0,!0):n(i.original)):(r(i.original),B.error(t(`chat:input.notConnectedDraftKept`)))}},l);return()=>clearTimeout(u)},[i,e,s,c,n,a,o,r,t])}function Ih({onTranscript:e}){let[t,n]=(0,X.useState)(!1),[r,i]=(0,X.useState)(!1),a=(0,X.useRef)(null);return(0,X.useEffect)(()=>{if(typeof window>`u`)return;let e=window.SpeechRecognition||window.webkitSpeechRecognition;i(!!e)},[]),{isListening:t,isSupported:r,toggleListening:(0,X.useCallback)(()=>{if(typeof window>`u`)return;let r=window.SpeechRecognition||window.webkitSpeechRecognition;if(r){if(t){a.current?.stop(),n(!1);return}try{let t=new r;t.continuous=!0,t.interimResults=!1,t.lang=navigator.language||`en-US`,t.onresult=t=>{let n=``;for(let e=t.resultIndex;e<t.results.length;++e){let r=t.results[e];r&&r.isFinal&&r[0]&&(n+=r[0].transcript)}n.trim()&&e(n.trim())},t.onerror=()=>{n(!1)},t.onend=()=>{n(!1)},t.start(),a.current=t,n(!0)}catch{n(!1)}}},[t,e]),stopListening:(0,X.useCallback)(()=>{a.current?.abort?.(),a.current?.stop?.(),a.current=null,n(!1)},[])}}function Lh({onOpenBreakdown:e}={}){let{isLoading:t,setLoading:n,addMessage:r,clearMessages:i}=q(Me(e=>({isLoading:e.isLoading,setLoading:e.setLoading,addMessage:e.addMessage,clearMessages:e.clearMessages}))),a=q(e=>e.messages).length>0,o=q(e=>e.queue),s=q(e=>e.enqueue),c=q(e=>e.removeQueued),l=q(e=>e.clearQueue),u=K(e=>e.setCurrentView),d=K(e=>e.setPromptLibraryOpen),f=K(e=>e.pushPrompt),p=K(e=>e.promptHistory),m=K(e=>e.promptInsertRequest),h=K(e=>e.clearPromptInsert),g=K(e=>e.setProcessMonitorOpen),_=K(e=>e.setQueuePanelOpen),v=ha(),{sendMessage:y,sendAbort:b,client:x,refineModel:S,updatePrefs:C}=v,{t:w}=H(),T=W(e=>e.enhanceEnabled),E=N(e=>e.session?.provider),D=N(e=>e.session?.model),O=R(e=>e.provider),k=R(e=>e.model),[A,j]=(0,X.useState)(()=>K.getState().draftInput??``),M=(0,X.useRef)(null),{isListening:P,isSupported:F,toggleListening:I,stopListening:L}=Ih({onTranscript:e=>{j(t=>t?`${t} ${e}`:e)}});Fh({clientConnected:x?.isConnected,t:w,sendMessage:y,setInput:j}),Ch({client:x,sendMessage:y});let ee=N(e=>e.lastInputTokens),te=N(e=>e.maxContext),[z,ne]=(0,X.useState)(null),[re,ie]=(0,X.useState)(!1),[ae,oe]=(0,X.useState)(!1),se=(0,X.useRef)(!1),ce=(0,X.useRef)(null),le=(0,X.useRef)(null),ue=ja(e=>e.refs),{removeRef:de,clearRefs:fe}=ja.getState(),{draggingOver:pe,onDragEnter:me,onDragLeave:V,onDragOver:he,onDrop:ge,onTextPaste:_e,pasteHint:ye,pendingImagesRef:be,pendingImages:xe,addImageFiles:Se,removeImage:Ce,clearPendingImages:we,setPendingImages:Te,setPasteHint:Ee}=Ph({input:A,textareaRef:le,setInput:j,errorText:{tooManyImages:e=>w(`chat:input.tooManyImages`,{max:e}),imageProcessFailed:e=>w(`chat:input.imageProcessFailed`,{name:e}),imageTooLarge:e=>w(`chat:input.imageTooLarge`,{name:e})}}),De=(0,X.useRef)(null);(0,X.useEffect)(()=>{K.getState().setDraftInput(A)},[A]),(0,X.useEffect)(()=>()=>{M.current!==null&&clearTimeout(M.current)},[]);let Oe=ve(),ke=(0,X.useCallback)(()=>{bh(Oe);let e=le.current;e&&(e.value=``,e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,200)}px`,t||e.focus())},[t,Oe]),Ae=(0,X.useCallback)(()=>{let e=!T;W.getState().set({enhanceEnabled:e}),C({enhanceEnabled:e})},[T,C]),je=(0,X.useRef)(()=>!1),{sendMsg:Ne,handleSubmit:Pe,handleBtw:Fe,handleSteer:Ie,handleAddQueue:Le,handleAbort:Re,handleStopAndEdit:ze}=Th({input:A,setInput:j,sessionId:Oe,textareaRef:le,pendingImagesRef:be,clearPendingImages:we,isLoading:t,setLoading:n,addMessage:r,enqueue:s,ws:v,enhanceEnabled:T,pushPrompt:f,setHistoryIdx:e=>Ge(e),stickyDraftRef:{get current(){return Ke.current},set current(e){Ke.current=e}},refineBackstopTimerRef:M,topicCheckBusyRef:se,topicCheckAbortRef:ce,setTopicCheckBusy:oe,runSlashCommand:e=>je.current(e),clearTextarea:ke,t:w}),Be=(0,X.useCallback)(t=>Xo({raw:t,addMessage:r,clearMessages:i,client:x,queue:o,sendAbort:b,sendMsg:Ne,setLoading:n,setCurrentView:u,toggleRefineEnabled:Ae,setProcessMonitorOpen:g,setQueuePanelOpen:_,ws:v,onOpenBreakdown:e,handleNextList:uh,handleNextSelect:e=>dh(e,Ne)}),[r,i,x,o,b,Ne,n,u,Ae,g,_,v,e]);je.current=Be;let{slashIndex:Ve,setSlashIndex:He,slashSuggestions:Ue,historyIdx:We,setHistoryIdx:Ge,stickyDraftRef:Ke,handleKeyDown:qe}=wh({input:A,setInput:j,textareaRef:le,atMention:z,promptHistory:p,runSlashCommand:Be,handleSubmit:Pe});xh({sessionId:Oe,input:A,setInput:j,pendingImages:xe,setPendingImages:Te,clearPendingImages:we,fileRefs:ue,clearRefs:fe,setHistoryIdx:Ge,stickyDraftRef:Ke,setAtMention:ne,setPasteHint:Ee,stopSpeech:L,topicCheckAbortRef:ce,topicCheckBusyRef:se,setTopicCheckBusy:oe,refineBackstopTimerRef:M,textareaRef:le}),(0,X.useEffect)(()=>{m!=null&&(j(e=>e.trim()?`${e}\n${m}`:m),h(),requestAnimationFrame(()=>le.current?.focus()))},[m,h]);let Je=()=>{let e=le.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,200)}px`)};return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(Kc,{}),ye&&(0,Z.jsx)(qm,{pasteHint:ye,onDismiss:()=>Ee(null),t:w}),(0,Z.jsx)(Jm,{pendingImages:xe,onRemove:Ce,onClearAll:we,t:w}),(0,Z.jsx)(ph,{queue:o,onClear:l,onRemove:c}),(0,Z.jsx)(_h,{enhanceEnabled:T,refinePickOpen:re,setRefinePickOpen:ie,refineModel:S,clientConnected:x?.isConnected===!0,addUserMessage:e=>r({role:`user`,content:e}),setLoading:n,sendMessage:y,isLoading:t,enqueue:s,setInput:j,resolveCancelInput:vh,notConnectedDraftKept:()=>B.error(w(`chat:input.notConnectedDraftKept`))}),(0,Z.jsx)(Xm,{sessionProvider:E,sessionModel:D,fallbackProvider:O,fallbackModel:k,onOpenPromptLibrary:()=>d(!0),onOpenModelSwitcher:()=>K.getState().setModelSwitcherOpen(!0),t:w}),(0,Z.jsx)(Ym,{fileRefs:ue,onRemove:de,onClearAll:fe,t:w}),ae&&(0,Z.jsx)(`div`,{className:`px-1 text-xs text-muted-foreground`,role:`status`,children:w(`chat:input.topicShiftChecking`)}),(0,Z.jsxs)(`form`,{onSubmit:Pe,onDragEnter:me,onDragOver:he,onDragLeave:V,onDrop:ge,"data-session-id":Oe??void 0,"data-running":t?`true`:`false`,"data-chat-started":a?`true`:`false`,"data-has-draft":A.trim()||xe.length>0?`true`:`false`,className:G(`relative flex flex-col gap-2 rounded-xl border border-border/70 bg-background/85 p-2 shadow-lg shadow-black/5 transition-colors sm:flex-row sm:items-end`,t&&`border-warning/45 bg-warning/5 shadow-warning/10`,!a&&!t&&`border-border/50 bg-card/55 shadow-none`,pe&&`ring-2 ring-primary ring-offset-2 ring-offset-background bg-primary/5`),children:[pe&&(0,Z.jsx)(`div`,{className:`absolute inset-0 z-20 flex items-center justify-center pointer-events-none rounded-lg bg-primary/10 text-primary text-sm font-medium`,children:w(`chat:input.dropOverlay`)}),(0,Z.jsxs)(`div`,{className:`relative w-full flex-1`,children:[(0,Z.jsx)(nh,{atMention:z,input:A,textareaRef:le,setInput:j,setAtMention:ne}),!z&&(0,Z.jsx)(Sh,{suggestions:Ue,selectedIndex:Ve,onSelectIndex:He,onRun:e=>{j(``),Be(e)}}),(0,Z.jsx)(`textarea`,{ref:le,"data-chat-textarea":!0,value:A,onChange:e=>{let t=e.target.value;j(t),Je(),We>=0&&(Ge(-1),Ke.current=null);let n=e.target.selectionStart??t.length;ne(Wo(t,n))},onSelect:e=>{let t=e.currentTarget;ne(Wo(t.value,t.selectionStart))},onKeyDown:qe,onPaste:_e,placeholder:x?.isConnected?w(t?`chat:inputPlaceholderLoading`:`chat:inputPlaceholder`):w(`chat:inputPlaceholderConnecting`),className:G(`flex min-h-[64px] w-full resize-none overflow-y-auto rounded-lg border border-input bg-card/80 px-4 py-3 pr-12 shadow-sm sm:min-h-[44px]`,`text-sm ring-offset-background placeholder:text-muted-foreground`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,`disabled:cursor-not-allowed disabled:opacity-50`,`scrollbar-thin`),rows:1,disabled:!x?.isConnected||ae}),(0,Z.jsx)(eh,{input:A,lastInputTokens:ee,maxContext:te})]}),(0,Z.jsx)($m,{imagePickerRef:De,disabled:!x?.isConnected||ae,topicCheckBusy:ae,clientConnected:x?.isConnected===!0,isLoading:t,chatStarted:a,input:A,pendingImages:xe,addImageFiles:Se,handleStopAndEdit:ze,handleAbort:Re,handleBtw:Fe,handleSteer:Ie,handleAddQueue:Le,updatePrefs:C,t:w,isListening:P,isSpeechSupported:F,onToggleSpeech:I})]})]})}function Rh(e){return{index:e.promptIndex,iteration:e.promptIndex,timestamp:e.ts??``,label:e.promptPreview??``,messageCount:0,tokens:0,fileCount:e.fileCount??0}}function zh({open:e,onClose:t,className:n}){let{t:r}=H(),[i,a]=(0,X.useState)([]),[o,s]=(0,X.useState)(!1),c=ha(),l=R(e=>e.wsConnected),u=(0,X.useRef)(null),d=ve();(0,X.useEffect)(()=>{if(!(!e||!l||!c.client?.isConnected))return a([]),c.client.send?.({type:`session.checkpoints`,payload:c.client.withSession({})}),u.current=c.client.on?.(`session.checkpoints`,e=>{let t=e?.payload;(t?.sessionId===void 0||d===void 0||t.sessionId===d)&&t?.checkpoints&&a(t.checkpoints.map(Rh))})??null,()=>{u.current?.()}},[e,l,c.client,d]);let f=(0,X.useCallback)(async e=>{s(!0),c.client.send?.({type:`session.rewind`,payload:c.client.withSession({checkpointIndex:e})}),setTimeout(()=>{t(),s(!1)},800)},[c.client,t]);return(0,Z.jsx)(Ja,{open:e,onOpenChange:e=>{e||t()},children:(0,Z.jsxs)(Ga,{className:G(`max-w-md gap-0 overflow-hidden border-border/80 bg-card p-0 pt-[10dvh] flex flex-col max-h-[75dvh]`,n),children:[(0,Z.jsx)(Ka,{className:`sr-only`,children:r(`activity:checkpoint.heading`)}),(0,Z.jsx)(qa,{className:`sr-only`,children:r(`activity:checkpoint.countSuffix`,{count:i.length})}),(0,Z.jsx)(`div`,{className:`flex items-center justify-between border-b border-border/70 bg-card/95 px-4 py-3 shrink-0`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,Z.jsx)(`span`,{className:`flex items-center justify-center w-8 h-8 rounded-md border border-primary/20 bg-primary/10 text-primary`,children:(0,Z.jsx)(Fn,{className:`h-4 w-4`})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h2`,{className:`text-sm font-semibold`,children:r(`activity:checkpoint.heading`)}),(0,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:r(`activity:checkpoint.countSuffix`,{count:i.length})})]})]})}),(0,Z.jsx)(`div`,{className:`border-b border-border/70 bg-muted/25 px-4 py-2.5 text-[10px] text-muted-foreground leading-relaxed`,children:r(`activity:checkpoint.description`)}),(0,Z.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:i.length===0?(0,Z.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16 gap-3 text-muted-foreground`,children:[(0,Z.jsx)(He,{className:`h-10 w-10 opacity-15`}),(0,Z.jsx)(`p`,{className:`text-sm font-medium`,children:r(`activity:checkpoint.emptyTitle`)}),(0,Z.jsx)(`p`,{className:`text-xs text-center max-w-xs`,children:r(`activity:checkpoint.emptyBody`)})]}):(0,Z.jsx)(`div`,{className:`py-1`,children:[...i].reverse().map((e,t)=>{let n=t===0;return(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>f(e.index),disabled:o,className:G(`w-full flex items-start gap-3 px-4 py-3 text-left transition-colors group`,n?`bg-primary/5 hover:bg-primary/10`:`hover:bg-accent/40`,o&&`opacity-50 pointer-events-none`),children:[(0,Z.jsxs)(`div`,{className:`flex flex-col items-center mt-1.5`,children:[(0,Z.jsx)(`div`,{className:G(`w-2.5 h-2.5 rounded-full border-2 shrink-0 transition-colors`,n?`border-primary bg-primary/20 shadow-[0_0_0_3px_hsl(var(--primary)/0.25)]`:`border-muted-foreground/30 bg-background group-hover:border-primary/40`)}),t<i.length-1&&(0,Z.jsx)(`div`,{className:`w-px flex-1 min-h-[20px] bg-border/50`})]}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsxs)(`span`,{className:`text-xs font-mono text-muted-foreground tabular-nums shrink-0`,children:[`#`,e.index]}),(0,Z.jsx)(`span`,{className:`text-xs font-medium truncate`,children:e.label}),n&&(0,Z.jsx)(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium shrink-0`,children:r(`activity:checkpoint.latest`)})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 mt-1 text-[10px] text-muted-foreground`,children:[(0,Z.jsx)(`span`,{className:`tabular-nums`,children:r(`activity:checkpoint.msgSuffix`,{count:e.messageCount})}),(0,Z.jsx)(`span`,{className:`opacity-50`,children:`·`}),(0,Z.jsxs)(`span`,{className:`tabular-nums`,children:[e.fileCount??0,` files`]}),(0,Z.jsx)(`span`,{className:`opacity-50`,children:`·`}),(0,Z.jsxs)(`span`,{className:`tabular-nums`,children:[`iter `,e.iteration]})]})]}),(0,Z.jsx)(`span`,{className:`shrink-0 mt-1.5 opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,Z.jsx)(Ae,{className:`h-4 w-4 text-primary`})})]},e.index)})})}),(0,Z.jsxs)(`div`,{className:`border-t border-border/70 bg-muted/20 px-4 py-2 text-[10px] text-muted-foreground text-center shrink-0`,children:[r(`activity:checkpoint.footerPre`),` ·`,` `,(0,Z.jsx)(`kbd`,{className:`px-1 py-0.5 rounded bg-muted font-mono text-[9px]`,children:`Esc`}),` `,r(`activity:checkpoint.footerPost`)]})]})})}function Bh(e){return!!(e?.role===`user`&&Array.isArray(e.content)&&e.content.length>0&&e.content.every(e=>e.type===`tool_result`))}function Vh(e,t){if(e[t]?.role!==`user`||Bh(e[t]))return[];let n=[];for(let r=t+1;r<e.length;r+=1){let t=e[r];if(t?.role===`user`&&!Bh(t))break;t?.role===`assistant`&&n.push(r)}return n}function Hh(e,t){return e.messageBreakdown.find(e=>e.index===t)?.pairedAssistantIndices??Vh(e.messages,t)}function Uh(e,t,n){let r=new Set(t);return e.messages.forEach((i,a)=>{if(!(i.role!==`user`||!t.has(a)&&!n.some(e=>e.messageIndex===a)))for(let t of Hh(e,a))r.add(t)}),r}function Wh(e){let t=new Map;for(let n of e){let e=`${n.messageIndex}:${n.blockIndex??`string`}`;t.set(e,[...t.get(e)??[],n])}return[...t.values()].flatMap(e=>{let t=e.sort((e,t)=>(e.start??0)-(t.start??0)),n=[];for(let e of t){let t=n.at(-1);t?.end!==void 0&&e.start!==void 0&&e.end!==void 0&&e.start<=t.end?t.end=Math.max(t.end,e.end):n.push({...e})}return n})}function Gh(e,t){if(t<=0||t>=e.length)return!1;let n=e.charCodeAt(t-1),r=e.charCodeAt(t);return n>=55296&&n<=56319&&r>=56320&&r<=57343}function Kh(e,t){if(t.start===void 0||t.end===void 0)return;let n=e[t.messageIndex];if(!n)return;if(t.blockIndex===void 0&&typeof n.content==`string`){n.content=n.content.slice(0,t.start)+n.content.slice(t.end);return}if(!Array.isArray(n.content)||t.blockIndex===void 0)return;let r=n.content[t.blockIndex];r?.type===`text`&&typeof r.text==`string`&&(r.text=r.text.slice(0,t.start)+r.text.slice(t.end))}var qh={phase:`closed`,revision:null,messages:[],readonlyContext:null,messageBreakdown:[],diagnostics:null,removeMessages:new Set,explicitRemoveMessages:new Set,removeRanges:[],validation:null,appliedResult:null,errorMessage:null},Jh=xa(((e,t)=>({...qh,open:()=>e({...qh,phase:`loading_snapshot`,removeMessages:new Set,explicitRemoveMessages:new Set}),close:()=>e({...qh}),loadSnapshot:t=>e(e=>{let n=e.phase===`applied_success`&&e.appliedResult!==null;return{phase:n?`applied_success`:`clean_snapshot`,revision:t.revision,messages:t.messages,readonlyContext:t.readonlyContext,messageBreakdown:t.messageBreakdown,diagnostics:t.diagnostics,removeMessages:new Set,explicitRemoveMessages:new Set,removeRanges:[],validation:null,appliedResult:n?e.appliedResult:null,errorMessage:null}}),toggleRemoveMessage:n=>{let r=t();if(r.phase===`validating`||r.phase===`applying`)return;let i=new Set(r.explicitRemoveMessages);if(r.messages[n]?.role===`assistant`&&r.messages.some((e,t)=>e.role===`user`&&(r.explicitRemoveMessages.has(t)||r.removeRanges.some(e=>e.messageIndex===t))&&Hh(r,t).includes(n))&&r.removeMessages.has(n))return;i.has(n)?i.delete(n):i.add(n);let a=r.removeRanges,o=Uh(r,i,a);e({removeMessages:o,explicitRemoveMessages:i,removeRanges:a,phase:o.size>0||a.length>0?`dirty`:`clean_snapshot`,validation:null})},markRangeForRemoval:n=>{let r=t();if(r.phase===`validating`||r.phase===`applying`||r.explicitRemoveMessages.has(n.messageIndex)||n.start===void 0||n.end===void 0||n.start<0||n.end<=n.start)return;let i=r.messages[n.messageIndex],a;if(n.blockIndex===void 0&&typeof i?.content==`string`)a=i.content;else if(n.blockIndex!==void 0&&Array.isArray(i?.content)){let e=i.content[n.blockIndex];e?.type===`text`&&(a=e.text)}if(a===void 0||n.end>a.length||Gh(a,n.start)||Gh(a,n.end))return;let o=Wh([...r.removeRanges,n]);e({removeMessages:Uh(r,r.explicitRemoveMessages,o),removeRanges:o,phase:`dirty`,validation:null})},clearRemovals:()=>e({removeMessages:new Set,explicitRemoveMessages:new Set,removeRanges:[],phase:`clean_snapshot`,validation:null}),beginValidation:()=>e({phase:`validating`,validation:null,errorMessage:null}),beginApply:()=>e({phase:`applying`,errorMessage:null}),setValidation:t=>e({validation:t,phase:t.conflict?`conflicted`:t.ok?`validated`:`invalid`,errorMessage:null}),setApplied:t=>e({appliedResult:t,phase:`applied_success`,removeMessages:new Set,explicitRemoveMessages:new Set,removeRanges:[],validation:null,errorMessage:null}),setError:n=>e({errorMessage:n,phase:n?`apply_failed`:t().phase}),resetToClean:()=>e({phase:`clean_snapshot`,removeMessages:new Set,explicitRemoveMessages:new Set,removeRanges:[],validation:null,errorMessage:null}),getProposedMessages:()=>{let e=t(),n=structuredClone(e.messages);for(let t of[...e.removeRanges].sort((e,t)=>(t.start??0)-(e.start??0)))Kh(n,t);return n.filter((t,n)=>!e.removeMessages.has(n))}})));function Yh(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Xh(e){let t=window.getSelection();if(!t||t.rangeCount===0||t.isCollapsed)return null;let n=t.getRangeAt(0);if(!e.contains(n.commonAncestorContainer))return null;let r=n.cloneRange();r.selectNodeContents(e),r.setEnd(n.startContainer,n.startOffset);let i=r.toString().length,a=i+n.toString().length;return a>i?{start:i,end:a}:null}function Zh(e){return e.type===`image`?e.source?.type===`base64`?`${e.source.media_type??`image`} · ${e.source.data?.length??0} base64 chars`:`URL image source`:e.type===`tool_use`?`${e.name??`tool`} · ${e.id??`unknown id`}`:e.type===`tool_result`?`tool result · ${e.tool_use_id??`unknown id`}`:e.type===`thinking`?`thinking · ${e.thinking?.length??0} chars`:e.type}function Qh({text:e,blockIndex:t,marked:n,disabled:r,onMarkRange:i}){let[a,o]=(0,X.useState)(null),s=(0,X.useRef)(null),c=(0,X.useCallback)(()=>{if(r)return;let e=s.current;e&&o(Xh(e))},[r]);return(0,X.useEffect)(()=>{o(null)},[e]),(0,Z.jsxs)(`div`,{className:G(`rounded-md border bg-background p-3`,n&&`border-destructive/40 bg-destructive/5`),children:[(0,Z.jsx)(`p`,{ref:s,className:`whitespace-pre-wrap break-words font-mono text-xs leading-relaxed text-foreground select-text`,onMouseUp:c,onKeyUp:c,tabIndex:r?-1:0,children:e||`(empty)`}),a&&(0,Z.jsx)(`button`,{type:`button`,disabled:r,className:`mt-2 rounded-md border border-destructive/30 px-2 py-1 text-[11px] font-medium text-destructive hover:bg-destructive/10 disabled:cursor-not-allowed disabled:opacity-40`,onMouseDown:e=>e.preventDefault(),onClick:()=>{i(t,a.start,a.end),window.getSelection()?.removeAllRanges(),o(null)},children:`Mark for removal`})]})}function $h({index:e,role:t,tokens:n,content:r,blockCount:i,warnings:a,markedForRemoval:o,markedRanges:s,disabled:c,onToggle:l,onMarkRange:u}){let[d,f]=(0,X.useState)(!1),p=t===`user`?`text-primary`:t===`assistant`?`text-success`:`text-muted-foreground`,m=a.length>0;return(0,Z.jsxs)(`div`,{className:G(`group flex items-start gap-3 rounded-lg border bg-card p-3 transition-colors`,o&&`border-destructive/40 bg-destructive/5 opacity-70`,!o&&`hover:border-primary/30`),children:[(0,Z.jsx)(`button`,{type:`button`,onClick:l,disabled:c,className:`mt-0.5 shrink-0 disabled:cursor-not-allowed disabled:opacity-40`,"aria-label":o?`Undo removal`:`Mark for removal`,children:o?(0,Z.jsx)(vr,{className:`h-3.5 w-3.5 text-destructive`}):(0,Z.jsx)(`div`,{className:`h-3.5 w-3.5 rounded-sm border border-border/60 group-hover:border-primary/50 transition-colors`})}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px]`,children:[i!==null&&i>0&&(0,Z.jsx)(`button`,{type:`button`,onClick:()=>f(e=>!e),className:`text-muted-foreground/60 hover:text-foreground shrink-0`,children:d?(0,Z.jsx)(Ct,{className:`h-3 w-3`}):(0,Z.jsx)(ot,{className:`h-3 w-3`})}),(0,Z.jsx)(`span`,{className:G(`font-mono font-medium`,p),children:t}),(0,Z.jsxs)(`span`,{className:`text-muted-foreground/60 tabular-nums`,children:[Yh(n),` tok`]}),i!==null&&i>0&&(0,Z.jsxs)(`span`,{className:`text-muted-foreground/50 tabular-nums`,children:[i,` blk`]}),m&&(0,Z.jsx)(Kr,{className:`h-3 w-3 text-warning shrink-0`})]}),(0,Z.jsx)(`div`,{className:`mt-3 space-y-2`,children:typeof r==`string`?(0,Z.jsx)(Qh,{text:r,marked:s.some(e=>e.blockIndex===void 0),disabled:c,onMarkRange:u}):r.map((t,n)=>(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between text-[10px] text-muted-foreground`,children:[(0,Z.jsx)(`span`,{className:`font-mono`,children:t.type}),typeof t.text==`string`&&(0,Z.jsxs)(`span`,{children:[Yh(Math.ceil(t.text.length/4)),` tok`]})]}),t.type===`text`&&typeof t.text==`string`?(0,Z.jsx)(Qh,{text:t.text,blockIndex:n,marked:s.some(e=>e.blockIndex===n),disabled:c,onMarkRange:u}):(0,Z.jsx)(`div`,{className:`rounded-md border bg-muted/20 p-3 font-mono text-[11px] text-muted-foreground`,children:Zh(t)})]},`${e}-${n}`))}),d&&m&&(0,Z.jsx)(`div`,{className:`mt-2 space-y-1`,children:a.map((e,t)=>(0,Z.jsxs)(`div`,{className:G(`flex items-start gap-1 text-[10px] rounded px-1.5 py-0.5`,e.severity===`danger`?`bg-destructive/10 text-destructive`:e.severity===`warning`?`bg-warning/10 text-warning`:`bg-muted text-muted-foreground`),children:[(0,Z.jsx)(`span`,{className:`font-mono`,children:e.code}),(0,Z.jsx)(`span`,{className:`opacity-80`,children:e.message})]},t))})]})]})}var eg=5e3;function tg({open:e,onClose:t}){let{t:n}=H(),r=Jh(e=>e.phase),i=Jh(e=>e.revision),a=Jh(e=>e.messageBreakdown),o=Jh(e=>e.readonlyContext),s=Jh(e=>e.messages),c=Jh(e=>e.removeMessages),l=Jh(e=>e.removeRanges),u=Jh(e=>e.validation),d=Jh(e=>e.appliedResult),f=Jh(e=>e.errorMessage),p=Jh,m=q(e=>e.isLoading),h=N(e=>e.contextLimitWarning),g=ve(),_=V()?.withSession?.({})?.sessionId??g??re()??void 0;xs(`context.editor.snapshot`,e=>{let t=e.payload;!t||typeof t.revision!=`string`||Array.isArray(t.messages)&&p.getState().loadSnapshot(t)},{sessionId:_,deps:[e,p,_]}),xs(`context.editor.validation`,e=>{p.getState().setValidation(e.payload)},{sessionId:_,deps:[e,p,_]}),xs(`context.editor.applied`,e=>{p.getState().setApplied(e.payload);let t=V();typeof t?.openContextEditor==`function`&&t.openContextEditor()},{sessionId:_,deps:[e,p,_]}),(0,X.useEffect)(()=>{if(!e){p.getState().close();return}(p.getState().phase===`closed`||p.getState().phase===`apply_failed`)&&p.getState().open();let t=V();if(!t?.send||!t?.on){p.getState().setError(U.t(`activity:context.wsNotConnected`));return}t.send({type:`context.editor.open`,payload:t.withSession({})});let n=setTimeout(()=>{p.getState().phase===`loading_snapshot`&&p.getState().setError(U.t(`activity:ctxEditor.snapshotTimedOut`))},eg);return()=>clearTimeout(n)},[e,p,_]),(0,X.useEffect)(()=>{if(!e)return;let n=e=>{if(e.key===`Escape`&&r!==`applying`&&r!==`validating`){if((c.size>0||l.length>0)&&r===`dirty`)return;t()}};return document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[e,t,r,c.size,l.length]);let v=(0,X.useCallback)(()=>{let e=V();if(!e?.send||!i)return;p.getState().beginValidation();let t=p.getState(),n=t.getProposedMessages(),r=[...[...t.removeMessages].map(e=>({messageIndex:e})),...t.removeRanges];e.validateContextEditor(i,n,r,!0)},[i,p]),y=(0,X.useCallback)(()=>{let e=V();if(!e?.send||!i)return;let t=p.getState(),n=t.getProposedMessages(),r=[...[...t.removeMessages].map(e=>({messageIndex:e})),...t.removeRanges];p.getState().beginApply(),e.applyContextEditor(i,n,r,!0)},[i,p]);if(!e)return null;let b=r===`applying`||r===`validating`,x=c.size>0||l.length>0,S=r===`validated`&&!m,C=x&&!b&&!m;return(0,Z.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-start justify-center bg-black/40 backdrop-blur-sm`,children:(0,Z.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":n(`activity:ctxEditor.contextWindowEditor`),className:`m-6 flex max-h-[calc(100dvh-3rem)] w-full max-w-4xl flex-col overflow-hidden rounded-lg border bg-card shadow-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between border-b px-4 py-3 shrink-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Cn,{className:`h-4 w-4 text-primary`}),(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`activity:ctxEditor.contextWindowEditor`)}),i&&(0,Z.jsxs)(`span`,{className:`text-[10px] font-mono text-muted-foreground/60 ml-2`,children:[`rev `,i.slice(0,8),`…`]})]}),(0,Z.jsx)(`button`,{type:`button`,onClick:t,disabled:b,className:`p-1.5 rounded-md hover:bg-accent hover:text-accent-foreground transition-colors disabled:opacity-40`,"aria-label":n(`common:action.close`),children:(0,Z.jsx)(St,{className:`h-4 w-4`})})]}),h&&(0,Z.jsxs)(`div`,{role:`status`,className:`mx-4 mt-3 flex items-start gap-2 rounded-md border border-warning/40 bg-warning/10 p-3 text-xs text-warning`,children:[(0,Z.jsx)(Kr,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,Z.jsx)(`span`,{children:n(`activity:ctxEditor.providerLimitDecreased`,{previous:Yh(h.previousMaxContext),current:Yh(h.maxContext)})})]}),o&&(0,Z.jsxs)(`div`,{className:`grid grid-cols-4 gap-2 px-4 py-2 border-b bg-muted/20 text-[11px] shrink-0`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground/60`,children:n(`activity:ctxEditor.system`)}),(0,Z.jsx)(`span`,{className:`font-mono font-medium`,children:Yh(o.systemPromptTokens)})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Z.jsxs)(`span`,{className:`text-muted-foreground/60`,children:[`Tools (`,o.toolCount,`)`]}),(0,Z.jsx)(`span`,{className:`font-mono font-medium`,children:Yh(o.toolSchemaTokens)})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground/60`,children:n(`activity:ctxEditor.messages`)}),(0,Z.jsx)(`span`,{className:`font-mono font-medium`,children:Yh(o.messageTokens)})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground/60`,children:n(`activity:ctxEditor.total`)}),(0,Z.jsx)(`span`,{className:`font-mono font-medium text-primary`,children:Yh(o.totalTokens)})]})]}),r===`loading_snapshot`&&(0,Z.jsxs)(`div`,{className:`flex items-center justify-center gap-2 text-sm text-muted-foreground py-12`,children:[(0,Z.jsx)(wt,{className:`h-4 w-4 animate-spin`}),n(`activity:ctxEditor.loadingContextSnapshot`)]}),r!==`loading_snapshot`&&a.length===0&&!f&&(0,Z.jsxs)(`div`,{className:`flex flex-1 min-h-0 flex-col items-center justify-center gap-2 px-6 py-12 text-center text-sm text-muted-foreground`,children:[(0,Z.jsx)(tn,{className:`h-5 w-5 text-muted-foreground/60`}),(0,Z.jsx)(`p`,{children:n(`activity:ctxEditor.emptyConversation`)})]}),f&&r===`apply_failed`&&(0,Z.jsx)(`div`,{className:`m-4 rounded-md bg-destructive/10 border border-destructive/20 p-3 text-sm text-destructive`,children:f}),r===`applied_success`&&d&&(0,Z.jsxs)(`div`,{className:`m-4 rounded-md bg-success/10 border border-success/20 p-3 text-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-success font-medium`,children:[(0,Z.jsx)($t,{className:`h-4 w-4`}),`Context updated: `,d.before.messages,` → `,d.after.messages,` `,`messages`]}),(0,Z.jsxs)(`div`,{className:`mt-1 text-muted-foreground text-xs`,children:[`Saved`,` `,Yh(d.before.fullRequestTokens-d.after.fullRequestTokens),` `,`tokens`,d.removed.toolUses.length>0&&` · ${d.removed.toolUses.length} tool calls repaired`]})]}),u?.conflict&&(0,Z.jsxs)(`div`,{className:`m-4 rounded-md bg-warning/10 border border-warning/20 p-3 text-sm text-warning`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 font-medium`,children:[(0,Z.jsx)(Kr,{className:`h-4 w-4`}),u.conflict.code===`CONTEXT_REVISION_CONFLICT`?`Context changed while editor was open.`:`Agent is currently running.`]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs opacity-80`,children:u.conflict.message})]}),r!==`loading_snapshot`&&a.length>0&&(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 space-y-3 overflow-y-auto overscroll-contain bg-muted/10 p-4`,children:a.map(e=>(0,Z.jsx)($h,{index:e.index,role:e.role,tokens:e.tokens,content:s[e.index]?.content??``,blockCount:e.blockCount,warnings:e.warnings,markedForRemoval:c.has(e.index),markedRanges:l.filter(t=>t.messageIndex===e.index),disabled:b,onToggle:()=>p.getState().toggleRemoveMessage(e.index),onMarkRange:(t,n,r)=>p.getState().markRangeForRemoval({messageIndex:e.index,...t===void 0?{}:{blockIndex:t},start:n,end:r})},e.index))}),u?.ok===!1&&u.validationErrors.length>0&&(0,Z.jsxs)(`div`,{className:`border-t px-4 py-2 bg-destructive/5 shrink-0`,children:[(0,Z.jsxs)(`div`,{className:`text-[11px] font-medium text-destructive mb-1`,children:[`Validation errors (`,u.validationErrors.length,`)`]}),u.validationErrors.slice(0,5).map((e,t)=>(0,Z.jsxs)(`div`,{className:`text-[10px] text-destructive/80 font-mono`,children:[e.path,`: `,e.message]},t))]}),u?.ok&&u.repair.changed&&(0,Z.jsx)(`div`,{className:`border-t px-4 py-2 bg-warning/5 shrink-0`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] text-warning`,children:[(0,Z.jsx)(at,{className:`h-3 w-3`}),(0,Z.jsx)(`span`,{children:n(`activity:ctxEditor.repairPreviewWillRemove`)}),u.repair.removedToolUses.length>0&&(0,Z.jsxs)(`span`,{children:[u.repair.removedToolUses.length,` orphan tool_use(s)`]}),u.repair.removedToolResults.length>0&&(0,Z.jsxs)(`span`,{children:[u.repair.removedToolResults.length,` orphan tool_result(s)`]}),u.repair.removedMessages>0&&(0,Z.jsxs)(`span`,{children:[u.repair.removedMessages,` empty message(s)`]})]})}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-t px-4 py-3 shrink-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] text-muted-foreground`,children:[x&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(vr,{className:`h-3 w-3 text-destructive`}),(0,Z.jsxs)(`span`,{children:[c.size,` message`,c.size===1?``:`s`,` and`,` `,l.length,` range`,l.length===1?``:`s`,` marked`]})]}),m&&(0,Z.jsxs)(`span`,{className:`flex items-center gap-1 text-warning`,children:[(0,Z.jsx)(He,{className:`h-3 w-3`}),n(`activity:ctxEditor.agentRunningApplyDisabled`)]})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[x&&(0,Z.jsx)(`button`,{type:`button`,onClick:()=>p.getState().clearRemovals(),className:`text-[11px] text-muted-foreground hover:text-foreground transition-colors`,disabled:b,children:n(`activity:ctxEditor.clear`)}),(0,Z.jsxs)(`button`,{type:`button`,onClick:v,disabled:!C,className:G(`flex items-center gap-1.5 rounded-md px-3 py-1.5 text-[11px] font-medium transition-colors`,C?`bg-secondary text-secondary-foreground hover:bg-secondary/80`:`bg-muted text-muted-foreground/40 cursor-not-allowed`),children:[r===`validating`?(0,Z.jsx)(wt,{className:`h-3 w-3 animate-spin`}):(0,Z.jsx)(tn,{className:`h-3 w-3`}),`Validate`]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:y,disabled:!S,className:G(`flex items-center gap-1.5 rounded-md px-3 py-1.5 text-[11px] font-medium transition-colors`,S?`bg-primary text-primary-foreground hover:bg-primary/90`:`bg-muted text-muted-foreground/40 cursor-not-allowed`),children:[r===`applying`?(0,Z.jsx)(wt,{className:`h-3 w-3 animate-spin`}):(0,Z.jsx)($t,{className:`h-3 w-3`}),`Apply Changes`]})]})]})]})})}function ng(e,t){if(!e)return`reset time unknown`;let n=Math.max(0,Math.ceil((e-t)/1e3));if(n===0)return`rechecking now`;if(n<60)return`${n}s`;let r=Math.floor(n/60);return r<60?`${r}m ${n%60}s`:`${Math.floor(r/60)}h ${r%60}m`}function rg(e,t){if(!e)return``;let n=Math.max(0,Math.floor((t-e)/1e3));if(n<60)return`${n}s ago`;let r=Math.floor(n/60);return r<60?`${r}m ago`:`${Math.floor(r/60)}h ${r%60}m ago`}var ig=/Sibling quarantine:.*?\bon\s+([^\s/]+\/\S+)/;function ag(e){return ig.exec(e.lastErrorMessage??``)?.[1]??null}function og(){let{t:e}=H(),t=ka(e=>e.entries);ka(e=>e.summary);let n=ka(e=>e.removeEntry),r=ka(e=>e.audit),i=W(e=>e.modelAvailabilitySchedule),[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(null),[l,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(Date.now()),p=(0,X.useMemo)(()=>Object.values(t).sort((e,t)=>(e.stateExpiresAt??0)-(t.stateExpiresAt??0)),[t]),m=(0,X.useMemo)(()=>p.filter(e=>e.state!==`healthy`),[p]),h=(0,X.useMemo)(()=>Yd(i,new Date(d)),[i,d]),g=(0,X.useCallback)(()=>{V().getProviderStatus()},[]),_=(0,X.useCallback)(()=>{u(e=>{let t=!e;return t&&V().getProviderAuditHistory(20),t})},[]),v=(0,X.useCallback)((e,t)=>{V().retryProviderModel(e,t),n(e,t)},[n]),y=(0,X.useCallback)((e,t)=>{V().clearProviderStatus(e,t),n(e,t)},[n]);if((0,X.useEffect)(()=>{if(m.length===0&&h.length===0)return;let e=window.setInterval(()=>f(Date.now()),1e3);return()=>window.clearInterval(e)},[h.length,m.length]),(0,X.useEffect)(()=>{a&&g()},[a,g]),m.length===0&&h.length===0)return null;let b=m.filter(e=>e.state===`blocked`).length,x=m.length-b;return s&&t[s],(0,Z.jsxs)(`div`,{className:`mx-auto mb-2 max-w-6xl rounded-lg border border-warning/25 bg-warning/5 text-xs`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-2 text-left hover:bg-warning/5`,onClick:()=>o(e=>!e),"aria-expanded":a,children:[(0,Z.jsx)(Kr,{className:`h-3.5 w-3.5 text-warning`}),(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,children:e(`activity:providerWait.providerModelAvailability`)}),(0,Z.jsxs)(`span`,{className:`text-muted-foreground`,children:[b,` blocked · `,x,` degraded · `,h.length,` scheduled`]}),(0,Z.jsx)(`button`,{type:`button`,className:`ml-auto inline-flex items-center gap-1 text-muted-foreground transition-colors hover:text-foreground`,onClick:e=>{e.stopPropagation(),g()},title:e(`activity:providerWait.refreshStatus`),children:(0,Z.jsx)(xi,{className:`h-3 w-3`})}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:a?`Hide`:`Details`})]}),a&&(0,Z.jsxs)(`div`,{className:`border-t border-warning/15 px-3 py-2`,children:[m.map(t=>{let n=`${t.providerId}\u0000${t.model}`,r=s===n,i=ag(t);return(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`button`,{type:`button`,className:`flex flex-wrap cursor-pointer items-center gap-x-2 gap-y-1 py-1.5 hover:bg-warning/5`,onClick:()=>c(r?null:n),children:[t.state===`blocked`?(0,Z.jsx)(Pi,{className:`h-3.5 w-3.5 text-warning`}):(0,Z.jsx)($t,{className:`h-3.5 w-3.5 text-warning`}),(0,Z.jsxs)(`code`,{className:`text-foreground`,children:[t.providerId,`/`,t.model]}),(0,Z.jsx)(`span`,{className:`rounded bg-warning/10 px-1.5 py-0.5 text-warning`,children:t.state}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:t.reason.replaceAll(`_`,` `)}),i&&(0,Z.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-muted-foreground`,children:[`via `,i]}),(0,Z.jsx)(`span`,{className:`ml-auto tabular-nums text-muted-foreground`,children:ng(t.stateExpiresAt,d)})]}),r&&(0,Z.jsxs)(`div`,{className:`ml-6 mb-2 rounded border border-border/50 bg-background/50 p-2`,children:[t.lastErrorMessage&&(0,Z.jsxs)(`div`,{className:`mb-1.5 text-destructive`,children:[(0,Z.jsxs)(`span`,{className:`text-muted-foreground`,children:[e(`activity:providerWait.lastError`),` `]}),t.lastErrorMessage.slice(0,300)]}),(0,Z.jsxs)(`div`,{className:`mb-1.5 flex flex-wrap gap-x-3 gap-y-0.5 text-muted-foreground`,children:[t.totalFailures!==void 0&&(0,Z.jsxs)(`span`,{children:[`failures: `,t.totalFailures]}),t.rateLimitHits!==void 0&&t.rateLimitHits>0&&(0,Z.jsxs)(`span`,{children:[`rate-limits: `,t.rateLimitHits]}),t.consecutiveFailures!==void 0&&(0,Z.jsxs)(`span`,{children:[`streak: `,t.consecutiveFailures]}),t.lastErrorStatus!==void 0&&(0,Z.jsxs)(`span`,{children:[`HTTP: `,t.lastErrorStatus]}),t.lastSessionId&&(0,Z.jsxs)(`span`,{children:[`session: `,t.lastSessionId.slice(0,12),`…`]}),t.lastAgentId&&(0,Z.jsxs)(`span`,{children:[`agent: `,t.lastAgentId.slice(0,16),`…`]}),t.lastFailureAt&&(0,Z.jsx)(`span`,{children:rg(t.lastFailureAt,d)})]}),t.recentErrors&&t.recentErrors.length>0&&(0,Z.jsxs)(`details`,{className:`mb-1.5`,children:[(0,Z.jsxs)(`summary`,{className:`cursor-pointer text-muted-foreground hover:text-foreground`,children:[`Error history (`,t.recentErrors.length,`)`]}),(0,Z.jsx)(`div`,{className:`mt-1 max-h-32 overflow-y-auto text-[11px] text-muted-foreground`,children:t.recentErrors.map((e,t)=>(0,Z.jsxs)(`div`,{className:`flex gap-2 border-b border-border/20 py-0.5`,children:[(0,Z.jsx)(`span`,{className:`shrink-0 tabular-nums text-warning/70`,children:e.kind}),(0,Z.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[`HTTP `,e.status]}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.message.slice(0,200)}),(0,Z.jsx)(`span`,{className:`ml-auto shrink-0 tabular-nums`,children:rg(e.timestamp,d)})]},t))})]}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded border border-border bg-background px-2 py-1 text-[11px] font-medium text-foreground transition-colors hover:bg-accent`,onClick:()=>v(t.providerId,t.model),children:[(0,Z.jsx)(Tn,{className:`h-3 w-3`}),e(`activity:providerWait.reopenHalfOpenProbe`)]}),(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded border border-border bg-background px-2 py-1 text-[11px] font-medium text-muted-foreground transition-colors hover:text-foreground`,onClick:()=>y(t.providerId,t.model),children:[(0,Z.jsx)(vr,{className:`h-3 w-3`}),e(`activity:providerWait.clearTracking`)]})]})]})]},n)}),h.map(e=>(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 py-1.5`,children:[(0,Z.jsx)(Pi,{className:`h-3.5 w-3.5 text-info`}),(0,Z.jsx)(`code`,{className:`text-foreground`,children:Jd(e)}),(0,Z.jsx)(`span`,{className:`rounded bg-info/10 px-1.5 py-0.5 text-info`,children:`scheduled`}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:e.label??`calendar blackout`}),(0,Z.jsxs)(`span`,{className:`ml-auto tabular-nums text-muted-foreground`,children:[e.start,`–`,e.end,` · `,e.timezone??`local time`]})]},e.id)),(0,Z.jsxs)(`button`,{type:`button`,className:`mt-1 flex w-full items-center gap-2 border-t border-border/30 py-1.5 text-left hover:bg-warning/5`,onClick:_,"aria-expanded":l,children:[(0,Z.jsx)(Pi,{className:`h-3.5 w-3.5 text-warning`}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:providerWait.recentBlockOpenEvents`,{count:r.length})}),(0,Z.jsx)(`span`,{className:`ml-auto text-muted-foreground`,children:l?`Hide`:`Show`})]}),l&&(0,Z.jsx)(`div`,{className:`pt-1`,children:r.length===0?(0,Z.jsx)(`div`,{className:`py-1 text-muted-foreground`,children:e(`activity:providerWait.noBlockOpenEventsYet`)}):r.map((e,t)=>{let n=e.to!==`blocked`,r=[e.error?.sessionId,e.error?.agentId].filter(e=>typeof e==`string`&&e.length>0).map(e=>`${e.slice(0,12)}…`).join(` / `);return(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5 py-0.5`,children:[(0,Z.jsx)(`span`,{className:`shrink-0 tabular-nums text-muted-foreground`,children:rg(e.ts,d)}),(0,Z.jsxs)(`code`,{className:`text-foreground`,children:[e.providerId,`/`,e.model]}),(0,Z.jsxs)(`span`,{className:n?`text-info`:`text-warning`,children:[e.from,` → `,e.to]}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:e.reason.replaceAll(`_`,` `)}),e.error&&(0,Z.jsxs)(`span`,{className:`text-destructive`,children:[e.error.kind,e.error.status==null?``:` ${e.error.status}`]}),r&&(0,Z.jsx)(`span`,{className:`ml-auto text-muted-foreground`,children:r})]},`${e.ts}-${t}`)})}),(0,Z.jsx)(`div`,{className:`mt-1 text-[11px] text-muted-foreground`,children:e(`activity:providerWait.wrongstackRoutesAroundActiveSchedulesAnd`)})]})]})}var sg=`
|
|
98
|
+
`).length;a({chars:i.length,lines:e}),setTimeout(()=>a(null),4e3)}},pasteHint:i,pendingImagesRef:c,pendingImages:l,addImageFiles:p,removeImage:e=>{d(c.current.filter(t=>t.id!==e))},clearPendingImages:()=>d([]),setPendingImages:d,setPasteHint:a}}function Fh({clientConnected:e,t,sendMessage:n,setInput:r}){let i=K(e=>e.refinePanel),a=K(e=>e.setRefinePanel),o=q(e=>e.enqueue),s=q(e=>e.addMessage),c=q(e=>e.setLoading);(0,X.useEffect)(()=>{if(!i||(i.status??`refining`)!==`refining`)return;let l=i.retried?21e4:105e3,u=setTimeout(()=>{let i=K.getState().refinePanel;if(!(!i||(i.status??`refining`)!==`refining`)){if(a(null),B.info(t(`chat:input.refineTimeoutFallback`)),i.mode!==void 0&&q.getState().isLoading){let e=i.images,t=e&&e.length>0&&i.mode===`btw`?`queue`:i.mode;o(i.original,t,e);return}e?(s({role:`user`,content:i.original}),c(!0),i.freshContext===!0?n(i.original,void 0,!0):n(i.original)):(r(i.original),B.error(t(`chat:input.notConnectedDraftKept`)))}},l);return()=>clearTimeout(u)},[i,e,s,c,n,a,o,r,t])}function Ih({onTranscript:e}){let[t,n]=(0,X.useState)(!1),[r,i]=(0,X.useState)(!1),a=(0,X.useRef)(null);return(0,X.useEffect)(()=>{if(typeof window>`u`)return;let e=window.SpeechRecognition||window.webkitSpeechRecognition;i(!!e)},[]),{isListening:t,isSupported:r,toggleListening:(0,X.useCallback)(()=>{if(typeof window>`u`)return;let r=window.SpeechRecognition||window.webkitSpeechRecognition;if(r){if(t){a.current?.stop(),n(!1);return}try{let t=new r;t.continuous=!0,t.interimResults=!1,t.lang=navigator.language||`en-US`,t.onresult=t=>{let n=``;for(let e=t.resultIndex;e<t.results.length;++e){let r=t.results[e];r?.isFinal&&r[0]&&(n+=r[0].transcript)}n.trim()&&e(n.trim())},t.onerror=()=>{n(!1)},t.onend=()=>{n(!1)},t.start(),a.current=t,n(!0)}catch{n(!1)}}},[t,e]),stopListening:(0,X.useCallback)(()=>{a.current?.abort?.(),a.current?.stop?.(),a.current=null,n(!1)},[])}}function Lh({onOpenBreakdown:e}={}){let{isLoading:t,setLoading:n,addMessage:r,clearMessages:i}=q(Me(e=>({isLoading:e.isLoading,setLoading:e.setLoading,addMessage:e.addMessage,clearMessages:e.clearMessages}))),a=q(e=>e.messages).length>0,o=q(e=>e.queue),s=q(e=>e.enqueue),c=q(e=>e.removeQueued),l=q(e=>e.clearQueue),u=K(e=>e.setCurrentView),d=K(e=>e.setPromptLibraryOpen),f=K(e=>e.pushPrompt),p=K(e=>e.promptHistory),m=K(e=>e.promptInsertRequest),h=K(e=>e.clearPromptInsert),g=K(e=>e.setProcessMonitorOpen),_=K(e=>e.setQueuePanelOpen),v=ha(),{sendMessage:y,sendAbort:b,client:x,refineModel:S,updatePrefs:C}=v,{t:w}=H(),T=W(e=>e.enhanceEnabled),E=N(e=>e.session?.provider),D=N(e=>e.session?.model),O=R(e=>e.provider),k=R(e=>e.model),[A,j]=(0,X.useState)(()=>K.getState().draftInput??``),M=(0,X.useRef)(null),{isListening:P,isSupported:F,toggleListening:I,stopListening:L}=Ih({onTranscript:e=>{j(t=>t?`${t} ${e}`:e)}});Fh({clientConnected:x?.isConnected,t:w,sendMessage:y,setInput:j}),Ch({client:x,sendMessage:y});let ee=N(e=>e.lastInputTokens),te=N(e=>e.maxContext),[z,ne]=(0,X.useState)(null),[re,ie]=(0,X.useState)(!1),[ae,oe]=(0,X.useState)(!1),se=(0,X.useRef)(!1),ce=(0,X.useRef)(null),le=(0,X.useRef)(null),ue=ja(e=>e.refs),{removeRef:de,clearRefs:fe}=ja.getState(),{draggingOver:pe,onDragEnter:me,onDragLeave:V,onDragOver:he,onDrop:ge,onTextPaste:_e,pasteHint:ye,pendingImagesRef:be,pendingImages:xe,addImageFiles:Se,removeImage:Ce,clearPendingImages:we,setPendingImages:Te,setPasteHint:Ee}=Ph({input:A,textareaRef:le,setInput:j,errorText:{tooManyImages:e=>w(`chat:input.tooManyImages`,{max:e}),imageProcessFailed:e=>w(`chat:input.imageProcessFailed`,{name:e}),imageTooLarge:e=>w(`chat:input.imageTooLarge`,{name:e})}}),De=(0,X.useRef)(null);(0,X.useEffect)(()=>{K.getState().setDraftInput(A)},[A]),(0,X.useEffect)(()=>()=>{M.current!==null&&clearTimeout(M.current)},[]);let Oe=ve(),ke=(0,X.useCallback)(()=>{bh(Oe);let e=le.current;e&&(e.value=``,e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,200)}px`,t||e.focus())},[t,Oe]),Ae=(0,X.useCallback)(()=>{let e=!T;W.getState().set({enhanceEnabled:e}),C({enhanceEnabled:e})},[T,C]),je=(0,X.useRef)(()=>!1),{sendMsg:Ne,handleSubmit:Pe,handleBtw:Fe,handleSteer:Ie,handleAddQueue:Le,handleAbort:Re,handleStopAndEdit:ze}=Th({input:A,setInput:j,sessionId:Oe,textareaRef:le,pendingImagesRef:be,clearPendingImages:we,isLoading:t,setLoading:n,addMessage:r,enqueue:s,ws:v,enhanceEnabled:T,pushPrompt:f,setHistoryIdx:e=>Ge(e),stickyDraftRef:{get current(){return Ke.current},set current(e){Ke.current=e}},refineBackstopTimerRef:M,topicCheckBusyRef:se,topicCheckAbortRef:ce,setTopicCheckBusy:oe,runSlashCommand:e=>je.current(e),clearTextarea:ke,t:w}),Be=(0,X.useCallback)(t=>Xo({raw:t,addMessage:r,clearMessages:i,client:x,queue:o,sendAbort:b,sendMsg:Ne,setLoading:n,setCurrentView:u,toggleRefineEnabled:Ae,setProcessMonitorOpen:g,setQueuePanelOpen:_,ws:v,onOpenBreakdown:e,handleNextList:uh,handleNextSelect:e=>dh(e,Ne)}),[r,i,x,o,b,Ne,n,u,Ae,g,_,v,e]);je.current=Be;let{slashIndex:Ve,setSlashIndex:He,slashSuggestions:Ue,historyIdx:We,setHistoryIdx:Ge,stickyDraftRef:Ke,handleKeyDown:qe}=wh({input:A,setInput:j,textareaRef:le,atMention:z,promptHistory:p,runSlashCommand:Be,handleSubmit:Pe});xh({sessionId:Oe,input:A,setInput:j,pendingImages:xe,setPendingImages:Te,clearPendingImages:we,fileRefs:ue,clearRefs:fe,setHistoryIdx:Ge,stickyDraftRef:Ke,setAtMention:ne,setPasteHint:Ee,stopSpeech:L,topicCheckAbortRef:ce,topicCheckBusyRef:se,setTopicCheckBusy:oe,refineBackstopTimerRef:M,textareaRef:le}),(0,X.useEffect)(()=>{m!=null&&(j(e=>e.trim()?`${e}\n${m}`:m),h(),requestAnimationFrame(()=>le.current?.focus()))},[m,h]);let Je=()=>{let e=le.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,200)}px`)};return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(Kc,{}),ye&&(0,Z.jsx)(qm,{pasteHint:ye,onDismiss:()=>Ee(null),t:w}),(0,Z.jsx)(Jm,{pendingImages:xe,onRemove:Ce,onClearAll:we,t:w}),(0,Z.jsx)(ph,{queue:o,onClear:l,onRemove:c}),(0,Z.jsx)(_h,{enhanceEnabled:T,refinePickOpen:re,setRefinePickOpen:ie,refineModel:S,clientConnected:x?.isConnected===!0,addUserMessage:e=>r({role:`user`,content:e}),setLoading:n,sendMessage:y,isLoading:t,enqueue:s,setInput:j,resolveCancelInput:vh,notConnectedDraftKept:()=>B.error(w(`chat:input.notConnectedDraftKept`))}),(0,Z.jsx)(Xm,{sessionProvider:E,sessionModel:D,fallbackProvider:O,fallbackModel:k,onOpenPromptLibrary:()=>d(!0),onOpenModelSwitcher:()=>K.getState().setModelSwitcherOpen(!0),t:w}),(0,Z.jsx)(Ym,{fileRefs:ue,onRemove:de,onClearAll:fe,t:w}),ae&&(0,Z.jsx)(`div`,{className:`px-1 text-xs text-muted-foreground`,role:`status`,children:w(`chat:input.topicShiftChecking`)}),(0,Z.jsxs)(`form`,{onSubmit:Pe,onDragEnter:me,onDragOver:he,onDragLeave:V,onDrop:ge,"data-session-id":Oe??void 0,"data-running":t?`true`:`false`,"data-chat-started":a?`true`:`false`,"data-has-draft":A.trim()||xe.length>0?`true`:`false`,className:G(`relative flex flex-col gap-2 rounded-xl border border-border/70 bg-background/85 p-2 shadow-lg shadow-black/5 transition-colors sm:flex-row sm:items-end`,t&&`border-warning/45 bg-warning/5 shadow-warning/10`,!a&&!t&&`border-border/50 bg-card/55 shadow-none`,pe&&`ring-2 ring-primary ring-offset-2 ring-offset-background bg-primary/5`),children:[pe&&(0,Z.jsx)(`div`,{className:`absolute inset-0 z-20 flex items-center justify-center pointer-events-none rounded-lg bg-primary/10 text-primary text-sm font-medium`,children:w(`chat:input.dropOverlay`)}),(0,Z.jsxs)(`div`,{className:`relative w-full flex-1`,children:[(0,Z.jsx)(nh,{atMention:z,input:A,textareaRef:le,setInput:j,setAtMention:ne}),!z&&(0,Z.jsx)(Sh,{suggestions:Ue,selectedIndex:Ve,onSelectIndex:He,onRun:e=>{j(``),Be(e)}}),(0,Z.jsx)(`textarea`,{ref:le,"data-chat-textarea":!0,value:A,onChange:e=>{let t=e.target.value;j(t),Je(),We>=0&&(Ge(-1),Ke.current=null);let n=e.target.selectionStart??t.length;ne(Wo(t,n))},onSelect:e=>{let t=e.currentTarget;ne(Wo(t.value,t.selectionStart))},onKeyDown:qe,onPaste:_e,placeholder:x?.isConnected?w(t?`chat:inputPlaceholderLoading`:`chat:inputPlaceholder`):w(`chat:inputPlaceholderConnecting`),className:G(`flex min-h-[64px] w-full resize-none overflow-y-auto rounded-lg border border-input bg-card/80 px-4 py-3 pr-12 shadow-sm sm:min-h-[44px]`,`text-sm ring-offset-background placeholder:text-muted-foreground`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,`disabled:cursor-not-allowed disabled:opacity-50`,`scrollbar-thin`),rows:1,disabled:!x?.isConnected||ae}),(0,Z.jsx)(eh,{input:A,lastInputTokens:ee,maxContext:te})]}),(0,Z.jsx)($m,{imagePickerRef:De,disabled:!x?.isConnected||ae,topicCheckBusy:ae,clientConnected:x?.isConnected===!0,isLoading:t,chatStarted:a,input:A,pendingImages:xe,addImageFiles:Se,handleStopAndEdit:ze,handleAbort:Re,handleBtw:Fe,handleSteer:Ie,handleAddQueue:Le,updatePrefs:C,t:w,isListening:P,isSpeechSupported:F,onToggleSpeech:I})]})]})}function Rh(e){return{index:e.promptIndex,iteration:e.promptIndex,timestamp:e.ts??``,label:e.promptPreview??``,messageCount:0,tokens:0,fileCount:e.fileCount??0}}function zh({open:e,onClose:t,className:n}){let{t:r}=H(),[i,a]=(0,X.useState)([]),[o,s]=(0,X.useState)(!1),c=ha(),l=R(e=>e.wsConnected),u=(0,X.useRef)(null),d=ve();(0,X.useEffect)(()=>{if(!(!e||!l||!c.client?.isConnected))return a([]),c.client.send?.({type:`session.checkpoints`,payload:c.client.withSession({})}),u.current=c.client.on?.(`session.checkpoints`,e=>{let t=e?.payload;(t?.sessionId===void 0||d===void 0||t.sessionId===d)&&t?.checkpoints&&a(t.checkpoints.map(Rh))})??null,()=>{u.current?.()}},[e,l,c.client,d]);let f=(0,X.useCallback)(async e=>{s(!0),c.client.send?.({type:`session.rewind`,payload:c.client.withSession({checkpointIndex:e})}),setTimeout(()=>{t(),s(!1)},800)},[c.client,t]);return(0,Z.jsx)(Ja,{open:e,onOpenChange:e=>{e||t()},children:(0,Z.jsxs)(Ga,{className:G(`max-w-md gap-0 overflow-hidden border-border/80 bg-card p-0 pt-[10dvh] flex flex-col max-h-[75dvh]`,n),children:[(0,Z.jsx)(Ka,{className:`sr-only`,children:r(`activity:checkpoint.heading`)}),(0,Z.jsx)(qa,{className:`sr-only`,children:r(`activity:checkpoint.countSuffix`,{count:i.length})}),(0,Z.jsx)(`div`,{className:`flex items-center justify-between border-b border-border/70 bg-card/95 px-4 py-3 shrink-0`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,Z.jsx)(`span`,{className:`flex items-center justify-center w-8 h-8 rounded-md border border-primary/20 bg-primary/10 text-primary`,children:(0,Z.jsx)(Fn,{className:`h-4 w-4`})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h2`,{className:`text-sm font-semibold`,children:r(`activity:checkpoint.heading`)}),(0,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:r(`activity:checkpoint.countSuffix`,{count:i.length})})]})]})}),(0,Z.jsx)(`div`,{className:`border-b border-border/70 bg-muted/25 px-4 py-2.5 text-[10px] text-muted-foreground leading-relaxed`,children:r(`activity:checkpoint.description`)}),(0,Z.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:i.length===0?(0,Z.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16 gap-3 text-muted-foreground`,children:[(0,Z.jsx)(He,{className:`h-10 w-10 opacity-15`}),(0,Z.jsx)(`p`,{className:`text-sm font-medium`,children:r(`activity:checkpoint.emptyTitle`)}),(0,Z.jsx)(`p`,{className:`text-xs text-center max-w-xs`,children:r(`activity:checkpoint.emptyBody`)})]}):(0,Z.jsx)(`div`,{className:`py-1`,children:[...i].reverse().map((e,t)=>{let n=t===0;return(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>f(e.index),disabled:o,className:G(`w-full flex items-start gap-3 px-4 py-3 text-left transition-colors group`,n?`bg-primary/5 hover:bg-primary/10`:`hover:bg-accent/40`,o&&`opacity-50 pointer-events-none`),children:[(0,Z.jsxs)(`div`,{className:`flex flex-col items-center mt-1.5`,children:[(0,Z.jsx)(`div`,{className:G(`w-2.5 h-2.5 rounded-full border-2 shrink-0 transition-colors`,n?`border-primary bg-primary/20 shadow-[0_0_0_3px_hsl(var(--primary)/0.25)]`:`border-muted-foreground/30 bg-background group-hover:border-primary/40`)}),t<i.length-1&&(0,Z.jsx)(`div`,{className:`w-px flex-1 min-h-[20px] bg-border/50`})]}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsxs)(`span`,{className:`text-xs font-mono text-muted-foreground tabular-nums shrink-0`,children:[`#`,e.index]}),(0,Z.jsx)(`span`,{className:`text-xs font-medium truncate`,children:e.label}),n&&(0,Z.jsx)(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium shrink-0`,children:r(`activity:checkpoint.latest`)})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 mt-1 text-[10px] text-muted-foreground`,children:[(0,Z.jsx)(`span`,{className:`tabular-nums`,children:r(`activity:checkpoint.msgSuffix`,{count:e.messageCount})}),(0,Z.jsx)(`span`,{className:`opacity-50`,children:`·`}),(0,Z.jsxs)(`span`,{className:`tabular-nums`,children:[e.fileCount??0,` files`]}),(0,Z.jsx)(`span`,{className:`opacity-50`,children:`·`}),(0,Z.jsxs)(`span`,{className:`tabular-nums`,children:[`iter `,e.iteration]})]})]}),(0,Z.jsx)(`span`,{className:`shrink-0 mt-1.5 opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,Z.jsx)(Ae,{className:`h-4 w-4 text-primary`})})]},e.index)})})}),(0,Z.jsxs)(`div`,{className:`border-t border-border/70 bg-muted/20 px-4 py-2 text-[10px] text-muted-foreground text-center shrink-0`,children:[r(`activity:checkpoint.footerPre`),` ·`,` `,(0,Z.jsx)(`kbd`,{className:`px-1 py-0.5 rounded bg-muted font-mono text-[9px]`,children:`Esc`}),` `,r(`activity:checkpoint.footerPost`)]})]})})}function Bh(e){return!!(e?.role===`user`&&Array.isArray(e.content)&&e.content.length>0&&e.content.every(e=>e.type===`tool_result`))}function Vh(e,t){if(e[t]?.role!==`user`||Bh(e[t]))return[];let n=[];for(let r=t+1;r<e.length;r+=1){let t=e[r];if(t?.role===`user`&&!Bh(t))break;t?.role===`assistant`&&n.push(r)}return n}function Hh(e,t){return e.messageBreakdown.find(e=>e.index===t)?.pairedAssistantIndices??Vh(e.messages,t)}function Uh(e,t,n){let r=new Set(t);return e.messages.forEach((i,a)=>{if(!(i.role!==`user`||!t.has(a)&&!n.some(e=>e.messageIndex===a)))for(let t of Hh(e,a))r.add(t)}),r}function Wh(e){let t=new Map;for(let n of e){let e=`${n.messageIndex}:${n.blockIndex??`string`}`;t.set(e,[...t.get(e)??[],n])}return[...t.values()].flatMap(e=>{let t=e.sort((e,t)=>(e.start??0)-(t.start??0)),n=[];for(let e of t){let t=n.at(-1);t?.end!==void 0&&e.start!==void 0&&e.end!==void 0&&e.start<=t.end?t.end=Math.max(t.end,e.end):n.push({...e})}return n})}function Gh(e,t){if(t<=0||t>=e.length)return!1;let n=e.charCodeAt(t-1),r=e.charCodeAt(t);return n>=55296&&n<=56319&&r>=56320&&r<=57343}function Kh(e,t){if(t.start===void 0||t.end===void 0)return;let n=e[t.messageIndex];if(!n)return;if(t.blockIndex===void 0&&typeof n.content==`string`){n.content=n.content.slice(0,t.start)+n.content.slice(t.end);return}if(!Array.isArray(n.content)||t.blockIndex===void 0)return;let r=n.content[t.blockIndex];r?.type===`text`&&typeof r.text==`string`&&(r.text=r.text.slice(0,t.start)+r.text.slice(t.end))}var qh={phase:`closed`,revision:null,messages:[],readonlyContext:null,messageBreakdown:[],diagnostics:null,removeMessages:new Set,explicitRemoveMessages:new Set,removeRanges:[],validation:null,appliedResult:null,errorMessage:null},Jh=xa(((e,t)=>({...qh,open:()=>e({...qh,phase:`loading_snapshot`,removeMessages:new Set,explicitRemoveMessages:new Set}),close:()=>e({...qh}),loadSnapshot:t=>e(e=>{let n=e.phase===`applied_success`&&e.appliedResult!==null;return{phase:n?`applied_success`:`clean_snapshot`,revision:t.revision,messages:t.messages,readonlyContext:t.readonlyContext,messageBreakdown:t.messageBreakdown,diagnostics:t.diagnostics,removeMessages:new Set,explicitRemoveMessages:new Set,removeRanges:[],validation:null,appliedResult:n?e.appliedResult:null,errorMessage:null}}),toggleRemoveMessage:n=>{let r=t();if(r.phase===`validating`||r.phase===`applying`)return;let i=new Set(r.explicitRemoveMessages);if(r.messages[n]?.role===`assistant`&&r.messages.some((e,t)=>e.role===`user`&&(r.explicitRemoveMessages.has(t)||r.removeRanges.some(e=>e.messageIndex===t))&&Hh(r,t).includes(n))&&r.removeMessages.has(n))return;i.has(n)?i.delete(n):i.add(n);let a=r.removeRanges,o=Uh(r,i,a);e({removeMessages:o,explicitRemoveMessages:i,removeRanges:a,phase:o.size>0||a.length>0?`dirty`:`clean_snapshot`,validation:null})},markRangeForRemoval:n=>{let r=t();if(r.phase===`validating`||r.phase===`applying`||r.explicitRemoveMessages.has(n.messageIndex)||n.start===void 0||n.end===void 0||n.start<0||n.end<=n.start)return;let i=r.messages[n.messageIndex],a;if(n.blockIndex===void 0&&typeof i?.content==`string`)a=i.content;else if(n.blockIndex!==void 0&&Array.isArray(i?.content)){let e=i.content[n.blockIndex];e?.type===`text`&&(a=e.text)}if(a===void 0||n.end>a.length||Gh(a,n.start)||Gh(a,n.end))return;let o=Wh([...r.removeRanges,n]);e({removeMessages:Uh(r,r.explicitRemoveMessages,o),removeRanges:o,phase:`dirty`,validation:null})},clearRemovals:()=>e({removeMessages:new Set,explicitRemoveMessages:new Set,removeRanges:[],phase:`clean_snapshot`,validation:null}),beginValidation:()=>e({phase:`validating`,validation:null,errorMessage:null}),beginApply:()=>e({phase:`applying`,errorMessage:null}),setValidation:t=>e({validation:t,phase:t.conflict?`conflicted`:t.ok?`validated`:`invalid`,errorMessage:null}),setApplied:t=>e({appliedResult:t,phase:`applied_success`,removeMessages:new Set,explicitRemoveMessages:new Set,removeRanges:[],validation:null,errorMessage:null}),setError:n=>e({errorMessage:n,phase:n?`apply_failed`:t().phase}),resetToClean:()=>e({phase:`clean_snapshot`,removeMessages:new Set,explicitRemoveMessages:new Set,removeRanges:[],validation:null,errorMessage:null}),getProposedMessages:()=>{let e=t(),n=structuredClone(e.messages);for(let t of[...e.removeRanges].sort((e,t)=>(t.start??0)-(e.start??0)))Kh(n,t);return n.filter((t,n)=>!e.removeMessages.has(n))}})));function Yh(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Xh(e){let t=window.getSelection();if(!t||t.rangeCount===0||t.isCollapsed)return null;let n=t.getRangeAt(0);if(!e.contains(n.commonAncestorContainer))return null;let r=n.cloneRange();r.selectNodeContents(e),r.setEnd(n.startContainer,n.startOffset);let i=r.toString().length,a=i+n.toString().length;return a>i?{start:i,end:a}:null}function Zh(e){return e.type===`image`?e.source?.type===`base64`?`${e.source.media_type??`image`} · ${e.source.data?.length??0} base64 chars`:`URL image source`:e.type===`tool_use`?`${e.name??`tool`} · ${e.id??`unknown id`}`:e.type===`tool_result`?`tool result · ${e.tool_use_id??`unknown id`}`:e.type===`thinking`?`thinking · ${e.thinking?.length??0} chars`:e.type}function Qh({text:e,blockIndex:t,marked:n,disabled:r,onMarkRange:i}){let[a,o]=(0,X.useState)(null),s=(0,X.useRef)(null),c=(0,X.useCallback)(()=>{if(r)return;let e=s.current;e&&o(Xh(e))},[r]);return(0,X.useEffect)(()=>{o(null)},[e]),(0,Z.jsxs)(`div`,{className:G(`rounded-md border bg-background p-3`,n&&`border-destructive/40 bg-destructive/5`),children:[(0,Z.jsx)(`p`,{ref:s,className:`whitespace-pre-wrap break-words font-mono text-xs leading-relaxed text-foreground select-text`,onMouseUp:c,onKeyUp:c,tabIndex:r?-1:0,children:e||`(empty)`}),a&&(0,Z.jsx)(`button`,{type:`button`,disabled:r,className:`mt-2 rounded-md border border-destructive/30 px-2 py-1 text-[11px] font-medium text-destructive hover:bg-destructive/10 disabled:cursor-not-allowed disabled:opacity-40`,onMouseDown:e=>e.preventDefault(),onClick:()=>{i(t,a.start,a.end),window.getSelection()?.removeAllRanges(),o(null)},children:`Mark for removal`})]})}function $h({index:e,role:t,tokens:n,content:r,blockCount:i,warnings:a,markedForRemoval:o,markedRanges:s,disabled:c,onToggle:l,onMarkRange:u}){let[d,f]=(0,X.useState)(!1),p=t===`user`?`text-primary`:t===`assistant`?`text-success`:`text-muted-foreground`,m=a.length>0;return(0,Z.jsxs)(`div`,{className:G(`group flex items-start gap-3 rounded-lg border bg-card p-3 transition-colors`,o&&`border-destructive/40 bg-destructive/5 opacity-70`,!o&&`hover:border-primary/30`),children:[(0,Z.jsx)(`button`,{type:`button`,onClick:l,disabled:c,className:`mt-0.5 shrink-0 disabled:cursor-not-allowed disabled:opacity-40`,"aria-label":o?`Undo removal`:`Mark for removal`,children:o?(0,Z.jsx)(vr,{className:`h-3.5 w-3.5 text-destructive`}):(0,Z.jsx)(`div`,{className:`h-3.5 w-3.5 rounded-sm border border-border/60 group-hover:border-primary/50 transition-colors`})}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px]`,children:[i!==null&&i>0&&(0,Z.jsx)(`button`,{type:`button`,onClick:()=>f(e=>!e),className:`text-muted-foreground/60 hover:text-foreground shrink-0`,children:d?(0,Z.jsx)(Ct,{className:`h-3 w-3`}):(0,Z.jsx)(ot,{className:`h-3 w-3`})}),(0,Z.jsx)(`span`,{className:G(`font-mono font-medium`,p),children:t}),(0,Z.jsxs)(`span`,{className:`text-muted-foreground/60 tabular-nums`,children:[Yh(n),` tok`]}),i!==null&&i>0&&(0,Z.jsxs)(`span`,{className:`text-muted-foreground/50 tabular-nums`,children:[i,` blk`]}),m&&(0,Z.jsx)(Kr,{className:`h-3 w-3 text-warning shrink-0`})]}),(0,Z.jsx)(`div`,{className:`mt-3 space-y-2`,children:typeof r==`string`?(0,Z.jsx)(Qh,{text:r,marked:s.some(e=>e.blockIndex===void 0),disabled:c,onMarkRange:u}):r.map((t,n)=>(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between text-[10px] text-muted-foreground`,children:[(0,Z.jsx)(`span`,{className:`font-mono`,children:t.type}),typeof t.text==`string`&&(0,Z.jsxs)(`span`,{children:[Yh(Math.ceil(t.text.length/4)),` tok`]})]}),t.type===`text`&&typeof t.text==`string`?(0,Z.jsx)(Qh,{text:t.text,blockIndex:n,marked:s.some(e=>e.blockIndex===n),disabled:c,onMarkRange:u}):(0,Z.jsx)(`div`,{className:`rounded-md border bg-muted/20 p-3 font-mono text-[11px] text-muted-foreground`,children:Zh(t)})]},`${e}-${n}`))}),d&&m&&(0,Z.jsx)(`div`,{className:`mt-2 space-y-1`,children:a.map((e,t)=>(0,Z.jsxs)(`div`,{className:G(`flex items-start gap-1 text-[10px] rounded px-1.5 py-0.5`,e.severity===`danger`?`bg-destructive/10 text-destructive`:e.severity===`warning`?`bg-warning/10 text-warning`:`bg-muted text-muted-foreground`),children:[(0,Z.jsx)(`span`,{className:`font-mono`,children:e.code}),(0,Z.jsx)(`span`,{className:`opacity-80`,children:e.message})]},t))})]})]})}var eg=5e3;function tg({open:e,onClose:t}){let{t:n}=H(),r=Jh(e=>e.phase),i=Jh(e=>e.revision),a=Jh(e=>e.messageBreakdown),o=Jh(e=>e.readonlyContext),s=Jh(e=>e.messages),c=Jh(e=>e.removeMessages),l=Jh(e=>e.removeRanges),u=Jh(e=>e.validation),d=Jh(e=>e.appliedResult),f=Jh(e=>e.errorMessage),p=Jh,m=q(e=>e.isLoading),h=N(e=>e.contextLimitWarning),g=ve(),_=V()?.withSession?.({})?.sessionId??g??re()??void 0;xs(`context.editor.snapshot`,e=>{let t=e.payload;!t||typeof t.revision!=`string`||Array.isArray(t.messages)&&p.getState().loadSnapshot(t)},{sessionId:_,deps:[e,p,_]}),xs(`context.editor.validation`,e=>{p.getState().setValidation(e.payload)},{sessionId:_,deps:[e,p,_]}),xs(`context.editor.applied`,e=>{p.getState().setApplied(e.payload);let t=V();typeof t?.openContextEditor==`function`&&t.openContextEditor()},{sessionId:_,deps:[e,p,_]}),(0,X.useEffect)(()=>{if(!e){p.getState().close();return}(p.getState().phase===`closed`||p.getState().phase===`apply_failed`)&&p.getState().open();let t=V();if(!t?.send||!t?.on){p.getState().setError(U.t(`activity:context.wsNotConnected`));return}t.send({type:`context.editor.open`,payload:t.withSession({})});let n=setTimeout(()=>{p.getState().phase===`loading_snapshot`&&p.getState().setError(U.t(`activity:ctxEditor.snapshotTimedOut`))},eg);return()=>clearTimeout(n)},[e,p,_]),(0,X.useEffect)(()=>{if(!e)return;let n=e=>{if(e.key===`Escape`&&r!==`applying`&&r!==`validating`){if((c.size>0||l.length>0)&&r===`dirty`)return;t()}};return document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[e,t,r,c.size,l.length]);let v=(0,X.useCallback)(()=>{let e=V();if(!e?.send||!i)return;p.getState().beginValidation();let t=p.getState(),n=t.getProposedMessages(),r=[...[...t.removeMessages].map(e=>({messageIndex:e})),...t.removeRanges];e.validateContextEditor(i,n,r,!0)},[i,p]),y=(0,X.useCallback)(()=>{let e=V();if(!e?.send||!i)return;let t=p.getState(),n=t.getProposedMessages(),r=[...[...t.removeMessages].map(e=>({messageIndex:e})),...t.removeRanges];p.getState().beginApply(),e.applyContextEditor(i,n,r,!0)},[i,p]);if(!e)return null;let b=r===`applying`||r===`validating`,x=c.size>0||l.length>0,S=r===`validated`&&!m,C=x&&!b&&!m;return(0,Z.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-start justify-center bg-black/40 backdrop-blur-sm`,children:(0,Z.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":n(`activity:ctxEditor.contextWindowEditor`),className:`m-6 flex max-h-[calc(100dvh-3rem)] w-full max-w-4xl flex-col overflow-hidden rounded-lg border bg-card shadow-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between border-b px-4 py-3 shrink-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Cn,{className:`h-4 w-4 text-primary`}),(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`activity:ctxEditor.contextWindowEditor`)}),i&&(0,Z.jsxs)(`span`,{className:`text-[10px] font-mono text-muted-foreground/60 ml-2`,children:[`rev `,i.slice(0,8),`…`]})]}),(0,Z.jsx)(`button`,{type:`button`,onClick:t,disabled:b,className:`p-1.5 rounded-md hover:bg-accent hover:text-accent-foreground transition-colors disabled:opacity-40`,"aria-label":n(`common:action.close`),children:(0,Z.jsx)(St,{className:`h-4 w-4`})})]}),h&&(0,Z.jsxs)(`div`,{role:`status`,className:`mx-4 mt-3 flex items-start gap-2 rounded-md border border-warning/40 bg-warning/10 p-3 text-xs text-warning`,children:[(0,Z.jsx)(Kr,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,Z.jsx)(`span`,{children:n(`activity:ctxEditor.providerLimitDecreased`,{previous:Yh(h.previousMaxContext),current:Yh(h.maxContext)})})]}),o&&(0,Z.jsxs)(`div`,{className:`grid grid-cols-4 gap-2 px-4 py-2 border-b bg-muted/20 text-[11px] shrink-0`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground/60`,children:n(`activity:ctxEditor.system`)}),(0,Z.jsx)(`span`,{className:`font-mono font-medium`,children:Yh(o.systemPromptTokens)})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Z.jsxs)(`span`,{className:`text-muted-foreground/60`,children:[`Tools (`,o.toolCount,`)`]}),(0,Z.jsx)(`span`,{className:`font-mono font-medium`,children:Yh(o.toolSchemaTokens)})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground/60`,children:n(`activity:ctxEditor.messages`)}),(0,Z.jsx)(`span`,{className:`font-mono font-medium`,children:Yh(o.messageTokens)})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground/60`,children:n(`activity:ctxEditor.total`)}),(0,Z.jsx)(`span`,{className:`font-mono font-medium text-primary`,children:Yh(o.totalTokens)})]})]}),r===`loading_snapshot`&&(0,Z.jsxs)(`div`,{className:`flex items-center justify-center gap-2 text-sm text-muted-foreground py-12`,children:[(0,Z.jsx)(wt,{className:`h-4 w-4 animate-spin`}),n(`activity:ctxEditor.loadingContextSnapshot`)]}),r!==`loading_snapshot`&&a.length===0&&!f&&(0,Z.jsxs)(`div`,{className:`flex flex-1 min-h-0 flex-col items-center justify-center gap-2 px-6 py-12 text-center text-sm text-muted-foreground`,children:[(0,Z.jsx)(tn,{className:`h-5 w-5 text-muted-foreground/60`}),(0,Z.jsx)(`p`,{children:n(`activity:ctxEditor.emptyConversation`)})]}),f&&r===`apply_failed`&&(0,Z.jsx)(`div`,{className:`m-4 rounded-md bg-destructive/10 border border-destructive/20 p-3 text-sm text-destructive`,children:f}),r===`applied_success`&&d&&(0,Z.jsxs)(`div`,{className:`m-4 rounded-md bg-success/10 border border-success/20 p-3 text-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-success font-medium`,children:[(0,Z.jsx)($t,{className:`h-4 w-4`}),`Context updated: `,d.before.messages,` → `,d.after.messages,` `,`messages`]}),(0,Z.jsxs)(`div`,{className:`mt-1 text-muted-foreground text-xs`,children:[`Saved`,` `,Yh(d.before.fullRequestTokens-d.after.fullRequestTokens),` `,`tokens`,d.removed.toolUses.length>0&&` · ${d.removed.toolUses.length} tool calls repaired`]})]}),u?.conflict&&(0,Z.jsxs)(`div`,{className:`m-4 rounded-md bg-warning/10 border border-warning/20 p-3 text-sm text-warning`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 font-medium`,children:[(0,Z.jsx)(Kr,{className:`h-4 w-4`}),u.conflict.code===`CONTEXT_REVISION_CONFLICT`?`Context changed while editor was open.`:`Agent is currently running.`]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs opacity-80`,children:u.conflict.message})]}),r!==`loading_snapshot`&&a.length>0&&(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 space-y-3 overflow-y-auto overscroll-contain bg-muted/10 p-4`,children:a.map(e=>(0,Z.jsx)($h,{index:e.index,role:e.role,tokens:e.tokens,content:s[e.index]?.content??``,blockCount:e.blockCount,warnings:e.warnings,markedForRemoval:c.has(e.index),markedRanges:l.filter(t=>t.messageIndex===e.index),disabled:b,onToggle:()=>p.getState().toggleRemoveMessage(e.index),onMarkRange:(t,n,r)=>p.getState().markRangeForRemoval({messageIndex:e.index,...t===void 0?{}:{blockIndex:t},start:n,end:r})},e.index))}),u?.ok===!1&&u.validationErrors.length>0&&(0,Z.jsxs)(`div`,{className:`border-t px-4 py-2 bg-destructive/5 shrink-0`,children:[(0,Z.jsxs)(`div`,{className:`text-[11px] font-medium text-destructive mb-1`,children:[`Validation errors (`,u.validationErrors.length,`)`]}),u.validationErrors.slice(0,5).map((e,t)=>(0,Z.jsxs)(`div`,{className:`text-[10px] text-destructive/80 font-mono`,children:[e.path,`: `,e.message]},t))]}),u?.ok&&u.repair.changed&&(0,Z.jsx)(`div`,{className:`border-t px-4 py-2 bg-warning/5 shrink-0`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] text-warning`,children:[(0,Z.jsx)(at,{className:`h-3 w-3`}),(0,Z.jsx)(`span`,{children:n(`activity:ctxEditor.repairPreviewWillRemove`)}),u.repair.removedToolUses.length>0&&(0,Z.jsxs)(`span`,{children:[u.repair.removedToolUses.length,` orphan tool_use(s)`]}),u.repair.removedToolResults.length>0&&(0,Z.jsxs)(`span`,{children:[u.repair.removedToolResults.length,` orphan tool_result(s)`]}),u.repair.removedMessages>0&&(0,Z.jsxs)(`span`,{children:[u.repair.removedMessages,` empty message(s)`]})]})}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-t px-4 py-3 shrink-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] text-muted-foreground`,children:[x&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(vr,{className:`h-3 w-3 text-destructive`}),(0,Z.jsxs)(`span`,{children:[c.size,` message`,c.size===1?``:`s`,` and`,` `,l.length,` range`,l.length===1?``:`s`,` marked`]})]}),m&&(0,Z.jsxs)(`span`,{className:`flex items-center gap-1 text-warning`,children:[(0,Z.jsx)(He,{className:`h-3 w-3`}),n(`activity:ctxEditor.agentRunningApplyDisabled`)]})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[x&&(0,Z.jsx)(`button`,{type:`button`,onClick:()=>p.getState().clearRemovals(),className:`text-[11px] text-muted-foreground hover:text-foreground transition-colors`,disabled:b,children:n(`activity:ctxEditor.clear`)}),(0,Z.jsxs)(`button`,{type:`button`,onClick:v,disabled:!C,className:G(`flex items-center gap-1.5 rounded-md px-3 py-1.5 text-[11px] font-medium transition-colors`,C?`bg-secondary text-secondary-foreground hover:bg-secondary/80`:`bg-muted text-muted-foreground/40 cursor-not-allowed`),children:[r===`validating`?(0,Z.jsx)(wt,{className:`h-3 w-3 animate-spin`}):(0,Z.jsx)(tn,{className:`h-3 w-3`}),`Validate`]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:y,disabled:!S,className:G(`flex items-center gap-1.5 rounded-md px-3 py-1.5 text-[11px] font-medium transition-colors`,S?`bg-primary text-primary-foreground hover:bg-primary/90`:`bg-muted text-muted-foreground/40 cursor-not-allowed`),children:[r===`applying`?(0,Z.jsx)(wt,{className:`h-3 w-3 animate-spin`}):(0,Z.jsx)($t,{className:`h-3 w-3`}),`Apply Changes`]})]})]})]})})}function ng(e,t){if(!e)return`reset time unknown`;let n=Math.max(0,Math.ceil((e-t)/1e3));if(n===0)return`rechecking now`;if(n<60)return`${n}s`;let r=Math.floor(n/60);return r<60?`${r}m ${n%60}s`:`${Math.floor(r/60)}h ${r%60}m`}function rg(e,t){if(!e)return``;let n=Math.max(0,Math.floor((t-e)/1e3));if(n<60)return`${n}s ago`;let r=Math.floor(n/60);return r<60?`${r}m ago`:`${Math.floor(r/60)}h ${r%60}m ago`}var ig=/Sibling quarantine:.*?\bon\s+([^\s/]+\/\S+)/;function ag(e){return ig.exec(e.lastErrorMessage??``)?.[1]??null}function og(){let{t:e}=H(),t=ka(e=>e.entries);ka(e=>e.summary);let n=ka(e=>e.removeEntry),r=ka(e=>e.audit),i=W(e=>e.modelAvailabilitySchedule),[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(null),[l,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(Date.now()),p=(0,X.useMemo)(()=>Object.values(t).sort((e,t)=>(e.stateExpiresAt??0)-(t.stateExpiresAt??0)),[t]),m=(0,X.useMemo)(()=>p.filter(e=>e.state!==`healthy`),[p]),h=(0,X.useMemo)(()=>Yd(i,new Date(d)),[i,d]),g=(0,X.useCallback)(()=>{V().getProviderStatus()},[]),_=(0,X.useCallback)(()=>{u(e=>{let t=!e;return t&&V().getProviderAuditHistory(20),t})},[]),v=(0,X.useCallback)((e,t)=>{V().retryProviderModel(e,t),n(e,t)},[n]),y=(0,X.useCallback)((e,t)=>{V().clearProviderStatus(e,t),n(e,t)},[n]);if((0,X.useEffect)(()=>{if(m.length===0&&h.length===0)return;let e=window.setInterval(()=>f(Date.now()),1e3);return()=>window.clearInterval(e)},[h.length,m.length]),(0,X.useEffect)(()=>{a&&g()},[a,g]),m.length===0&&h.length===0)return null;let b=m.filter(e=>e.state===`blocked`).length,x=m.length-b;return s&&t[s],(0,Z.jsxs)(`div`,{className:`mx-auto mb-2 max-w-6xl rounded-lg border border-warning/25 bg-warning/5 text-xs`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-2 text-left hover:bg-warning/5`,onClick:()=>o(e=>!e),"aria-expanded":a,children:[(0,Z.jsx)(Kr,{className:`h-3.5 w-3.5 text-warning`}),(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,children:e(`activity:providerWait.providerModelAvailability`)}),(0,Z.jsxs)(`span`,{className:`text-muted-foreground`,children:[b,` blocked · `,x,` degraded · `,h.length,` scheduled`]}),(0,Z.jsx)(`button`,{type:`button`,className:`ml-auto inline-flex items-center gap-1 text-muted-foreground transition-colors hover:text-foreground`,onClick:e=>{e.stopPropagation(),g()},title:e(`activity:providerWait.refreshStatus`),children:(0,Z.jsx)(xi,{className:`h-3 w-3`})}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:a?`Hide`:`Details`})]}),a&&(0,Z.jsxs)(`div`,{className:`border-t border-warning/15 px-3 py-2`,children:[m.map(t=>{let n=`${t.providerId}\u0000${t.model}`,r=s===n,i=ag(t);return(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`button`,{type:`button`,className:`flex flex-wrap cursor-pointer items-center gap-x-2 gap-y-1 py-1.5 hover:bg-warning/5`,onClick:()=>c(r?null:n),children:[t.state===`blocked`?(0,Z.jsx)(Pi,{className:`h-3.5 w-3.5 text-warning`}):(0,Z.jsx)($t,{className:`h-3.5 w-3.5 text-warning`}),(0,Z.jsxs)(`code`,{className:`text-foreground`,children:[t.providerId,`/`,t.model]}),(0,Z.jsx)(`span`,{className:`rounded bg-warning/10 px-1.5 py-0.5 text-warning`,children:t.state}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:t.reason.replaceAll(`_`,` `)}),i&&(0,Z.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-muted-foreground`,children:[`via `,i]}),(0,Z.jsx)(`span`,{className:`ml-auto tabular-nums text-muted-foreground`,children:ng(t.stateExpiresAt,d)})]}),r&&(0,Z.jsxs)(`div`,{className:`ml-6 mb-2 rounded border border-border/50 bg-background/50 p-2`,children:[t.lastErrorMessage&&(0,Z.jsxs)(`div`,{className:`mb-1.5 text-destructive`,children:[(0,Z.jsxs)(`span`,{className:`text-muted-foreground`,children:[e(`activity:providerWait.lastError`),` `]}),t.lastErrorMessage.slice(0,300)]}),(0,Z.jsxs)(`div`,{className:`mb-1.5 flex flex-wrap gap-x-3 gap-y-0.5 text-muted-foreground`,children:[t.totalFailures!==void 0&&(0,Z.jsxs)(`span`,{children:[`failures: `,t.totalFailures]}),t.rateLimitHits!==void 0&&t.rateLimitHits>0&&(0,Z.jsxs)(`span`,{children:[`rate-limits: `,t.rateLimitHits]}),t.consecutiveFailures!==void 0&&(0,Z.jsxs)(`span`,{children:[`streak: `,t.consecutiveFailures]}),t.lastErrorStatus!==void 0&&(0,Z.jsxs)(`span`,{children:[`HTTP: `,t.lastErrorStatus]}),t.lastSessionId&&(0,Z.jsxs)(`span`,{children:[`session: `,t.lastSessionId.slice(0,12),`…`]}),t.lastAgentId&&(0,Z.jsxs)(`span`,{children:[`agent: `,t.lastAgentId.slice(0,16),`…`]}),t.lastFailureAt&&(0,Z.jsx)(`span`,{children:rg(t.lastFailureAt,d)})]}),t.recentErrors&&t.recentErrors.length>0&&(0,Z.jsxs)(`details`,{className:`mb-1.5`,children:[(0,Z.jsxs)(`summary`,{className:`cursor-pointer text-muted-foreground hover:text-foreground`,children:[`Error history (`,t.recentErrors.length,`)`]}),(0,Z.jsx)(`div`,{className:`mt-1 max-h-32 overflow-y-auto text-[11px] text-muted-foreground`,children:t.recentErrors.map((e,t)=>(0,Z.jsxs)(`div`,{className:`flex gap-2 border-b border-border/20 py-0.5`,children:[(0,Z.jsx)(`span`,{className:`shrink-0 tabular-nums text-warning/70`,children:e.kind}),(0,Z.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[`HTTP `,e.status]}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.message.slice(0,200)}),(0,Z.jsx)(`span`,{className:`ml-auto shrink-0 tabular-nums`,children:rg(e.timestamp,d)})]},t))})]}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded border border-border bg-background px-2 py-1 text-[11px] font-medium text-foreground transition-colors hover:bg-accent`,onClick:()=>v(t.providerId,t.model),children:[(0,Z.jsx)(Tn,{className:`h-3 w-3`}),e(`activity:providerWait.reopenHalfOpenProbe`)]}),(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded border border-border bg-background px-2 py-1 text-[11px] font-medium text-muted-foreground transition-colors hover:text-foreground`,onClick:()=>y(t.providerId,t.model),children:[(0,Z.jsx)(vr,{className:`h-3 w-3`}),e(`activity:providerWait.clearTracking`)]})]})]})]},n)}),h.map(e=>(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 py-1.5`,children:[(0,Z.jsx)(Pi,{className:`h-3.5 w-3.5 text-info`}),(0,Z.jsx)(`code`,{className:`text-foreground`,children:Jd(e)}),(0,Z.jsx)(`span`,{className:`rounded bg-info/10 px-1.5 py-0.5 text-info`,children:`scheduled`}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:e.label??`calendar blackout`}),(0,Z.jsxs)(`span`,{className:`ml-auto tabular-nums text-muted-foreground`,children:[e.start,`–`,e.end,` · `,e.timezone??`local time`]})]},e.id)),(0,Z.jsxs)(`button`,{type:`button`,className:`mt-1 flex w-full items-center gap-2 border-t border-border/30 py-1.5 text-left hover:bg-warning/5`,onClick:_,"aria-expanded":l,children:[(0,Z.jsx)(Pi,{className:`h-3.5 w-3.5 text-warning`}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:providerWait.recentBlockOpenEvents`,{count:r.length})}),(0,Z.jsx)(`span`,{className:`ml-auto text-muted-foreground`,children:l?`Hide`:`Show`})]}),l&&(0,Z.jsx)(`div`,{className:`pt-1`,children:r.length===0?(0,Z.jsx)(`div`,{className:`py-1 text-muted-foreground`,children:e(`activity:providerWait.noBlockOpenEventsYet`)}):r.map((e,t)=>{let n=e.to!==`blocked`,r=[e.error?.sessionId,e.error?.agentId].filter(e=>typeof e==`string`&&e.length>0).map(e=>`${e.slice(0,12)}…`).join(` / `);return(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5 py-0.5`,children:[(0,Z.jsx)(`span`,{className:`shrink-0 tabular-nums text-muted-foreground`,children:rg(e.ts,d)}),(0,Z.jsxs)(`code`,{className:`text-foreground`,children:[e.providerId,`/`,e.model]}),(0,Z.jsxs)(`span`,{className:n?`text-info`:`text-warning`,children:[e.from,` → `,e.to]}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:e.reason.replaceAll(`_`,` `)}),e.error&&(0,Z.jsxs)(`span`,{className:`text-destructive`,children:[e.error.kind,e.error.status==null?``:` ${e.error.status}`]}),r&&(0,Z.jsx)(`span`,{className:`ml-auto text-muted-foreground`,children:r})]},`${e.ts}-${t}`)})}),(0,Z.jsx)(`div`,{className:`mt-1 text-[11px] text-muted-foreground`,children:e(`activity:providerWait.wrongstackRoutesAroundActiveSchedulesAnd`)})]})]})}var sg=`
|
|
99
99
|
::highlight(chat-search) { background-color: hsl(var(--primary) / 0.3); color: inherit; }
|
|
100
100
|
::highlight(chat-search-active) { background-color: hsl(var(--primary) / 0.85); color: hsl(var(--primary-foreground)); }
|
|
101
101
|
`;function cg(e){return e.thinkingLog?[e.content,e.thinkingLog.text].filter(Boolean).join(`
|
|
102
102
|
`):e.role===`tool`?[e.toolName??``,e.toolResult??``,JSON.stringify(e.toolInput??``)].join(`
|
|
103
|
-
`):e.content}function lg(){let{t:e}=H(),t=K(e=>e.searchOpen),n=K(e=>e.setSearchOpen),r=K(e=>e.searchQuery),i=K(e=>e.setSearchQuery),a=q(e=>e.messages),o=K(e=>e.requestScrollToMessage),s=K(e=>e.setSearchActiveMessageId),c=(0,X.useRef)(null),[l,u]=(0,X.useState)(0),[d,f]=(0,X.useState)(0);(0,X.useEffect)(()=>{t&&requestAnimationFrame(()=>c.current?.focus())},[t]);let p=()=>{n(!1),requestAnimationFrame(()=>document.querySelector(`textarea`)?.focus())};(0,X.useEffect)(()=>{let e=document.createElement(`style`);return e.textContent=sg,document.head.appendChild(e),()=>{document.head.removeChild(e)}},[]);let m=(0,X.useMemo)(()=>{let e=r.trim().toLowerCase();return e?a.filter(t=>cg(t).toLowerCase().includes(e)).map(e=>e.id):[]},[a,r]);(0,X.useEffect)(()=>{l>=m.length&&u(0)},[m,l]),(0,X.useEffect)(()=>{s(t&&r.trim()?m[l]??null:null)},[t,r,m,l,s]),(0,X.useEffect)(()=>{let e=window,n=e.CSS?.highlights,i=e.Highlight;if(!n||!i)return;let a=()=>{n.delete(`chat-search`),n.delete(`chat-search-active`)},o=r.trim();if(!o||!t){a();return}let s=o.toLowerCase(),c=[],u=[],d=m[l];for(let e of document.querySelectorAll(`[data-message-id]`)){let t=e.dataset.messageId===d,n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),r=n.nextNode();for(;r;){let e=r.nodeValue??``;if(e.length>0){let n=e.toLowerCase(),i=0;for(;i<=n.length-s.length;){let e=n.indexOf(s,i);if(e===-1)break;let a=document.createRange();a.setStart(r,e),a.setEnd(r,e+s.length),c.push(a),t&&u.push(a),i=e+s.length}}r=n.nextNode()}}return c.length>0?n.set(`chat-search`,new i(...c)):n.delete(`chat-search`),u.length>0?n.set(`chat-search-active`,new i(...u)):n.delete(`chat-search-active`),a},[r,m,l,t,d]);let h=m[l];if((0,X.useEffect)(()=>{if(!h)return;o(h);let e=0,t=requestAnimationFrame(function n(){f(e=>e+1),++e<3&&(t=requestAnimationFrame(n))});return()=>cancelAnimationFrame(t)},[h,o]),!t)return null;let g=e=>{m.length!==0&&u(t=>(t+e+m.length)%m.length)};return(0,Z.jsx)(`div`,{className:`absolute top-2 right-4 z-30 w-[28rem] max-w-[calc(100%-2rem)] rounded-lg border bg-popover shadow-xl`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[(0,Z.jsx)(vn,{className:`h-4 w-4 text-muted-foreground shrink-0`}),(0,Z.jsx)(`input`,{ref:c,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Escape`?(e.preventDefault(),p()):e.key===`Enter`?(e.preventDefault(),g(e.shiftKey?-1:1)):e.key===`ArrowDown`?(e.preventDefault(),g(1)):e.key===`ArrowUp`&&(e.preventDefault(),g(-1))},placeholder:e(`activity:search.placeholder`),className:`flex-1 bg-transparent outline-none text-sm placeholder:text-muted-foreground`}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums shrink-0`,children:m.length===0?r?`0`:``:`${l+1} / ${m.length}`}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>g(-1),disabled:m.length===0,className:G(`p-1 rounded hover:bg-muted disabled:opacity-30 disabled:cursor-not-allowed`),title:e(`activity:search.prevHit`),"aria-label":e(`activity:search.prevHit`),children:(0,Z.jsx)(ai,{className:`h-3.5 w-3.5`})}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>g(1),disabled:m.length===0,className:G(`p-1 rounded hover:bg-muted disabled:opacity-30 disabled:cursor-not-allowed`),title:e(`activity:search.nextHit`),"aria-label":e(`activity:search.nextHit`),children:(0,Z.jsx)(qn,{className:`h-3.5 w-3.5`})}),(0,Z.jsx)(`button`,{type:`button`,onClick:p,className:`p-1 rounded hover:bg-muted text-muted-foreground`,title:e(`activity:search.close`),"aria-label":e(`activity:search.close`),children:(0,Z.jsx)(St,{className:`h-3.5 w-3.5`})})]})})}var ug={file:{color:`#60a5fa`},edit:{color:`#fbbf24`},search:{color:`#a78bfa`},folder:{color:`#38bdf8`},terminal:{color:`#67e8f9`},web:{color:`#34d399`},git:{color:`#a3e635`},tree:{color:`#22d3ee`},code:{color:`#818cf8`},test:{color:`#4ade80`},package:{color:`#f472b6`},document:{color:`#94a3b8`},scaffold:{color:`#c084fc`},todo:{color:`#facc15`},plan:{color:`#2dd4bf`},task:{color:`#5eead4`},meta:{color:`#cbd5e1`},index:{color:`#06b6d4`},json:{color:`#eab308`},diff:{color:`#93c5fd`},logs:{color:`#a3a3a3`},settings:{color:`#9ca3af`},brain:{color:`#e879f9`},fallback:{color:`#9ca3af`}},dg={read:`file`,cat:`file`,view:`file`,write:`file`,create:`file`,edit:`edit`,replace:`edit`,str_replace:`edit`,multi_edit:`edit`,patch:`edit`,grep:`search`,search:`search`,rg:`search`,ripgrep:`search`,glob:`folder`,find:`search`,folder:`folder`,ls:`folder`,list:`folder`,set_working_dir:`folder`,tree:`tree`,bash:`terminal`,shell:`terminal`,sh:`terminal`,exec:`terminal`,run:`terminal`,command:`terminal`,fetch:`web`,web_fetch:`web`,web_search:`web`,git:`git`,diff:`diff`,lint:`code`,format:`settings`,typecheck:`code`,language_info:`code`,language:`code`,language_package:`package`,test:`test`,install:`package`,outdated:`package`,audit:`package`,document:`document`,scaffold:`scaffold`,todo:`todo`,plan:`plan`,task:`task`,json:`json`,index:`index`,logs:`logs`,mode:`meta`,tool_search:`meta`,tool_use:`meta`,batch_tool_use:`meta`,tool_help:`meta`,remember:`brain`,forget:`brain`,search_memory:`brain`,find_related_memories:`brain`,memory_for_file:`brain`,memory_for_path:`brain`,memory_search:`brain`,memory_graph:`brain`,memory_verify:`brain`,memory_hygiene:`brain`,memory_candidates:`brain`,lsp_diagnostics:`code`,lsp_definition:`search`,lsp_completion:`code`,lsp_rename:`edit`,"codebase-lsp-search":`index`};function fg(e){return e?dg[e.toLowerCase()]??`fallback`:`fallback`}var pg={file:tn,edit:ft,search:vn,folder:Rt,terminal:it,web:Bn,git:Vi,tree:Pe,code:on,test:rt,package:Bi,document:mn,scaffold:Cr,todo:yt,plan:Ze,task:Yt,meta:li,index:$n,json:Pn,diff:qi,logs:Jr,settings:kt,brain:lr,fallback:li};function mg(e){let t=fg(e);return{Icon:pg[t],color:ug[t].color}}var hg={file:`file read/write`,edit:`file editing`,search:`search & grep`,folder:`folder navigation`,terminal:`shell commands`,web:`web fetch`,git:`git operations`,tree:`directory tree`,code:`code quality`,test:`testing`,package:`package management`,document:`documentation`,scaffold:`project scaffolding`,todo:`todo tracking`,plan:`planning`,task:`task management`,meta:`tool orchestration`,index:`code indexing`,json:`JSON data`,diff:`diff & patch`,logs:`log viewing`,settings:`configuration`,brain:`memory`,fallback:`external tool`};function gg(e){let t=fg(e),n=_g(ug[t].color);return`${hg[t]} — ${n}`}function _g(e){return{"#60a5fa":`blue`,"#fbbf24":`amber`,"#a78bfa":`violet`,"#38bdf8":`sky`,"#67e8f9":`cyan-light`,"#a3e635":`lime`,"#34d399":`emerald`,"#22d3ee":`cyan`,"#818cf8":`indigo`,"#4ade80":`green`,"#f472b6":`pink`,"#94a3b8":`slate`,"#c084fc":`purple`,"#facc15":`yellow`,"#2dd4bf":`teal`,"#5eead4":`teal-light`,"#cbd5e1":`slate-light`,"#06b6d4":`cyan-dark`,"#eab308":`yellow-dark`,"#93c5fd":`blue-light`,"#a3a3a3":`neutral`,"#9ca3af":`gray`,"#e879f9":`fuchsia`}[e]??`colored`}function vg(){return{started:0,ok:0,failed:0,totalMs:0}}function yg(e,t){e.started+=t.started,e.ok+=t.ok,e.failed+=t.failed,e.totalMs+=t.totalMs}function bg(e,t){let n=e+t;return n>0?e/n*100:null}function xg(e){return e===null?`--`:`${e.toFixed(0)}%`}function Sg(e){return e<=0?`--`:e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(1)}s`}function Cg(e){return{bash:`Shell command`,cat:`Read file`,edit:`Edit file`,glob:`Find files`,grep:`Search text`,read:`Read file`,web_fetch:`Fetch URL`,web_search:`Web search`,write:`Write file`}[e.toLowerCase()]||e.replace(/^mcp__/,``).replace(/__/g,` · `).replace(/[_-]+/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function wg({ok:e,failed:t,inFlight:n}){let r=Math.max(1,e+t+n);return(0,Z.jsxs)(`span`,{className:`relative inline-block h-2 w-full min-w-16 overflow-hidden rounded-full bg-muted/60 align-middle ring-1 ring-inset ring-border/20`,children:[(0,Z.jsx)(`span`,{className:`absolute inset-y-0 left-0 bg-success transition-all duration-500`,style:{width:`${e/r*100}%`}}),(0,Z.jsx)(`span`,{className:`absolute inset-y-0 bg-destructive transition-all duration-500`,style:{left:`${e/r*100}%`,width:`${t/r*100}%`}})]})}function Tg({label:e,value:t,tone:n}){return(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col rounded-lg border border-border/50 bg-muted/20 px-2.5 py-2`,children:[(0,Z.jsx)(`span`,{className:`truncate text-[10px] uppercase tracking-wider text-muted-foreground`,children:e}),(0,Z.jsx)(`span`,{className:G(`font-mono text-sm font-bold tabular-nums`,n),children:t})]})}function Eg({name:e,bucket:t}){let n=t.ok+t.failed,r=n>0?t.totalMs/n:0,{Icon:i,color:a}=mg(e),o=Cg(e);return(0,Z.jsxs)(`div`,{className:`grid grid-cols-[minmax(9rem,1.15fr)_minmax(5rem,1fr)_3.5rem_4rem] items-center gap-x-3 gap-y-1 rounded-md px-2.5 py-2 text-xs transition-colors hover:bg-muted/50 sm:grid-cols-[minmax(11rem,1.2fr)_minmax(7rem,1.5fr)_3.5rem_3.5rem_4rem]`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`grid h-6 w-6 shrink-0 place-items-center rounded-md bg-background ring-1 ring-inset ring-border/50`,children:(0,Z.jsx)(i,{className:`h-3.5 w-3.5`,style:{color:a}})}),(0,Z.jsxs)(`span`,{className:`min-w-0`,children:[(0,Z.jsx)(`span`,{className:`block truncate font-medium text-foreground`,title:e,children:o}),(0,Z.jsx)(`span`,{className:`block truncate font-mono text-[10px] text-muted-foreground`,title:e,children:e})]})]}),(0,Z.jsx)(`div`,{className:`hidden sm:block`,children:(0,Z.jsx)(wg,{ok:t.ok,failed:t.failed,inFlight:0})}),(0,Z.jsxs)(`span`,{className:`text-right font-mono tabular-nums text-muted-foreground`,title:`Calls`,children:[t.started,`×`]}),(0,Z.jsx)(`span`,{className:G(`text-right font-mono tabular-nums`,t.failed>0?`text-destructive`:`text-success`),children:xg(bg(t.ok,t.failed))}),(0,Z.jsx)(`span`,{className:`text-right font-mono tabular-nums text-muted-foreground`,children:Sg(r)})]})}function Dg({open:e,onClose:t}){let{t:n}=H(),r=L(e=>e.sessions),i=K(e=>e.sessionNicknames),a=b(e=>e.entries),[o,s]=(0,X.useState)(!1);(0,X.useEffect)(()=>{if(!e){s(!1);return}requestAnimationFrame(()=>requestAnimationFrame(()=>s(!0)))},[e]),(0,X.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&t()};return document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[e,t]);let c=(0,X.useMemo)(()=>Object.values(r).sort((e,t)=>t.lastActivityAt-e.lastActivityAt),[r]),l=(0,X.useMemo)(()=>{let e=vg(),t=0,n=0,r=0;for(let i of c){for(let t of Object.values(i.perAgent))yg(e,t);t+=xe(i),n+=i.delegations.ok+i.delegations.failed,r+=i.delegations.failed}return{...e,inFlight:t,delegations:n,delegationFailures:r}},[c]),u=(0,X.useMemo)(()=>a.filter(e=>!(e.id in r)&&(e.toolCallCount??0)>0).slice(0,12),[a,r]);if(!e)return null;let d=c.length>0,f=bg(l.ok,l.failed);return(0,Z.jsx)(`div`,{className:G(`fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4 backdrop-blur-sm transition-opacity duration-200`,o?`opacity-100`:`opacity-0`),onClick:t,"data-testid":`tool-stats-modal`,children:(0,Z.jsxs)(`section`,{"aria-label":n(`chat:toolStats.title`,`Tool call statistics`),className:G(`flex max-h-[86vh] w-full max-w-4xl flex-col overflow-hidden rounded-xl border border-border/70 bg-card shadow-2xl transition-transform duration-200`,o?`scale-100`:`scale-95`),onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/60 px-4 py-3`,children:[(0,Z.jsx)(li,{className:`h-4 w-4 text-primary`}),(0,Z.jsx)(`h2`,{className:`text-sm font-semibold`,children:n(`chat:toolStats.title`,`Tool call statistics`)}),(0,Z.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:n(`chat:toolStats.liveScope`,`This page · live + closed sessions`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:t,className:`rounded p-1 text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground`,title:n(`common:action.close`,`Close`),children:(0,Z.jsx)(St,{className:`h-4 w-4`})})]}),(0,Z.jsxs)(`div`,{className:`flex-1 space-y-4 overflow-y-auto overscroll-contain p-4`,children:[(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-6`,children:[(0,Z.jsx)(Tg,{label:n(`chat:toolStats.calls`,`Calls`),value:l.started.toLocaleString()}),(0,Z.jsx)(Tg,{label:n(`chat:toolStats.ok`,`Success`),value:`${l.ok}`,tone:`text-success`}),(0,Z.jsx)(Tg,{label:n(`chat:toolStats.failed`,`Failed`),value:`${l.failed}`,tone:l.failed>0?`text-destructive`:void 0}),(0,Z.jsx)(Tg,{label:n(`chat:toolStats.successRate`,`Success rate`),value:xg(f),tone:f!==null&&f<80?`text-warning`:`text-success`}),l.inFlight>0&&(0,Z.jsx)(Tg,{label:n(`chat:toolStats.inFlight`,`In flight`),value:`${l.inFlight}`,tone:`text-info`}),(0,Z.jsx)(Tg,{label:n(`chat:toolStats.totalDuration`,`Tool time`),value:Sg(l.totalMs)})]}),(0,Z.jsx)(wg,{ok:l.ok,failed:l.failed,inFlight:l.inFlight}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`h3`,{className:`mb-1.5 flex items-center gap-1.5 text-xs font-bold uppercase tracking-wider text-foreground/80`,children:[(0,Z.jsx)(Pr,{className:`h-3.5 w-3.5 text-primary`}),n(`chat:toolStats.liveSessions`,`Open tabs`)]}),d?(0,Z.jsx)(`div`,{className:`space-y-2`,children:c.map(e=>(0,Z.jsx)(kg,{session:e,label:Og(e.sessionId,i)},e.sessionId))}):(0,Z.jsx)(`p`,{className:`rounded-lg border border-border/40 bg-muted/20 px-3 py-4 text-center text-xs text-muted-foreground`,children:n(`chat:toolStats.noLiveData`,`No tool calls recorded yet on this page. Run a prompt — stats appear here live, per tab.`)})]}),u.length>0&&(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`h3`,{className:`mb-1.5 flex items-center gap-1.5 text-xs font-bold uppercase tracking-wider text-foreground/80`,children:[(0,Z.jsx)(He,{className:`h-3.5 w-3.5 text-muted-foreground`}),n(`chat:toolStats.pastSessions`,`Earlier sessions`)]}),(0,Z.jsx)(`div`,{className:`space-y-0.5 rounded-lg border border-border/40 bg-muted/10 p-2`,children:u.map(e=>{let t=Math.max(0,(e.toolCallCount??0)-(e.toolErrorCount??0)),n=e.toolErrorCount??0;return(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1 text-xs rounded hover:bg-muted/40 transition-colors`,children:[(0,Z.jsx)(`span`,{className:`truncate flex-1 min-w-0`,title:e.id,children:e.title||e.id.slice(0,8)}),(0,Z.jsx)(wg,{ok:t,failed:n,inFlight:0}),(0,Z.jsxs)(`span`,{className:`tabular-nums text-muted-foreground w-12 text-right`,children:[e.toolCallCount,`×`]}),(0,Z.jsx)(`span`,{className:`tabular-nums text-success w-8 text-right`,children:t}),(0,Z.jsx)(`span`,{className:`tabular-nums text-destructive w-8 text-right`,children:n}),(0,Z.jsx)(`span`,{className:`tabular-nums w-10 text-right font-mono text-muted-foreground`,children:xg(bg(t,n))})]},e.id)})})]})]})]})})}function Og(e,t){return t[e]??`session ${e.slice(0,8)}`}function kg({session:e,label:t}){let{t:n}=H(),r=(0,X.useMemo)(()=>Object.entries(e.perTool).sort(([,e],[,t])=>t.started-e.started),[e.perTool]),i=(0,X.useMemo)(()=>Object.entries(e.perAgent),[e.perAgent]).filter(([e])=>e!==_e),a=e.perAgent[_e],o=(0,X.useMemo)(()=>{let t=vg();for(let n of Object.values(e.perAgent))yg(t,n);return t},[e.perAgent]),s=xe(e),c=e.delegations;return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/10 p-2.5`,children:[(0,Z.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate text-xs font-semibold`,title:e.sessionId,children:t}),s>0&&(0,Z.jsx)(`span`,{className:`rounded bg-info/10 px-1.5 py-0.5 font-mono text-[10px] text-info`,children:n(`chat:toolStats.running`,`{{count}} running`,{count:s})}),(0,Z.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono text-[10px] tabular-nums text-muted-foreground`,children:[xg(bg(o.ok,o.failed)),` · `,o.ok,`✓ `,o.failed,`✗`]}),(0,Z.jsx)(`span`,{className:`w-24 shrink-0`,children:(0,Z.jsx)(wg,{ok:o.ok,failed:o.failed,inFlight:s})})]}),(0,Z.jsxs)(`div`,{className:`overflow-hidden rounded-lg border border-border/40 bg-background/30`,children:[(0,Z.jsxs)(`div`,{className:`grid grid-cols-[minmax(9rem,1.15fr)_3.5rem_4rem] gap-x-3 border-b border-border/40 bg-muted/30 px-2.5 py-1.5 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground sm:grid-cols-[minmax(11rem,1.2fr)_minmax(7rem,1.5fr)_3.5rem_3.5rem_4rem]`,children:[(0,Z.jsx)(`span`,{children:n(`chat:toolStats.tool`,`Tool`)}),(0,Z.jsx)(`span`,{className:`hidden sm:block`,children:n(`chat:toolStats.outcome`,`Outcome`)}),(0,Z.jsx)(`span`,{className:`text-right`,children:n(`chat:toolStats.calls`,`Calls`)}),(0,Z.jsx)(`span`,{className:`text-right`,children:n(`chat:toolStats.successRate`,`Success rate`)}),(0,Z.jsx)(`span`,{className:`text-right`,children:n(`chat:toolStats.average`,`Avg.`)})]}),(0,Z.jsx)(`div`,{className:`divide-y divide-border/30`,children:r.map(([e,t])=>(0,Z.jsx)(Eg,{name:e,bucket:t},e))})]}),(i.length>0||c.started>0)&&(0,Z.jsxs)(`div`,{className:`mt-2 rounded border border-border/40 bg-background/40 p-2`,children:[(0,Z.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[10px] font-bold uppercase tracking-wider text-muted-foreground`,children:[(0,Z.jsx)(jr,{className:`h-3 w-3`}),n(`chat:toolStats.agentToAgent`,`Agent-to-agent`)]}),i.map(([e,t])=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 px-1 py-0.5 text-xs`,children:[(0,Z.jsx)(jr,{className:`h-3 w-3 shrink-0 text-info`}),(0,Z.jsx)(`span`,{className:`font-mono truncate flex-1 min-w-0`,title:e,children:e}),(0,Z.jsx)(wg,{ok:t.ok,failed:t.failed,inFlight:0}),(0,Z.jsx)(`span`,{className:`tabular-nums text-success w-8 text-right`,children:t.ok}),(0,Z.jsx)(`span`,{className:`tabular-nums text-destructive w-8 text-right`,children:t.failed})]},e)),c.started>0&&(0,Z.jsxs)(`div`,{className:`mt-1 flex items-center gap-1.5 px-1 text-[11px] text-muted-foreground`,children:[(0,Z.jsx)(Kr,{className:G(`h-3 w-3`,c.failed>0?`text-destructive`:`text-success`)}),n(`chat:toolStats.delegations`,`{{count}} delegated run(s)`,{count:c.ok+c.failed}),c.failed>0&&(0,Z.jsx)(`span`,{className:`text-destructive`,children:n(`chat:toolStats.delegationFailed`,`{{count}} failed`,{count:c.failed})}),(0,Z.jsx)(`span`,{className:`ml-auto tabular-nums`,children:n(`chat:toolStats.delegateToolCalls`,`{{count}} tools inside`,{count:c.toolCalls})})]})]}),a&&i.length>0&&(0,Z.jsx)(`p`,{className:`mt-1 px-1 text-[10px] text-muted-foreground/70`,children:n(`chat:toolStats.leaderLine`,`Leader: {{ok}}✓ {{failed}}✗`,{ok:a.ok,failed:a.failed})})]})}function Ag(e){let{client:t,slug:n}=e,r=!1,i=()=>{},a=()=>{},o=t=>{r||(r=!0,clearTimeout(s),i(),a(),e.onSettle(t))},s=setTimeout(()=>o(`error`),e.timeoutMs??8e3),c=()=>{a=t.on(`prompts.content`,r=>{let i=r.payload;if(i?.slug!==n)return;let a=i.content?.trim()??``;if(!i.found||!a){o(`error`);return}let s=e.compose(a),c=t.sendMessage(s);e.onSent(c,s),t.send({type:`prompts.used`,payload:{slug:n}}),o(`idle`)}),t.send({type:`prompts.content`,payload:{slug:n}})};if(!e.requireSoloSession||!e.subagentsAllowed){c();return}i=t.on(`prefs.updated`,t=>{let n=t.payload;if(!(e.sessionId&&n.sessionId!==e.sessionId)&&typeof n.subagentsAllowed==`boolean`){if(n.subagentsAllowed!==!1){o(`error`);return}i(),i=()=>{},c()}}),e.setPrefs({subagentsAllowed:!1}),t.send({type:`prefs.update`,payload:{subagentsAllowed:!1,...e.sessionId?{sessionId:e.sessionId}:{}}})}var jg=`elite-bug-hunter`;function Mg(e){let t=[],n=e=>{for(let r of e)r.type===`directory`&&(r.ignored||(t.push(r.path),r.children&&n(r.children)))};return n(e),t.sort((e,t)=>e.localeCompare(t))}function Ng(){let{t:e}=H(),{projectName:n,cwd:r}=N(Me(e=>({projectName:e.projectName,cwd:e.cwd}))),{provider:i,model:a}=R(Me(e=>({provider:e.provider,model:e.model}))),o=R(e=>e.wsConnected),s=R(e=>e.wsUrl),c=t(e=>e.tree),l=N(e=>e.session?.id),{subagentsAllowed:u,setPrefs:d}=W(Me(e=>({subagentsAllowed:e.subagentsAllowed,setPrefs:e.set}))),{addMessage:f,setLoading:p}=q(Me(e=>({addMessage:e.addMessage,setLoading:e.setLoading}))),[m,h]=(0,X.useState)(void 0),[g,_]=(0,X.useState)(`idle`),[v,y]=(0,X.useState)(``),[b,x]=(0,X.useState)(1),[S,C]=(0,X.useState)(`idle`),[w,T]=(0,X.useState)(``),[E,D]=(0,X.useState)(`ratchet`),[O,k]=(0,X.useState)(``),A=Mg(c);(0,X.useEffect)(()=>{if(!o)return;let e=V(s),t=e.on(`providers.saved`,e=>{let t=e.payload;h(t.providers?.length??0)});return e.listSavedProviders(),()=>{t()}},[o,s]),(0,X.useEffect)(()=>{o&&V(s).send({type:`files.tree`,payload:l?{sessionId:l}:{}})},[l,o,s]);let j=(0,X.useCallback)(()=>{let e=V(s);!e.isConnected||g===`loading`||(_(`loading`),Ag({client:e,slug:jg,requireSoloSession:!0,subagentsAllowed:u,sessionId:l,setPrefs:d,compose:e=>{let t=v?`${v} and all of its descendants`:`the whole project`;return ga(`${e}
|
|
103
|
+
`):e.content}function lg(){let{t:e}=H(),t=K(e=>e.searchOpen),n=K(e=>e.setSearchOpen),r=K(e=>e.searchQuery),i=K(e=>e.setSearchQuery),a=q(e=>e.messages),o=K(e=>e.requestScrollToMessage),s=K(e=>e.setSearchActiveMessageId),c=(0,X.useRef)(null),[l,u]=(0,X.useState)(0),[d,f]=(0,X.useState)(0);(0,X.useEffect)(()=>{t&&requestAnimationFrame(()=>c.current?.focus())},[t]);let p=()=>{n(!1),requestAnimationFrame(()=>document.querySelector(`textarea`)?.focus())};(0,X.useEffect)(()=>{let e=document.createElement(`style`);return e.textContent=sg,document.head.appendChild(e),()=>{document.head.removeChild(e)}},[]);let m=(0,X.useMemo)(()=>{let e=r.trim().toLowerCase();return e?a.filter(t=>cg(t).toLowerCase().includes(e)).map(e=>e.id):[]},[a,r]);(0,X.useEffect)(()=>{l>=m.length&&u(0)},[m,l]),(0,X.useEffect)(()=>{s(t&&r.trim()?m[l]??null:null)},[t,r,m,l,s]),(0,X.useEffect)(()=>{let e=window,n=e.CSS?.highlights,i=e.Highlight;if(!n||!i)return;let a=()=>{n.delete(`chat-search`),n.delete(`chat-search-active`)},o=r.trim();if(!o||!t){a();return}let s=o.toLowerCase(),c=[],u=[],d=m[l];for(let e of document.querySelectorAll(`[data-message-id]`)){let t=e.dataset.messageId===d,n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),r=n.nextNode();for(;r;){let e=r.nodeValue??``;if(e.length>0){let n=e.toLowerCase(),i=0;for(;i<=n.length-s.length;){let e=n.indexOf(s,i);if(e===-1)break;let a=document.createRange();a.setStart(r,e),a.setEnd(r,e+s.length),c.push(a),t&&u.push(a),i=e+s.length}}r=n.nextNode()}}return c.length>0?n.set(`chat-search`,new i(...c)):n.delete(`chat-search`),u.length>0?n.set(`chat-search-active`,new i(...u)):n.delete(`chat-search-active`),a},[r,m,l,t,d]);let h=m[l];if((0,X.useEffect)(()=>{if(!h)return;o(h);let e=0,t=requestAnimationFrame(function n(){f(e=>e+1),++e<3&&(t=requestAnimationFrame(n))});return()=>cancelAnimationFrame(t)},[h,o]),!t)return null;let g=e=>{m.length!==0&&u(t=>(t+e+m.length)%m.length)};return(0,Z.jsx)(`div`,{className:`absolute top-2 right-4 z-30 w-[28rem] max-w-[calc(100%-2rem)] rounded-lg border bg-popover shadow-xl`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[(0,Z.jsx)(vn,{className:`h-4 w-4 text-muted-foreground shrink-0`}),(0,Z.jsx)(`input`,{ref:c,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Escape`?(e.preventDefault(),p()):e.key===`Enter`?(e.preventDefault(),g(e.shiftKey?-1:1)):e.key===`ArrowDown`?(e.preventDefault(),g(1)):e.key===`ArrowUp`&&(e.preventDefault(),g(-1))},placeholder:e(`activity:search.placeholder`),className:`flex-1 bg-transparent outline-none text-sm placeholder:text-muted-foreground`}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums shrink-0`,children:m.length===0?r?`0`:``:`${l+1} / ${m.length}`}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>g(-1),disabled:m.length===0,className:G(`p-1 rounded hover:bg-muted disabled:opacity-30 disabled:cursor-not-allowed`),title:e(`activity:search.prevHit`),"aria-label":e(`activity:search.prevHit`),children:(0,Z.jsx)(ai,{className:`h-3.5 w-3.5`})}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>g(1),disabled:m.length===0,className:G(`p-1 rounded hover:bg-muted disabled:opacity-30 disabled:cursor-not-allowed`),title:e(`activity:search.nextHit`),"aria-label":e(`activity:search.nextHit`),children:(0,Z.jsx)(qn,{className:`h-3.5 w-3.5`})}),(0,Z.jsx)(`button`,{type:`button`,onClick:p,className:`p-1 rounded hover:bg-muted text-muted-foreground`,title:e(`activity:search.close`),"aria-label":e(`activity:search.close`),children:(0,Z.jsx)(St,{className:`h-3.5 w-3.5`})})]})})}var ug={file:{color:`#60a5fa`},edit:{color:`#fbbf24`},search:{color:`#a78bfa`},folder:{color:`#38bdf8`},terminal:{color:`#67e8f9`},web:{color:`#34d399`},git:{color:`#a3e635`},tree:{color:`#22d3ee`},code:{color:`#818cf8`},test:{color:`#4ade80`},package:{color:`#f472b6`},document:{color:`#94a3b8`},scaffold:{color:`#c084fc`},todo:{color:`#facc15`},plan:{color:`#2dd4bf`},task:{color:`#5eead4`},meta:{color:`#cbd5e1`},index:{color:`#06b6d4`},json:{color:`#eab308`},diff:{color:`#93c5fd`},logs:{color:`#a3a3a3`},settings:{color:`#9ca3af`},brain:{color:`#e879f9`},fallback:{color:`#9ca3af`}},dg={read:`file`,cat:`file`,view:`file`,write:`file`,create:`file`,edit:`edit`,replace:`edit`,str_replace:`edit`,multi_edit:`edit`,patch:`edit`,grep:`search`,search:`search`,rg:`search`,ripgrep:`search`,glob:`folder`,find:`search`,folder:`folder`,ls:`folder`,list:`folder`,set_working_dir:`folder`,tree:`tree`,bash:`terminal`,shell:`terminal`,sh:`terminal`,exec:`terminal`,run:`terminal`,command:`terminal`,fetch:`web`,web_fetch:`web`,web_search:`web`,git:`git`,diff:`diff`,lint:`code`,format:`settings`,typecheck:`code`,language_info:`code`,language:`code`,language_package:`package`,test:`test`,install:`package`,outdated:`package`,audit:`package`,document:`document`,scaffold:`scaffold`,todo:`todo`,plan:`plan`,task:`task`,json:`json`,index:`index`,logs:`logs`,mode:`meta`,tool_search:`meta`,tool_use:`meta`,batch_tool_use:`meta`,tool_help:`meta`,remember:`brain`,forget:`brain`,search_memory:`brain`,find_related_memories:`brain`,memory_for_file:`brain`,memory_for_path:`brain`,memory_search:`brain`,memory_graph:`brain`,memory_verify:`brain`,memory_hygiene:`brain`,memory_candidates:`brain`,lsp_diagnostics:`code`,lsp_definition:`search`,lsp_completion:`code`,lsp_rename:`edit`,"codebase-lsp-search":`index`};function fg(e){return e?dg[e.toLowerCase()]??`fallback`:`fallback`}var pg={file:tn,edit:ft,search:vn,folder:Rt,terminal:it,web:Bn,git:Vi,tree:Pe,code:on,test:rt,package:Bi,document:mn,scaffold:Cr,todo:yt,plan:Ze,task:Yt,meta:li,index:$n,json:Pn,diff:qi,logs:Jr,settings:kt,brain:lr,fallback:li};function mg(e){let t=fg(e);return{Icon:pg[t],color:ug[t].color}}var hg={file:`file read/write`,edit:`file editing`,search:`search & grep`,folder:`folder navigation`,terminal:`shell commands`,web:`web fetch`,git:`git operations`,tree:`directory tree`,code:`code quality`,test:`testing`,package:`package management`,document:`documentation`,scaffold:`project scaffolding`,todo:`todo tracking`,plan:`planning`,task:`task management`,meta:`tool orchestration`,index:`code indexing`,json:`JSON data`,diff:`diff & patch`,logs:`log viewing`,settings:`configuration`,brain:`memory`,fallback:`external tool`};function gg(e){let t=fg(e),n=_g(ug[t].color);return`${hg[t]} — ${n}`}function _g(e){return{"#60a5fa":`blue`,"#fbbf24":`amber`,"#a78bfa":`violet`,"#38bdf8":`sky`,"#67e8f9":`cyan-light`,"#a3e635":`lime`,"#34d399":`emerald`,"#22d3ee":`cyan`,"#818cf8":`indigo`,"#4ade80":`green`,"#f472b6":`pink`,"#94a3b8":`slate`,"#c084fc":`purple`,"#facc15":`yellow`,"#2dd4bf":`teal`,"#5eead4":`teal-light`,"#cbd5e1":`slate-light`,"#06b6d4":`cyan-dark`,"#eab308":`yellow-dark`,"#93c5fd":`blue-light`,"#a3a3a3":`neutral`,"#9ca3af":`gray`,"#e879f9":`fuchsia`}[e]??`colored`}function vg(){return{started:0,ok:0,failed:0,totalMs:0}}function yg(e,t){e.started+=t.started,e.ok+=t.ok,e.failed+=t.failed,e.totalMs+=t.totalMs}function bg(e,t){let n=e+t;return n>0?e/n*100:null}function xg(e){return e===null?`--`:`${e.toFixed(0)}%`}function Sg(e){return e<=0?`--`:e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(1)}s`}function Cg(e){return{bash:`Shell command`,cat:`Read file`,edit:`Edit file`,glob:`Find files`,grep:`Search text`,read:`Read file`,web_fetch:`Fetch URL`,web_search:`Web search`,write:`Write file`}[e.toLowerCase()]||e.replace(/^mcp__/,``).replace(/__/g,` · `).replace(/[_-]+/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function wg({ok:e,failed:t,inFlight:n}){let r=Math.max(1,e+t+n);return(0,Z.jsxs)(`span`,{className:`relative inline-block h-2 w-full min-w-16 overflow-hidden rounded-full bg-muted/60 align-middle ring-1 ring-inset ring-border/20`,children:[(0,Z.jsx)(`span`,{className:`absolute inset-y-0 left-0 bg-success transition-all duration-500`,style:{width:`${e/r*100}%`}}),(0,Z.jsx)(`span`,{className:`absolute inset-y-0 bg-destructive transition-all duration-500`,style:{left:`${e/r*100}%`,width:`${t/r*100}%`}})]})}function Tg({label:e,value:t,tone:n}){return(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col rounded-lg border border-border/50 bg-muted/20 px-2.5 py-2`,children:[(0,Z.jsx)(`span`,{className:`truncate text-[10px] uppercase tracking-wider text-muted-foreground`,children:e}),(0,Z.jsx)(`span`,{className:G(`font-mono text-sm font-bold tabular-nums`,n),children:t})]})}function Eg({name:e,bucket:t}){let n=t.ok+t.failed,r=n>0?t.totalMs/n:0,{Icon:i,color:a}=mg(e),o=Cg(e);return(0,Z.jsxs)(`div`,{className:`grid grid-cols-[minmax(9rem,1.15fr)_minmax(5rem,1fr)_3.5rem_4rem] items-center gap-x-3 gap-y-1 rounded-md px-2.5 py-2 text-xs transition-colors hover:bg-muted/50 sm:grid-cols-[minmax(11rem,1.2fr)_minmax(7rem,1.5fr)_3.5rem_3.5rem_4rem]`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`grid h-6 w-6 shrink-0 place-items-center rounded-md bg-background ring-1 ring-inset ring-border/50`,children:(0,Z.jsx)(i,{className:`h-3.5 w-3.5`,style:{color:a}})}),(0,Z.jsxs)(`span`,{className:`min-w-0`,children:[(0,Z.jsx)(`span`,{className:`block truncate font-medium text-foreground`,title:e,children:o}),(0,Z.jsx)(`span`,{className:`block truncate font-mono text-[10px] text-muted-foreground`,title:e,children:e})]})]}),(0,Z.jsx)(`div`,{className:`hidden sm:block`,children:(0,Z.jsx)(wg,{ok:t.ok,failed:t.failed,inFlight:0})}),(0,Z.jsxs)(`span`,{className:`text-right font-mono tabular-nums text-muted-foreground`,title:`Calls`,children:[t.started,`×`]}),(0,Z.jsx)(`span`,{className:G(`text-right font-mono tabular-nums`,t.failed>0?`text-destructive`:`text-success`),children:xg(bg(t.ok,t.failed))}),(0,Z.jsx)(`span`,{className:`text-right font-mono tabular-nums text-muted-foreground`,children:Sg(r)})]})}function Dg({open:e,onClose:t}){let{t:n}=H(),r=L(e=>e.sessions),i=K(e=>e.sessionNicknames),a=b(e=>e.entries),[o,s]=(0,X.useState)(!1);(0,X.useEffect)(()=>{if(!e){s(!1);return}requestAnimationFrame(()=>requestAnimationFrame(()=>s(!0)))},[e]),(0,X.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&t()};return document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[e,t]);let c=(0,X.useMemo)(()=>Object.values(r).sort((e,t)=>t.lastActivityAt-e.lastActivityAt),[r]),l=(0,X.useMemo)(()=>{let e=vg(),t=0,n=0,r=0;for(let i of c){for(let t of Object.values(i.perAgent))yg(e,t);t+=xe(i),n+=i.delegations.ok+i.delegations.failed,r+=i.delegations.failed}return{...e,inFlight:t,delegations:n,delegationFailures:r}},[c]),u=(0,X.useMemo)(()=>a.filter(e=>!(e.id in r)&&(e.toolCallCount??0)>0).slice(0,12),[a,r]);if(!e)return null;let d=c.length>0,f=bg(l.ok,l.failed);return(0,Z.jsx)(`div`,{className:G(`fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4 backdrop-blur-sm transition-opacity duration-200`,o?`opacity-100`:`opacity-0`),onClick:t,"data-testid":`tool-stats-modal`,children:(0,Z.jsxs)(`section`,{"aria-label":n(`chat:toolStats.title`,`Tool call statistics`),className:G(`flex max-h-[86vh] w-full max-w-4xl flex-col overflow-hidden rounded-xl border border-border/70 bg-card shadow-2xl transition-transform duration-200`,o?`scale-100`:`scale-95`),onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/60 px-4 py-3`,children:[(0,Z.jsx)(li,{className:`h-4 w-4 text-primary`}),(0,Z.jsx)(`h2`,{className:`text-sm font-semibold`,children:n(`chat:toolStats.title`,`Tool call statistics`)}),(0,Z.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:n(`chat:toolStats.liveScope`,`This page · live + closed sessions`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:t,className:`rounded p-1 text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground`,title:n(`common:action.close`,`Close`),children:(0,Z.jsx)(St,{className:`h-4 w-4`})})]}),(0,Z.jsxs)(`div`,{className:`flex-1 space-y-4 overflow-y-auto overscroll-contain p-4`,children:[(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-6`,children:[(0,Z.jsx)(Tg,{label:n(`chat:toolStats.calls`,`Calls`),value:l.started.toLocaleString()}),(0,Z.jsx)(Tg,{label:n(`chat:toolStats.ok`,`Success`),value:`${l.ok}`,tone:`text-success`}),(0,Z.jsx)(Tg,{label:n(`chat:toolStats.failed`,`Failed`),value:`${l.failed}`,tone:l.failed>0?`text-destructive`:void 0}),(0,Z.jsx)(Tg,{label:n(`chat:toolStats.successRate`,`Success rate`),value:xg(f),tone:f!==null&&f<80?`text-warning`:`text-success`}),l.inFlight>0&&(0,Z.jsx)(Tg,{label:n(`chat:toolStats.inFlight`,`In flight`),value:`${l.inFlight}`,tone:`text-info`}),(0,Z.jsx)(Tg,{label:n(`chat:toolStats.totalDuration`,`Tool time`),value:Sg(l.totalMs)})]}),(0,Z.jsx)(wg,{ok:l.ok,failed:l.failed,inFlight:l.inFlight}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`h3`,{className:`mb-1.5 flex items-center gap-1.5 text-xs font-bold uppercase tracking-wider text-foreground/80`,children:[(0,Z.jsx)(Pr,{className:`h-3.5 w-3.5 text-primary`}),n(`chat:toolStats.liveSessions`,`Open tabs`)]}),d?(0,Z.jsx)(`div`,{className:`space-y-2`,children:c.map(e=>(0,Z.jsx)(kg,{session:e,label:Og(e.sessionId,i)},e.sessionId))}):(0,Z.jsx)(`p`,{className:`rounded-lg border border-border/40 bg-muted/20 px-3 py-4 text-center text-xs text-muted-foreground`,children:n(`chat:toolStats.noLiveData`,`No tool calls recorded yet on this page. Run a prompt — stats appear here live, per tab.`)})]}),u.length>0&&(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`h3`,{className:`mb-1.5 flex items-center gap-1.5 text-xs font-bold uppercase tracking-wider text-foreground/80`,children:[(0,Z.jsx)(He,{className:`h-3.5 w-3.5 text-muted-foreground`}),n(`chat:toolStats.pastSessions`,`Earlier sessions`)]}),(0,Z.jsx)(`div`,{className:`space-y-0.5 rounded-lg border border-border/40 bg-muted/10 p-2`,children:u.map(e=>{let t=Math.max(0,(e.toolCallCount??0)-(e.toolErrorCount??0)),n=e.toolErrorCount??0;return(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1 text-xs rounded hover:bg-muted/40 transition-colors`,children:[(0,Z.jsx)(`span`,{className:`truncate flex-1 min-w-0`,title:e.id,children:e.title||e.id.slice(0,8)}),(0,Z.jsx)(wg,{ok:t,failed:n,inFlight:0}),(0,Z.jsxs)(`span`,{className:`tabular-nums text-muted-foreground w-12 text-right`,children:[e.toolCallCount,`×`]}),(0,Z.jsx)(`span`,{className:`tabular-nums text-success w-8 text-right`,children:t}),(0,Z.jsx)(`span`,{className:`tabular-nums text-destructive w-8 text-right`,children:n}),(0,Z.jsx)(`span`,{className:`tabular-nums w-10 text-right font-mono text-muted-foreground`,children:xg(bg(t,n))})]},e.id)})})]})]})]})})}function Og(e,t){return t[e]??`session ${e.slice(0,8)}`}function kg({session:e,label:t}){let{t:n}=H(),r=(0,X.useMemo)(()=>Object.entries(e.perTool).sort(([,e],[,t])=>t.started-e.started),[e.perTool]),i=(0,X.useMemo)(()=>Object.entries(e.perAgent),[e.perAgent]).filter(([e])=>e!==_e),a=e.perAgent[_e],o=(0,X.useMemo)(()=>{let t=vg();for(let n of Object.values(e.perAgent))yg(t,n);return t},[e.perAgent]),s=xe(e),c=e.delegations;return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/10 p-2.5`,children:[(0,Z.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate text-xs font-semibold`,title:e.sessionId,children:t}),s>0&&(0,Z.jsx)(`span`,{className:`rounded bg-info/10 px-1.5 py-0.5 font-mono text-[10px] text-info`,children:n(`chat:toolStats.running`,`{{count}} running`,{count:s})}),(0,Z.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono text-[10px] tabular-nums text-muted-foreground`,children:[xg(bg(o.ok,o.failed)),` · `,o.ok,`✓ `,o.failed,`✗`]}),(0,Z.jsx)(`span`,{className:`w-24 shrink-0`,children:(0,Z.jsx)(wg,{ok:o.ok,failed:o.failed,inFlight:s})})]}),(0,Z.jsxs)(`div`,{className:`overflow-hidden rounded-lg border border-border/40 bg-background/30`,children:[(0,Z.jsxs)(`div`,{className:`grid grid-cols-[minmax(9rem,1.15fr)_3.5rem_4rem] gap-x-3 border-b border-border/40 bg-muted/30 px-2.5 py-1.5 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground sm:grid-cols-[minmax(11rem,1.2fr)_minmax(7rem,1.5fr)_3.5rem_3.5rem_4rem]`,children:[(0,Z.jsx)(`span`,{children:n(`chat:toolStats.tool`,`Tool`)}),(0,Z.jsx)(`span`,{className:`hidden sm:block`,children:n(`chat:toolStats.outcome`,`Outcome`)}),(0,Z.jsx)(`span`,{className:`text-right`,children:n(`chat:toolStats.calls`,`Calls`)}),(0,Z.jsx)(`span`,{className:`text-right`,children:n(`chat:toolStats.successRate`,`Success rate`)}),(0,Z.jsx)(`span`,{className:`text-right`,children:n(`chat:toolStats.average`,`Avg.`)})]}),(0,Z.jsx)(`div`,{className:`divide-y divide-border/30`,children:r.map(([e,t])=>(0,Z.jsx)(Eg,{name:e,bucket:t},e))})]}),(i.length>0||c.started>0)&&(0,Z.jsxs)(`div`,{className:`mt-2 rounded border border-border/40 bg-background/40 p-2`,children:[(0,Z.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[10px] font-bold uppercase tracking-wider text-muted-foreground`,children:[(0,Z.jsx)(jr,{className:`h-3 w-3`}),n(`chat:toolStats.agentToAgent`,`Agent-to-agent`)]}),i.map(([e,t])=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 px-1 py-0.5 text-xs`,children:[(0,Z.jsx)(jr,{className:`h-3 w-3 shrink-0 text-info`}),(0,Z.jsx)(`span`,{className:`font-mono truncate flex-1 min-w-0`,title:e,children:e}),(0,Z.jsx)(wg,{ok:t.ok,failed:t.failed,inFlight:0}),(0,Z.jsx)(`span`,{className:`tabular-nums text-success w-8 text-right`,children:t.ok}),(0,Z.jsx)(`span`,{className:`tabular-nums text-destructive w-8 text-right`,children:t.failed})]},e)),c.started>0&&(0,Z.jsxs)(`div`,{className:`mt-1 flex items-center gap-1.5 px-1 text-[11px] text-muted-foreground`,children:[(0,Z.jsx)(Kr,{className:G(`h-3 w-3`,c.failed>0?`text-destructive`:`text-success`)}),n(`chat:toolStats.delegations`,`{{count}} delegated run(s)`,{count:c.ok+c.failed}),c.failed>0&&(0,Z.jsx)(`span`,{className:`text-destructive`,children:n(`chat:toolStats.delegationFailed`,`{{count}} failed`,{count:c.failed})}),(0,Z.jsx)(`span`,{className:`ml-auto tabular-nums`,children:n(`chat:toolStats.delegateToolCalls`,`{{count}} tools inside`,{count:c.toolCalls})})]})]}),a&&i.length>0&&(0,Z.jsx)(`p`,{className:`mt-1 px-1 text-[10px] text-muted-foreground/70`,children:n(`chat:toolStats.leaderLine`,`Leader: {{ok}}✓ {{failed}}✗`,{ok:a.ok,failed:a.failed})})]})}function Ag(e){let{client:t,slug:n}=e,r=!1,i=()=>{},a=()=>{},o=t=>{r||(r=!0,clearTimeout(s),i(),a(),e.onSettle(t))},s=setTimeout(()=>o(`error`),e.timeoutMs??8e3),c=()=>{a=t.on(`prompts.content`,r=>{let i=r.payload;if(i?.slug!==n)return;let a=i.content?.trim()??``;if(!i.found||!a){o(`error`);return}let s=e.compose(a),c=t.sendMessage(s);e.onSent(c,s),t.send({type:`prompts.used`,payload:{slug:n}}),o(`idle`)}),t.send({type:`prompts.content`,payload:{slug:n}})};if(!e.requireSoloSession||!e.subagentsAllowed){c();return}i=t.on(`prefs.updated`,t=>{let n=t.payload;if(!(e.sessionId&&n.sessionId!==e.sessionId)&&typeof n.subagentsAllowed==`boolean`){if(n.subagentsAllowed!==!1){o(`error`);return}i(),i=()=>{},c()}}),e.setPrefs({subagentsAllowed:!1}),t.send({type:`prefs.update`,payload:{subagentsAllowed:!1,...e.sessionId?{sessionId:e.sessionId}:{}}})}var jg=`proof-driven-bug-hunter`;function Mg(e){let t=[],n=e=>{for(let r of e)r.type===`directory`&&(r.ignored||(t.push(r.path),r.children&&n(r.children)))};return n(e),t.sort((e,t)=>e.localeCompare(t))}function Ng(){let{t:e}=H(),{projectName:n,cwd:r}=N(Me(e=>({projectName:e.projectName,cwd:e.cwd}))),{provider:i,model:a}=R(Me(e=>({provider:e.provider,model:e.model}))),o=R(e=>e.wsConnected),s=R(e=>e.wsUrl),c=t(e=>e.tree),l=N(e=>e.session?.id),{subagentsAllowed:u,setPrefs:d}=W(Me(e=>({subagentsAllowed:e.subagentsAllowed,setPrefs:e.set}))),{addMessage:f,setLoading:p}=q(Me(e=>({addMessage:e.addMessage,setLoading:e.setLoading}))),[m,h]=(0,X.useState)(void 0),[g,_]=(0,X.useState)(`idle`),[v,y]=(0,X.useState)(``),[b,x]=(0,X.useState)(1),[S,C]=(0,X.useState)(`idle`),[w,T]=(0,X.useState)(``),[E,D]=(0,X.useState)(`ratchet`),[O,k]=(0,X.useState)(``),A=Mg(c);(0,X.useEffect)(()=>{if(!o)return;let e=V(s),t=e.on(`providers.saved`,e=>{let t=e.payload;h(t.providers?.length??0)});return e.listSavedProviders(),()=>{t()}},[o,s]),(0,X.useEffect)(()=>{o&&V(s).send({type:`files.tree`,payload:l?{sessionId:l}:{}})},[l,o,s]);let j=(0,X.useCallback)(()=>{let e=V(s);!e.isConnected||g===`loading`||(_(`loading`),Ag({client:e,slug:jg,requireSoloSession:!0,subagentsAllowed:u,sessionId:l,setPrefs:d,compose:e=>{let t=v?`${v} and all of its descendants`:`the whole project`;return ga(`${e}
|
|
104
104
|
|
|
105
105
|
## WebUI run configuration (mandatory)
|
|
106
106
|
This run may complete up to ${b} proven bug ${b===1?`round`:`rounds`}. Work on only one bug at a time; after its proof, fix, verification, and cleanup are complete, continue to the next round only while below this limit. Stop early when no further proven bug is available. Stay strictly within ${t}. This configuration overrides the prompt's one-issue total limit, but not its one-issue-per-round discipline.`,{scope:v,maxBugs:b})},onSent:(e,t)=>{f({id:e,role:`user`,content:t,bugHunt:{scope:v,maxBugs:b}}),p(!0)},onSettle:_}))},[f,b,v,g,l,p,d,u,s]),M=(0,X.useCallback)(()=>{let e=V(s);!e.isConnected||S===`loading`||(C(`loading`),Ag({client:e,slug:pa[E],requireSoloSession:sa.has(E),subagentsAllowed:u,sessionId:l,setPrefs:d,compose:e=>{let t=w?`${w} and all of its descendants`:`the whole project`,n=O?`Optimise for ${da[O]} (\`${O}\`). A change that improves another metric while making this one worse is a regression for this round.`:`Pick the metric the user actually feels for this workload, name it explicitly, and state why it is the one that matters before you measure anything.`;return ca(`${e}
|
|
@@ -141,4 +141,4 @@ Record the baseline, every attempt, and every keep/revert verdict in \`PERF_LOG.
|
|
|
141
141
|
`).slice(-4).join(`
|
|
142
142
|
`).trim();return(0,Z.jsxs)(`div`,{className:`ws-reasoning min-w-0 max-w-full py-0.5 sm:max-w-[720px]`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`flex w-full flex-wrap items-center gap-x-2 gap-y-0.5 text-left font-mono text-xs`,"aria-expanded":i,children:[(0,Z.jsx)(`span`,{className:`ws-reasoning__mark text-sm leading-none`,"aria-hidden":!0,children:`✦`}),(0,Z.jsx)(`span`,{className:`font-semibold uppercase tracking-wide text-primary`,children:r(`activity:message.thinkingProcess`)}),(0,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70`,children:r(`activity:message.thinkingMeta`,{iter:t.iteration,dur:s,lines:r(`activity:message.linesSuffix`,{count:n})})}),(0,Z.jsx)(`span`,{className:`ml-auto text-muted-foreground/60`,children:i?(0,Z.jsx)(Ct,{className:`h-3.5 w-3.5`}):(0,Z.jsx)(ot,{className:`h-3.5 w-3.5`})})]}),(0,Z.jsx)(`pre`,{className:G(`mt-1.5 whitespace-pre-wrap break-words font-mono text-xs italic leading-relaxed text-foreground/65`,i?`max-h-[32rem] overflow-auto`:`max-h-24 overflow-hidden`),children:i?t.text:c||t.text}),(0,Z.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-2`,children:[(0,Z.jsx)(r_,{text:t.text,label:r(`activity:message.copyLog`),className:`text-[10px] text-muted-foreground/60 opacity-70 transition-opacity hover:opacity-100`}),!i&&n>4&&(0,Z.jsx)(`button`,{type:`button`,onClick:()=>a(!0),className:`text-[10px] text-muted-foreground/70 transition-colors hover:text-foreground`,children:r(`activity:message.showFullLog`)})]})]})})():(()=>{if(le)return null;let t=e.content,n=!!e.attachments&&e.attachments.length>0;return(0,Z.jsxs)(`div`,{className:G(`text-sm leading-relaxed markdown-content`,e.streaming&&`streaming-cursor`),children:[n&&(0,Z.jsx)(n_,{attachments:e.attachments??[],notRetainedLabel:r(`activity:message.imageNotRetained`)}),t?u&&e.role===`assistant`?(0,Z.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs leading-relaxed text-foreground/90 max-h-[40rem] overflow-auto`,children:e.content}):e.role===`assistant`&&e.isError?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(a_,{text:e.content}),fe&&!e.streaming&&!T&&(0,Z.jsx)(l_,{text:e.content,timestamp:e.timestamp})]}):e.streaming?(0,Z.jsx)(m_,{text:t}):(0,Z.jsx)(d_,{remarkPlugins:[io],rehypePlugins:Ll,components:Bl,children:t}):e.streaming?(0,Z.jsx)(`span`,{className:`inline-block animate-pulse text-muted-foreground`,children:r(`activity:message.typing`)}):n||pe.length>0?null:(0,Z.jsx)(`span`,{className:`text-muted-foreground italic`,children:r(`activity:message.noContent`)})]})})()}),f&&e.status===`failed`&&(0,Z.jsx)(`span`,{className:`text-[10px] font-medium text-destructive flex items-center gap-1 px-1`,children:r(`activity:message.failedToSend`)}),fe&&!T&&pe.length>0&&(0,Z.jsx)(sh,{steps:pe,yoloMode:ne,autoMode:z===`auto`,autoDelayMs:te.autonomyDelayMs,onAutoSubmit:ue,canAutoSubmit:ce,onBatchSubmit:de,isLatest:fe,sessionEndAutoFill:!0}),(0,Z.jsxs)(`div`,{className:G(`flex max-w-full flex-wrap items-center gap-2 px-1`,f?`flex-row-reverse`:`flex-row`),children:[!le&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground/70`,children:new Date(e.timestamp).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}),(0,Z.jsx)(`span`,{className:`w-px h-3 bg-border/60 shrink-0`,"aria-hidden":!0})]}),e.runSummary&&(0,Z.jsxs)(`span`,{className:`text-[10px] text-muted-foreground/75 font-mono tabular-nums`,title:[r(`activity:message.rsIterations`,{n:e.runSummary.iterations}),r(`activity:message.rsTools`,{n:e.runSummary.tools}),r(`activity:message.rsElapsed`,{s:`${(e.runSummary.durationMs/1e3).toFixed(2)}s`}),e.runSummary.costDelta>0?r(`activity:message.rsCost`,{c:e.runSummary.costDelta.toFixed(4)}):``].filter(Boolean).join(` · `),children:[e.runSummary.iterations,` iter`,e.runSummary.tools>0?` · ${e.runSummary.tools} tool${e.runSummary.tools===1?``:`s`}`:``,` `,`·`,` `,e.runSummary.durationMs<6e4?`${(e.runSummary.durationMs/1e3).toFixed(1)}s`:`${Math.floor(e.runSummary.durationMs/6e4)}m ${Math.floor(e.runSummary.durationMs%6e4/1e3)}s`,e.runSummary.costDelta>0?` · ${e.runSummary.costDelta>=.01?e.runSummary.costDelta.toFixed(4):e.runSummary.costDelta.toFixed(6).replace(/0+$/,``).replace(/\.$/,``)}`:``]}),e.usage&&(e.usage.input>0||e.usage.output>0)&&(()=>{let t=e.usage,n=((t.input+(t.cacheWrite??0))*I+t.output*L+(t.cacheRead??0)*ee)/1e6,i=I>0||L>0,a=n>=.01?`${n.toFixed(4)}`:n>0?`${n.toFixed(6).replace(/0+$/,``).replace(/\.$/,``)}`:``;return(0,Z.jsxs)(`span`,{className:`text-[10px] text-muted-foreground/75 font-mono tabular-nums`,title:[r(`activity:message.useInput`,{n:t.input.toLocaleString()}),r(`activity:message.useOutput`,{n:t.output.toLocaleString()}),t.cacheRead?r(`activity:message.useCacheRead`,{n:t.cacheRead.toLocaleString()}):``,i?r(`activity:message.useCost`,{c:a}):``].filter(Boolean).join(` · `),children:[t.input.toLocaleString(),`→`,t.output.toLocaleString(),t.cacheRead?` · ${t.cacheRead.toLocaleString()} ↺`:``,i&&a?` · ${a}`:``]})})(),!v&&!_&&e.content&&!e.streaming&&(0,Z.jsx)(r_,{text:e.content,label:r(`common:action.copy`),className:`opacity-50 hover:opacity-100 transition-opacity`}),e.role===`assistant`&&e.content&&!e.streaming&&(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>d(e=>!e),title:r(u?`activity:message.showRenderedTitle`:`activity:message.showRawTitle`),className:G(`text-xs inline-flex items-center gap-1 transition-opacity`,u?`text-primary hover:text-primary/80 opacity-100`:`opacity-50 hover:opacity-100 text-muted-foreground hover:text-foreground`),children:[(0,Z.jsx)(bt,{className:`h-3 w-3`}),(0,Z.jsx)(`span`,{children:r(u?`activity:message.renderedLabel`:`activity:message.rawLabel`)})]}),f&&!_&&!o&&!T&&(0,Z.jsxs)(Z.Fragment,{children:[e.status===`failed`&&(0,Z.jsxs)(`button`,{type:`button`,onClick:he,title:r(`activity:message.retryLabel`,`Retry`),className:`opacity-75 hover:opacity-100 transition-opacity text-xs text-destructive hover:text-destructive/80 inline-flex items-center gap-1 font-medium`,children:[(0,Z.jsx)(Tn,{className:`h-3 w-3`}),(0,Z.jsx)(`span`,{children:r(`activity:message.retryLabel`,`Retry`)})]}),e.content&&(0,Z.jsxs)(`button`,{type:`button`,onClick:_e,title:r(`activity:message.editTitle`),className:`opacity-50 hover:opacity-100 transition-opacity text-xs text-muted-foreground hover:text-foreground inline-flex items-center gap-1`,children:[(0,Z.jsx)(or,{className:`h-3 w-3`}),(0,Z.jsx)(`span`,{children:r(`activity:message.editLabel`)})]})]}),e.role===`assistant`&&e.content&&!e.streaming&&(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>O(e.id),title:r(F?`activity:message.unpinTitle`:`activity:message.pinTitle`),className:G(`text-xs inline-flex items-center gap-1 transition-opacity`,F?`text-warning hover:text-warning/85 opacity-100`:`opacity-50 hover:opacity-100 text-muted-foreground hover:text-foreground`),children:[F?(0,Z.jsx)(Ti,{className:`h-3 w-3`}):(0,Z.jsx)(Gr,{className:`h-3 w-3`}),(0,Z.jsx)(`span`,{children:r(F?`activity:message.pinnedLabel`:`activity:message.pinLabel`)})]}),(fe||e.isError)&&e.content&&!e.streaming&&!T&&(0,Z.jsxs)(`button`,{type:`button`,onClick:ge,title:r(`activity:message.regenerateTitle`),className:`opacity-50 hover:opacity-100 transition-opacity text-xs text-muted-foreground hover:text-foreground inline-flex items-center gap-1`,children:[(0,Z.jsx)(Tn,{className:`h-3 w-3`}),(0,Z.jsx)(`span`,{children:r(`activity:message.retryLabel`)})]})]})]})]})});function L_(e){return e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(e<1e4?2:1)}s`:`${Math.floor(e/6e4)}m${Math.floor(e%6e4/1e3)}s`}var R_=(0,X.memo)(function({tools:e,defaultOpen:t=!1,isContinuation:n=!1}){let{t:r}=H(),[i,a]=(0,X.useState)(t);if(e.length===1)return(0,Z.jsx)(I_,{message:k(e[0]),isFirst:!0,isContinuation:n});let o=e.filter(e=>e.toolResult===void 0).length,s=e.filter(e=>e.isError).length,c=e.reduce((e,t)=>e+(t.toolDurationMs??0),0),l=Array.from(new Set(e.map(e=>e.toolName).filter(Boolean))),u=l.slice(0,3).join(`, `),d=l.length>3?` +${l.length-3}`:``;return(0,Z.jsxs)(`div`,{className:`flex gap-3 animate-message`,children:[n?(0,Z.jsx)(`div`,{className:`flex-shrink-0 w-8 h-8`,"aria-hidden":!0}):(0,Z.jsx)(`div`,{className:`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center bg-secondary text-secondary-foreground ring-2 ring-offset-2 ring-offset-background ring-secondary/20`,children:(0,Z.jsx)(kr,{className:`h-4 w-4`})}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 max-w-[85%] flex-1 min-w-0`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:G(`flex items-center gap-2 text-sm font-medium cursor-pointer select-none`,`hover:bg-muted/50 rounded-lg px-2 py-1.5 -mx-2 transition-colors`,`border border-border/40 bg-muted/30`),children:[i?(0,Z.jsx)(Ct,{className:`h-3.5 w-3.5 text-muted-foreground`}):(0,Z.jsx)(ot,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,Z.jsx)(kr,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,Z.jsx)(`span`,{className:`font-mono text-xs`,children:r(`activity:toolGroup.toolCalls`,{count:e.length})}),o>0?(0,Z.jsx)(wt,{className:`h-3 w-3 animate-spin text-warning`}):s>0?(0,Z.jsx)(Rr,{className:`h-3 w-3 text-destructive`}):(0,Z.jsx)($t,{className:`h-3 w-3 text-success`}),c>0&&(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums font-normal`,children:L_(c)}),u&&(0,Z.jsxs)(`span`,{className:`text-xs text-muted-foreground/80 font-mono truncate`,children:[`· `,u,d]})]}),i&&(0,Z.jsx)(`div`,{className:`space-y-2 pl-3 border-l-2 border-border/40 ml-2 tool-details`,children:e.map(e=>(0,Z.jsx)(I_,{message:e,isFirst:!1},e.id))})]})]})}),z_=!1;function B_(){if(z_)return;let e=V();e&&(e.on(`chimera.reports`,e=>{let t=e.payload;(t?.isQuery||t?.reports)&&V_.setState({reports:t.reports??[],loading:!1})}),e.on(`chimera.report.detail`,e=>{let t=e.payload;V_.setState({detail:t.error?null:t,error:t.error??null,detailLoading:!1})}),e.on(`chimera.report.updated`,()=>{V_.getState().fetchReports();let e=V_.getState().selectedReportId;e&&V_.getState().selectReport(e)}),e.on(`chimera.report.note_added`,()=>{let e=V_.getState().selectedReportId;e&&V_.getState().selectReport(e)}),e.on(`chimera.finding.updated`,()=>{V_.getState().fetchReports();let e=V_.getState().selectedReportId;e&&V_.getState().selectReport(e)}),e.on(`chimera.report_available`,()=>{V_.getState().fetchReports()}),z_=!0)}var V_=jt((e,t)=>({reports:[],selectedReportId:null,detail:null,loading:!1,detailLoading:!1,error:null,filterSessionId:``,filterLifecycle:``,searchQuery:``,fetchReports:()=>{B_();let n=V();if(!n.isConnected){e({loading:!1});return}e({loading:!0,error:null});let{filterSessionId:r,filterLifecycle:i}=t();n.send({type:`chimera.reports.list`,payload:{all:!0,sessionId:r||void 0,lifecycle:i||void 0}})},selectReport:t=>{if(B_(),e({selectedReportId:t}),!t){e({detail:null,detailLoading:!1});return}let n=V();n.isConnected&&(e({detailLoading:!0,error:null}),n.send({type:`chimera.report.get`,payload:{reportId:t}}))},setFilterSessionId:n=>{e({filterSessionId:n}),t().fetchReports()},setFilterLifecycle:n=>{e({filterLifecycle:n}),t().fetchReports()},setSearchQuery:t=>{e({searchQuery:t})},transitionReport:(e,t,n)=>{let r=V();r.isConnected&&r.send({type:`chimera.report.transition`,payload:{reportId:e,to:t,reason:n}})},addReportNote:(e,t)=>{let n=V();n.isConnected&&n.send({type:`chimera.report.add_note`,payload:{reportId:e,note:t}})},transitionFinding:(e,t,n,r)=>{let i=V();i.isConnected&&i.send({type:`chimera.finding.transition`,payload:{findingId:e,to:t,outcome:n,reason:r}})}})),H_=(0,X.memo)(function({message:e,sessionId:t}){let n=e.chimeraReport,r=l(e=>e.lanes[t]?.isLoading??!1);if(!n)return null;let i=n.actionedAt!=null;return(0,Z.jsx)(`div`,{className:`mx-auto max-w-6xl w-full px-3 sm:px-5 lg:px-6 py-1`,"data-chimera-report-card":n.reportId,children:(0,Z.jsxs)(`div`,{className:`rounded-xl border border-warning/30 bg-warning/[0.06] px-4 py-3 space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-baseline gap-2 text-sm font-semibold min-w-0`,children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,children:`🦂`}),(0,Z.jsx)(`span`,{className:`shrink-0`,children:`Chimera report — action needed`}),(0,Z.jsxs)(`span`,{className:`text-xs font-normal text-muted-foreground truncate`,children:[`report `,n.reportId]})]}),(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground whitespace-pre-wrap break-words`,children:e.content}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{if(i||r)return;let a=`Take a look at the tasks mentioned in this Chimera report (${n.reportId}) — review the findings it flagged for this session and address them.`,o=D(t);o.addMessage({role:`user`,content:a}),o.patch({isLoading:!0}),V().sendMessage(a,void 0,!1,t===`__unbound__`?void 0:t),o.updateMessage(e.id,{chimeraReport:{...n,actionedAt:Date.now()}}),O.getState().markActioned(t,n.reportId,Date.now())},disabled:i||r,title:i?`Prompt sent to the leader`:r?`Waiting for the leader to finish its current run`:`Send the leader a prompt to work through this report`,className:G(`inline-flex min-h-11 items-center gap-2 rounded-lg px-4 py-2 text-sm font-medium transition-colors`,i||r?`cursor-not-allowed border border-border bg-muted text-muted-foreground`:`bg-primary text-primary-foreground hover:bg-primary/90 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`),children:i?`Prompt sent ✓`:r?`Leader is running…`:`Take action — have the leader review it`}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>{V_.getState().selectReport(n.reportId),Ba(`chimera`)},className:`inline-flex min-h-11 items-center gap-1.5 rounded-lg border border-border bg-background px-3 py-2 text-xs font-medium text-foreground hover:bg-muted transition-colors`,children:[(0,Z.jsx)(qt,{size:14}),(0,Z.jsx)(`span`,{children:`Open in Chimera Hub`})]})]})]})})}),U_=(0,X.memo)(function({row:e,isLoading:t,compactMode:n,isFirstRow:r,groupToolCalls:i,sessionId:a}){let o=G(`mx-auto max-w-6xl w-full px-3 sm:px-5 lg:px-6`,r&&`pt-4`,n?`pb-3`:`pb-6`);return e.kind===`day`?(0,Z.jsx)(`div`,{className:o,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 py-1 text-[11px] text-muted-foreground/70 uppercase tracking-wider font-medium`,children:[(0,Z.jsx)(`div`,{className:`flex-1 h-px bg-border/50`}),(0,Z.jsx)(`span`,{children:e.label}),(0,Z.jsx)(`div`,{className:`flex-1 h-px bg-border/50`})]})}):e.kind===`user`?(0,Z.jsx)(`div`,{className:o,children:(0,Z.jsx)(I_,{message:e.message,isFirst:!0})}):(0,Z.jsx)(`div`,{className:o,children:(0,Z.jsx)(`div`,{className:G(`chat-turn`,n?`space-y-1`:`space-y-1.5`),children:e.items.flatMap(n=>{if(n.kind===`msg`)return n.message.chimeraReport?[(0,Z.jsx)(H_,{message:n.message,sessionId:a},n.key)]:n.message.councilDecision||Qg(n.message.content)?[(0,Z.jsx)(t_,{message:n.message},n.key)]:n.message.brainDecision||Jg(n.message.content)?[(0,Z.jsx)(Xg,{message:n.message},n.key)]:[(0,Z.jsx)(I_,{message:n.message,isFirst:n.isFirst,isContinuation:n.isContinuation},n.key)];if(i){let r=e.isLastTurn&&n.isLastGroup&&t&&n.hasRunningTool;return[(0,Z.jsx)(R_,{tools:n.tools,defaultOpen:r,isContinuation:n.isContinuation},n.key)]}return n.tools.map(e=>(0,Z.jsx)(I_,{message:e,isFirst:!1,isContinuation:n.isContinuation},e.id))})})})}),W_={running:`bg-success/10 text-success`,completed:`bg-success/10 text-success`,failed:`bg-destructive/10 text-destructive`,timeout:`bg-warning/10 text-warning`,stopped:`bg-muted text-muted-foreground`};function G_(e){let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}):``}var K_=(0,X.memo)(function({entry:e}){let{t}=H(),n=G_(e.ts);if(e.kind===`text`)return(0,Z.jsxs)(`div`,{className:`flex gap-3`,children:[(0,Z.jsx)(`div`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-accent text-accent-foreground ring-accent/20 ring-offset-background ring-2 ring-offset-2`,children:(0,Z.jsx)(jr,{className:`h-4 w-4`})}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1 rounded-lg border border-border/70 bg-card px-4 py-3 shadow-sm`,children:[(0,Z.jsx)(d_,{children:e.content}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-[9px] tabular-nums text-muted-foreground/60`,children:[e.iteration>0&&(0,Z.jsxs)(`span`,{children:[`iter `,e.iteration]}),n&&(0,Z.jsx)(`span`,{className:`ml-auto font-mono`,children:n})]})]})]});if(e.kind===`thinking`)return(0,Z.jsxs)(`details`,{className:`group rounded-lg border border-primary/20 bg-primary/5 px-3 py-2`,children:[(0,Z.jsxs)(`summary`,{className:`flex cursor-pointer select-none items-center gap-2 text-[10px] font-medium uppercase tracking-wider text-primary/80 marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,Z.jsx)(lr,{className:`h-3.5 w-3.5 shrink-0`}),t(`activity:transcript.kindThinking`),e.iteration>0&&(0,Z.jsxs)(`span`,{className:`rounded bg-primary/10 px-1 py-0.5 text-[9px] normal-case tabular-nums`,children:[`iter `,e.iteration]}),n&&(0,Z.jsx)(`span`,{className:`ml-auto font-mono text-[9px] normal-case text-muted-foreground`,children:n})]}),(0,Z.jsx)(`pre`,{className:`mt-2 whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed text-foreground/75`,children:e.content})]});if(e.kind===`tool_use`||e.kind===`tool_result`){let r=e.kind===`tool_use`,i=e.toolOk!==!1,a=r?li:i?ui:St;return(0,Z.jsxs)(`div`,{className:G(`rounded-lg border px-3 py-2`,r?`border-warning/20 bg-warning/5`:i?`border-success/20 bg-success/5`:`border-destructive/25 bg-destructive/5`),children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(a,{className:G(`h-3.5 w-3.5 shrink-0`,r?`text-warning`:i?`text-success`:`text-destructive`)}),(0,Z.jsx)(`span`,{className:`shrink-0 text-[10px] font-medium uppercase tracking-wider text-muted-foreground`,children:t(r?`activity:transcript.kindToolCall`:`activity:transcript.kindToolResult`)}),e.toolName&&(0,Z.jsx)(`span`,{className:`min-w-0 truncate rounded bg-background/70 px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground`,children:e.toolName}),n&&(0,Z.jsx)(`span`,{className:`ml-auto shrink-0 font-mono text-[9px] tabular-nums text-muted-foreground`,children:n})]}),e.content&&(0,Z.jsx)(`pre`,{className:`mt-1.5 max-h-64 overflow-y-auto whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed text-foreground/80`,children:e.content})]})}if(e.kind===`error`)return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-destructive/25 bg-destructive/5 px-3 py-2`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(Ie,{className:`h-3.5 w-3.5 shrink-0 text-destructive`}),(0,Z.jsx)(`span`,{className:`shrink-0 text-[10px] font-medium uppercase tracking-wider text-destructive`,children:t(`activity:transcript.kindError`)}),n&&(0,Z.jsx)(`span`,{className:`ml-auto shrink-0 font-mono text-[9px] tabular-nums text-muted-foreground`,children:n})]}),(0,Z.jsx)(`pre`,{className:`mt-1.5 whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed text-destructive/90`,children:e.content})]});let r=e.kind===`status`?tr:Et;return(0,Z.jsx)(`div`,{className:`flex justify-center`,children:(0,Z.jsxs)(`div`,{className:`flex max-w-full items-center gap-1.5 rounded-full border border-border/50 bg-muted/25 px-3 py-1 text-[10px] text-muted-foreground`,children:[(0,Z.jsx)(r,{className:`h-3 w-3 shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.content}),n&&(0,Z.jsx)(`span`,{className:`shrink-0 font-mono text-[9px] tabular-nums opacity-70`,children:n})]})})});function q_({agentId:e}){let{t}=H(),n=_(t=>t.agents.get(e)),r=_(t=>t.agentTranscripts.get(e)??oe),i=K(e=>e.setSubagentChatFocus),[a,o]=(0,X.useState)(!1),s=(0,X.useRef)(null),c=(0,X.useRef)(!0),l=r[r.length-1],d=l?.content.length??0;return(0,X.useEffect)(()=>{c.current=!0},[e]),(0,X.useEffect)(()=>{let e=s.current;e&&c.current&&(e.scrollTop=e.scrollHeight)},[r.length,d,l?.id,e]),(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,"data-testid":`subagent-transcript-view`,children:[(0,Z.jsxs)(`div`,{"data-testid":`subagent-task-strip`,className:`flex h-8 max-h-8 shrink-0 items-center gap-1.5 overflow-hidden border-b border-border/60 bg-muted/20 px-3 text-xs`,children:[(0,Z.jsx)(jr,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,Z.jsx)(`span`,{className:`max-w-[9rem] shrink-0 truncate font-semibold text-foreground`,children:n?.name??e}),n&&(0,Z.jsx)(`span`,{className:G(`shrink-0 rounded px-1.5 py-0.5 text-[9px] font-medium uppercase tracking-wider`,W_[n.status]??W_.stopped),children:n.status}),(0,Z.jsx)(`span`,{className:`shrink-0 text-[9px] font-medium uppercase tracking-wider text-muted-foreground/80`,children:t(`activity:transcript.readOnly`)}),n?.description?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`shrink-0 text-border`,"aria-hidden":`true`,children:`·`}),(0,Z.jsx)(`span`,{className:`shrink-0 font-semibold uppercase tracking-wide text-foreground/70`,children:t(`activity:transcript.taskLabel`)}),(0,Z.jsx)(`button`,{type:`button`,"data-testid":`subagent-task-preview`,onClick:()=>o(!0),title:t(`activity:transcript.taskExpandTitle`),className:`min-w-0 flex-1 truncate text-left text-muted-foreground hover:text-foreground`,children:u(n.description)}),n.description.length>140&&(0,Z.jsx)(`span`,{className:`shrink-0 tabular-nums text-[10px] text-muted-foreground/70`,children:t(`activity:transcript.taskChars`,{count:n.description.length})}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>o(!0),title:t(`activity:transcript.taskExpandTitle`),"aria-label":t(`activity:transcript.taskExpandTitle`),"aria-expanded":a,className:`flex shrink-0 items-center gap-1 rounded border border-border/60 bg-background/70 px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground transition-colors hover:border-primary/40 hover:text-foreground`,children:[(0,Z.jsx)(en,{className:`h-3 w-3`}),t(`activity:transcript.taskExpand`)]})]}):(0,Z.jsx)(`span`,{className:`flex-1`}),n!=null&&(0,Z.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[10px] text-muted-foreground`,children:[`iter `,n.iteration,` · `,n.toolCalls,` `,t(`activity:agents.tcSuffix`),` · $`,n.costUsd.toFixed(4)]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>i(null,n?.sessionId),"aria-label":t(`activity:transcript.returnToLeader`),className:`ml-0.5 inline-flex shrink-0 items-center gap-0.5 rounded bg-primary/15 px-1.5 py-0.5 text-[10px] font-medium text-primary transition-colors hover:bg-primary/25`,children:[(0,Z.jsx)(St,{className:`h-3 w-3`}),t(`activity:transcript.returnToLeader`)]})]}),(0,Z.jsx)(`div`,{ref:s,onScroll:e=>{let t=e.currentTarget;c.current=t.scrollHeight-t.scrollTop-t.clientHeight<80},role:`log`,"aria-label":t(`activity:chatView.chatTranscript`),"aria-live":`polite`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:r.length===0?(0,Z.jsx)(`div`,{className:`mx-auto max-w-6xl px-3 pt-6 sm:px-5 lg:px-6`,children:(0,Z.jsx)(`div`,{className:`rounded-lg border border-dashed border-border p-6 text-center text-xs text-muted-foreground`,children:t(`activity:transcript.empty`)})}):(0,Z.jsx)(`div`,{className:`mx-auto max-w-6xl space-y-2.5 px-3 pb-8 pt-3 sm:px-5 lg:px-6`,children:r.map(e=>(0,Z.jsx)(K_,{entry:e},e.id))})}),n?.description&&(0,Z.jsx)(Ja,{open:a,onOpenChange:o,children:(0,Z.jsxs)(Ga,{className:`flex max-h-[85dvh] max-w-3xl flex-col gap-3 overflow-hidden`,children:[(0,Z.jsxs)(Ua,{children:[(0,Z.jsxs)(Ka,{className:`flex items-center gap-2 pr-6 text-base`,children:[(0,Z.jsx)(jr,{className:`h-4 w-4 shrink-0 text-primary`}),(0,Z.jsxs)(`span`,{className:`truncate`,children:[n.name??e,` · `,t(`activity:transcript.taskModalTitle`)]})]}),(0,Z.jsx)(qa,{className:`sr-only`,children:t(`activity:transcript.taskModalDescription`)})]}),(0,Z.jsx)(`pre`,{"data-testid":`subagent-task-full`,className:`min-h-0 flex-1 overflow-y-auto whitespace-pre-wrap break-words rounded-md border border-border/60 bg-muted/30 px-3 py-2.5 font-mono text-xs leading-relaxed text-foreground/85`,children:n.description})]})})]})}function J_(){let{t:e}=H(),t=q(e=>e.thinkingBuffer);if(!t)return null;let n=t.split(`
|
|
143
143
|
`).slice(-6).join(`
|
|
144
|
-
`).trim();return(0,Z.jsxs)(`div`,{className:`flex gap-3 animate-message thinking-bubble`,"aria-live":`polite`,children:[(0,Z.jsxs)(`div`,{className:`thinking-orb flex-shrink-0`,"aria-hidden":!0,children:[(0,Z.jsx)(`span`,{className:`thinking-orb__ring`}),(0,Z.jsx)(`span`,{className:`thinking-orb__ring thinking-orb__ring--delay`}),(0,Z.jsx)(`span`,{className:`thinking-orb__spark thinking-orb__spark--one`}),(0,Z.jsx)(`span`,{className:`thinking-orb__spark thinking-orb__spark--two`}),(0,Z.jsx)(lr,{className:`thinking-orb__icon h-4 w-4`})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1 max-w-[85%] min-w-0`,children:[(0,Z.jsxs)(`span`,{className:`thinking-label text-xs font-medium text-primary px-1`,children:[(0,Z.jsx)(`span`,{children:e(`chat:thinking`)}),(0,Z.jsxs)(`span`,{className:`thinking-dots`,"aria-hidden":!0,children:[(0,Z.jsx)(`span`,{}),(0,Z.jsx)(`span`,{}),(0,Z.jsx)(`span`,{})]})]}),(0,Z.jsxs)(`div`,{className:`thinking-panel rounded-2xl rounded-bl-md px-3 py-2 border text-foreground/80`,children:[(0,Z.jsxs)(`div`,{className:`thinking-wave`,"aria-hidden":!0,children:[(0,Z.jsx)(`span`,{}),(0,Z.jsx)(`span`,{}),(0,Z.jsx)(`span`,{}),(0,Z.jsx)(`span`,{}),(0,Z.jsx)(`span`,{})]}),(0,Z.jsx)(`pre`,{className:`thinking-text whitespace-pre-wrap break-words font-sans text-xs leading-relaxed italic max-h-32 overflow-hidden`,children:n||`…`})]})]})]})}function Y_(e){let{hasMessages:t,autoCollapseInput:n,sessionChanged:r,prevHadMessages:i,prevAutoCollapse:a}=e;return n&&t&&(r||!i||!a)}function X_(e,t){return typeof e==`function`?e(t):e}function Z_(){let{t:e}=H(),t=q(e=>e.messages),n=q(e=>e.isLoading),r=K(e=>e.sidebarOpen),i=K(e=>e.toggleSidebar),a=K(e=>e.compactMode),{totalTokens:o,startTime:s,lastInputTokens:c,maxContext:l,contextLimitWarning:u,cacheStats:d,iteration:f}=N(Me(e=>({totalTokens:e.totalTokens,startTime:e.startTime,lastInputTokens:e.lastInputTokens,maxContext:e.maxContext,contextLimitWarning:e.contextLimitWarning,cacheStats:e.cacheStats,iteration:e.iteration}))),p=N(e=>e.session),m=ve()??p?.id,h=K(e=>m?e.sessionNicknames[m]:void 0),g=K(e=>e.setSessionNickname),_=p?.title,[v,y]=(0,X.useState)(!1),[x,S]=(0,X.useState)(``),C=b(e=>e.entries),w=K(e=>e.chatSwitcherOpen),T=K(e=>e.setChatSwitcherOpen),E=(0,X.useCallback)(e=>{T(X_(e,K.getState().chatSwitcherOpen))},[T]),D=(0,X.useRef)(null);(0,X.useEffect)(()=>{if(!w)return;let e=e=>{D.current?.contains(e.target)||E(!1)},t=e=>{e.key===`Escape`&&E(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[w]);let{configProvider:O,configModel:k}=R(Me(e=>({configProvider:e.provider,configModel:e.model}))),A=p?.provider||O,j=p?.model||k,M=(0,X.useRef)(null),F=(0,X.useMemo)(()=>bs(t),[t]),I=(0,X.useRef)(0);I.current=F.length+1;let L=(0,X.useMemo)(()=>{let e=new Map;return F.forEach((t,n)=>{if(t.kind===`user`)e.set(t.message.id,n);else if(t.kind===`agent`)for(let r of t.items)if(r.kind===`msg`)e.set(r.message.id,n);else for(let t of r.tools)e.set(t.id,n)}),e},[F]),ee=K(e=>e.scrollTarget),te=W(e=>e.autonomy),z=W(e=>e.groupToolCalls),ne=W(e=>e.autoCollapseInput),re=(0,X.useCallback)(e=>{W.getState().set({autonomy:e});try{let t=V();if(typeof t.switchAutonomy==`function`){t.switchAutonomy(e);return}t.send?.({type:`autonomy.switch`,payload:t.withSession?.({mode:e})??{mode:e}})}catch{}},[]),[ie,ae]=(0,X.useState)(!1),oe=K(e=>e.chatCheckpointOpen),se=K(e=>e.setChatCheckpointOpen),ce=(0,X.useCallback)(e=>{se(X_(e,K.getState().chatCheckpointOpen))},[se]),le=K(e=>e.chatMemoryPanelOpen),ue=K(e=>e.setChatMemoryPanelOpen),de=(0,X.useCallback)(e=>{ue(X_(e,K.getState().chatMemoryPanelOpen))},[ue]),fe=K(e=>e.chatInputCollapsed),B=K(e=>e.setChatInputCollapsed),pe=(0,X.useCallback)(e=>{B(X_(e,K.getState().chatInputCollapsed))},[B]),me=(0,X.useRef)(n),he=(0,X.useRef)(t.length>0),ge=(0,X.useRef)(m),_e=(0,X.useRef)(ne),ye=K(e=>e.chatContextBreakdownOpen),be=K(e=>e.setChatContextBreakdownOpen),xe=K(e=>e.chatToolStatsOpen),Se=K(e=>e.setChatToolStatsOpen),Ce=(0,X.useCallback)(e=>{Se(X_(e,K.getState().chatToolStatsOpen))},[Se]),we=K(e=>e.chatContextEditorOpen),Te=K(e=>e.setChatContextEditorOpen),Ee=fa(e=>Object.values(e.contextMemories).filter(e=>e.state!==`exited`).length);(0,X.useEffect)(()=>{let e=()=>de(!0);return window.addEventListener(`open:memory-panel`,e),()=>window.removeEventListener(`open:memory-panel`,e)},[]),(0,X.useEffect)(()=>{let e=()=>be(!0);return document.addEventListener(`open:context-breakdown`,e),()=>document.removeEventListener(`open:context-breakdown`,e)},[]),(0,X.useEffect)(()=>{let e=()=>Te(!0);return document.addEventListener(`open:context-editor`,e),()=>document.removeEventListener(`open:context-editor`,e)},[]),(0,X.useEffect)(()=>{let e=()=>pe(!1);return document.addEventListener(`chat:session-end`,e),document.addEventListener(`chat:next-step-countdown`,e),()=>{document.removeEventListener(`chat:session-end`,e),document.removeEventListener(`chat:next-step-countdown`,e)}},[]),(0,X.useEffect)(()=>{me.current&&!n&&pe(!1),me.current=n},[n]),(0,X.useEffect)(()=>{let e=t.length>0,r=m!=null&&m!==ge.current;!n&&Y_({hasMessages:e,autoCollapseInput:ne,sessionChanged:r,prevHadMessages:he.current,prevAutoCollapse:_e.current})&&pe(!0),ge.current=m,he.current=e,_e.current=ne},[t.length,ne,m,n]);let De=(0,X.useCallback)(()=>{let e=!W.getState().autoCollapseInput;W.getState().set({autoCollapseInput:e}),e||pe(!1)},[]),Oe=l>0&&c>0?Math.min(100,Math.round(c/l*100)):0,[ke,Ae]=(0,X.useState)(!0),[je,Ne]=(0,X.useState)(0),[Pe,Fe]=(0,X.useState)(!1),Ie=(0,X.useRef)(t.length),Le=(0,X.useCallback)(()=>{let e=M.current;if(!e)return;let t=e.scrollSize-e.scrollOffset-e.viewportSize<120;Ae(t),t&&(Ne(0),Ie.current=q.getState().messages.length),Fe(e.scrollOffset>e.viewportSize&&e.scrollSize>e.viewportSize*2.5)},[]),Re=(0,X.useCallback)(e=>{let t=V();P.getState().openTab(e,{resumeSession:e=>t.resumeSession?.(e)}),E(!1)},[]);(0,X.useEffect)(()=>{let e=M.current;if(e){if(ke)e.scrollToIndex(I.current-1,{align:`end`}),Ie.current=t.length;else{let e=t.length-Ie.current;e>0&&Ne(e)}}},[t,ke]),(0,X.useEffect)(()=>{Ae(!0),Ne(0),Ie.current=q.getState().messages.length,ae(!1),y(!1),requestAnimationFrame(()=>{M.current?.scrollToIndex(I.current-1,{align:`end`})})},[m]),(0,X.useEffect)(()=>{if(!ee)return;let e=L.get(ee.id);e!==void 0&&M.current?.scrollToIndex(e,{align:`center`,smooth:!0})},[ee,L]);let ze=(0,X.useCallback)(()=>{M.current?.scrollToIndex(I.current-1,{align:`end`,smooth:!0}),Ae(!0),Ne(0),Ie.current=q.getState().messages.length},[]),Be=(0,X.useCallback)(()=>{M.current?.scrollToIndex(0,{align:`start`,smooth:!0})},[]),[Ve,He]=(0,X.useState)(null),[Ue,We]=(0,X.useState)(()=>Date.now()),Ge=(0,X.useRef)(null),Ke=t[t.length-1],qe=Ke?.role===`assistant`&&Ke.streaming&&Ke.content?Ke:null;(0,X.useEffect)(()=>{if(qe){let e=Ge.current;(!e||e.id!==qe.id)&&(Ge.current={id:qe.id,at:Date.now(),len:qe.content.length})}else Ge.current&&=null},[qe]);let Je=(0,X.useMemo)(()=>{let n=t[t.length-1],r=t.filter(e=>e.role===`tool`&&e.toolResult===void 0),i=e(`activity:chatView.thinking`);if(r.length>0){let t=Array.from(new Set(r.map(e=>e.toolName).filter(Boolean))),n=t.slice(0,2).join(`, `),a=t.length>2?` +${t.length-2}`:``;i=r.length===1?e(`activity:chatView.runningTool`,{tool:n||e(`activity:chatView.toolWord`)}):e(`activity:chatView.runningTools`,{count:r.length,preview:`${n}${a}`})}else n?.role===`assistant`&&n.content?i=e(`activity:chatView.writingReply`):n?.role===`tool`&&n.toolResult!==void 0&&(i=e(`activity:chatView.thinkingNextStep`));let a=Ve?Math.max(0,Math.floor((Ue-Ve)/1e3)):0,o=a<60?`${a}s`:`${Math.floor(a/60)}m ${a%60}s`,s=``;if(qe){let e=Ge.current;if(e&&e.id===qe.id){let t=Math.max(1,Ue-e.at),n=Math.max(0,qe.content.length-e.len);if(t>500&&n>0){let e=n*1e3/t;s=e>=1e3?`${(e/1e3).toFixed(1)}k ch/s`:`${Math.round(e)} ch/s`}}}return{label:i,elapsed:o,speedLabel:s}},[t,Ue,Ve,e,qe]);(0,X.useEffect)(()=>{n&&Ve===null&&He(Date.now()),!n&&Ve!==null&&He(null)},[n,Ve]),(0,X.useEffect)(()=>{if(!n)return;let e=setInterval(()=>We(Date.now()),500);return()=>clearInterval(e)},[n]);let Ye=e=>{if(!e)return`--`;let t=Math.floor((Date.now()-e)/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`},Xe=(()=>{if(!n)return`idle`;let e=t[t.length-1];return e?.role===`assistant`&&e.content&&e.streaming?`streaming`:`thinking`})();return{messages:t,isLoading:n,sidebarOpen:r,toggleSidebar:i,compactMode:a,totalTokens:o,startTime:s,lastInputTokens:c,maxContext:l,contextLimitWarning:u,cacheStats:d,iteration:f,sessionId:m,nickname:h,sessionTitle:_,renamingTitle:v,setRenamingTitle:y,titleDraft:x,setTitleDraft:S,setSessionNickname:g,historyEntries:C,switcherOpen:w,setSwitcherOpen:E,switcherRef:D,handleHistorySelect:Re,provider:A,model:j,vlistRef:M,rows:F,autonomy:te,groupToolCallsPref:z,autoCollapseInput:ne,handleAutonomyChange:re,processOpen:ie,setProcessOpen:ae,checkpointOpen:oe,setCheckpointOpen:ce,memoryPanelOpen:le,setMemoryPanelOpen:de,inputCollapsed:fe,setInputCollapsed:pe,breakdownOpen:ye,setBreakdownOpen:be,toolStatsOpen:xe,setToolStatsOpen:Ce,editorOpen:we,setEditorOpen:Te,activeMemoryCount:Ee,handleToggleAutoCollapse:De,ctxPct:Oe,pinnedToBottom:ke,unreadCount:je,scrolledDeep:Pe,handleScroll:Le,scrollToBottom:ze,scrollToTop:Be,runningStatus:Je,formatDuration:Ye,agentState:Xe,stateTone:Xe===`idle`?`bg-muted text-muted-foreground`:Xe===`streaming`?`bg-primary/10 text-primary`:`bg-warning/10 text-warning`,hasStatusContent:l>0&&c>0||o.input>0||!!s}}var Q_=(0,X.lazy)(()=>ta(()=>import(`./ProcessMonitor-ygFLD5zk.js`).then(e=>({default:e.ProcessMonitor})),__vite__mapDeps([63,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,25,20,18,19,21,23,26,29])));function $_(){let{t:e}=H(),t=Z_(),n=ve(),r=K(e=>e.subagentChatFocusId),a=K(e=>e.setSubagentChatFocus),o=K(e=>e.setSearchOpen),c=S(n??void 0),l=_(e=>r==null?void 0:e.agents.get(r)),u=!l||A(l.sessionId,n),d=!!l&&u,f=r!=null&&d&&r!==c;(0,X.useEffect)(()=>{(Rg(r,d)||r!=null&&r===c)&&a(null,n)},[r,d,c,a,n]),(0,X.useEffect)(()=>{f&&o(!1)},[f,o]);let p=R(e=>e.wsStatus),m=t.sessionId,h=s(e=>t.sessionId?e.startedAt[t.sessionId]!==void 0:!1),g=s(e=>t.sessionId?e.progress[t.sessionId]:void 0),v=ye(g),y=E(g?.stage);return(0,X.useEffect)(()=>{!m||p.state!==`open`||V().getChimeraReports(m)},[m,p]),(0,Z.jsxs)(`div`,{className:`flex flex-col flex-1 min-h-0 bg-[hsl(var(--surface-2)/0.45)]`,children:[(0,Z.jsx)(Kg,{sidebarOpen:t.sidebarOpen,toggleSidebar:t.toggleSidebar,agentState:t.agentState,stateTone:t.stateTone,sessionId:t.sessionId,renamingTitle:t.renamingTitle,setRenamingTitle:t.setRenamingTitle,titleDraft:t.titleDraft,setTitleDraft:t.setTitleDraft,nickname:t.nickname,sessionTitle:t.sessionTitle,setSessionNickname:t.setSessionNickname,historyEntries:t.historyEntries,switcherRef:t.switcherRef,switcherOpen:t.switcherOpen,setSwitcherOpen:t.setSwitcherOpen,handleHistorySelect:t.handleHistorySelect,iteration:t.iteration,autonomy:t.autonomy,handleAutonomyChange:t.handleAutonomyChange,memoryPanelOpen:t.memoryPanelOpen,setMemoryPanelOpen:t.setMemoryPanelOpen,activeMemoryCount:t.activeMemoryCount,processOpen:t.processOpen,setProcessOpen:t.setProcessOpen,checkpointOpen:t.checkpointOpen,setCheckpointOpen:t.setCheckpointOpen,toolStatsOpen:t.toolStatsOpen,setToolStatsOpen:t.setToolStatsOpen,hasStatusContent:t.hasStatusContent,lastInputTokens:t.lastInputTokens,ctxPct:t.ctxPct,maxContext:t.maxContext,cacheStats:t.cacheStats,setBreakdownOpen:t.setBreakdownOpen,contextLimitWarning:t.contextLimitWarning,setEditorOpen:t.setEditorOpen,totalTokens:t.totalTokens,startTime:t.startTime,formatDuration:t.formatDuration}),(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,Z.jsx)(`div`,{className:G(`ws-view-pane relative mx-2 mt-2 flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden rounded-xl border border-border/70 bg-card/55 shadow-sm sm:mx-3 lg:mx-4 lg:mt-3`,!f&&`ws-view-parked`),...f?{}:{inert:!0,"aria-hidden":!0},children:(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:f&&r!=null&&(0,Z.jsx)(q_,{agentId:r},r)})}),(0,Z.jsxs)(`div`,{className:G(`ws-view-pane relative mx-2 mt-2 min-h-0 min-w-0 flex-1 overflow-hidden rounded-xl border border-border/70 bg-card/55 shadow-sm sm:mx-3 lg:mx-4 lg:mt-3`,f&&`ws-view-parked`),...f?{inert:!0,"aria-hidden":!0}:{},children:[(0,Z.jsx)(lg,{}),!t.pinnedToBottom&&(0,Z.jsxs)(`button`,{type:`button`,onClick:t.scrollToBottom,className:G(`absolute bottom-4 left-1/2 -translate-x-1/2 z-10 jump-bottom`,`flex items-center gap-2 px-4 py-2 rounded-md shadow-lg`,`bg-primary text-primary-foreground text-xs font-medium`,`hover:bg-primary/90 transition-colors animate-message`),children:[(0,Z.jsx)(qn,{className:`h-3.5 w-3.5`}),t.unreadCount>0?`${t.unreadCount} new message${t.unreadCount===1?``:`s`}`:`Jump to latest`]}),t.scrolledDeep&&(0,Z.jsxs)(`button`,{type:`button`,onClick:t.scrollToTop,title:e(`chat:header.scrollTopTitle`),className:G(`absolute top-3 right-3 z-10`,`flex items-center gap-1 px-2.5 py-1 rounded-md shadow-md border`,`bg-background/90 backdrop-blur-sm text-[11px] text-muted-foreground`,`hover:text-foreground hover:bg-background transition-colors animate-message`),children:[(0,Z.jsx)(ai,{className:`h-3 w-3`}),(0,Z.jsx)(`span`,{children:e(`activity:chatView.top`)})]}),t.rows.length===0&&!t.isLoading?(0,Z.jsx)(`div`,{className:`h-full overflow-y-auto overscroll-contain`,children:(0,Z.jsx)(`div`,{className:`mx-auto max-w-6xl w-full px-3 sm:px-5 lg:px-6 pt-4 pb-8`,children:h?(0,Z.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-3 py-16 text-center`,role:`status`,"aria-live":`polite`,children:[(0,Z.jsxs)(`div`,{className:`relative h-12 w-12`,"aria-hidden":`true`,children:[(0,Z.jsx)(`div`,{className:`absolute inset-0 rounded-full border-2 border-muted-foreground/20`}),(0,Z.jsx)(`div`,{className:`absolute inset-0 rounded-full border-2 border-transparent border-t-primary animate-spin`}),(0,Z.jsx)(`div`,{className:`absolute inset-1.5 rounded-full bg-background/80`}),(0,Z.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-[11px] font-semibold tabular-nums text-foreground`,children:v===null?`...`:`${v}%`})]}),(0,Z.jsx)(`p`,{className:`text-sm font-medium`,children:e(`activity:chatView.restoringTranscript`)}),(0,Z.jsxs)(`div`,{className:`w-full max-w-sm`,children:[(0,Z.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-3 text-[11px] text-muted-foreground`,children:[(0,Z.jsx)(`span`,{className:`truncate`,children:y}),g&&g.totalBytes>0?(0,Z.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[i(g.loadedBytes),` /`,` `,i(g.totalBytes)]}):(0,Z.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:`reading...`})]}),(0,Z.jsx)(`div`,{className:`h-1.5 overflow-hidden rounded-full bg-muted`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-primary transition-[width] duration-200 ease-out`,style:{width:`${v??12}%`}})})]}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground max-w-sm`,children:e(`activity:chatView.restoringTranscriptHint`)})]}):(0,Z.jsx)(Ng,{})})}):(0,Z.jsxs)(qr,{ref:t.vlistRef,className:`h-full`,onScroll:t.handleScroll,role:`log`,"aria-label":e(`activity:chatView.chatTranscript`),"aria-live":`polite`,children:[t.rows.map((e,n)=>(0,Z.jsx)(U_,{row:e,isLoading:t.isLoading,compactMode:t.compactMode,isFirstRow:n===0,groupToolCalls:t.groupToolCallsPref,sessionId:t.sessionId??`__unbound__`},e.key)),(0,Z.jsxs)(`div`,{id:`chat-activity`,className:G(`mx-auto max-w-6xl w-full px-3 sm:px-5 lg:px-6`,t.compactMode?`pb-3`:`pb-8`),children:[(0,Z.jsx)(J_,{}),t.isLoading&&(0,Z.jsxs)(`div`,{className:`flex gap-3 animate-message`,children:[(0,Z.jsx)(`div`,{className:`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center bg-accent text-accent-foreground ring-2 ring-offset-2 ring-offset-background ring-accent/20`,children:(0,Z.jsx)(jr,{className:`h-4 w-4`})}),(0,Z.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:(0,Z.jsx)(`div`,{className:`rounded-lg px-4 py-3 bg-card border border-border/70 text-foreground shadow-sm`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 text-sm`,children:[(0,Z.jsxs)(`span`,{className:`flex gap-1`,children:[(0,Z.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary/70 animate-bounce [animation-delay:-0.3s]`}),(0,Z.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary/70 animate-bounce [animation-delay:-0.15s]`}),(0,Z.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary/70 animate-bounce`})]}),(0,Z.jsx)(`span`,{className:`text-foreground/90`,children:t.runningStatus.label}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:t.runningStatus.elapsed}),t.iteration&&(0,Z.jsxs)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:[`· iter `,t.iteration.index,t.iteration.max>0?`/${t.iteration.max}`:``]}),t.runningStatus.speedLabel&&(0,Z.jsxs)(`span`,{className:`text-xs text-muted-foreground/80 tabular-nums`,children:[`· `,t.runningStatus.speedLabel]})]})})})]})]},`__live`)]},t.sessionId??`__unbound__`)]})]}),(0,Z.jsx)(`div`,{className:G(`ws-view-pane shrink-0 bg-[hsl(var(--surface-2)/0.45)] px-2 pb-2 pt-2 sm:px-3 lg:px-4 lg:pb-3`,f&&`ws-view-parked`),...f?{inert:!0,"aria-hidden":!0}:{},children:t.inputCollapsed&&t.messages.length>0?(0,Z.jsxs)(`div`,{className:`flex items-center gap-1 rounded-lg border border-border/60 bg-card/40 px-3 py-1.5 hover:bg-card/70 hover:border-border/80 transition-colors`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>t.setInputCollapsed(!1),className:`flex flex-1 items-center gap-2 text-xs text-muted-foreground/60 hover:text-foreground/80 transition-colors`,children:[(0,Z.jsx)(dn,{className:`h-3.5 w-3.5 shrink-0`}),(0,Z.jsx)(`span`,{children:e(`chat:input.expandInput`,`Expand input`)}),t.rows.length>0&&(0,Z.jsxs)(`span`,{className:`ml-auto tabular-nums text-[10px] text-muted-foreground/40`,children:[t.rows.length,` msgs ·`,` `,_s(t.totalTokens.input+t.totalTokens.output)]})]}),t.isLoading&&(0,Z.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),V().sendAbort(t.sessionId??void 0),q.getState().setLoading(!1)},className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-[11px] font-medium bg-destructive/15 text-destructive hover:bg-destructive/25 transition-colors`,title:e(`chat:input.abortTitle`,`Stop/Abort`),"data-testid":`collapsed-stop`,children:[(0,Z.jsx)(sn,{className:`h-3 w-3 fill-current`}),(0,Z.jsx)(`span`,{children:e(`common:action.stop`,`Stop`)})]}),(0,Z.jsx)(zg,{label:e(`activity:chatView.autoCollapse`),value:t.autoCollapseInput,onChange:t.handleToggleAutoCollapse})]}):(0,Z.jsxs)(Z.Fragment,{children:[t.messages.length>0&&(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>t.setInputCollapsed(!0),className:`mb-1 flex w-full items-center gap-1.5 rounded px-2 py-0.5 text-[10px] text-muted-foreground/50 hover:text-muted-foreground/80 transition-colors`,children:[(0,Z.jsx)(Ct,{className:`h-3 w-3`}),(0,Z.jsx)(`span`,{children:e(`chat:input.collapseInput`,`Collapse`)})]}),(0,Z.jsx)(og,{}),(0,Z.jsx)(Bg,{hasStatusContent:t.hasStatusContent,totalTokens:t.totalTokens,rowsCount:t.rows.length,iteration:t.iteration,startTime:t.startTime,formatDuration:t.formatDuration,onToggleAutoCollapse:t.handleToggleAutoCollapse}),(0,Z.jsx)(`div`,{className:`ws-chat-input-wrap p-0`,children:(0,Z.jsx)(`div`,{className:`max-w-6xl mx-auto`,children:(0,Z.jsx)(Lh,{onOpenBreakdown:()=>t.setBreakdownOpen(!0)})})})]})}),(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)(Q_,{open:t.processOpen,onClose:()=>t.setProcessOpen(!1)})}),(0,Z.jsx)(zh,{open:t.checkpointOpen,onClose:()=>t.setCheckpointOpen(!1)}),(0,Z.jsx)(Es,{open:t.breakdownOpen,onClose:()=>t.setBreakdownOpen(!1)}),(0,Z.jsx)(Dg,{open:t.toolStatsOpen,onClose:()=>t.setToolStatsOpen(!1)}),(0,Z.jsx)(tg,{open:t.editorOpen,onClose:()=>t.setEditorOpen(!1)}),(0,Z.jsx)(Hm,{open:t.memoryPanelOpen,onClose:()=>t.setMemoryPanelOpen(!1)})]})}function ev(){let e=Ta(e=>e.info),{client:t}=ha(),n=(0,X.useRef)(null),r=(0,X.useCallback)(()=>{t?.getGitInfo?.()},[t]);return(0,X.useEffect)(()=>(r(),n.current=setInterval(r,3e4),()=>{n.current&&clearInterval(n.current)}),[r]),e}var tv=new Map,nv=new Set;se(e=>{tv.delete(e),nv.add(e)});function rv({sessionId:e,className:t}){let{t:n}=H(),[r,i]=(0,X.useState)([]),[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(null),[l,u]=(0,X.useState)(null),[d,f]=(0,X.useState)(0),[p,m]=(0,X.useState)(!1),[h,g]=(0,X.useState)(!1),[_,v]=(0,X.useState)(``),[y,b]=(0,X.useState)(``),[x,S]=(0,X.useState)(!1),[C,w]=(0,X.useState)(``),T=(0,X.useRef)(e),E=R(e=>e.wsUrl),D=V(E),O=q(e=>e.messages).filter(e=>e.role===`tool`&&e.toolResult===void 0&&!!e.toolUseId);(0,X.useLayoutEffect)(()=>{let t=T.current;nv.has(t)||tv.set(t,{participants:r,joined:a,joinedRole:s,error:l,openAnnotationCount:d,paused:p,injectOpen:h,injectToolUseId:_,injectContent:y,injectIsError:x,injectReason:C});let n=tv.get(e);nv.delete(e),i(n?.participants??[]),o(n?.joined??!1),c(n?.joinedRole??null),u(n?.error??null),f(n?.openAnnotationCount??0),m(n?.paused??!1),g(n?.injectOpen??!1),v(n?.injectToolUseId??``),b(n?.injectContent??``),S(n?.injectIsError??!1),w(n?.injectReason??``),T.current=e},[e]),(0,X.useEffect)(()=>{let t=[];return t.push(D.on(`collab.state`,t=>{let n=t.payload;n.sessionId===e&&i(n.participants??[])})),t.push(D.on(`collab.participant.joined`,t=>{let n=t.payload;n.sessionId===e&&i(e=>e.some(e=>e.participantId===n.participantId)?e:[...e,{participantId:n.participantId,role:n.role,joinedAt:n.joinedAt}])})),t.push(D.on(`collab.participant.left`,t=>{let n=t.payload;if(n.sessionId!==e)return;let r=n.participantId;i(e=>e.filter(e=>e.participantId!==r))})),t.push(D.on(`error`,e=>{let t=e.payload;t.phase===`collab`&&(u(t.message),o(!1))})),t.push(D.on(`collab.annotation.added`,t=>{let n=t.payload;n.sessionId===e&&(n.annotation?.resolved||f(e=>e+1))})),t.push(D.on(`collab.annotation.resolved`,t=>{t.payload.sessionId===e&&f(e=>Math.max(0,e-1))})),t.push(D.on(`collab.pause.granted`,t=>{t.payload.sessionId===e&&m(!0)})),t.push(D.on(`collab.pause.released`,t=>{t.payload.sessionId===e&&m(!1)})),()=>{for(let e of t)e()}},[D,e]);let k=(t=`observer`)=>{u(null),D.send({type:`collab.join`,payload:{sessionId:e,role:t}}),o(!0),c(t)},A=()=>{D.send({type:`collab.request_pause`,payload:{sessionId:e}})},j=()=>{D.send({type:`collab.resume`,payload:{sessionId:e}})},M=()=>{D.send({type:`collab.leave`,payload:{sessionId:e}}),o(!1),i([])},N=t=>{D.send({type:`collab.grant_control`,payload:{sessionId:e,toParticipant:t}})},P=()=>{_&&(D.send({type:`collab.inject_tool`,payload:{sessionId:e,toolUseId:_,content:y,isError:x,reason:C.trim()||U.t(`activity:collab.controllerInjection`)}}),g(!1),v(``),b(``),S(!1),w(``))},F=a&&s===`controller`;return r.length===0&&!l?(0,Z.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,Z.jsx)(fr,{className:`w-4 h-4 text-muted-foreground`}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`activity:collab.noObservers`)}),(0,Z.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>k(`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,Z.jsx)(st,{className:`w-3 h-3`}),n(`activity:collab.observerRole`)]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>k(`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,Z.jsx)(Kt,{className:`w-3 h-3`}),n(`activity:collab.annotatorRole`)]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>k(`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,Z.jsx)(si,{className:`w-3 h-3`}),n(`activity:collab.controllerRole`)]})]})]}):l?(0,Z.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,Z.jsx)(`span`,{className:`text-xs text-destructive`,children:n(`activity:collab.errorPrefix`,{error:l})}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{u(null),o(!1)},className:`ml-auto text-xs underline text-destructive`,children:n(`activity:collab.dismiss`)})]}):(0,Z.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,Z.jsxs)(`span`,{className:`relative flex h-2 w-2`,role:`img`,"aria-label":n(`common:status.live`),children:[(0,Z.jsx)(`span`,{className:`absolute inline-flex h-full w-full rounded-full bg-success opacity-75 animate-ping`}),(0,Z.jsx)(`span`,{className:`relative inline-flex rounded-full h-2 w-2 bg-success`})]}),(0,Z.jsx)(fr,{className:`w-4 h-4 text-success`}),(0,Z.jsx)(`span`,{className:`text-xs font-medium text-success`,children:n(`activity:collab.observers`,{count:r.length})}),d>0&&(0,Z.jsxs)(`span`,{title:n(`activity:collab.annotationsTitle`,{count:d}),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,Z.jsx)(Kt,{className:`w-3 h-3`}),n(`activity:collab.notes`,{count:d})]}),p&&(0,Z.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,Z.jsx)(si,{className:`w-3 h-3`}),n(`activity:collab.paused`)]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1 ml-2`,children:[r.slice(0,3).map(e=>(0,Z.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,Z.jsx)(Xt,{className:`w-3 h-3`}),e.role,F&&e.role!==`controller`&&(0,Z.jsx)(`button`,{type:`button`,onClick:()=>N(e.participantId),title:n(`activity:collab.grantTitle`),className:`ml-0.5 inline-flex items-center rounded hover:bg-success/20 transition-colors`,children:(0,Z.jsx)(mi,{className:`w-3 h-3`})})]},e.participantId)),r.length>3&&(0,Z.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`+`,r.length-3]})]}),F&&(0,Z.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>g(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,Z.jsx)(Mi,{className:`w-3 h-3`}),n(`activity:collab.inject`)]}),p?(0,Z.jsxs)(`button`,{type:`button`,onClick:j,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,Z.jsx)(er,{className:`w-3 h-3`}),n(`activity:collab.resume`)]}):(0,Z.jsxs)(`button`,{type:`button`,onClick:A,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,Z.jsx)(si,{className:`w-3 h-3`}),n(`activity:collab.pauseAgent`)]})]}),a&&s!==`controller`&&(0,Z.jsxs)(`button`,{type:`button`,onClick:M,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,Z.jsx)(fn,{className:`w-3 h-3`}),n(`activity:collab.leave`)]}),F&&h&&(0,Z.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,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Mi,{className:`w-3.5 h-3.5 text-info`}),(0,Z.jsx)(`span`,{className:`font-medium`,children:n(`activity:collab.injectToolResult`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>g(!1),className:`ml-auto text-muted-foreground hover:text-foreground`,children:n(`activity:collab.close`)})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:n(`activity:collab.targetTool`)}),(0,Z.jsx)(`input`,{list:`collab-inject-tools`,value:_,onChange:e=>v(e.target.value),placeholder:n(`activity:collab.targetPlaceholder`),className:`px-2 py-1 rounded border border-border bg-background font-mono`}),(0,Z.jsx)(`datalist`,{id:`collab-inject-tools`,children:O.map(e=>{let t=e.toolInput===void 0?``:` — ${JSON.stringify(e.toolInput).slice(0,40)}`;return(0,Z.jsxs)(`option`,{value:e.toolUseId,children:[e.toolName??n(`activity:collab.toolFallback`),t]},e.toolUseId)})}),O.length===0&&(0,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:n(`activity:collab.noPendingTools`)})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:n(`activity:collab.resultContent`)}),(0,Z.jsx)(`textarea`,{value:y,onChange:e=>b(e.target.value),rows:3,placeholder:n(`activity:collab.resultPlaceholder`),className:`px-2 py-1 rounded border border-border bg-background font-mono`})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsxs)(`label`,{className:`flex items-center gap-1`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:x,onChange:e=>S(e.target.checked)}),(0,Z.jsx)(`span`,{children:n(`activity:collab.markError`)})]}),(0,Z.jsx)(`input`,{type:`text`,value:C,onChange:e=>w(e.target.value),placeholder:n(`activity:collab.reasonPlaceholder`),className:`flex-1 px-2 py-1 rounded border border-border bg-background`})]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:P,disabled:!_,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,Z.jsx)(Mi,{className:`w-3 h-3`}),n(`activity:collab.queueInjection`)]})]})]})}var iv={running:{led:`bg-success led-pulse`,badge:`border-success/30 bg-success/10 text-success`,labelKey:`activity:fleet.statusRunning`},completed:{led:`bg-success`,badge:`border-border bg-muted/40 text-muted-foreground`,labelKey:`activity:fleet.statusDone`},failed:{led:`bg-destructive`,badge:`border-destructive/30 bg-destructive/10 text-destructive`,labelKey:`activity:fleet.statusFailed`},timeout:{led:`bg-warning`,badge:`border-warning/30 bg-warning/10 text-warning`,labelKey:`activity:fleet.statusTimeout`},stopped:{led:`bg-muted-foreground`,badge:`border-border bg-muted text-muted-foreground`,labelKey:`activity:fleet.statusStopped`}};function av({className:e}){let{t}=H(),n=_(e=>e.agents),i=ve(),[a,o]=(0,X.useState)(null),s=(0,X.useMemo)(()=>{let e=Array.from(n.values()).filter(e=>A(e.sessionId,i));return e.sort(c),e},[n,i]),l=(0,X.useCallback)(async(e,t)=>{try{await navigator.clipboard.writeText(t),o(e),setTimeout(()=>o(null),2e3)}catch{}},[]),u=(0,X.useCallback)(e=>{K.getState().setSubagentChatFocus(e,i??void 0),K.getState().setDockSection(null)},[i]);if(s.length===0)return(0,Z.jsx)(`div`,{className:G(`p-4 text-center text-xs text-muted-foreground`,e),children:t(`activity:agents.noAgentsRunning`)});let d=r(s),f=s.reduce((e,t)=>e+(t.costUsd??0),0);return(0,Z.jsxs)(`div`,{className:G(`flex flex-col gap-3`,e),children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 rounded-lg border border-border/70 bg-card/60 px-3 py-2 text-xs backdrop-blur-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(jr,{className:`h-4 w-4 text-primary shrink-0`}),(0,Z.jsx)(`span`,{className:`font-semibold`,children:t(`activity:dock.fleet`)}),(0,Z.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,s.length,`)`]})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px]`,children:[d.running>0&&(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-medium text-success`,children:[(0,Z.jsx)(`span`,{className:`h-2 w-2 rounded-full bg-success animate-pulse`}),d.running,` `,t(`activity:fleet.statusRunning`)]}),d.completed>0&&(0,Z.jsxs)(`span`,{className:`text-muted-foreground`,children:[d.completed,` `,t(`activity:fleet.statusDone`)]}),d.failed>0&&(0,Z.jsxs)(`span`,{className:`font-medium text-destructive`,children:[d.failed,` `,t(`activity:fleet.statusFailed`)]}),f>0&&(0,Z.jsx)(`span`,{className:`rounded bg-muted/60 px-1.5 py-0.5 font-mono text-[10px] text-foreground/80`,children:ec(f)})]})]}),(0,Z.jsx)(`div`,{className:`flex flex-col gap-2`,children:s.map(e=>{let n=iv[e.status]??iv.stopped,r=Date.now()-e.startedAt,i=e.description;return(0,Z.jsxs)(`div`,{className:`group flex flex-col gap-2 rounded-lg border border-border/70 bg-card/80 p-3 shadow-xs transition-colors hover:border-primary/40 hover:bg-card`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,Z.jsx)(`span`,{className:G(`h-2 w-2 rounded-full shrink-0`,n.led)}),(0,Z.jsx)(`span`,{className:`truncate text-xs font-semibold text-foreground`,children:e.name}),(e.provider||e.model)&&(0,Z.jsxs)(`span`,{className:`hidden sm:inline-flex items-center gap-1 rounded bg-muted/60 px-1.5 py-0.5 text-[10px] font-mono text-muted-foreground truncate`,children:[(0,Z.jsx)(ar,{className:`h-3 w-3 shrink-0`}),e.model??e.provider]}),(0,Z.jsx)(`span`,{className:G(`rounded-md border px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wider shrink-0`,n.badge),children:t(n.labelKey)})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,Z.jsxs)(`span`,{className:`flex items-center gap-1 text-[11px] font-mono text-muted-foreground tabular-nums`,children:[(0,Z.jsx)(He,{className:`h-3 w-3`}),nc(r)]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>u(e.id),className:`inline-flex items-center gap-1 rounded-md border border-primary/30 bg-primary/10 px-2 py-1 text-xs font-medium text-primary hover:bg-primary/20 transition-colors cursor-pointer`,title:`Open subagent chat tab`,children:[(0,Z.jsx)(Lt,{className:`h-3 w-3`}),(0,Z.jsx)(`span`,{children:`Chat Tab`})]})]})]}),i?(0,Z.jsx)(`p`,{className:`text-[11px] text-muted-foreground line-clamp-2 leading-relaxed`,children:i}):null,(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 border-t border-border/40 pt-2 text-[11px]`,children:[(0,Z.jsx)(`div`,{className:`flex items-center gap-2 min-w-0`,children:e.status===`running`&&(e.currentTool||e.lastTool)?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-primary font-mono text-[10px] bg-primary/10 px-1.5 py-0.5 rounded truncate`,children:[(0,Z.jsx)(li,{className:`h-3 w-3 shrink-0 animate-pulse`}),e.currentTool?e.currentTool:`last: ${e.lastTool}`]}):e.error?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-destructive text-[10px] truncate`,children:[(0,Z.jsx)(Rr,{className:`h-3 w-3 shrink-0`}),e.error.message]}):(0,Z.jsxs)(`span`,{className:`text-[10px] text-muted-foreground font-mono`,children:[`iter `,e.iteration,` · `,e.toolCalls,` tools`]})}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 ml-auto`,children:[e.costUsd>0&&(0,Z.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:ec(e.costUsd)}),e.finalText&&(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>l(e.id,e.finalText),className:`inline-flex items-center gap-1 text-[10px] text-muted-foreground hover:text-foreground hover:bg-muted px-1.5 py-0.5 rounded transition-colors cursor-pointer`,title:t(`activity:fleet.copyOutput`),children:[a===e.id?(0,Z.jsx)(ui,{className:`h-3 w-3 text-success`}):(0,Z.jsx)(oi,{className:`h-3 w-3`}),(0,Z.jsx)(`span`,{children:a===e.id?t(`common:action.copied`):t(`common:action.copy`)})]})]})]})]},e.id)})})]})}var ov={up:(0,Z.jsx)(Di,{className:`h-3.5 w-3.5 text-success`}),down:(0,Z.jsx)(cr,{className:`h-3.5 w-3.5 text-destructive`}),stable:(0,Z.jsx)(zr,{className:`h-3.5 w-3.5 text-warning`})},sv={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 cv({goal:e,className:t}){let{t:n}=H(),[r,i]=(0,X.useState)(!1);(0,X.useEffect)(()=>{let e=V();e?.send?.({type:`goal.get`});let t=setInterval(()=>{e?.send?.({type:`goal.get`})},1e4);return()=>clearInterval(t)},[]),(0,X.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=sv[e.goalState],c=e.deliverables?.filter(e=>e.status===`done`).length??0,l=e.deliverables?.length??0,u=e.progressTrend?ov[e.progressTrend]:null;return(0,Z.jsxs)(`div`,{className:G(`rounded-lg border border-border bg-card/60 backdrop-blur-sm`,t),children:[(0,Z.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,Z.jsx)(wr,{className:`h-4 w-4 text-primary`}),(0,Z.jsx)(`span`,{className:`text-xs font-semibold text-foreground flex-1 min-w-0 truncate`,children:n(`activity:goal.heading`)}),(0,Z.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,Z.jsx)(ot,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}):(0,Z.jsx)(Ct,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`})]}),!r&&(0,Z.jsxs)(`div`,{className:`px-3 pb-3 space-y-3 border-t pt-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`text-xs text-foreground leading-relaxed whitespace-pre-wrap break-words`,children:e.goal}),e.refinedGoal&&e.refinedGoal!==e.goal&&(0,Z.jsxs)(`div`,{className:`mt-1.5 p-2 rounded bg-accent/40 border border-border/50`,children:[(0,Z.jsx)(`p`,{className:`text-[10px] text-muted-foreground mb-0.5 uppercase tracking-wider font-medium`,children:n(`activity:goal.refined`)}),(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed whitespace-pre-wrap break-words`,children:e.refinedGoal})]})]}),(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between text-[10px]`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground uppercase tracking-wider font-medium`,children:n(`activity:goal.progress`)}),(0,Z.jsxs)(`span`,{className:`flex items-center gap-1 tabular-nums`,children:[u,(0,Z.jsxs)(`span`,{className:`font-medium text-foreground`,children:[e.progress,`%`]})]})]}),(0,Z.jsx)(`div`,{className:`h-1.5 bg-muted rounded-full overflow-hidden`,children:(0,Z.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,Z.jsx)(`p`,{className:`text-[10px] text-muted-foreground italic`,children:e.progressNote})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] text-muted-foreground`,children:[(0,Z.jsx)(He,{className:`h-3 w-3`}),(0,Z.jsx)(`span`,{className:`tabular-nums font-medium`,children:e.iterations}),(0,Z.jsx)(`span`,{children:n(`activity:goal.iterations`)}),e.lastStatus&&(0,Z.jsx)(`span`,{className:`text-border`,children:`·`}),e.lastStatus&&(0,Z.jsx)(`span`,{className:`truncate`,children:e.lastStatus})]}),l>0&&(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between text-[10px] text-muted-foreground uppercase tracking-wider font-medium`,children:[(0,Z.jsx)(`span`,{children:n(`activity:goal.deliverables`)}),(0,Z.jsxs)(`span`,{className:`tabular-nums`,children:[c,`/`,l]})]}),(0,Z.jsx)(`ul`,{className:`space-y-0.5`,children:a.map(e=>(0,Z.jsxs)(`li`,{className:`flex items-start gap-1.5 text-[11px]`,children:[e.status===`done`?(0,Z.jsx)($t,{className:`h-3 w-3 text-success mt-0.5 shrink-0`}):(0,Z.jsx)(Vt,{className:`h-3 w-3 text-muted-foreground/70 mt-0.5 shrink-0`}),(0,Z.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,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-[10px] text-muted-foreground uppercase tracking-wider font-medium`,children:n(`activity:goal.recentActivity`)}),(0,Z.jsx)(`div`,{className:`space-y-1`,children:o.map((e,t)=>(0,Z.jsxs)(`div`,{className:`flex items-start gap-1.5 text-[10px] text-muted-foreground`,children:[(0,Z.jsxs)(`span`,{className:`font-mono tabular-nums shrink-0 text-foreground/60`,children:[`#`,e.iteration]}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.task||e.status||e.progressNote||`…`})]},`${e.iteration}-${t}`))})]})]})]})}var lv={in_progress:0,pending:1,completed:2},uv=`__no_session__`,dv=new Map,fv=new Set;se(e=>{dv.delete(e),fv.add(e)});function pv(){let{t:e}=H(),t=N(e=>e.todos),n=ve(),[r,i]=(0,X.useState)(new Set),a=V(),o=(0,X.useRef)(n??uv);(0,X.useLayoutEffect)(()=>{fv.has(o.current)||dv.set(o.current,new Set(r));let e=n??uv;fv.delete(e),i(new Set(dv.get(e)??[])),o.current=e},[n]),(0,X.useEffect)(()=>{n&&a.send({type:`todos.get`,payload:{sessionId:n}})},[n,a]);let s=(0,X.useCallback)(e=>{a.removeTodo(e)},[a]),c=(0,X.useCallback)(e=>{if(e.status===`in_progress`)return;let t=e.status===`completed`?`pending`:`completed`;a.updateTodoStatus(e.id,t)},[a]),l=[...t].sort((e,t)=>(lv[e.status]??9)-(lv[t.status]??9)),u=l.filter(e=>e.status===`completed`).length,d=l.filter(e=>e.status===`in_progress`),f=l.filter(e=>e.status===`pending`),p=l.filter(e=>e.status===`completed`),m=p.length>0,h=r.has(`completed`),g=e=>{i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},_=t=>{let n=t.status===`in_progress`&&t.activeForm?t.activeForm:t.content,r=t.status===`in_progress`,i=t.status===`completed`,a=!!(t.kanbanBoardId&&t.kanbanTaskId),o=!r&&!(a&&i);return(0,Z.jsxs)(`div`,{className:G(`relative px-3 py-1.5 flex items-start gap-2 text-[13px] group transition-colors`,o&&`hover:bg-accent/40`,r?`bg-warning/8`:i?`bg-success/5`:`bg-background`),children:[o&&(0,Z.jsx)(`button`,{type:`button`,className:`absolute inset-0 cursor-pointer`,"aria-label":e(`activity:todos.toggleAria`,{content:t.content}),onClick:()=>c(t)}),(0,Z.jsx)(`span`,{className:`pointer-events-none relative mt-0.5 shrink-0`,children:i?(0,Z.jsx)($t,{className:`w-3.5 h-3.5 text-success`}):r?(0,Z.jsx)(He,{className:`w-3.5 h-3.5 text-warning animate-spin`}):(0,Z.jsx)(Vt,{className:G(`w-3.5 h-3.5 transition-colors`,`text-muted-foreground/65 group-hover:text-success`)})}),(0,Z.jsxs)(`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,t.blockedBy?.length?(0,Z.jsx)(`span`,{className:`mt-0.5 block text-[11px] text-destructive`,children:e(`activity:todos.blockedBy`,{work:t.blockedBy.join(`; `)})}):null]}),!a&&(0,Z.jsx)(`button`,{type:`button`,onClick:()=>s(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,Z.jsx)(vr,{className:`w-3 h-3 text-muted-foreground`})})]},t.id)};return t.length===0?null:(0,Z.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/50 backdrop-blur-sm overflow-hidden`,children:[(0,Z.jsxs)(`div`,{className:`px-3 py-1.5 flex items-center gap-2 border-b border-border/50`,children:[(0,Z.jsx)(`h2`,{className:`text-[11px] font-semibold text-foreground uppercase tracking-wider`,children:e(`activity:work.todos`)}),(0,Z.jsxs)(`span`,{className:`tabular text-[10px] text-muted-foreground ml-auto`,children:[u,`/`,t.length]})]}),d.length>0&&(0,Z.jsx)(`div`,{className:`border-b border-border/30 last:border-b-0`,children:d.map(_)}),f.length>0&&(0,Z.jsx)(`div`,{className:`border-b border-border/30 last:border-b-0`,children:f.map(_)}),m&&(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>g(`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,Z.jsxs)(`span`,{className:`tabular`,children:[h?`▶`:`▼`,` `,e(`activity:todos.completedCount`,{count:p.length})]})}),!h&&p.map(_)]})]})}var mv={pending:{icon:(0,Z.jsx)(Vt,{className:`w-3.5 h-3.5`}),labelKey:`statusPending`,color:`text-muted-foreground/70`},in_progress:{icon:(0,Z.jsx)(He,{className:`w-3.5 h-3.5 animate-spin`}),labelKey:`statusInProgress`,color:`text-warning`},blocked:{icon:(0,Z.jsx)(si,{className:`w-3.5 h-3.5`}),labelKey:`statusBlocked`,color:`text-warning`},failed:{icon:(0,Z.jsx)(Rr,{className:`w-3.5 h-3.5`}),labelKey:`statusFailed`,color:`text-destructive`},review:{icon:(0,Z.jsx)(Tn,{className:`w-3.5 h-3.5`}),labelKey:`statusReview`,color:`text-info`},completed:{icon:(0,Z.jsx)($t,{className:`w-3.5 h-3.5`}),labelKey:`statusDone`,color:`text-success`}},hv={critical:`text-destructive`,high:`text-warning`,medium:`text-warning/85`,low:`text-muted-foreground`},gv={feature:`⚡`,bugfix:`🐛`,refactor:`♻️`,docs:`📝`,test:`🧪`,chore:`🔧`},_v=`__no_session__`,vv=new Map,yv=new Set;se(e=>{vv.delete(e),yv.add(e)});function bv(){let{t:e}=H(),[t,n]=(0,X.useState)([]),[r,i]=(0,X.useState)(new Set),a=V(),o=ve(),s=(0,X.useRef)(o??_v);(0,X.useLayoutEffect)(()=>{yv.has(s.current)||vv.set(s.current,new Set(r));let e=o??_v;yv.delete(e),i(new Set(vv.get(e)??[])),s.current=e},[o]),xs(`tasks.updated`,e=>{let t=e.payload;t?.sessionId&&o&&t.sessionId!==o||t?.tasks&&n(t.tasks)},{sessionId:o,deps:[o]}),(0,X.useEffect)(()=>{n([]),a.getTasks()},[o,a]);let c=(0,X.useCallback)(e=>{i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),l=(0,X.useCallback)((e,t)=>{a.updateTaskStatus(e,t)},[a]),u=[`in_progress`,`blocked`,`review`,`pending`,`failed`,`completed`],d=[...t].sort((e,t)=>u.indexOf(e.status)-u.indexOf(t.status)),f=new Map;for(let e of d){let t=f.get(e.status)??[];t.push(e),f.set(e.status,t)}let p=t.filter(e=>e.status===`completed`).length;return t.length===0?null:(0,Z.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/50 backdrop-blur-sm overflow-hidden`,children:[(0,Z.jsxs)(`div`,{className:`px-3 py-1.5 flex items-center gap-2 border-b border-border/50`,children:[(0,Z.jsx)(`h2`,{className:`text-[11px] font-semibold text-foreground uppercase tracking-wider`,children:e(`activity:work.tasks`)}),(0,Z.jsxs)(`span`,{className:`tabular text-[10px] text-muted-foreground ml-auto`,children:[p,`/`,t.length]})]}),u.map(t=>{let n=f.get(t);if(!n||n.length===0)return null;let i=mv[t],a=r.has(t);return(0,Z.jsxs)(`div`,{className:`border-b border-border/30 last:border-b-0`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>c(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,Z.jsxs)(`span`,{className:`tabular`,children:[a?`▶`:`▼`,` `,n.length,` `,e(`activity:task.${i.labelKey}`)]})}),!a&&n.map(t=>(0,Z.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,Z.jsx)(`span`,{className:G(`mt-0.5 shrink-0`,i.color),children:i.icon}),(0,Z.jsxs)(`span`,{className:`leading-snug flex-1 min-w-0`,children:[(0,Z.jsxs)(`span`,{className:G(t.status===`completed`?`text-muted-foreground line-through`:`text-foreground/80`),children:[gv[t.type],` `,t.title]}),t.priority!==`medium`&&(0,Z.jsx)(`span`,{className:G(`ml-1 text-[10px]`,hv[t.priority]),children:t.priority}),t.assignee&&(0,Z.jsxs)(`span`,{className:`ml-1 text-[10px] text-muted-foreground`,children:[`@`,t.assignee]}),t.estimateHours&&(0,Z.jsxs)(`span`,{className:`ml-1 text-[10px] text-muted-foreground`,children:[t.estimateHours,`h`]})]}),(0,Z.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,Z.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),l(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,Z.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),l(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,Z.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),l(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 xv={open:{icon:(0,Z.jsx)(Vt,{className:`w-3.5 h-3.5`}),labelKey:`statusOpen`,color:`text-muted-foreground/70`},in_progress:{icon:(0,Z.jsx)(He,{className:`w-3.5 h-3.5 animate-spin`}),labelKey:`statusInProgress`,color:`text-warning`},done:{icon:(0,Z.jsx)($t,{className:`w-3.5 h-3.5`}),labelKey:`statusDone`,color:`text-success`}},Sv=`__no_session__`,Cv=new Map,wv=new Set;se(e=>{Cv.delete(e),wv.add(e)});function Tv(){let{t:e}=H(),[t,n]=(0,X.useState)([]),[r,i]=(0,X.useState)(new Set),a=V(),o=ve(),s=(0,X.useRef)(o??Sv);(0,X.useLayoutEffect)(()=>{wv.has(s.current)||Cv.set(s.current,new Set(r));let e=o??Sv;wv.delete(e),i(new Set(Cv.get(e)??[])),s.current=e},[o]),(0,X.useEffect)(()=>{n([]),a.getPlan();let e=a.on(`plan.updated`,e=>{let t=e?.payload;t?.sessionId&&o&&t.sessionId!==o||t?.plan?.items&&n(t.plan.items)});return()=>{e()}},[o,a]);let c=(0,X.useCallback)(e=>{i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),l=(0,X.useCallback)((e,t)=>{a.updatePlanItem(e.id,t)},[a]),u=[`in_progress`,`open`,`done`],d=[...t].sort((e,t)=>u.indexOf(e.status)-u.indexOf(t.status)),f=new Map;for(let e of d){let t=f.get(e.status)??[];t.push(e),f.set(e.status,t)}let p=t.filter(e=>e.status===`done`).length;return t.length===0?null:(0,Z.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/50 backdrop-blur-sm overflow-hidden`,children:[(0,Z.jsxs)(`div`,{className:`px-3 py-1.5 flex items-center gap-2 border-b border-border/50`,children:[(0,Z.jsxs)(`h2`,{className:`text-[11px] font-semibold text-foreground uppercase tracking-wider`,children:[`📋 `,e(`activity:work.plan`)]}),(0,Z.jsxs)(`span`,{className:`tabular text-[10px] text-muted-foreground ml-auto`,children:[p,`/`,t.length]})]}),u.map(t=>{let n=f.get(t);if(!n||n.length===0)return null;let i=xv[t],a=r.has(t);return(0,Z.jsxs)(`div`,{className:`border-b border-border/30 last:border-b-0`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>c(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,Z.jsxs)(`span`,{className:`tabular`,children:[a?`▶`:`▼`,` `,n.length,` `,e(`activity:plan.${i.labelKey}`)]})}),!a&&n.map(t=>(0,Z.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,Z.jsx)(`span`,{className:G(`mt-0.5 shrink-0`,i.color),children:i.icon}),(0,Z.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,Z.jsxs)(`div`,{className:`flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity shrink-0`,children:[t.status===`open`&&(0,Z.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),l(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,Z.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),l(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,Z.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),l(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 Ev=[{id:`todos`,labelKey:`work.todos`,icon:`✅`},{id:`tasks`,labelKey:`work.tasks`,icon:`📋`},{id:`plan`,labelKey:`work.plan`,icon:`🗺️`}];function Dv(){let{t:e}=H(),t=K(e=>e.workDashboardTab),n=K(e=>e.setWorkDashboardTab);return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/50 backdrop-blur-sm overflow-hidden`,children:[(0,Z.jsx)(`div`,{className:`flex border-b border-border/50 bg-muted/30`,children:Ev.map(r=>(0,Z.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,Z.jsx)(`span`,{className:`text-xs`,children:r.icon}),e(`activity:${r.labelKey}`)]},r.id))}),(0,Z.jsx)(`div`,{className:G(t===`todos`?`block`:`hidden`),children:(0,Z.jsx)(pv,{})}),(0,Z.jsx)(`div`,{className:G(t===`tasks`?`block`:`hidden`),children:(0,Z.jsx)(bv,{})}),(0,Z.jsx)(`div`,{className:G(t===`plan`?`block`:`hidden`),children:(0,Z.jsx)(Tv,{})})]})}var Ov={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))`},kv=[Ov.primary,Ov.info,Ov.success,Ov.warning,Ov.destructive,Ov.muted],Av=e=>e.replace(/^wstack\/ap\//,``);function jv(e){return[...e].sort((e,t)=>e.allocatedAt-t.allocatedAt).map((e,t)=>({handle:e,color:kv[t%kv.length],y:60+t*48}))}var Mv={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 Nv({worktrees:e,baseBranch:t}){let{t:n}=H(),r=jv(e),i=Math.max(120,60+r.length*48+20);return(0,Z.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-border/70 bg-card/70 p-3`,children:(0,Z.jsxs)(`svg`,{width:`100%`,height:i,viewBox:`0 0 600 ${i}`,className:`min-w-[420px]`,role:`img`,"aria-label":n(`activity:worktree.graphAria`,{base:t||`HEAD`}),children:[(0,Z.jsx)(`title`,{children:n(`activity:worktree.graphAria`,{base:t||`HEAD`})}),(0,Z.jsx)(`line`,{x1:40,y1:20,x2:40,y2:i-10,stroke:Ov.primary,strokeWidth:3}),(0,Z.jsx)(`text`,{x:36,y:14,fontSize:11,fill:Ov.muted,children:t||`HEAD`}),(0,Z.jsx)(`circle`,{cx:40,cy:20,r:5,fill:Ov.primary}),r.map(e=>{let r=Mv[e.handle.status]??k(Mv.active),i=e.handle.status===`merged`,a=e.handle.status===`needs-review`||e.handle.status===`failed`;return(0,Z.jsxs)(`g`,{className:`transition-all duration-500`,children:[(0,Z.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:r.dash,opacity:r.opacity}),i?(0,Z.jsx)(`path`,{d:`M 220 ${e.y} C 160 ${e.y+20}, 100 ${e.y+24}, 40 ${e.y+24}`,fill:`none`,stroke:Ov.success,strokeWidth:2,opacity:.9}):null,(0,Z.jsx)(`circle`,{cx:220,cy:e.y,r:5,fill:a?Ov.destructive:e.color}),(0,Z.jsx)(`text`,{x:232,y:e.y-6,fontSize:12,fill:Ov.foreground,fontFamily:`monospace`,children:Av(e.handle.branch)}),(0,Z.jsx)(`text`,{x:232,y:e.y+10,fontSize:10,fill:Ov.muted,children:a?`⚠ ${e.handle.status}`:i?n(`activity:worktree.mergedLabel`,{base:t}):`+${e.handle.insertions}/-${e.handle.deletions} · ${e.handle.ownerLabel}`})]},e.handle.handleId)})]})})}var Pv={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 Fv(e){return Pv[e]??{icon:`?`,labelKey:``,tint:`border-border`,dot:`bg-muted-foreground`}}var Iv=e=>e.replace(/^wstack\/ap\//,``);function Lv({worktrees:e,baseBranch:t}){let{t:n}=H(),r=[...e].sort((e,t)=>e.allocatedAt-t.allocatedAt);return(0,Z.jsxs)(`div`,{className:`rounded-lg border bg-card/50 backdrop-blur-sm px-3 py-3`,children:[(0,Z.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,Z.jsx)(`span`,{className:`font-semibold tracking-wide uppercase text-[10px]`,children:n(`activity:worktree.lanesHeading`)}),(0,Z.jsxs)(`span`,{className:`opacity-60`,children:[`· `,n(`activity:worktree.base`)]}),(0,Z.jsx)(`code`,{className:`font-mono text-primary`,children:t||`HEAD`}),(0,Z.jsxs)(`span`,{className:`opacity-60`,children:[`· `,n(`activity:worktree.isolatedCount`,{count:r.length})]})]}),(0,Z.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:r.map(e=>{let t=Fv(e.status),r=e.status===`needs-review`,i=Math.min(100,e.insertions+e.deletions);return(0,Z.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,Z.jsx)(`span`,{className:G(`h-2.5 w-2.5 shrink-0 rounded-full`,t.dot),"aria-hidden":!0}),(0,Z.jsx)(`code`,{className:`w-44 shrink-0 truncate font-mono text-sm`,children:Iv(e.branch)}),(0,Z.jsxs)(`span`,{className:`shrink-0 rounded bg-muted px-2 py-0.5 text-xs text-muted-foreground`,children:[`⟵ `,e.ownerLabel]}),r?(0,Z.jsx)(`span`,{className:`font-mono text-xs font-bold text-destructive`,children:n(`activity:worktree.conflictBadge`)}):(0,Z.jsxs)(`span`,{className:`flex items-center gap-1 font-mono text-xs transition-all duration-500`,children:[(0,Z.jsxs)(`span`,{className:`text-success`,children:[`+`,e.insertions]}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:`·`}),(0,Z.jsxs)(`span`,{className:`text-destructive`,children:[`-`,e.deletions]}),(0,Z.jsxs)(`span`,{className:`ml-1 text-muted-foreground`,children:[e.files,`f`]})]}),(0,Z.jsx)(`div`,{className:`ml-auto hidden h-1 w-24 overflow-hidden rounded-full bg-muted sm:block`,children:(0,Z.jsx)(`div`,{className:`h-full bg-gradient-to-r from-success to-destructive transition-all duration-700`,style:{width:`${i}%`}})}),(0,Z.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,Z.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 Rv=e=>e?e.replace(/^wstack\/ap\//,``):``;function zv(){let{t:e}=H(),{client:t}=ha(),n=Aa(e=>e.orphans),r=Aa(e=>e.canClean),i=Aa(e=>e.cleanBlockedReason),a=Aa(e=>e.cleanResult),[o,s]=(0,X.useState)(!1);return(0,X.useEffect)(()=>{t?.send?.({type:`worktree.scan`})},[t]),(0,X.useEffect)(()=>{a&&s(!1)},[a]),n.length===0&&!a?null:(0,Z.jsxs)(`div`,{className:`rounded-md border border-warning/30 bg-warning/5 px-3 py-2 text-xs`,children:[n.length>0?(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(Kr,{className:`mt-0.5 h-4 w-4 shrink-0 text-warning`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`font-medium text-warning`,children:e(`activity:worktree.orphanCount`,{count:n.length})}),(0,Z.jsx)(`div`,{className:`mt-0.5 max-h-16 overflow-auto font-mono text-[10px] text-muted-foreground`,children:n.map((e,t)=>(0,Z.jsxs)(`div`,{className:`truncate`,children:[e.kind===`branch`?`⌥ `:`▢ `,Rv(e.branch)||e.dir]},`${e.kind}-${e.branch??e.dir??t}`))})]}),(0,Z.jsxs)(`button`,{type:`button`,disabled:!r||o,onClick:async()=>{let r=n.length;await $a({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,Z.jsx)(wt,{className:`h-3.5 w-3.5 animate-spin`}):(0,Z.jsx)(Xr,{className:`h-3.5 w-3.5`}),e(`activity:worktree.cleanConfirm`)]})]}):null,a&&(0,Z.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 Bv={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`}},Vv={goal:`Goal`,"goal-state":`Goal State`,fleet:`Fleet`,work:`Work`,worktrees:`Worktrees`,collab:`Collab`},Hv=[`goal`,`goal-state`,`fleet`,`work`,`worktrees`,`collab`];function Uv({section:e,icon:t,label:n,value:r,active:i,pulse:a,onClick:o}){let s=Bv[e],{t:c}=H();return(0,Z.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,Z.jsx)(`span`,{className:G(a&&`animate-pulse`),children:t}),n,r&&(0,Z.jsx)(`span`,{className:`tabular-nums opacity-80`,children:r})]})}function Wv(){let e=K(e=>e.dockSection),{t}=H(),n=K(e=>e.toggleDockSection),r=K(e=>e.hiddenChips),i=K(e=>e.toggleChipHidden),a=K(e=>e.dockCustomizeOpen),o=K(e=>e.setDockCustomizeOpen),s=ve(),c=Oa(e=>e.goal),l=Da(e=>e.phases.length),u=Da(e=>e.overallPercent),d=Da(e=>e.activePhaseId),f=Aa(e=>e.worktrees),p=N(e=>e.todos),m=_(e=>e.agents),h=ev(),g=(0,X.useMemo)(()=>Array.from(m.values()).filter(e=>A(e.sessionId,s)),[m,s]),v=g.length,y=(0,X.useMemo)(()=>g.filter(e=>e.status===`running`).length,[g]),b=p.filter(e=>e.status===`completed`).length,x=p.some(e=>e.status===`in_progress`),S=l>0,C=(0,X.useMemo)(()=>new Set(r),[r]),w={goal:S,"goal-state":c!==null,fleet:v>0,work:!0,worktrees:f.length>0,collab:!0},T={goal:(w.goal||e===`goal`)&&!C.has(`goal`),"goal-state":(w[`goal-state`]||e===`goal-state`)&&!C.has(`goal-state`),fleet:(w.fleet||e===`fleet`)&&!C.has(`fleet`),work:(w.work||e===`work`)&&!C.has(`work`),worktrees:(w.worktrees||e===`worktrees`)&&!C.has(`worktrees`),collab:(w.collab||e===`collab`)&&!C.has(`collab`)},E=e&&T[e]?e:null;return(0,Z.jsx)(`div`,{children:(0,Z.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:[T.goal&&(0,Z.jsx)(Uv,{section:`goal`,icon:(0,Z.jsx)(Zt,{className:`h-3 w-3`}),label:t(`activity:dock.goal`),value:`${u}%`,active:!1,pulse:d!=null,onClick:()=>Ba(`goal`)}),T[`goal-state`]&&c&&(0,Z.jsx)(Uv,{section:`goal-state`,icon:(0,Z.jsx)(wr,{className:`h-3 w-3`}),label:t(`activity:dock.goalState`),value:`${c.progress}%`,active:E===`goal-state`,pulse:c.goalState===`active`,onClick:()=>n(`goal-state`)}),T.fleet&&(0,Z.jsx)(Uv,{section:`fleet`,icon:(0,Z.jsx)(jr,{className:`h-3 w-3`}),label:t(`activity:dock.fleet`),value:`${y}/${v}`,active:E===`fleet`,pulse:y>0,onClick:()=>n(`fleet`)}),(0,Z.jsx)(Uv,{section:`work`,icon:(0,Z.jsx)(yt,{className:`h-3 w-3`}),label:t(`activity:dock.work`),value:p.length>0?`${b}/${p.length}`:void 0,active:E===`work`,pulse:x,onClick:()=>n(`work`)}),T.worktrees&&(0,Z.jsx)(Uv,{section:`worktrees`,icon:(0,Z.jsx)(Vi,{className:`h-3 w-3`}),label:t(`activity:dock.worktrees`),value:String(f.length),active:E===`worktrees`,onClick:()=>n(`worktrees`)}),h&&(0,Z.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,Z.jsx)(Vi,{className:`h-3 w-3 shrink-0 text-muted-foreground`}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate font-semibold text-foreground`,children:h.branch}),h.ahead>0&&(0,Z.jsxs)(`span`,{className:`text-success`,title:t(`activity:dock.ahead`,{count:h.ahead}),children:[`↑`,h.ahead]}),h.behind>0&&(0,Z.jsxs)(`span`,{className:`text-warning`,title:t(`activity:dock.behind`,{count:h.behind}),children:[`↓`,h.behind]}),h.added>0&&(0,Z.jsxs)(`span`,{className:`text-success`,title:t(`activity:dock.linesAdded`,{count:h.added}),children:[`+`,h.added]}),h.deleted>0&&(0,Z.jsxs)(`span`,{className:`text-destructive`,title:t(`activity:dock.linesDeleted`,{count:h.deleted}),children:[`-`,h.deleted]}),h.untracked>0&&(0,Z.jsxs)(`span`,{className:`text-muted-foreground`,title:t(`activity:dock.untrackedFiles`,{count:h.untracked}),children:[h.untracked,`?`]})]}),(0,Z.jsx)(Uv,{section:`collab`,icon:(0,Z.jsx)(fr,{className:`h-3 w-3`}),label:t(`activity:dock.collab`),active:E===`collab`,onClick:()=>n(`collab`)}),(0,Z.jsxs)(mo,{open:a,onOpenChange:o,children:[(0,Z.jsx)(ho,{asChild:!0,children:(0,Z.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,Z.jsx)(Je,{className:`h-3 w-3`})})}),(0,Z.jsxs)(vo,{align:`end`,className:`w-44`,children:[(0,Z.jsx)(So,{children:t(`activity:dock.dockChips`)}),(0,Z.jsx)(Co,{}),Hv.map(e=>(0,Z.jsx)(bo,{checked:!C.has(e),onCheckedChange:()=>i(e),onSelect:e=>e.preventDefault(),children:Vv[e]},e))]})]})]})})}var Gv={"goal-state":{titleKey:`activity:dock.goalState`,detailKey:`activity:dock.goalStateDetail`},fleet:{titleKey:`activity:dock.fleet`,detailKey:`activity:dock.fleetDetail`},work:{titleKey:`activity:dock.work`,detailKey:`activity:dock.workDetail`},worktrees:{titleKey:`activity:dock.worktrees`,detailKey:`activity:dock.worktreesDetail`},collab:{titleKey:`activity:dock.collab`,detailKey:`activity:dock.collabDetail`}};function Kv({sessionId:e}){let t=K(e=>e.dockSection),n=K(e=>e.setDockSection),r=K(e=>e.inspectorOpen),i=Oa(e=>e.goal),a=Aa(e=>e.worktrees),o=Aa(e=>e.baseBranch),[s,c]=(0,X.useState)(`graph`),{t:l}=H(),u=t!==null&&t!==`goal`,d=u?t:null,f=d?Gv[d]:null,p=r&&u?`sm:right-[min(680px,48vw)]`:``;return(0,X.useEffect)(()=>{if(!u)return;let e=e=>{e.key===`Escape`&&n(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[u,n]),(0,Z.jsxs)(`aside`,{id:`workspace-dock-inspector`,"data-testid":u?`workspace-dock-inspector`:void 0,"aria-hidden":!u,inert:!u||void 0,"aria-label":f?l(`activity:dock.inspectorNamed`,{name:l(f.titleKey)}):l(`activity:dock.inspector`),className:G(`fixed inset-y-0 right-0 z-40 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]`,p,u?`translate-x-0`:`pointer-events-none translate-x-full`),children:[(0,Z.jsxs)(`header`,{className:`relative shrink-0 border-b border-border/70 bg-muted/20 px-4 py-3 pr-12`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-foreground`,children:[(0,Z.jsx)(Sr,{className:`h-4 w-4 text-primary`}),l(f?f.titleKey:`activity:dock.workspace`)]}),(0,Z.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:l(f?f.detailKey:`activity:dock.workspaceDetails`)}),(0,Z.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":l(`activity:dock.closeWorkspaceInspector`),title:l(`activity:dock.closeWorkspaceInspector`),children:(0,Z.jsx)(St,{className:`h-4 w-4`})})]}),(0,Z.jsxs)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain p-3 sm:p-4`,children:[d===`goal-state`&&(i?(0,Z.jsx)(cv,{goal:i}):(0,Z.jsx)(qv,{title:l(`activity:dock.noActiveGoal`),detail:l(`activity:dock.noActiveGoalDetail`)})),d===`fleet`&&(0,Z.jsx)(av,{}),d===`worktrees`&&(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:[`graph`,`lanes`].map(e=>(0,Z.jsx)(`button`,{type:`button`,onClick:()=>c(e),className:G(`rounded-md border px-2.5 py-1 text-xs capitalize transition-colors`,s===e?`border-primary/30 bg-primary/10 text-primary`:`border-border text-muted-foreground hover:text-foreground`),children:e},e))}),(0,Z.jsx)(zv,{}),s===`graph`?(0,Z.jsx)(Nv,{worktrees:a,baseBranch:o||`HEAD`}):(0,Z.jsx)(Lv,{worktrees:a,baseBranch:o||`HEAD`})]}),(0,Z.jsx)(`div`,{className:G(d===`work`?`block`:`hidden`),id:`panel-work`,children:(0,Z.jsx)(Dv,{})}),(0,Z.jsx)(`div`,{className:G(d===`collab`?`block`:`hidden`),children:(0,Z.jsx)(rv,{sessionId:e})})]})]})}function qv({title:e,detail:t}){return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-muted/20 px-3 py-2 text-xs`,children:[(0,Z.jsx)(`div`,{className:`font-medium text-foreground`,children:e}),(0,Z.jsx)(`div`,{className:`mt-1 text-muted-foreground`,children:t})]})}function Jv({sessionId:e,desktopShell:t}){let{t:n}=H(),{currentView:r,terminalOpen:i,setTerminalOpen:a}=K(Me(e=>({currentView:e.currentView,terminalOpen:e.terminalOpen,setTerminalOpen:e.setTerminalOpen}))),o=e,s=Lm;return(0,Z.jsxs)(Z.Fragment,{children:[o&&(0,Z.jsxs)(`div`,{className:G(`flex flex-col`,r!==`chat`&&`ws-view-parked`),...r===`chat`?{}:{inert:!0,"aria-hidden":!0},children:[(0,Z.jsx)(`div`,{className:`ws-workspace-dock-wrap shrink-0 px-3 pt-2 sm:px-4`,children:(0,Z.jsx)(Wv,{})}),(0,Z.jsx)(Lg,{})]}),(0,Z.jsx)(`div`,{className:G(`flex min-h-0 min-w-0 flex-1 flex-col`,r!==`chat`&&`ws-view-parked`),...r===`chat`?{}:{inert:!0,"aria-hidden":!0},children:(0,Z.jsx)(Os,{level:`panel`,name:n(`activity:panels.chat`),children:(0,Z.jsx)($_,{})})}),r!==`chat`&&(0,Z.jsx)(Im,{view:r,onCloseToChat:s}),i&&(0,Z.jsx)(Os,{level:`panel`,name:n(`activity:panels.terminal`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Wu,{label:n(`common:loadingNamed`,{name:n(`activity:panels.terminal`)})}),children:(0,Z.jsx)(Yv,{desktopShell:t,onClose:()=>a(!1)})})})]})}var Yv=(0,X.lazy)(()=>ta(()=>import(`./TerminalPanel-BiWnldbB.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([64,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,19,20,21,65,66])));function Xv(){let e=W(e=>e.wrongProxyEnabled),t=W(e=>e.wrongProxyUrl),[n,r]=(0,X.useState)(()=>({status:e?`checking`:`disabled`,latencyMs:null,url:t||`http://localhost:3444`}));return(0,X.useEffect)(()=>{if(!e||!t){r({status:`disabled`,latencyMs:null,url:t||`http://localhost:3444`});return}let n=!1,i=async()=>{let e=t.trim().replace(/\/+$/,``),i=`${e}/api/health`,a=Date.now(),o=new AbortController,s=setTimeout(()=>o.abort(),2e3);try{let t=await fetch(i,{method:`GET`,signal:o.signal,headers:{accept:`application/json`}});if(clearTimeout(s),n)return;let c=t.ok&&t.status>=200&&t.status<300;r({status:c?`connected`:`error`,latencyMs:Date.now()-a,url:e,error:c?void 0:`HTTP ${t.status}`})}catch(t){if(clearTimeout(s),n)return;r({status:`error`,latencyMs:Date.now()-a,url:e,error:t instanceof Error?t.message:`Unreachable`})}};i();let a=setInterval(()=>void i(),1e4);return()=>{n=!0,clearInterval(a)}},[e,t]),n}function Zv(){let e=W(e=>e.hqEnabled),t=W(e=>e.hqUrl),n=W(e=>e.hqToken),[r,i]=(0,X.useState)(()=>({status:e&&t?`checking`:`disabled`,latencyMs:null,url:t||``}));return(0,X.useEffect)(()=>{if(!e||!t){i({status:`disabled`,latencyMs:null,url:t||``});return}let r=!1,a=async()=>{let e=t.trim().replace(/\/+$/,``),a=`${e}/api/auth/status`,o=Date.now(),s=new AbortController,c=setTimeout(()=>s.abort(),2e3);try{let t={accept:`application/json`};n&&(t.Authorization=`Bearer ${n}`);let l=await fetch(a,{method:`GET`,signal:s.signal,headers:t});if(clearTimeout(c),r)return;let u=l.ok||l.status===401;i({status:u?`connected`:`error`,latencyMs:Date.now()-o,url:e,error:u?void 0:`HTTP ${l.status}`})}catch(t){if(clearTimeout(c),r)return;i({status:`error`,latencyMs:Date.now()-o,url:e,error:t instanceof Error?t.message:`Unreachable`})}};a();let o=setInterval(()=>void a(),1e4);return()=>{r=!0,clearInterval(o)}},[e,t,n]),r}function Qv(){let e=Na(e=>e.snapshot),t=K(e=>e.setCronJobsOpen),n=e?.jobs??[],r=n.filter(e=>e.overdue).length,i=n.filter(e=>e.enabled&&!e.overdue).length,a=n.length;return a===0?null:(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>t(!0),className:G(`relative inline-flex h-8 items-center gap-1.5 rounded-md border px-2 text-xs transition-colors`,r>0?`border-destructive/40 bg-destructive/10 text-destructive hover:bg-destructive/15`:`border-border/70 bg-background/60 text-muted-foreground hover:bg-accent/60 hover:text-foreground`),title:`${a} cron job${a===1?``:`s`}${r>0?`, ${r} overdue`:``}`,children:[(0,Z.jsx)(An,{className:`h-3.5 w-3.5`}),(0,Z.jsxs)(`span`,{className:`hidden lg:inline`,children:[i,`/`,a]}),r>0?(0,Z.jsx)(`span`,{className:`min-w-4 bg-destructive/15 px-1 text-[10px] font-semibold tabular-nums text-destructive`,children:r>99?`99+`:r}):null]})}function $v(e,t){let n=Math.max(0,Date.now()-e),r=Math.floor(n/1e3);if(r<10)return t(`toasts:menu.justNow`,{defaultValue:`Just now`});if(r<60)return t(`toasts:menu.secondsAgo`,{count:r,defaultValue:`${r}s ago`});let i=Math.floor(r/60);if(i<60)return t(`toasts:menu.minutesAgo`,{count:i,defaultValue:`${i}m ago`});let a=Math.floor(i/60);if(a<24)return t(`toasts:menu.hoursAgo`,{count:a,defaultValue:`${a}h ago`});let o=Math.floor(a/24);return t(`toasts:menu.daysAgo`,{count:o,defaultValue:`${o}d ago`})}function ey({variant:e}){return e===`success`?(0,Z.jsx)(ui,{className:`h-4 w-4 text-success shrink-0`}):e===`error`?(0,Z.jsx)(Rr,{className:`h-4 w-4 text-destructive shrink-0`}):e===`warn`?(0,Z.jsx)(Kr,{className:`h-4 w-4 text-warning shrink-0`}):(0,Z.jsx)(tr,{className:`h-4 w-4 text-info shrink-0`})}function ty({item:e,onMarkAsRead:t,onRemove:n}){let{t:r}=H(),i=(0,X.useMemo)(()=>$v(e.timestamp,r),[e.timestamp,r]),a=(0,X.useMemo)(()=>new Date(e.timestamp).toLocaleString(),[e.timestamp]);return(0,Z.jsxs)(`div`,{role:`menuitem`,tabIndex:0,onClick:()=>{e.read||t()},onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),e.read||t())},className:G(`group relative flex items-start gap-2.5 px-3 py-2.5 text-xs transition-colors cursor-pointer outline-none select-none`,`hover:bg-accent/50 focus-visible:bg-accent/60`,e.read?`opacity-85`:`bg-primary/[0.04]`),children:[(0,Z.jsx)(`div`,{className:`mt-0.5 shrink-0`,children:(0,Z.jsx)(ey,{variant:e.variant})}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0 pr-1`,children:[(0,Z.jsx)(`div`,{className:G(`whitespace-pre-wrap break-words leading-relaxed text-foreground`,!e.read&&`font-medium`),children:e.message}),(0,Z.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,title:a,children:[(0,Z.jsx)(He,{className:`h-3 w-3 opacity-70`}),i]}),e.action&&(0,Z.jsx)(`button`,{type:`button`,onClick:n=>{n.stopPropagation(),e.action?.onClick(),t()},className:`font-medium text-primary hover:underline`,children:e.action.label})]})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[!e.read&&(0,Z.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),t()},className:`rounded p-0.5 text-muted-foreground hover:bg-accent hover:text-foreground`,title:r(`toasts:menu.markAsRead`,{defaultValue:`Mark as read`}),"aria-label":r(`toasts:menu.markAsRead`,{defaultValue:`Mark as read`}),children:(0,Z.jsx)(ui,{className:`h-3 w-3`})}),(0,Z.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),n()},className:`rounded p-0.5 text-muted-foreground opacity-60 hover:opacity-100 hover:bg-destructive/10 hover:text-destructive transition-opacity`,title:r(`toasts:menu.remove`,{defaultValue:`Remove notification`}),"aria-label":r(`toasts:menu.remove`,{defaultValue:`Remove notification`}),children:(0,Z.jsx)(St,{className:`h-3 w-3`})}),!e.read&&(0,Z.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary shrink-0`,"aria-label":`Unread indicator`})]})]})}function ny({defaultOpen:e,open:t,onOpenChange:n}={}){let{t:r}=H(),i=m(e=>e.notifications),a=m(e=>e.markAsRead),o=m(e=>e.markAllAsRead),s=m(e=>e.clearAll),c=m(e=>e.removeNotification),[l,u]=(0,X.useState)(`all`),d=(0,X.useMemo)(()=>i.filter(e=>!e.read).length,[i]),f=(0,X.useMemo)(()=>l===`unread`?i.filter(e=>!e.read):i,[i,l]),p=(0,X.useCallback)(()=>{o()},[o]),h=(0,X.useCallback)(()=>{s()},[s]);return(0,Z.jsxs)(mo,{defaultOpen:e,open:t,onOpenChange:n,children:[(0,Z.jsx)(ho,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,"data-testid":`notification-menu-trigger`,className:G(`relative inline-flex h-8 w-8 items-center justify-center rounded-md border border-border/70 bg-background/60 text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground`,d>0&&`text-foreground`),title:d>0?`${r(`toasts:menu.title`,{defaultValue:`Notifications`})} (${d} ${r(`toasts:menu.unreadCount`,{count:d,defaultValue:`${d} unread`})})`:r(`toasts:menu.title`,{defaultValue:`Notifications`}),"aria-label":r(`toasts:menu.title`,{defaultValue:`Notifications`}),children:[d>0?(0,Z.jsx)(Ur,{className:`h-3.5 w-3.5 text-primary`}):(0,Z.jsx)(Qn,{className:`h-3.5 w-3.5`}),d>0&&(0,Z.jsx)(`span`,{"data-testid":`notification-badge`,className:`absolute -top-1 -right-1 flex h-4 min-w-4 items-center justify-center rounded-full bg-destructive px-1 text-[10px] font-bold text-destructive-foreground shadow-sm`,children:d>99?`99+`:d})]})}),(0,Z.jsxs)(vo,{align:`end`,sideOffset:6,className:`w-80 sm:w-96 max-w-[calc(100vw-1rem)] p-0 rounded-xl border border-border/80 bg-card/95 backdrop-blur-xl shadow-2xl overflow-hidden text-card-foreground`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/60 px-3.5 py-2.5 bg-muted/30`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`font-semibold text-xs text-foreground`,children:r(`toasts:menu.title`,{defaultValue:`Notifications`})}),d>0?(0,Z.jsxs)(`span`,{className:`rounded-full bg-primary/15 px-2 py-0.5 text-[10px] font-medium text-primary tabular-nums`,children:[d,` `,r(`toasts:menu.tabUnread`,{defaultValue:`Unread`}).toLowerCase()]}):null]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Z.jsxs)(`button`,{type:`button`,disabled:d===0,onClick:p,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground disabled:opacity-40 disabled:pointer-events-none`,title:r(`toasts:menu.markAllRead`,{defaultValue:`Mark all as read`}),children:[(0,Z.jsx)(vt,{className:`h-3.5 w-3.5`}),(0,Z.jsx)(`span`,{children:r(`toasts:menu.markAllRead`,{defaultValue:`Mark all as read`})})]}),(0,Z.jsxs)(`button`,{type:`button`,disabled:i.length===0,onClick:h,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive disabled:opacity-40 disabled:pointer-events-none`,title:r(`toasts:menu.clearAll`,{defaultValue:`Clear all`}),children:[(0,Z.jsx)(vr,{className:`h-3.5 w-3.5`}),(0,Z.jsx)(`span`,{children:r(`toasts:menu.clearAll`,{defaultValue:`Clear all`})})]})]})]}),(0,Z.jsxs)(`div`,{className:`flex border-b border-border/50 bg-background/50 px-3 py-1.5 gap-1.5 text-xs`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>u(`all`),className:G(`flex-1 rounded-md px-2.5 py-1 text-center font-medium transition-all`,l===`all`?`bg-accent text-accent-foreground shadow-xs`:`text-muted-foreground hover:bg-accent/50 hover:text-foreground`),children:[r(`toasts:menu.tabAll`,{defaultValue:`All`}),` (`,i.length,`)`]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>u(`unread`),className:G(`flex-1 rounded-md px-2.5 py-1 text-center font-medium transition-all`,l===`unread`?`bg-accent text-accent-foreground shadow-xs`:`text-muted-foreground hover:bg-accent/50 hover:text-foreground`),children:[r(`toasts:menu.tabUnread`,{defaultValue:`Unread`}),` (`,d,`)`]})]}),(0,Z.jsx)(`div`,{role:`list`,className:`max-h-[340px] overflow-y-auto divide-y divide-border/30`,"aria-label":r(`toasts:menu.title`,{defaultValue:`Notifications`}),children:f.length===0?(0,Z.jsxs)(`div`,{className:`flex flex-col items-center justify-center px-4 py-8 text-center text-muted-foreground`,children:[(0,Z.jsx)(Ci,{className:`h-7 w-7 text-muted-foreground/40 mb-2`}),(0,Z.jsx)(`p`,{className:`text-xs font-medium text-foreground`,children:l===`unread`&&i.length>0?r(`toasts:menu.allRead`,{defaultValue:`All caught up`}):r(`toasts:menu.empty`,{defaultValue:`No notifications`})}),(0,Z.jsx)(`p`,{className:`text-[11px] text-muted-foreground mt-0.5 max-w-[220px]`,children:l===`unread`&&i.length>0?r(`toasts:menu.allRead`,{defaultValue:`All caught up`}):r(`toasts:menu.emptyHint`,{defaultValue:`Toasts and system notifications will appear here.`})})]}):f.map(e=>(0,Z.jsx)(ty,{item:e,onMarkAsRead:()=>a(e.id),onRemove:()=>c(e.id)},e.id))})]})]})}function ry(e){return e.split(`-`).map(e=>e.slice(0,1).toUpperCase()+e.slice(1)).join(` `)}function iy(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 ay(){let[e,t]=(0,X.useState)(null);return(0,X.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 oy({currentView:e,projectName:t,sessionLabel:n,isLoading:r,iteration:i,onPalette:a,onSettings:o}){let{t:s}=H(),{theme:c,setTheme:l,palette:u,setPalette:d}=Vu(),f=R(e=>e.wsConnected),p=N(e=>e.appVersion),m=N(e=>e.latestVersion),h=N(e=>e.updateAvailable),g=N(e=>e.droppedTools),_=c===`system`?typeof window<`u`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:c,v=(0,X.useCallback)(()=>{l(_===`dark`?`light`:`dark`)},[_,l]),y=K(e=>e.toggleSidebar),b=Xv(),x=Zv(),S=b.status===`connected`?`WrongProxy: Connected${b.latencyMs==null?``:` (${b.latencyMs}ms)`} · ${b.url}`:b.status===`error`?`WrongProxy: Unreachable · ${b.url}${b.error?` (${b.error})`:``}`:b.status===`checking`?`WrongProxy: Checking · ${b.url}`:`WrongProxy: Disabled`,C=x.status===`connected`?`HQ: Connected${x.latencyMs==null?``:` (${x.latencyMs}ms)`} · ${x.url}`:x.status===`error`?`HQ: Unreachable · ${x.url}${x.error?` (${x.error})`:``}`:x.status===`checking`?`HQ: Checking · ${x.url}`:`HQ: Disabled`,w=ay(),T=w?w.memoryUsage.heapUsed/w.heapLimit:0,E=w?.codebaseIndexServer,D=E?.health,O=D?.server;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-border/70 bg-card/85 px-2.5 py-1.5 shadow-sm backdrop-blur-xl md:hidden`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:y,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`,"aria-label":`Toggle navigation menu`,title:`Toggle navigation`,children:(0,Z.jsx)(ht,{className:`h-4 w-4`})}),(0,Z.jsx)(`div`,{className:`min-w-0`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`truncate text-xs font-semibold`,children:t||`WrongStack`}),(0,Z.jsx)(`span`,{className:`rounded bg-muted/60 px-1 py-0.5 text-[10px] text-muted-foreground font-mono`,children:ry(e)}),r&&(0,Z.jsx)(`span`,{className:`inline-flex items-center gap-0.5 text-[10px] font-medium text-primary`,children:(0,Z.jsx)(jr,{className:`h-3 w-3 animate-pulse`})})]})})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,Z.jsx)(Lc,{}),(0,Z.jsx)(ny,{}),(0,Z.jsx)(`button`,{type:`button`,onClick:v,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:_===`dark`?`Switch to light theme`:`Switch to dark theme`,children:_===`dark`?(0,Z.jsx)(Ji,{className:`h-3.5 w-3.5`}):(0,Z.jsx)(qe,{className:`h-3.5 w-3.5`})}),(0,Z.jsxs)(mo,{children:[(0,Z.jsx)(ho,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,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:`More options`,"aria-label":`More options`,children:(0,Z.jsx)(Mr,{className:`h-3.5 w-3.5`})})}),(0,Z.jsxs)(vo,{align:`end`,className:`w-48`,children:[(0,Z.jsxs)(yo,{onSelect:a,className:`gap-2`,children:[(0,Z.jsx)(xr,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:s(`activity:topbar.command`)})]}),(0,Z.jsxs)(yo,{onSelect:o,className:`gap-2`,children:[(0,Z.jsx)(kt,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:s(`activity:topbar.settings`)})]}),(0,Z.jsxs)(`div`,{className:`border-t border-border/60 my-1 px-2 py-1 space-y-1 text-[11px] text-muted-foreground`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`span`,{children:`Backend WS`}),(0,Z.jsx)(`span`,{className:G(`font-mono font-medium`,f?`text-success`:`text-warning`),children:f?`Connected`:`Offline`})]}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`span`,{children:`WrongProxy`}),(0,Z.jsx)(`span`,{className:G(`font-mono font-medium`,b.status===`connected`?`text-success`:b.status===`error`?`text-destructive`:`text-muted-foreground`),children:b.status===`connected`?`Connected`:b.status===`error`?`Offline`:`Disabled`})]}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`span`,{children:`HQ`}),(0,Z.jsx)(`span`,{className:G(`font-mono font-medium`,x.status===`connected`?`text-success`:x.status===`error`?`text-destructive`:`text-muted-foreground`),children:x.status===`connected`?`Connected`:x.status===`error`?`Offline`:`Disabled`})]})]})]})]})]})]}),(0,Z.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,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Z.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate text-sm font-semibold`,children:t||`WrongStack`}),p?(0,Z.jsxs)(`span`,{className:G(`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-[11px] font-medium tabular-nums`,h&&m&&m!==p?`border-warning/40 bg-warning/10 text-warning`:`border-border/70 bg-muted/50 text-muted-foreground`),title:h&&m&&m!==p?`Update available: v${p} → v${m} — run wstack update`:`WrongStack v${p}`,children:[`v`,p,h&&m&&m!==p?(0,Z.jsxs)(`span`,{className:`text-[10px] opacity-80`,children:[`→ v`,m]}):null]}):null,(0,Z.jsx)(`span`,{className:`rounded-md border border-border/70 bg-muted/50 px-1.5 py-0.5 text-[11px] text-muted-foreground`,children:ry(e)}),(0,Z.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,Z.jsx)(jr,{className:`h-3 w-3 animate-pulse`}):(0,Z.jsx)(et,{className:`h-3 w-3`}),r?`Running`:`Ready`,i?(0,Z.jsxs)(`span`,{className:`tabular`,children:[i.index,i.max>0?`/${i.max}`:``]}):null]}),(0,Z.jsx)(Lc,{showCountWhenZero:!0}),w?(0,Z.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`,T>=.85?`text-destructive`:T>=.6?`text-warning`:`text-success`),title:`WebUI server PID ${w.pid} · heap ${iy(w.memoryUsage.heapUsed)} / ${iy(w.heapLimit)}`,children:[`RAM `,iy(w.memoryUsage.rss)]}):null,E?(0,Z.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`,E.status===`connected`?`text-success`:E.status===`unresponsive`||E.status===`error`?`text-destructive`:E.status===`degraded`||E.status===`connecting`||E.status===`stopping`?`text-warning`:`text-muted-foreground`),title:[`Codebase index: ${D?.status??E.status}`,E.pid?`PID ${E.pid}`:null,D?.latencyMs==null?null:`RTT ${D.latencyMs}ms`,O?`RAM ${iy(O.memory.rss)}`:null,D?.missedHeartbeats?`missed ${D.missedHeartbeats}`:null].filter(Boolean).join(` · `),children:[`Index `,D?.status??E.status]}):null,g>0?(0,Z.jsxs)(`span`,{className:`rounded-md border border-warning/40 bg-warning/10 px-1.5 py-0.5 text-[11px] font-medium tabular-nums text-warning`,title:`${g} tool(s) dropped from provider requests due to maxTools limit`,children:[`-`,g,` tools`]}):null]}),(0,Z.jsx)(`div`,{className:`mt-0.5 truncate text-[11px] text-muted-foreground`,children:n||`No named session`})]})}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,Z.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:s(`activity:topbar.commandPalette`),children:[(0,Z.jsx)(xr,{className:`h-3.5 w-3.5`}),s(`activity:topbar.command`)]}),(0,Z.jsx)(`button`,{type:`button`,onClick:v,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:_===`dark`?`Switch to light theme`:`Switch to dark theme`,children:_===`dark`?(0,Z.jsx)(Ji,{className:`h-3.5 w-3.5`}):(0,Z.jsx)(qe,{className:`h-3.5 w-3.5`})}),(0,Z.jsxs)(mo,{children:[(0,Z.jsx)(ho,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,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:`${s(`settings:general.paletteSwitcherTitle`)}: ${s(I(u).labelKey)}`,"aria-label":`${s(`settings:general.paletteSwitcherTitle`)}: ${s(I(u).labelKey)}`,children:(0,Z.jsx)(Jn,{className:`h-3.5 w-3.5`})})}),(0,Z.jsxs)(vo,{align:`end`,className:`w-56`,children:[(0,Z.jsx)(So,{children:s(`settings:general.paletteHeading`)}),le.map(e=>(0,Z.jsxs)(yo,{onSelect:()=>d(e.id),className:`gap-2`,children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`h-4 w-4 shrink-0 rounded-[3px] border border-border/70`,style:{background:`linear-gradient(90deg, ${e.swatch} 0 50%, ${e.swatchSecondary} 50% 100%)`}}),(0,Z.jsx)(`span`,{className:`flex-1`,children:s(e.labelKey)}),u===e.id?(0,Z.jsx)(ui,{className:`h-3.5 w-3.5 text-primary`,"aria-hidden":!0}):null]},e.id))]})]}),(0,Z.jsx)(Qv,{}),(0,Z.jsx)(ny,{}),(0,Z.jsx)(`button`,{type:`button`,onClick:o,className:G(`inline-flex h-8 w-8 items-center justify-center rounded-md border bg-background/60 transition-colors`,b.status===`connected`?`border-border/70 text-success hover:bg-accent/60`:b.status===`error`?`border-destructive/40 bg-destructive/10 text-destructive hover:bg-destructive/20`:`border-border/50 text-muted-foreground/40 hover:text-muted-foreground hover:bg-accent/60`),title:S,"aria-label":S,"data-testid":`wrongproxy-status-button`,children:(0,Z.jsx)(xt,{className:`h-3.5 w-3.5`})}),(0,Z.jsx)(`button`,{type:`button`,onClick:o,className:G(`inline-flex h-8 w-8 items-center justify-center rounded-md border bg-background/60 transition-colors`,x.status===`connected`?`border-border/70 text-success hover:bg-accent/60`:x.status===`error`?`border-destructive/40 bg-destructive/10 text-destructive hover:bg-destructive/20`:`border-border/50 text-muted-foreground/40 hover:text-muted-foreground hover:bg-accent/60`),title:C,"aria-label":C,"data-testid":`hq-status-button`,children:(0,Z.jsx)(Zr,{className:`h-3.5 w-3.5`})}),(0,Z.jsx)(`span`,{role:`status`,"aria-label":f?`Connected`:`Disconnected`,className:G(`inline-flex h-8 w-8 items-center justify-center rounded-md border border-border/70 bg-background/60`,f?`text-success`:`text-warning`),title:f?`Connected`:`Disconnected`,"data-testid":`ws-status-indicator`,children:f?(0,Z.jsx)(_t,{className:`h-3.5 w-3.5`}):(0,Z.jsx)(En,{className:`h-3.5 w-3.5`})}),(0,Z.jsx)(`button`,{type:`button`,onClick:o,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:s(`activity:topbar.settings`),children:(0,Z.jsx)(kt,{className:`h-3.5 w-3.5`})})]})]})})]})}var sy=(0,X.lazy)(()=>ta(()=>import(`./CronJobsPanel-DGKW_zwc.js`).then(e=>({default:e.CronJobsPanel})),__vite__mapDeps([67,1,2,3,4,5,6,7,8,9,10,11,12,13,14,18,0,15,16,19,20,21,29]))),cy=(0,X.lazy)(()=>ta(()=>import(`./ProcessMonitor-ygFLD5zk.js`).then(e=>({default:e.ProcessMonitor})),__vite__mapDeps([63,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,25,20,18,19,21,23,26,29]))),ly=(0,X.lazy)(()=>ta(()=>import(`./QueuePanel-CJlIV0pX.js`).then(e=>({default:e.QueuePanel})),__vite__mapDeps([68,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,19,18,20,21,29])));function uy(){let{t:e}=H(),{theme:n}=Vu(),r=oa(),{currentView:i,sidebarOpen:a,toggleSidebar:o,setSearchOpen:s,setSidebarOpen:c,setInspectorTab:l,setPaletteOpen:u,setShortcutsOpen:d,setModelSwitcherOpen:f,setPromptLibraryOpen:p,toggleInspector:m,setFleetMonitorOpen:g,setAgentsMonitorOpen:v,processMonitorOpen:y,setProcessMonitorOpen:b,queuePanelOpen:x,setQueuePanelOpen:S,cronJobsOpen:C,setCronJobsOpen:w,setTerminalOpen:E}=K(Me(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,setTerminalOpen:e.setTerminalOpen}))),D=q(e=>e.isLoading),O=q(e=>e.messages.length),k=T(e=>e.info),A=T(e=>e.promptedThisSession);(0,X.useEffect)(()=>{!k||k.chosen||k.variants.length!==0&&(O>0||A||T.getState().openPicker())},[k,O,A]);let j=N(e=>e.iteration),M=N(e=>e.projectName),P=N(e=>e.session?.title),F=N(e=>e.session?.id),I=ve()??F,L=K(e=>I?e.sessionNicknames[I]:void 0),ee=K(e=>e.sideContextBreakdownOpen),te=K(e=>e.setSideContextBreakdownOpen);_(e=>e.agents),$o({setPaletteOpen:u,setSearchOpen:s,setShortcutsOpen:d,setModelSwitcherOpen:f,setPromptLibraryOpen:p,setFleetMonitorOpen:g,setAgentsMonitorOpen:v,setProcessMonitorOpen:b,setQueuePanelOpen:S,setCronJobsOpen:w,setTerminalOpen:E}),(0,X.useEffect)(()=>{typeof window>`u`||(window.location.pathname===`/debug`?za(`debug`):window.location.pathname===`/analytics`?za(`analytics`):window.location.pathname===`/refresh-debug`&&za(`refresh-debug`))},[]),(0,X.useEffect)(()=>{let e=e=>{let{filePath:t}=e.detail;K.getState().setCurrentView(`files`);let n=V(R.getState().wsUrl);n&&n.send({type:`files.read`,payload:n.withSession({filePath:t})})};return window.addEventListener(`wrongstack:open-file`,e),()=>window.removeEventListener(`wrongstack:open-file`,e)},[]),(0,X.useEffect)(()=>{let e=e=>{let{filePath:n}=e.detail,r=t.getState().openFiles.find(e=>e.path===n);if(!r)return;let i=V(R.getState().wsUrl);i&&i.send({type:`files.write`,payload:i.withSession({filePath:n,content:r.content})})};return window.addEventListener(`wrongstack:save-file`,e),()=>window.removeEventListener(`wrongstack:save-file`,e)},[]);let{isMobile:z}=ia();(0,X.useEffect)(()=>{z&&K.getState().sidebarOpen&&c(!1)},[z,c]);let ne=z&&a;return ua(),rs(),ts(),(0,X.useEffect)(()=>{let e=[];if(D){let t=j?` iter ${j.index}${j.max?`/${j.max}`:``}`:``;e.push(`●${t}`)}let t=L?.trim()||P?.trim(),n=M?.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=M||`AI Agent`}},[D,j,M,P,L]),ns({toggleSidebar:o,setSearchOpen:s,toggleInspector:m,setInspectorTab:l}),(0,Z.jsxs)(`div`,{"data-shell":r?`desktop`:`browser`,className:G(`ws-app-root flex min-h-0 min-w-0 overflow-hidden`,r&&`ws-desktop-shell`,n),children:[(0,Z.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:e(`activity:app.skipToContent`)}),i!==`setup`&&(0,Z.jsx)(Ro,{desktopShell:r}),a&&i!==`setup`&&(0,Z.jsx)(Lu,{desktopShell:r}),(0,Z.jsxs)(`main`,{id:`main-content`,className:`flex-1 min-w-0 min-h-0 flex flex-col overflow-hidden bg-background/70`,...ne?{inert:!0}:{},children:[i!==`setup`&&(0,Z.jsx)(oy,{currentView:i,projectName:M,sessionLabel:L||P||I||void 0,isLoading:D,iteration:j??null,onPalette:()=>u(!0),onSettings:()=>Ba(`settings`)}),i!==`setup`&&(0,Z.jsx)(`div`,{className:G(i!==`chat`&&`ws-view-parked`),...i===`chat`?{}:{inert:!0,"aria-hidden":!0},children:(0,Z.jsx)(fl,{})}),i!==`setup`&&(0,Z.jsx)(gs,{}),i!==`setup`&&(0,Z.jsx)(Uu,{}),(0,Z.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col`,children:(0,Z.jsx)(Jv,{sessionId:I??null,desktopShell:r})})]}),i!==`setup`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Os,{level:`panel`,name:e(`activity:panels.inspector`),children:(0,Z.jsx)(Rc,{})}),I&&(0,Z.jsx)(Os,{level:`panel`,name:e(`activity:panels.workspaceInspector`),children:(0,Z.jsx)(Kv,{sessionId:I})})]}),y&&(0,Z.jsx)(Os,{level:`panel`,name:e(`activity:panels.processMonitor`),children:(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)(cy,{open:y,onClose:()=>b(!1)})})}),x&&(0,Z.jsx)(Os,{level:`panel`,name:e(`activity:panels.queue`),children:(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)(ly,{open:x,onClose:()=>S(!1)})})}),C&&(0,Z.jsx)(Os,{level:`panel`,name:e(`activity:panels.cronJobs`),children:(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)(sy,{open:C,onClose:()=>w(!1)})})}),(0,Z.jsx)(Kc,{}),ee&&(0,Z.jsx)(Es,{open:ee,onClose:()=>te(!1)}),(0,Z.jsx)(ps,{}),(0,Z.jsx)(Ru,{}),(0,Z.jsx)(eo,{}),(0,Z.jsx)(hs,{}),(0,Z.jsx)(Za,{}),(0,Z.jsx)(Zo,{}),(0,Z.jsx)(ml,{}),(0,Z.jsx)(rl,{}),(0,Z.jsx)(ks,{}),(0,Z.jsx)(h,{})]})}function dy(){return(0,Z.jsx)(Os,{children:(0,Z.jsx)(Bu,{defaultTheme:`system`,children:(0,Z.jsx)(uy,{})})})}oo.createRoot(k(document.getElementById(`root`))).render((0,Z.jsx)(X.StrictMode,{children:(0,Z.jsx)(dy,{})}));export{mo as A,Ns as C,js as D,Fs as E,yo as M,ho as N,cs as O,vc as S,Ps as T,Vu as _,M_ as a,Tc as b,r_ as c,Af as d,Cf as f,Gu as g,wd as h,V_ as i,vo as j,os as k,jf as l,rf as m,Lv as n,d_ as o,Sf as p,Nv as r,a_ as s,zv as t,Mf as u,Bl as v,Is as w,wc as x,Ll as y};
|
|
144
|
+
`).trim();return(0,Z.jsxs)(`div`,{className:`flex gap-3 animate-message thinking-bubble`,"aria-live":`polite`,children:[(0,Z.jsxs)(`div`,{className:`thinking-orb flex-shrink-0`,"aria-hidden":!0,children:[(0,Z.jsx)(`span`,{className:`thinking-orb__ring`}),(0,Z.jsx)(`span`,{className:`thinking-orb__ring thinking-orb__ring--delay`}),(0,Z.jsx)(`span`,{className:`thinking-orb__spark thinking-orb__spark--one`}),(0,Z.jsx)(`span`,{className:`thinking-orb__spark thinking-orb__spark--two`}),(0,Z.jsx)(lr,{className:`thinking-orb__icon h-4 w-4`})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1 max-w-[85%] min-w-0`,children:[(0,Z.jsxs)(`span`,{className:`thinking-label text-xs font-medium text-primary px-1`,children:[(0,Z.jsx)(`span`,{children:e(`chat:thinking`)}),(0,Z.jsxs)(`span`,{className:`thinking-dots`,"aria-hidden":!0,children:[(0,Z.jsx)(`span`,{}),(0,Z.jsx)(`span`,{}),(0,Z.jsx)(`span`,{})]})]}),(0,Z.jsxs)(`div`,{className:`thinking-panel rounded-2xl rounded-bl-md px-3 py-2 border text-foreground/80`,children:[(0,Z.jsxs)(`div`,{className:`thinking-wave`,"aria-hidden":!0,children:[(0,Z.jsx)(`span`,{}),(0,Z.jsx)(`span`,{}),(0,Z.jsx)(`span`,{}),(0,Z.jsx)(`span`,{}),(0,Z.jsx)(`span`,{})]}),(0,Z.jsx)(`pre`,{className:`thinking-text whitespace-pre-wrap break-words font-sans text-xs leading-relaxed italic max-h-32 overflow-hidden`,children:n||`…`})]})]})]})}function Y_(e){let{hasMessages:t,autoCollapseInput:n,sessionChanged:r,prevHadMessages:i,prevAutoCollapse:a}=e;return n&&t&&(r||!i||!a)}function X_(e,t){return typeof e==`function`?e(t):e}function Z_(){let{t:e}=H(),t=q(e=>e.messages),n=q(e=>e.isLoading),r=K(e=>e.sidebarOpen),i=K(e=>e.toggleSidebar),a=K(e=>e.compactMode),{totalTokens:o,startTime:s,lastInputTokens:c,maxContext:l,contextLimitWarning:u,cacheStats:d,iteration:f}=N(Me(e=>({totalTokens:e.totalTokens,startTime:e.startTime,lastInputTokens:e.lastInputTokens,maxContext:e.maxContext,contextLimitWarning:e.contextLimitWarning,cacheStats:e.cacheStats,iteration:e.iteration}))),p=N(e=>e.session),m=ve()??p?.id,h=K(e=>m?e.sessionNicknames[m]:void 0),g=K(e=>e.setSessionNickname),_=p?.title,[v,y]=(0,X.useState)(!1),[x,S]=(0,X.useState)(``),C=b(e=>e.entries),w=K(e=>e.chatSwitcherOpen),T=K(e=>e.setChatSwitcherOpen),E=(0,X.useCallback)(e=>{T(X_(e,K.getState().chatSwitcherOpen))},[T]),D=(0,X.useRef)(null);(0,X.useEffect)(()=>{if(!w)return;let e=e=>{D.current?.contains(e.target)||E(!1)},t=e=>{e.key===`Escape`&&E(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[w]);let{configProvider:O,configModel:k}=R(Me(e=>({configProvider:e.provider,configModel:e.model}))),A=p?.provider||O,j=p?.model||k,M=(0,X.useRef)(null),F=(0,X.useMemo)(()=>bs(t),[t]),I=(0,X.useRef)(0);I.current=F.length+1;let L=(0,X.useMemo)(()=>{let e=new Map;return F.forEach((t,n)=>{if(t.kind===`user`)e.set(t.message.id,n);else if(t.kind===`agent`)for(let r of t.items)if(r.kind===`msg`)e.set(r.message.id,n);else for(let t of r.tools)e.set(t.id,n)}),e},[F]),ee=K(e=>e.scrollTarget),te=W(e=>e.autonomy),z=W(e=>e.groupToolCalls),ne=W(e=>e.autoCollapseInput),re=(0,X.useCallback)(e=>{W.getState().set({autonomy:e});try{let t=V();if(typeof t.switchAutonomy==`function`){t.switchAutonomy(e);return}t.send?.({type:`autonomy.switch`,payload:t.withSession?.({mode:e})??{mode:e}})}catch{}},[]),[ie,ae]=(0,X.useState)(!1),oe=K(e=>e.chatCheckpointOpen),se=K(e=>e.setChatCheckpointOpen),ce=(0,X.useCallback)(e=>{se(X_(e,K.getState().chatCheckpointOpen))},[se]),le=K(e=>e.chatMemoryPanelOpen),ue=K(e=>e.setChatMemoryPanelOpen),de=(0,X.useCallback)(e=>{ue(X_(e,K.getState().chatMemoryPanelOpen))},[ue]),fe=K(e=>e.chatInputCollapsed),B=K(e=>e.setChatInputCollapsed),pe=(0,X.useCallback)(e=>{B(X_(e,K.getState().chatInputCollapsed))},[B]),me=(0,X.useRef)(n),he=(0,X.useRef)(t.length>0),ge=(0,X.useRef)(m),_e=(0,X.useRef)(ne),ye=K(e=>e.chatContextBreakdownOpen),be=K(e=>e.setChatContextBreakdownOpen),xe=K(e=>e.chatToolStatsOpen),Se=K(e=>e.setChatToolStatsOpen),Ce=(0,X.useCallback)(e=>{Se(X_(e,K.getState().chatToolStatsOpen))},[Se]),we=K(e=>e.chatContextEditorOpen),Te=K(e=>e.setChatContextEditorOpen),Ee=fa(e=>Object.values(e.contextMemories).filter(e=>e.state!==`exited`).length);(0,X.useEffect)(()=>{let e=()=>de(!0);return window.addEventListener(`open:memory-panel`,e),()=>window.removeEventListener(`open:memory-panel`,e)},[]),(0,X.useEffect)(()=>{let e=()=>be(!0);return document.addEventListener(`open:context-breakdown`,e),()=>document.removeEventListener(`open:context-breakdown`,e)},[]),(0,X.useEffect)(()=>{let e=()=>Te(!0);return document.addEventListener(`open:context-editor`,e),()=>document.removeEventListener(`open:context-editor`,e)},[]),(0,X.useEffect)(()=>{let e=()=>pe(!1);return document.addEventListener(`chat:session-end`,e),document.addEventListener(`chat:next-step-countdown`,e),()=>{document.removeEventListener(`chat:session-end`,e),document.removeEventListener(`chat:next-step-countdown`,e)}},[]),(0,X.useEffect)(()=>{me.current&&!n&&pe(!1),me.current=n},[n]),(0,X.useEffect)(()=>{let e=t.length>0,r=m!=null&&m!==ge.current;!n&&Y_({hasMessages:e,autoCollapseInput:ne,sessionChanged:r,prevHadMessages:he.current,prevAutoCollapse:_e.current})&&pe(!0),ge.current=m,he.current=e,_e.current=ne},[t.length,ne,m,n]);let De=(0,X.useCallback)(()=>{let e=!W.getState().autoCollapseInput;W.getState().set({autoCollapseInput:e}),e||pe(!1)},[]),Oe=l>0&&c>0?Math.min(100,Math.round(c/l*100)):0,[ke,Ae]=(0,X.useState)(!0),[je,Ne]=(0,X.useState)(0),[Pe,Fe]=(0,X.useState)(!1),Ie=(0,X.useRef)(t.length),Le=(0,X.useCallback)(()=>{let e=M.current;if(!e)return;let t=e.scrollSize-e.scrollOffset-e.viewportSize<120;Ae(t),t&&(Ne(0),Ie.current=q.getState().messages.length),Fe(e.scrollOffset>e.viewportSize&&e.scrollSize>e.viewportSize*2.5)},[]),Re=(0,X.useCallback)(e=>{let t=V();P.getState().openTab(e,{resumeSession:e=>t.resumeSession?.(e)}),E(!1)},[]);(0,X.useEffect)(()=>{let e=M.current;if(e){if(ke)e.scrollToIndex(I.current-1,{align:`end`}),Ie.current=t.length;else{let e=t.length-Ie.current;e>0&&Ne(e)}}},[t,ke]),(0,X.useEffect)(()=>{Ae(!0),Ne(0),Ie.current=q.getState().messages.length,ae(!1),y(!1),requestAnimationFrame(()=>{M.current?.scrollToIndex(I.current-1,{align:`end`})})},[m]),(0,X.useEffect)(()=>{if(!ee)return;let e=L.get(ee.id);e!==void 0&&M.current?.scrollToIndex(e,{align:`center`,smooth:!0})},[ee,L]);let ze=(0,X.useCallback)(()=>{M.current?.scrollToIndex(I.current-1,{align:`end`,smooth:!0}),Ae(!0),Ne(0),Ie.current=q.getState().messages.length},[]),Be=(0,X.useCallback)(()=>{M.current?.scrollToIndex(0,{align:`start`,smooth:!0})},[]),[Ve,He]=(0,X.useState)(null),[Ue,We]=(0,X.useState)(()=>Date.now()),Ge=(0,X.useRef)(null),Ke=t[t.length-1],qe=Ke?.role===`assistant`&&Ke.streaming&&Ke.content?Ke:null;(0,X.useEffect)(()=>{if(qe){let e=Ge.current;(!e||e.id!==qe.id)&&(Ge.current={id:qe.id,at:Date.now(),len:qe.content.length})}else Ge.current&&=null},[qe]);let Je=(0,X.useMemo)(()=>{let n=t[t.length-1],r=t.filter(e=>e.role===`tool`&&e.toolResult===void 0),i=e(`activity:chatView.thinking`);if(r.length>0){let t=Array.from(new Set(r.map(e=>e.toolName).filter(Boolean))),n=t.slice(0,2).join(`, `),a=t.length>2?` +${t.length-2}`:``;i=r.length===1?e(`activity:chatView.runningTool`,{tool:n||e(`activity:chatView.toolWord`)}):e(`activity:chatView.runningTools`,{count:r.length,preview:`${n}${a}`})}else n?.role===`assistant`&&n.content?i=e(`activity:chatView.writingReply`):n?.role===`tool`&&n.toolResult!==void 0&&(i=e(`activity:chatView.thinkingNextStep`));let a=Ve?Math.max(0,Math.floor((Ue-Ve)/1e3)):0,o=a<60?`${a}s`:`${Math.floor(a/60)}m ${a%60}s`,s=``;if(qe){let e=Ge.current;if(e&&e.id===qe.id){let t=Math.max(1,Ue-e.at),n=Math.max(0,qe.content.length-e.len);if(t>500&&n>0){let e=n*1e3/t;s=e>=1e3?`${(e/1e3).toFixed(1)}k ch/s`:`${Math.round(e)} ch/s`}}}return{label:i,elapsed:o,speedLabel:s}},[t,Ue,Ve,e,qe]);(0,X.useEffect)(()=>{n&&Ve===null&&He(Date.now()),!n&&Ve!==null&&He(null)},[n,Ve]),(0,X.useEffect)(()=>{if(!n)return;let e=setInterval(()=>We(Date.now()),500);return()=>clearInterval(e)},[n]);let Ye=e=>{if(!e)return`--`;let t=Math.floor((Date.now()-e)/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`},Xe=(()=>{if(!n)return`idle`;let e=t[t.length-1];return e?.role===`assistant`&&e.content&&e.streaming?`streaming`:`thinking`})();return{messages:t,isLoading:n,sidebarOpen:r,toggleSidebar:i,compactMode:a,totalTokens:o,startTime:s,lastInputTokens:c,maxContext:l,contextLimitWarning:u,cacheStats:d,iteration:f,sessionId:m,nickname:h,sessionTitle:_,renamingTitle:v,setRenamingTitle:y,titleDraft:x,setTitleDraft:S,setSessionNickname:g,historyEntries:C,switcherOpen:w,setSwitcherOpen:E,switcherRef:D,handleHistorySelect:Re,provider:A,model:j,vlistRef:M,rows:F,autonomy:te,groupToolCallsPref:z,autoCollapseInput:ne,handleAutonomyChange:re,processOpen:ie,setProcessOpen:ae,checkpointOpen:oe,setCheckpointOpen:ce,memoryPanelOpen:le,setMemoryPanelOpen:de,inputCollapsed:fe,setInputCollapsed:pe,breakdownOpen:ye,setBreakdownOpen:be,toolStatsOpen:xe,setToolStatsOpen:Ce,editorOpen:we,setEditorOpen:Te,activeMemoryCount:Ee,handleToggleAutoCollapse:De,ctxPct:Oe,pinnedToBottom:ke,unreadCount:je,scrolledDeep:Pe,handleScroll:Le,scrollToBottom:ze,scrollToTop:Be,runningStatus:Je,formatDuration:Ye,agentState:Xe,stateTone:Xe===`idle`?`bg-muted text-muted-foreground`:Xe===`streaming`?`bg-primary/10 text-primary`:`bg-warning/10 text-warning`,hasStatusContent:l>0&&c>0||o.input>0||!!s}}var Q_=(0,X.lazy)(()=>ta(()=>import(`./ProcessMonitor-CBIQkbLx.js`).then(e=>({default:e.ProcessMonitor})),__vite__mapDeps([63,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,25,20,18,19,21,23,26,29])));function $_(){let{t:e}=H(),t=Z_(),n=ve(),r=K(e=>e.subagentChatFocusId),a=K(e=>e.setSubagentChatFocus),o=K(e=>e.setSearchOpen),c=S(n??void 0),l=_(e=>r==null?void 0:e.agents.get(r)),u=!l||A(l.sessionId,n),d=!!l&&u,f=r!=null&&d&&r!==c;(0,X.useEffect)(()=>{(Rg(r,d)||r!=null&&r===c)&&a(null,n)},[r,d,c,a,n]),(0,X.useEffect)(()=>{f&&o(!1)},[f,o]);let p=R(e=>e.wsStatus),m=t.sessionId,h=s(e=>t.sessionId?e.startedAt[t.sessionId]!==void 0:!1),g=s(e=>t.sessionId?e.progress[t.sessionId]:void 0),v=ye(g),y=E(g?.stage);return(0,X.useEffect)(()=>{!m||p.state!==`open`||V().getChimeraReports(m)},[m,p]),(0,Z.jsxs)(`div`,{className:`flex flex-col flex-1 min-h-0 bg-[hsl(var(--surface-2)/0.45)]`,children:[(0,Z.jsx)(Kg,{sidebarOpen:t.sidebarOpen,toggleSidebar:t.toggleSidebar,agentState:t.agentState,stateTone:t.stateTone,sessionId:t.sessionId,renamingTitle:t.renamingTitle,setRenamingTitle:t.setRenamingTitle,titleDraft:t.titleDraft,setTitleDraft:t.setTitleDraft,nickname:t.nickname,sessionTitle:t.sessionTitle,setSessionNickname:t.setSessionNickname,historyEntries:t.historyEntries,switcherRef:t.switcherRef,switcherOpen:t.switcherOpen,setSwitcherOpen:t.setSwitcherOpen,handleHistorySelect:t.handleHistorySelect,iteration:t.iteration,autonomy:t.autonomy,handleAutonomyChange:t.handleAutonomyChange,memoryPanelOpen:t.memoryPanelOpen,setMemoryPanelOpen:t.setMemoryPanelOpen,activeMemoryCount:t.activeMemoryCount,processOpen:t.processOpen,setProcessOpen:t.setProcessOpen,checkpointOpen:t.checkpointOpen,setCheckpointOpen:t.setCheckpointOpen,toolStatsOpen:t.toolStatsOpen,setToolStatsOpen:t.setToolStatsOpen,hasStatusContent:t.hasStatusContent,lastInputTokens:t.lastInputTokens,ctxPct:t.ctxPct,maxContext:t.maxContext,cacheStats:t.cacheStats,setBreakdownOpen:t.setBreakdownOpen,contextLimitWarning:t.contextLimitWarning,setEditorOpen:t.setEditorOpen,totalTokens:t.totalTokens,startTime:t.startTime,formatDuration:t.formatDuration}),(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,Z.jsx)(`div`,{className:G(`ws-view-pane relative mx-2 mt-2 flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden rounded-xl border border-border/70 bg-card/55 shadow-sm sm:mx-3 lg:mx-4 lg:mt-3`,!f&&`ws-view-parked`),...f?{}:{inert:!0,"aria-hidden":!0},children:(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:f&&r!=null&&(0,Z.jsx)(q_,{agentId:r},r)})}),(0,Z.jsxs)(`div`,{className:G(`ws-view-pane relative mx-2 mt-2 min-h-0 min-w-0 flex-1 overflow-hidden rounded-xl border border-border/70 bg-card/55 shadow-sm sm:mx-3 lg:mx-4 lg:mt-3`,f&&`ws-view-parked`),...f?{inert:!0,"aria-hidden":!0}:{},children:[(0,Z.jsx)(lg,{}),!t.pinnedToBottom&&(0,Z.jsxs)(`button`,{type:`button`,onClick:t.scrollToBottom,className:G(`absolute bottom-4 left-1/2 -translate-x-1/2 z-10 jump-bottom`,`flex items-center gap-2 px-4 py-2 rounded-md shadow-lg`,`bg-primary text-primary-foreground text-xs font-medium`,`hover:bg-primary/90 transition-colors animate-message`),children:[(0,Z.jsx)(qn,{className:`h-3.5 w-3.5`}),t.unreadCount>0?`${t.unreadCount} new message${t.unreadCount===1?``:`s`}`:`Jump to latest`]}),t.scrolledDeep&&(0,Z.jsxs)(`button`,{type:`button`,onClick:t.scrollToTop,title:e(`chat:header.scrollTopTitle`),className:G(`absolute top-3 right-3 z-10`,`flex items-center gap-1 px-2.5 py-1 rounded-md shadow-md border`,`bg-background/90 backdrop-blur-sm text-[11px] text-muted-foreground`,`hover:text-foreground hover:bg-background transition-colors animate-message`),children:[(0,Z.jsx)(ai,{className:`h-3 w-3`}),(0,Z.jsx)(`span`,{children:e(`activity:chatView.top`)})]}),t.rows.length===0&&!t.isLoading?(0,Z.jsx)(`div`,{className:`h-full overflow-y-auto overscroll-contain`,children:(0,Z.jsx)(`div`,{className:`mx-auto max-w-6xl w-full px-3 sm:px-5 lg:px-6 pt-4 pb-8`,children:h?(0,Z.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-3 py-16 text-center`,role:`status`,"aria-live":`polite`,children:[(0,Z.jsxs)(`div`,{className:`relative h-12 w-12`,"aria-hidden":`true`,children:[(0,Z.jsx)(`div`,{className:`absolute inset-0 rounded-full border-2 border-muted-foreground/20`}),(0,Z.jsx)(`div`,{className:`absolute inset-0 rounded-full border-2 border-transparent border-t-primary animate-spin`}),(0,Z.jsx)(`div`,{className:`absolute inset-1.5 rounded-full bg-background/80`}),(0,Z.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-[11px] font-semibold tabular-nums text-foreground`,children:v===null?`...`:`${v}%`})]}),(0,Z.jsx)(`p`,{className:`text-sm font-medium`,children:e(`activity:chatView.restoringTranscript`)}),(0,Z.jsxs)(`div`,{className:`w-full max-w-sm`,children:[(0,Z.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-3 text-[11px] text-muted-foreground`,children:[(0,Z.jsx)(`span`,{className:`truncate`,children:y}),g&&g.totalBytes>0?(0,Z.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[i(g.loadedBytes),` /`,` `,i(g.totalBytes)]}):(0,Z.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:`reading...`})]}),(0,Z.jsx)(`div`,{className:`h-1.5 overflow-hidden rounded-full bg-muted`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-primary transition-[width] duration-200 ease-out`,style:{width:`${v??12}%`}})})]}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground max-w-sm`,children:e(`activity:chatView.restoringTranscriptHint`)})]}):(0,Z.jsx)(Ng,{})})}):(0,Z.jsxs)(qr,{ref:t.vlistRef,className:`h-full`,onScroll:t.handleScroll,role:`log`,"aria-label":e(`activity:chatView.chatTranscript`),"aria-live":`polite`,children:[t.rows.map((e,n)=>(0,Z.jsx)(U_,{row:e,isLoading:t.isLoading,compactMode:t.compactMode,isFirstRow:n===0,groupToolCalls:t.groupToolCallsPref,sessionId:t.sessionId??`__unbound__`},e.key)),(0,Z.jsxs)(`div`,{id:`chat-activity`,className:G(`mx-auto max-w-6xl w-full px-3 sm:px-5 lg:px-6`,t.compactMode?`pb-3`:`pb-8`),children:[(0,Z.jsx)(J_,{}),t.isLoading&&(0,Z.jsxs)(`div`,{className:`flex gap-3 animate-message`,children:[(0,Z.jsx)(`div`,{className:`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center bg-accent text-accent-foreground ring-2 ring-offset-2 ring-offset-background ring-accent/20`,children:(0,Z.jsx)(jr,{className:`h-4 w-4`})}),(0,Z.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:(0,Z.jsx)(`div`,{className:`rounded-lg px-4 py-3 bg-card border border-border/70 text-foreground shadow-sm`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 text-sm`,children:[(0,Z.jsxs)(`span`,{className:`flex gap-1`,children:[(0,Z.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary/70 animate-bounce [animation-delay:-0.3s]`}),(0,Z.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary/70 animate-bounce [animation-delay:-0.15s]`}),(0,Z.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary/70 animate-bounce`})]}),(0,Z.jsx)(`span`,{className:`text-foreground/90`,children:t.runningStatus.label}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:t.runningStatus.elapsed}),t.iteration&&(0,Z.jsxs)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:[`· iter `,t.iteration.index,t.iteration.max>0?`/${t.iteration.max}`:``]}),t.runningStatus.speedLabel&&(0,Z.jsxs)(`span`,{className:`text-xs text-muted-foreground/80 tabular-nums`,children:[`· `,t.runningStatus.speedLabel]})]})})})]})]},`__live`)]},t.sessionId??`__unbound__`)]})]}),(0,Z.jsx)(`div`,{className:G(`ws-view-pane shrink-0 bg-[hsl(var(--surface-2)/0.45)] px-2 pb-2 pt-2 sm:px-3 lg:px-4 lg:pb-3`,f&&`ws-view-parked`),...f?{inert:!0,"aria-hidden":!0}:{},children:t.inputCollapsed&&t.messages.length>0?(0,Z.jsxs)(`div`,{className:`flex items-center gap-1 rounded-lg border border-border/60 bg-card/40 px-3 py-1.5 hover:bg-card/70 hover:border-border/80 transition-colors`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>t.setInputCollapsed(!1),className:`flex flex-1 items-center gap-2 text-xs text-muted-foreground/60 hover:text-foreground/80 transition-colors`,children:[(0,Z.jsx)(dn,{className:`h-3.5 w-3.5 shrink-0`}),(0,Z.jsx)(`span`,{children:e(`chat:input.expandInput`,`Expand input`)}),t.rows.length>0&&(0,Z.jsxs)(`span`,{className:`ml-auto tabular-nums text-[10px] text-muted-foreground/40`,children:[t.rows.length,` msgs ·`,` `,_s(t.totalTokens.input+t.totalTokens.output)]})]}),t.isLoading&&(0,Z.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),V().sendAbort(t.sessionId??void 0),q.getState().setLoading(!1)},className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-[11px] font-medium bg-destructive/15 text-destructive hover:bg-destructive/25 transition-colors`,title:e(`chat:input.abortTitle`,`Stop/Abort`),"data-testid":`collapsed-stop`,children:[(0,Z.jsx)(sn,{className:`h-3 w-3 fill-current`}),(0,Z.jsx)(`span`,{children:e(`common:action.stop`,`Stop`)})]}),(0,Z.jsx)(zg,{label:e(`activity:chatView.autoCollapse`),value:t.autoCollapseInput,onChange:t.handleToggleAutoCollapse})]}):(0,Z.jsxs)(Z.Fragment,{children:[t.messages.length>0&&(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>t.setInputCollapsed(!0),className:`mb-1 flex w-full items-center gap-1.5 rounded px-2 py-0.5 text-[10px] text-muted-foreground/50 hover:text-muted-foreground/80 transition-colors`,children:[(0,Z.jsx)(Ct,{className:`h-3 w-3`}),(0,Z.jsx)(`span`,{children:e(`chat:input.collapseInput`,`Collapse`)})]}),(0,Z.jsx)(og,{}),(0,Z.jsx)(Bg,{hasStatusContent:t.hasStatusContent,totalTokens:t.totalTokens,rowsCount:t.rows.length,iteration:t.iteration,startTime:t.startTime,formatDuration:t.formatDuration,onToggleAutoCollapse:t.handleToggleAutoCollapse}),(0,Z.jsx)(`div`,{className:`ws-chat-input-wrap p-0`,children:(0,Z.jsx)(`div`,{className:`max-w-6xl mx-auto`,children:(0,Z.jsx)(Lh,{onOpenBreakdown:()=>t.setBreakdownOpen(!0)})})})]})}),(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)(Q_,{open:t.processOpen,onClose:()=>t.setProcessOpen(!1)})}),(0,Z.jsx)(zh,{open:t.checkpointOpen,onClose:()=>t.setCheckpointOpen(!1)}),(0,Z.jsx)(Es,{open:t.breakdownOpen,onClose:()=>t.setBreakdownOpen(!1)}),(0,Z.jsx)(Dg,{open:t.toolStatsOpen,onClose:()=>t.setToolStatsOpen(!1)}),(0,Z.jsx)(tg,{open:t.editorOpen,onClose:()=>t.setEditorOpen(!1)}),(0,Z.jsx)(Hm,{open:t.memoryPanelOpen,onClose:()=>t.setMemoryPanelOpen(!1)})]})}function ev(){let e=Ta(e=>e.info),{client:t}=ha(),n=(0,X.useRef)(null),r=(0,X.useCallback)(()=>{t?.getGitInfo?.()},[t]);return(0,X.useEffect)(()=>(r(),n.current=setInterval(r,3e4),()=>{n.current&&clearInterval(n.current)}),[r]),e}var tv=new Map,nv=new Set;se(e=>{tv.delete(e),nv.add(e)});function rv({sessionId:e,className:t}){let{t:n}=H(),[r,i]=(0,X.useState)([]),[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(null),[l,u]=(0,X.useState)(null),[d,f]=(0,X.useState)(0),[p,m]=(0,X.useState)(!1),[h,g]=(0,X.useState)(!1),[_,v]=(0,X.useState)(``),[y,b]=(0,X.useState)(``),[x,S]=(0,X.useState)(!1),[C,w]=(0,X.useState)(``),T=(0,X.useRef)(e),E=R(e=>e.wsUrl),D=V(E),O=q(e=>e.messages).filter(e=>e.role===`tool`&&e.toolResult===void 0&&!!e.toolUseId);(0,X.useLayoutEffect)(()=>{let t=T.current;nv.has(t)||tv.set(t,{participants:r,joined:a,joinedRole:s,error:l,openAnnotationCount:d,paused:p,injectOpen:h,injectToolUseId:_,injectContent:y,injectIsError:x,injectReason:C});let n=tv.get(e);nv.delete(e),i(n?.participants??[]),o(n?.joined??!1),c(n?.joinedRole??null),u(n?.error??null),f(n?.openAnnotationCount??0),m(n?.paused??!1),g(n?.injectOpen??!1),v(n?.injectToolUseId??``),b(n?.injectContent??``),S(n?.injectIsError??!1),w(n?.injectReason??``),T.current=e},[e]),(0,X.useEffect)(()=>{let t=[];return t.push(D.on(`collab.state`,t=>{let n=t.payload;n.sessionId===e&&i(n.participants??[])})),t.push(D.on(`collab.participant.joined`,t=>{let n=t.payload;n.sessionId===e&&i(e=>e.some(e=>e.participantId===n.participantId)?e:[...e,{participantId:n.participantId,role:n.role,joinedAt:n.joinedAt}])})),t.push(D.on(`collab.participant.left`,t=>{let n=t.payload;if(n.sessionId!==e)return;let r=n.participantId;i(e=>e.filter(e=>e.participantId!==r))})),t.push(D.on(`error`,e=>{let t=e.payload;t.phase===`collab`&&(u(t.message),o(!1))})),t.push(D.on(`collab.annotation.added`,t=>{let n=t.payload;n.sessionId===e&&(n.annotation?.resolved||f(e=>e+1))})),t.push(D.on(`collab.annotation.resolved`,t=>{t.payload.sessionId===e&&f(e=>Math.max(0,e-1))})),t.push(D.on(`collab.pause.granted`,t=>{t.payload.sessionId===e&&m(!0)})),t.push(D.on(`collab.pause.released`,t=>{t.payload.sessionId===e&&m(!1)})),()=>{for(let e of t)e()}},[D,e]);let k=(t=`observer`)=>{u(null),D.send({type:`collab.join`,payload:{sessionId:e,role:t}}),o(!0),c(t)},A=()=>{D.send({type:`collab.request_pause`,payload:{sessionId:e}})},j=()=>{D.send({type:`collab.resume`,payload:{sessionId:e}})},M=()=>{D.send({type:`collab.leave`,payload:{sessionId:e}}),o(!1),i([])},N=t=>{D.send({type:`collab.grant_control`,payload:{sessionId:e,toParticipant:t}})},P=()=>{_&&(D.send({type:`collab.inject_tool`,payload:{sessionId:e,toolUseId:_,content:y,isError:x,reason:C.trim()||U.t(`activity:collab.controllerInjection`)}}),g(!1),v(``),b(``),S(!1),w(``))},F=a&&s===`controller`;return r.length===0&&!l?(0,Z.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,Z.jsx)(fr,{className:`w-4 h-4 text-muted-foreground`}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`activity:collab.noObservers`)}),(0,Z.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>k(`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,Z.jsx)(st,{className:`w-3 h-3`}),n(`activity:collab.observerRole`)]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>k(`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,Z.jsx)(Kt,{className:`w-3 h-3`}),n(`activity:collab.annotatorRole`)]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>k(`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,Z.jsx)(si,{className:`w-3 h-3`}),n(`activity:collab.controllerRole`)]})]})]}):l?(0,Z.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,Z.jsx)(`span`,{className:`text-xs text-destructive`,children:n(`activity:collab.errorPrefix`,{error:l})}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{u(null),o(!1)},className:`ml-auto text-xs underline text-destructive`,children:n(`activity:collab.dismiss`)})]}):(0,Z.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,Z.jsxs)(`span`,{className:`relative flex h-2 w-2`,role:`img`,"aria-label":n(`common:status.live`),children:[(0,Z.jsx)(`span`,{className:`absolute inline-flex h-full w-full rounded-full bg-success opacity-75 animate-ping`}),(0,Z.jsx)(`span`,{className:`relative inline-flex rounded-full h-2 w-2 bg-success`})]}),(0,Z.jsx)(fr,{className:`w-4 h-4 text-success`}),(0,Z.jsx)(`span`,{className:`text-xs font-medium text-success`,children:n(`activity:collab.observers`,{count:r.length})}),d>0&&(0,Z.jsxs)(`span`,{title:n(`activity:collab.annotationsTitle`,{count:d}),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,Z.jsx)(Kt,{className:`w-3 h-3`}),n(`activity:collab.notes`,{count:d})]}),p&&(0,Z.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,Z.jsx)(si,{className:`w-3 h-3`}),n(`activity:collab.paused`)]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1 ml-2`,children:[r.slice(0,3).map(e=>(0,Z.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,Z.jsx)(Xt,{className:`w-3 h-3`}),e.role,F&&e.role!==`controller`&&(0,Z.jsx)(`button`,{type:`button`,onClick:()=>N(e.participantId),title:n(`activity:collab.grantTitle`),className:`ml-0.5 inline-flex items-center rounded hover:bg-success/20 transition-colors`,children:(0,Z.jsx)(mi,{className:`w-3 h-3`})})]},e.participantId)),r.length>3&&(0,Z.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`+`,r.length-3]})]}),F&&(0,Z.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>g(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,Z.jsx)(Mi,{className:`w-3 h-3`}),n(`activity:collab.inject`)]}),p?(0,Z.jsxs)(`button`,{type:`button`,onClick:j,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,Z.jsx)(er,{className:`w-3 h-3`}),n(`activity:collab.resume`)]}):(0,Z.jsxs)(`button`,{type:`button`,onClick:A,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,Z.jsx)(si,{className:`w-3 h-3`}),n(`activity:collab.pauseAgent`)]})]}),a&&s!==`controller`&&(0,Z.jsxs)(`button`,{type:`button`,onClick:M,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,Z.jsx)(fn,{className:`w-3 h-3`}),n(`activity:collab.leave`)]}),F&&h&&(0,Z.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,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Mi,{className:`w-3.5 h-3.5 text-info`}),(0,Z.jsx)(`span`,{className:`font-medium`,children:n(`activity:collab.injectToolResult`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>g(!1),className:`ml-auto text-muted-foreground hover:text-foreground`,children:n(`activity:collab.close`)})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:n(`activity:collab.targetTool`)}),(0,Z.jsx)(`input`,{list:`collab-inject-tools`,value:_,onChange:e=>v(e.target.value),placeholder:n(`activity:collab.targetPlaceholder`),className:`px-2 py-1 rounded border border-border bg-background font-mono`}),(0,Z.jsx)(`datalist`,{id:`collab-inject-tools`,children:O.map(e=>{let t=e.toolInput===void 0?``:` — ${JSON.stringify(e.toolInput).slice(0,40)}`;return(0,Z.jsxs)(`option`,{value:e.toolUseId,children:[e.toolName??n(`activity:collab.toolFallback`),t]},e.toolUseId)})}),O.length===0&&(0,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:n(`activity:collab.noPendingTools`)})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:n(`activity:collab.resultContent`)}),(0,Z.jsx)(`textarea`,{value:y,onChange:e=>b(e.target.value),rows:3,placeholder:n(`activity:collab.resultPlaceholder`),className:`px-2 py-1 rounded border border-border bg-background font-mono`})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsxs)(`label`,{className:`flex items-center gap-1`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:x,onChange:e=>S(e.target.checked)}),(0,Z.jsx)(`span`,{children:n(`activity:collab.markError`)})]}),(0,Z.jsx)(`input`,{type:`text`,value:C,onChange:e=>w(e.target.value),placeholder:n(`activity:collab.reasonPlaceholder`),className:`flex-1 px-2 py-1 rounded border border-border bg-background`})]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:P,disabled:!_,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,Z.jsx)(Mi,{className:`w-3 h-3`}),n(`activity:collab.queueInjection`)]})]})]})}var iv={running:{led:`bg-success led-pulse`,badge:`border-success/30 bg-success/10 text-success`,labelKey:`activity:fleet.statusRunning`},completed:{led:`bg-success`,badge:`border-border bg-muted/40 text-muted-foreground`,labelKey:`activity:fleet.statusDone`},failed:{led:`bg-destructive`,badge:`border-destructive/30 bg-destructive/10 text-destructive`,labelKey:`activity:fleet.statusFailed`},timeout:{led:`bg-warning`,badge:`border-warning/30 bg-warning/10 text-warning`,labelKey:`activity:fleet.statusTimeout`},stopped:{led:`bg-muted-foreground`,badge:`border-border bg-muted text-muted-foreground`,labelKey:`activity:fleet.statusStopped`}};function av({className:e}){let{t}=H(),n=_(e=>e.agents),i=ve(),[a,o]=(0,X.useState)(null),s=(0,X.useMemo)(()=>{let e=Array.from(n.values()).filter(e=>A(e.sessionId,i));return e.sort(c),e},[n,i]),l=(0,X.useCallback)(async(e,t)=>{try{await navigator.clipboard.writeText(t),o(e),setTimeout(()=>o(null),2e3)}catch{}},[]),u=(0,X.useCallback)(e=>{K.getState().setSubagentChatFocus(e,i??void 0),K.getState().setDockSection(null)},[i]);if(s.length===0)return(0,Z.jsx)(`div`,{className:G(`p-4 text-center text-xs text-muted-foreground`,e),children:t(`activity:agents.noAgentsRunning`)});let d=r(s),f=s.reduce((e,t)=>e+(t.costUsd??0),0);return(0,Z.jsxs)(`div`,{className:G(`flex flex-col gap-3`,e),children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 rounded-lg border border-border/70 bg-card/60 px-3 py-2 text-xs backdrop-blur-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(jr,{className:`h-4 w-4 text-primary shrink-0`}),(0,Z.jsx)(`span`,{className:`font-semibold`,children:t(`activity:dock.fleet`)}),(0,Z.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,s.length,`)`]})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px]`,children:[d.running>0&&(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-medium text-success`,children:[(0,Z.jsx)(`span`,{className:`h-2 w-2 rounded-full bg-success animate-pulse`}),d.running,` `,t(`activity:fleet.statusRunning`)]}),d.completed>0&&(0,Z.jsxs)(`span`,{className:`text-muted-foreground`,children:[d.completed,` `,t(`activity:fleet.statusDone`)]}),d.failed>0&&(0,Z.jsxs)(`span`,{className:`font-medium text-destructive`,children:[d.failed,` `,t(`activity:fleet.statusFailed`)]}),f>0&&(0,Z.jsx)(`span`,{className:`rounded bg-muted/60 px-1.5 py-0.5 font-mono text-[10px] text-foreground/80`,children:ec(f)})]})]}),(0,Z.jsx)(`div`,{className:`flex flex-col gap-2`,children:s.map(e=>{let n=iv[e.status]??iv.stopped,r=Date.now()-e.startedAt,i=e.description;return(0,Z.jsxs)(`div`,{className:`group flex flex-col gap-2 rounded-lg border border-border/70 bg-card/80 p-3 shadow-xs transition-colors hover:border-primary/40 hover:bg-card`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,Z.jsx)(`span`,{className:G(`h-2 w-2 rounded-full shrink-0`,n.led)}),(0,Z.jsx)(`span`,{className:`truncate text-xs font-semibold text-foreground`,children:e.name}),(e.provider||e.model)&&(0,Z.jsxs)(`span`,{className:`hidden sm:inline-flex items-center gap-1 rounded bg-muted/60 px-1.5 py-0.5 text-[10px] font-mono text-muted-foreground truncate`,children:[(0,Z.jsx)(ar,{className:`h-3 w-3 shrink-0`}),e.model??e.provider]}),(0,Z.jsx)(`span`,{className:G(`rounded-md border px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wider shrink-0`,n.badge),children:t(n.labelKey)})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,Z.jsxs)(`span`,{className:`flex items-center gap-1 text-[11px] font-mono text-muted-foreground tabular-nums`,children:[(0,Z.jsx)(He,{className:`h-3 w-3`}),nc(r)]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>u(e.id),className:`inline-flex items-center gap-1 rounded-md border border-primary/30 bg-primary/10 px-2 py-1 text-xs font-medium text-primary hover:bg-primary/20 transition-colors cursor-pointer`,title:`Open subagent chat tab`,children:[(0,Z.jsx)(Lt,{className:`h-3 w-3`}),(0,Z.jsx)(`span`,{children:`Chat Tab`})]})]})]}),i?(0,Z.jsx)(`p`,{className:`text-[11px] text-muted-foreground line-clamp-2 leading-relaxed`,children:i}):null,(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 border-t border-border/40 pt-2 text-[11px]`,children:[(0,Z.jsx)(`div`,{className:`flex items-center gap-2 min-w-0`,children:e.status===`running`&&(e.currentTool||e.lastTool)?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-primary font-mono text-[10px] bg-primary/10 px-1.5 py-0.5 rounded truncate`,children:[(0,Z.jsx)(li,{className:`h-3 w-3 shrink-0 animate-pulse`}),e.currentTool?e.currentTool:`last: ${e.lastTool}`]}):e.error?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-destructive text-[10px] truncate`,children:[(0,Z.jsx)(Rr,{className:`h-3 w-3 shrink-0`}),e.error.message]}):(0,Z.jsxs)(`span`,{className:`text-[10px] text-muted-foreground font-mono`,children:[`iter `,e.iteration,` · `,e.toolCalls,` tools`]})}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 ml-auto`,children:[e.costUsd>0&&(0,Z.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:ec(e.costUsd)}),e.finalText&&(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>l(e.id,e.finalText),className:`inline-flex items-center gap-1 text-[10px] text-muted-foreground hover:text-foreground hover:bg-muted px-1.5 py-0.5 rounded transition-colors cursor-pointer`,title:t(`activity:fleet.copyOutput`),children:[a===e.id?(0,Z.jsx)(ui,{className:`h-3 w-3 text-success`}):(0,Z.jsx)(oi,{className:`h-3 w-3`}),(0,Z.jsx)(`span`,{children:a===e.id?t(`common:action.copied`):t(`common:action.copy`)})]})]})]})]},e.id)})})]})}var ov={up:(0,Z.jsx)(Di,{className:`h-3.5 w-3.5 text-success`}),down:(0,Z.jsx)(cr,{className:`h-3.5 w-3.5 text-destructive`}),stable:(0,Z.jsx)(zr,{className:`h-3.5 w-3.5 text-warning`})},sv={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 cv({goal:e,className:t}){let{t:n}=H(),[r,i]=(0,X.useState)(!1);(0,X.useEffect)(()=>{let e=V();e?.send?.({type:`goal.get`});let t=setInterval(()=>{e?.send?.({type:`goal.get`})},1e4);return()=>clearInterval(t)},[]),(0,X.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=sv[e.goalState],c=e.deliverables?.filter(e=>e.status===`done`).length??0,l=e.deliverables?.length??0,u=e.progressTrend?ov[e.progressTrend]:null;return(0,Z.jsxs)(`div`,{className:G(`rounded-lg border border-border bg-card/60 backdrop-blur-sm`,t),children:[(0,Z.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,Z.jsx)(wr,{className:`h-4 w-4 text-primary`}),(0,Z.jsx)(`span`,{className:`text-xs font-semibold text-foreground flex-1 min-w-0 truncate`,children:n(`activity:goal.heading`)}),(0,Z.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,Z.jsx)(ot,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}):(0,Z.jsx)(Ct,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`})]}),!r&&(0,Z.jsxs)(`div`,{className:`px-3 pb-3 space-y-3 border-t pt-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`text-xs text-foreground leading-relaxed whitespace-pre-wrap break-words`,children:e.goal}),e.refinedGoal&&e.refinedGoal!==e.goal&&(0,Z.jsxs)(`div`,{className:`mt-1.5 p-2 rounded bg-accent/40 border border-border/50`,children:[(0,Z.jsx)(`p`,{className:`text-[10px] text-muted-foreground mb-0.5 uppercase tracking-wider font-medium`,children:n(`activity:goal.refined`)}),(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed whitespace-pre-wrap break-words`,children:e.refinedGoal})]})]}),(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between text-[10px]`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground uppercase tracking-wider font-medium`,children:n(`activity:goal.progress`)}),(0,Z.jsxs)(`span`,{className:`flex items-center gap-1 tabular-nums`,children:[u,(0,Z.jsxs)(`span`,{className:`font-medium text-foreground`,children:[e.progress,`%`]})]})]}),(0,Z.jsx)(`div`,{className:`h-1.5 bg-muted rounded-full overflow-hidden`,children:(0,Z.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,Z.jsx)(`p`,{className:`text-[10px] text-muted-foreground italic`,children:e.progressNote})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] text-muted-foreground`,children:[(0,Z.jsx)(He,{className:`h-3 w-3`}),(0,Z.jsx)(`span`,{className:`tabular-nums font-medium`,children:e.iterations}),(0,Z.jsx)(`span`,{children:n(`activity:goal.iterations`)}),e.lastStatus&&(0,Z.jsx)(`span`,{className:`text-border`,children:`·`}),e.lastStatus&&(0,Z.jsx)(`span`,{className:`truncate`,children:e.lastStatus})]}),l>0&&(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between text-[10px] text-muted-foreground uppercase tracking-wider font-medium`,children:[(0,Z.jsx)(`span`,{children:n(`activity:goal.deliverables`)}),(0,Z.jsxs)(`span`,{className:`tabular-nums`,children:[c,`/`,l]})]}),(0,Z.jsx)(`ul`,{className:`space-y-0.5`,children:a.map(e=>(0,Z.jsxs)(`li`,{className:`flex items-start gap-1.5 text-[11px]`,children:[e.status===`done`?(0,Z.jsx)($t,{className:`h-3 w-3 text-success mt-0.5 shrink-0`}):(0,Z.jsx)(Vt,{className:`h-3 w-3 text-muted-foreground/70 mt-0.5 shrink-0`}),(0,Z.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,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-[10px] text-muted-foreground uppercase tracking-wider font-medium`,children:n(`activity:goal.recentActivity`)}),(0,Z.jsx)(`div`,{className:`space-y-1`,children:o.map((e,t)=>(0,Z.jsxs)(`div`,{className:`flex items-start gap-1.5 text-[10px] text-muted-foreground`,children:[(0,Z.jsxs)(`span`,{className:`font-mono tabular-nums shrink-0 text-foreground/60`,children:[`#`,e.iteration]}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.task||e.status||e.progressNote||`…`})]},`${e.iteration}-${t}`))})]})]})]})}var lv={in_progress:0,pending:1,completed:2},uv=`__no_session__`,dv=new Map,fv=new Set;se(e=>{dv.delete(e),fv.add(e)});function pv(){let{t:e}=H(),t=N(e=>e.todos),n=ve(),[r,i]=(0,X.useState)(new Set),a=V(),o=(0,X.useRef)(n??uv);(0,X.useLayoutEffect)(()=>{fv.has(o.current)||dv.set(o.current,new Set(r));let e=n??uv;fv.delete(e),i(new Set(dv.get(e)??[])),o.current=e},[n]),(0,X.useEffect)(()=>{n&&a.send({type:`todos.get`,payload:{sessionId:n}})},[n,a]);let s=(0,X.useCallback)(e=>{a.removeTodo(e)},[a]),c=(0,X.useCallback)(e=>{if(e.status===`in_progress`)return;let t=e.status===`completed`?`pending`:`completed`;a.updateTodoStatus(e.id,t)},[a]),l=[...t].sort((e,t)=>(lv[e.status]??9)-(lv[t.status]??9)),u=l.filter(e=>e.status===`completed`).length,d=l.filter(e=>e.status===`in_progress`),f=l.filter(e=>e.status===`pending`),p=l.filter(e=>e.status===`completed`),m=p.length>0,h=r.has(`completed`),g=e=>{i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},_=t=>{let n=t.status===`in_progress`&&t.activeForm?t.activeForm:t.content,r=t.status===`in_progress`,i=t.status===`completed`,a=!!(t.kanbanBoardId&&t.kanbanTaskId),o=!r&&!(a&&i);return(0,Z.jsxs)(`div`,{className:G(`relative px-3 py-1.5 flex items-start gap-2 text-[13px] group transition-colors`,o&&`hover:bg-accent/40`,r?`bg-warning/8`:i?`bg-success/5`:`bg-background`),children:[o&&(0,Z.jsx)(`button`,{type:`button`,className:`absolute inset-0 cursor-pointer`,"aria-label":e(`activity:todos.toggleAria`,{content:t.content}),onClick:()=>c(t)}),(0,Z.jsx)(`span`,{className:`pointer-events-none relative mt-0.5 shrink-0`,children:i?(0,Z.jsx)($t,{className:`w-3.5 h-3.5 text-success`}):r?(0,Z.jsx)(He,{className:`w-3.5 h-3.5 text-warning animate-spin`}):(0,Z.jsx)(Vt,{className:G(`w-3.5 h-3.5 transition-colors`,`text-muted-foreground/65 group-hover:text-success`)})}),(0,Z.jsxs)(`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,t.blockedBy?.length?(0,Z.jsx)(`span`,{className:`mt-0.5 block text-[11px] text-destructive`,children:e(`activity:todos.blockedBy`,{work:t.blockedBy.join(`; `)})}):null]}),!a&&(0,Z.jsx)(`button`,{type:`button`,onClick:()=>s(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,Z.jsx)(vr,{className:`w-3 h-3 text-muted-foreground`})})]},t.id)};return t.length===0?null:(0,Z.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/50 backdrop-blur-sm overflow-hidden`,children:[(0,Z.jsxs)(`div`,{className:`px-3 py-1.5 flex items-center gap-2 border-b border-border/50`,children:[(0,Z.jsx)(`h2`,{className:`text-[11px] font-semibold text-foreground uppercase tracking-wider`,children:e(`activity:work.todos`)}),(0,Z.jsxs)(`span`,{className:`tabular text-[10px] text-muted-foreground ml-auto`,children:[u,`/`,t.length]})]}),d.length>0&&(0,Z.jsx)(`div`,{className:`border-b border-border/30 last:border-b-0`,children:d.map(_)}),f.length>0&&(0,Z.jsx)(`div`,{className:`border-b border-border/30 last:border-b-0`,children:f.map(_)}),m&&(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>g(`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,Z.jsxs)(`span`,{className:`tabular`,children:[h?`▶`:`▼`,` `,e(`activity:todos.completedCount`,{count:p.length})]})}),!h&&p.map(_)]})]})}var mv={pending:{icon:(0,Z.jsx)(Vt,{className:`w-3.5 h-3.5`}),labelKey:`statusPending`,color:`text-muted-foreground/70`},in_progress:{icon:(0,Z.jsx)(He,{className:`w-3.5 h-3.5 animate-spin`}),labelKey:`statusInProgress`,color:`text-warning`},blocked:{icon:(0,Z.jsx)(si,{className:`w-3.5 h-3.5`}),labelKey:`statusBlocked`,color:`text-warning`},failed:{icon:(0,Z.jsx)(Rr,{className:`w-3.5 h-3.5`}),labelKey:`statusFailed`,color:`text-destructive`},review:{icon:(0,Z.jsx)(Tn,{className:`w-3.5 h-3.5`}),labelKey:`statusReview`,color:`text-info`},completed:{icon:(0,Z.jsx)($t,{className:`w-3.5 h-3.5`}),labelKey:`statusDone`,color:`text-success`}},hv={critical:`text-destructive`,high:`text-warning`,medium:`text-warning/85`,low:`text-muted-foreground`},gv={feature:`⚡`,bugfix:`🐛`,refactor:`♻️`,docs:`📝`,test:`🧪`,chore:`🔧`},_v=`__no_session__`,vv=new Map,yv=new Set;se(e=>{vv.delete(e),yv.add(e)});function bv(){let{t:e}=H(),[t,n]=(0,X.useState)([]),[r,i]=(0,X.useState)(new Set),a=V(),o=ve(),s=(0,X.useRef)(o??_v);(0,X.useLayoutEffect)(()=>{yv.has(s.current)||vv.set(s.current,new Set(r));let e=o??_v;yv.delete(e),i(new Set(vv.get(e)??[])),s.current=e},[o]),xs(`tasks.updated`,e=>{let t=e.payload;t?.sessionId&&o&&t.sessionId!==o||t?.tasks&&n(t.tasks)},{sessionId:o,deps:[o]}),(0,X.useEffect)(()=>{n([]),a.getTasks()},[o,a]);let c=(0,X.useCallback)(e=>{i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),l=(0,X.useCallback)((e,t)=>{a.updateTaskStatus(e,t)},[a]),u=[`in_progress`,`blocked`,`review`,`pending`,`failed`,`completed`],d=[...t].sort((e,t)=>u.indexOf(e.status)-u.indexOf(t.status)),f=new Map;for(let e of d){let t=f.get(e.status)??[];t.push(e),f.set(e.status,t)}let p=t.filter(e=>e.status===`completed`).length;return t.length===0?null:(0,Z.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/50 backdrop-blur-sm overflow-hidden`,children:[(0,Z.jsxs)(`div`,{className:`px-3 py-1.5 flex items-center gap-2 border-b border-border/50`,children:[(0,Z.jsx)(`h2`,{className:`text-[11px] font-semibold text-foreground uppercase tracking-wider`,children:e(`activity:work.tasks`)}),(0,Z.jsxs)(`span`,{className:`tabular text-[10px] text-muted-foreground ml-auto`,children:[p,`/`,t.length]})]}),u.map(t=>{let n=f.get(t);if(!n||n.length===0)return null;let i=mv[t],a=r.has(t);return(0,Z.jsxs)(`div`,{className:`border-b border-border/30 last:border-b-0`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>c(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,Z.jsxs)(`span`,{className:`tabular`,children:[a?`▶`:`▼`,` `,n.length,` `,e(`activity:task.${i.labelKey}`)]})}),!a&&n.map(t=>(0,Z.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,Z.jsx)(`span`,{className:G(`mt-0.5 shrink-0`,i.color),children:i.icon}),(0,Z.jsxs)(`span`,{className:`leading-snug flex-1 min-w-0`,children:[(0,Z.jsxs)(`span`,{className:G(t.status===`completed`?`text-muted-foreground line-through`:`text-foreground/80`),children:[gv[t.type],` `,t.title]}),t.priority!==`medium`&&(0,Z.jsx)(`span`,{className:G(`ml-1 text-[10px]`,hv[t.priority]),children:t.priority}),t.assignee&&(0,Z.jsxs)(`span`,{className:`ml-1 text-[10px] text-muted-foreground`,children:[`@`,t.assignee]}),t.estimateHours&&(0,Z.jsxs)(`span`,{className:`ml-1 text-[10px] text-muted-foreground`,children:[t.estimateHours,`h`]})]}),(0,Z.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,Z.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),l(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,Z.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),l(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,Z.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),l(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 xv={open:{icon:(0,Z.jsx)(Vt,{className:`w-3.5 h-3.5`}),labelKey:`statusOpen`,color:`text-muted-foreground/70`},in_progress:{icon:(0,Z.jsx)(He,{className:`w-3.5 h-3.5 animate-spin`}),labelKey:`statusInProgress`,color:`text-warning`},done:{icon:(0,Z.jsx)($t,{className:`w-3.5 h-3.5`}),labelKey:`statusDone`,color:`text-success`}},Sv=`__no_session__`,Cv=new Map,wv=new Set;se(e=>{Cv.delete(e),wv.add(e)});function Tv(){let{t:e}=H(),[t,n]=(0,X.useState)([]),[r,i]=(0,X.useState)(new Set),a=V(),o=ve(),s=(0,X.useRef)(o??Sv);(0,X.useLayoutEffect)(()=>{wv.has(s.current)||Cv.set(s.current,new Set(r));let e=o??Sv;wv.delete(e),i(new Set(Cv.get(e)??[])),s.current=e},[o]),(0,X.useEffect)(()=>{n([]),a.getPlan();let e=a.on(`plan.updated`,e=>{let t=e?.payload;t?.sessionId&&o&&t.sessionId!==o||t?.plan?.items&&n(t.plan.items)});return()=>{e()}},[o,a]);let c=(0,X.useCallback)(e=>{i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),l=(0,X.useCallback)((e,t)=>{a.updatePlanItem(e.id,t)},[a]),u=[`in_progress`,`open`,`done`],d=[...t].sort((e,t)=>u.indexOf(e.status)-u.indexOf(t.status)),f=new Map;for(let e of d){let t=f.get(e.status)??[];t.push(e),f.set(e.status,t)}let p=t.filter(e=>e.status===`done`).length;return t.length===0?null:(0,Z.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/50 backdrop-blur-sm overflow-hidden`,children:[(0,Z.jsxs)(`div`,{className:`px-3 py-1.5 flex items-center gap-2 border-b border-border/50`,children:[(0,Z.jsxs)(`h2`,{className:`text-[11px] font-semibold text-foreground uppercase tracking-wider`,children:[`📋 `,e(`activity:work.plan`)]}),(0,Z.jsxs)(`span`,{className:`tabular text-[10px] text-muted-foreground ml-auto`,children:[p,`/`,t.length]})]}),u.map(t=>{let n=f.get(t);if(!n||n.length===0)return null;let i=xv[t],a=r.has(t);return(0,Z.jsxs)(`div`,{className:`border-b border-border/30 last:border-b-0`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>c(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,Z.jsxs)(`span`,{className:`tabular`,children:[a?`▶`:`▼`,` `,n.length,` `,e(`activity:plan.${i.labelKey}`)]})}),!a&&n.map(t=>(0,Z.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,Z.jsx)(`span`,{className:G(`mt-0.5 shrink-0`,i.color),children:i.icon}),(0,Z.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,Z.jsxs)(`div`,{className:`flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity shrink-0`,children:[t.status===`open`&&(0,Z.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),l(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,Z.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),l(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,Z.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),l(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 Ev=[{id:`todos`,labelKey:`work.todos`,icon:`✅`},{id:`tasks`,labelKey:`work.tasks`,icon:`📋`},{id:`plan`,labelKey:`work.plan`,icon:`🗺️`}];function Dv(){let{t:e}=H(),t=K(e=>e.workDashboardTab),n=K(e=>e.setWorkDashboardTab);return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/50 backdrop-blur-sm overflow-hidden`,children:[(0,Z.jsx)(`div`,{className:`flex border-b border-border/50 bg-muted/30`,children:Ev.map(r=>(0,Z.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,Z.jsx)(`span`,{className:`text-xs`,children:r.icon}),e(`activity:${r.labelKey}`)]},r.id))}),(0,Z.jsx)(`div`,{className:G(t===`todos`?`block`:`hidden`),children:(0,Z.jsx)(pv,{})}),(0,Z.jsx)(`div`,{className:G(t===`tasks`?`block`:`hidden`),children:(0,Z.jsx)(bv,{})}),(0,Z.jsx)(`div`,{className:G(t===`plan`?`block`:`hidden`),children:(0,Z.jsx)(Tv,{})})]})}var Ov={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))`},kv=[Ov.primary,Ov.info,Ov.success,Ov.warning,Ov.destructive,Ov.muted],Av=e=>e.replace(/^wstack\/ap\//,``);function jv(e){return[...e].sort((e,t)=>e.allocatedAt-t.allocatedAt).map((e,t)=>({handle:e,color:kv[t%kv.length],y:60+t*48}))}var Mv={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 Nv({worktrees:e,baseBranch:t}){let{t:n}=H(),r=jv(e),i=Math.max(120,60+r.length*48+20);return(0,Z.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-border/70 bg-card/70 p-3`,children:(0,Z.jsxs)(`svg`,{width:`100%`,height:i,viewBox:`0 0 600 ${i}`,className:`min-w-[420px]`,role:`img`,"aria-label":n(`activity:worktree.graphAria`,{base:t||`HEAD`}),children:[(0,Z.jsx)(`title`,{children:n(`activity:worktree.graphAria`,{base:t||`HEAD`})}),(0,Z.jsx)(`line`,{x1:40,y1:20,x2:40,y2:i-10,stroke:Ov.primary,strokeWidth:3}),(0,Z.jsx)(`text`,{x:36,y:14,fontSize:11,fill:Ov.muted,children:t||`HEAD`}),(0,Z.jsx)(`circle`,{cx:40,cy:20,r:5,fill:Ov.primary}),r.map(e=>{let r=Mv[e.handle.status]??k(Mv.active),i=e.handle.status===`merged`,a=e.handle.status===`needs-review`||e.handle.status===`failed`;return(0,Z.jsxs)(`g`,{className:`transition-all duration-500`,children:[(0,Z.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:r.dash,opacity:r.opacity}),i?(0,Z.jsx)(`path`,{d:`M 220 ${e.y} C 160 ${e.y+20}, 100 ${e.y+24}, 40 ${e.y+24}`,fill:`none`,stroke:Ov.success,strokeWidth:2,opacity:.9}):null,(0,Z.jsx)(`circle`,{cx:220,cy:e.y,r:5,fill:a?Ov.destructive:e.color}),(0,Z.jsx)(`text`,{x:232,y:e.y-6,fontSize:12,fill:Ov.foreground,fontFamily:`monospace`,children:Av(e.handle.branch)}),(0,Z.jsx)(`text`,{x:232,y:e.y+10,fontSize:10,fill:Ov.muted,children:a?`⚠ ${e.handle.status}`:i?n(`activity:worktree.mergedLabel`,{base:t}):`+${e.handle.insertions}/-${e.handle.deletions} · ${e.handle.ownerLabel}`})]},e.handle.handleId)})]})})}var Pv={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 Fv(e){return Pv[e]??{icon:`?`,labelKey:``,tint:`border-border`,dot:`bg-muted-foreground`}}var Iv=e=>e.replace(/^wstack\/ap\//,``);function Lv({worktrees:e,baseBranch:t}){let{t:n}=H(),r=[...e].sort((e,t)=>e.allocatedAt-t.allocatedAt);return(0,Z.jsxs)(`div`,{className:`rounded-lg border bg-card/50 backdrop-blur-sm px-3 py-3`,children:[(0,Z.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,Z.jsx)(`span`,{className:`font-semibold tracking-wide uppercase text-[10px]`,children:n(`activity:worktree.lanesHeading`)}),(0,Z.jsxs)(`span`,{className:`opacity-60`,children:[`· `,n(`activity:worktree.base`)]}),(0,Z.jsx)(`code`,{className:`font-mono text-primary`,children:t||`HEAD`}),(0,Z.jsxs)(`span`,{className:`opacity-60`,children:[`· `,n(`activity:worktree.isolatedCount`,{count:r.length})]})]}),(0,Z.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:r.map(e=>{let t=Fv(e.status),r=e.status===`needs-review`,i=Math.min(100,e.insertions+e.deletions);return(0,Z.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,Z.jsx)(`span`,{className:G(`h-2.5 w-2.5 shrink-0 rounded-full`,t.dot),"aria-hidden":!0}),(0,Z.jsx)(`code`,{className:`w-44 shrink-0 truncate font-mono text-sm`,children:Iv(e.branch)}),(0,Z.jsxs)(`span`,{className:`shrink-0 rounded bg-muted px-2 py-0.5 text-xs text-muted-foreground`,children:[`⟵ `,e.ownerLabel]}),r?(0,Z.jsx)(`span`,{className:`font-mono text-xs font-bold text-destructive`,children:n(`activity:worktree.conflictBadge`)}):(0,Z.jsxs)(`span`,{className:`flex items-center gap-1 font-mono text-xs transition-all duration-500`,children:[(0,Z.jsxs)(`span`,{className:`text-success`,children:[`+`,e.insertions]}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:`·`}),(0,Z.jsxs)(`span`,{className:`text-destructive`,children:[`-`,e.deletions]}),(0,Z.jsxs)(`span`,{className:`ml-1 text-muted-foreground`,children:[e.files,`f`]})]}),(0,Z.jsx)(`div`,{className:`ml-auto hidden h-1 w-24 overflow-hidden rounded-full bg-muted sm:block`,children:(0,Z.jsx)(`div`,{className:`h-full bg-gradient-to-r from-success to-destructive transition-all duration-700`,style:{width:`${i}%`}})}),(0,Z.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,Z.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 Rv=e=>e?e.replace(/^wstack\/ap\//,``):``;function zv(){let{t:e}=H(),{client:t}=ha(),n=Aa(e=>e.orphans),r=Aa(e=>e.canClean),i=Aa(e=>e.cleanBlockedReason),a=Aa(e=>e.cleanResult),[o,s]=(0,X.useState)(!1);return(0,X.useEffect)(()=>{t?.send?.({type:`worktree.scan`})},[t]),(0,X.useEffect)(()=>{a&&s(!1)},[a]),n.length===0&&!a?null:(0,Z.jsxs)(`div`,{className:`rounded-md border border-warning/30 bg-warning/5 px-3 py-2 text-xs`,children:[n.length>0?(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(Kr,{className:`mt-0.5 h-4 w-4 shrink-0 text-warning`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`font-medium text-warning`,children:e(`activity:worktree.orphanCount`,{count:n.length})}),(0,Z.jsx)(`div`,{className:`mt-0.5 max-h-16 overflow-auto font-mono text-[10px] text-muted-foreground`,children:n.map((e,t)=>(0,Z.jsxs)(`div`,{className:`truncate`,children:[e.kind===`branch`?`⌥ `:`▢ `,Rv(e.branch)||e.dir]},`${e.kind}-${e.branch??e.dir??t}`))})]}),(0,Z.jsxs)(`button`,{type:`button`,disabled:!r||o,onClick:async()=>{let r=n.length;await $a({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,Z.jsx)(wt,{className:`h-3.5 w-3.5 animate-spin`}):(0,Z.jsx)(Xr,{className:`h-3.5 w-3.5`}),e(`activity:worktree.cleanConfirm`)]})]}):null,a&&(0,Z.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 Bv={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`}},Vv={goal:`Goal`,"goal-state":`Goal State`,fleet:`Fleet`,work:`Work`,worktrees:`Worktrees`,collab:`Collab`},Hv=[`goal`,`goal-state`,`fleet`,`work`,`worktrees`,`collab`];function Uv({section:e,icon:t,label:n,value:r,active:i,pulse:a,onClick:o}){let s=Bv[e],{t:c}=H();return(0,Z.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,Z.jsx)(`span`,{className:G(a&&`animate-pulse`),children:t}),n,r&&(0,Z.jsx)(`span`,{className:`tabular-nums opacity-80`,children:r})]})}function Wv(){let e=K(e=>e.dockSection),{t}=H(),n=K(e=>e.toggleDockSection),r=K(e=>e.hiddenChips),i=K(e=>e.toggleChipHidden),a=K(e=>e.dockCustomizeOpen),o=K(e=>e.setDockCustomizeOpen),s=ve(),c=Oa(e=>e.goal),l=Da(e=>e.phases.length),u=Da(e=>e.overallPercent),d=Da(e=>e.activePhaseId),f=Aa(e=>e.worktrees),p=N(e=>e.todos),m=_(e=>e.agents),h=ev(),g=(0,X.useMemo)(()=>Array.from(m.values()).filter(e=>A(e.sessionId,s)),[m,s]),v=g.length,y=(0,X.useMemo)(()=>g.filter(e=>e.status===`running`).length,[g]),b=p.filter(e=>e.status===`completed`).length,x=p.some(e=>e.status===`in_progress`),S=l>0,C=(0,X.useMemo)(()=>new Set(r),[r]),w={goal:S,"goal-state":c!==null,fleet:v>0,work:!0,worktrees:f.length>0,collab:!0},T={goal:(w.goal||e===`goal`)&&!C.has(`goal`),"goal-state":(w[`goal-state`]||e===`goal-state`)&&!C.has(`goal-state`),fleet:(w.fleet||e===`fleet`)&&!C.has(`fleet`),work:(w.work||e===`work`)&&!C.has(`work`),worktrees:(w.worktrees||e===`worktrees`)&&!C.has(`worktrees`),collab:(w.collab||e===`collab`)&&!C.has(`collab`)},E=e&&T[e]?e:null;return(0,Z.jsx)(`div`,{children:(0,Z.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:[T.goal&&(0,Z.jsx)(Uv,{section:`goal`,icon:(0,Z.jsx)(Zt,{className:`h-3 w-3`}),label:t(`activity:dock.goal`),value:`${u}%`,active:!1,pulse:d!=null,onClick:()=>Ba(`goal`)}),T[`goal-state`]&&c&&(0,Z.jsx)(Uv,{section:`goal-state`,icon:(0,Z.jsx)(wr,{className:`h-3 w-3`}),label:t(`activity:dock.goalState`),value:`${c.progress}%`,active:E===`goal-state`,pulse:c.goalState===`active`,onClick:()=>n(`goal-state`)}),T.fleet&&(0,Z.jsx)(Uv,{section:`fleet`,icon:(0,Z.jsx)(jr,{className:`h-3 w-3`}),label:t(`activity:dock.fleet`),value:`${y}/${v}`,active:E===`fleet`,pulse:y>0,onClick:()=>n(`fleet`)}),(0,Z.jsx)(Uv,{section:`work`,icon:(0,Z.jsx)(yt,{className:`h-3 w-3`}),label:t(`activity:dock.work`),value:p.length>0?`${b}/${p.length}`:void 0,active:E===`work`,pulse:x,onClick:()=>n(`work`)}),T.worktrees&&(0,Z.jsx)(Uv,{section:`worktrees`,icon:(0,Z.jsx)(Vi,{className:`h-3 w-3`}),label:t(`activity:dock.worktrees`),value:String(f.length),active:E===`worktrees`,onClick:()=>n(`worktrees`)}),h&&(0,Z.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,Z.jsx)(Vi,{className:`h-3 w-3 shrink-0 text-muted-foreground`}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate font-semibold text-foreground`,children:h.branch}),h.ahead>0&&(0,Z.jsxs)(`span`,{className:`text-success`,title:t(`activity:dock.ahead`,{count:h.ahead}),children:[`↑`,h.ahead]}),h.behind>0&&(0,Z.jsxs)(`span`,{className:`text-warning`,title:t(`activity:dock.behind`,{count:h.behind}),children:[`↓`,h.behind]}),h.added>0&&(0,Z.jsxs)(`span`,{className:`text-success`,title:t(`activity:dock.linesAdded`,{count:h.added}),children:[`+`,h.added]}),h.deleted>0&&(0,Z.jsxs)(`span`,{className:`text-destructive`,title:t(`activity:dock.linesDeleted`,{count:h.deleted}),children:[`-`,h.deleted]}),h.untracked>0&&(0,Z.jsxs)(`span`,{className:`text-muted-foreground`,title:t(`activity:dock.untrackedFiles`,{count:h.untracked}),children:[h.untracked,`?`]})]}),(0,Z.jsx)(Uv,{section:`collab`,icon:(0,Z.jsx)(fr,{className:`h-3 w-3`}),label:t(`activity:dock.collab`),active:E===`collab`,onClick:()=>n(`collab`)}),(0,Z.jsxs)(mo,{open:a,onOpenChange:o,children:[(0,Z.jsx)(ho,{asChild:!0,children:(0,Z.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,Z.jsx)(Je,{className:`h-3 w-3`})})}),(0,Z.jsxs)(vo,{align:`end`,className:`w-44`,children:[(0,Z.jsx)(So,{children:t(`activity:dock.dockChips`)}),(0,Z.jsx)(Co,{}),Hv.map(e=>(0,Z.jsx)(bo,{checked:!C.has(e),onCheckedChange:()=>i(e),onSelect:e=>e.preventDefault(),children:Vv[e]},e))]})]})]})})}var Gv={"goal-state":{titleKey:`activity:dock.goalState`,detailKey:`activity:dock.goalStateDetail`},fleet:{titleKey:`activity:dock.fleet`,detailKey:`activity:dock.fleetDetail`},work:{titleKey:`activity:dock.work`,detailKey:`activity:dock.workDetail`},worktrees:{titleKey:`activity:dock.worktrees`,detailKey:`activity:dock.worktreesDetail`},collab:{titleKey:`activity:dock.collab`,detailKey:`activity:dock.collabDetail`}};function Kv({sessionId:e}){let t=K(e=>e.dockSection),n=K(e=>e.setDockSection),r=K(e=>e.inspectorOpen),i=Oa(e=>e.goal),a=Aa(e=>e.worktrees),o=Aa(e=>e.baseBranch),[s,c]=(0,X.useState)(`graph`),{t:l}=H(),u=t!==null&&t!==`goal`,d=u?t:null,f=d?Gv[d]:null,p=r&&u?`sm:right-[min(680px,48vw)]`:``;return(0,X.useEffect)(()=>{if(!u)return;let e=e=>{e.key===`Escape`&&n(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[u,n]),(0,Z.jsxs)(`aside`,{id:`workspace-dock-inspector`,"data-testid":u?`workspace-dock-inspector`:void 0,"aria-hidden":!u,inert:!u||void 0,"aria-label":f?l(`activity:dock.inspectorNamed`,{name:l(f.titleKey)}):l(`activity:dock.inspector`),className:G(`fixed inset-y-0 right-0 z-40 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]`,p,u?`translate-x-0`:`pointer-events-none translate-x-full`),children:[(0,Z.jsxs)(`header`,{className:`relative shrink-0 border-b border-border/70 bg-muted/20 px-4 py-3 pr-12`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-foreground`,children:[(0,Z.jsx)(Sr,{className:`h-4 w-4 text-primary`}),l(f?f.titleKey:`activity:dock.workspace`)]}),(0,Z.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:l(f?f.detailKey:`activity:dock.workspaceDetails`)}),(0,Z.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":l(`activity:dock.closeWorkspaceInspector`),title:l(`activity:dock.closeWorkspaceInspector`),children:(0,Z.jsx)(St,{className:`h-4 w-4`})})]}),(0,Z.jsxs)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain p-3 sm:p-4`,children:[d===`goal-state`&&(i?(0,Z.jsx)(cv,{goal:i}):(0,Z.jsx)(qv,{title:l(`activity:dock.noActiveGoal`),detail:l(`activity:dock.noActiveGoalDetail`)})),d===`fleet`&&(0,Z.jsx)(av,{}),d===`worktrees`&&(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:[`graph`,`lanes`].map(e=>(0,Z.jsx)(`button`,{type:`button`,onClick:()=>c(e),className:G(`rounded-md border px-2.5 py-1 text-xs capitalize transition-colors`,s===e?`border-primary/30 bg-primary/10 text-primary`:`border-border text-muted-foreground hover:text-foreground`),children:e},e))}),(0,Z.jsx)(zv,{}),s===`graph`?(0,Z.jsx)(Nv,{worktrees:a,baseBranch:o||`HEAD`}):(0,Z.jsx)(Lv,{worktrees:a,baseBranch:o||`HEAD`})]}),(0,Z.jsx)(`div`,{className:G(d===`work`?`block`:`hidden`),id:`panel-work`,children:(0,Z.jsx)(Dv,{})}),(0,Z.jsx)(`div`,{className:G(d===`collab`?`block`:`hidden`),children:(0,Z.jsx)(rv,{sessionId:e})})]})]})}function qv({title:e,detail:t}){return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-muted/20 px-3 py-2 text-xs`,children:[(0,Z.jsx)(`div`,{className:`font-medium text-foreground`,children:e}),(0,Z.jsx)(`div`,{className:`mt-1 text-muted-foreground`,children:t})]})}function Jv({sessionId:e,desktopShell:t}){let{t:n}=H(),{currentView:r,terminalOpen:i,setTerminalOpen:a}=K(Me(e=>({currentView:e.currentView,terminalOpen:e.terminalOpen,setTerminalOpen:e.setTerminalOpen}))),o=e,s=Lm;return(0,Z.jsxs)(Z.Fragment,{children:[o&&(0,Z.jsxs)(`div`,{className:G(`flex flex-col`,r!==`chat`&&`ws-view-parked`),...r===`chat`?{}:{inert:!0,"aria-hidden":!0},children:[(0,Z.jsx)(`div`,{className:`ws-workspace-dock-wrap shrink-0 px-3 pt-2 sm:px-4`,children:(0,Z.jsx)(Wv,{})}),(0,Z.jsx)(Lg,{})]}),(0,Z.jsx)(`div`,{className:G(`flex min-h-0 min-w-0 flex-1 flex-col`,r!==`chat`&&`ws-view-parked`),...r===`chat`?{}:{inert:!0,"aria-hidden":!0},children:(0,Z.jsx)(Os,{level:`panel`,name:n(`activity:panels.chat`),children:(0,Z.jsx)($_,{})})}),r!==`chat`&&(0,Z.jsx)(Im,{view:r,onCloseToChat:s}),i&&(0,Z.jsx)(Os,{level:`panel`,name:n(`activity:panels.terminal`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(Wu,{label:n(`common:loadingNamed`,{name:n(`activity:panels.terminal`)})}),children:(0,Z.jsx)(Yv,{desktopShell:t,onClose:()=>a(!1)})})})]})}var Yv=(0,X.lazy)(()=>ta(()=>import(`./TerminalPanel-CTr-KAnH.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([64,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,19,20,21,65,66])));function Xv(){let e=W(e=>e.wrongProxyEnabled),t=W(e=>e.wrongProxyUrl),[n,r]=(0,X.useState)(()=>({status:e?`checking`:`disabled`,latencyMs:null,url:t||`http://localhost:3444`}));return(0,X.useEffect)(()=>{if(!e||!t){r({status:`disabled`,latencyMs:null,url:t||`http://localhost:3444`});return}let n=!1,i=async()=>{let e=t.trim().replace(/\/+$/,``),i=`${e}/api/health`,a=Date.now(),o=new AbortController,s=setTimeout(()=>o.abort(),2e3);try{let t=await fetch(i,{method:`GET`,signal:o.signal,headers:{accept:`application/json`}});if(clearTimeout(s),n)return;let c=t.ok&&t.status>=200&&t.status<300;r({status:c?`connected`:`error`,latencyMs:Date.now()-a,url:e,error:c?void 0:`HTTP ${t.status}`})}catch(t){if(clearTimeout(s),n)return;r({status:`error`,latencyMs:Date.now()-a,url:e,error:t instanceof Error?t.message:`Unreachable`})}};i();let a=setInterval(()=>void i(),1e4);return()=>{n=!0,clearInterval(a)}},[e,t]),n}function Zv(){let e=W(e=>e.hqEnabled),t=W(e=>e.hqUrl),n=W(e=>e.hqToken),[r,i]=(0,X.useState)(()=>({status:e&&t?`checking`:`disabled`,latencyMs:null,url:t||``}));return(0,X.useEffect)(()=>{if(!e||!t){i({status:`disabled`,latencyMs:null,url:t||``});return}let r=!1,a=async()=>{let e=t.trim().replace(/\/+$/,``),a=`${e}/api/auth/status`,o=Date.now(),s=new AbortController,c=setTimeout(()=>s.abort(),2e3);try{let t={accept:`application/json`};n&&(t.Authorization=`Bearer ${n}`);let l=await fetch(a,{method:`GET`,signal:s.signal,headers:t});if(clearTimeout(c),r)return;let u=l.ok||l.status===401;i({status:u?`connected`:`error`,latencyMs:Date.now()-o,url:e,error:u?void 0:`HTTP ${l.status}`})}catch(t){if(clearTimeout(c),r)return;i({status:`error`,latencyMs:Date.now()-o,url:e,error:t instanceof Error?t.message:`Unreachable`})}};a();let o=setInterval(()=>void a(),1e4);return()=>{r=!0,clearInterval(o)}},[e,t,n]),r}function Qv(){let e=Na(e=>e.snapshot),t=K(e=>e.setCronJobsOpen),n=e?.jobs??[],r=n.filter(e=>e.overdue).length,i=n.filter(e=>e.enabled&&!e.overdue).length,a=n.length;return a===0?null:(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>t(!0),className:G(`relative inline-flex h-8 items-center gap-1.5 rounded-md border px-2 text-xs transition-colors`,r>0?`border-destructive/40 bg-destructive/10 text-destructive hover:bg-destructive/15`:`border-border/70 bg-background/60 text-muted-foreground hover:bg-accent/60 hover:text-foreground`),title:`${a} cron job${a===1?``:`s`}${r>0?`, ${r} overdue`:``}`,children:[(0,Z.jsx)(An,{className:`h-3.5 w-3.5`}),(0,Z.jsxs)(`span`,{className:`hidden lg:inline`,children:[i,`/`,a]}),r>0?(0,Z.jsx)(`span`,{className:`min-w-4 bg-destructive/15 px-1 text-[10px] font-semibold tabular-nums text-destructive`,children:r>99?`99+`:r}):null]})}function $v(e,t){let n=Math.max(0,Date.now()-e),r=Math.floor(n/1e3);if(r<10)return t(`toasts:menu.justNow`,{defaultValue:`Just now`});if(r<60)return t(`toasts:menu.secondsAgo`,{count:r,defaultValue:`${r}s ago`});let i=Math.floor(r/60);if(i<60)return t(`toasts:menu.minutesAgo`,{count:i,defaultValue:`${i}m ago`});let a=Math.floor(i/60);if(a<24)return t(`toasts:menu.hoursAgo`,{count:a,defaultValue:`${a}h ago`});let o=Math.floor(a/24);return t(`toasts:menu.daysAgo`,{count:o,defaultValue:`${o}d ago`})}function ey({variant:e}){return e===`success`?(0,Z.jsx)(ui,{className:`h-4 w-4 text-success shrink-0`}):e===`error`?(0,Z.jsx)(Rr,{className:`h-4 w-4 text-destructive shrink-0`}):e===`warn`?(0,Z.jsx)(Kr,{className:`h-4 w-4 text-warning shrink-0`}):(0,Z.jsx)(tr,{className:`h-4 w-4 text-info shrink-0`})}function ty({item:e,onMarkAsRead:t,onRemove:n}){let{t:r}=H(),i=(0,X.useMemo)(()=>$v(e.timestamp,r),[e.timestamp,r]),a=(0,X.useMemo)(()=>new Date(e.timestamp).toLocaleString(),[e.timestamp]);return(0,Z.jsxs)(`div`,{role:`menuitem`,tabIndex:0,onClick:()=>{e.read||t()},onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),e.read||t())},className:G(`group relative flex items-start gap-2.5 px-3 py-2.5 text-xs transition-colors cursor-pointer outline-none select-none`,`hover:bg-accent/50 focus-visible:bg-accent/60`,e.read?`opacity-85`:`bg-primary/[0.04]`),children:[(0,Z.jsx)(`div`,{className:`mt-0.5 shrink-0`,children:(0,Z.jsx)(ey,{variant:e.variant})}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0 pr-1`,children:[(0,Z.jsx)(`div`,{className:G(`whitespace-pre-wrap break-words leading-relaxed text-foreground`,!e.read&&`font-medium`),children:e.message}),(0,Z.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,title:a,children:[(0,Z.jsx)(He,{className:`h-3 w-3 opacity-70`}),i]}),e.action&&(0,Z.jsx)(`button`,{type:`button`,onClick:n=>{n.stopPropagation(),e.action?.onClick(),t()},className:`font-medium text-primary hover:underline`,children:e.action.label})]})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[!e.read&&(0,Z.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),t()},className:`rounded p-0.5 text-muted-foreground hover:bg-accent hover:text-foreground`,title:r(`toasts:menu.markAsRead`,{defaultValue:`Mark as read`}),"aria-label":r(`toasts:menu.markAsRead`,{defaultValue:`Mark as read`}),children:(0,Z.jsx)(ui,{className:`h-3 w-3`})}),(0,Z.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),n()},className:`rounded p-0.5 text-muted-foreground opacity-60 hover:opacity-100 hover:bg-destructive/10 hover:text-destructive transition-opacity`,title:r(`toasts:menu.remove`,{defaultValue:`Remove notification`}),"aria-label":r(`toasts:menu.remove`,{defaultValue:`Remove notification`}),children:(0,Z.jsx)(St,{className:`h-3 w-3`})}),!e.read&&(0,Z.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary shrink-0`,"aria-label":`Unread indicator`})]})]})}function ny({defaultOpen:e,open:t,onOpenChange:n}={}){let{t:r}=H(),i=m(e=>e.notifications),a=m(e=>e.markAsRead),o=m(e=>e.markAllAsRead),s=m(e=>e.clearAll),c=m(e=>e.removeNotification),[l,u]=(0,X.useState)(`all`),d=(0,X.useMemo)(()=>i.filter(e=>!e.read).length,[i]),f=(0,X.useMemo)(()=>l===`unread`?i.filter(e=>!e.read):i,[i,l]),p=(0,X.useCallback)(()=>{o()},[o]),h=(0,X.useCallback)(()=>{s()},[s]);return(0,Z.jsxs)(mo,{defaultOpen:e,open:t,onOpenChange:n,children:[(0,Z.jsx)(ho,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,"data-testid":`notification-menu-trigger`,className:G(`relative inline-flex h-8 w-8 items-center justify-center rounded-md border border-border/70 bg-background/60 text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground`,d>0&&`text-foreground`),title:d>0?`${r(`toasts:menu.title`,{defaultValue:`Notifications`})} (${d} ${r(`toasts:menu.unreadCount`,{count:d,defaultValue:`${d} unread`})})`:r(`toasts:menu.title`,{defaultValue:`Notifications`}),"aria-label":r(`toasts:menu.title`,{defaultValue:`Notifications`}),children:[d>0?(0,Z.jsx)(Ur,{className:`h-3.5 w-3.5 text-primary`}):(0,Z.jsx)(Qn,{className:`h-3.5 w-3.5`}),d>0&&(0,Z.jsx)(`span`,{"data-testid":`notification-badge`,className:`absolute -top-1 -right-1 flex h-4 min-w-4 items-center justify-center rounded-full bg-destructive px-1 text-[10px] font-bold text-destructive-foreground shadow-sm`,children:d>99?`99+`:d})]})}),(0,Z.jsxs)(vo,{align:`end`,sideOffset:6,className:`w-80 sm:w-96 max-w-[calc(100vw-1rem)] p-0 rounded-xl border border-border/80 bg-card/95 backdrop-blur-xl shadow-2xl overflow-hidden text-card-foreground`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/60 px-3.5 py-2.5 bg-muted/30`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`font-semibold text-xs text-foreground`,children:r(`toasts:menu.title`,{defaultValue:`Notifications`})}),d>0?(0,Z.jsxs)(`span`,{className:`rounded-full bg-primary/15 px-2 py-0.5 text-[10px] font-medium text-primary tabular-nums`,children:[d,` `,r(`toasts:menu.tabUnread`,{defaultValue:`Unread`}).toLowerCase()]}):null]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Z.jsxs)(`button`,{type:`button`,disabled:d===0,onClick:p,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground disabled:opacity-40 disabled:pointer-events-none`,title:r(`toasts:menu.markAllRead`,{defaultValue:`Mark all as read`}),children:[(0,Z.jsx)(vt,{className:`h-3.5 w-3.5`}),(0,Z.jsx)(`span`,{children:r(`toasts:menu.markAllRead`,{defaultValue:`Mark all as read`})})]}),(0,Z.jsxs)(`button`,{type:`button`,disabled:i.length===0,onClick:h,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive disabled:opacity-40 disabled:pointer-events-none`,title:r(`toasts:menu.clearAll`,{defaultValue:`Clear all`}),children:[(0,Z.jsx)(vr,{className:`h-3.5 w-3.5`}),(0,Z.jsx)(`span`,{children:r(`toasts:menu.clearAll`,{defaultValue:`Clear all`})})]})]})]}),(0,Z.jsxs)(`div`,{className:`flex border-b border-border/50 bg-background/50 px-3 py-1.5 gap-1.5 text-xs`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>u(`all`),className:G(`flex-1 rounded-md px-2.5 py-1 text-center font-medium transition-all`,l===`all`?`bg-accent text-accent-foreground shadow-xs`:`text-muted-foreground hover:bg-accent/50 hover:text-foreground`),children:[r(`toasts:menu.tabAll`,{defaultValue:`All`}),` (`,i.length,`)`]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>u(`unread`),className:G(`flex-1 rounded-md px-2.5 py-1 text-center font-medium transition-all`,l===`unread`?`bg-accent text-accent-foreground shadow-xs`:`text-muted-foreground hover:bg-accent/50 hover:text-foreground`),children:[r(`toasts:menu.tabUnread`,{defaultValue:`Unread`}),` (`,d,`)`]})]}),(0,Z.jsx)(`div`,{role:`list`,className:`max-h-[340px] overflow-y-auto divide-y divide-border/30`,"aria-label":r(`toasts:menu.title`,{defaultValue:`Notifications`}),children:f.length===0?(0,Z.jsxs)(`div`,{className:`flex flex-col items-center justify-center px-4 py-8 text-center text-muted-foreground`,children:[(0,Z.jsx)(Ci,{className:`h-7 w-7 text-muted-foreground/40 mb-2`}),(0,Z.jsx)(`p`,{className:`text-xs font-medium text-foreground`,children:l===`unread`&&i.length>0?r(`toasts:menu.allRead`,{defaultValue:`All caught up`}):r(`toasts:menu.empty`,{defaultValue:`No notifications`})}),(0,Z.jsx)(`p`,{className:`text-[11px] text-muted-foreground mt-0.5 max-w-[220px]`,children:l===`unread`&&i.length>0?r(`toasts:menu.allRead`,{defaultValue:`All caught up`}):r(`toasts:menu.emptyHint`,{defaultValue:`Toasts and system notifications will appear here.`})})]}):f.map(e=>(0,Z.jsx)(ty,{item:e,onMarkAsRead:()=>a(e.id),onRemove:()=>c(e.id)},e.id))})]})]})}function ry(e){return e.split(`-`).map(e=>e.slice(0,1).toUpperCase()+e.slice(1)).join(` `)}function iy(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 ay(){let[e,t]=(0,X.useState)(null);return(0,X.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 oy({currentView:e,projectName:t,sessionLabel:n,isLoading:r,iteration:i,onPalette:a,onSettings:o}){let{t:s}=H(),{theme:c,setTheme:l,palette:u,setPalette:d}=Vu(),f=R(e=>e.wsConnected),p=N(e=>e.appVersion),m=N(e=>e.latestVersion),h=N(e=>e.updateAvailable),g=N(e=>e.droppedTools),_=c===`system`?typeof window<`u`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:c,v=(0,X.useCallback)(()=>{l(_===`dark`?`light`:`dark`)},[_,l]),y=K(e=>e.toggleSidebar),b=Xv(),x=Zv(),S=b.status===`connected`?`WrongProxy: Connected${b.latencyMs==null?``:` (${b.latencyMs}ms)`} · ${b.url}`:b.status===`error`?`WrongProxy: Unreachable · ${b.url}${b.error?` (${b.error})`:``}`:b.status===`checking`?`WrongProxy: Checking · ${b.url}`:`WrongProxy: Disabled`,C=x.status===`connected`?`HQ: Connected${x.latencyMs==null?``:` (${x.latencyMs}ms)`} · ${x.url}`:x.status===`error`?`HQ: Unreachable · ${x.url}${x.error?` (${x.error})`:``}`:x.status===`checking`?`HQ: Checking · ${x.url}`:`HQ: Disabled`,w=ay(),T=w?w.memoryUsage.heapUsed/w.heapLimit:0,E=w?.codebaseIndexServer,D=E?.health,O=D?.server;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-border/70 bg-card/85 px-2.5 py-1.5 shadow-sm backdrop-blur-xl md:hidden`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:y,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`,"aria-label":`Toggle navigation menu`,title:`Toggle navigation`,children:(0,Z.jsx)(ht,{className:`h-4 w-4`})}),(0,Z.jsx)(`div`,{className:`min-w-0`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`truncate text-xs font-semibold`,children:t||`WrongStack`}),(0,Z.jsx)(`span`,{className:`rounded bg-muted/60 px-1 py-0.5 text-[10px] text-muted-foreground font-mono`,children:ry(e)}),r&&(0,Z.jsx)(`span`,{className:`inline-flex items-center gap-0.5 text-[10px] font-medium text-primary`,children:(0,Z.jsx)(jr,{className:`h-3 w-3 animate-pulse`})})]})})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,Z.jsx)(Lc,{}),(0,Z.jsx)(ny,{}),(0,Z.jsx)(`button`,{type:`button`,onClick:v,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:_===`dark`?`Switch to light theme`:`Switch to dark theme`,children:_===`dark`?(0,Z.jsx)(Ji,{className:`h-3.5 w-3.5`}):(0,Z.jsx)(qe,{className:`h-3.5 w-3.5`})}),(0,Z.jsxs)(mo,{children:[(0,Z.jsx)(ho,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,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:`More options`,"aria-label":`More options`,children:(0,Z.jsx)(Mr,{className:`h-3.5 w-3.5`})})}),(0,Z.jsxs)(vo,{align:`end`,className:`w-48`,children:[(0,Z.jsxs)(yo,{onSelect:a,className:`gap-2`,children:[(0,Z.jsx)(xr,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:s(`activity:topbar.command`)})]}),(0,Z.jsxs)(yo,{onSelect:o,className:`gap-2`,children:[(0,Z.jsx)(kt,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:s(`activity:topbar.settings`)})]}),(0,Z.jsxs)(`div`,{className:`border-t border-border/60 my-1 px-2 py-1 space-y-1 text-[11px] text-muted-foreground`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`span`,{children:`Backend WS`}),(0,Z.jsx)(`span`,{className:G(`font-mono font-medium`,f?`text-success`:`text-warning`),children:f?`Connected`:`Offline`})]}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`span`,{children:`WrongProxy`}),(0,Z.jsx)(`span`,{className:G(`font-mono font-medium`,b.status===`connected`?`text-success`:b.status===`error`?`text-destructive`:`text-muted-foreground`),children:b.status===`connected`?`Connected`:b.status===`error`?`Offline`:`Disabled`})]}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`span`,{children:`HQ`}),(0,Z.jsx)(`span`,{className:G(`font-mono font-medium`,x.status===`connected`?`text-success`:x.status===`error`?`text-destructive`:`text-muted-foreground`),children:x.status===`connected`?`Connected`:x.status===`error`?`Offline`:`Disabled`})]})]})]})]})]})]}),(0,Z.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,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Z.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate text-sm font-semibold`,children:t||`WrongStack`}),p?(0,Z.jsxs)(`span`,{className:G(`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-[11px] font-medium tabular-nums`,h&&m&&m!==p?`border-warning/40 bg-warning/10 text-warning`:`border-border/70 bg-muted/50 text-muted-foreground`),title:h&&m&&m!==p?`Update available: v${p} → v${m} — run wstack update`:`WrongStack v${p}`,children:[`v`,p,h&&m&&m!==p?(0,Z.jsxs)(`span`,{className:`text-[10px] opacity-80`,children:[`→ v`,m]}):null]}):null,(0,Z.jsx)(`span`,{className:`rounded-md border border-border/70 bg-muted/50 px-1.5 py-0.5 text-[11px] text-muted-foreground`,children:ry(e)}),(0,Z.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,Z.jsx)(jr,{className:`h-3 w-3 animate-pulse`}):(0,Z.jsx)(et,{className:`h-3 w-3`}),r?`Running`:`Ready`,i?(0,Z.jsxs)(`span`,{className:`tabular`,children:[i.index,i.max>0?`/${i.max}`:``]}):null]}),(0,Z.jsx)(Lc,{showCountWhenZero:!0}),w?(0,Z.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`,T>=.85?`text-destructive`:T>=.6?`text-warning`:`text-success`),title:`WebUI server PID ${w.pid} · heap ${iy(w.memoryUsage.heapUsed)} / ${iy(w.heapLimit)}`,children:[`RAM `,iy(w.memoryUsage.rss)]}):null,E?(0,Z.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`,E.status===`connected`?`text-success`:E.status===`unresponsive`||E.status===`error`?`text-destructive`:E.status===`degraded`||E.status===`connecting`||E.status===`stopping`?`text-warning`:`text-muted-foreground`),title:[`Codebase index: ${D?.status??E.status}`,E.pid?`PID ${E.pid}`:null,D?.latencyMs==null?null:`RTT ${D.latencyMs}ms`,O?`RAM ${iy(O.memory.rss)}`:null,D?.missedHeartbeats?`missed ${D.missedHeartbeats}`:null].filter(Boolean).join(` · `),children:[`Index `,D?.status??E.status]}):null,g>0?(0,Z.jsxs)(`span`,{className:`rounded-md border border-warning/40 bg-warning/10 px-1.5 py-0.5 text-[11px] font-medium tabular-nums text-warning`,title:`${g} tool(s) dropped from provider requests due to maxTools limit`,children:[`-`,g,` tools`]}):null]}),(0,Z.jsx)(`div`,{className:`mt-0.5 truncate text-[11px] text-muted-foreground`,children:n||`No named session`})]})}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,Z.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:s(`activity:topbar.commandPalette`),children:[(0,Z.jsx)(xr,{className:`h-3.5 w-3.5`}),s(`activity:topbar.command`)]}),(0,Z.jsx)(`button`,{type:`button`,onClick:v,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:_===`dark`?`Switch to light theme`:`Switch to dark theme`,children:_===`dark`?(0,Z.jsx)(Ji,{className:`h-3.5 w-3.5`}):(0,Z.jsx)(qe,{className:`h-3.5 w-3.5`})}),(0,Z.jsxs)(mo,{children:[(0,Z.jsx)(ho,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,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:`${s(`settings:general.paletteSwitcherTitle`)}: ${s(I(u).labelKey)}`,"aria-label":`${s(`settings:general.paletteSwitcherTitle`)}: ${s(I(u).labelKey)}`,children:(0,Z.jsx)(Jn,{className:`h-3.5 w-3.5`})})}),(0,Z.jsxs)(vo,{align:`end`,className:`w-56`,children:[(0,Z.jsx)(So,{children:s(`settings:general.paletteHeading`)}),le.map(e=>(0,Z.jsxs)(yo,{onSelect:()=>d(e.id),className:`gap-2`,children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`h-4 w-4 shrink-0 rounded-[3px] border border-border/70`,style:{background:`linear-gradient(90deg, ${e.swatch} 0 50%, ${e.swatchSecondary} 50% 100%)`}}),(0,Z.jsx)(`span`,{className:`flex-1`,children:s(e.labelKey)}),u===e.id?(0,Z.jsx)(ui,{className:`h-3.5 w-3.5 text-primary`,"aria-hidden":!0}):null]},e.id))]})]}),(0,Z.jsx)(Qv,{}),(0,Z.jsx)(ny,{}),(0,Z.jsx)(`button`,{type:`button`,onClick:o,className:G(`inline-flex h-8 w-8 items-center justify-center rounded-md border bg-background/60 transition-colors`,b.status===`connected`?`border-border/70 text-success hover:bg-accent/60`:b.status===`error`?`border-destructive/40 bg-destructive/10 text-destructive hover:bg-destructive/20`:`border-border/50 text-muted-foreground/40 hover:text-muted-foreground hover:bg-accent/60`),title:S,"aria-label":S,"data-testid":`wrongproxy-status-button`,children:(0,Z.jsx)(xt,{className:`h-3.5 w-3.5`})}),(0,Z.jsx)(`button`,{type:`button`,onClick:o,className:G(`inline-flex h-8 w-8 items-center justify-center rounded-md border bg-background/60 transition-colors`,x.status===`connected`?`border-border/70 text-success hover:bg-accent/60`:x.status===`error`?`border-destructive/40 bg-destructive/10 text-destructive hover:bg-destructive/20`:`border-border/50 text-muted-foreground/40 hover:text-muted-foreground hover:bg-accent/60`),title:C,"aria-label":C,"data-testid":`hq-status-button`,children:(0,Z.jsx)(Zr,{className:`h-3.5 w-3.5`})}),(0,Z.jsx)(`span`,{role:`status`,"aria-label":f?`Connected`:`Disconnected`,className:G(`inline-flex h-8 w-8 items-center justify-center rounded-md border border-border/70 bg-background/60`,f?`text-success`:`text-warning`),title:f?`Connected`:`Disconnected`,"data-testid":`ws-status-indicator`,children:f?(0,Z.jsx)(_t,{className:`h-3.5 w-3.5`}):(0,Z.jsx)(En,{className:`h-3.5 w-3.5`})}),(0,Z.jsx)(`button`,{type:`button`,onClick:o,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:s(`activity:topbar.settings`),children:(0,Z.jsx)(kt,{className:`h-3.5 w-3.5`})})]})]})})]})}var sy=(0,X.lazy)(()=>ta(()=>import(`./CronJobsPanel-CGq8lhRJ.js`).then(e=>({default:e.CronJobsPanel})),__vite__mapDeps([67,1,2,3,4,5,6,7,8,9,10,11,12,13,14,18,0,15,16,19,20,21,29]))),cy=(0,X.lazy)(()=>ta(()=>import(`./ProcessMonitor-CBIQkbLx.js`).then(e=>({default:e.ProcessMonitor})),__vite__mapDeps([63,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,25,20,18,19,21,23,26,29]))),ly=(0,X.lazy)(()=>ta(()=>import(`./QueuePanel-CutrvgTH.js`).then(e=>({default:e.QueuePanel})),__vite__mapDeps([68,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,19,18,20,21,29])));function uy(){let{t:e}=H(),{theme:n}=Vu(),r=oa(),{currentView:i,sidebarOpen:a,toggleSidebar:o,setSearchOpen:s,setSidebarOpen:c,setInspectorTab:l,setPaletteOpen:u,setShortcutsOpen:d,setModelSwitcherOpen:f,setPromptLibraryOpen:p,toggleInspector:m,setFleetMonitorOpen:g,setAgentsMonitorOpen:v,processMonitorOpen:y,setProcessMonitorOpen:b,queuePanelOpen:x,setQueuePanelOpen:S,cronJobsOpen:C,setCronJobsOpen:w,setTerminalOpen:E}=K(Me(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,setTerminalOpen:e.setTerminalOpen}))),D=q(e=>e.isLoading),O=q(e=>e.messages.length),k=T(e=>e.info),A=T(e=>e.promptedThisSession);(0,X.useEffect)(()=>{!k||k.chosen||k.variants.length!==0&&(O>0||A||T.getState().openPicker())},[k,O,A]);let j=N(e=>e.iteration),M=N(e=>e.projectName),P=N(e=>e.session?.title),F=N(e=>e.session?.id),I=ve()??F,L=K(e=>I?e.sessionNicknames[I]:void 0),ee=K(e=>e.sideContextBreakdownOpen),te=K(e=>e.setSideContextBreakdownOpen);_(e=>e.agents),$o({setPaletteOpen:u,setSearchOpen:s,setShortcutsOpen:d,setModelSwitcherOpen:f,setPromptLibraryOpen:p,setFleetMonitorOpen:g,setAgentsMonitorOpen:v,setProcessMonitorOpen:b,setQueuePanelOpen:S,setCronJobsOpen:w,setTerminalOpen:E}),(0,X.useEffect)(()=>{typeof window>`u`||(window.location.pathname===`/debug`?za(`debug`):window.location.pathname===`/analytics`?za(`analytics`):window.location.pathname===`/refresh-debug`&&za(`refresh-debug`))},[]),(0,X.useEffect)(()=>{let e=e=>{let{filePath:t}=e.detail;K.getState().setCurrentView(`files`);let n=V(R.getState().wsUrl);n&&n.send({type:`files.read`,payload:n.withSession({filePath:t})})};return window.addEventListener(`wrongstack:open-file`,e),()=>window.removeEventListener(`wrongstack:open-file`,e)},[]),(0,X.useEffect)(()=>{let e=e=>{let{filePath:n}=e.detail,r=t.getState().openFiles.find(e=>e.path===n);if(!r)return;let i=V(R.getState().wsUrl);i&&i.send({type:`files.write`,payload:i.withSession({filePath:n,content:r.content})})};return window.addEventListener(`wrongstack:save-file`,e),()=>window.removeEventListener(`wrongstack:save-file`,e)},[]);let{isMobile:z}=ia();(0,X.useEffect)(()=>{z&&K.getState().sidebarOpen&&c(!1)},[z,c]);let ne=z&&a;return ua(),rs(),ts(),(0,X.useEffect)(()=>{let e=[];if(D){let t=j?` iter ${j.index}${j.max?`/${j.max}`:``}`:``;e.push(`●${t}`)}let t=L?.trim()||P?.trim(),n=M?.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=M||`AI Agent`}},[D,j,M,P,L]),ns({toggleSidebar:o,setSearchOpen:s,toggleInspector:m,setInspectorTab:l}),(0,Z.jsxs)(`div`,{"data-shell":r?`desktop`:`browser`,className:G(`ws-app-root flex min-h-0 min-w-0 overflow-hidden`,r&&`ws-desktop-shell`,n),children:[(0,Z.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:e(`activity:app.skipToContent`)}),i!==`setup`&&(0,Z.jsx)(Ro,{desktopShell:r}),a&&i!==`setup`&&(0,Z.jsx)(Lu,{desktopShell:r}),(0,Z.jsxs)(`main`,{id:`main-content`,className:`flex-1 min-w-0 min-h-0 flex flex-col overflow-hidden bg-background/70`,...ne?{inert:!0}:{},children:[i!==`setup`&&(0,Z.jsx)(oy,{currentView:i,projectName:M,sessionLabel:L||P||I||void 0,isLoading:D,iteration:j??null,onPalette:()=>u(!0),onSettings:()=>Ba(`settings`)}),i!==`setup`&&(0,Z.jsx)(`div`,{className:G(i!==`chat`&&`ws-view-parked`),...i===`chat`?{}:{inert:!0,"aria-hidden":!0},children:(0,Z.jsx)(fl,{})}),i!==`setup`&&(0,Z.jsx)(gs,{}),i!==`setup`&&(0,Z.jsx)(Uu,{}),(0,Z.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col`,children:(0,Z.jsx)(Jv,{sessionId:I??null,desktopShell:r})})]}),i!==`setup`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Os,{level:`panel`,name:e(`activity:panels.inspector`),children:(0,Z.jsx)(Rc,{})}),I&&(0,Z.jsx)(Os,{level:`panel`,name:e(`activity:panels.workspaceInspector`),children:(0,Z.jsx)(Kv,{sessionId:I})})]}),y&&(0,Z.jsx)(Os,{level:`panel`,name:e(`activity:panels.processMonitor`),children:(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)(cy,{open:y,onClose:()=>b(!1)})})}),x&&(0,Z.jsx)(Os,{level:`panel`,name:e(`activity:panels.queue`),children:(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)(ly,{open:x,onClose:()=>S(!1)})})}),C&&(0,Z.jsx)(Os,{level:`panel`,name:e(`activity:panels.cronJobs`),children:(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)(sy,{open:C,onClose:()=>w(!1)})})}),(0,Z.jsx)(Kc,{}),ee&&(0,Z.jsx)(Es,{open:ee,onClose:()=>te(!1)}),(0,Z.jsx)(ps,{}),(0,Z.jsx)(Ru,{}),(0,Z.jsx)(eo,{}),(0,Z.jsx)(hs,{}),(0,Z.jsx)(Za,{}),(0,Z.jsx)(Zo,{}),(0,Z.jsx)(ml,{}),(0,Z.jsx)(rl,{}),(0,Z.jsx)(ks,{}),(0,Z.jsx)(h,{})]})}function dy(){return(0,Z.jsx)(Os,{children:(0,Z.jsx)(Bu,{defaultTheme:`system`,children:(0,Z.jsx)(uy,{})})})}oo.createRoot(k(document.getElementById(`root`))).render((0,Z.jsx)(X.StrictMode,{children:(0,Z.jsx)(dy,{})}));export{mo as A,Ns as C,js as D,Fs as E,yo as M,ho as N,cs as O,vc as S,Ps as T,Vu as _,M_ as a,Tc as b,r_ as c,Af as d,Cf as f,Gu as g,wd as h,V_ as i,vo as j,os as k,jf as l,rf as m,Lv as n,d_ as o,Sf as p,Nv as r,a_ as s,zv as t,Mf as u,Bl as v,Is as w,wc as x,Ll as y};
|