@wrongstack/webui 0.319.0 → 0.319.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/assets/{AgentRosterView-BVpIFQwi.js → AgentRosterView-VIctzKMy.js} +1 -1
  2. package/dist/assets/{AnalyticsDashboard-nqlWJi6M.js → AnalyticsDashboard-Dr67MeEY.js} +1 -1
  3. package/dist/assets/{AudienceMemoryPanel-BT6C4Jkw.js → AudienceMemoryPanel-DoaZfrjf.js} +1 -1
  4. package/dist/assets/{ChangesView-CN7NWDeV.js → ChangesView-s7Mn7iE2.js} +1 -1
  5. package/dist/assets/ChimeraReviewsView-Cverzv0b.js +1 -0
  6. package/dist/assets/{ChronicleDashboard-BWMkG_hu.js → ChronicleDashboard-CzqPfaPc.js} +1 -1
  7. package/dist/assets/{CodeEditor-DZ2k-Mz5.js → CodeEditor-DXQoTSH5.js} +1 -1
  8. package/dist/assets/{CodeMap-CLOuNLqN.js → CodeMap-D34FOPgR.js} +1 -1
  9. package/dist/assets/{CronJobsPanel-CsMIoWVQ.js → CronJobsPanel-CenxuaN9.js} +1 -1
  10. package/dist/assets/{DebugDashboard-C0tmxxV8.js → DebugDashboard-DWaUg6e1.js} +1 -1
  11. package/dist/assets/{DesignGalleryView-lc-XRmVG.js → DesignGalleryView-BKtjn4px.js} +1 -1
  12. package/dist/assets/{GoalView-BuYUc4OB.js → GoalView-BZ62_vF-.js} +1 -1
  13. package/dist/assets/{KanbanView-DQK6adut.js → KanbanView-DsWnTpxr.js} +1 -1
  14. package/dist/assets/{MailboxDetailView-CBV3-Hf2.js → MailboxDetailView-DS1P9DRT.js} +1 -1
  15. package/dist/assets/{MemoryDrawer-rPf-1Ulk.js → MemoryDrawer-BJEY1v4P.js} +1 -1
  16. package/dist/assets/{MemoryManager-B_ZJhOqq.js → MemoryManager-D-kuyTQe.js} +1 -1
  17. package/dist/assets/{OfficeMapPanel-DnbdkXL1.js → OfficeMapPanel-BqoCcniD.js} +1 -1
  18. package/dist/assets/{RequirementIntakeView-g9dzUTVw.js → RequirementIntakeView-BVyF2zXR.js} +1 -1
  19. package/dist/assets/{SageTabs-Bw6PDwy3.js → SageTabs-YASyEFo6.js} +2 -2
  20. package/dist/assets/{SddHub-Cdow0Exb.js → SddHub-rmGGEYZe.js} +1 -1
  21. package/dist/assets/{SessionInspectView-je_xLISf.js → SessionInspectView-iaKkGAAM.js} +1 -1
  22. package/dist/assets/{SessionList-4y1uuB-y.js → SessionList-vmAS2Fg5.js} +1 -1
  23. package/dist/assets/{SessionsDashboard-DkaNF5lx.js → SessionsDashboard-x3iyhrGl.js} +1 -1
  24. package/dist/assets/SetupScreen-huPJT0Bv.js +1 -0
  25. package/dist/assets/{SkillDetailView-Bjq8GkDB.js → SkillDetailView-BcD9z7zG.js} +1 -1
  26. package/dist/assets/{TechStackView-CQ9AdoBa.js → TechStackView-DmMtwb4l.js} +1 -1
  27. package/dist/assets/{index-Cwjer17r.js → index-BQ7PJ-sA.js} +3 -3
  28. package/dist/components/ChatInput/use-speech-recognition.d.ts +1 -1
  29. package/dist/components/DependencyGraph.d.ts +1 -1
  30. package/dist/components/DiffView.d.ts +1 -1
  31. package/dist/components/MessageBubble/ToolLedgerCard.d.ts +1 -1
  32. package/dist/components/SetupScreen/CustomProviderSection.d.ts +1 -1
  33. package/dist/components/agents/AgentRosterCard.d.ts +1 -1
  34. package/dist/components/context-editor/ContextWindowEditor.d.ts +1 -1
  35. package/dist/components/ui/dropdown-menu.d.ts +1 -1
  36. package/dist/components/vector-memory-panel/index.d.ts +1 -1
  37. package/dist/index.html +1 -1
  38. package/dist/index.js +4835 -3052
  39. package/dist/manifest.json +1 -1
  40. package/dist/stores/index.d.ts +2 -2
  41. package/package.json +9 -9
  42. package/dist/assets/ChimeraReviewsView-BNQE5kRx.js +0 -1
  43. package/dist/assets/SetupScreen-DWzbXvmU.js +0 -1
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ws-client-DtTZLD8e.js","assets/rolldown-runtime-hePW80VL.js","assets/vendor-enc0q-Va.js","assets/monaco-BCqJp2xW.js","assets/monaco-Bowa0-zp.css","assets/markdown-Kp5uSgOw.js","assets/vendor-BMdWcCR4.css","assets/i18n-D06uU1PM.js","assets/activity-CtTKsSX6.js","assets/chat-BITJe8-v.js","assets/commandPalette-BovBiPec.js","assets/common-BBHmIHQW.js","assets/settings-Ci_RMpCQ.js","assets/setup-Dwt58Mpz.js","assets/toasts-DZ6HdKgG.js","assets/utils-DQ9Exx8j.js","assets/ui-store-Dm7ujR9u.js","assets/ProcessMonitor-CHNNqCk9.js","assets/useWebSocket-9lfOsI_r.js","assets/codemap-activity-store-Br4b57a0.js","assets/stores-C7Vvce-6.js","assets/chat-store-oW_-zcJP.js","assets/mailbox-store-B9DIvRgo.js","assets/view-navigation-wOKaM_Rf.js","assets/codemap-index-store-tSmlp7Uz.js","assets/dialog-BTHxOi5z.js","assets/AnalyticsDashboard-nqlWJi6M.js","assets/AgentRosterView-BVpIFQwi.js","assets/ModelPicker-CLs0qQgg.js","assets/roster-ws-BQUI8QuW.js","assets/AudienceMemoryPanel-BT6C4Jkw.js","assets/button-DNyYztcH.js","assets/input-CTGeYzNe.js","assets/shared-CLfD85oZ.js","assets/OfficeMapPanel-DnbdkXL1.js","assets/OfficeMapPanel-Ce7myLNH.css","assets/ChangesView-CN7NWDeV.js","assets/empty-state-DBQN80mK.js","assets/monaco-theme-CR1QvFi2.js","assets/ChronicleDashboard-BWMkG_hu.js","assets/CodeEditor-DZ2k-Mz5.js","assets/MemoryDrawer-rPf-1Ulk.js","assets/CodeMap-CLOuNLqN.js","assets/DebugDashboard-C0tmxxV8.js","assets/DesignGalleryView-lc-XRmVG.js","assets/GoalView-BuYUc4OB.js","assets/ConfirmModal-B6BGiiN8.js","assets/KanbanView-DQK6adut.js","assets/SddFlowGraph-Bj_Aqq5B.js","assets/MailboxDetailView-CBV3-Hf2.js","assets/PromptJournalView-Biu4DknM.js","assets/RefreshDebugView-d9iU3sFX.js","assets/SageTabs-Bw6PDwy3.js","assets/RequirementIntakeView-g9dzUTVw.js","assets/SddHub-Cdow0Exb.js","assets/SpecsView-ok8HZ8ws.js","assets/SessionsDashboard-DkaNF5lx.js","assets/SessionList-4y1uuB-y.js","assets/SessionInspectView-je_xLISf.js","assets/SkillDetailView-Bjq8GkDB.js","assets/TechStackView-CQ9AdoBa.js","assets/DeadCodeScanPanel-DooqnEMF.js","assets/ChimeraReviewsView-BNQE5kRx.js","assets/SetupScreen-DWzbXvmU.js","assets/TerminalPanel-cbM6oQWQ.js","assets/xterm-BWzBEEhg.js","assets/xterm-BrP-ENHg.css","assets/CronJobsPanel-CsMIoWVQ.js","assets/QueuePanel-CzTXq6j4.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ws-client-DtTZLD8e.js","assets/rolldown-runtime-hePW80VL.js","assets/vendor-enc0q-Va.js","assets/monaco-BCqJp2xW.js","assets/monaco-Bowa0-zp.css","assets/markdown-Kp5uSgOw.js","assets/vendor-BMdWcCR4.css","assets/i18n-D06uU1PM.js","assets/activity-CtTKsSX6.js","assets/chat-BITJe8-v.js","assets/commandPalette-BovBiPec.js","assets/common-BBHmIHQW.js","assets/settings-Ci_RMpCQ.js","assets/setup-Dwt58Mpz.js","assets/toasts-DZ6HdKgG.js","assets/utils-DQ9Exx8j.js","assets/ui-store-Dm7ujR9u.js","assets/ProcessMonitor-CHNNqCk9.js","assets/useWebSocket-9lfOsI_r.js","assets/codemap-activity-store-Br4b57a0.js","assets/stores-C7Vvce-6.js","assets/chat-store-oW_-zcJP.js","assets/mailbox-store-B9DIvRgo.js","assets/view-navigation-wOKaM_Rf.js","assets/codemap-index-store-tSmlp7Uz.js","assets/dialog-BTHxOi5z.js","assets/AnalyticsDashboard-Dr67MeEY.js","assets/AgentRosterView-VIctzKMy.js","assets/ModelPicker-CLs0qQgg.js","assets/roster-ws-BQUI8QuW.js","assets/AudienceMemoryPanel-DoaZfrjf.js","assets/button-DNyYztcH.js","assets/input-CTGeYzNe.js","assets/shared-CLfD85oZ.js","assets/OfficeMapPanel-BqoCcniD.js","assets/OfficeMapPanel-Ce7myLNH.css","assets/ChangesView-s7Mn7iE2.js","assets/empty-state-DBQN80mK.js","assets/monaco-theme-CR1QvFi2.js","assets/ChronicleDashboard-CzqPfaPc.js","assets/CodeEditor-DXQoTSH5.js","assets/MemoryDrawer-BJEY1v4P.js","assets/CodeMap-D34FOPgR.js","assets/DebugDashboard-DWaUg6e1.js","assets/DesignGalleryView-BKtjn4px.js","assets/GoalView-BZ62_vF-.js","assets/ConfirmModal-B6BGiiN8.js","assets/KanbanView-DsWnTpxr.js","assets/SddFlowGraph-Bj_Aqq5B.js","assets/MailboxDetailView-DS1P9DRT.js","assets/PromptJournalView-Biu4DknM.js","assets/RefreshDebugView-d9iU3sFX.js","assets/SageTabs-YASyEFo6.js","assets/RequirementIntakeView-BVyF2zXR.js","assets/SddHub-rmGGEYZe.js","assets/SpecsView-ok8HZ8ws.js","assets/SessionsDashboard-x3iyhrGl.js","assets/SessionList-vmAS2Fg5.js","assets/SessionInspectView-iaKkGAAM.js","assets/SkillDetailView-BcD9z7zG.js","assets/TechStackView-DmMtwb4l.js","assets/DeadCodeScanPanel-DooqnEMF.js","assets/ChimeraReviewsView-Cverzv0b.js","assets/SetupScreen-huPJT0Bv.js","assets/TerminalPanel-cbM6oQWQ.js","assets/xterm-BWzBEEhg.js","assets/xterm-BrP-ENHg.css","assets/CronJobsPanel-CenxuaN9.js","assets/QueuePanel-CzTXq6j4.js"])))=>i.map(i=>d[i]);
2
2
  import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,A as n,B as r,C as i,D as a,Dt as o,E as s,F as c,G as l,H as u,Ht as d,It as f,K as p,L as m,M as h,Mt as g,N as _,O as v,Ot as y,P as b,Pt as x,Q as S,R as C,S as w,St as T,T as E,U as D,V as O,Vt as k,W as A,X as j,Y as M,Z as ee,_ as N,_t as P,a as F,at as I,b as te,et as L,f as R,g as z,h as ne,i as re,it as ie,j as B,k as ae,lt as oe,m as se,mt as ce,nt as le,ot as ue,p as de,q as fe,rt as pe,t as V,tt as me,v as he,vt as ge,w as _e,wt as ve,x as ye,y as be,z as xe}from"./ws-client-DtTZLD8e.js";import{$ as Se,$i as Ce,$n as we,$r as Te,$t as Ee,A as De,Aa as Oe,Ai as ke,An as Ae,Ar as je,At as Me,B as Ne,Ba as Pe,Bn as Fe,Br as Ie,Bt as Le,C as Re,Ci as ze,Cr as Be,Ct as Ve,D as He,Di as Ue,Dn as We,Dr as Ge,Dt as Ke,E as qe,Ea as Je,Ei as Ye,En as Xe,Er as Ze,F as Qe,Fa as $e,Fi as et,Fr as tt,Ft as nt,G as rt,Gr as it,H as at,Ha as ot,Hi as st,Ht as ct,I as lt,Ia as ut,Ii as dt,In as ft,Ir as pt,It as mt,J as ht,Ji as gt,Jn as _t,Jr as vt,Jt as yt,K as bt,Ka as xt,Ki as St,Kn as Ct,Kr as wt,Kt as Tt,L as Et,La as Dt,Li as Ot,Ln as kt,Lr as At,Lt as jt,M as Mt,Ma as Nt,Mi as Pt,Mn as Ft,Mr as It,Mt as Lt,N as Rt,Na as zt,Ni as Bt,Nn as Vt,Nt as Ht,O as Ut,Oa as Wt,Oi as Gt,On as Kt,Or as qt,Ot as Jt,P as Yt,Pr as Xt,Q as Zt,Qa as Qt,Qn as $t,Qr as en,Qt as tn,R as nn,Ra as rn,Rn as an,Rr as on,Rt as sn,Sa as cn,Si as ln,Sn as un,St as dn,T as fn,Tn as pn,Tr as mn,Tt as hn,U as gn,Ua as _n,Ui as vn,Un as yn,V as bn,Va as xn,Vn as Sn,Vr as Cn,Vt as wn,W as Tn,Wi as En,Wn as Dn,Wr as On,Wt as kn,X as An,Xa as jn,Xn as Mn,Xr as Nn,Y as Pn,Yi as Fn,Yn as In,Yr as Ln,Yt as Rn,Z as zn,Zn as Bn,_a as Vn,_i as Hn,_n as Un,_r as Wn,_t as Gn,aa as Kn,ai as qn,an as Jn,ao as Yn,at as Xn,ba as Zn,bi as Qn,br as $n,bt as er,ca as tr,ci as nr,cr as rr,ct as ir,da as ar,dn as or,dr as sr,dt as cr,en as lr,er as ur,et as dr,fa as fr,fr as pr,ft as mr,ga as hr,gn as gr,gt as _r,ha as vr,hi as yr,hn as br,hr as xr,ht as Sr,ia as Cr,ii as wr,in as Tr,io as H,ir as Er,it as Dr,j as Or,ja as kr,ji as Ar,jn as jr,jr as Mr,jt as Nr,k as Pr,ka as Fr,ki as Ir,kn as Lr,kt as Rr,la as zr,li as Br,ln as Vr,lr as Hr,ma as Ur,mi as Wr,mn as Gr,mr as Kr,mt as qr,na as Jr,ni as Yr,nr as Xr,nt as Zr,oa as Qr,oi as $r,on as ei,oo as ti,or as ni,ot as ri,pa as ii,pi as ai,pt as oi,q as si,qa as ci,qi as li,qn as ui,qt as di,ra as fi,ri as pi,rn as mi,rr as hi,rt as gi,sa as _i,sn as vi,sr as yi,st as bi,ti as xi,tn as Si,to as U,tr as Ci,tt as wi,ua as Ti,ui as Ei,ur as Di,ut as Oi,vi as ki,vn as Ai,vr as ji,vt as Mi,w as Ni,wa as Pi,wi as Fi,wn as Ii,wr as Li,xa as Ri,xn as zi,ya as Bi,yi as Vi,yn as Hi,yt as Ui,z as Wi,za as Gi,zi as Ki,zn as qi,zr as Ji,zt as Yi}from"./vendor-enc0q-Va.js";import{n as W,r as Xi}from"./i18n-D06uU1PM.js";import{s as G}from"./monaco-BCqJp2xW.js";import{a as Zi,c as Qi,d as $i,f as ea,h as ta,i as na,l as ra,m as ia,n as aa,o as oa,p as sa,r as ca,s as la,t as ua,u as da}from"./useWebSocket-9lfOsI_r.js";import{t as K}from"./utils-DQ9Exx8j.js";import{a as fa,i as pa,n as q,r as ma,t as ha}from"./ui-store-Dm7ujR9u.js";import{t as J}from"./chat-store-oW_-zcJP.js";import{_ as ga,b as _a,d as va,g as ya,i as ba,m as xa,p as Sa,s as Ca,t as wa,v as Ta,x as Ea,y as Da}from"./stores-C7Vvce-6.js";import{n as Oa,r as ka,t as Aa}from"./mailbox-store-B9DIvRgo.js";import{a as ja,i as Ma,n as Na,o as Pa,r as Fa,t as Ia}from"./view-navigation-wOKaM_Rf.js";import{a as La,i as Ra,n as za,o as Ba,r as Va,t as Ha}from"./dialog-BTHxOi5z.js";import{t as Y}from"./button-DNyYztcH.js";import{t as Ua}from"./input-CTGeYzNe.js";import{i as Wa,n as Ga,o as Ka,r as qa,t as Ja}from"./ConfirmModal-B6BGiiN8.js";import{n as Ya,r as Xa,t as Za}from"./ModelPicker-CLs0qQgg.js";import{d as Qa,p as $a}from"./markdown-Kp5uSgOw.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(ti(),1),eo=e(Yn(),1),to=new Set([`chat`,`settings`,`goal`,`kanban`,`sddhub`,`files`,`changes`,`sessions`,`setup`,`skill`,`roster`,`mailbox`,`debug`,`design-gallery`,`refresh-debug`,`analytics`]),no=new Set([`goal`,`fleet`,`work`,`worktrees`,`collab`]),ro=new Set([`todos`,`tasks`,`plan`]);function io(){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 ao(e){typeof window>`u`||window.wrongstackDesktopHost?.setReady?.(e)}function oo(e,t,n){typeof window>`u`||typeof e!=`string`||window.wrongstackDesktopHost?.ackCommand?.(e,t,n)}var Z=Oi(),so=Dr,co=ir,lo=X.forwardRef(({className:e,inset:t,children:n,...r},i)=>(0,Z.jsxs)(bi,{ref:i,className:K(`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)(ar,{className:`ml-auto h-4 w-4`})]}));lo.displayName=bi.displayName;var uo=X.forwardRef(({className:e,...t},n)=>(0,Z.jsx)(ri,{ref:n,className:K(`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}));uo.displayName=ri.displayName;var fo=X.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,Z.jsx)(Zr,{children:(0,Z.jsx)(Zt,{ref:r,sideOffset:t,className:K(`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})}));fo.displayName=Zt.displayName;var po=X.forwardRef(({className:e,inset:t,...n},r)=>(0,Z.jsx)(Se,{ref:r,className:K(`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}));po.displayName=Se.displayName;var mo=X.forwardRef(({className:e,children:t,checked:n,...r},i)=>(0,Z.jsxs)(zn,{ref:i,className:K(`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)(dr,{children:(0,Z.jsx)(ii,{className:`h-4 w-4`})})}),t]}));mo.displayName=zn.displayName;var ho=X.forwardRef(({className:e,children:t,...n},r)=>(0,Z.jsxs)(gi,{ref:r,className:K(`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)(dr,{children:(0,Z.jsx)(gt,{className:`h-2 w-2 fill-current`})})}),t]}));ho.displayName=gi.displayName;var go=X.forwardRef(({className:e,inset:t,...n},r)=>(0,Z.jsx)(wi,{ref:r,className:K(`px-2 py-1.5 text-sm font-semibold`,t&&`pl-8`,e),...n}));go.displayName=wi.displayName;var _o=X.forwardRef(({className:e,...t},n)=>(0,Z.jsx)(Xn,{ref:n,className:K(`-mx-1 my-1 h-px bg-muted`,e),...t}));_o.displayName=Xn.displayName;var vo=({className:e,...t})=>(0,Z.jsx)(`span`,{className:K(`ml-auto text-xs tracking-widest opacity-60`,e),...t});vo.displayName=`DropdownMenuShortcut`;var yo=[{id:`chat`,icon:(0,Z.jsx)(we,{size:16}),label:`Session`},{id:`files`,icon:(0,Z.jsx)(Te,{size:16}),label:`Files`},{id:`changes`,icon:(0,Z.jsx)(Ji,{size:16}),label:`Changes`},{id:`mailbox`,icon:(0,Z.jsx)(ni,{size:16}),label:`Mailbox`},{id:`skills`,icon:(0,Z.jsx)(Tt,{size:16}),label:`Skills`},{id:`design`,icon:(0,Z.jsx)(Fe,{size:16}),label:`Design Studio`}],bo=[{id:`roster`,icon:(0,Z.jsx)(Pi,{size:16}),label:`Agent Roster`},{id:`sddhub`,icon:(0,Z.jsx)(_r,{size:16}),label:`SDD`},{id:`kanban`,icon:(0,Z.jsx)(Ot,{size:16}),label:`Kanban`},{id:`goal`,icon:(0,Z.jsx)(Ai,{size:16}),label:`Goal`},{id:`codemap`,icon:(0,Z.jsx)(Dn,{size:16}),label:`CodeMap`},{id:`techstack`,icon:(0,Z.jsx)(cn,{size:16}),label:`TechStack`},{id:`chronicle`,icon:(0,Z.jsx)(vr,{size:16}),label:`Chronicle`},{id:`prompts`,icon:(0,Z.jsx)(Vr,{size:16}),label:`Prompt Journal`},{id:`chimera`,icon:(0,Z.jsx)(lr,{size:16}),label:`Chimera Reviews`},{id:`intake`,icon:(0,Z.jsx)(St,{size:16}),label:`Requirements`},{id:`memory`,icon:(0,Z.jsx)(Ri,{size:16}),label:`Memory`}],xo=[`chat`,`files`,`changes`,`mailbox`],So=[...xo,`skills`,`design`],Co=132,wo=38,To=165,Eo=46;function Do(e,t){let n=yo.length+bo.length,r=Number.isFinite(e)?e:720,i=t?Co:To,a=t?wo:Eo,o=Math.floor((r-i)/a);return Math.max(xo.length,Math.min(n,o))}function Oo(e){let t=yo.length+bo.length,n=Math.max(xo.length,Math.min(t,Math.floor(e))),r=Math.min(yo.length,n),i=new Set(So.slice(0,r)),a=yo.map(e=>e.id).filter(e=>i.has(e)),o=yo.map(e=>e.id).filter(e=>!i.has(e)),s=Math.max(0,n-a.length),c=bo.slice(0,s).map(e=>e.id),l=new Set(c);return{visiblePanelIds:a,overflowPanelIds:o,visibleViewIds:c,overflowViewIds:bo.map(e=>e.id).filter(e=>!l.has(e))}}var ko=yo.map(e=>e.id);function Ao(){return typeof window>`u`?720:window.visualViewport?.height??window.innerHeight}function jo(e){let[t,n]=(0,X.useState)(Ao);return(0,X.useEffect)(()=>{if(typeof window>`u`)return;let e=()=>n(Ao());return e(),window.addEventListener(`resize`,e),window.visualViewport?.addEventListener(`resize`,e),()=>{window.removeEventListener(`resize`,e),window.visualViewport?.removeEventListener(`resize`,e)}},[]),Do(t,e)}function Mo({desktopShell:e=!1}){let n=q(e=>e.activeActivity),r=q(e=>e.sidebarOpen),i=q(e=>e.currentView),a=j(e=>e.projectName),o=t(e=>e.wsConnected),{t:s}=U(),c=(e,t)=>s(`activity:nav.${e}`,t),l=ka(Oa),u=z(e=>e.openTabIds.length),d=q(e=>e.inspectorOpen),f=jo(e),p=(0,X.useMemo)(()=>Oo(f),[f]),m=(0,X.useMemo)(()=>new Set(p.visiblePanelIds),[p.visiblePanelIds]),h=(0,X.useMemo)(()=>new Set(p.overflowPanelIds),[p.overflowPanelIds]),g=(0,X.useMemo)(()=>new Set(p.visibleViewIds),[p.visibleViewIds]),_=(0,X.useMemo)(()=>new Set(p.overflowViewIds),[p.overflowViewIds]),v=yo.filter(e=>m.has(e.id)),y=yo.filter(e=>h.has(e.id)),b=bo.filter(e=>g.has(e.id)),x=bo.filter(e=>_.has(e.id)),S=e=>{if(e===`mailbox`)return l||void 0;if(e===`chat`)return u>0?u:void 0};return(0,Z.jsxs)(`div`,{className:K(`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:()=>{Pa(`chat`)},title:a?s(`activity:brand.returnToChat`,{name:a}):s(`activity:brand.returnToChatDefault`),className:K(`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:[v.map(t=>(0,Z.jsx)(Po,{compact:e,icon:t.icon,label:`${c(t.id,t.label)} (${ja(t.id)})`,active:r&&n===t.id,badge:S(t.id),onClick:()=>Ma(t.id)},t.id)),b.length>0&&(0,Z.jsx)(`div`,{className:`my-1.5 h-px w-6 shrink-0 bg-border/70`}),b.map(t=>(0,Z.jsx)(Po,{compact:e,icon:t.icon,label:c(t.id,t.label),active:i===t.id,onClick:()=>Fa(t.id)},t.id))]}),(0,Z.jsx)(`div`,{role:`status`,"aria-label":o?s(`activity:connection.connected`,`Connected`):s(`activity:connection.disconnected`,`Disconnected`),className:`flex items-center justify-center py-1`,children:(0,Z.jsx)(`span`,{className:K(`h-1.5 w-1.5 rounded-full`,o?`bg-success`:`bg-muted-foreground/40`),title:o?s(`activity:connection.connected`,`Connected`):s(`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)(No,{compact:e,monitorOpen:d,overflowPanels:y,overflowViews:x})})]})}function No({compact:e=!1,monitorOpen:t,overflowPanels:n,overflowViews:r}){let{t:i}=U(),a=q(e=>e.activeActivity),o=q(e=>e.sidebarOpen),s=q(e=>e.currentView),c=q(e=>e.inspectorOpen),l=q(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=q.getState();t.inspectorOpen&&t.inspectorTab===e?t.setInspectorOpen(!1):(t.setInspectorTab(e),t.setInspectorOpen(!0))};return(0,Z.jsxs)(so,{children:[(0,Z.jsx)(co,{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:K(`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)(ze,{size:16})}),u>0&&(0,Z.jsx)(`span`,{className:K(`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)(fo,{side:`right`,align:`end`,sideOffset:8,className:`w-56`,children:[(0,Z.jsxs)(po,{onSelect:()=>q.getState().setPaletteOpen(!0),children:[(0,Z.jsx)(dt,{size:16}),(0,Z.jsx)(`span`,{children:i(`activity:menu.commandPalette`)}),(0,Z.jsx)(vo,{children:`⌘K`})]}),(0,Z.jsxs)(po,{onSelect:()=>q.getState().setShortcutsOpen(!0),children:[(0,Z.jsx)(mn,{size:16}),(0,Z.jsx)(`span`,{children:i(`activity:menu.keyboardShortcuts`)}),(0,Z.jsx)(vo,{children:`?`})]}),n.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(_o,{}),(0,Z.jsx)(go,{className:`text-[11px] uppercase text-muted-foreground`,children:i(`activity:menu.panels`)}),n.map(e=>(0,Z.jsxs)(po,{onSelect:()=>Pa(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)(vo,{children:ja(e.id)})]},e.id))]}),r.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(_o,{}),(0,Z.jsx)(go,{className:`text-[11px] uppercase text-muted-foreground`,children:i(`activity:menu.views`)}),r.map(e=>(0,Z.jsxs)(po,{onSelect:()=>Fa(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)(_o,{}),(0,Z.jsx)(go,{className:`text-[11px] uppercase text-muted-foreground`,children:i(`activity:nav.settings`,`Settings`)}),(0,Z.jsxs)(po,{onSelect:()=>Fa(`settings`),children:[(0,Z.jsx)(mi,{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)(Fe,{size:14}),label:`General`,tab:`general`},{icon:(0,Z.jsx)(Dn,{size:14}),label:`Provider`,tab:`provider`},{icon:(0,Z.jsx)(Pi,{size:14}),label:`Agent`,tab:`agent`},{icon:(0,Z.jsx)(cr,{size:14}),label:`Execution`,tab:`execution`},{icon:(0,Z.jsx)(Li,{size:14}),label:`Fallbacks`,tab:`fallbacks`}].map(({icon:e,label:t,tab:n})=>(0,Z.jsxs)(po,{onSelect:()=>{q.getState().setSettingsActiveTab(n),Fa(`settings`)},children:[e,(0,Z.jsx)(`span`,{children:i(`settings:tabs.${n}`,t)})]},n)),(0,Z.jsx)(_o,{}),(0,Z.jsx)(go,{className:`text-[11px] uppercase text-muted-foreground`,children:i(`activity:menu.monitors`)}),(0,Z.jsxs)(po,{onSelect:()=>m(`fleet`),children:[(0,Z.jsx)(Be,{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)(vo,{children:`⇧⌘M`})]}),(0,Z.jsxs)(po,{onSelect:()=>m(`sideEffects`),children:[(0,Z.jsx)(cr,{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 Po({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:K(`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 Fo=[{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}],Io=[`Run`,`Session`,`Inspect`,`Agent`,`Config`,`App`];function Lo(e){let t=e.toLowerCase();return t===`/`||t===``?Fo.filter(e=>!e.hidden):Fo.filter(e=>e.name.startsWith(t)||(e.aliases?.some(e=>e.startsWith(t))??!1))}function Ro(e,t){let n=t-1;for(;n>=0;){let r=d(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 zo(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 Bo(e){let t=Math.max(3,...Array.from(e.matchAll(/`+/g),e=>e[0].length+1));return"`".repeat(t)}function Vo(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function Ho(){let e=J.getState().messages,t=[],n=new Date().toISOString().slice(0,19).replace(/[:T]/g,`-`),r=j.getState().projectName||`chat`,i=j.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=Bo(n.thinkingLog.text),r=n.thinkingLog.text.split(`
3
3
  `).length;t.push(`### 🧠 Thinking process — iteration ${n.thinkingLog.iteration}`),t.push(``),t.push(`_${zo(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 Uo(){let e=J.getState().messages,t=j.getState(),n=t.projectName||`chat`,r=Vo(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(`
@@ -86,7 +86,7 @@ Type while the agent is running to queue messages; they are sent automatically w
86
86
  `).length:0,c=s>0?n(`activity:fileRef.linesCount`,{count:s}):null;return(0,Z.jsxs)(`div`,{title:Td(e),className:K(`inline-flex items-center gap-1.5 max-w-[180px] shrink-0`,`rounded-full border border-border bg-muted/60 pl-2 pr-1 py-0.5`,`text-xs text-foreground hover:bg-muted transition-colors`),children:[(0,Z.jsx)(i,{className:K(`h-3 w-3 shrink-0`,a)}),(0,Z.jsx)(`span`,{className:`truncate font-mono text-[11px]`,children:o}),c&&(0,Z.jsx)(`span`,{className:`text-[9px] text-muted-foreground shrink-0`,children:c}),(0,Z.jsx)(`button`,{type:`button`,onClick:t,className:`inline-flex items-center justify-center h-4 w-4 rounded-full text-muted-foreground hover:bg-background hover:text-foreground transition-colors shrink-0`,title:n(`activity:fileRef.removeTitle`),children:(0,Z.jsx)(mr,{className:`h-3 w-3`})})]})}function Dd(e,t){return e.trim()?e:t}var Od=new Map;y(e=>{Od.delete(e)});function kd({onOpenBreakdown:e}={}){let{isLoading:n,setLoading:r,addMessage:i,clearMessages:a}=J(jn(e=>({isLoading:e.isLoading,setLoading:e.setLoading,addMessage:e.addMessage,clearMessages:e.clearMessages}))),o=J(e=>e.messages),s=S(e=>e.openFiles),c=o.length>0,l=J(e=>e.queue),u=J(e=>e.enqueue),f=J(e=>e.removeQueued),m=J(e=>e.clearQueue),h=q(e=>e.setCurrentView),g=q(e=>e.setPromptLibraryOpen),_=q(e=>e.pushPrompt),v=q(e=>e.promptHistory),y=ua(),{sendMessage:b,sendAbort:x,sendMailboxMessage:C,client:w,refineModel:T,updatePrefs:E,adviseTopic:O}=y,{t:k}=U(),A=W(e=>e.enhanceEnabled),M=j(e=>e.session?.provider),ee=j(e=>e.session?.model),N=t(e=>e.provider),F=t(e=>e.model),I=W(e=>e.refinerProvider),te=W(e=>e.refinerModel),L=W(e=>e.refinerFallbackProfile),R=W(e=>e.fallbackProfiles),z=q(e=>e.refinePanel),ne=t(e=>e.provider),re=t(e=>e.model),ie=q(e=>e.promptInsertRequest),B=q(e=>e.clearPromptInsert),ae=q(e=>e.setRefinePanel),oe=q(e=>e.setProcessMonitorOpen),se=q(e=>e.setQueuePanelOpen),{reset:ce}=D(),[le,ue]=(0,X.useState)(()=>q.getState().draftInput??``),de=(0,X.useRef)(null),{isListening:fe,isSupported:pe,toggleListening:V,stopListening:me}=Cd({onTranscript:e=>{ue(t=>t?`${t} ${e}`:e)}});Sd({clientConnected:w?.isConnected,t:k,sendMessage:b,setInput:ue}),fd({client:w,sendMessage:b});let he=j(e=>e.lastInputTokens),ge=j(e=>e.maxContext),[_e,ve]=(0,X.useState)(0),[ye,be]=(0,X.useState)(-1),xe=(0,X.useRef)(null),[Se,Ce]=(0,X.useState)(null),[we,Te]=(0,X.useState)(!1),[Ee,De]=(0,X.useState)(!1),Oe=(0,X.useRef)(!1),ke=(0,X.useRef)(null),Ae=(0,X.useRef)(null),je=Ta(e=>e.refs),{removeRef:Me,clearRefs:Ne}=Ta.getState(),Pe=je.length>0,{draggingOver:Fe,onDragEnter:Ie,onDragLeave:Le,onDragOver:Re,onDrop:ze,onTextPaste:Be,pasteHint:Ve,pendingImagesRef:He,pendingImages:Ue,addImageFiles:We,removeImage:Ge,clearPendingImages:Ke,setPendingImages:qe,setPasteHint:Ye}=xd({input:le,textareaRef:Ae,setInput:ue,errorText:{tooManyImages:e=>k(`chat:input.tooManyImages`,{max:e}),imageProcessFailed:e=>k(`chat:input.imageProcessFailed`,{name:e}),imageTooLarge:e=>k(`chat:input.imageTooLarge`,{name:e})}}),Xe=(0,X.useRef)(null);(0,X.useEffect)(()=>{q.getState().setDraftInput(le)},[le]),(0,X.useEffect)(()=>()=>{de.current!==null&&clearTimeout(de.current)},[]);let Ze=P(),Qe=(0,X.useRef)(Ze);(0,X.useEffect)(()=>{if(Qe.current===Ze)return;let e=Qe.current;e&&Od.set(e,{input:le,images:[...Ue],refs:[...je]}),Qe.current=Ze;let t=q.getState().refinePanel,n=t?.sessionId??e;if(t&&n!==Ze&&(q.getState().setRefinePanel(null),n)){let e=Od.get(n)??{input:``,images:[],refs:[]};Od.set(n,{...e,input:t.original})}if(Ze&&Od.has(Ze)){let e=Od.get(Ze),t=q.getState().draftInput;ue(e.input.trim()?e.input:t),qe(e.images),Ne();for(let t of e.refs)Ta.getState().addRef(t)}else ue(Ze?q.getState().draftInput:``),Ke(),Ne();be(-1),xe.current=null,Ce(null),Ye(null),me(),ke.current?.abort(),ke.current=null,Oe.current=!1,De(!1),de.current!==null&&(clearTimeout(de.current),de.current=null),Ka.getState().settle(null);let r=Ae.current;r&&(r.style.height=`auto`)},[Ze]),(0,X.useEffect)(()=>{if(!z||A||z.sessionId!==void 0&&z.sessionId!==Ze)return;let e=z;ae(null),w?.isConnected?(i({role:`user`,content:e.original}),r(!0),e.freshContext===!0?b(e.original,void 0,!0):b(e.original)):(ue(e.original),p.error(k(`chat:input.notConnectedDraftKept`)))},[z,A,Ze,ae,w,i,r,b,k]),(0,X.useEffect)(()=>{ie!=null&&(ue(e=>e.trim()?`${e}\n${ie}`:ie),B(),requestAnimationFrame(()=>Ae.current?.focus()))},[ie,B]);let $e=(0,X.useCallback)(()=>{let e=!A;W.getState().set({enhanceEnabled:e}),E({enhanceEnabled:e})},[A,E]),et=(0,X.useCallback)((e,t)=>{let a=t??`queue`;if(n){let t=He.current;J.getState().setPendingRefinement(e,t.length>0?t.map(e=>{let t=e.dataUrl.indexOf(`,`);return{data:t>=0?e.dataUrl.slice(t+1):e.dataUrl,mime:e.mediaType}}):[],a),J.getState().setRefining(!0),T?(T(e,{timeoutMs:15e3}),de.current!==null&&clearTimeout(de.current),de.current=setTimeout(()=>{de.current=null,J.getState().setRefining(!1),J.getState().setPendingRefinement(null)},3e4)):(J.getState().setPendingRefinement(null),J.getState().setRefining(!1),u(e,a,t.length>0?t:void 0));return}i({role:`user`,content:e}),b(e)&&r(!0)},[n,He,T,u,i,b,r]),tt=(0,X.useCallback)(t=>Wo({raw:t,addMessage:i,clearMessages:a,client:w,queue:l,sendAbort:x,sendMsg:et,setLoading:r,setCurrentView:h,toggleRefineEnabled:$e,setProcessMonitorOpen:oe,setQueuePanelOpen:se,ws:y,onOpenBreakdown:e,handleNextList:nd,handleNextSelect:e=>rd(e,et)}),[i,a,w,l,x,et,r,h,$e,oe,se,y,e]),nt=le.startsWith(`/`)&&!le.includes(` `)?Lo(le):[];(0,X.useEffect)(()=>{_e>=nt.length&&ve(0)},[nt.length,_e]);let rt=(0,X.useCallback)(()=>{let e=Ze??j.getState().session?.id;e&&Od.delete(e);let t=Ae.current;t&&(t.value=``,t.style.height=`auto`,t.style.height=`${Math.min(t.scrollHeight,200)}px`,n||t.focus())},[n,Ze]),it=(0,X.useCallback)(async e=>{if(ce(),Oe.current||!le.trim()&&He.current.length===0&&je.length===0)return;let t=le.trim(),a={};for(let e of s)a[e.path]=e.content;let c=[t,ga(je,a)].filter(Boolean).join(`
87
87
 
88
88
  `);if(t.startsWith(`/`)&&tt(c)){Ne(),_(t),ue(``),be(-1),xe.current=null,rt();return}let l=!1,d=o.reduce((e,t)=>e+ +(t.role===`user`),0);if(e===`btw`&&!n&&w?.isConnected&&w.supportsCapability(`context.topic-boundary`)&&d>=5){Oe.current=!0,De(!0);let e=new AbortController;ke.current=e;try{let t=await O(c);if(e.signal.aborted)return;if(t.suggestNewContext){let n=await Wa({title:k(`chat:input.topicShiftTitle`),message:k(`chat:input.topicShiftMessage`,{reason:t.reason,topic:t.nextTopic??k(`chat:input.topicShiftUnnamed`)}),confirmLabel:k(`chat:input.topicShiftFresh`),cancelLabel:k(`chat:input.topicShiftSame`),defaultAction:`cancel`});if(e.signal.aborted||n===`dismiss`)return;l=n===`confirm`}}catch{}finally{Oe.current=!1,De(!1),ke.current===e&&(ke.current=null)}}Ne(),ue(``),be(-1),xe.current=null,rt(),_(t);let f=He.current,m=f.map(e=>({id:e.id,kind:`image`,dataUrl:e.dataUrl,mediaType:e.mediaType,bytes:e.bytes,name:e.name}));if(e===`queue`){u(c,`queue`,f.length>0?f:void 0),Ke();return}let h=e===`steer`&&n;if(e===`btw`&&n){if(f.length>0){u(c,`queue`,f),Ke();return}if(w?.isConnected){let e=!1;try{C({type:`btw`,to:`leader`,subject:`btw from WebUI`,body:c,priority:`normal`,audience:`all`}),e=!0}catch(e){console.warn(JSON.stringify({level:`warn`,event:`ws_btw_send_failed`,reason:`send_error`,error:Hu(e),timestamp:new Date().toISOString()}))}u(c,`btw`,void 0,e)}else console.warn(JSON.stringify({level:`warn`,event:`ws_btw_send_failed`,reason:`not_connected`,timestamp:new Date().toISOString()})),u(c,`btw`);Ke();return}h&&x();try{if(w?.isConnected){if(A&&f.length===0){let e=L?R[L]?.[0]:void 0,t=e?.indexOf(`/`)??-1,n=e?t>0?e.slice(0,t):ne:I||ne,r=e?t>0?e.slice(t+1):e:te||re;ae({original:c,refined:c,english:c,status:`countdown`,resolve:e=>{},provider:n,model:r,...Ze?{sessionId:Ze}:{},...l?{freshContext:!0}:{}})}else{let e=f.length>0?fa(f):void 0,t=l?b(c,e,!0):b(c,e);if(!t){p.error(k(`chat:input.notConnectedDraftKept`));return}i({id:t,role:`user`,content:c,...m.length>0?{attachments:m}:{}}),r(!0),Ke()}}else ue(c),p.error(k(`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:Hu(e),timestamp:new Date().toISOString()})),r(!1)}},[le,je,n,u,w,b,x,C,A,ae,i,r,tt,_,rt,ce,Ke,He,ne,re,k,o,O,Ne,s,R,L,I,te]),at=(0,X.useCallback)(e=>{e.preventDefault(),it(`btw`)},[it]),ot=(0,X.useCallback)(()=>{it(`btw`)},[it]),st=(0,X.useCallback)(()=>{it(`steer`)},[it]),ct=(0,X.useCallback)(()=>{it(`queue`)},[it]),lt=(0,X.useCallback)(()=>{x(),r(!1)},[x,r]),ut=(0,X.useCallback)(()=>{x(),r(!1);let e=J.getState().messages;for(let t=e.length-1;t>=0;t--){let n=d(e[t]);if(n.role===`user`&&n.content){ue(n.content),requestAnimationFrame(()=>{let e=Ae.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,200)}px`,e.focus(),e.setSelectionRange(n.content.length,n.content.length))});return}}},[x,r]),dt=(0,X.useCallback)(e=>{if(!(Se&&e.defaultPrevented)){if(nt.length===0&&!Se&&v.length>0){if(e.key===`ArrowUp`){let t=e.currentTarget,n=t.value.slice(0,t.selectionStart);if(ye>=0||n.indexOf(`
89
- `)===-1){e.preventDefault(),ye===-1&&(xe.current=t.value);let n=Math.min(v.length-1,ye+1);be(n);let r=v[n]??``;ue(r),requestAnimationFrame(()=>{let e=Ae.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,200)}px`,e.setSelectionRange(r.length,r.length))});return}}if(e.key===`ArrowDown`&&ye>=0){e.preventDefault();let t=ye-1;if(t<0){let e=xe.current??``;xe.current=null,be(-1),ue(e),requestAnimationFrame(()=>{let t=Ae.current;t&&(t.style.height=`auto`,t.style.height=`${Math.min(t.scrollHeight,200)}px`,t.setSelectionRange(e.length,e.length))})}else{be(t);let e=v[t]??``;ue(e),requestAnimationFrame(()=>{let t=Ae.current;t&&(t.style.height=`auto`,t.style.height=`${Math.min(t.scrollHeight,200)}px`,t.setSelectionRange(e.length,e.length))})}return}}if(nt.length>0){if(e.key===`ArrowDown`){e.preventDefault(),ve(e=>(e+1)%nt.length);return}if(e.key===`ArrowUp`){e.preventDefault(),ve(e=>(e-1+nt.length)%nt.length);return}if(e.key===`Tab`){e.preventDefault();let t=nt[_e];t&&(ue(t.name+` `),ve(0));return}if(e.key===`Enter`&&!e.shiftKey){let t=nt[_e];if(t&&t.name!==le.toLowerCase().trim()){e.preventDefault(),ue(``),tt(t.name);return}}if(e.key===`Escape`){e.preventDefault(),ue(``);return}}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),at(e))}},[nt,_e,Se,v,ye,le,tt,at]),ft=()=>{let e=Ae.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)(zc,{}),Ve&&(0,Z.jsxs)(`div`,{className:K(`rounded-md border px-2.5 py-1.5 text-xs flex items-center justify-between gap-2 animate-message`,Ve.lang?`border-success/30 bg-success/5 text-success`:`border-warning/30 bg-warning/5 text-warning`),children:[(0,Z.jsx)(`span`,{children:Ve.lang?(0,Z.jsxs)(Z.Fragment,{children:[k(`chat:input.autoFencedAs`),` `,(0,Z.jsx)(`span`,{className:`font-mono font-semibold`,children:Ve.lang}),` — `,(0,Z.jsx)(`span`,{className:`font-mono tabular-nums`,children:Ve.chars.toLocaleString()}),` `,k(`chat:input.charsWord`),` (`,(0,Z.jsx)(`span`,{className:`font-mono tabular-nums`,children:Ve.lines}),` `,k(`chat:input.linesWord`),`)`]}):(0,Z.jsxs)(Z.Fragment,{children:[k(`chat:input.pastedWord`),` `,(0,Z.jsx)(`span`,{className:`font-mono tabular-nums`,children:Ve.chars.toLocaleString()}),` `,k(`chat:input.charsWord`),` (`,(0,Z.jsx)(`span`,{className:`font-mono tabular-nums`,children:Ve.lines}),` `,k(`chat:input.linesWord`),`) `,k(`chat:input.fencedHintPrefix`),` `,(0,Z.jsx)(`span`,{className:`font-mono`,children:"```"}),`.`]})}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[Ve.undoFence&&(0,Z.jsx)(`button`,{type:`button`,onClick:Ve.undoFence,className:`underline underline-offset-2 hover:opacity-80`,title:k(`chat:input.removeFencesTitle`),children:k(`common:action.undo`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>Ye(null),className:`opacity-60 hover:opacity-100 shrink-0`,title:k(`chat:input.dismissTitle`),"aria-label":k(`chat:input.dismissTitle`),children:`×`})]})]}),Ue.length>0&&(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-1`,children:[(0,Z.jsx)(`span`,{className:`text-[10px] uppercase text-muted-foreground shrink-0`,children:k(`chat:input.imagesLabel`)}),Ue.map(e=>(0,Z.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-lg border border-border bg-muted/40 px-1.5 py-1`,title:e.name??k(`chat:input.pendingAttachmentAlt`),children:[(0,Z.jsx)(`img`,{src:e.dataUrl,alt:e.name??k(`chat:input.pendingAttachmentAlt`),className:`h-10 w-10 rounded object-cover border border-border/50`}),(0,Z.jsxs)(`span`,{className:`flex flex-col leading-tight`,children:[(0,Z.jsx)(`span`,{className:`text-[11px] text-foreground/90 max-w-[120px] truncate`,children:e.name??k(`chat:input.imageAttached`)}),(0,Z.jsxs)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[e.width&&e.height?`${e.width}×${e.height} · `:``,Math.max(1,Math.round(e.bytes/1024)),` KB`]})]}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>Ge(e.id),title:k(`chat:input.removeImageTitle`),"aria-label":k(`chat:input.removeImageTitle`),className:`inline-flex items-center justify-center h-5 w-5 rounded text-muted-foreground hover:bg-muted hover:text-foreground transition-colors`,children:`×`})]},e.id)),Ue.length>1&&(0,Z.jsx)(`button`,{type:`button`,onClick:Ke,className:`text-[10px] text-muted-foreground hover:text-foreground underline underline-offset-2 shrink-0`,children:k(`chat:input.clearAll`)})]}),(0,Z.jsx)(ad,{queue:l,onClear:m,onRemove:f}),(0,Z.jsx)(ld,{enhanceEnabled:A,refinePickOpen:we,setRefinePickOpen:Te,refineModel:T,clientConnected:w?.isConnected===!0,addUserMessage:e=>i({role:`user`,content:e}),setLoading:r,sendMessage:b,isLoading:n,enqueue:u,setInput:ue,resolveCancelInput:Dd,notConnectedDraftKept:()=>p.error(k(`chat:input.notConnectedDraftKept`))}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-1`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>g(!0),className:`inline-flex items-center gap-1.5 rounded-lg border border-border/50 bg-card/50 px-2.5 py-1.5 text-xs text-muted-foreground hover:text-foreground hover:border-primary/30 hover:bg-accent/50 transition-all duration-200`,title:k(`chat:input.openPromptLibrary`),children:[(0,Z.jsx)(Je,{className:`h-3.5 w-3.5`}),k(`activity:chatInput.promptLibrary`)]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>q.getState().setModelSwitcherOpen(!0),className:`inline-flex items-center gap-1.5 rounded-lg border border-border/50 bg-card/50 px-2.5 py-1.5 text-xs text-muted-foreground hover:text-foreground hover:border-primary/30 hover:bg-accent/50 transition-all duration-200`,title:k(`chat:header.changeModelTitle`),children:[(0,Z.jsx)(Ar,{className:`h-3.5 w-3.5`}),(0,Z.jsxs)(`span`,{className:`font-mono whitespace-nowrap`,children:[(M??N)||k(`chat:header.noProvider`),` / `,(ee??F)||k(`chat:header.noModel`)]})]}),(0,Z.jsx)(ud,{})]}),Pe&&(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-1`,children:[(0,Z.jsx)(`span`,{className:`text-[10px] uppercase text-muted-foreground shrink-0`,children:k(`chat:input.referencesLabel`)}),je.map(e=>(0,Z.jsx)(Ed,{reference:e,onRemove:()=>Me(e.id)},e.id)),(0,Z.jsx)(`button`,{type:`button`,onClick:Ne,className:`text-[10px] text-muted-foreground hover:text-foreground underline underline-offset-2 shrink-0`,children:k(`chat:input.clearAll`)})]}),Ee&&(0,Z.jsx)(`div`,{className:`px-1 text-xs text-muted-foreground`,role:`status`,children:k(`chat:input.topicShiftChecking`)}),(0,Z.jsxs)(`form`,{onSubmit:at,onDragEnter:Ie,onDragOver:Re,onDragLeave:Le,onDrop:ze,"data-session-id":Ze??void 0,"data-running":n?`true`:`false`,"data-chat-started":c?`true`:`false`,"data-has-draft":le.trim()||Ue.length>0?`true`:`false`,className:K(`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`,n&&`border-warning/45 bg-warning/5 shadow-warning/10`,!c&&!n&&`border-border/50 bg-card/55 shadow-none`,Fe&&`ring-2 ring-primary ring-offset-2 ring-offset-background bg-primary/5`),children:[Fe&&(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:k(`chat:input.dropOverlay`)}),(0,Z.jsxs)(`div`,{className:`relative w-full flex-1`,children:[(0,Z.jsx)(Ju,{atMention:Se,input:le,textareaRef:Ae,setInput:ue,setAtMention:Ce}),!Se&&(0,Z.jsx)(dd,{suggestions:nt,selectedIndex:_e,onSelectIndex:ve,onRun:e=>{ue(``),tt(e)}}),(0,Z.jsx)(`textarea`,{ref:Ae,"data-chat-textarea":!0,value:le,onChange:e=>{let t=e.target.value;ue(t),ft(),ye>=0&&(be(-1),xe.current=null);let n=e.target.selectionStart??t.length;Ce(Ro(t,n))},onSelect:e=>{let t=e.currentTarget;Ce(Ro(t.value,t.selectionStart))},onKeyDown:dt,onPaste:Be,placeholder:w?.isConnected?k(n?`chat:inputPlaceholderLoading`:`chat:inputPlaceholder`):k(`chat:inputPlaceholderConnecting`),className:K(`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:!w?.isConnected||Ee}),(0,Z.jsx)(Ku,{input:le,lastInputTokens:he,maxContext:ge})]}),(0,Z.jsx)(Gu,{imagePickerRef:Xe,disabled:!w?.isConnected||Ee,topicCheckBusy:Ee,clientConnected:w?.isConnected===!0,isLoading:n,chatStarted:c,input:le,pendingImages:Ue,addImageFiles:We,handleStopAndEdit:ut,handleAbort:lt,handleBtw:ot,handleSteer:st,handleAddQueue:ct,updatePrefs:E,t:k,isListening:fe,isSpeechSupported:pe,onToggleSpeech:V})]})]})}function Ad(e){return{index:e.promptIndex,iteration:e.promptIndex,timestamp:e.ts??``,label:e.promptPreview??``,messageCount:0,tokens:0,fileCount:e.fileCount??0}}function jd({open:e,onClose:n,className:r}){let{t:i}=U(),[a,o]=(0,X.useState)([]),[s,c]=(0,X.useState)(!1),l=ua(),u=t(e=>e.wsConnected),d=(0,X.useRef)(null),f=P();(0,X.useEffect)(()=>{if(!(!e||!u||!l.client?.isConnected))return o([]),l.client.send?.({type:`session.checkpoints`,payload:l.client.withSession({})}),d.current=l.client.on?.(`session.checkpoints`,e=>{let t=e?.payload;(t?.sessionId===void 0||f===void 0||t.sessionId===f)&&t?.checkpoints&&o(t.checkpoints.map(Ad))})??null,()=>{d.current?.()}},[e,u,l.client,f]);let p=(0,X.useCallback)(async e=>{c(!0),l.client.send?.({type:`session.rewind`,payload:l.client.withSession({checkpointIndex:e})}),setTimeout(()=>{n(),c(!1)},800)},[l.client,n]);return(0,Z.jsx)(Ha,{open:e,onOpenChange:e=>{e||n()},children:(0,Z.jsxs)(za,{className:K(`max-w-md gap-0 overflow-hidden border-border/80 bg-card p-0 pt-[10dvh] flex flex-col max-h-[75dvh]`,r),children:[(0,Z.jsx)(Ba,{className:`sr-only`,children:i(`activity:checkpoint.heading`)}),(0,Z.jsx)(Va,{className:`sr-only`,children:i(`activity:checkpoint.countSuffix`,{count:a.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)(Un,{className:`h-4 w-4`})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h2`,{className:`text-sm font-semibold`,children:i(`activity:checkpoint.heading`)}),(0,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:i(`activity:checkpoint.countSuffix`,{count:a.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:i(`activity:checkpoint.description`)}),(0,Z.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:a.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)(vn,{className:`h-10 w-10 opacity-15`}),(0,Z.jsx)(`p`,{className:`text-sm font-medium`,children:i(`activity:checkpoint.emptyTitle`)}),(0,Z.jsx)(`p`,{className:`text-xs text-center max-w-xs`,children:i(`activity:checkpoint.emptyBody`)})]}):(0,Z.jsx)(`div`,{className:`py-1`,children:[...a].reverse().map((e,t)=>{let n=t===0;return(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>p(e.index),disabled:s,className:K(`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`,s&&`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:K(`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<a.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:i(`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:i(`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)(Hi,{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:[i(`activity:checkpoint.footerPre`),` ·`,` `,(0,Z.jsx)(`kbd`,{className:`px-1 py-0.5 rounded bg-muted font-mono text-[9px]`,children:`Esc`}),` `,i(`activity:checkpoint.footerPost`)]})]})})}function Md(e){return!!(e?.role===`user`&&Array.isArray(e.content)&&e.content.length>0&&e.content.every(e=>e.type===`tool_result`))}function Nd(e,t){if(e[t]?.role!==`user`||Md(e[t]))return[];let n=[];for(let r=t+1;r<e.length;r+=1){let t=e[r];if(t?.role===`user`&&!Md(t))break;t?.role===`assistant`&&n.push(r)}return n}function Pd(e,t){return e.messageBreakdown.find(e=>e.index===t)?.pairedAssistantIndices??Nd(e.messages,t)}function Fd(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 Pd(e,a))r.add(t)}),r}function Id(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 Ld(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 Rd(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 zd={phase:`closed`,revision:null,messages:[],readonlyContext:null,messageBreakdown:[],diagnostics:null,removeMessages:new Set,explicitRemoveMessages:new Set,removeRanges:[],validation:null,appliedResult:null,errorMessage:null},Bd=Qt((e,t)=>({...zd,open:()=>e({...zd,phase:`loading_snapshot`,removeMessages:new Set,explicitRemoveMessages:new Set}),close:()=>e({...zd}),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))&&Pd(r,t).includes(n))&&r.removeMessages.has(n))return;i.has(n)?i.delete(n):i.add(n);let a=r.removeRanges,o=Fd(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||Ld(a,n.start)||Ld(a,n.end))return;let o=Id([...r.removeRanges,n]);e({removeMessages:Fd(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)))Rd(n,t);return n.filter((t,n)=>!e.removeMessages.has(n))}}));function Vd(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Hd(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 Ud(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 Wd({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(Hd(e))},[r]);return(0,X.useEffect)(()=>{o(null)},[e]),(0,Z.jsxs)(`div`,{className:K(`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 Gd({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:K(`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)(Lt,{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)(fr,{className:`h-3 w-3`}):(0,Z.jsx)(ar,{className:`h-3 w-3`})}),(0,Z.jsx)(`span`,{className:K(`font-mono font-medium`,p),children:t}),(0,Z.jsxs)(`span`,{className:`text-muted-foreground/60 tabular-nums`,children:[Vd(n),` tok`]}),i!==null&&i>0&&(0,Z.jsxs)(`span`,{className:`text-muted-foreground/50 tabular-nums`,children:[i,` blk`]}),m&&(0,Z.jsx)(Rr,{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)(Wd,{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:[Vd(Math.ceil(t.text.length/4)),` tok`]})]}),t.type===`text`&&typeof t.text==`string`?(0,Z.jsx)(Wd,{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:Ud(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:K(`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 Kd=5e3;function qd(e){if(!e||typeof e!=`object`)return;let t=e.sessionId;return typeof t==`string`&&t.length>0?t:void 0}function Jd(e,t){let n=qd(e);return!t||!n||n===t}function Yd({open:e,onClose:t}){let{t:n}=U(),r=Bd(e=>e.phase),i=Bd(e=>e.revision),a=Bd(e=>e.messageBreakdown),o=Bd(e=>e.readonlyContext),s=Bd(e=>e.messages),c=Bd(e=>e.removeMessages),l=Bd(e=>e.removeRanges),u=Bd(e=>e.validation),d=Bd(e=>e.appliedResult),f=Bd(e=>e.errorMessage),p=Bd,m=J(e=>e.isLoading),h=j(e=>e.contextLimitWarning),g=P();(0,X.useEffect)(()=>{if(!e){p.getState().close();return}p.getState().open();let t=V();if(!t?.send||!t.on){p.getState().setError(H.t(`activity:context.wsNotConnected`));return}let n=t.withSession({}).sessionId??g??re()??void 0,r=()=>{t.send({type:`context.editor.open`,payload:t.withSession({})})},i=e=>{if(e.type!==`context.editor.snapshot`||!Jd(e.payload,n))return;let t=e.payload;!t||typeof t.revision!=`string`||!Array.isArray(t.messages)||p.getState().loadSnapshot(t)},a=e=>{if(e.type!==`context.editor.validation`||!Jd(e.payload,n))return;let t=e.payload;p.getState().setValidation(t)},o=e=>{if(e.type!==`context.editor.applied`||!Jd(e.payload,n))return;let i=e.payload;p.getState().setApplied(i),typeof t.openContextEditor==`function`?t.openContextEditor():r()},s=t.on(`context.editor.snapshot`,i),c=t.on(`context.editor.validation`,a),l=t.on(`context.editor.applied`,o);r();let u=setTimeout(()=>{p.getState().phase===`loading_snapshot`&&p.getState().setError(H.t(`activity:ctxEditor.snapshotTimedOut`))},Kd);return()=>{clearTimeout(u),s?.(),c?.(),l?.(),t.off?.(`context.editor.snapshot`,i),t.off?.(`context.editor.validation`,a),t.off?.(`context.editor.applied`,o)}},[e,p,g]),(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 _=(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]),v=(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 y=r===`applying`||r===`validating`,b=c.size>0||l.length>0,x=r===`validated`&&!m,S=b&&!y&&!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)(_r,{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:y,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)(mr,{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)(Rr,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,Z.jsx)(`span`,{children:n(`activity:ctxEditor.providerLimitDecreased`,{previous:Vd(h.previousMaxContext),current:Vd(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:Vd(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:Vd(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:Vd(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:Vd(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)(pr,{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)(wr,{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)(Cr,{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 `,Vd(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)(Rr,{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)(Gd,{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:y,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)(cr,{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:[b&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Lt,{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)(vn,{className:`h-3 w-3`}),n(`activity:ctxEditor.agentRunningApplyDisabled`)]})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[b&&(0,Z.jsx)(`button`,{type:`button`,onClick:()=>p.getState().clearRemovals(),className:`text-[11px] text-muted-foreground hover:text-foreground transition-colors`,disabled:y,children:n(`activity:ctxEditor.clear`)}),(0,Z.jsxs)(`button`,{type:`button`,onClick:_,disabled:!S,className:K(`flex items-center gap-1.5 rounded-md px-3 py-1.5 text-[11px] font-medium transition-colors`,S?`bg-secondary text-secondary-foreground hover:bg-secondary/80`:`bg-muted text-muted-foreground/40 cursor-not-allowed`),children:[r===`validating`?(0,Z.jsx)(pr,{className:`h-3 w-3 animate-spin`}):(0,Z.jsx)(wr,{className:`h-3 w-3`}),`Validate`]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:v,disabled:!x,className:K(`flex items-center gap-1.5 rounded-md px-3 py-1.5 text-[11px] font-medium transition-colors`,x?`bg-primary text-primary-foreground hover:bg-primary/90`:`bg-muted text-muted-foreground/40 cursor-not-allowed`),children:[r===`applying`?(0,Z.jsx)(pr,{className:`h-3 w-3 animate-spin`}):(0,Z.jsx)(Cr,{className:`h-3 w-3`}),`Apply Changes`]})]})]})]})})}var Xd=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`];function Zd(e){let t=/^(\d{2}):(\d{2})$/.exec(e);if(!t)return;let n=Number(t[1]),r=Number(t[2]);return n<=23&&r<=59?n*60+r:void 0}function Qd(e,t=new Date){if(e.enabled===!1)return!1;let n=Zd(e.start),r=Zd(e.end);if(n===void 0||r===void 0)return!1;try{let i=new Intl.DateTimeFormat(`en-US`,{timeZone:e.timezone,weekday:`short`,hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}).formatToParts(t),a=Xd.indexOf(i.find(e=>e.type===`weekday`)?.value??``),o=Number(i.find(e=>e.type===`hour`)?.value),s=Number(i.find(e=>e.type===`minute`)?.value);if(a<0||!Number.isFinite(o+s))return!1;let c=o*60+s,l=e.days?.length?new Set(e.days):void 0;return n===r?!l||l.has(a):n<r?(!l||l.has(a))&&c>=n&&c<r:c>=n?!l||l.has(a):c<r&&(!l||l.has((a+6)%7))}catch{return!1}}function $d(e){if(Zd(e.start)===void 0||Zd(e.end)===void 0)return!1;try{return new Intl.DateTimeFormat(`en-US`,{timeZone:e.timezone}).format(new Date),!0}catch{return!1}}function ef(e){return`${e.provider??`*`}/${e.model??`*`}`}function tf(e,t=new Date){let n=new Map;for(let t of e){if(t.enabled===!1||!$d(t))continue;let e=ef(t);n.set(e,[...n.get(e)??[],t])}let r=[];for(let e of n.values()){let n=e.find(e=>e.mode!==`allow_only`&&Qd(e,t));if(n){r.push(n);continue}let i=e.filter(e=>e.mode===`allow_only`);i.length>0&&!i.some(e=>Qd(e,t))&&r.push(i[0])}return r}function nf(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 rf(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 af=/Sibling quarantine:.*?\bon\s+([^\s/]+\/\S+)/;function of(e){return af.exec(e.lastErrorMessage??``)?.[1]??null}function sf(){let{t:e}=U(),t=Ca(e=>e.entries);Ca(e=>e.summary);let n=Ca(e=>e.removeEntry),r=Ca(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)(()=>tf(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)(Rr,{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)(zi,{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=of(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)(En,{className:`h-3.5 w-3.5 text-warning`}):(0,Z.jsx)(Cr,{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:nf(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:rf(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:rf(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)(gr,{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)(Lt,{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)(En,{className:`h-3.5 w-3.5 text-info`}),(0,Z.jsx)(`code`,{className:`text-foreground`,children:ef(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)(En,{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:rf(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 cf=`
89
+ `)===-1){e.preventDefault(),ye===-1&&(xe.current=t.value);let n=Math.min(v.length-1,ye+1);be(n);let r=v[n]??``;ue(r),requestAnimationFrame(()=>{let e=Ae.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,200)}px`,e.setSelectionRange(r.length,r.length))});return}}if(e.key===`ArrowDown`&&ye>=0){e.preventDefault();let t=ye-1;if(t<0){let e=xe.current??``;xe.current=null,be(-1),ue(e),requestAnimationFrame(()=>{let t=Ae.current;t&&(t.style.height=`auto`,t.style.height=`${Math.min(t.scrollHeight,200)}px`,t.setSelectionRange(e.length,e.length))})}else{be(t);let e=v[t]??``;ue(e),requestAnimationFrame(()=>{let t=Ae.current;t&&(t.style.height=`auto`,t.style.height=`${Math.min(t.scrollHeight,200)}px`,t.setSelectionRange(e.length,e.length))})}return}}if(nt.length>0){if(e.key===`ArrowDown`){e.preventDefault(),ve(e=>(e+1)%nt.length);return}if(e.key===`ArrowUp`){e.preventDefault(),ve(e=>(e-1+nt.length)%nt.length);return}if(e.key===`Tab`){e.preventDefault();let t=nt[_e];t&&(ue(t.name+` `),ve(0));return}if(e.key===`Enter`&&!e.shiftKey){let t=nt[_e];if(t&&t.name!==le.toLowerCase().trim()){e.preventDefault(),ue(``),tt(t.name);return}}if(e.key===`Escape`){e.preventDefault(),ue(``);return}}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),at(e))}},[nt,_e,Se,v,ye,le,tt,at]),ft=()=>{let e=Ae.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)(zc,{}),Ve&&(0,Z.jsxs)(`div`,{className:K(`rounded-md border px-2.5 py-1.5 text-xs flex items-center justify-between gap-2 animate-message`,Ve.lang?`border-success/30 bg-success/5 text-success`:`border-warning/30 bg-warning/5 text-warning`),children:[(0,Z.jsx)(`span`,{children:Ve.lang?(0,Z.jsxs)(Z.Fragment,{children:[k(`chat:input.autoFencedAs`),` `,(0,Z.jsx)(`span`,{className:`font-mono font-semibold`,children:Ve.lang}),` — `,(0,Z.jsx)(`span`,{className:`font-mono tabular-nums`,children:Ve.chars.toLocaleString()}),` `,k(`chat:input.charsWord`),` (`,(0,Z.jsx)(`span`,{className:`font-mono tabular-nums`,children:Ve.lines}),` `,k(`chat:input.linesWord`),`)`]}):(0,Z.jsxs)(Z.Fragment,{children:[k(`chat:input.pastedWord`),` `,(0,Z.jsx)(`span`,{className:`font-mono tabular-nums`,children:Ve.chars.toLocaleString()}),` `,k(`chat:input.charsWord`),` (`,(0,Z.jsx)(`span`,{className:`font-mono tabular-nums`,children:Ve.lines}),` `,k(`chat:input.linesWord`),`) `,k(`chat:input.fencedHintPrefix`),` `,(0,Z.jsx)(`span`,{className:`font-mono`,children:"```"}),`.`]})}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[Ve.undoFence&&(0,Z.jsx)(`button`,{type:`button`,onClick:Ve.undoFence,className:`underline underline-offset-2 hover:opacity-80`,title:k(`chat:input.removeFencesTitle`),children:k(`common:action.undo`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>Ye(null),className:`opacity-60 hover:opacity-100 shrink-0`,title:k(`chat:input.dismissTitle`),"aria-label":k(`chat:input.dismissTitle`),children:`×`})]})]}),Ue.length>0&&(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-1`,children:[(0,Z.jsx)(`span`,{className:`text-[10px] uppercase text-muted-foreground shrink-0`,children:k(`chat:input.imagesLabel`)}),Ue.map(e=>(0,Z.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-lg border border-border bg-muted/40 px-1.5 py-1`,title:e.name??k(`chat:input.pendingAttachmentAlt`),children:[(0,Z.jsx)(`img`,{src:e.dataUrl,alt:e.name??k(`chat:input.pendingAttachmentAlt`),className:`h-10 w-10 rounded object-cover border border-border/50`}),(0,Z.jsxs)(`span`,{className:`flex flex-col leading-tight`,children:[(0,Z.jsx)(`span`,{className:`text-[11px] text-foreground/90 max-w-[120px] truncate`,children:e.name??k(`chat:input.imageAttached`)}),(0,Z.jsxs)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[e.width&&e.height?`${e.width}×${e.height} · `:``,Math.max(1,Math.round(e.bytes/1024)),` KB`]})]}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>Ge(e.id),title:k(`chat:input.removeImageTitle`),"aria-label":k(`chat:input.removeImageTitle`),className:`inline-flex items-center justify-center h-5 w-5 rounded text-muted-foreground hover:bg-muted hover:text-foreground transition-colors`,children:`×`})]},e.id)),Ue.length>1&&(0,Z.jsx)(`button`,{type:`button`,onClick:Ke,className:`text-[10px] text-muted-foreground hover:text-foreground underline underline-offset-2 shrink-0`,children:k(`chat:input.clearAll`)})]}),(0,Z.jsx)(ad,{queue:l,onClear:m,onRemove:f}),(0,Z.jsx)(ld,{enhanceEnabled:A,refinePickOpen:we,setRefinePickOpen:Te,refineModel:T,clientConnected:w?.isConnected===!0,addUserMessage:e=>i({role:`user`,content:e}),setLoading:r,sendMessage:b,isLoading:n,enqueue:u,setInput:ue,resolveCancelInput:Dd,notConnectedDraftKept:()=>p.error(k(`chat:input.notConnectedDraftKept`))}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-1`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>g(!0),className:`inline-flex items-center gap-1.5 rounded-lg border border-border/50 bg-card/50 px-2.5 py-1.5 text-xs text-muted-foreground hover:text-foreground hover:border-primary/30 hover:bg-accent/50 transition-all duration-200`,title:k(`chat:input.openPromptLibrary`),children:[(0,Z.jsx)(Je,{className:`h-3.5 w-3.5`}),k(`activity:chatInput.promptLibrary`)]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>q.getState().setModelSwitcherOpen(!0),className:`inline-flex items-center gap-1.5 rounded-lg border border-border/50 bg-card/50 px-2.5 py-1.5 text-xs text-muted-foreground hover:text-foreground hover:border-primary/30 hover:bg-accent/50 transition-all duration-200`,title:k(`chat:header.changeModelTitle`),children:[(0,Z.jsx)(Ar,{className:`h-3.5 w-3.5`}),(0,Z.jsxs)(`span`,{className:`font-mono whitespace-nowrap`,children:[(M??N)||k(`chat:header.noProvider`),` / `,(ee??F)||k(`chat:header.noModel`)]})]}),(0,Z.jsx)(ud,{})]}),Pe&&(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-1`,children:[(0,Z.jsx)(`span`,{className:`text-[10px] uppercase text-muted-foreground shrink-0`,children:k(`chat:input.referencesLabel`)}),je.map(e=>(0,Z.jsx)(Ed,{reference:e,onRemove:()=>Me(e.id)},e.id)),(0,Z.jsx)(`button`,{type:`button`,onClick:Ne,className:`text-[10px] text-muted-foreground hover:text-foreground underline underline-offset-2 shrink-0`,children:k(`chat:input.clearAll`)})]}),Ee&&(0,Z.jsx)(`div`,{className:`px-1 text-xs text-muted-foreground`,role:`status`,children:k(`chat:input.topicShiftChecking`)}),(0,Z.jsxs)(`form`,{onSubmit:at,onDragEnter:Ie,onDragOver:Re,onDragLeave:Le,onDrop:ze,"data-session-id":Ze??void 0,"data-running":n?`true`:`false`,"data-chat-started":c?`true`:`false`,"data-has-draft":le.trim()||Ue.length>0?`true`:`false`,className:K(`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`,n&&`border-warning/45 bg-warning/5 shadow-warning/10`,!c&&!n&&`border-border/50 bg-card/55 shadow-none`,Fe&&`ring-2 ring-primary ring-offset-2 ring-offset-background bg-primary/5`),children:[Fe&&(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:k(`chat:input.dropOverlay`)}),(0,Z.jsxs)(`div`,{className:`relative w-full flex-1`,children:[(0,Z.jsx)(Ju,{atMention:Se,input:le,textareaRef:Ae,setInput:ue,setAtMention:Ce}),!Se&&(0,Z.jsx)(dd,{suggestions:nt,selectedIndex:_e,onSelectIndex:ve,onRun:e=>{ue(``),tt(e)}}),(0,Z.jsx)(`textarea`,{ref:Ae,"data-chat-textarea":!0,value:le,onChange:e=>{let t=e.target.value;ue(t),ft(),ye>=0&&(be(-1),xe.current=null);let n=e.target.selectionStart??t.length;Ce(Ro(t,n))},onSelect:e=>{let t=e.currentTarget;Ce(Ro(t.value,t.selectionStart))},onKeyDown:dt,onPaste:Be,placeholder:w?.isConnected?k(n?`chat:inputPlaceholderLoading`:`chat:inputPlaceholder`):k(`chat:inputPlaceholderConnecting`),className:K(`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:!w?.isConnected||Ee}),(0,Z.jsx)(Ku,{input:le,lastInputTokens:he,maxContext:ge})]}),(0,Z.jsx)(Gu,{imagePickerRef:Xe,disabled:!w?.isConnected||Ee,topicCheckBusy:Ee,clientConnected:w?.isConnected===!0,isLoading:n,chatStarted:c,input:le,pendingImages:Ue,addImageFiles:We,handleStopAndEdit:ut,handleAbort:lt,handleBtw:ot,handleSteer:st,handleAddQueue:ct,updatePrefs:E,t:k,isListening:fe,isSpeechSupported:pe,onToggleSpeech:V})]})]})}function Ad(e){return{index:e.promptIndex,iteration:e.promptIndex,timestamp:e.ts??``,label:e.promptPreview??``,messageCount:0,tokens:0,fileCount:e.fileCount??0}}function jd({open:e,onClose:n,className:r}){let{t:i}=U(),[a,o]=(0,X.useState)([]),[s,c]=(0,X.useState)(!1),l=ua(),u=t(e=>e.wsConnected),d=(0,X.useRef)(null),f=P();(0,X.useEffect)(()=>{if(!(!e||!u||!l.client?.isConnected))return o([]),l.client.send?.({type:`session.checkpoints`,payload:l.client.withSession({})}),d.current=l.client.on?.(`session.checkpoints`,e=>{let t=e?.payload;(t?.sessionId===void 0||f===void 0||t.sessionId===f)&&t?.checkpoints&&o(t.checkpoints.map(Ad))})??null,()=>{d.current?.()}},[e,u,l.client,f]);let p=(0,X.useCallback)(async e=>{c(!0),l.client.send?.({type:`session.rewind`,payload:l.client.withSession({checkpointIndex:e})}),setTimeout(()=>{n(),c(!1)},800)},[l.client,n]);return(0,Z.jsx)(Ha,{open:e,onOpenChange:e=>{e||n()},children:(0,Z.jsxs)(za,{className:K(`max-w-md gap-0 overflow-hidden border-border/80 bg-card p-0 pt-[10dvh] flex flex-col max-h-[75dvh]`,r),children:[(0,Z.jsx)(Ba,{className:`sr-only`,children:i(`activity:checkpoint.heading`)}),(0,Z.jsx)(Va,{className:`sr-only`,children:i(`activity:checkpoint.countSuffix`,{count:a.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)(Un,{className:`h-4 w-4`})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h2`,{className:`text-sm font-semibold`,children:i(`activity:checkpoint.heading`)}),(0,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:i(`activity:checkpoint.countSuffix`,{count:a.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:i(`activity:checkpoint.description`)}),(0,Z.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:a.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)(vn,{className:`h-10 w-10 opacity-15`}),(0,Z.jsx)(`p`,{className:`text-sm font-medium`,children:i(`activity:checkpoint.emptyTitle`)}),(0,Z.jsx)(`p`,{className:`text-xs text-center max-w-xs`,children:i(`activity:checkpoint.emptyBody`)})]}):(0,Z.jsx)(`div`,{className:`py-1`,children:[...a].reverse().map((e,t)=>{let n=t===0;return(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>p(e.index),disabled:s,className:K(`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`,s&&`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:K(`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<a.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:i(`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:i(`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)(Hi,{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:[i(`activity:checkpoint.footerPre`),` ·`,` `,(0,Z.jsx)(`kbd`,{className:`px-1 py-0.5 rounded bg-muted font-mono text-[9px]`,children:`Esc`}),` `,i(`activity:checkpoint.footerPost`)]})]})})}function Md(e){return!!(e?.role===`user`&&Array.isArray(e.content)&&e.content.length>0&&e.content.every(e=>e.type===`tool_result`))}function Nd(e,t){if(e[t]?.role!==`user`||Md(e[t]))return[];let n=[];for(let r=t+1;r<e.length;r+=1){let t=e[r];if(t?.role===`user`&&!Md(t))break;t?.role===`assistant`&&n.push(r)}return n}function Pd(e,t){return e.messageBreakdown.find(e=>e.index===t)?.pairedAssistantIndices??Nd(e.messages,t)}function Fd(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 Pd(e,a))r.add(t)}),r}function Id(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 Ld(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 Rd(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 zd={phase:`closed`,revision:null,messages:[],readonlyContext:null,messageBreakdown:[],diagnostics:null,removeMessages:new Set,explicitRemoveMessages:new Set,removeRanges:[],validation:null,appliedResult:null,errorMessage:null},Bd=Qt((e,t)=>({...zd,open:()=>e({...zd,phase:`loading_snapshot`,removeMessages:new Set,explicitRemoveMessages:new Set}),close:()=>e({...zd}),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))&&Pd(r,t).includes(n))&&r.removeMessages.has(n))return;i.has(n)?i.delete(n):i.add(n);let a=r.removeRanges,o=Fd(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||Ld(a,n.start)||Ld(a,n.end))return;let o=Id([...r.removeRanges,n]);e({removeMessages:Fd(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)))Rd(n,t);return n.filter((t,n)=>!e.removeMessages.has(n))}}));function Vd(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Hd(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 Ud(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 Wd({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(Hd(e))},[r]);return(0,X.useEffect)(()=>{o(null)},[e]),(0,Z.jsxs)(`div`,{className:K(`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 Gd({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:K(`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)(Lt,{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)(fr,{className:`h-3 w-3`}):(0,Z.jsx)(ar,{className:`h-3 w-3`})}),(0,Z.jsx)(`span`,{className:K(`font-mono font-medium`,p),children:t}),(0,Z.jsxs)(`span`,{className:`text-muted-foreground/60 tabular-nums`,children:[Vd(n),` tok`]}),i!==null&&i>0&&(0,Z.jsxs)(`span`,{className:`text-muted-foreground/50 tabular-nums`,children:[i,` blk`]}),m&&(0,Z.jsx)(Rr,{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)(Wd,{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:[Vd(Math.ceil(t.text.length/4)),` tok`]})]}),t.type===`text`&&typeof t.text==`string`?(0,Z.jsx)(Wd,{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:Ud(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:K(`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 Kd=5e3;function qd(e){if(!e||typeof e!=`object`)return;let t=e.sessionId;return typeof t==`string`&&t.length>0?t:void 0}function Jd(e,t){let n=qd(e);return!t||!n||n===t}function Yd({open:e,onClose:t}){let{t:n}=U(),r=Bd(e=>e.phase),i=Bd(e=>e.revision),a=Bd(e=>e.messageBreakdown),o=Bd(e=>e.readonlyContext),s=Bd(e=>e.messages),c=Bd(e=>e.removeMessages),l=Bd(e=>e.removeRanges),u=Bd(e=>e.validation),d=Bd(e=>e.appliedResult),f=Bd(e=>e.errorMessage),p=Bd,m=J(e=>e.isLoading),h=j(e=>e.contextLimitWarning),g=P();(0,X.useEffect)(()=>{if(!e){p.getState().close();return}p.getState().open();let t=V();if(!t?.send||!t.on){p.getState().setError(H.t(`activity:context.wsNotConnected`));return}let n=t.withSession({}).sessionId??g??re()??void 0,r=()=>{t.send({type:`context.editor.open`,payload:t.withSession({})})},i=e=>{if(e.type!==`context.editor.snapshot`||!Jd(e.payload,n))return;let t=e.payload;!t||typeof t.revision!=`string`||!Array.isArray(t.messages)||p.getState().loadSnapshot(t)},a=e=>{if(e.type!==`context.editor.validation`||!Jd(e.payload,n))return;let t=e.payload;p.getState().setValidation(t)},o=e=>{if(e.type!==`context.editor.applied`||!Jd(e.payload,n))return;let i=e.payload;p.getState().setApplied(i),typeof t.openContextEditor==`function`?t.openContextEditor():r()},s=t.on(`context.editor.snapshot`,i),c=t.on(`context.editor.validation`,a),l=t.on(`context.editor.applied`,o);r();let u=setTimeout(()=>{p.getState().phase===`loading_snapshot`&&p.getState().setError(H.t(`activity:ctxEditor.snapshotTimedOut`))},Kd);return()=>{clearTimeout(u),s?.(),c?.(),l?.(),t.off?.(`context.editor.snapshot`,i),t.off?.(`context.editor.validation`,a),t.off?.(`context.editor.applied`,o)}},[e,p,g]),(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 _=(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]),v=(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 y=r===`applying`||r===`validating`,b=c.size>0||l.length>0,x=r===`validated`&&!m,S=b&&!y&&!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)(_r,{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:y,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)(mr,{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)(Rr,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,Z.jsx)(`span`,{children:n(`activity:ctxEditor.providerLimitDecreased`,{previous:Vd(h.previousMaxContext),current:Vd(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:Vd(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:Vd(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:Vd(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:Vd(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)(pr,{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)(wr,{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)(Cr,{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`,` `,Vd(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)(Rr,{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)(Gd,{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:y,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)(cr,{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:[b&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Lt,{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)(vn,{className:`h-3 w-3`}),n(`activity:ctxEditor.agentRunningApplyDisabled`)]})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[b&&(0,Z.jsx)(`button`,{type:`button`,onClick:()=>p.getState().clearRemovals(),className:`text-[11px] text-muted-foreground hover:text-foreground transition-colors`,disabled:y,children:n(`activity:ctxEditor.clear`)}),(0,Z.jsxs)(`button`,{type:`button`,onClick:_,disabled:!S,className:K(`flex items-center gap-1.5 rounded-md px-3 py-1.5 text-[11px] font-medium transition-colors`,S?`bg-secondary text-secondary-foreground hover:bg-secondary/80`:`bg-muted text-muted-foreground/40 cursor-not-allowed`),children:[r===`validating`?(0,Z.jsx)(pr,{className:`h-3 w-3 animate-spin`}):(0,Z.jsx)(wr,{className:`h-3 w-3`}),`Validate`]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:v,disabled:!x,className:K(`flex items-center gap-1.5 rounded-md px-3 py-1.5 text-[11px] font-medium transition-colors`,x?`bg-primary text-primary-foreground hover:bg-primary/90`:`bg-muted text-muted-foreground/40 cursor-not-allowed`),children:[r===`applying`?(0,Z.jsx)(pr,{className:`h-3 w-3 animate-spin`}):(0,Z.jsx)(Cr,{className:`h-3 w-3`}),`Apply Changes`]})]})]})]})})}var Xd=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`];function Zd(e){let t=/^(\d{2}):(\d{2})$/.exec(e);if(!t)return;let n=Number(t[1]),r=Number(t[2]);return n<=23&&r<=59?n*60+r:void 0}function Qd(e,t=new Date){if(e.enabled===!1)return!1;let n=Zd(e.start),r=Zd(e.end);if(n===void 0||r===void 0)return!1;try{let i=new Intl.DateTimeFormat(`en-US`,{timeZone:e.timezone,weekday:`short`,hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}).formatToParts(t),a=Xd.indexOf(i.find(e=>e.type===`weekday`)?.value??``),o=Number(i.find(e=>e.type===`hour`)?.value),s=Number(i.find(e=>e.type===`minute`)?.value);if(a<0||!Number.isFinite(o+s))return!1;let c=o*60+s,l=e.days?.length?new Set(e.days):void 0;return n===r?!l||l.has(a):n<r?(!l||l.has(a))&&c>=n&&c<r:c>=n?!l||l.has(a):c<r&&(!l||l.has((a+6)%7))}catch{return!1}}function $d(e){if(Zd(e.start)===void 0||Zd(e.end)===void 0)return!1;try{return new Intl.DateTimeFormat(`en-US`,{timeZone:e.timezone}).format(new Date),!0}catch{return!1}}function ef(e){return`${e.provider??`*`}/${e.model??`*`}`}function tf(e,t=new Date){let n=new Map;for(let t of e){if(t.enabled===!1||!$d(t))continue;let e=ef(t);n.set(e,[...n.get(e)??[],t])}let r=[];for(let e of n.values()){let n=e.find(e=>e.mode!==`allow_only`&&Qd(e,t));if(n){r.push(n);continue}let i=e.filter(e=>e.mode===`allow_only`);i.length>0&&!i.some(e=>Qd(e,t))&&r.push(i[0])}return r}function nf(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 rf(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 af=/Sibling quarantine:.*?\bon\s+([^\s/]+\/\S+)/;function of(e){return af.exec(e.lastErrorMessage??``)?.[1]??null}function sf(){let{t:e}=U(),t=Ca(e=>e.entries);Ca(e=>e.summary);let n=Ca(e=>e.removeEntry),r=Ca(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)(()=>tf(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)(Rr,{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)(zi,{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=of(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)(En,{className:`h-3.5 w-3.5 text-warning`}):(0,Z.jsx)(Cr,{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:nf(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:rf(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:rf(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)(gr,{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)(Lt,{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)(En,{className:`h-3.5 w-3.5 text-info`}),(0,Z.jsx)(`code`,{className:`text-foreground`,children:ef(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)(En,{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:rf(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 cf=`
90
90
  ::highlight(chat-search) { background-color: hsl(var(--primary) / 0.3); color: inherit; }
91
91
  ::highlight(chat-search-active) { background-color: hsl(var(--primary) / 0.85); color: hsl(var(--primary-foreground)); }
92
92
  `;function lf(e){return e.thinkingLog?[e.content,e.thinkingLog.text].filter(Boolean).join(`
@@ -141,4 +141,4 @@ Record the baseline, every attempt, and every keep/revert verdict in \`PERF_LOG.
141
141
  `):``),b(n.url??``)):i?(s(i.name),l(i.transport),d(i.description??``),S(!0),w(i.lazy??!1),m(i.command??``),g(i.args?.join(` `)??``),v(i.env?Object.entries(i.env).map(([e,t])=>`${e}=${t}`).join(`
142
142
  `):``),b(i.url??``)):(s(``),l(`stdio`),d(``),S(!0),w(!1),m(``),g(``),v(``),b(``)))},[n,i,e]);let T=()=>{if(!o.trim()){p.error(a(`settings:mcp.serverNameRequired`));return}let e={};if(_.trim())for(let t of _.trim().split(`
143
143
  `)){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:x,command:f.trim()||void 0,args:h.trim()?h.trim().split(/\s+/):void 0,env:Object.keys(e).length>0?e:void 0,url:y.trim()||void 0,lazy:C}),t(!1)},E=!!n,D=!!i;return(0,Z.jsx)(Ha,{open:e,onOpenChange:t,children:(0,Z.jsxs)(za,{children:[(0,Z.jsx)(La,{children:(0,Z.jsx)(Ba,{children:a(E?`settings:mcp.dialogTitleEdit`:D?`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)(Ua,{value:o,onChange:e=>s(e.target.value),placeholder:a(`settings:mcp.fieldNamePlaceholder`),disabled:E||D})]}),(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:D,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)(Ua,{value:y,onChange:e=>b(e.target.value),placeholder:a(`activity:mCPSection.httpsMcpExampleComMcp`),disabled:D})]}),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)(Ua,{value:f,onChange:e=>m(e.target.value),placeholder:a(`settings:mcp.fieldCommandPlaceholder`),disabled:D})]}),(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)(Ua,{value:h,onChange:e=>g(e.target.value),placeholder:a(`settings:mcp.fieldArgsPlaceholder`),disabled:D})]})]}),(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:_,onChange:e=>v(e.target.value),placeholder:`GITHUB_TOKEN=ghp_...
144
- 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)(Ua,{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:x,onChange:e=>S(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:C,onChange:e=>w(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)(Ra,{children:[(0,Z.jsx)(Y,{variant:`outline`,onClick:()=>t(!1),children:a(`common:action.cancel`)}),(0,Z.jsx)(Y,{onClick:T,children:a(E?`settings:mcp.saveChanges`:`settings:mcp.addServer`)})]})]})})}function gh({server:e,isAdded:t,onAdd:n}){let{t:r}=U();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)(Pm,{variant:`secondary`,className:`text-xs shrink-0`,children:e.badge}),(0,Z.jsx)(Pm,{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)(ii,{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)(We,{className:`w-4 h-4 mr-1`}),r(`common:action.add`)]})})]})}function _h(){let e=ua(),{t}=U(),[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,m]=(0,X.useState)(!1),[h,g]=(0,X.useState)(),[_,v]=(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]),p.success(H.t(`settings:mcp.toastAdded`,{name:t.server.name}))}},i=e=>{if(e.type===`mcp.server.removed`){let t=e.payload;r(e=>e.filter(e=>e.name!==t.name)),p.success(H.t(`settings:mcp.toastRemoved`,{name:t.name}))}},o=e=>{if(e.type===`mcp.server.updated`){let t=e.payload;r(e=>e.map(e=>e.name===t.server.name?t.server:e))}},s=e=>{if(e.type===`mcp.server.discovered`){let t=e.payload;r(e=>e.map(e=>e.name===t.name?{...e,status:`sleeping`,tools:t.tools}:e)),v(null),p.success(H.t(`settings:mcp.toastDiscovered`,{count:t.tools.length,name:t.name}))}},c=e=>{if(e.type===`mcp.server.sleeping`){let t=e.payload;r(e=>e.map(e=>e.name===t.name?{...e,status:`sleeping`}:e)),v(null),p.info(H.t(`settings:mcp.toastSleeping`,{name:t.name}))}},l=e=>{if(e.type===`mcp.server.waking`){let t=e.payload;r(e=>e.map(e=>e.name===t.name?{...e,status:`connecting`}:e))}},u=e=>{if(e.type===`mcp.server.connected`){let t=e.payload;r(e=>e.map(e=>e.name===t.name?{...e,status:`connected`,pid:t.pid,error:void 0,lastError:void 0}:e)),v(null),p.success(H.t(`settings:mcp.toastConnected`,{name:t.name}))}},d=e=>{if(e.type===`mcp.server.reconnected`){let t=e.payload;r(e=>e.map(e=>e.name===t.name?{...e,status:`connected`,error:void 0,lastError:void 0}:e)),v(null),p.success(H.t(`settings:mcp.toastReconnected`,{name:t.name}))}},f=e=>{if(e.type===`mcp.server.disconnected`){let t=e.payload;r(e=>e.map(e=>e.name===t.name?{...e,status:`error`,error:t.reason,lastError:t.reason,pid:void 0}:e)),v(null),p.warn(H.t(`settings:mcp.toastDisconnected`,{name:t.name,reason:t.reason}))}},m=e=>{if(e.type===`mcp.server.error`){let t=e.payload;r(e=>e.map(e=>e.name===t.name?{...e,status:`error`,error:t.error}:e)),v(null),p.error(H.t(`settings:mcp.toastError`,{name:t.name,error:t.error}))}},h=e=>{if(e.type===`mcp.operation_result`){let t=e.payload;t.success||p.error(t.message),v(null)}},g=e.client.on(`mcp.list`,t),_=e.client.on(`mcp.server.added`,n),y=e.client.on(`mcp.server.removed`,i),b=e.client.on(`mcp.server.updated`,o),x=e.client.on(`mcp.server.discovered`,s),S=e.client.on(`mcp.server.sleeping`,c),C=e.client.on(`mcp.server.waking`,l),w=e.client.on(`mcp.server.connected`,u),T=e.client.on(`mcp.server.error`,m),E=e.client.on(`mcp.operation_result`,h),D=e.client.on(`mcp.server.reconnected`,d),O=e.client.on(`mcp.server.disconnected`,f);return a(!0),e.client?.listMcpServers(),()=>{g?.(),_?.(),y?.(),b?.(),x?.(),S?.(),C?.(),w?.(),T?.(),E?.(),D?.(),O?.()}},[e.client]);let y=(0,X.useCallback)(t=>{e.client?.addMcpServer(t)},[e]),b=(0,X.useCallback)(e=>{g(dh(e,!1)),m(!0)},[]),x=(0,X.useCallback)(n=>{qa({title:t(`settings:mcp.removeConfirmTitle`,{name:n}),message:t(`settings:mcp.removeConfirmBody`),confirmLabel:t(`common:action.remove`),danger:!0}).then(t=>{t&&e.client?.removeMcpServer(n)})},[e]),S=(0,X.useCallback)(e=>{l(e),g(void 0),d(!0)},[]),C=(0,X.useCallback)(t=>{e.client?.updateMcpServer(t)},[e]),w=(0,X.useCallback)(t=>{v(t),e.client?.wakeMcpServer(t)},[e]),T=(0,X.useCallback)(t=>{v(t),e.client?.sleepMcpServer(t)},[e]),E=(0,X.useCallback)(t=>{v(t),e.client?.discoverMcpServer(t)},[e]),D=(0,X.useCallback)(()=>{a(!0),e.client?.listMcpServers()},[e]),O=n.filter(e=>e.status===`connected`).length,k=n.filter(e=>e.status===`sleeping`).length,A=new Set(n.map(e=>e.name));return(0,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)(Jn,{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:O,sleeping:k,total:n.length})})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsxs)(Y,{variant:`outline`,size:`sm`,onClick:D,disabled:i,children:[i?(0,Z.jsx)(pr,{className:`w-4 h-4 animate-spin`}):null,t(`common:action.refresh`)]}),(0,Z.jsxs)(Y,{size:`sm`,onClick:()=>{g(void 0),m(!0)},children:[(0,Z.jsx)(We,{className:`w-4 h-4 mr-1`}),t(`settings:mcp.addCustom`)]})]})]}),(0,Z.jsxs)(Es,{value:o,onValueChange:e=>s(e),children:[(0,Z.jsxs)(Ds,{children:[(0,Z.jsxs)(Os,{value:`recommended`,children:[(0,Z.jsx)(wn,{className:`w-3.5 h-3.5 mr-1`}),t(`settings:mcp.tabRecommended`)]}),(0,Z.jsx)(Os,{value:`list`,children:t(`settings:mcp.tabServers`)}),(0,Z.jsx)(Os,{value:`add`,children:t(`settings:mcp.tabAddCustom`)})]}),(0,Z.jsxs)(ks,{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:uh.map(e=>(0,Z.jsx)(gh,{server:e,isAdded:A.has(e.name),onAdd:()=>b(e)},e.name))})]}),(0,Z.jsx)(ks,{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)(pr,{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)(Jn,{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)(mh,{server:e,onWake:()=>w(e.name),onSleep:()=>T(e.name),onDiscover:()=>E(e.name),onEdit:()=>S(e),onRemove:()=>x(e.name)},e.name))}),(0,Z.jsx)(ks,{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)(hh,{open:f,onOpenChange:e=>{e||(m(!1),g(void 0))},prefillConfig:h,onSave:y}),(0,Z.jsx)(hh,{open:u,onOpenChange:d,server:c,onSave:C})]})}function vh({syncPref:e}){let{t}=U(),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)(Jn,{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)(Ua,{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)(Jn,{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)(Ua,{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)(Ua,{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)(Jn,{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)(_h,{}):(0,Z.jsxs)(`div`,{className:`text-center py-6 text-muted-foreground`,children:[(0,Z.jsx)(Jn,{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)(ei,{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 yh({syncPref:e}){let{t}=U(),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)(Bi,{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 bh({syncPref:e}){let{t}=U(),n=W(e=>e.reasoningEffort),r=j(e=>e.reasoningEffortLevels),i=qc(r,n).map(e=>({value:e,label:t(Kc(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:Jc(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 xh({provider:e,catalogModels:n,currentCatalogProvider:r,isLoadingModels:i,isSwitching:a,setIsLoadingModels:o,onModelSelect:s,refreshModels:c}){let l=t(e=>e.model),{t:u}=U();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:r?.name||e}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e})]}),(0,Z.jsx)(Y,{variant:`ghost`,size:`sm`,onClick:()=>{o(!0),c(e)},children:(0,Z.jsx)(zi,{className:K(`h-4 w-4`,i&&`animate-spin`)})})]}),i&&!n[e]?(0,Z.jsxs)(`div`,{className:`flex items-center justify-center py-8`,children:[(0,Z.jsx)(pr,{className:`h-6 w-6 animate-spin text-muted-foreground`}),(0,Z.jsx)(`span`,{className:`ml-2 text-muted-foreground`,children:u(`settings:model.loading`)})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(xm,{options:(n[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:l,onSelect:s,disabled:a,emptyMessage:u(`settings:model.notFound`)}),a?(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`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:u(`settings:model.selectProviderFirst`)})]})})}var Sh=[{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.`}],Ch={};function wh({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,Ch),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)(Ki,{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)(mr,{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)(We,{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)(mr,{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)(We,{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:Sh.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:Sh.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 Th(){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 Eh({models:e,onChange:n}){let{t:r}=U(),[i,a]=(0,X.useState)(!1),[o,s]=(0,X.useState)(``),[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.useRef)(void 0),_=(0,X.useRef)(null),v=t(e=>e.wsUrl),y=(0,X.useCallback)(e=>{if(!e.trim()){l([]);return}d(!0);let t=V(v),n=t.on(`provider.models.search_result`,t=>{let n=t.payload;!n||n.query!==e.trim()||(l(n.matches??[]),d(!1))});t.searchProviderModels(e.trim(),8),setTimeout(()=>{n?.(),d(!1)},5e3)},[v]);(0,X.useEffect)(()=>{if(g.current&&clearTimeout(g.current),!o.trim()){l([]);return}return g.current=setTimeout(()=>y(o),250),()=>{g.current&&clearTimeout(g.current)}},[o,y]);let b=(0,X.useCallback)((t,r)=>{if(!t||e.some(e=>e.id===t))return;let i={id:t,name:r?.name??r?.modelId??t,...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}:{}}};n([...e,i]),s(``),l([]),a(!1)},[e,n]),x=(0,X.useCallback)(t=>{n(e.filter(e=>e.id!==t))},[e,n]),S=(0,X.useCallback)(()=>{let e=m.trim();e&&(b(e),h(``),p(!1))},[m,b]);return(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground block`,children:r(`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:K(`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:()=>x(e.id),className:`opacity-0 group-hover:opacity-100 transition-opacity text-muted-foreground hover:text-destructive`,children:(0,Z.jsx)(mr,{className:`h-3 w-3`})})]},e.id))}),i?(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)(vi,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,Z.jsx)(Ua,{placeholder:r(`setup:screen.custom.modelSearchPlaceholder`),value:o,onChange:e=>s(e.target.value),className:`text-sm pl-8`,autoFocus:!0}),u&&(0,Z.jsx)(pr,{className:`absolute right-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 animate-spin text-muted-foreground`})]}),c.length>0&&(0,Z.jsx)(`div`,{className:`space-y-1 max-h-40 overflow-y-auto`,children:c.map(e=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>b(e.modelId,e),className:K(`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)(ii,{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}`))}),!u&&o.trim()&&c.length===0&&(0,Z.jsxs)(`div`,{className:`text-xs text-muted-foreground text-center py-2`,children:[r(`setup:screen.custom.noCatalogMatch`),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{p(!0),setTimeout(()=>_.current?.focus(),50)},className:`ml-1 text-accent underline underline-offset-2 hover:text-accent/80`,children:r(`setup:screen.custom.useCustomId`)})]}),f&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Ua,{ref:_,placeholder:r(`setup:screen.custom.customModelIdPlaceholder`),value:m,onChange:e=>h(e.target.value),className:`text-sm flex-1`,onKeyDown:e=>{e.key===`Enter`&&S()}}),(0,Z.jsxs)(Y,{type:`button`,size:`sm`,onClick:S,disabled:!m.trim(),children:[(0,Z.jsx)(ii,{className:`h-3.5 w-3.5 mr-1`}),r(`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:()=>{a(!1),s(``),l([]),p(!1),h(``)},className:`text-xs`,children:r(`setup:screen.custom.cancel`)})})]}):(0,Z.jsxs)(Y,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>a(!0),className:`text-xs`,children:[(0,Z.jsx)(We,{className:`h-3.5 w-3.5 mr-1`}),r(`setup:screen.custom.addModel`)]}),e.length>0&&(0,Z.jsxs)(`p`,{className:`text-[10px] text-muted-foreground`,children:[e.length,` `,e.length===1?r(`setup:screen.custom.modelSingular`):r(`setup:screen.custom.modelPlural`)]})]})}function Dh({maskedKey:e,className:t}){let{t:n}=U(),[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:K(`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)(ii,{className:`h-3 w-3 text-success`}):(0,Z.jsx)(Bt,{className:`h-3 w-3`})})]})}var Oh={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(Oh);var kh=[{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_...`}}],Ah=[{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`}}],jh=Object.fromEntries([...kh,...Object.values(Oh),...Ah].map(e=>[e.id,e]));function Mh(){return Ah.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 Nh(){return Object.values(jh).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 Ph=`openai-compatible`,Fh=Mh(),Ih=[{kind:`chatgpt`,label:`ChatGPT`,subtitle:`Plus / Pro / Team → openai-codex`,icon:(0,Z.jsx)(Tt,{className:`h-5 w-5`})},{kind:`claude`,label:`Claude`,subtitle:`Pro / Max → anthropic-oauth`,icon:(0,Z.jsx)(Pi,{className:`h-5 w-5`})},{kind:`copilot`,label:`GitHub Copilot`,subtitle:`Copilot → github-copilot`,icon:(0,Z.jsx)(st,{className:`h-5 w-5`})}],Lh=[`awaiting_browser`,`awaiting_code`,`exchanging`,`fetching_models`];function Rh({ws:e,savedByKind:t}){let{t:n}=U(),[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)(``),[m,h]=(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`?(p.success(t.message??H.t(`settings:oauth.signedInToast`,{provider:t.providerId??t.kind})),c(null),o(``),u(null),f(``)):t.phase===`error`&&p.error(t.message??H.t(`settings:oauth.signInFailed`))});return()=>t?.()},[e]);let g=(0,X.useCallback)(t=>{i(e=>({...e,[t]:{phase:t===`copilot`?`awaiting_code`:`awaiting_browser`}})),e.startOAuth(t)},[e]),_=(0,X.useCallback)((t,n)=>{i(e=>({...e,[t]:{phase:t===`copilot`?`awaiting_code`:`awaiting_browser`}})),e.startOAuth(t,n)},[e]),v=(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]),y=(0,X.useCallback)(t=>{e.cancelOAuth(t),i(e=>({...e,[t]:{phase:`idle`}})),c(null)},[e]),b=(0,X.useCallback)(t=>{let n=a.trim();n&&(e.submitOAuthCode(t,n),i(e=>({...e,[t]:{...e[t],phase:`exchanging`}})))},[a,e]),x=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:Ih.map(e=>{let t=r[e.kind],i=Lh.includes(t.phase),p=x[e.kind],S=p?.length??0,C=m===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:()=>y(e.kind),className:`shrink-0 lg:w-full`,children:n(`common:action.cancel`)}):(0,Z.jsx)(Y,{size:`sm`,onClick:()=>g(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)(pr,{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)(Qn,{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)(Ua,{placeholder:n(`activity:oauth.httpLocalhostCallbackCode`),value:a,onChange:e=>o(e.target.value),className:`font-mono text-xs`,onKeyDown:t=>{t.key===`Enter`&&b(e.kind)}}),(0,Z.jsx)(Y,{size:`sm`,onClick:()=>b(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)(Qn,{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)(pr,{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)(pr,{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)(Cr,{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)(Fn,{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:()=>h(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)(dn,{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&&p&&(0,Z.jsxs)(`div`,{className:`mt-2 space-y-1.5`,children:[p.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)(Cr,{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:()=>_(e.kind,t.id),className:`h-6 px-1.5 text-[11px]`,title:n(`settings:oauth.retryLogin`),children:[(0,Z.jsx)(zi,{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)(Ua,{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`&&v(e.kind)}}),(0,Z.jsx)(Y,{size:`sm`,onClick:()=>v(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)(We,{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)(Ua,{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`&&v(e.kind)}}),(0,Z.jsx)(Y,{size:`sm`,onClick:()=>v(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)(We,{className:`h-3.5 w-3.5 mr-1`}),n(`settings:oauth.newAccount`)]})})]},e.kind)})})]})}function zh({open:e,providerId:t,modelCount:n,onConfirm:r,onCancel:i}){let a=(0,X.useRef)(null),{t:o}=U();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)(Ha,{open:e,onOpenChange:e=>{e||i()},children:(0,Z.jsxs)(za,{className:`sm:max-w-md border-warning/50`,ref:a,tabIndex:-1,"data-clear-allowlist-dialog":!0,children:[(0,Z.jsxs)(La,{children:[(0,Z.jsxs)(Ba,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Rr,{className:`h-5 w-5 text-warning`}),o(`settings:allowlist.title`)]}),(0,Z.jsx)(Va,{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)(Ra,{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 Bh({ws:e,onSelect:t,onClose:n}){let{t:r}=U(),[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)(mr,{className:`h-4 w-4`})})]}),(0,Z.jsxs)(`div`,{className:`relative mb-3`,children:[(0,Z.jsx)(vi,{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)(pr,{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 Vh=new Set([`__proto__`,`constructor`,`prototype`,`__defineGetter__`,`__defineSetter__`,`__lookupGetter__`,`__lookupSetter__`]);`document`in globalThis&&Mt({jitless:!0});var Hh=[`text`,`image`,`audio`,`video`,`pdf`],Uh=[`none`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],Wh=Ut().int().nonnegative(),Gh=Ut().finite(),Kh=He({context:Wh.optional(),output:Wh.optional(),input:Wh.optional()}),qh=He({input:Gh.optional(),output:Gh.optional(),cache_read:Gh.optional(),cache_write:Gh.optional(),cache_write_5m:Gh.optional(),cache_write_1h:Gh.optional(),context_over_200k:Gh.optional(),reasoning:Gh.optional(),input_audio:Gh.optional(),output_audio:Gh.optional()}),Jh=He({input:Ni(De().min(1)).optional(),output:Ni(De().min(1)).optional()}),Yh=Or([He({type:qe(`toggle`)}),He({type:qe(`effort`),values:Ni(Re(Uh)).optional()}),He({type:qe(`budget_tokens`),min:Ut().optional(),max:Ut().optional()})]),Xh=e=>({message:`${e} id is a forbidden prototype-pollution key`}),Zh=He({id:De().min(1).refine(e=>!Vh.has(e),Xh(`Model`)),name:De().min(1),description:De().optional(),family:De().optional(),attachment:fn().optional(),reasoning:fn().optional(),reasoning_options:Or([Yh,Ni(Yh)]).optional(),interleaved:Or([fn(),He({field:De().optional()})]).optional(),tool_call:fn().optional(),structured_output:fn().optional(),temperature:fn().optional(),knowledge:De().optional(),release_date:De().optional(),last_updated:De().optional(),open_weights:fn().optional(),modalities:Jh.optional(),cost:qh.optional(),limit:Kh.optional(),status:De().optional(),experimental:fn().optional()}),Qh=He({id:De().min(1).refine(e=>!Vh.has(e),Xh(`Provider`)),name:De().min(1),env:Ni(De()).optional(),npm:De().optional(),api:De().optional(),doc:De().optional(),models:Pr(De(),Zh)});Pr(De(),Qh);function $h(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 eg(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 tg=[{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 ng({providerId:e,modelId:t,initialModelsDev:n,onSave:r,onCancel:i}){let{t:a}=U(),[o,s]=(0,X.useState)(!1),[c,l]=(0,X.useState)(()=>$h(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=eg(c,n),i=Zh.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=Zh.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:K(`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:K(`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:Hh.map(e=>{let t=c.inputModalities.includes(e);return(0,Z.jsx)(`button`,{type:`button`,onClick:()=>_(`inputModalities`,e),className:K(`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:Hh.map(e=>{let t=c.outputModalities.includes(e);return(0,Z.jsx)(`button`,{type:`button`,onClick:()=>_(`outputModalities`,e),className:K(`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:tg.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)(mr,{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)(ii,{className:`h-3.5 w-3.5`}),a(`common:action.save`)]})]})]})}function rg(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 ig(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 ag(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 og(e){let t=e?.modalities;return{input:Array.isArray(t?.input)?t.input:[],output:Array.isArray(t?.output)?t.output:[]}}var sg={text:wr,image:je,audio:Bn,video:Ui,pdf:wr};function cg({providerId:e,models:t,customModels:n,ws:r,pickedModelId:i,onPickModel:a}){let{t:o}=U(),[s,c]=(0,X.useState)(null),[l,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(!1),[m,h]=(0,X.useState)(``),g=(0,X.useMemo)(()=>rg(t,n),[t,n]),_=(0,X.useMemo)(()=>{let e=m.trim().toLowerCase();return e?g.filter(t=>t.modelId.toLowerCase().includes(e)||(t.name?.toLowerCase().includes(e)??!1)):g},[g,m]),v=(0,X.useCallback)(t=>{r.removeCustomModel(e,t),p.success(o(`settings:providerModels.modelRemoved`,{model:t}))},[r,e,o]),y=(0,X.useCallback)((t,n)=>{r.setCustomModel(e,t,{modelsDev:n}),c(null),p.success(o(`settings:providerModels.modelSaved`,{model:t}))},[r,e,o]),b=(0,X.useCallback)((t,n)=>{r.setCustomModel(e,t,{modelsDev:n}),u(!1),p.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)(We,{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)(We,{className:`h-3.5 w-3.5`}),o(`settings:providerModels.addCustom`)]})]}),g.length>0&&(0,Z.jsxs)(`div`,{className:`overflow-hidden rounded-lg border border-border/70`,children:[g.length>8&&(0,Z.jsxs)(`div`,{className:`relative border-b border-border/40 bg-muted/10`,children:[(0,Z.jsx)(vi,{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:m,onChange:e=>h(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:_.map(t=>{let n=ig(t.modelsDev),r=t.maxOutput??t.modelsDev?.limit?.output,l=typeof r==`number`?r.toLocaleString():void 0,u=ag(t.modelsDev),d=og(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)(vn,{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)(Ue,{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=sg[e]??wr;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)(oi,{className:`h-3.5 w-3.5 text-muted-foreground`,"aria-label":o(`activity:modelListEditor.tools`)}),f?.reasoning&&(0,Z.jsx)(Zn,{className:`h-3.5 w-3.5 text-muted-foreground`,"aria-label":o(`activity:modelListEditor.reasoning`)}),f?.vision&&(0,Z.jsx)(ki,{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:K(`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)(ii,{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)(ii,{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)(jr,{className:`h-3.5 w-3.5`})}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>v(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)(Lt,{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)(ng,{providerId:e,modelId:t.modelId,initialModelsDev:t.modelsDev??{},onSave:y,onCancel:()=>c(null)})})},`${t.modelId}-edit`)]},t.modelId)})})]})})]}),g.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)(Bh,{ws:r,onSelect:b,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)(mr,{className:`h-4 w-4`})})]}),(0,Z.jsx)(ng,{providerId:e,modelId:``,initialModelsDev:{},onSave:y,onCancel:()=>f(!1)})]})]})]})}function lg(){return{inFlight:!1,last:null,picked:null}}function ug(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 dg(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 fg(e){return(e?.length??0)>0}function pg(e,t){return`Allowlist cleared for ${e} — ${t} model${t===1?``:`s`} removed`}function mg(e){return e.length>0}function hg(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 gg=3e3;function _g({providerId:e,savedPickedModelId:t,savedModels:n,savedCustomModels:r,ws:i,onPickModel:a,onClearModels:o,onUndoClear:s}){let[c,l]=(0,X.useState)(()=>lg()),{t:u}=U(),[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:ug(t.payload)}))}),[i,e]);let m=(0,X.useCallback)(()=>{l(e=>({...e,inFlight:!0})),i.probeProvider(e,gg)},[i,e]),h=(0,X.useCallback)((e,t)=>{l(e=>({...e,picked:t})),a?.(e,t)},[a]),g=(0,X.useCallback)(()=>{f(!0)},[]),_=(0,X.useCallback)(()=>{f(!1)},[]),v=(0,X.useCallback)(()=>{f(!1);let t=n?[...n]:[];l(e=>({...e,picked:null,last:null})),o?o(e):i.clearProviderModels(e),mg(t)&&p.undoable(pg(e,t.length),()=>{let n=hg({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]),y=(0,X.useMemo)(()=>c.picked??t??n?.[0]??``,[c.picked,t,n]),b=(0,X.useMemo)(()=>dg(c),[c]),x=(0,X.useMemo)(()=>fg(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)(ji,{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`)}),y?(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:y}):(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:m,disabled:c.inFlight,"aria-label":u(`activity:providerModels.refreshAria`,{provider:e}),className:`h-8 px-2 text-xs`,children:[c.inFlight?(0,Z.jsx)(pr,{className:`h-3.5 w-3.5 animate-spin`}):(0,Z.jsx)(zi,{className:`h-3.5 w-3.5`}),c.inFlight?u(`activity:providerModels.probing`):u(`activity:providerModels.refresh`)]}),x&&(0,Z.jsx)(Y,{variant:`ghost`,size:`sm`,onClick:g,"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)(vg,{formatted:b}),(0,Z.jsx)(`div`,{className:`mt-3`,children:(0,Z.jsx)(cg,{providerId:e,models:n??[],customModels:r,ws:i,pickedModelId:y??void 0,onPickModel:h})}),(0,Z.jsx)(zh,{open:d,providerId:e,modelCount:n?.length??0,onConfirm:v,onCancel:_})]})}function vg({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 yg=[`anthropic`,`openai`,`google`,`openai-compatible`];function bg({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:m,ws:h,catalogQuery:g,setCatalogQuery:_}){let{t:v}=U(),[y,b]=(0,X.useState)(null),[x,S]=(0,X.useState)(``),[C,w]=(0,X.useState)(``),[T,E]=(0,X.useState)(!1),[D,O]=(0,X.useState)(!1),[k,A]=(0,X.useState)(``),[j,M]=(0,X.useState)(`openai-compatible`),[ee,N]=(0,X.useState)(``),[P,F]=(0,X.useState)(``),[I,te]=(0,X.useState)([]),L=Th(),R=Th(),z=(0,X.useCallback)(e=>{!x.trim()||!C.trim()||(c(e,x.trim(),C.trim()),S(``),w(``),b(null))},[c,x,C]),ne=(0,X.useCallback)(()=>{k.trim()&&(d(k.trim(),j,ee||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),A(``),M(`openai-compatible`),N(``),F(``),te([]),O(!1))},[d,k,j,ee,P,I]),re=(0,X.useCallback)(e=>{A(e.id),M(Ph),N(e.defaultBaseUrl),e.noAuth&&F(``),te([])},[]),[ie,B]=(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=h.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?.()},[h]);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(``),B(null),ce(!1),p.success(v(`settings:provider.savedToast`,{name:e.name})),e.apiBase&&setTimeout(()=>h.probeProvider(e.id,6e3),700))},[ae,de,c,d,h]),V=g.trim()?t.filter(e=>{let t=g.trim().toLowerCase();return e.id.toLowerCase().includes(t)||e.name.toLowerCase().includes(t)||e.family.toLowerCase().includes(t)}):t,me=V.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)(Ze,{className:`h-4 w-4 text-muted-foreground`}),v(`settings:provider.subscriptionHeading`)]}),(0,Z.jsx)(Rh,{ws:h,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)(At,{className:`h-4 w-4 text-muted-foreground`}),v(`settings:provider.apiKeysHeading`)]}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground mb-3`,children:v(`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)(At,{className:`h-4 w-4 mr-1`}),v(`settings:provider.tabCatalog`)]}),(0,Z.jsxs)(Y,{variant:a===`saved`?`default`:`outline`,size:`sm`,onClick:()=>o(`saved`),children:[(0,Z.jsx)(Ze,{className:`h-4 w-4 mr-1`}),v(`settings:provider.tabSaved`,{count:r.length})]})]}),a===`catalog`&&(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(Ua,{placeholder:v(`settings:provider.searchPlaceholder`,{count:t.length}),value:g,onChange:e=>_(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)(pr,{className:`h-6 w-6 animate-spin text-muted-foreground`}),(0,Z.jsx)(`span`,{className:`ml-2 text-muted-foreground`,children:v(`settings:provider.loadingCatalog`)})]}):V.length===0&&g?(0,Z.jsx)(`div`,{className:`text-center py-8 text-muted-foreground text-sm`,children:v(`settings:provider.noMatch`,{query:g})}):yg.map(t=>{let n=me[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:K(`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:K(`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)(Ze,{className:`h-3 w-3 inline mr-1`}),v(`settings:provider.configured`)]}),n&&(0,Z.jsxs)(`span`,{className:K(`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)(Cr,{className:`h-3 w-3`}):(0,Z.jsx)(Fn,{className:`h-3 w-3`}),n.ok?v(`settings:provider.reachable`):n.status]}),t.envVars[0]&&(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:v(`settings:provider.envVar`,{var:t.envVars[0]})}),r&&(0,Z.jsx)(Cr,{className:`h-4 w-4 text-primary`})]})]}),(0,Z.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[v(`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:ie===t.id?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(Ua,{autoFocus:!0,type:se?`text`:`password`,placeholder:v(`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)(Vi,{className:`h-4 w-4`}):(0,Z.jsx)(ki,{className:`h-4 w-4`})}),(0,Z.jsx)(Y,{size:`sm`,onClick:()=>pe(t),disabled:!ae.trim(),children:v(`common:action.save`)})]}),t.envVars[0]&&(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:v(`settings:provider.orEnv`,{env:t.envVars[0]})})]}):(0,Z.jsxs)(Y,{size:`sm`,variant:`outline`,onClick:()=>{B(t.id),oe(``)},children:[(0,Z.jsx)(Ze,{className:`h-3.5 w-3.5 mr-1`}),v(`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:v(`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)(Jn,{className:`h-3.5 w-3.5`}),v(`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)(Ze,{className:`h-3.5 w-3.5`}),v(`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)(Ee,{className:`h-3.5 w-3.5`}),v(`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`}),v(`settings:provider.modelCount`,{count:fe.models})]})]})]}),(0,Z.jsxs)(Y,{size:`sm`,variant:`outline`,onClick:()=>O(!D),children:[(0,Z.jsx)(We,{className:`h-4 w-4 mr-1`}),v(`settings:provider.addProvider`)]})]}),D&&(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:v(`settings:provider.addCustomHeading`)}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:v(`settings:provider.localServers`)}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:Fh.map(e=>(0,Z.jsx)(Y,{type:`button`,size:`sm`,variant:k===e.id?`default`:`outline`,onClick:()=>re(e),title:e.hint,children:e.label},e.id))})]}),(0,Z.jsx)(Ua,{placeholder:v(`settings:provider.providerIdPlaceholder`),value:k,onChange:e=>A(e.target.value),ref:L.setFieldRef(0),onKeyDown:e=>L.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:j,onChange:e=>M(e.target.value),ref:L.setFieldRef(1),onKeyDown:e=>L.handleKeyDown(e,1),children:[(0,Z.jsx)(`option`,{value:`anthropic`,children:v(`activity:provider.anthropic`)}),(0,Z.jsx)(`option`,{value:`openai`,children:v(`activity:provider.openai`)}),(0,Z.jsx)(`option`,{value:`openai-compatible`,children:v(`activity:provider.openaiCompatible`)}),(0,Z.jsx)(`option`,{value:`google`,children:v(`activity:provider.google`)})]}),(0,Z.jsx)(Ua,{placeholder:v(`activity:provider.baseUrlOptionalEGHttpLocalhost11434V1`),value:ee,onChange:e=>N(e.target.value),ref:L.setFieldRef(2),onKeyDown:e=>L.handleKeyDown(e,2)}),(0,Z.jsx)(Ua,{type:`password`,placeholder:v(`settings:provider.apiKeyOptionalPlaceholder`),value:P,onChange:e=>F(e.target.value),ref:L.setFieldRef(3),onKeyDown:e=>L.handleKeyDown(e,3)}),(0,Z.jsx)(Eh,{models:I,onChange:te}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(Y,{size:`sm`,onClick:ne,disabled:!k.trim(),ref:L.setFieldRef(4),onKeyDown:e=>L.handleKeyDown(e,4,ne),children:v(`common:action.add`)}),(0,Z.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>O(!1),ref:L.setFieldRef(5),onKeyDown:e=>L.handleKeyDown(e,5),children:v(`common:action.cancel`)})]})]}),i?(0,Z.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,Z.jsx)(pr,{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)(Ze,{className:`h-8 w-8 mx-auto mb-2 opacity-50`}),(0,Z.jsx)(`p`,{children:v(`settings:provider.noSaved`)}),(0,Z.jsx)(`p`,{className:`text-sm`,children:v(`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)(Ee,{className:`h-3 w-3`}),v(`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)(At,{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`}),v(`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)(Ze,{className:`h-3.5 w-3.5`}),v(`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)(Lt,{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)(_g,{providerId:e.id,savedPickedModelId:e.pickedModelId,savedModels:e.models,savedCustomModels:e.customModels,ws:h,onPickModel:m}),(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:v(`settings:provider.apiKeysLabel`)}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:v(`settings:provider.keyCount`,{count:e.apiKeys.length})})]}),(0,Z.jsxs)(Y,{size:`sm`,variant:`ghost`,onClick:()=>b(y===e.id?null:e.id),className:`h-8 px-2 text-xs`,children:[(0,Z.jsx)(We,{className:`h-3.5 w-3.5`}),v(`settings:provider.addKey`)]})]}),e.apiKeys.length===0&&!y&&(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:v(`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)(Ze,{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:v(`settings:provider.active`)})]}),(0,Z.jsx)(`div`,{className:`mt-0.5`,children:(0,Z.jsx)(Dh,{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:v(`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)(Lt,{className:`h-3.5 w-3.5 text-destructive`})})]})]},t.label))}),y===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)(Ua,{placeholder:v(`settings:provider.keyLabelPlaceholder`),value:x,onChange:e=>S(e.target.value),ref:R.setFieldRef(0),onKeyDown:e=>R.handleKeyDown(e,0)}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(Ua,{type:T?`text`:`password`,placeholder:v(`settings:provider.apiKeyPlaceholder`),value:C,onChange:e=>w(e.target.value),ref:R.setFieldRef(1),onKeyDown:e=>R.handleKeyDown(e,1)}),(0,Z.jsx)(Y,{size:`icon`,variant:`ghost`,onClick:()=>E(!T),children:T?(0,Z.jsx)(Vi,{className:`h-4 w-4`}):(0,Z.jsx)(ki,{className:`h-4 w-4`})})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(Y,{size:`sm`,onClick:()=>z(e.id),disabled:!x.trim()||!C.trim(),ref:R.setFieldRef(2),onKeyDown:t=>R.handleKeyDown(t,2,()=>z(e.id)),children:v(`settings:provider.saveKey`)}),(0,Z.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>{b(null),S(``),w(``)},ref:R.setFieldRef(3),onKeyDown:e=>R.handleKeyDown(e,3),children:v(`common:action.cancel`)})]})]})]})]})]},e.id))]})]})}var xg=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}))})),Sg=xg.map(e=>e.phase),Cg=xg.flatMap(e=>[...e.roles]),wg=Cg.map(e=>e.role),Tg=[`*`,...Sg,...wg];function Eg(e){if(e===`*`)return`Default (*)`;let t=xg.find(t=>t.phase===e);if(t)return`Phase: ${t.label} (${t.phase})`;let n=Cg.find(t=>t.role===e);return n?`${n.name} (${n.role})`:`Custom: ${e}`}var Dg=[{value:``,label:`mode: inherit`},{value:`auto`,label:`mode: auto`},{value:`on`,label:`mode: on`},{value:`off`,label:`mode: off`}],Og=[{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`}],kg=[{value:``,label:`preserve: inherit`},{value:`on`,label:`preserve: on`},{value:`off`,label:`preserve: off`}],Ag=new Set(Tg);function jg(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 Mg(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 Ng({syncPref:e,candidates:t}){let n=W(),{t:r}=U(),[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=jg(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}`:``,...Mg(n)].filter(Boolean).join(` + `)},y=Array.from(new Set([...Object.keys(n.modelMatrix),i].filter(e=>e&&!Ag.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)(Li,{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:Eg(`*`)}),(0,Z.jsx)(`optgroup`,{label:r(`settings:agent.routingPhasesGroup`),children:xg.map(e=>(0,Z.jsx)(`option`,{value:e.phase,children:Eg(e.phase)},e.phase))}),xg.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:Eg(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:Eg(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:Dg.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:Og.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:kg.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:Eg(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:Dg.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:Og.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:kg.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))})]})]},e))})]})}var Pg=[`off`,`low`,`medium`,`high`,`all`],Fg={off:`bg-muted-foreground`,low:`bg-success`,medium:`bg-warning`,high:`bg-warning ring-2 ring-warning/25`,all:`bg-destructive`},Ig={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`},Lg=[`executor`,`skeptic`,`auditor`];function Rg(e){return e&&e.length>0?e.map(e=>({id:e.id,name:e.name,description:e.description})):Lg.map(e=>({id:e,name:e}))}var zg=[{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`}],Bg=[{value:`off`,labelKey:`settings:brainOpt.waitForever`},{value:`30000`,label:`30s`},{value:`60000`,label:`1m`},{value:`120000`,label:`2m`},{value:`300000`,label:`5m`}],Vg=[{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`}],Hg=[{value:`100`,label:`100`},{value:`200`,labelKey:`settings:brainOpt.n200Default`},{value:`400`,label:`400`},{value:`800`,label:`800`},{value:`1600`,label:`1600`}],Ug=[{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`}],Wg=[{value:`10`,label:`10`},{value:`20`,labelKey:`settings:brainOpt.n20Default`},{value:`50`,label:`50`},{value:`100`,label:`100`}],Gg=[{value:`60000`,label:`1m`},{value:`300000`,labelKey:`settings:brainOpt.m5Default`},{value:`900000`,label:`15m`},{value:`3600000`,label:`1h`}],Kg=[{value:`50`,label:`50`},{value:`200`,labelKey:`settings:brainOpt.n200Default`},{value:`500`,label:`500`},{value:`1000`,label:`1000`}],qg=[{value:`default`,labelKey:`settings:brainOpt.default`},{value:`10000`,label:`10s`},{value:`20000`,label:`20s`},{value:`30000`,label:`30s`},{value:`60000`,label:`60s`}],Jg=[{value:`default`,labelKey:`settings:brainOpt.default`},{value:`1`,labelKey:`settings:brainOpt.oneSerial`},{value:`2`,label:`2`},{value:`3`,label:`3`},{value:`5`,label:`5`}],Yg=[{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`}],Xg=[{value:`default`,labelKey:`settings:brainOpt.default`},{value:`200`,label:`200`},{value:`400`,label:`400`},{value:`800`,label:`800`},{value:`1600`,label:`1600`}],Zg=[{value:`default`,labelKey:`settings:brainOpt.default500`},{value:`100`,label:`100`},{value:`500`,label:`500`},{value:`1000`,label:`1000`},{value:`5000`,label:`5000`}],Qg=[{value:`default`,labelKey:`settings:brainOpt.default10m`},{value:`120000`,label:`2m`},{value:`600000`,label:`10m`},{value:`1800000`,label:`30m`},{value:`3600000`,label:`1h`}];function $g(e,t){return e.some(e=>e.value===t)?e:[...e,{value:t,label:t}]}function e_(e,t){return e.map(e=>({value:e.value,label:e.labelKey?t(e.labelKey):e.label??e.value}))}function t_(e){return e===void 0?`default`:String(e)}function n_({level:e}){return(0,Z.jsx)(`span`,{className:K(`inline-block h-2.5 w-2.5 rounded-full`,Fg[e])})}function r_(e){return e.provider?`${e.provider}/${e.model}`:e.model}var i_={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 a_(){let{t:e}=U(),{client:t}=ua(),[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=P();(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)(()=>Rg(n?.personaCatalog),[n?.personaCatalog]),b=Pg.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(r_),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)(Sm,{open:f!==null,mode:`provider-model`,title:f?e(i_[f].title):``,hint:f?e(i_[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)(Zn,{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)(pr,{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:Pg.map(e=>(0,Z.jsxs)(Y,{variant:b===e?`default`:`outline`,size:`sm`,className:K(`gap-1.5 text-xs`,b===e&&`shadow-sm`),disabled:c,onClick:()=>g(e),children:[(0,Z.jsx)(n_,{level:e}),e.toUpperCase()]},e))}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(Ig[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:e_(zg,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:e_(Bg,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:e_($g(Wg,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)(Pm,{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)(Pm,{variant:`outline`,className:`text-[10px] shrink-0`,children:t.then.action}),t.enabled===!1&&(0,Z.jsx)(Pm,{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)(Pm,{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:e_($g(Hg,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:e_($g(Ug,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)(Pm,{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:e_($g(Gg,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:e_($g(Kg,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)(Pm,{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:r_(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(r_),r=e.splice(t,1)[0];r&&e.splice(t-1,0,r),h({models:e})},children:(0,Z.jsx)(zt,{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(r_),r=e.splice(t,1)[0];r&&e.splice(t+1,0,r),h({models:e})},children:(0,Z.jsx)(Pe,{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(r_).filter((e,n)=>n!==t);h({models:e.length>0?e:null})},children:(0,Z.jsx)(mr,{className:`h-3 w-3`})})]},`${r_(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)(We,{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)(Pm,{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:r_(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)(mr,{className:`h-3 w-3`})})]},`${r_(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)(We,{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?r_(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:e_(Vg,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:e_(Vg,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:t_(n.council.perCallTimeoutMs),options:e_($g(qg,t_(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:t_(n.council.maxConcurrency),options:e_($g(Jg,t_(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:t_(n.council.voterMaxTokens),options:e_($g(Yg,t_(n.council.voterMaxTokens)),e),onChange:e=>h({council:{voterMaxTokens:e==="default"?null:Number(e)}}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.councilJudgeBudgetLabel`),hint:e(`settings:brain.councilJudgeBudgetHint`),value:t_(n.council.judgeMaxTokens),options:e_($g(Xg,t_(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:t_(n.ledger.maxMemoryEntries),options:e_($g(Zg,t_(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:t_(n.ledger.interventionRetryWindowMs),options:e_($g(Qg,t_(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)(Pm,{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 o_(){let{t:e}=U();return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(ki,{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 s_({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 c_({tool:e,onToggle:t,busy:n}){let{t:r}=U(),[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)(s_,{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)(Pm,{variant:`outline`,className:`px-1.5 text-[10px]`,children:e.permission}),(0,Z.jsx)(Pm,{variant:`outline`,className:`px-1.5 text-[10px]`,children:e.mutating?`mutating`:`read-only`}),(0,Z.jsx)(Pm,{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)(pr,{className:`h-3 w-3 animate-spin`}):e.disabled?(0,Z.jsx)(Xe,{className:`h-3 w-3`}):(0,Z.jsx)(pn,{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)(fr,{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 l_(){let{t:e}=U(),{client:t}=ua(),[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}):p.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,m=n.filter(e=>!e.disabled&&!e.direct).length,h=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)(oi,{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 · `,m,` lazy · `,h,` disabled · `,n.length,` `,`total`]})]}),(0,Z.jsxs)(`div`,{className:`relative`,children:[(0,Z.jsx)(vi,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground`}),(0,Z.jsx)(Ua,{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)(pr,{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)(c_,{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 u_(){let{t:e}=U();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)(ki,{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)(a_,{})]}),(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)(ki,{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)(o_,{})]}),(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)(ki,{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)(l_,{})]})]})}function d_(e,t,n,r,i){e.set({[r]:i}),t({[r]:i}),r===`contextMode`&&typeof i==`string`&&n(i)}var f_=[{id:`general`,icon:(0,Z.jsx)(Fe,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.general`,descKey:`settings:tabs.generalDesc`},{id:`provider`,icon:(0,Z.jsx)(Dn,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.provider`,descKey:`settings:tabs.providerDesc`},{id:`connection`,icon:(0,Z.jsx)(At,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.connection`,descKey:`settings:tabs.connectionDesc`},{id:`agent`,icon:(0,Z.jsx)(Pi,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.agent`,descKey:`settings:tabs.agentDesc`},{id:`execution`,icon:(0,Z.jsx)(cr,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.execution`,descKey:`settings:tabs.executionDesc`},{id:`fallbacks`,icon:(0,Z.jsx)(Li,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.fallbacks`,descKey:`settings:tabs.fallbacksDesc`},{id:`routing`,icon:(0,Z.jsx)(xr,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.routing`,descKey:`settings:tabs.routingDesc`},{id:`fleet`,icon:(0,Z.jsx)(un,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.fleet`,descKey:`settings:tabs.fleetDesc`},{id:`integrations`,icon:(0,Z.jsx)(Ii,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.integrations`,descKey:`settings:tabs.integrationsDesc`},{id:`chimera`,icon:(0,Z.jsx)(Zn,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.chimera`,descKey:`settings:tabs.chimeraDesc`},{id:`context`,icon:(0,Z.jsx)(wr,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.context`,descKey:`settings:tabs.contextDesc`},{id:`logs`,icon:(0,Z.jsx)(Bi,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.logs`,descKey:`settings:tabs.logsDesc`},{id:`security`,icon:(0,Z.jsx)(Rn,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.security`,descKey:`settings:tabs.securityDesc`},{id:`display`,icon:(0,Z.jsx)(Fe,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.display`,descKey:`settings:tabs.displayDesc`}];function p_(){let{settingsActiveTab:e,setSettingsActiveTab:n}=q(jn(e=>({settingsActiveTab:e.settingsActiveTab,setSettingsActiveTab:e.setSettingsActiveTab}))),r=em(`settings`),i=(0,X.useRef)(!1),[a,o]=(0,X.useState)(!1),{provider:s,model:c,setProvider:l,setModel:u,wsConnected:d}=t(jn(e=>({provider:e.provider,model:e.model,setProvider:e.setProvider,setModel:e.setModel,wsConnected:e.wsConnected}))),f=ua(),m=f.client,{updatePrefs:h,switchAutonomy:g,switchContextMode:_}=f,v=W(),{t:y}=U(),b=Ya(!0),x=(0,X.useCallback)((e,t)=>{d_(v,h,_,e,t)},[v,h,_]),[S,C]=(0,X.useState)([]),[w,T]=(0,X.useState)({}),[E,D]=(0,X.useState)([]),[O,k]=(0,X.useState)(!1),[A,j]=(0,X.useState)(!1),[M,ee]=(0,X.useState)(!1),[N,P]=(0,X.useState)(`catalog`),[F,I]=(0,X.useState)(``),[te,L]=(0,X.useState)(!1),R=(0,X.useCallback)(()=>{v.reset(),L(!1),window.location.reload()},[v]),z=S.find(e=>e.id===s),ne=f_.find(t=>t.id===e);(0,X.useEffect)(()=>{let e=e=>{if(e.type===`provider.catalog`){let t=e.payload;C(t.providers.sort((e,t)=>e.id.localeCompare(t.id))),k(!1)}},t=e=>{if(e.type===`provider.models`){let t=e.payload;T(e=>({...e,[t.provider]:t.models})),j(!1)}},n=e=>{if(e.type===`providers.saved`){let t=e.payload.providers.sort((e,t)=>e.id.localeCompare(t.id));D(t),ee(!1),t.length>0&&P(`saved`)}};if(!d||!m)return;let r=m.on(`provider.catalog`,e),i=m.on(`provider.models`,t),a=m.on(`providers.saved`,n);return k(!0),ee(!0),m.listProviders(),m.listSavedProviders(),()=>{r?.(),i?.(),a?.()}},[d,m]);let re=(0,X.useCallback)(e=>{l(e),w[e]||(j(!0),f.listProviderModels?.(e))},[w,l,f]),ie=(0,X.useCallback)(async e=>{if(i.current)return;let n=t.getState().model,r=t.getState().provider;if(!(!r||e===n)){i.current=!0,o(!0),u(e);try{p.info(H.t(`settings:toast.switchingTo`,{provider:r,model:e}));let t=await f.switchModel?.(r,e);t?.success?p.success(H.t(t.runActive?`settings:toast.modelSwitchedRunActive`:`settings:toast.modelSwitchedNextRequest`,{from:`${r} / ${n}`,to:`${r} / ${e}`})):(u(n),p.error(t?.message??H.t(`settings:toast.modelSwitchTimeout`)))}finally{i.current=!1,o(!1)}}},[u,f]),B=(0,X.useCallback)((e,t,n)=>{f.addKey?.(e,t,n)},[f]),ae=(0,X.useCallback)((e,t)=>{f.deleteKey?.(e,t)},[f]),oe=(0,X.useCallback)((e,t)=>{f.setActiveKey?.(e,t)},[f]),se=(0,X.useCallback)((e,t,n,r,i,a)=>{f.addProvider?.(e,t,n,r,i,a)},[f]),ce=(0,X.useCallback)(e=>{f.removeProvider?.(e)},[f]),le=(0,X.useCallback)((e,n)=>{f.client.updateProvider({id:e,models:[n]}),e===t.getState().provider&&u(n)},[u,f.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)(Tr,{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:y(`settings:title`)}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-[11px] text-muted-foreground`,children:s&&c?`${s} / ${c}`:y(`settings:subtitle`)})]})]}),(0,Z.jsx)(Y,{variant:`ghost`,size:`icon`,onClick:()=>Pa(`chat`),children:(0,Z.jsx)(mr,{className:`h-4 w-4`})}),(0,Z.jsx)(Y,{variant:`ghost`,size:`sm`,onClick:()=>L(!0),children:y(`settings:resetLabel`)})]}),(0,Z.jsx)(ws,{className:`min-h-0 flex-1`,ref:r,children:(0,Z.jsx)(`div`,{className:`mx-auto max-w-7xl p-4 sm:p-6`,children:(0,Z.jsxs)(Es,{value:e,onValueChange:n,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)(Ds,{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:f_.map(e=>(0,Z.jsxs)(Os,{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:y(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:[ne?.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:ne.icon}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-semibold`,children:y(ne.labelKey)}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:y(ne.descKey)})]})]}),(0,Z.jsx)(ks,{value:`general`,className:`mt-0`,children:(0,Z.jsx)(Vm,{})}),(0,Z.jsxs)(ks,{value:`provider`,className:`mt-0 space-y-4`,children:[(0,Z.jsx)(bg,{activeProvider:s,catalogProviders:S,isLoadingCatalog:O,savedProviders:E,isLoadingSaved:M,providerTab:N,setProviderTab:P,onSelectProvider:re,onAddKey:B,onDeleteKey:ae,onSetActiveKey:oe,onAddProvider:se,onRemoveProvider:ce,onPickProviderModel:le,ws:f.client,catalogQuery:F,setCatalogQuery:I}),(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`}),y(`settings:model.heading`)]}),(0,Z.jsx)(xh,{provider:s,catalogModels:w,currentCatalogProvider:z,isLoadingModels:A,setIsLoadingModels:j,onModelSelect:ie,isSwitching:a,refreshModels:e=>f.listProviderModels?.(e)}),(0,Z.jsx)(bh,{syncPref:x})]})]}),(0,Z.jsx)(ks,{value:`connection`,className:`mt-0`,children:(0,Z.jsx)(Bm,{})}),(0,Z.jsx)(ks,{value:`agent`,className:`mt-0 space-y-6`,children:(0,Z.jsx)(wm,{syncPref:x,switchAutonomy:g})}),(0,Z.jsx)(ks,{value:`execution`,className:`mt-0 space-y-6`,children:(0,Z.jsx)(nh,{syncPref:x,fallbackCandidates:b})}),(0,Z.jsx)(ks,{value:`fallbacks`,className:`mt-0`,children:(0,Z.jsx)(ch,{syncPref:x,candidates:b,provider:s,activeModel:c,setProvider:l,setModel:u,switchModel:f.switchModel})}),(0,Z.jsxs)(ks,{value:`routing`,className:`mt-0`,children:[(0,Z.jsx)(Ng,{syncPref:x,candidates:b}),(0,Z.jsx)(`div`,{className:`mt-6 border-t border-border pt-6`,children:(0,Z.jsx)(wh,{syncPref:x})})]}),(0,Z.jsx)(ks,{value:`fleet`,className:`mt-0`,children:(0,Z.jsx)(lh,{syncPref:x})}),(0,Z.jsx)(ks,{value:`integrations`,className:`mt-0`,children:(0,Z.jsx)(vh,{syncPref:x})}),(0,Z.jsx)(ks,{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)(Hm,{syncPref:x,sessionProvider:s,sessionModel:c})})}),(0,Z.jsx)(ks,{value:`context`,className:`mt-0 space-y-6`,children:(0,Z.jsx)(Jm,{syncPref:x})}),(0,Z.jsx)(ks,{value:`logs`,className:`mt-0 space-y-6`,children:(0,Z.jsx)(yh,{syncPref:x})}),(0,Z.jsx)(ks,{value:`security`,className:`mt-0`,children:(0,Z.jsx)(u_,{})}),(0,Z.jsx)(ks,{value:`display`,className:`mt-0`,children:(0,Z.jsx)($m,{syncPref:x})})]})]})})}),(0,Z.jsx)(Ha,{open:te,onOpenChange:L,children:(0,Z.jsxs)(za,{showCloseButton:!1,children:[(0,Z.jsxs)(La,{children:[(0,Z.jsx)(Ba,{children:y(`settings:resetConfirmTitle`)}),(0,Z.jsx)(Va,{children:y(`settings:resetConfirmBody`)})]}),(0,Z.jsxs)(Ra,{className:`gap-2 sm:gap-0`,children:[(0,Z.jsx)(Y,{variant:`outline`,onClick:()=>L(!1),children:y(`settings:cancel`)}),(0,Z.jsx)(Y,{variant:`destructive`,onClick:R,children:y(`settings:resetConfirmAction`)})]})]})})]})}function m_(){let e=ya(e=>e.info),{client:t}=ua(),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 h_=new Map,g_=new Set;y(e=>{h_.delete(e),g_.add(e)});function __({sessionId:e,className:n}){let{t:r}=U(),[i,a]=(0,X.useState)([]),[o,s]=(0,X.useState)(!1),[c,l]=(0,X.useState)(null),[u,d]=(0,X.useState)(null),[f,p]=(0,X.useState)(0),[m,h]=(0,X.useState)(!1),[g,_]=(0,X.useState)(!1),[v,y]=(0,X.useState)(``),[b,x]=(0,X.useState)(``),[S,C]=(0,X.useState)(!1),[w,T]=(0,X.useState)(``),E=(0,X.useRef)(e),D=t(e=>e.wsUrl),O=V(D),k=J(e=>e.messages).filter(e=>e.role===`tool`&&e.toolResult===void 0&&!!e.toolUseId);(0,X.useLayoutEffect)(()=>{let t=E.current;g_.has(t)||h_.set(t,{participants:i,joined:o,joinedRole:c,error:u,openAnnotationCount:f,paused:m,injectOpen:g,injectToolUseId:v,injectContent:b,injectIsError:S,injectReason:w});let n=h_.get(e);g_.delete(e),a(n?.participants??[]),s(n?.joined??!1),l(n?.joinedRole??null),d(n?.error??null),p(n?.openAnnotationCount??0),h(n?.paused??!1),_(n?.injectOpen??!1),y(n?.injectToolUseId??``),x(n?.injectContent??``),C(n?.injectIsError??!1),T(n?.injectReason??``),E.current=e},[e]),(0,X.useEffect)(()=>{let t=[];return t.push(O.on(`collab.state`,t=>{let n=t.payload;n.sessionId===e&&a(n.participants??[])})),t.push(O.on(`collab.participant.joined`,t=>{let n=t.payload;n.sessionId===e&&a(e=>e.some(e=>e.participantId===n.participantId)?e:[...e,{participantId:n.participantId,role:n.role,joinedAt:n.joinedAt}])})),t.push(O.on(`collab.participant.left`,t=>{let n=t.payload;if(n.sessionId!==e)return;let r=n.participantId;a(e=>e.filter(e=>e.participantId!==r))})),t.push(O.on(`error`,e=>{let t=e.payload;t.phase===`collab`&&(d(t.message),s(!1))})),t.push(O.on(`collab.annotation.added`,t=>{let n=t.payload;n.sessionId===e&&(n.annotation?.resolved||p(e=>e+1))})),t.push(O.on(`collab.annotation.resolved`,t=>{t.payload.sessionId===e&&p(e=>Math.max(0,e-1))})),t.push(O.on(`collab.pause.granted`,t=>{t.payload.sessionId===e&&h(!0)})),t.push(O.on(`collab.pause.released`,t=>{t.payload.sessionId===e&&h(!1)})),()=>{for(let e of t)e()}},[O,e]);let A=(t=`observer`)=>{d(null),O.send({type:`collab.join`,payload:{sessionId:e,role:t}}),s(!0),l(t)},j=()=>{O.send({type:`collab.request_pause`,payload:{sessionId:e}})},M=()=>{O.send({type:`collab.resume`,payload:{sessionId:e}})},ee=()=>{O.send({type:`collab.leave`,payload:{sessionId:e}}),s(!1),a([])},N=t=>{O.send({type:`collab.grant_control`,payload:{sessionId:e,toParticipant:t}})},P=()=>{v&&(O.send({type:`collab.inject_tool`,payload:{sessionId:e,toolUseId:v,content:b,isError:S,reason:w.trim()||H.t(`activity:collab.controllerInjection`)}}),_(!1),y(``),x(``),C(!1),T(``))},F=o&&c===`controller`;return i.length===0&&!u?(0,Z.jsxs)(`div`,{className:K(`flex items-center gap-2 px-3 py-2 rounded-md border border-dashed border-border bg-card/40`,n),children:[(0,Z.jsx)(er,{className:`w-4 h-4 text-muted-foreground`}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r(`activity:collab.noObservers`)}),(0,Z.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>A(`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:r(`activity:collab.observerTitle`),children:[(0,Z.jsx)(sr,{className:`w-3 h-3`}),r(`activity:collab.observerRole`)]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>A(`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:r(`activity:collab.annotatorTitle`),children:[(0,Z.jsx)(ur,{className:`w-3 h-3`}),r(`activity:collab.annotatorRole`)]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>A(`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:r(`activity:collab.controllerTitle`),children:[(0,Z.jsx)(Vt,{className:`w-3 h-3`}),r(`activity:collab.controllerRole`)]})]})]}):u?(0,Z.jsxs)(`div`,{className:K(`flex items-center gap-2 px-3 py-2 rounded-md border border-destructive/50 bg-destructive/10`,n),role:`alert`,children:[(0,Z.jsx)(`span`,{className:`text-xs text-destructive`,children:r(`activity:collab.errorPrefix`,{error:u})}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{d(null),s(!1)},className:`ml-auto text-xs underline text-destructive`,children:r(`activity:collab.dismiss`)})]}):(0,Z.jsxs)(`div`,{className:K(`relative flex items-center gap-2 px-3 py-2 rounded-md border border-success/40 bg-success/5`,n),children:[(0,Z.jsxs)(`span`,{className:`relative flex h-2 w-2`,role:`img`,"aria-label":r(`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)(er,{className:`w-4 h-4 text-success`}),(0,Z.jsx)(`span`,{className:`text-xs font-medium text-success`,children:r(`activity:collab.observers`,{count:i.length})}),f>0&&(0,Z.jsxs)(`span`,{title:r(`activity:collab.annotationsTitle`,{count:f}),className:`ml-2 inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-warning/15 text-warning border border-warning/30`,children:[(0,Z.jsx)(ur,{className:`w-3 h-3`}),r(`activity:collab.notes`,{count:f})]}),m&&(0,Z.jsxs)(`span`,{title:r(`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)(Vt,{className:`w-3 h-3`}),r(`activity:collab.paused`)]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1 ml-2`,children:[i.slice(0,3).map(e=>(0,Z.jsxs)(`span`,{title:r(`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)(ki,{className:`w-3 h-3`}),e.role,F&&e.role!==`controller`&&(0,Z.jsx)(`button`,{type:`button`,onClick:()=>N(e.participantId),title:r(`activity:collab.grantTitle`),className:`ml-0.5 inline-flex items-center rounded hover:bg-success/20 transition-colors`,children:(0,Z.jsx)(Ve,{className:`w-3 h-3`})})]},e.participantId)),i.length>3&&(0,Z.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`+`,i.length-3]})]}),F&&(0,Z.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>_(e=>!e),className:`inline-flex items-center gap-1 text-xs px-2 py-1 rounded border border-info/40 bg-info/10 text-info hover:bg-info/20 transition-colors`,title:r(`activity:collab.injectTitle`),children:[(0,Z.jsx)(sn,{className:`w-3 h-3`}),r(`activity:collab.inject`)]}),m?(0,Z.jsxs)(`button`,{type:`button`,onClick:M,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:r(`activity:collab.resumeTitle`),children:[(0,Z.jsx)(Kt,{className:`w-3 h-3`}),r(`activity:collab.resume`)]}):(0,Z.jsxs)(`button`,{type:`button`,onClick:j,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:r(`activity:collab.pauseTitle`),children:[(0,Z.jsx)(Vt,{className:`w-3 h-3`}),r(`activity:collab.pauseAgent`)]})]}),o&&c!==`controller`&&(0,Z.jsxs)(`button`,{type:`button`,onClick:ee,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:r(`activity:collab.leaveTitle`),children:[(0,Z.jsx)(Hr,{className:`w-3 h-3`}),r(`activity:collab.leave`)]}),F&&g&&(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)(sn,{className:`w-3.5 h-3.5 text-info`}),(0,Z.jsx)(`span`,{className:`font-medium`,children:r(`activity:collab.injectToolResult`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>_(!1),className:`ml-auto text-muted-foreground hover:text-foreground`,children:r(`activity:collab.close`)})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:r(`activity:collab.targetTool`)}),(0,Z.jsx)(`input`,{list:`collab-inject-tools`,value:v,onChange:e=>y(e.target.value),placeholder:r(`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:k.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??r(`activity:collab.toolFallback`),t]},e.toolUseId)})}),k.length===0&&(0,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:r(`activity:collab.noPendingTools`)})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:r(`activity:collab.resultContent`)}),(0,Z.jsx)(`textarea`,{value:b,onChange:e=>x(e.target.value),rows:3,placeholder:r(`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:S,onChange:e=>C(e.target.checked)}),(0,Z.jsx)(`span`,{children:r(`activity:collab.markError`)})]}),(0,Z.jsx)(`input`,{type:`text`,value:w,onChange:e=>T(e.target.value),placeholder:r(`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:!v,className:`self-end inline-flex items-center gap-1 text-xs px-3 py-1 rounded bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:[(0,Z.jsx)(sn,{className:`w-3 h-3`}),r(`activity:collab.queueInjection`)]})]})]})}var v_={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 y_({className:e}){let{t}=U(),n=B(e=>e.agents),i=P(),[a,o]=(0,X.useState)(null),s=(0,X.useMemo)(()=>{let e=Array.from(n.values()).filter(e=>r(e.sessionId,i));return e.sort(b),e},[n,i]),c=(0,X.useCallback)(async(e,t)=>{try{await navigator.clipboard.writeText(t),o(e),setTimeout(()=>o(null),2e3)}catch{}},[]),l=(0,X.useCallback)(e=>{q.getState().setSubagentChatFocus(e,i??void 0),q.getState().setDockSection(null)},[i]);if(s.length===0)return(0,Z.jsx)(`div`,{className:K(`p-4 text-center text-xs text-muted-foreground`,e),children:t(`activity:agents.noAgentsRunning`)});let u=xe(s),d=s.reduce((e,t)=>e+(t.costUsd??0),0);return(0,Z.jsxs)(`div`,{className:K(`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)(Pi,{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:[u.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`}),u.running,` `,t(`activity:fleet.statusRunning`)]}),u.completed>0&&(0,Z.jsxs)(`span`,{className:`text-muted-foreground`,children:[u.completed,` `,t(`activity:fleet.statusDone`)]}),u.failed>0&&(0,Z.jsxs)(`span`,{className:`font-medium text-destructive`,children:[u.failed,` `,t(`activity:fleet.statusFailed`)]}),d>0&&(0,Z.jsx)(`span`,{className:`rounded bg-muted/60 px-1.5 py-0.5 font-mono text-[10px] text-foreground/80`,children:qs(d)})]})]}),(0,Z.jsx)(`div`,{className:`flex flex-col gap-2`,children:s.map(e=>{let n=v_[e.status]??v_.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:K(`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:K(`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)(vn,{className:`h-3 w-3`}),Ys(r)]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>l(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)(we,{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)(oi,{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)(Fn,{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:qs(e.costUsd)}),e.finalText&&(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>c(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)(ii,{className:`h-3 w-3 text-success`}):(0,Z.jsx)(Bt,{className:`h-3 w-3`}),(0,Z.jsx)(`span`,{children:a===e.id?t(`common:action.copied`):t(`common:action.copy`)})]})]})]})]},e.id)})})]})}var b_={up:(0,Z.jsx)(Me,{className:`h-3.5 w-3.5 text-success`}),down:(0,Z.jsx)(Nr,{className:`h-3.5 w-3.5 text-destructive`}),stable:(0,Z.jsx)(In,{className:`h-3.5 w-3.5 text-warning`})},x_={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 S_({goal:e,className:t}){let{t:n}=U(),[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=x_[e.goalState],c=e.deliverables?.filter(e=>e.status===`done`).length??0,l=e.deliverables?.length??0,u=e.progressTrend?b_[e.progressTrend]:null;return(0,Z.jsxs)(`div`,{className:K(`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)(mt,{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:K(`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)(ar,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}):(0,Z.jsx)(fr,{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:K(`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)(vn,{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)(Cr,{className:`h-3 w-3 text-success mt-0.5 shrink-0`}):(0,Z.jsx)(gt,{className:`h-3 w-3 text-muted-foreground/70 mt-0.5 shrink-0`}),(0,Z.jsx)(`span`,{className:K(`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 C_={in_progress:0,pending:1,completed:2},w_=`__no_session__`,T_=new Map,E_=new Set;y(e=>{T_.delete(e),E_.add(e)});function D_(){let{t:e}=U(),t=j(e=>e.todos),n=P(),[r,i]=(0,X.useState)(new Set),a=V(),o=(0,X.useRef)(n??w_);(0,X.useLayoutEffect)(()=>{E_.has(o.current)||T_.set(o.current,new Set(r));let e=n??w_;E_.delete(e),i(new Set(T_.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)=>(C_[e.status]??9)-(C_[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:K(`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)(Cr,{className:`w-3.5 h-3.5 text-success`}):r?(0,Z.jsx)(vn,{className:`w-3.5 h-3.5 text-warning animate-spin`}):(0,Z.jsx)(gt,{className:K(`w-3.5 h-3.5 transition-colors`,`text-muted-foreground/65 group-hover:text-success`)})}),(0,Z.jsxs)(`span`,{className:K(`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)(Lt,{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 O_={pending:{icon:(0,Z.jsx)(gt,{className:`w-3.5 h-3.5`}),labelKey:`statusPending`,color:`text-muted-foreground/70`},in_progress:{icon:(0,Z.jsx)(vn,{className:`w-3.5 h-3.5 animate-spin`}),labelKey:`statusInProgress`,color:`text-warning`},blocked:{icon:(0,Z.jsx)(Vt,{className:`w-3.5 h-3.5`}),labelKey:`statusBlocked`,color:`text-warning`},failed:{icon:(0,Z.jsx)(Fn,{className:`w-3.5 h-3.5`}),labelKey:`statusFailed`,color:`text-destructive`},review:{icon:(0,Z.jsx)(gr,{className:`w-3.5 h-3.5`}),labelKey:`statusReview`,color:`text-info`},completed:{icon:(0,Z.jsx)(Cr,{className:`w-3.5 h-3.5`}),labelKey:`statusDone`,color:`text-success`}},k_={critical:`text-destructive`,high:`text-warning`,medium:`text-warning/85`,low:`text-muted-foreground`},A_={feature:`⚡`,bugfix:`🐛`,refactor:`♻️`,docs:`📝`,test:`🧪`,chore:`🔧`},j_=`__no_session__`,M_=new Map,N_=new Set;y(e=>{M_.delete(e),N_.add(e)});function P_(){let{t:e}=U(),[t,n]=(0,X.useState)([]),[r,i]=(0,X.useState)(new Set),a=V(),o=P(),s=(0,X.useRef)(o??j_);(0,X.useLayoutEffect)(()=>{N_.has(s.current)||M_.set(s.current,new Set(r));let e=o??j_;N_.delete(e),i(new Set(M_.get(e)??[])),s.current=e},[o]),(0,X.useEffect)(()=>{n([]),a.getTasks();let e=a.on(`tasks.updated`,e=>{let t=e?.payload;t?.sessionId&&o&&t.sessionId!==o||t?.tasks&&n(t.tasks)});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.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=O_[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:K(`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:K(`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:K(t.status===`completed`?`text-muted-foreground line-through`:`text-foreground/80`),children:[A_[t.type],` `,t.title]}),t.priority!==`medium`&&(0,Z.jsx)(`span`,{className:K(`ml-1 text-[10px]`,k_[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 F_={open:{icon:(0,Z.jsx)(gt,{className:`w-3.5 h-3.5`}),labelKey:`statusOpen`,color:`text-muted-foreground/70`},in_progress:{icon:(0,Z.jsx)(vn,{className:`w-3.5 h-3.5 animate-spin`}),labelKey:`statusInProgress`,color:`text-warning`},done:{icon:(0,Z.jsx)(Cr,{className:`w-3.5 h-3.5`}),labelKey:`statusDone`,color:`text-success`}},I_=`__no_session__`,L_=new Map,R_=new Set;y(e=>{L_.delete(e),R_.add(e)});function z_(){let{t:e}=U(),[t,n]=(0,X.useState)([]),[r,i]=(0,X.useState)(new Set),a=V(),o=P(),s=(0,X.useRef)(o??I_);(0,X.useLayoutEffect)(()=>{R_.has(s.current)||L_.set(s.current,new Set(r));let e=o??I_;R_.delete(e),i(new Set(L_.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=F_[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:K(`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:K(`mt-0.5 shrink-0`,i.color),children:i.icon}),(0,Z.jsx)(`span`,{className:K(`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 B_=[{id:`todos`,labelKey:`work.todos`,icon:`✅`},{id:`tasks`,labelKey:`work.tasks`,icon:`📋`},{id:`plan`,labelKey:`work.plan`,icon:`🗺️`}];function V_(){let{t:e}=U(),t=q(e=>e.workDashboardTab),n=q(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:B_.map(r=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>n(r.id),className:K(`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:K(t===`todos`?`block`:`hidden`),children:(0,Z.jsx)(D_,{})}),(0,Z.jsx)(`div`,{className:K(t===`tasks`?`block`:`hidden`),children:(0,Z.jsx)(P_,{})}),(0,Z.jsx)(`div`,{className:K(t===`plan`?`block`:`hidden`),children:(0,Z.jsx)(z_,{})})]})}var H_={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))`},U_=[H_.primary,H_.info,H_.success,H_.warning,H_.destructive,H_.muted],W_=e=>e.replace(/^wstack\/ap\//,``);function G_(e){return[...e].sort((e,t)=>e.allocatedAt-t.allocatedAt).map((e,t)=>({handle:e,color:U_[t%U_.length],y:60+t*48}))}var K_={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 q_({worktrees:e,baseBranch:t}){let{t:n}=U(),r=G_(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:H_.primary,strokeWidth:3}),(0,Z.jsx)(`text`,{x:36,y:14,fontSize:11,fill:H_.muted,children:t||`HEAD`}),(0,Z.jsx)(`circle`,{cx:40,cy:20,r:5,fill:H_.primary}),r.map(e=>{let r=K_[e.handle.status]??d(K_.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:H_.success,strokeWidth:2,opacity:.9}):null,(0,Z.jsx)(`circle`,{cx:220,cy:e.y,r:5,fill:a?H_.destructive:e.color}),(0,Z.jsx)(`text`,{x:232,y:e.y-6,fontSize:12,fill:H_.foreground,fontFamily:`monospace`,children:W_(e.handle.branch)}),(0,Z.jsx)(`text`,{x:232,y:e.y+10,fontSize:10,fill:H_.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 J_={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 Y_(e){return J_[e]??{icon:`?`,labelKey:``,tint:`border-border`,dot:`bg-muted-foreground`}}var X_=e=>e.replace(/^wstack\/ap\//,``);function Z_({worktrees:e,baseBranch:t}){let{t:n}=U(),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=Y_(e.status),r=e.status===`needs-review`,i=Math.min(100,e.insertions+e.deletions);return(0,Z.jsxs)(`div`,{className:K(`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:K(`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:X_(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 Q_=e=>e?e.replace(/^wstack\/ap\//,``):``;function $_(){let{t:e}=U(),{client:t}=ua(),n=wa(e=>e.orphans),r=wa(e=>e.canClean),i=wa(e=>e.cleanBlockedReason),a=wa(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)(Rr,{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`?`⌥ `:`▢ `,Q_(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 qa({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)(pr,{className:`h-3.5 w-3.5 animate-spin`}):(0,Z.jsx)(ln,{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 ev={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`}},tv={goal:`Goal`,"goal-state":`Goal State`,fleet:`Fleet`,work:`Work`,worktrees:`Worktrees`,collab:`Collab`},nv=[`goal`,`goal-state`,`fleet`,`work`,`worktrees`,`collab`];function rv({section:e,icon:t,label:n,value:r,active:i,pulse:a,onClick:o}){let s=ev[e],{t:c}=U();return(0,Z.jsxs)(`button`,{type:`button`,onClick:o,title:c(i?`activity:dock.collapseChip`:`activity:dock.expandChip`,{label:n}),className:K(`flex items-center gap-2 h-7 px-2.5 rounded-md border text-xs font-medium shrink-0 transition-colors`,i?s.active:K(`border-border/40`,s.idle)),children:[(0,Z.jsx)(`span`,{className:K(a&&`animate-pulse`),children:t}),n,r&&(0,Z.jsx)(`span`,{className:`tabular-nums opacity-80`,children:r})]})}function iv(){let e=q(e=>e.dockSection),{t}=U(),n=q(e=>e.toggleDockSection),i=q(e=>e.hiddenChips),a=q(e=>e.toggleChipHidden),o=q(e=>e.dockCustomizeOpen),s=q(e=>e.setDockCustomizeOpen),c=P(),l=Sa(e=>e.goal),u=xa(e=>e.phases.length),d=xa(e=>e.overallPercent),f=xa(e=>e.activePhaseId),p=wa(e=>e.worktrees),m=j(e=>e.todos),h=B(e=>e.agents),g=m_(),_=(0,X.useMemo)(()=>Array.from(h.values()).filter(e=>r(e.sessionId,c)),[h,c]),v=_.length,y=(0,X.useMemo)(()=>_.filter(e=>e.status===`running`).length,[_]),b=m.filter(e=>e.status===`completed`).length,x=m.some(e=>e.status===`in_progress`),S=u>0,C=(0,X.useMemo)(()=>new Set(i),[i]),w={goal:S,"goal-state":l!==null,fleet:v>0,work:!0,worktrees:p.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)(rv,{section:`goal`,icon:(0,Z.jsx)(Ai,{className:`h-3 w-3`}),label:t(`activity:dock.goal`),value:`${d}%`,active:!1,pulse:f!=null,onClick:()=>Fa(`goal`)}),T[`goal-state`]&&l&&(0,Z.jsx)(rv,{section:`goal-state`,icon:(0,Z.jsx)(mt,{className:`h-3 w-3`}),label:t(`activity:dock.goalState`),value:`${l.progress}%`,active:E===`goal-state`,pulse:l.goalState===`active`,onClick:()=>n(`goal-state`)}),T.fleet&&(0,Z.jsx)(rv,{section:`fleet`,icon:(0,Z.jsx)(Pi,{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)(rv,{section:`work`,icon:(0,Z.jsx)(Kr,{className:`h-3 w-3`}),label:t(`activity:dock.work`),value:m.length>0?`${b}/${m.length}`:void 0,active:E===`work`,pulse:x,onClick:()=>n(`work`)}),T.worktrees&&(0,Z.jsx)(rv,{section:`worktrees`,icon:(0,Z.jsx)(Cn,{className:`h-3 w-3`}),label:t(`activity:dock.worktrees`),value:String(p.length),active:E===`worktrees`,onClick:()=>n(`worktrees`)}),g&&(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)(Cn,{className:`h-3 w-3 shrink-0 text-muted-foreground`}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate font-semibold text-foreground`,children:g.branch}),g.ahead>0&&(0,Z.jsxs)(`span`,{className:`text-success`,title:t(`activity:dock.ahead`,{count:g.ahead}),children:[`↑`,g.ahead]}),g.behind>0&&(0,Z.jsxs)(`span`,{className:`text-warning`,title:t(`activity:dock.behind`,{count:g.behind}),children:[`↓`,g.behind]}),g.added>0&&(0,Z.jsxs)(`span`,{className:`text-success`,title:t(`activity:dock.linesAdded`,{count:g.added}),children:[`+`,g.added]}),g.deleted>0&&(0,Z.jsxs)(`span`,{className:`text-destructive`,title:t(`activity:dock.linesDeleted`,{count:g.deleted}),children:[`-`,g.deleted]}),g.untracked>0&&(0,Z.jsxs)(`span`,{className:`text-muted-foreground`,title:t(`activity:dock.untrackedFiles`,{count:g.untracked}),children:[g.untracked,`?`]})]}),(0,Z.jsx)(rv,{section:`collab`,icon:(0,Z.jsx)(er,{className:`h-3 w-3`}),label:t(`activity:dock.collab`),active:E===`collab`,onClick:()=>n(`collab`)}),(0,Z.jsxs)(so,{open:o,onOpenChange:s,children:[(0,Z.jsx)(co,{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)(di,{className:`h-3 w-3`})})}),(0,Z.jsxs)(fo,{align:`end`,className:`w-44`,children:[(0,Z.jsx)(go,{children:t(`activity:dock.dockChips`)}),(0,Z.jsx)(_o,{}),nv.map(e=>(0,Z.jsx)(mo,{checked:!C.has(e),onCheckedChange:()=>a(e),onSelect:e=>e.preventDefault(),children:tv[e]},e))]})]})]})})}var av={"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 ov({sessionId:e}){let t=q(e=>e.dockSection),n=q(e=>e.setDockSection),r=q(e=>e.inspectorOpen),i=Sa(e=>e.goal),a=wa(e=>e.worktrees),o=wa(e=>e.baseBranch),[s,c]=(0,X.useState)(`graph`),{t:l}=U(),u=t!==null&&t!==`goal`,d=u?t:null,f=d?av[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:K(`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)(ft,{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)(mr,{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)(S_,{goal:i}):(0,Z.jsx)(sv,{title:l(`activity:dock.noActiveGoal`),detail:l(`activity:dock.noActiveGoalDetail`)})),d===`fleet`&&(0,Z.jsx)(y_,{}),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:K(`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)($_,{}),s===`graph`?(0,Z.jsx)(q_,{worktrees:a,baseBranch:o||`HEAD`}):(0,Z.jsx)(Z_,{worktrees:a,baseBranch:o||`HEAD`})]}),(0,Z.jsx)(`div`,{className:K(d===`work`?`block`:`hidden`),id:`panel-work`,children:(0,Z.jsx)(V_,{})}),(0,Z.jsx)(`div`,{className:K(d===`collab`?`block`:`hidden`),children:(0,Z.jsx)(__,{sessionId:e})})]})]})}function sv({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})]})}var cv=(0,X.lazy)(()=>G(()=>import(`./AnalyticsDashboard-nqlWJi6M.js`).then(e=>({default:e.AnalyticsDashboard})),__vite__mapDeps([26,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,20,21,19,22]))),lv=(0,X.lazy)(()=>G(()=>import(`./AgentRosterView-BVpIFQwi.js`).then(e=>({default:e.AgentRosterView})),__vite__mapDeps([27,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,21,20,19,22,23,28,18,24,29,30,25,31,32,33,34,35]))),uv=(0,X.lazy)(()=>G(()=>import(`./ChangesView-CN7NWDeV.js`).then(e=>({default:e.ChangesView})),__vite__mapDeps([36,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,19,20,21,22,23,24,37,38]))),dv=(0,X.lazy)(()=>G(()=>import(`./ChronicleDashboard-BWMkG_hu.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]))),fv=(0,X.lazy)(()=>G(()=>import(`./CodeEditor-DZ2k-Mz5.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,19,20,21,22,23,37,38,41,31,33]))),pv=(0,X.lazy)(()=>G(()=>import(`./CodeMap-CLOuNLqN.js`).then(e=>({default:e.CodeMap})),__vite__mapDeps([42,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,19,24]))),mv=(0,X.lazy)(()=>G(()=>import(`./DebugDashboard-C0tmxxV8.js`).then(e=>({default:e.DebugDashboard})),__vite__mapDeps([43,1,2,3,4,5,6,7,8,9,10,11,12,13,14]))),hv=(0,X.lazy)(()=>G(()=>import(`./DesignGalleryView-lc-XRmVG.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,18,19,20,21,22,23,24]))),gv=(0,X.lazy)(()=>G(()=>import(`./GoalView-BuYUc4OB.js`).then(e=>({default:e.GoalView})),__vite__mapDeps([45,1,2,3,4,5,6,7,8,9,10,11,12,13,14,18,0,15,16,19,20,21,22,23,24,31,46,25,32]))),_v=(0,X.lazy)(()=>G(()=>import(`./KanbanView-DQK6adut.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,20,21,19,22,25,28,18,23,24,48]))),vv=(0,X.lazy)(()=>G(()=>import(`./MailboxDetailView-CBV3-Hf2.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,22,23,37]))),yv=(0,X.lazy)(()=>G(()=>import(`./PromptJournalView-Biu4DknM.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]))),bv=(0,X.lazy)(()=>G(()=>import(`./RefreshDebugView-d9iU3sFX.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,21]))),xv=(0,X.lazy)(()=>G(()=>import(`./SageTabs-Bw6PDwy3.js`).then(e=>({default:e.SageTabs})),__vite__mapDeps([52,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]))),Sv=(0,X.lazy)(()=>G(()=>import(`./RequirementIntakeView-g9dzUTVw.js`).then(e=>({default:e.RequirementIntakeView})),__vite__mapDeps([53,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,31,32]))),Cv=(0,X.lazy)(()=>G(()=>import(`./SddHub-Cdow0Exb.js`).then(e=>({default:e.SddHub})),__vite__mapDeps([54,1,2,3,4,5,6,7,8,9,10,11,12,13,14,18,0,15,16,19,20,21,22,23,24,25,31,28,48,55]))),wv=(0,X.lazy)(()=>G(()=>import(`./SessionsDashboard-DkaNF5lx.js`).then(e=>({default:e.SessionsDashboard})),__vite__mapDeps([56,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,19,20,21,22,23,24,57,46,25,31,32]))),Tv=(0,X.lazy)(()=>G(()=>import(`./SessionInspectView-je_xLISf.js`).then(e=>({default:e.SessionInspectView})),__vite__mapDeps([58,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,19,20,21,22,23,24,57,46,25,31,32]))),Ev=(0,X.lazy)(()=>G(()=>import(`./SkillDetailView-Bjq8GkDB.js`).then(e=>({default:e.SkillDetailView})),__vite__mapDeps([59,1,2,3,4,5,6,7,8,9,10,11,12,13,14,18,0,15,16,19,20,21,22,23,24,25,37]))),Dv=(0,X.lazy)(()=>G(()=>import(`./TechStackView-CQ9AdoBa.js`).then(e=>({default:e.TechStackView})),__vite__mapDeps([60,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,20,0,16,21,19,22,31,32]))),Ov=(0,X.lazy)(()=>G(()=>import(`./DeadCodeScanPanel-DooqnEMF.js`).then(e=>({default:e.DeadCodeScanPanel})),__vite__mapDeps([61,1,2,3,4,5,6,7,8,9,10,11,12,13,14]))),kv=(0,X.lazy)(()=>G(()=>import(`./ChimeraReviewsView-BNQE5kRx.js`).then(e=>({default:e.ChimeraReviewsView})),__vite__mapDeps([62,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,37])));function Av({sessionId:e,desktopShell:t}){let{t:n}=U(),{currentView:r,terminalOpen:i,setTerminalOpen:a}=q(jn(e=>({currentView:e.currentView,terminalOpen:e.terminalOpen,setTerminalOpen:e.setTerminalOpen})));return(0,Z.jsxs)(Z.Fragment,{children:[e&&(0,Z.jsxs)(`div`,{className:K(`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)(iv,{})}),(0,Z.jsx)(Rf,{})]}),(0,Z.jsx)(`div`,{className:K(`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)(xs,{level:`panel`,name:n(`activity:panels.chat`),children:(0,Z.jsx)($p,{})})}),r===`settings`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.settings`),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(p_,{})})}),r===`memory`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.sageMemory`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{label:n(`common:loadingNamed`,{name:n(`activity:panels.sageMemory`)})}),children:(0,Z.jsx)(xv,{})})}),r===`roster`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.agentRoster`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{label:n(`common:loadingNamed`,{name:n(`activity:panels.agentRoster`)})}),children:(0,Z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:(0,Z.jsx)(lv,{})})})}),r===`context`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.contextDashboard`),children:(0,Z.jsx)(ym,{})}),r===`setup`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.setup`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(jv,{})})})}),r===`goal`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.goal`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(gv,{onClose:()=>Pa(`chat`)})})})}),r===`sddhub`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.sddHub`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Cv,{})})})}),r===`kanban`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.kanban`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(_v,{onClose:()=>Pa(`chat`)})})})}),r===`sessions`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.sessions`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(wv,{})})})}),r===`session-inspect`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.sessionInspect`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{label:n(`common:loadingNamed`,{name:n(`activity:panels.sessionInspect`)})}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Tv,{})})})}),r===`chronicle`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.chronicle`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(dv,{})})})}),r===`intake`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.requirementsIntake`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Sv,{})})})}),r===`prompts`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:nav.prompts`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{label:n(`common:loadingNamed`,{name:n(`activity:nav.prompts`)})}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(yv,{})})})}),r===`debug`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.debugDashboard`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(mv,{})})})}),r===`refresh-debug`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.refreshDebug`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(bv,{})})})}),r===`files`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.editor`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{label:n(`common:loadingNamed`,{name:n(`activity:panels.editor`)})}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(fv,{})})})}),r===`changes`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.changes`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{label:n(`common:loadingNamed`,{name:n(`activity:panels.changes`)})}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(uv,{className:`h-full min-h-0`})})})}),r===`mailbox`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.mailbox`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(vv,{className:`h-full min-h-0`})})})}),r===`design-gallery`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.designGallery`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(hv,{className:`h-full`})})})}),r===`skill`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.skill`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Ev,{className:`h-full`})})})}),r===`analytics`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.analytics`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(cv,{})})})}),r===`codemap`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.codemap`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{label:n(`common:loadingNamed`,{name:n(`activity:panels.codemap`)})}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(pv,{})})})}),r===`techstack`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.techstack`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{label:n(`common:loadingNamed`,{name:n(`activity:panels.techstack`)})}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Dv,{})})})}),r===`deadcode`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.deadcode`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{label:n(`common:loadingNamed`,{name:n(`activity:panels.deadcode`)})}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-y-auto`,children:(0,Z.jsx)(Ov,{})})})}),r===`chimera`&&(0,Z.jsx)(xs,{level:`panel`,name:`Chimera Reviews`,children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(kv,{})})})}),i&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.terminal`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{label:n(`common:loadingNamed`,{name:n(`activity:panels.terminal`)})}),children:(0,Z.jsx)(Mv,{desktopShell:t,onClose:()=>a(!1)})})})]})}var jv=(0,X.lazy)(()=>G(()=>import(`./SetupScreen-DWzbXvmU.js`).then(e=>({default:e.SetupScreen})),__vite__mapDeps([63,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,19,20,21,22,23,24,25,31,32]))),Mv=(0,X.lazy)(()=>G(()=>import(`./TerminalPanel-cbM6oQWQ.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,20,21,19,22,65,66])));function Nv(){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 Pv(){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 Fv(){let e=Da(e=>e.snapshot),t=q(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:K(`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)(br,{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 Iv(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 Lv({variant:e}){return e===`success`?(0,Z.jsx)(ii,{className:`h-4 w-4 text-success shrink-0`}):e===`error`?(0,Z.jsx)(Fn,{className:`h-4 w-4 text-destructive shrink-0`}):e===`warn`?(0,Z.jsx)(Rr,{className:`h-4 w-4 text-warning shrink-0`}):(0,Z.jsx)(qt,{className:`h-4 w-4 text-info shrink-0`})}function Rv({item:e,onMarkAsRead:t,onRemove:n}){let{t:r}=U(),i=(0,X.useMemo)(()=>Iv(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:K(`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)(Lv,{variant:e.variant})}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0 pr-1`,children:[(0,Z.jsx)(`div`,{className:K(`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)(vn,{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)(ii,{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)(mr,{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 zv({defaultOpen:e,open:t,onOpenChange:n}={}){let{t:r}=U(),i=fe(e=>e.notifications),a=fe(e=>e.markAsRead),o=fe(e=>e.markAllAsRead),s=fe(e=>e.clearAll),c=fe(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]),m=(0,X.useCallback)(()=>{s()},[s]);return(0,Z.jsxs)(so,{defaultOpen:e,open:t,onOpenChange:n,children:[(0,Z.jsx)(co,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,"data-testid":`notification-menu-trigger`,className:K(`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)(Fr,{className:`h-3.5 w-3.5 text-primary`}):(0,Z.jsx)(Wt,{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)(fo,{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)(Ur,{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:m,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)(Lt,{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:K(`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:K(`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)(Oe,{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)(Rv,{item:e,onMarkAsRead:()=>a(e.id),onRemove:()=>c(e.id)},e.id))})]})]})}function Bv(e){return e.split(`-`).map(e=>e.slice(0,1).toUpperCase()+e.slice(1)).join(` `)}function Vv(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 Hv(){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 Uv({currentView:e,projectName:n,sessionLabel:r,isLoading:i,iteration:a,onPalette:o,onSettings:s}){let{t:c}=U(),{theme:l,setTheme:u,palette:d,setPalette:f}=Pu(),p=t(e=>e.wsConnected),m=j(e=>e.appVersion),h=j(e=>e.latestVersion),g=j(e=>e.updateAvailable),_=j(e=>e.droppedTools),v=l===`system`?typeof window<`u`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:l,y=(0,X.useCallback)(()=>{u(v===`dark`?`light`:`dark`)},[v,u]),b=q(e=>e.toggleSidebar),x=Nv(),S=Pv(),C=x.status===`connected`?`WrongProxy: Connected${x.latencyMs==null?``:` (${x.latencyMs}ms)`} · ${x.url}`:x.status===`error`?`WrongProxy: Unreachable · ${x.url}${x.error?` (${x.error})`:``}`:x.status===`checking`?`WrongProxy: Checking · ${x.url}`:`WrongProxy: Disabled`,w=S.status===`connected`?`HQ: Connected${S.latencyMs==null?``:` (${S.latencyMs}ms)`} · ${S.url}`:S.status===`error`?`HQ: Unreachable · ${S.url}${S.error?` (${S.error})`:``}`:S.status===`checking`?`HQ: Checking · ${S.url}`:`HQ: Disabled`,T=Hv(),E=T?T.memoryUsage.heapUsed/T.heapLimit:0,D=T?.codebaseIndexServer,O=D?.health,k=O?.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:b,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)(Xr,{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:n||`WrongStack`}),(0,Z.jsx)(`span`,{className:`rounded bg-muted/60 px-1 py-0.5 text-[10px] text-muted-foreground font-mono`,children:Bv(e)}),i&&(0,Z.jsx)(`span`,{className:`inline-flex items-center gap-0.5 text-[10px] font-medium text-primary`,children:(0,Z.jsx)(Pi,{className:`h-3 w-3 animate-pulse`})})]})})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,Z.jsx)(Ac,{}),(0,Z.jsx)(zv,{}),(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`,title:v===`dark`?`Switch to light theme`:`Switch to dark theme`,children:v===`dark`?(0,Z.jsx)(Yi,{className:`h-3.5 w-3.5`}):(0,Z.jsx)(ui,{className:`h-3.5 w-3.5`})}),(0,Z.jsxs)(so,{children:[(0,Z.jsx)(co,{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)(Fi,{className:`h-3.5 w-3.5`})})}),(0,Z.jsxs)(fo,{align:`end`,className:`w-48`,children:[(0,Z.jsxs)(po,{onSelect:o,className:`gap-2`,children:[(0,Z.jsx)(dt,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:c(`activity:topbar.command`)})]}),(0,Z.jsxs)(po,{onSelect:s,className:`gap-2`,children:[(0,Z.jsx)(mi,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:c(`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:K(`font-mono font-medium`,p?`text-success`:`text-warning`),children:p?`Connected`:`Offline`})]}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`span`,{children:`WrongProxy`}),(0,Z.jsx)(`span`,{className:K(`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.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`span`,{children:`HQ`}),(0,Z.jsx)(`span`,{className:K(`font-mono font-medium`,S.status===`connected`?`text-success`:S.status===`error`?`text-destructive`:`text-muted-foreground`),children:S.status===`connected`?`Connected`:S.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:n||`WrongStack`}),m?(0,Z.jsxs)(`span`,{className:K(`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-[11px] font-medium tabular-nums`,g&&h&&h!==m?`border-warning/40 bg-warning/10 text-warning`:`border-border/70 bg-muted/50 text-muted-foreground`),title:g&&h&&h!==m?`Update available: v${m} → v${h} — run wstack update`:`WrongStack v${m}`,children:[`v`,m,g&&h&&h!==m?(0,Z.jsxs)(`span`,{className:`text-[10px] opacity-80`,children:[`→ v`,h]}):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:Bv(e)}),(0,Z.jsxs)(`span`,{className:K(`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[11px] font-medium`,i?`bg-primary/10 text-primary`:`bg-muted text-muted-foreground`),children:[i?(0,Z.jsx)(Pi,{className:`h-3 w-3 animate-pulse`}):(0,Z.jsx)(Tt,{className:`h-3 w-3`}),i?`Running`:`Ready`,a?(0,Z.jsxs)(`span`,{className:`tabular`,children:[a.index,a.max>0?`/${a.max}`:``]}):null]}),(0,Z.jsx)(Ac,{showCountWhenZero:!0}),T?(0,Z.jsxs)(`span`,{className:K(`rounded-md border border-border/70 bg-muted/50 px-1.5 py-0.5 text-[11px] font-medium tabular-nums`,E>=.85?`text-destructive`:E>=.6?`text-warning`:`text-success`),title:`WebUI server PID ${T.pid} · heap ${Vv(T.memoryUsage.heapUsed)} / ${Vv(T.heapLimit)}`,children:[`RAM `,Vv(T.memoryUsage.rss)]}):null,D?(0,Z.jsxs)(`span`,{className:K(`rounded-md border border-border/70 bg-muted/50 px-1.5 py-0.5 text-[11px] font-medium tabular-nums`,D.status===`connected`?`text-success`:D.status===`unresponsive`||D.status===`error`?`text-destructive`:D.status===`degraded`||D.status===`connecting`||D.status===`stopping`?`text-warning`:`text-muted-foreground`),title:[`Codebase index: ${O?.status??D.status}`,D.pid?`PID ${D.pid}`:null,O?.latencyMs==null?null:`RTT ${O.latencyMs}ms`,k?`RAM ${Vv(k.memory.rss)}`:null,O?.missedHeartbeats?`missed ${O.missedHeartbeats}`:null].filter(Boolean).join(` · `),children:[`Index `,O?.status??D.status]}):null,_>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:`${_} tool(s) dropped from provider requests due to maxTools limit`,children:[`-`,_,` tools`]}):null]}),(0,Z.jsx)(`div`,{className:`mt-0.5 truncate text-[11px] text-muted-foreground`,children:r||`No named session`})]})}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:o,className:`inline-flex h-8 items-center gap-1.5 rounded-md border border-border/70 bg-background/60 px-2 text-xs text-muted-foreground hover:bg-accent/60 hover:text-foreground`,title:c(`activity:topbar.commandPalette`),children:[(0,Z.jsx)(dt,{className:`h-3.5 w-3.5`}),c(`activity:topbar.command`)]}),(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`,title:v===`dark`?`Switch to light theme`:`Switch to dark theme`,children:v===`dark`?(0,Z.jsx)(Yi,{className:`h-3.5 w-3.5`}):(0,Z.jsx)(ui,{className:`h-3.5 w-3.5`})}),(0,Z.jsxs)(so,{children:[(0,Z.jsx)(co,{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:`${c(`settings:general.paletteSwitcherTitle`)}: ${c(ie(d).labelKey)}`,"aria-label":`${c(`settings:general.paletteSwitcherTitle`)}: ${c(ie(d).labelKey)}`,children:(0,Z.jsx)(Fe,{className:`h-3.5 w-3.5`})})}),(0,Z.jsxs)(fo,{align:`end`,className:`w-56`,children:[(0,Z.jsx)(go,{children:c(`settings:general.paletteHeading`)}),me.map(e=>(0,Z.jsxs)(po,{onSelect:()=>f(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:c(e.labelKey)}),d===e.id?(0,Z.jsx)(ii,{className:`h-3.5 w-3.5 text-primary`,"aria-hidden":!0}):null]},e.id))]})]}),(0,Z.jsx)(Fv,{}),(0,Z.jsx)(zv,{}),(0,Z.jsx)(`button`,{type:`button`,onClick:s,className:K(`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":`wrongproxy-status-button`,children:(0,Z.jsx)(Gr,{className:`h-3.5 w-3.5`})}),(0,Z.jsx)(`button`,{type:`button`,onClick:s,className:K(`inline-flex h-8 w-8 items-center justify-center rounded-md border bg-background/60 transition-colors`,S.status===`connected`?`border-border/70 text-success hover:bg-accent/60`:S.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:w,"aria-label":w,"data-testid":`hq-status-button`,children:(0,Z.jsx)(un,{className:`h-3.5 w-3.5`})}),(0,Z.jsx)(`span`,{role:`status`,"aria-label":p?`Connected`:`Disconnected`,className:K(`inline-flex h-8 w-8 items-center justify-center rounded-md border border-border/70 bg-background/60`,p?`text-success`:`text-warning`),title:p?`Connected`:`Disconnected`,"data-testid":`ws-status-indicator`,children:p?(0,Z.jsx)(qr,{className:`h-3.5 w-3.5`}):(0,Z.jsx)(Sr,{className:`h-3.5 w-3.5`})}),(0,Z.jsx)(`button`,{type:`button`,onClick:s,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:c(`activity:topbar.settings`),children:(0,Z.jsx)(mi,{className:`h-3.5 w-3.5`})})]})]})})]})}(0,X.lazy)(()=>G(()=>import(`./AnalyticsDashboard-nqlWJi6M.js`).then(e=>({default:e.AnalyticsDashboard})),__vite__mapDeps([26,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,20,21,19,22]))),(0,X.lazy)(()=>G(()=>import(`./CodeMap-CLOuNLqN.js`).then(e=>({default:e.CodeMap})),__vite__mapDeps([42,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,19,24]))),(0,X.lazy)(()=>G(()=>import(`./ChronicleDashboard-BWMkG_hu.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]))),(0,X.lazy)(()=>G(()=>import(`./GoalView-BuYUc4OB.js`).then(e=>({default:e.GoalView})),__vite__mapDeps([45,1,2,3,4,5,6,7,8,9,10,11,12,13,14,18,0,15,16,19,20,21,22,23,24,31,46,25,32]))),(0,X.lazy)(()=>G(()=>import(`./ChangesView-CN7NWDeV.js`).then(e=>({default:e.ChangesView})),__vite__mapDeps([36,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,19,20,21,22,23,24,37,38])));var Wv=(0,X.lazy)(()=>G(()=>import(`./CronJobsPanel-CsMIoWVQ.js`).then(e=>({default:e.CronJobsPanel})),__vite__mapDeps([67,1,2,3,4,5,6,7,8,9,10,11,12,13,14,20,0,15,16,21,19,22,25])));(0,X.lazy)(()=>G(()=>import(`./CodeEditor-DZ2k-Mz5.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,19,20,21,22,23,37,38,41,31,33]))),(0,X.lazy)(()=>G(()=>import(`./DebugDashboard-C0tmxxV8.js`).then(e=>({default:e.DebugDashboard})),__vite__mapDeps([43,1,2,3,4,5,6,7,8,9,10,11,12,13,14]))),(0,X.lazy)(()=>G(()=>import(`./DesignGalleryView-lc-XRmVG.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,18,19,20,21,22,23,24]))),(0,X.lazy)(()=>G(()=>import(`./MailboxDetailView-CBV3-Hf2.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,22,23,37]))),(0,X.lazy)(()=>G(()=>import(`./SageTabs-Bw6PDwy3.js`).then(e=>({default:e.SageTabs})),__vite__mapDeps([52,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]))),(0,X.lazy)(()=>G(()=>import(`./AgentRosterView-BVpIFQwi.js`).then(e=>({default:e.AgentRosterView})),__vite__mapDeps([27,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,21,20,19,22,23,28,18,24,29,30,25,31,32,33,34,35]))),(0,X.lazy)(()=>G(()=>import(`./KanbanView-DQK6adut.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,20,21,19,22,25,28,18,23,24,48]))),(0,X.lazy)(()=>G(()=>import(`./OfficeMapPanel-DnbdkXL1.js`).then(e=>({default:e.OfficeMapPanel})),__vite__mapDeps([34,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,20,21,19,22,35])));var Gv=(0,X.lazy)(()=>G(()=>import(`./ProcessMonitor-CHNNqCk9.js`).then(e=>({default:e.ProcessMonitor})),__vite__mapDeps([17,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,19,20,21,22,23,24,25]))),Kv=(0,X.lazy)(()=>G(()=>import(`./QueuePanel-CzTXq6j4.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,21,20,19,22,25])));(0,X.lazy)(()=>G(()=>import(`./RefreshDebugView-d9iU3sFX.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,21]))),(0,X.lazy)(()=>G(()=>import(`./SddHub-Cdow0Exb.js`).then(e=>({default:e.SddHub})),__vite__mapDeps([54,1,2,3,4,5,6,7,8,9,10,11,12,13,14,18,0,15,16,19,20,21,22,23,24,25,31,28,48,55]))),(0,X.lazy)(()=>G(()=>import(`./SessionsDashboard-DkaNF5lx.js`).then(e=>({default:e.SessionsDashboard})),__vite__mapDeps([56,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,19,20,21,22,23,24,57,46,25,31,32]))),(0,X.lazy)(()=>G(()=>import(`./SetupScreen-DWzbXvmU.js`).then(e=>({default:e.SetupScreen})),__vite__mapDeps([63,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,19,20,21,22,23,24,25,31,32]))),(0,X.lazy)(()=>G(()=>import(`./SkillDetailView-Bjq8GkDB.js`).then(e=>({default:e.SkillDetailView})),__vite__mapDeps([59,1,2,3,4,5,6,7,8,9,10,11,12,13,14,18,0,15,16,19,20,21,22,23,24,25,37]))),(0,X.lazy)(()=>G(()=>import(`./SpecsView-ok8HZ8ws.js`).then(e=>({default:e.SpecsView})),__vite__mapDeps([55,1,2,3,4,5,6,7,8,9,10,11,12,13,14,18,0,15,16,19,20,21,22,23,24,31]))),(0,X.lazy)(()=>G(()=>import(`./TechStackView-CQ9AdoBa.js`).then(e=>({default:e.TechStackView})),__vite__mapDeps([60,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,20,0,16,21,19,22,31,32]))),(0,X.lazy)(()=>G(()=>import(`./TerminalPanel-cbM6oQWQ.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,20,21,19,22,65,66])));function qv(){let{t:e}=U(),{theme:n}=Pu(),r=ta(),{currentView:i,sidebarOpen:a,toggleSidebar:o,setSearchOpen:s,setSidebarOpen:c,setInspectorTab:u,setPaletteOpen:d,setShortcutsOpen:f,setModelSwitcherOpen:p,setPromptLibraryOpen:m,toggleInspector:h,setFleetMonitorOpen:g,setAgentsMonitorOpen:_,processMonitorOpen:v,setProcessMonitorOpen:y,queuePanelOpen:b,setQueuePanelOpen:x,cronJobsOpen:C,setCronJobsOpen:w,setTerminalOpen:T}=q(jn(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}))),E=J(e=>e.isLoading),D=J(e=>e.messages.length),O=ye(e=>e.info),k=ye(e=>e.promptedThisSession);(0,X.useEffect)(()=>{!O||O.chosen||O.variants.length!==0&&(D>0||k||ye.getState().openPicker())},[O,D,k]);let A=j(e=>e.iteration),M=j(e=>e.projectName),ee=j(e=>e.session?.title),N=j(e=>e.session?.id),F=P()??N,I=q(e=>F?e.sessionNicknames[F]:void 0),te=q(e=>e.sideContextBreakdownOpen),L=q(e=>e.setSideContextBreakdownOpen);B(e=>e.agents),qo({setPaletteOpen:d,setSearchOpen:s,setShortcutsOpen:f,setModelSwitcherOpen:p,setPromptLibraryOpen:m,setFleetMonitorOpen:g,setAgentsMonitorOpen:_,setProcessMonitorOpen:y,setQueuePanelOpen:x,setCronJobsOpen:w,setTerminalOpen:T}),(0,X.useEffect)(()=>{typeof window>`u`||(window.location.pathname===`/debug`?Na(`debug`):window.location.pathname===`/analytics`?Na(`analytics`):window.location.pathname===`/refresh-debug`&&Na(`refresh-debug`))},[]),(0,X.useEffect)(()=>{let e=e=>{let{filePath:n}=e.detail;q.getState().setCurrentView(`files`);let r=V(t.getState().wsUrl);r&&r.send({type:`files.read`,payload:r.withSession({filePath:n})})};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=S.getState().openFiles.find(e=>e.path===n);if(!r)return;let i=V(t.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:R}=$i();(0,X.useEffect)(()=>{R&&q.getState().sidebarOpen&&c(!1)},[R,c]);let z=R&&a;return aa(),Zo(),Yo(),(0,X.useEffect)(()=>{let e=[];if(E){let t=A?` iter ${A.index}${A.max?`/${A.max}`:``}`:``;e.push(`●${t}`)}let t=I?.trim()||ee?.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`}},[E,A,M,ee,I]),Xo({toggleSidebar:o,setSearchOpen:s,toggleInspector:h,setInspectorTab:u}),(0,Z.jsxs)(`div`,{"data-shell":r?`desktop`:`browser`,className:K(`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)(Mo,{desktopShell:r}),a&&i!==`setup`&&(0,Z.jsx)(Au,{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`,...z?{inert:!0}:{},children:[i!==`setup`&&(0,Z.jsx)(Uv,{currentView:i,projectName:M,sessionLabel:I||ee||F||void 0,isLoading:E,iteration:A??null,onPalette:()=>d(!0),onSettings:()=>Fa(`settings`)}),i!==`setup`&&(0,Z.jsx)(`div`,{className:K(i!==`chat`&&`ws-view-parked`),...i===`chat`?{}:{inert:!0,"aria-hidden":!0},children:(0,Z.jsx)(al,{})}),i!==`setup`&&(0,Z.jsx)(us,{}),i!==`setup`&&(0,Z.jsx)(Iu,{}),(0,Z.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col`,children:(0,Z.jsx)(Av,{sessionId:F??null,desktopShell:r})})]}),i!==`setup`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(xs,{level:`panel`,name:e(`activity:panels.inspector`),children:(0,Z.jsx)(jc,{})}),F&&(0,Z.jsx)(xs,{level:`panel`,name:e(`activity:panels.workspaceInspector`),children:(0,Z.jsx)(ov,{sessionId:F})})]}),v&&(0,Z.jsx)(xs,{level:`panel`,name:e(`activity:panels.processMonitor`),children:(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)(Gv,{open:v,onClose:()=>y(!1)})})}),b&&(0,Z.jsx)(xs,{level:`panel`,name:e(`activity:panels.queue`),children:(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)(Kv,{open:b,onClose:()=>x(!1)})})}),C&&(0,Z.jsx)(xs,{level:`panel`,name:e(`activity:panels.cronJobs`),children:(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)(Wv,{open:C,onClose:()=>w(!1)})})}),(0,Z.jsx)(zc,{}),te&&(0,Z.jsx)(ys,{open:te,onClose:()=>L(!1)}),(0,Z.jsx)(ss,{}),(0,Z.jsx)(ju,{}),(0,Z.jsx)(Ja,{}),(0,Z.jsx)(ls,{}),(0,Z.jsx)(Ga,{}),(0,Z.jsx)(Go,{}),(0,Z.jsx)(sl,{}),(0,Z.jsx)(Xc,{}),(0,Z.jsx)(Ss,{}),(0,Z.jsx)(l,{})]})}function Jv(){return(0,Z.jsx)(xs,{children:(0,Z.jsx)(Nu,{defaultTheme:`system`,children:(0,Z.jsx)(qv,{})})})}eo.createRoot(d(document.getElementById(`root`))).render((0,Z.jsx)(X.StrictMode,{children:(0,Z.jsx)(Jv,{})}));export{so as A,Es as C,ws as D,Os as E,po as M,co as N,ns as O,dc as S,Ds as T,Pu as _,Fh as a,vc as b,Th as c,em as d,Vp as f,rp as g,ap as h,Ph as i,fo as j,es as k,sh as l,dp as m,Z_ as n,Nh as o,Mp as p,q_ as r,Eh as s,$_ as t,Pm as u,Nl as v,ks as w,_c as x,Al as y};
144
+ 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)(Ua,{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:x,onChange:e=>S(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:C,onChange:e=>w(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)(Ra,{children:[(0,Z.jsx)(Y,{variant:`outline`,onClick:()=>t(!1),children:a(`common:action.cancel`)}),(0,Z.jsx)(Y,{onClick:T,children:a(E?`settings:mcp.saveChanges`:`settings:mcp.addServer`)})]})]})})}function gh({server:e,isAdded:t,onAdd:n}){let{t:r}=U();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)(Pm,{variant:`secondary`,className:`text-xs shrink-0`,children:e.badge}),(0,Z.jsx)(Pm,{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)(ii,{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)(We,{className:`w-4 h-4 mr-1`}),r(`common:action.add`)]})})]})}function _h(){let e=ua(),{t}=U(),[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,m]=(0,X.useState)(!1),[h,g]=(0,X.useState)(),[_,v]=(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]),p.success(H.t(`settings:mcp.toastAdded`,{name:t.server.name}))}},i=e=>{if(e.type===`mcp.server.removed`){let t=e.payload;r(e=>e.filter(e=>e.name!==t.name)),p.success(H.t(`settings:mcp.toastRemoved`,{name:t.name}))}},o=e=>{if(e.type===`mcp.server.updated`){let t=e.payload;r(e=>e.map(e=>e.name===t.server.name?t.server:e))}},s=e=>{if(e.type===`mcp.server.discovered`){let t=e.payload;r(e=>e.map(e=>e.name===t.name?{...e,status:`sleeping`,tools:t.tools}:e)),v(null),p.success(H.t(`settings:mcp.toastDiscovered`,{count:t.tools.length,name:t.name}))}},c=e=>{if(e.type===`mcp.server.sleeping`){let t=e.payload;r(e=>e.map(e=>e.name===t.name?{...e,status:`sleeping`}:e)),v(null),p.info(H.t(`settings:mcp.toastSleeping`,{name:t.name}))}},l=e=>{if(e.type===`mcp.server.waking`){let t=e.payload;r(e=>e.map(e=>e.name===t.name?{...e,status:`connecting`}:e))}},u=e=>{if(e.type===`mcp.server.connected`){let t=e.payload;r(e=>e.map(e=>e.name===t.name?{...e,status:`connected`,pid:t.pid,error:void 0,lastError:void 0}:e)),v(null),p.success(H.t(`settings:mcp.toastConnected`,{name:t.name}))}},d=e=>{if(e.type===`mcp.server.reconnected`){let t=e.payload;r(e=>e.map(e=>e.name===t.name?{...e,status:`connected`,error:void 0,lastError:void 0}:e)),v(null),p.success(H.t(`settings:mcp.toastReconnected`,{name:t.name}))}},f=e=>{if(e.type===`mcp.server.disconnected`){let t=e.payload;r(e=>e.map(e=>e.name===t.name?{...e,status:`error`,error:t.reason,lastError:t.reason,pid:void 0}:e)),v(null),p.warn(H.t(`settings:mcp.toastDisconnected`,{name:t.name,reason:t.reason}))}},m=e=>{if(e.type===`mcp.server.error`){let t=e.payload;r(e=>e.map(e=>e.name===t.name?{...e,status:`error`,error:t.error}:e)),v(null),p.error(H.t(`settings:mcp.toastError`,{name:t.name,error:t.error}))}},h=e=>{if(e.type===`mcp.operation_result`){let t=e.payload;t.success||p.error(t.message),v(null)}},g=e.client.on(`mcp.list`,t),_=e.client.on(`mcp.server.added`,n),y=e.client.on(`mcp.server.removed`,i),b=e.client.on(`mcp.server.updated`,o),x=e.client.on(`mcp.server.discovered`,s),S=e.client.on(`mcp.server.sleeping`,c),C=e.client.on(`mcp.server.waking`,l),w=e.client.on(`mcp.server.connected`,u),T=e.client.on(`mcp.server.error`,m),E=e.client.on(`mcp.operation_result`,h),D=e.client.on(`mcp.server.reconnected`,d),O=e.client.on(`mcp.server.disconnected`,f);return a(!0),e.client?.listMcpServers(),()=>{g?.(),_?.(),y?.(),b?.(),x?.(),S?.(),C?.(),w?.(),T?.(),E?.(),D?.(),O?.()}},[e.client]);let y=(0,X.useCallback)(t=>{e.client?.addMcpServer(t)},[e]),b=(0,X.useCallback)(e=>{g(dh(e,!1)),m(!0)},[]),x=(0,X.useCallback)(n=>{qa({title:t(`settings:mcp.removeConfirmTitle`,{name:n}),message:t(`settings:mcp.removeConfirmBody`),confirmLabel:t(`common:action.remove`),danger:!0}).then(t=>{t&&e.client?.removeMcpServer(n)})},[e]),S=(0,X.useCallback)(e=>{l(e),g(void 0),d(!0)},[]),C=(0,X.useCallback)(t=>{e.client?.updateMcpServer(t)},[e]),w=(0,X.useCallback)(t=>{v(t),e.client?.wakeMcpServer(t)},[e]),T=(0,X.useCallback)(t=>{v(t),e.client?.sleepMcpServer(t)},[e]),E=(0,X.useCallback)(t=>{v(t),e.client?.discoverMcpServer(t)},[e]),D=(0,X.useCallback)(()=>{a(!0),e.client?.listMcpServers()},[e]),O=n.filter(e=>e.status===`connected`).length,k=n.filter(e=>e.status===`sleeping`).length,A=new Set(n.map(e=>e.name));return(0,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)(Jn,{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:O,sleeping:k,total:n.length})})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsxs)(Y,{variant:`outline`,size:`sm`,onClick:D,disabled:i,children:[i?(0,Z.jsx)(pr,{className:`w-4 h-4 animate-spin`}):null,t(`common:action.refresh`)]}),(0,Z.jsxs)(Y,{size:`sm`,onClick:()=>{g(void 0),m(!0)},children:[(0,Z.jsx)(We,{className:`w-4 h-4 mr-1`}),t(`settings:mcp.addCustom`)]})]})]}),(0,Z.jsxs)(Es,{value:o,onValueChange:e=>s(e),children:[(0,Z.jsxs)(Ds,{children:[(0,Z.jsxs)(Os,{value:`recommended`,children:[(0,Z.jsx)(wn,{className:`w-3.5 h-3.5 mr-1`}),t(`settings:mcp.tabRecommended`)]}),(0,Z.jsx)(Os,{value:`list`,children:t(`settings:mcp.tabServers`)}),(0,Z.jsx)(Os,{value:`add`,children:t(`settings:mcp.tabAddCustom`)})]}),(0,Z.jsxs)(ks,{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:uh.map(e=>(0,Z.jsx)(gh,{server:e,isAdded:A.has(e.name),onAdd:()=>b(e)},e.name))})]}),(0,Z.jsx)(ks,{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)(pr,{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)(Jn,{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)(mh,{server:e,onWake:()=>w(e.name),onSleep:()=>T(e.name),onDiscover:()=>E(e.name),onEdit:()=>S(e),onRemove:()=>x(e.name)},e.name))}),(0,Z.jsx)(ks,{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)(hh,{open:f,onOpenChange:e=>{e||(m(!1),g(void 0))},prefillConfig:h,onSave:y}),(0,Z.jsx)(hh,{open:u,onOpenChange:d,server:c,onSave:C})]})}function vh({syncPref:e}){let{t}=U(),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)(Jn,{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)(Ua,{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)(Jn,{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)(Ua,{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)(Ua,{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)(Jn,{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)(_h,{}):(0,Z.jsxs)(`div`,{className:`text-center py-6 text-muted-foreground`,children:[(0,Z.jsx)(Jn,{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)(ei,{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 yh({syncPref:e}){let{t}=U(),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)(Bi,{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 bh({syncPref:e}){let{t}=U(),n=W(e=>e.reasoningEffort),r=j(e=>e.reasoningEffortLevels),i=qc(r,n).map(e=>({value:e,label:t(Kc(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:Jc(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 xh({provider:e,catalogModels:n,currentCatalogProvider:r,isLoadingModels:i,isSwitching:a,setIsLoadingModels:o,onModelSelect:s,refreshModels:c}){let l=t(e=>e.model),{t:u}=U();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:r?.name||e}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e})]}),(0,Z.jsx)(Y,{variant:`ghost`,size:`sm`,onClick:()=>{o(!0),c(e)},children:(0,Z.jsx)(zi,{className:K(`h-4 w-4`,i&&`animate-spin`)})})]}),i&&!n[e]?(0,Z.jsxs)(`div`,{className:`flex items-center justify-center py-8`,children:[(0,Z.jsx)(pr,{className:`h-6 w-6 animate-spin text-muted-foreground`}),(0,Z.jsx)(`span`,{className:`ml-2 text-muted-foreground`,children:u(`settings:model.loading`)})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(xm,{options:(n[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:l,onSelect:s,disabled:a,emptyMessage:u(`settings:model.notFound`)}),a?(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`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:u(`settings:model.selectProviderFirst`)})]})})}var Sh=[{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.`}],Ch={};function wh({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,Ch),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)(Ki,{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)(mr,{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)(We,{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)(mr,{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)(We,{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:Sh.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:Sh.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 Th(){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 Eh({models:e,onChange:n}){let{t:r}=U(),[i,a]=(0,X.useState)(!1),[o,s]=(0,X.useState)(``),[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.useRef)(void 0),_=(0,X.useRef)(null),v=t(e=>e.wsUrl),y=(0,X.useCallback)(e=>{if(!e.trim()){l([]);return}d(!0);let t=V(v),n=t.on(`provider.models.search_result`,t=>{let n=t.payload;!n||n.query!==e.trim()||(l(n.matches??[]),d(!1))});t.searchProviderModels(e.trim(),8),setTimeout(()=>{n?.(),d(!1)},5e3)},[v]);(0,X.useEffect)(()=>{if(g.current&&clearTimeout(g.current),!o.trim()){l([]);return}return g.current=setTimeout(()=>y(o),250),()=>{g.current&&clearTimeout(g.current)}},[o,y]);let b=(0,X.useCallback)((t,r)=>{if(!t||e.some(e=>e.id===t))return;let i={id:t,name:r?.name??r?.modelId??t,...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}:{}}};n([...e,i]),s(``),l([]),a(!1)},[e,n]),x=(0,X.useCallback)(t=>{n(e.filter(e=>e.id!==t))},[e,n]),S=(0,X.useCallback)(()=>{let e=m.trim();e&&(b(e),h(``),p(!1))},[m,b]);return(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground block`,children:r(`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:K(`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:()=>x(e.id),className:`opacity-0 group-hover:opacity-100 transition-opacity text-muted-foreground hover:text-destructive`,children:(0,Z.jsx)(mr,{className:`h-3 w-3`})})]},e.id))}),i?(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)(vi,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,Z.jsx)(Ua,{placeholder:r(`setup:screen.custom.modelSearchPlaceholder`),value:o,onChange:e=>s(e.target.value),className:`text-sm pl-8`,autoFocus:!0}),u&&(0,Z.jsx)(pr,{className:`absolute right-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 animate-spin text-muted-foreground`})]}),c.length>0&&(0,Z.jsx)(`div`,{className:`space-y-1 max-h-40 overflow-y-auto`,children:c.map(e=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>b(e.modelId,e),className:K(`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)(ii,{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}`))}),!u&&o.trim()&&c.length===0&&(0,Z.jsxs)(`div`,{className:`text-xs text-muted-foreground text-center py-2`,children:[r(`setup:screen.custom.noCatalogMatch`),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{p(!0),setTimeout(()=>_.current?.focus(),50)},className:`ml-1 text-accent underline underline-offset-2 hover:text-accent/80`,children:r(`setup:screen.custom.useCustomId`)})]}),f&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Ua,{ref:_,placeholder:r(`setup:screen.custom.customModelIdPlaceholder`),value:m,onChange:e=>h(e.target.value),className:`text-sm flex-1`,onKeyDown:e=>{e.key===`Enter`&&S()}}),(0,Z.jsxs)(Y,{type:`button`,size:`sm`,onClick:S,disabled:!m.trim(),children:[(0,Z.jsx)(ii,{className:`h-3.5 w-3.5 mr-1`}),r(`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:()=>{a(!1),s(``),l([]),p(!1),h(``)},className:`text-xs`,children:r(`setup:screen.custom.cancel`)})})]}):(0,Z.jsxs)(Y,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>a(!0),className:`text-xs`,children:[(0,Z.jsx)(We,{className:`h-3.5 w-3.5 mr-1`}),r(`setup:screen.custom.addModel`)]}),e.length>0&&(0,Z.jsxs)(`p`,{className:`text-[10px] text-muted-foreground`,children:[e.length,` `,e.length===1?r(`setup:screen.custom.modelSingular`):r(`setup:screen.custom.modelPlural`)]})]})}function Dh({maskedKey:e,className:t}){let{t:n}=U(),[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:K(`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)(ii,{className:`h-3 w-3 text-success`}):(0,Z.jsx)(Bt,{className:`h-3 w-3`})})]})}var Oh={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(Oh);var kh=[{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_...`}}],Ah=[{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`}}],jh=Object.fromEntries([...kh,...Object.values(Oh),...Ah].map(e=>[e.id,e]));function Mh(){return Ah.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 Nh(){return Object.values(jh).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 Ph=`openai-compatible`,Fh=Mh(),Ih=[{kind:`chatgpt`,label:`ChatGPT`,subtitle:`Plus / Pro / Team → openai-codex`,icon:(0,Z.jsx)(Tt,{className:`h-5 w-5`})},{kind:`claude`,label:`Claude`,subtitle:`Pro / Max → anthropic-oauth`,icon:(0,Z.jsx)(Pi,{className:`h-5 w-5`})},{kind:`copilot`,label:`GitHub Copilot`,subtitle:`Copilot → github-copilot`,icon:(0,Z.jsx)(st,{className:`h-5 w-5`})}],Lh=[`awaiting_browser`,`awaiting_code`,`exchanging`,`fetching_models`];function Rh({ws:e,savedByKind:t}){let{t:n}=U(),[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)(``),[m,h]=(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`?(p.success(t.message??H.t(`settings:oauth.signedInToast`,{provider:t.providerId??t.kind})),c(null),o(``),u(null),f(``)):t.phase===`error`&&p.error(t.message??H.t(`settings:oauth.signInFailed`))});return()=>t?.()},[e]);let g=(0,X.useCallback)(t=>{i(e=>({...e,[t]:{phase:t===`copilot`?`awaiting_code`:`awaiting_browser`}})),e.startOAuth(t)},[e]),_=(0,X.useCallback)((t,n)=>{i(e=>({...e,[t]:{phase:t===`copilot`?`awaiting_code`:`awaiting_browser`}})),e.startOAuth(t,n)},[e]),v=(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]),y=(0,X.useCallback)(t=>{e.cancelOAuth(t),i(e=>({...e,[t]:{phase:`idle`}})),c(null)},[e]),b=(0,X.useCallback)(t=>{let n=a.trim();n&&(e.submitOAuthCode(t,n),i(e=>({...e,[t]:{...e[t],phase:`exchanging`}})))},[a,e]),x=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:Ih.map(e=>{let t=r[e.kind],i=Lh.includes(t.phase),p=x[e.kind],S=p?.length??0,C=m===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:()=>y(e.kind),className:`shrink-0 lg:w-full`,children:n(`common:action.cancel`)}):(0,Z.jsx)(Y,{size:`sm`,onClick:()=>g(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)(pr,{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)(Qn,{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)(Ua,{placeholder:n(`activity:oauth.httpLocalhostCallbackCode`),value:a,onChange:e=>o(e.target.value),className:`font-mono text-xs`,onKeyDown:t=>{t.key===`Enter`&&b(e.kind)}}),(0,Z.jsx)(Y,{size:`sm`,onClick:()=>b(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)(Qn,{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)(pr,{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)(pr,{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)(Cr,{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)(Fn,{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:()=>h(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)(dn,{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&&p&&(0,Z.jsxs)(`div`,{className:`mt-2 space-y-1.5`,children:[p.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)(Cr,{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:()=>_(e.kind,t.id),className:`h-6 px-1.5 text-[11px]`,title:n(`settings:oauth.retryLogin`),children:[(0,Z.jsx)(zi,{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)(Ua,{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`&&v(e.kind)}}),(0,Z.jsx)(Y,{size:`sm`,onClick:()=>v(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)(We,{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)(Ua,{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`&&v(e.kind)}}),(0,Z.jsx)(Y,{size:`sm`,onClick:()=>v(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)(We,{className:`h-3.5 w-3.5 mr-1`}),n(`settings:oauth.newAccount`)]})})]},e.kind)})})]})}function zh({open:e,providerId:t,modelCount:n,onConfirm:r,onCancel:i}){let a=(0,X.useRef)(null),{t:o}=U();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)(Ha,{open:e,onOpenChange:e=>{e||i()},children:(0,Z.jsxs)(za,{className:`sm:max-w-md border-warning/50`,ref:a,tabIndex:-1,"data-clear-allowlist-dialog":!0,children:[(0,Z.jsxs)(La,{children:[(0,Z.jsxs)(Ba,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Rr,{className:`h-5 w-5 text-warning`}),o(`settings:allowlist.title`)]}),(0,Z.jsx)(Va,{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)(Ra,{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 Bh({ws:e,onSelect:t,onClose:n}){let{t:r}=U(),[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)(mr,{className:`h-4 w-4`})})]}),(0,Z.jsxs)(`div`,{className:`relative mb-3`,children:[(0,Z.jsx)(vi,{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)(pr,{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 Vh=new Set([`__proto__`,`constructor`,`prototype`,`__defineGetter__`,`__defineSetter__`,`__lookupGetter__`,`__lookupSetter__`]);`document`in globalThis&&Mt({jitless:!0});var Hh=[`text`,`image`,`audio`,`video`,`pdf`],Uh=[`none`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],Wh=Ut().int().nonnegative(),Gh=Ut().finite(),Kh=He({context:Wh.optional(),output:Wh.optional(),input:Wh.optional()}),qh=He({input:Gh.optional(),output:Gh.optional(),cache_read:Gh.optional(),cache_write:Gh.optional(),cache_write_5m:Gh.optional(),cache_write_1h:Gh.optional(),context_over_200k:Gh.optional(),reasoning:Gh.optional(),input_audio:Gh.optional(),output_audio:Gh.optional()}),Jh=He({input:Ni(De().min(1)).optional(),output:Ni(De().min(1)).optional()}),Yh=Or([He({type:qe(`toggle`)}),He({type:qe(`effort`),values:Ni(Re(Uh)).optional()}),He({type:qe(`budget_tokens`),min:Ut().optional(),max:Ut().optional()})]),Xh=e=>({message:`${e} id is a forbidden prototype-pollution key`}),Zh=He({id:De().min(1).refine(e=>!Vh.has(e),Xh(`Model`)),name:De().min(1),description:De().optional(),family:De().optional(),attachment:fn().optional(),reasoning:fn().optional(),reasoning_options:Or([Yh,Ni(Yh)]).optional(),interleaved:Or([fn(),He({field:De().optional()})]).optional(),tool_call:fn().optional(),structured_output:fn().optional(),temperature:fn().optional(),knowledge:De().optional(),release_date:De().optional(),last_updated:De().optional(),open_weights:fn().optional(),modalities:Jh.optional(),cost:qh.optional(),limit:Kh.optional(),status:De().optional(),experimental:fn().optional()}),Qh=He({id:De().min(1).refine(e=>!Vh.has(e),Xh(`Provider`)),name:De().min(1),env:Ni(De()).optional(),npm:De().optional(),api:De().optional(),doc:De().optional(),models:Pr(De(),Zh)});Pr(De(),Qh);function $h(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 eg(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 tg=[{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 ng({providerId:e,modelId:t,initialModelsDev:n,onSave:r,onCancel:i}){let{t:a}=U(),[o,s]=(0,X.useState)(!1),[c,l]=(0,X.useState)(()=>$h(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=eg(c,n),i=Zh.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=Zh.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:K(`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:K(`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:Hh.map(e=>{let t=c.inputModalities.includes(e);return(0,Z.jsx)(`button`,{type:`button`,onClick:()=>_(`inputModalities`,e),className:K(`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:Hh.map(e=>{let t=c.outputModalities.includes(e);return(0,Z.jsx)(`button`,{type:`button`,onClick:()=>_(`outputModalities`,e),className:K(`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:tg.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)(mr,{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)(ii,{className:`h-3.5 w-3.5`}),a(`common:action.save`)]})]})]})}function rg(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 ig(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 ag(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 og(e){let t=e?.modalities;return{input:Array.isArray(t?.input)?t.input:[],output:Array.isArray(t?.output)?t.output:[]}}var sg={text:wr,image:je,audio:Bn,video:Ui,pdf:wr};function cg({providerId:e,models:t,customModels:n,ws:r,pickedModelId:i,onPickModel:a}){let{t:o}=U(),[s,c]=(0,X.useState)(null),[l,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(!1),[m,h]=(0,X.useState)(``),g=(0,X.useMemo)(()=>rg(t,n),[t,n]),_=(0,X.useMemo)(()=>{let e=m.trim().toLowerCase();return e?g.filter(t=>t.modelId.toLowerCase().includes(e)||(t.name?.toLowerCase().includes(e)??!1)):g},[g,m]),v=(0,X.useCallback)(t=>{r.removeCustomModel(e,t),p.success(o(`settings:providerModels.modelRemoved`,{model:t}))},[r,e,o]),y=(0,X.useCallback)((t,n)=>{r.setCustomModel(e,t,{modelsDev:n}),c(null),p.success(o(`settings:providerModels.modelSaved`,{model:t}))},[r,e,o]),b=(0,X.useCallback)((t,n)=>{r.setCustomModel(e,t,{modelsDev:n}),u(!1),p.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)(We,{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)(We,{className:`h-3.5 w-3.5`}),o(`settings:providerModels.addCustom`)]})]}),g.length>0&&(0,Z.jsxs)(`div`,{className:`overflow-hidden rounded-lg border border-border/70`,children:[g.length>8&&(0,Z.jsxs)(`div`,{className:`relative border-b border-border/40 bg-muted/10`,children:[(0,Z.jsx)(vi,{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:m,onChange:e=>h(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:_.map(t=>{let n=ig(t.modelsDev),r=t.maxOutput??t.modelsDev?.limit?.output,l=typeof r==`number`?r.toLocaleString():void 0,u=ag(t.modelsDev),d=og(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)(vn,{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)(Ue,{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=sg[e]??wr;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)(oi,{className:`h-3.5 w-3.5 text-muted-foreground`,"aria-label":o(`activity:modelListEditor.tools`)}),f?.reasoning&&(0,Z.jsx)(Zn,{className:`h-3.5 w-3.5 text-muted-foreground`,"aria-label":o(`activity:modelListEditor.reasoning`)}),f?.vision&&(0,Z.jsx)(ki,{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:K(`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)(ii,{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)(ii,{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)(jr,{className:`h-3.5 w-3.5`})}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>v(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)(Lt,{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)(ng,{providerId:e,modelId:t.modelId,initialModelsDev:t.modelsDev??{},onSave:y,onCancel:()=>c(null)})})},`${t.modelId}-edit`)]},t.modelId)})})]})})]}),g.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)(Bh,{ws:r,onSelect:b,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)(mr,{className:`h-4 w-4`})})]}),(0,Z.jsx)(ng,{providerId:e,modelId:``,initialModelsDev:{},onSave:y,onCancel:()=>f(!1)})]})]})]})}function lg(){return{inFlight:!1,last:null,picked:null}}function ug(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 dg(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 fg(e){return(e?.length??0)>0}function pg(e,t){return`Allowlist cleared for ${e} — ${t} model${t===1?``:`s`} removed`}function mg(e){return e.length>0}function hg(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 gg=3e3;function _g({providerId:e,savedPickedModelId:t,savedModels:n,savedCustomModels:r,ws:i,onPickModel:a,onClearModels:o,onUndoClear:s}){let[c,l]=(0,X.useState)(()=>lg()),{t:u}=U(),[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:ug(t.payload)}))}),[i,e]);let m=(0,X.useCallback)(()=>{l(e=>({...e,inFlight:!0})),i.probeProvider(e,gg)},[i,e]),h=(0,X.useCallback)((e,t)=>{l(e=>({...e,picked:t})),a?.(e,t)},[a]),g=(0,X.useCallback)(()=>{f(!0)},[]),_=(0,X.useCallback)(()=>{f(!1)},[]),v=(0,X.useCallback)(()=>{f(!1);let t=n?[...n]:[];l(e=>({...e,picked:null,last:null})),o?o(e):i.clearProviderModels(e),mg(t)&&p.undoable(pg(e,t.length),()=>{let n=hg({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]),y=(0,X.useMemo)(()=>c.picked??t??n?.[0]??``,[c.picked,t,n]),b=(0,X.useMemo)(()=>dg(c),[c]),x=(0,X.useMemo)(()=>fg(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)(ji,{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`)}),y?(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:y}):(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:m,disabled:c.inFlight,"aria-label":u(`activity:providerModels.refreshAria`,{provider:e}),className:`h-8 px-2 text-xs`,children:[c.inFlight?(0,Z.jsx)(pr,{className:`h-3.5 w-3.5 animate-spin`}):(0,Z.jsx)(zi,{className:`h-3.5 w-3.5`}),c.inFlight?u(`activity:providerModels.probing`):u(`activity:providerModels.refresh`)]}),x&&(0,Z.jsx)(Y,{variant:`ghost`,size:`sm`,onClick:g,"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)(vg,{formatted:b}),(0,Z.jsx)(`div`,{className:`mt-3`,children:(0,Z.jsx)(cg,{providerId:e,models:n??[],customModels:r,ws:i,pickedModelId:y??void 0,onPickModel:h})}),(0,Z.jsx)(zh,{open:d,providerId:e,modelCount:n?.length??0,onConfirm:v,onCancel:_})]})}function vg({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 yg=[`anthropic`,`openai`,`google`,`openai-compatible`];function bg({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:m,ws:h,catalogQuery:g,setCatalogQuery:_}){let{t:v}=U(),[y,b]=(0,X.useState)(null),[x,S]=(0,X.useState)(``),[C,w]=(0,X.useState)(``),[T,E]=(0,X.useState)(!1),[D,O]=(0,X.useState)(!1),[k,A]=(0,X.useState)(``),[j,M]=(0,X.useState)(`openai-compatible`),[ee,N]=(0,X.useState)(``),[P,F]=(0,X.useState)(``),[I,te]=(0,X.useState)([]),L=Th(),R=Th(),z=(0,X.useCallback)(e=>{!x.trim()||!C.trim()||(c(e,x.trim(),C.trim()),S(``),w(``),b(null))},[c,x,C]),ne=(0,X.useCallback)(()=>{k.trim()&&(d(k.trim(),j,ee||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),A(``),M(`openai-compatible`),N(``),F(``),te([]),O(!1))},[d,k,j,ee,P,I]),re=(0,X.useCallback)(e=>{A(e.id),M(Ph),N(e.defaultBaseUrl),e.noAuth&&F(``),te([])},[]),[ie,B]=(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=h.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?.()},[h]);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(``),B(null),ce(!1),p.success(v(`settings:provider.savedToast`,{name:e.name})),e.apiBase&&setTimeout(()=>h.probeProvider(e.id,6e3),700))},[ae,de,c,d,h]),V=g.trim()?t.filter(e=>{let t=g.trim().toLowerCase();return e.id.toLowerCase().includes(t)||e.name.toLowerCase().includes(t)||e.family.toLowerCase().includes(t)}):t,me=V.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)(Ze,{className:`h-4 w-4 text-muted-foreground`}),v(`settings:provider.subscriptionHeading`)]}),(0,Z.jsx)(Rh,{ws:h,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)(At,{className:`h-4 w-4 text-muted-foreground`}),v(`settings:provider.apiKeysHeading`)]}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground mb-3`,children:v(`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)(At,{className:`h-4 w-4 mr-1`}),v(`settings:provider.tabCatalog`)]}),(0,Z.jsxs)(Y,{variant:a===`saved`?`default`:`outline`,size:`sm`,onClick:()=>o(`saved`),children:[(0,Z.jsx)(Ze,{className:`h-4 w-4 mr-1`}),v(`settings:provider.tabSaved`,{count:r.length})]})]}),a===`catalog`&&(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(Ua,{placeholder:v(`settings:provider.searchPlaceholder`,{count:t.length}),value:g,onChange:e=>_(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)(pr,{className:`h-6 w-6 animate-spin text-muted-foreground`}),(0,Z.jsx)(`span`,{className:`ml-2 text-muted-foreground`,children:v(`settings:provider.loadingCatalog`)})]}):V.length===0&&g?(0,Z.jsx)(`div`,{className:`text-center py-8 text-muted-foreground text-sm`,children:v(`settings:provider.noMatch`,{query:g})}):yg.map(t=>{let n=me[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:K(`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:K(`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)(Ze,{className:`h-3 w-3 inline mr-1`}),v(`settings:provider.configured`)]}),n&&(0,Z.jsxs)(`span`,{className:K(`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)(Cr,{className:`h-3 w-3`}):(0,Z.jsx)(Fn,{className:`h-3 w-3`}),n.ok?v(`settings:provider.reachable`):n.status]}),t.envVars[0]&&(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:v(`settings:provider.envVar`,{var:t.envVars[0]})}),r&&(0,Z.jsx)(Cr,{className:`h-4 w-4 text-primary`})]})]}),(0,Z.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[v(`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:ie===t.id?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(Ua,{autoFocus:!0,type:se?`text`:`password`,placeholder:v(`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)(Vi,{className:`h-4 w-4`}):(0,Z.jsx)(ki,{className:`h-4 w-4`})}),(0,Z.jsx)(Y,{size:`sm`,onClick:()=>pe(t),disabled:!ae.trim(),children:v(`common:action.save`)})]}),t.envVars[0]&&(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:v(`settings:provider.orEnv`,{env:t.envVars[0]})})]}):(0,Z.jsxs)(Y,{size:`sm`,variant:`outline`,onClick:()=>{B(t.id),oe(``)},children:[(0,Z.jsx)(Ze,{className:`h-3.5 w-3.5 mr-1`}),v(`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:v(`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)(Jn,{className:`h-3.5 w-3.5`}),v(`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)(Ze,{className:`h-3.5 w-3.5`}),v(`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)(Ee,{className:`h-3.5 w-3.5`}),v(`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`}),v(`settings:provider.modelCount`,{count:fe.models})]})]})]}),(0,Z.jsxs)(Y,{size:`sm`,variant:`outline`,onClick:()=>O(!D),children:[(0,Z.jsx)(We,{className:`h-4 w-4 mr-1`}),v(`settings:provider.addProvider`)]})]}),D&&(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:v(`settings:provider.addCustomHeading`)}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:v(`settings:provider.localServers`)}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:Fh.map(e=>(0,Z.jsx)(Y,{type:`button`,size:`sm`,variant:k===e.id?`default`:`outline`,onClick:()=>re(e),title:e.hint,children:e.label},e.id))})]}),(0,Z.jsx)(Ua,{placeholder:v(`settings:provider.providerIdPlaceholder`),value:k,onChange:e=>A(e.target.value),ref:L.setFieldRef(0),onKeyDown:e=>L.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:j,onChange:e=>M(e.target.value),ref:L.setFieldRef(1),onKeyDown:e=>L.handleKeyDown(e,1),children:[(0,Z.jsx)(`option`,{value:`anthropic`,children:v(`activity:provider.anthropic`)}),(0,Z.jsx)(`option`,{value:`openai`,children:v(`activity:provider.openai`)}),(0,Z.jsx)(`option`,{value:`openai-compatible`,children:v(`activity:provider.openaiCompatible`)}),(0,Z.jsx)(`option`,{value:`google`,children:v(`activity:provider.google`)})]}),(0,Z.jsx)(Ua,{placeholder:v(`activity:provider.baseUrlOptionalEGHttpLocalhost11434V1`),value:ee,onChange:e=>N(e.target.value),ref:L.setFieldRef(2),onKeyDown:e=>L.handleKeyDown(e,2)}),(0,Z.jsx)(Ua,{type:`password`,placeholder:v(`settings:provider.apiKeyOptionalPlaceholder`),value:P,onChange:e=>F(e.target.value),ref:L.setFieldRef(3),onKeyDown:e=>L.handleKeyDown(e,3)}),(0,Z.jsx)(Eh,{models:I,onChange:te}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(Y,{size:`sm`,onClick:ne,disabled:!k.trim(),ref:L.setFieldRef(4),onKeyDown:e=>L.handleKeyDown(e,4,ne),children:v(`common:action.add`)}),(0,Z.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>O(!1),ref:L.setFieldRef(5),onKeyDown:e=>L.handleKeyDown(e,5),children:v(`common:action.cancel`)})]})]}),i?(0,Z.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,Z.jsx)(pr,{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)(Ze,{className:`h-8 w-8 mx-auto mb-2 opacity-50`}),(0,Z.jsx)(`p`,{children:v(`settings:provider.noSaved`)}),(0,Z.jsx)(`p`,{className:`text-sm`,children:v(`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)(Ee,{className:`h-3 w-3`}),v(`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)(At,{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`}),v(`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)(Ze,{className:`h-3.5 w-3.5`}),v(`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)(Lt,{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)(_g,{providerId:e.id,savedPickedModelId:e.pickedModelId,savedModels:e.models,savedCustomModels:e.customModels,ws:h,onPickModel:m}),(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:v(`settings:provider.apiKeysLabel`)}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:v(`settings:provider.keyCount`,{count:e.apiKeys.length})})]}),(0,Z.jsxs)(Y,{size:`sm`,variant:`ghost`,onClick:()=>b(y===e.id?null:e.id),className:`h-8 px-2 text-xs`,children:[(0,Z.jsx)(We,{className:`h-3.5 w-3.5`}),v(`settings:provider.addKey`)]})]}),e.apiKeys.length===0&&!y&&(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:v(`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)(Ze,{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:v(`settings:provider.active`)})]}),(0,Z.jsx)(`div`,{className:`mt-0.5`,children:(0,Z.jsx)(Dh,{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:v(`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)(Lt,{className:`h-3.5 w-3.5 text-destructive`})})]})]},t.label))}),y===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)(Ua,{placeholder:v(`settings:provider.keyLabelPlaceholder`),value:x,onChange:e=>S(e.target.value),ref:R.setFieldRef(0),onKeyDown:e=>R.handleKeyDown(e,0)}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(Ua,{type:T?`text`:`password`,placeholder:v(`settings:provider.apiKeyPlaceholder`),value:C,onChange:e=>w(e.target.value),ref:R.setFieldRef(1),onKeyDown:e=>R.handleKeyDown(e,1)}),(0,Z.jsx)(Y,{size:`icon`,variant:`ghost`,onClick:()=>E(!T),children:T?(0,Z.jsx)(Vi,{className:`h-4 w-4`}):(0,Z.jsx)(ki,{className:`h-4 w-4`})})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(Y,{size:`sm`,onClick:()=>z(e.id),disabled:!x.trim()||!C.trim(),ref:R.setFieldRef(2),onKeyDown:t=>R.handleKeyDown(t,2,()=>z(e.id)),children:v(`settings:provider.saveKey`)}),(0,Z.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>{b(null),S(``),w(``)},ref:R.setFieldRef(3),onKeyDown:e=>R.handleKeyDown(e,3),children:v(`common:action.cancel`)})]})]})]})]})]},e.id))]})]})}var xg=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}))})),Sg=xg.map(e=>e.phase),Cg=xg.flatMap(e=>[...e.roles]),wg=Cg.map(e=>e.role),Tg=[`*`,...Sg,...wg];function Eg(e){if(e===`*`)return`Default (*)`;let t=xg.find(t=>t.phase===e);if(t)return`Phase: ${t.label} (${t.phase})`;let n=Cg.find(t=>t.role===e);return n?`${n.name} (${n.role})`:`Custom: ${e}`}var Dg=[{value:``,label:`mode: inherit`},{value:`auto`,label:`mode: auto`},{value:`on`,label:`mode: on`},{value:`off`,label:`mode: off`}],Og=[{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`}],kg=[{value:``,label:`preserve: inherit`},{value:`on`,label:`preserve: on`},{value:`off`,label:`preserve: off`}],Ag=new Set(Tg);function jg(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 Mg(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 Ng({syncPref:e,candidates:t}){let n=W(),{t:r}=U(),[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=jg(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}`:``,...Mg(n)].filter(Boolean).join(` + `)},y=Array.from(new Set([...Object.keys(n.modelMatrix),i].filter(e=>e&&!Ag.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)(Li,{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:Eg(`*`)}),(0,Z.jsx)(`optgroup`,{label:r(`settings:agent.routingPhasesGroup`),children:xg.map(e=>(0,Z.jsx)(`option`,{value:e.phase,children:Eg(e.phase)},e.phase))}),xg.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:Eg(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:Eg(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:Dg.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:Og.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:kg.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:Eg(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:Dg.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:Og.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:kg.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:e.label},e.value||`inherit`))})]})]},e))})]})}var Pg=[`off`,`low`,`medium`,`high`,`all`],Fg={off:`bg-muted-foreground`,low:`bg-success`,medium:`bg-warning`,high:`bg-warning ring-2 ring-warning/25`,all:`bg-destructive`},Ig={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`},Lg=[`executor`,`skeptic`,`auditor`];function Rg(e){return e&&e.length>0?e.map(e=>({id:e.id,name:e.name,description:e.description})):Lg.map(e=>({id:e,name:e}))}var zg=[{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`}],Bg=[{value:`off`,labelKey:`settings:brainOpt.waitForever`},{value:`30000`,label:`30s`},{value:`60000`,label:`1m`},{value:`120000`,label:`2m`},{value:`300000`,label:`5m`}],Vg=[{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`}],Hg=[{value:`100`,label:`100`},{value:`200`,labelKey:`settings:brainOpt.n200Default`},{value:`400`,label:`400`},{value:`800`,label:`800`},{value:`1600`,label:`1600`}],Ug=[{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`}],Wg=[{value:`10`,label:`10`},{value:`20`,labelKey:`settings:brainOpt.n20Default`},{value:`50`,label:`50`},{value:`100`,label:`100`}],Gg=[{value:`60000`,label:`1m`},{value:`300000`,labelKey:`settings:brainOpt.m5Default`},{value:`900000`,label:`15m`},{value:`3600000`,label:`1h`}],Kg=[{value:`50`,label:`50`},{value:`200`,labelKey:`settings:brainOpt.n200Default`},{value:`500`,label:`500`},{value:`1000`,label:`1000`}],qg=[{value:`default`,labelKey:`settings:brainOpt.default`},{value:`10000`,label:`10s`},{value:`20000`,label:`20s`},{value:`30000`,label:`30s`},{value:`60000`,label:`60s`}],Jg=[{value:`default`,labelKey:`settings:brainOpt.default`},{value:`1`,labelKey:`settings:brainOpt.oneSerial`},{value:`2`,label:`2`},{value:`3`,label:`3`},{value:`5`,label:`5`}],Yg=[{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`}],Xg=[{value:`default`,labelKey:`settings:brainOpt.default`},{value:`200`,label:`200`},{value:`400`,label:`400`},{value:`800`,label:`800`},{value:`1600`,label:`1600`}],Zg=[{value:`default`,labelKey:`settings:brainOpt.default500`},{value:`100`,label:`100`},{value:`500`,label:`500`},{value:`1000`,label:`1000`},{value:`5000`,label:`5000`}],Qg=[{value:`default`,labelKey:`settings:brainOpt.default10m`},{value:`120000`,label:`2m`},{value:`600000`,label:`10m`},{value:`1800000`,label:`30m`},{value:`3600000`,label:`1h`}];function $g(e,t){return e.some(e=>e.value===t)?e:[...e,{value:t,label:t}]}function e_(e,t){return e.map(e=>({value:e.value,label:e.labelKey?t(e.labelKey):e.label??e.value}))}function t_(e){return e===void 0?`default`:String(e)}function n_({level:e}){return(0,Z.jsx)(`span`,{className:K(`inline-block h-2.5 w-2.5 rounded-full`,Fg[e])})}function r_(e){return e.provider?`${e.provider}/${e.model}`:e.model}var i_={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 a_(){let{t:e}=U(),{client:t}=ua(),[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=P();(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)(()=>Rg(n?.personaCatalog),[n?.personaCatalog]),b=Pg.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(r_),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)(Sm,{open:f!==null,mode:`provider-model`,title:f?e(i_[f].title):``,hint:f?e(i_[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)(Zn,{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)(pr,{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:Pg.map(e=>(0,Z.jsxs)(Y,{variant:b===e?`default`:`outline`,size:`sm`,className:K(`gap-1.5 text-xs`,b===e&&`shadow-sm`),disabled:c,onClick:()=>g(e),children:[(0,Z.jsx)(n_,{level:e}),e.toUpperCase()]},e))}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(Ig[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:e_(zg,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:e_(Bg,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:e_($g(Wg,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)(Pm,{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)(Pm,{variant:`outline`,className:`text-[10px] shrink-0`,children:t.then.action}),t.enabled===!1&&(0,Z.jsx)(Pm,{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)(Pm,{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:e_($g(Hg,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:e_($g(Ug,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)(Pm,{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:e_($g(Gg,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:e_($g(Kg,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)(Pm,{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:r_(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(r_),r=e.splice(t,1)[0];r&&e.splice(t-1,0,r),h({models:e})},children:(0,Z.jsx)(zt,{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(r_),r=e.splice(t,1)[0];r&&e.splice(t+1,0,r),h({models:e})},children:(0,Z.jsx)(Pe,{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(r_).filter((e,n)=>n!==t);h({models:e.length>0?e:null})},children:(0,Z.jsx)(mr,{className:`h-3 w-3`})})]},`${r_(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)(We,{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)(Pm,{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:r_(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)(mr,{className:`h-3 w-3`})})]},`${r_(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)(We,{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?r_(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:e_(Vg,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:e_(Vg,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:t_(n.council.perCallTimeoutMs),options:e_($g(qg,t_(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:t_(n.council.maxConcurrency),options:e_($g(Jg,t_(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:t_(n.council.voterMaxTokens),options:e_($g(Yg,t_(n.council.voterMaxTokens)),e),onChange:e=>h({council:{voterMaxTokens:e==="default"?null:Number(e)}}),disabled:c}),(0,Z.jsx)(Q,{label:e(`settings:brain.councilJudgeBudgetLabel`),hint:e(`settings:brain.councilJudgeBudgetHint`),value:t_(n.council.judgeMaxTokens),options:e_($g(Xg,t_(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:t_(n.ledger.maxMemoryEntries),options:e_($g(Zg,t_(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:t_(n.ledger.interventionRetryWindowMs),options:e_($g(Qg,t_(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)(Pm,{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 o_(){let{t:e}=U();return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(ki,{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 s_({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 c_({tool:e,onToggle:t,busy:n}){let{t:r}=U(),[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)(s_,{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)(Pm,{variant:`outline`,className:`px-1.5 text-[10px]`,children:e.permission}),(0,Z.jsx)(Pm,{variant:`outline`,className:`px-1.5 text-[10px]`,children:e.mutating?`mutating`:`read-only`}),(0,Z.jsx)(Pm,{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)(pr,{className:`h-3 w-3 animate-spin`}):e.disabled?(0,Z.jsx)(Xe,{className:`h-3 w-3`}):(0,Z.jsx)(pn,{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)(fr,{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 l_(){let{t:e}=U(),{client:t}=ua(),[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}):p.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,m=n.filter(e=>!e.disabled&&!e.direct).length,h=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)(oi,{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 · `,m,` lazy · `,h,` disabled · `,n.length,` `,`total`]})]}),(0,Z.jsxs)(`div`,{className:`relative`,children:[(0,Z.jsx)(vi,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground`}),(0,Z.jsx)(Ua,{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)(pr,{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)(c_,{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 u_(){let{t:e}=U();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)(ki,{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)(a_,{})]}),(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)(ki,{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)(o_,{})]}),(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)(ki,{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)(l_,{})]})]})}function d_(e,t,n,r,i){e.set({[r]:i}),t({[r]:i}),r===`contextMode`&&typeof i==`string`&&n(i)}var f_=[{id:`general`,icon:(0,Z.jsx)(Fe,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.general`,descKey:`settings:tabs.generalDesc`},{id:`provider`,icon:(0,Z.jsx)(Dn,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.provider`,descKey:`settings:tabs.providerDesc`},{id:`connection`,icon:(0,Z.jsx)(At,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.connection`,descKey:`settings:tabs.connectionDesc`},{id:`agent`,icon:(0,Z.jsx)(Pi,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.agent`,descKey:`settings:tabs.agentDesc`},{id:`execution`,icon:(0,Z.jsx)(cr,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.execution`,descKey:`settings:tabs.executionDesc`},{id:`fallbacks`,icon:(0,Z.jsx)(Li,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.fallbacks`,descKey:`settings:tabs.fallbacksDesc`},{id:`routing`,icon:(0,Z.jsx)(xr,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.routing`,descKey:`settings:tabs.routingDesc`},{id:`fleet`,icon:(0,Z.jsx)(un,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.fleet`,descKey:`settings:tabs.fleetDesc`},{id:`integrations`,icon:(0,Z.jsx)(Ii,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.integrations`,descKey:`settings:tabs.integrationsDesc`},{id:`chimera`,icon:(0,Z.jsx)(Zn,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.chimera`,descKey:`settings:tabs.chimeraDesc`},{id:`context`,icon:(0,Z.jsx)(wr,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.context`,descKey:`settings:tabs.contextDesc`},{id:`logs`,icon:(0,Z.jsx)(Bi,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.logs`,descKey:`settings:tabs.logsDesc`},{id:`security`,icon:(0,Z.jsx)(Rn,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.security`,descKey:`settings:tabs.securityDesc`},{id:`display`,icon:(0,Z.jsx)(Fe,{className:`h-3.5 w-3.5`}),labelKey:`settings:tabs.display`,descKey:`settings:tabs.displayDesc`}];function p_(){let{settingsActiveTab:e,setSettingsActiveTab:n}=q(jn(e=>({settingsActiveTab:e.settingsActiveTab,setSettingsActiveTab:e.setSettingsActiveTab}))),r=em(`settings`),i=(0,X.useRef)(!1),[a,o]=(0,X.useState)(!1),{provider:s,model:c,setProvider:l,setModel:u,wsConnected:d}=t(jn(e=>({provider:e.provider,model:e.model,setProvider:e.setProvider,setModel:e.setModel,wsConnected:e.wsConnected}))),f=ua(),m=f.client,{updatePrefs:h,switchAutonomy:g,switchContextMode:_}=f,v=W(),{t:y}=U(),b=Ya(!0),x=(0,X.useCallback)((e,t)=>{d_(v,h,_,e,t)},[v,h,_]),[S,C]=(0,X.useState)([]),[w,T]=(0,X.useState)({}),[E,D]=(0,X.useState)([]),[O,k]=(0,X.useState)(!1),[A,j]=(0,X.useState)(!1),[M,ee]=(0,X.useState)(!1),[N,P]=(0,X.useState)(`catalog`),[F,I]=(0,X.useState)(``),[te,L]=(0,X.useState)(!1),R=(0,X.useCallback)(()=>{v.reset(),L(!1),window.location.reload()},[v]),z=S.find(e=>e.id===s),ne=f_.find(t=>t.id===e);(0,X.useEffect)(()=>{let e=e=>{if(e.type===`provider.catalog`){let t=e.payload;C(t.providers.sort((e,t)=>e.id.localeCompare(t.id))),k(!1)}},t=e=>{if(e.type===`provider.models`){let t=e.payload;T(e=>({...e,[t.provider]:t.models})),j(!1)}},n=e=>{if(e.type===`providers.saved`){let t=e.payload.providers.sort((e,t)=>e.id.localeCompare(t.id));D(t),ee(!1),t.length>0&&P(`saved`)}};if(!d||!m)return;let r=m.on(`provider.catalog`,e),i=m.on(`provider.models`,t),a=m.on(`providers.saved`,n);return k(!0),ee(!0),m.listProviders(),m.listSavedProviders(),()=>{r?.(),i?.(),a?.()}},[d,m]);let re=(0,X.useCallback)(e=>{l(e),w[e]||(j(!0),f.listProviderModels?.(e))},[w,l,f]),ie=(0,X.useCallback)(async e=>{if(i.current)return;let n=t.getState().model,r=t.getState().provider;if(!(!r||e===n)){i.current=!0,o(!0),u(e);try{p.info(H.t(`settings:toast.switchingTo`,{provider:r,model:e}));let t=await f.switchModel?.(r,e);t?.success?p.success(H.t(t.runActive?`settings:toast.modelSwitchedRunActive`:`settings:toast.modelSwitchedNextRequest`,{from:`${r} / ${n}`,to:`${r} / ${e}`})):(u(n),p.error(t?.message??H.t(`settings:toast.modelSwitchTimeout`)))}finally{i.current=!1,o(!1)}}},[u,f]),B=(0,X.useCallback)((e,t,n)=>{f.addKey?.(e,t,n)},[f]),ae=(0,X.useCallback)((e,t)=>{f.deleteKey?.(e,t)},[f]),oe=(0,X.useCallback)((e,t)=>{f.setActiveKey?.(e,t)},[f]),se=(0,X.useCallback)((e,t,n,r,i,a)=>{f.addProvider?.(e,t,n,r,i,a)},[f]),ce=(0,X.useCallback)(e=>{f.removeProvider?.(e)},[f]),le=(0,X.useCallback)((e,n)=>{f.client.updateProvider({id:e,models:[n]}),e===t.getState().provider&&u(n)},[u,f.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)(Tr,{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:y(`settings:title`)}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-[11px] text-muted-foreground`,children:s&&c?`${s} / ${c}`:y(`settings:subtitle`)})]})]}),(0,Z.jsx)(Y,{variant:`ghost`,size:`icon`,onClick:()=>Pa(`chat`),children:(0,Z.jsx)(mr,{className:`h-4 w-4`})}),(0,Z.jsx)(Y,{variant:`ghost`,size:`sm`,onClick:()=>L(!0),children:y(`settings:resetLabel`)})]}),(0,Z.jsx)(ws,{className:`min-h-0 flex-1`,ref:r,children:(0,Z.jsx)(`div`,{className:`mx-auto max-w-7xl p-4 sm:p-6`,children:(0,Z.jsxs)(Es,{value:e,onValueChange:n,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)(Ds,{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:f_.map(e=>(0,Z.jsxs)(Os,{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:y(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:[ne?.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:ne.icon}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-semibold`,children:y(ne.labelKey)}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:y(ne.descKey)})]})]}),(0,Z.jsx)(ks,{value:`general`,className:`mt-0`,children:(0,Z.jsx)(Vm,{})}),(0,Z.jsxs)(ks,{value:`provider`,className:`mt-0 space-y-4`,children:[(0,Z.jsx)(bg,{activeProvider:s,catalogProviders:S,isLoadingCatalog:O,savedProviders:E,isLoadingSaved:M,providerTab:N,setProviderTab:P,onSelectProvider:re,onAddKey:B,onDeleteKey:ae,onSetActiveKey:oe,onAddProvider:se,onRemoveProvider:ce,onPickProviderModel:le,ws:f.client,catalogQuery:F,setCatalogQuery:I}),(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`}),y(`settings:model.heading`)]}),(0,Z.jsx)(xh,{provider:s,catalogModels:w,currentCatalogProvider:z,isLoadingModels:A,setIsLoadingModels:j,onModelSelect:ie,isSwitching:a,refreshModels:e=>f.listProviderModels?.(e)}),(0,Z.jsx)(bh,{syncPref:x})]})]}),(0,Z.jsx)(ks,{value:`connection`,className:`mt-0`,children:(0,Z.jsx)(Bm,{})}),(0,Z.jsx)(ks,{value:`agent`,className:`mt-0 space-y-6`,children:(0,Z.jsx)(wm,{syncPref:x,switchAutonomy:g})}),(0,Z.jsx)(ks,{value:`execution`,className:`mt-0 space-y-6`,children:(0,Z.jsx)(nh,{syncPref:x,fallbackCandidates:b})}),(0,Z.jsx)(ks,{value:`fallbacks`,className:`mt-0`,children:(0,Z.jsx)(ch,{syncPref:x,candidates:b,provider:s,activeModel:c,setProvider:l,setModel:u,switchModel:f.switchModel})}),(0,Z.jsxs)(ks,{value:`routing`,className:`mt-0`,children:[(0,Z.jsx)(Ng,{syncPref:x,candidates:b}),(0,Z.jsx)(`div`,{className:`mt-6 border-t border-border pt-6`,children:(0,Z.jsx)(wh,{syncPref:x})})]}),(0,Z.jsx)(ks,{value:`fleet`,className:`mt-0`,children:(0,Z.jsx)(lh,{syncPref:x})}),(0,Z.jsx)(ks,{value:`integrations`,className:`mt-0`,children:(0,Z.jsx)(vh,{syncPref:x})}),(0,Z.jsx)(ks,{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)(Hm,{syncPref:x,sessionProvider:s,sessionModel:c})})}),(0,Z.jsx)(ks,{value:`context`,className:`mt-0 space-y-6`,children:(0,Z.jsx)(Jm,{syncPref:x})}),(0,Z.jsx)(ks,{value:`logs`,className:`mt-0 space-y-6`,children:(0,Z.jsx)(yh,{syncPref:x})}),(0,Z.jsx)(ks,{value:`security`,className:`mt-0`,children:(0,Z.jsx)(u_,{})}),(0,Z.jsx)(ks,{value:`display`,className:`mt-0`,children:(0,Z.jsx)($m,{syncPref:x})})]})]})})}),(0,Z.jsx)(Ha,{open:te,onOpenChange:L,children:(0,Z.jsxs)(za,{showCloseButton:!1,children:[(0,Z.jsxs)(La,{children:[(0,Z.jsx)(Ba,{children:y(`settings:resetConfirmTitle`)}),(0,Z.jsx)(Va,{children:y(`settings:resetConfirmBody`)})]}),(0,Z.jsxs)(Ra,{className:`gap-2 sm:gap-0`,children:[(0,Z.jsx)(Y,{variant:`outline`,onClick:()=>L(!1),children:y(`settings:cancel`)}),(0,Z.jsx)(Y,{variant:`destructive`,onClick:R,children:y(`settings:resetConfirmAction`)})]})]})})]})}function m_(){let e=ya(e=>e.info),{client:t}=ua(),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 h_=new Map,g_=new Set;y(e=>{h_.delete(e),g_.add(e)});function __({sessionId:e,className:n}){let{t:r}=U(),[i,a]=(0,X.useState)([]),[o,s]=(0,X.useState)(!1),[c,l]=(0,X.useState)(null),[u,d]=(0,X.useState)(null),[f,p]=(0,X.useState)(0),[m,h]=(0,X.useState)(!1),[g,_]=(0,X.useState)(!1),[v,y]=(0,X.useState)(``),[b,x]=(0,X.useState)(``),[S,C]=(0,X.useState)(!1),[w,T]=(0,X.useState)(``),E=(0,X.useRef)(e),D=t(e=>e.wsUrl),O=V(D),k=J(e=>e.messages).filter(e=>e.role===`tool`&&e.toolResult===void 0&&!!e.toolUseId);(0,X.useLayoutEffect)(()=>{let t=E.current;g_.has(t)||h_.set(t,{participants:i,joined:o,joinedRole:c,error:u,openAnnotationCount:f,paused:m,injectOpen:g,injectToolUseId:v,injectContent:b,injectIsError:S,injectReason:w});let n=h_.get(e);g_.delete(e),a(n?.participants??[]),s(n?.joined??!1),l(n?.joinedRole??null),d(n?.error??null),p(n?.openAnnotationCount??0),h(n?.paused??!1),_(n?.injectOpen??!1),y(n?.injectToolUseId??``),x(n?.injectContent??``),C(n?.injectIsError??!1),T(n?.injectReason??``),E.current=e},[e]),(0,X.useEffect)(()=>{let t=[];return t.push(O.on(`collab.state`,t=>{let n=t.payload;n.sessionId===e&&a(n.participants??[])})),t.push(O.on(`collab.participant.joined`,t=>{let n=t.payload;n.sessionId===e&&a(e=>e.some(e=>e.participantId===n.participantId)?e:[...e,{participantId:n.participantId,role:n.role,joinedAt:n.joinedAt}])})),t.push(O.on(`collab.participant.left`,t=>{let n=t.payload;if(n.sessionId!==e)return;let r=n.participantId;a(e=>e.filter(e=>e.participantId!==r))})),t.push(O.on(`error`,e=>{let t=e.payload;t.phase===`collab`&&(d(t.message),s(!1))})),t.push(O.on(`collab.annotation.added`,t=>{let n=t.payload;n.sessionId===e&&(n.annotation?.resolved||p(e=>e+1))})),t.push(O.on(`collab.annotation.resolved`,t=>{t.payload.sessionId===e&&p(e=>Math.max(0,e-1))})),t.push(O.on(`collab.pause.granted`,t=>{t.payload.sessionId===e&&h(!0)})),t.push(O.on(`collab.pause.released`,t=>{t.payload.sessionId===e&&h(!1)})),()=>{for(let e of t)e()}},[O,e]);let A=(t=`observer`)=>{d(null),O.send({type:`collab.join`,payload:{sessionId:e,role:t}}),s(!0),l(t)},j=()=>{O.send({type:`collab.request_pause`,payload:{sessionId:e}})},M=()=>{O.send({type:`collab.resume`,payload:{sessionId:e}})},ee=()=>{O.send({type:`collab.leave`,payload:{sessionId:e}}),s(!1),a([])},N=t=>{O.send({type:`collab.grant_control`,payload:{sessionId:e,toParticipant:t}})},P=()=>{v&&(O.send({type:`collab.inject_tool`,payload:{sessionId:e,toolUseId:v,content:b,isError:S,reason:w.trim()||H.t(`activity:collab.controllerInjection`)}}),_(!1),y(``),x(``),C(!1),T(``))},F=o&&c===`controller`;return i.length===0&&!u?(0,Z.jsxs)(`div`,{className:K(`flex items-center gap-2 px-3 py-2 rounded-md border border-dashed border-border bg-card/40`,n),children:[(0,Z.jsx)(er,{className:`w-4 h-4 text-muted-foreground`}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r(`activity:collab.noObservers`)}),(0,Z.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>A(`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:r(`activity:collab.observerTitle`),children:[(0,Z.jsx)(sr,{className:`w-3 h-3`}),r(`activity:collab.observerRole`)]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>A(`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:r(`activity:collab.annotatorTitle`),children:[(0,Z.jsx)(ur,{className:`w-3 h-3`}),r(`activity:collab.annotatorRole`)]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>A(`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:r(`activity:collab.controllerTitle`),children:[(0,Z.jsx)(Vt,{className:`w-3 h-3`}),r(`activity:collab.controllerRole`)]})]})]}):u?(0,Z.jsxs)(`div`,{className:K(`flex items-center gap-2 px-3 py-2 rounded-md border border-destructive/50 bg-destructive/10`,n),role:`alert`,children:[(0,Z.jsx)(`span`,{className:`text-xs text-destructive`,children:r(`activity:collab.errorPrefix`,{error:u})}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{d(null),s(!1)},className:`ml-auto text-xs underline text-destructive`,children:r(`activity:collab.dismiss`)})]}):(0,Z.jsxs)(`div`,{className:K(`relative flex items-center gap-2 px-3 py-2 rounded-md border border-success/40 bg-success/5`,n),children:[(0,Z.jsxs)(`span`,{className:`relative flex h-2 w-2`,role:`img`,"aria-label":r(`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)(er,{className:`w-4 h-4 text-success`}),(0,Z.jsx)(`span`,{className:`text-xs font-medium text-success`,children:r(`activity:collab.observers`,{count:i.length})}),f>0&&(0,Z.jsxs)(`span`,{title:r(`activity:collab.annotationsTitle`,{count:f}),className:`ml-2 inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-warning/15 text-warning border border-warning/30`,children:[(0,Z.jsx)(ur,{className:`w-3 h-3`}),r(`activity:collab.notes`,{count:f})]}),m&&(0,Z.jsxs)(`span`,{title:r(`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)(Vt,{className:`w-3 h-3`}),r(`activity:collab.paused`)]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1 ml-2`,children:[i.slice(0,3).map(e=>(0,Z.jsxs)(`span`,{title:r(`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)(ki,{className:`w-3 h-3`}),e.role,F&&e.role!==`controller`&&(0,Z.jsx)(`button`,{type:`button`,onClick:()=>N(e.participantId),title:r(`activity:collab.grantTitle`),className:`ml-0.5 inline-flex items-center rounded hover:bg-success/20 transition-colors`,children:(0,Z.jsx)(Ve,{className:`w-3 h-3`})})]},e.participantId)),i.length>3&&(0,Z.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`+`,i.length-3]})]}),F&&(0,Z.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>_(e=>!e),className:`inline-flex items-center gap-1 text-xs px-2 py-1 rounded border border-info/40 bg-info/10 text-info hover:bg-info/20 transition-colors`,title:r(`activity:collab.injectTitle`),children:[(0,Z.jsx)(sn,{className:`w-3 h-3`}),r(`activity:collab.inject`)]}),m?(0,Z.jsxs)(`button`,{type:`button`,onClick:M,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:r(`activity:collab.resumeTitle`),children:[(0,Z.jsx)(Kt,{className:`w-3 h-3`}),r(`activity:collab.resume`)]}):(0,Z.jsxs)(`button`,{type:`button`,onClick:j,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:r(`activity:collab.pauseTitle`),children:[(0,Z.jsx)(Vt,{className:`w-3 h-3`}),r(`activity:collab.pauseAgent`)]})]}),o&&c!==`controller`&&(0,Z.jsxs)(`button`,{type:`button`,onClick:ee,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:r(`activity:collab.leaveTitle`),children:[(0,Z.jsx)(Hr,{className:`w-3 h-3`}),r(`activity:collab.leave`)]}),F&&g&&(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)(sn,{className:`w-3.5 h-3.5 text-info`}),(0,Z.jsx)(`span`,{className:`font-medium`,children:r(`activity:collab.injectToolResult`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>_(!1),className:`ml-auto text-muted-foreground hover:text-foreground`,children:r(`activity:collab.close`)})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:r(`activity:collab.targetTool`)}),(0,Z.jsx)(`input`,{list:`collab-inject-tools`,value:v,onChange:e=>y(e.target.value),placeholder:r(`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:k.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??r(`activity:collab.toolFallback`),t]},e.toolUseId)})}),k.length===0&&(0,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:r(`activity:collab.noPendingTools`)})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:r(`activity:collab.resultContent`)}),(0,Z.jsx)(`textarea`,{value:b,onChange:e=>x(e.target.value),rows:3,placeholder:r(`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:S,onChange:e=>C(e.target.checked)}),(0,Z.jsx)(`span`,{children:r(`activity:collab.markError`)})]}),(0,Z.jsx)(`input`,{type:`text`,value:w,onChange:e=>T(e.target.value),placeholder:r(`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:!v,className:`self-end inline-flex items-center gap-1 text-xs px-3 py-1 rounded bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:[(0,Z.jsx)(sn,{className:`w-3 h-3`}),r(`activity:collab.queueInjection`)]})]})]})}var v_={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 y_({className:e}){let{t}=U(),n=B(e=>e.agents),i=P(),[a,o]=(0,X.useState)(null),s=(0,X.useMemo)(()=>{let e=Array.from(n.values()).filter(e=>r(e.sessionId,i));return e.sort(b),e},[n,i]),c=(0,X.useCallback)(async(e,t)=>{try{await navigator.clipboard.writeText(t),o(e),setTimeout(()=>o(null),2e3)}catch{}},[]),l=(0,X.useCallback)(e=>{q.getState().setSubagentChatFocus(e,i??void 0),q.getState().setDockSection(null)},[i]);if(s.length===0)return(0,Z.jsx)(`div`,{className:K(`p-4 text-center text-xs text-muted-foreground`,e),children:t(`activity:agents.noAgentsRunning`)});let u=xe(s),d=s.reduce((e,t)=>e+(t.costUsd??0),0);return(0,Z.jsxs)(`div`,{className:K(`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)(Pi,{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:[u.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`}),u.running,` `,t(`activity:fleet.statusRunning`)]}),u.completed>0&&(0,Z.jsxs)(`span`,{className:`text-muted-foreground`,children:[u.completed,` `,t(`activity:fleet.statusDone`)]}),u.failed>0&&(0,Z.jsxs)(`span`,{className:`font-medium text-destructive`,children:[u.failed,` `,t(`activity:fleet.statusFailed`)]}),d>0&&(0,Z.jsx)(`span`,{className:`rounded bg-muted/60 px-1.5 py-0.5 font-mono text-[10px] text-foreground/80`,children:qs(d)})]})]}),(0,Z.jsx)(`div`,{className:`flex flex-col gap-2`,children:s.map(e=>{let n=v_[e.status]??v_.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:K(`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:K(`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)(vn,{className:`h-3 w-3`}),Ys(r)]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>l(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)(we,{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)(oi,{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)(Fn,{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:qs(e.costUsd)}),e.finalText&&(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>c(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)(ii,{className:`h-3 w-3 text-success`}):(0,Z.jsx)(Bt,{className:`h-3 w-3`}),(0,Z.jsx)(`span`,{children:a===e.id?t(`common:action.copied`):t(`common:action.copy`)})]})]})]})]},e.id)})})]})}var b_={up:(0,Z.jsx)(Me,{className:`h-3.5 w-3.5 text-success`}),down:(0,Z.jsx)(Nr,{className:`h-3.5 w-3.5 text-destructive`}),stable:(0,Z.jsx)(In,{className:`h-3.5 w-3.5 text-warning`})},x_={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 S_({goal:e,className:t}){let{t:n}=U(),[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=x_[e.goalState],c=e.deliverables?.filter(e=>e.status===`done`).length??0,l=e.deliverables?.length??0,u=e.progressTrend?b_[e.progressTrend]:null;return(0,Z.jsxs)(`div`,{className:K(`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)(mt,{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:K(`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)(ar,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}):(0,Z.jsx)(fr,{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:K(`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)(vn,{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)(Cr,{className:`h-3 w-3 text-success mt-0.5 shrink-0`}):(0,Z.jsx)(gt,{className:`h-3 w-3 text-muted-foreground/70 mt-0.5 shrink-0`}),(0,Z.jsx)(`span`,{className:K(`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 C_={in_progress:0,pending:1,completed:2},w_=`__no_session__`,T_=new Map,E_=new Set;y(e=>{T_.delete(e),E_.add(e)});function D_(){let{t:e}=U(),t=j(e=>e.todos),n=P(),[r,i]=(0,X.useState)(new Set),a=V(),o=(0,X.useRef)(n??w_);(0,X.useLayoutEffect)(()=>{E_.has(o.current)||T_.set(o.current,new Set(r));let e=n??w_;E_.delete(e),i(new Set(T_.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)=>(C_[e.status]??9)-(C_[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:K(`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)(Cr,{className:`w-3.5 h-3.5 text-success`}):r?(0,Z.jsx)(vn,{className:`w-3.5 h-3.5 text-warning animate-spin`}):(0,Z.jsx)(gt,{className:K(`w-3.5 h-3.5 transition-colors`,`text-muted-foreground/65 group-hover:text-success`)})}),(0,Z.jsxs)(`span`,{className:K(`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)(Lt,{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 O_={pending:{icon:(0,Z.jsx)(gt,{className:`w-3.5 h-3.5`}),labelKey:`statusPending`,color:`text-muted-foreground/70`},in_progress:{icon:(0,Z.jsx)(vn,{className:`w-3.5 h-3.5 animate-spin`}),labelKey:`statusInProgress`,color:`text-warning`},blocked:{icon:(0,Z.jsx)(Vt,{className:`w-3.5 h-3.5`}),labelKey:`statusBlocked`,color:`text-warning`},failed:{icon:(0,Z.jsx)(Fn,{className:`w-3.5 h-3.5`}),labelKey:`statusFailed`,color:`text-destructive`},review:{icon:(0,Z.jsx)(gr,{className:`w-3.5 h-3.5`}),labelKey:`statusReview`,color:`text-info`},completed:{icon:(0,Z.jsx)(Cr,{className:`w-3.5 h-3.5`}),labelKey:`statusDone`,color:`text-success`}},k_={critical:`text-destructive`,high:`text-warning`,medium:`text-warning/85`,low:`text-muted-foreground`},A_={feature:`⚡`,bugfix:`🐛`,refactor:`♻️`,docs:`📝`,test:`🧪`,chore:`🔧`},j_=`__no_session__`,M_=new Map,N_=new Set;y(e=>{M_.delete(e),N_.add(e)});function P_(){let{t:e}=U(),[t,n]=(0,X.useState)([]),[r,i]=(0,X.useState)(new Set),a=V(),o=P(),s=(0,X.useRef)(o??j_);(0,X.useLayoutEffect)(()=>{N_.has(s.current)||M_.set(s.current,new Set(r));let e=o??j_;N_.delete(e),i(new Set(M_.get(e)??[])),s.current=e},[o]),(0,X.useEffect)(()=>{n([]),a.getTasks();let e=a.on(`tasks.updated`,e=>{let t=e?.payload;t?.sessionId&&o&&t.sessionId!==o||t?.tasks&&n(t.tasks)});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.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=O_[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:K(`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:K(`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:K(t.status===`completed`?`text-muted-foreground line-through`:`text-foreground/80`),children:[A_[t.type],` `,t.title]}),t.priority!==`medium`&&(0,Z.jsx)(`span`,{className:K(`ml-1 text-[10px]`,k_[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 F_={open:{icon:(0,Z.jsx)(gt,{className:`w-3.5 h-3.5`}),labelKey:`statusOpen`,color:`text-muted-foreground/70`},in_progress:{icon:(0,Z.jsx)(vn,{className:`w-3.5 h-3.5 animate-spin`}),labelKey:`statusInProgress`,color:`text-warning`},done:{icon:(0,Z.jsx)(Cr,{className:`w-3.5 h-3.5`}),labelKey:`statusDone`,color:`text-success`}},I_=`__no_session__`,L_=new Map,R_=new Set;y(e=>{L_.delete(e),R_.add(e)});function z_(){let{t:e}=U(),[t,n]=(0,X.useState)([]),[r,i]=(0,X.useState)(new Set),a=V(),o=P(),s=(0,X.useRef)(o??I_);(0,X.useLayoutEffect)(()=>{R_.has(s.current)||L_.set(s.current,new Set(r));let e=o??I_;R_.delete(e),i(new Set(L_.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=F_[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:K(`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:K(`mt-0.5 shrink-0`,i.color),children:i.icon}),(0,Z.jsx)(`span`,{className:K(`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 B_=[{id:`todos`,labelKey:`work.todos`,icon:`✅`},{id:`tasks`,labelKey:`work.tasks`,icon:`📋`},{id:`plan`,labelKey:`work.plan`,icon:`🗺️`}];function V_(){let{t:e}=U(),t=q(e=>e.workDashboardTab),n=q(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:B_.map(r=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>n(r.id),className:K(`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:K(t===`todos`?`block`:`hidden`),children:(0,Z.jsx)(D_,{})}),(0,Z.jsx)(`div`,{className:K(t===`tasks`?`block`:`hidden`),children:(0,Z.jsx)(P_,{})}),(0,Z.jsx)(`div`,{className:K(t===`plan`?`block`:`hidden`),children:(0,Z.jsx)(z_,{})})]})}var H_={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))`},U_=[H_.primary,H_.info,H_.success,H_.warning,H_.destructive,H_.muted],W_=e=>e.replace(/^wstack\/ap\//,``);function G_(e){return[...e].sort((e,t)=>e.allocatedAt-t.allocatedAt).map((e,t)=>({handle:e,color:U_[t%U_.length],y:60+t*48}))}var K_={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 q_({worktrees:e,baseBranch:t}){let{t:n}=U(),r=G_(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:H_.primary,strokeWidth:3}),(0,Z.jsx)(`text`,{x:36,y:14,fontSize:11,fill:H_.muted,children:t||`HEAD`}),(0,Z.jsx)(`circle`,{cx:40,cy:20,r:5,fill:H_.primary}),r.map(e=>{let r=K_[e.handle.status]??d(K_.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:H_.success,strokeWidth:2,opacity:.9}):null,(0,Z.jsx)(`circle`,{cx:220,cy:e.y,r:5,fill:a?H_.destructive:e.color}),(0,Z.jsx)(`text`,{x:232,y:e.y-6,fontSize:12,fill:H_.foreground,fontFamily:`monospace`,children:W_(e.handle.branch)}),(0,Z.jsx)(`text`,{x:232,y:e.y+10,fontSize:10,fill:H_.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 J_={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 Y_(e){return J_[e]??{icon:`?`,labelKey:``,tint:`border-border`,dot:`bg-muted-foreground`}}var X_=e=>e.replace(/^wstack\/ap\//,``);function Z_({worktrees:e,baseBranch:t}){let{t:n}=U(),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=Y_(e.status),r=e.status===`needs-review`,i=Math.min(100,e.insertions+e.deletions);return(0,Z.jsxs)(`div`,{className:K(`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:K(`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:X_(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 Q_=e=>e?e.replace(/^wstack\/ap\//,``):``;function $_(){let{t:e}=U(),{client:t}=ua(),n=wa(e=>e.orphans),r=wa(e=>e.canClean),i=wa(e=>e.cleanBlockedReason),a=wa(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)(Rr,{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`?`⌥ `:`▢ `,Q_(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 qa({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)(pr,{className:`h-3.5 w-3.5 animate-spin`}):(0,Z.jsx)(ln,{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 ev={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`}},tv={goal:`Goal`,"goal-state":`Goal State`,fleet:`Fleet`,work:`Work`,worktrees:`Worktrees`,collab:`Collab`},nv=[`goal`,`goal-state`,`fleet`,`work`,`worktrees`,`collab`];function rv({section:e,icon:t,label:n,value:r,active:i,pulse:a,onClick:o}){let s=ev[e],{t:c}=U();return(0,Z.jsxs)(`button`,{type:`button`,onClick:o,title:c(i?`activity:dock.collapseChip`:`activity:dock.expandChip`,{label:n}),className:K(`flex items-center gap-2 h-7 px-2.5 rounded-md border text-xs font-medium shrink-0 transition-colors`,i?s.active:K(`border-border/40`,s.idle)),children:[(0,Z.jsx)(`span`,{className:K(a&&`animate-pulse`),children:t}),n,r&&(0,Z.jsx)(`span`,{className:`tabular-nums opacity-80`,children:r})]})}function iv(){let e=q(e=>e.dockSection),{t}=U(),n=q(e=>e.toggleDockSection),i=q(e=>e.hiddenChips),a=q(e=>e.toggleChipHidden),o=q(e=>e.dockCustomizeOpen),s=q(e=>e.setDockCustomizeOpen),c=P(),l=Sa(e=>e.goal),u=xa(e=>e.phases.length),d=xa(e=>e.overallPercent),f=xa(e=>e.activePhaseId),p=wa(e=>e.worktrees),m=j(e=>e.todos),h=B(e=>e.agents),g=m_(),_=(0,X.useMemo)(()=>Array.from(h.values()).filter(e=>r(e.sessionId,c)),[h,c]),v=_.length,y=(0,X.useMemo)(()=>_.filter(e=>e.status===`running`).length,[_]),b=m.filter(e=>e.status===`completed`).length,x=m.some(e=>e.status===`in_progress`),S=u>0,C=(0,X.useMemo)(()=>new Set(i),[i]),w={goal:S,"goal-state":l!==null,fleet:v>0,work:!0,worktrees:p.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)(rv,{section:`goal`,icon:(0,Z.jsx)(Ai,{className:`h-3 w-3`}),label:t(`activity:dock.goal`),value:`${d}%`,active:!1,pulse:f!=null,onClick:()=>Fa(`goal`)}),T[`goal-state`]&&l&&(0,Z.jsx)(rv,{section:`goal-state`,icon:(0,Z.jsx)(mt,{className:`h-3 w-3`}),label:t(`activity:dock.goalState`),value:`${l.progress}%`,active:E===`goal-state`,pulse:l.goalState===`active`,onClick:()=>n(`goal-state`)}),T.fleet&&(0,Z.jsx)(rv,{section:`fleet`,icon:(0,Z.jsx)(Pi,{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)(rv,{section:`work`,icon:(0,Z.jsx)(Kr,{className:`h-3 w-3`}),label:t(`activity:dock.work`),value:m.length>0?`${b}/${m.length}`:void 0,active:E===`work`,pulse:x,onClick:()=>n(`work`)}),T.worktrees&&(0,Z.jsx)(rv,{section:`worktrees`,icon:(0,Z.jsx)(Cn,{className:`h-3 w-3`}),label:t(`activity:dock.worktrees`),value:String(p.length),active:E===`worktrees`,onClick:()=>n(`worktrees`)}),g&&(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)(Cn,{className:`h-3 w-3 shrink-0 text-muted-foreground`}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate font-semibold text-foreground`,children:g.branch}),g.ahead>0&&(0,Z.jsxs)(`span`,{className:`text-success`,title:t(`activity:dock.ahead`,{count:g.ahead}),children:[`↑`,g.ahead]}),g.behind>0&&(0,Z.jsxs)(`span`,{className:`text-warning`,title:t(`activity:dock.behind`,{count:g.behind}),children:[`↓`,g.behind]}),g.added>0&&(0,Z.jsxs)(`span`,{className:`text-success`,title:t(`activity:dock.linesAdded`,{count:g.added}),children:[`+`,g.added]}),g.deleted>0&&(0,Z.jsxs)(`span`,{className:`text-destructive`,title:t(`activity:dock.linesDeleted`,{count:g.deleted}),children:[`-`,g.deleted]}),g.untracked>0&&(0,Z.jsxs)(`span`,{className:`text-muted-foreground`,title:t(`activity:dock.untrackedFiles`,{count:g.untracked}),children:[g.untracked,`?`]})]}),(0,Z.jsx)(rv,{section:`collab`,icon:(0,Z.jsx)(er,{className:`h-3 w-3`}),label:t(`activity:dock.collab`),active:E===`collab`,onClick:()=>n(`collab`)}),(0,Z.jsxs)(so,{open:o,onOpenChange:s,children:[(0,Z.jsx)(co,{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)(di,{className:`h-3 w-3`})})}),(0,Z.jsxs)(fo,{align:`end`,className:`w-44`,children:[(0,Z.jsx)(go,{children:t(`activity:dock.dockChips`)}),(0,Z.jsx)(_o,{}),nv.map(e=>(0,Z.jsx)(mo,{checked:!C.has(e),onCheckedChange:()=>a(e),onSelect:e=>e.preventDefault(),children:tv[e]},e))]})]})]})})}var av={"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 ov({sessionId:e}){let t=q(e=>e.dockSection),n=q(e=>e.setDockSection),r=q(e=>e.inspectorOpen),i=Sa(e=>e.goal),a=wa(e=>e.worktrees),o=wa(e=>e.baseBranch),[s,c]=(0,X.useState)(`graph`),{t:l}=U(),u=t!==null&&t!==`goal`,d=u?t:null,f=d?av[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:K(`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)(ft,{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)(mr,{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)(S_,{goal:i}):(0,Z.jsx)(sv,{title:l(`activity:dock.noActiveGoal`),detail:l(`activity:dock.noActiveGoalDetail`)})),d===`fleet`&&(0,Z.jsx)(y_,{}),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:K(`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)($_,{}),s===`graph`?(0,Z.jsx)(q_,{worktrees:a,baseBranch:o||`HEAD`}):(0,Z.jsx)(Z_,{worktrees:a,baseBranch:o||`HEAD`})]}),(0,Z.jsx)(`div`,{className:K(d===`work`?`block`:`hidden`),id:`panel-work`,children:(0,Z.jsx)(V_,{})}),(0,Z.jsx)(`div`,{className:K(d===`collab`?`block`:`hidden`),children:(0,Z.jsx)(__,{sessionId:e})})]})]})}function sv({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})]})}var cv=(0,X.lazy)(()=>G(()=>import(`./AnalyticsDashboard-Dr67MeEY.js`).then(e=>({default:e.AnalyticsDashboard})),__vite__mapDeps([26,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,20,21,19,22]))),lv=(0,X.lazy)(()=>G(()=>import(`./AgentRosterView-VIctzKMy.js`).then(e=>({default:e.AgentRosterView})),__vite__mapDeps([27,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,21,20,19,22,23,28,18,24,29,30,25,31,32,33,34,35]))),uv=(0,X.lazy)(()=>G(()=>import(`./ChangesView-s7Mn7iE2.js`).then(e=>({default:e.ChangesView})),__vite__mapDeps([36,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,19,20,21,22,23,24,37,38]))),dv=(0,X.lazy)(()=>G(()=>import(`./ChronicleDashboard-CzqPfaPc.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]))),fv=(0,X.lazy)(()=>G(()=>import(`./CodeEditor-DXQoTSH5.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,19,20,21,22,23,37,38,41,31,33]))),pv=(0,X.lazy)(()=>G(()=>import(`./CodeMap-D34FOPgR.js`).then(e=>({default:e.CodeMap})),__vite__mapDeps([42,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,19,24]))),mv=(0,X.lazy)(()=>G(()=>import(`./DebugDashboard-DWaUg6e1.js`).then(e=>({default:e.DebugDashboard})),__vite__mapDeps([43,1,2,3,4,5,6,7,8,9,10,11,12,13,14]))),hv=(0,X.lazy)(()=>G(()=>import(`./DesignGalleryView-BKtjn4px.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,18,19,20,21,22,23,24]))),gv=(0,X.lazy)(()=>G(()=>import(`./GoalView-BZ62_vF-.js`).then(e=>({default:e.GoalView})),__vite__mapDeps([45,1,2,3,4,5,6,7,8,9,10,11,12,13,14,18,0,15,16,19,20,21,22,23,24,31,46,25,32]))),_v=(0,X.lazy)(()=>G(()=>import(`./KanbanView-DsWnTpxr.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,20,21,19,22,25,28,18,23,24,48]))),vv=(0,X.lazy)(()=>G(()=>import(`./MailboxDetailView-DS1P9DRT.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,22,23,37]))),yv=(0,X.lazy)(()=>G(()=>import(`./PromptJournalView-Biu4DknM.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]))),bv=(0,X.lazy)(()=>G(()=>import(`./RefreshDebugView-d9iU3sFX.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,21]))),xv=(0,X.lazy)(()=>G(()=>import(`./SageTabs-YASyEFo6.js`).then(e=>({default:e.SageTabs})),__vite__mapDeps([52,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]))),Sv=(0,X.lazy)(()=>G(()=>import(`./RequirementIntakeView-BVyF2zXR.js`).then(e=>({default:e.RequirementIntakeView})),__vite__mapDeps([53,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,31,32]))),Cv=(0,X.lazy)(()=>G(()=>import(`./SddHub-rmGGEYZe.js`).then(e=>({default:e.SddHub})),__vite__mapDeps([54,1,2,3,4,5,6,7,8,9,10,11,12,13,14,18,0,15,16,19,20,21,22,23,24,25,31,28,48,55]))),wv=(0,X.lazy)(()=>G(()=>import(`./SessionsDashboard-x3iyhrGl.js`).then(e=>({default:e.SessionsDashboard})),__vite__mapDeps([56,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,19,20,21,22,23,24,57,46,25,31,32]))),Tv=(0,X.lazy)(()=>G(()=>import(`./SessionInspectView-iaKkGAAM.js`).then(e=>({default:e.SessionInspectView})),__vite__mapDeps([58,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,19,20,21,22,23,24,57,46,25,31,32]))),Ev=(0,X.lazy)(()=>G(()=>import(`./SkillDetailView-BcD9z7zG.js`).then(e=>({default:e.SkillDetailView})),__vite__mapDeps([59,1,2,3,4,5,6,7,8,9,10,11,12,13,14,18,0,15,16,19,20,21,22,23,24,25,37]))),Dv=(0,X.lazy)(()=>G(()=>import(`./TechStackView-DmMtwb4l.js`).then(e=>({default:e.TechStackView})),__vite__mapDeps([60,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,20,0,16,21,19,22,31,32]))),Ov=(0,X.lazy)(()=>G(()=>import(`./DeadCodeScanPanel-DooqnEMF.js`).then(e=>({default:e.DeadCodeScanPanel})),__vite__mapDeps([61,1,2,3,4,5,6,7,8,9,10,11,12,13,14]))),kv=(0,X.lazy)(()=>G(()=>import(`./ChimeraReviewsView-Cverzv0b.js`).then(e=>({default:e.ChimeraReviewsView})),__vite__mapDeps([62,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,37])));function Av({sessionId:e,desktopShell:t}){let{t:n}=U(),{currentView:r,terminalOpen:i,setTerminalOpen:a}=q(jn(e=>({currentView:e.currentView,terminalOpen:e.terminalOpen,setTerminalOpen:e.setTerminalOpen})));return(0,Z.jsxs)(Z.Fragment,{children:[e&&(0,Z.jsxs)(`div`,{className:K(`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)(iv,{})}),(0,Z.jsx)(Rf,{})]}),(0,Z.jsx)(`div`,{className:K(`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)(xs,{level:`panel`,name:n(`activity:panels.chat`),children:(0,Z.jsx)($p,{})})}),r===`settings`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.settings`),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(p_,{})})}),r===`memory`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.sageMemory`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{label:n(`common:loadingNamed`,{name:n(`activity:panels.sageMemory`)})}),children:(0,Z.jsx)(xv,{})})}),r===`roster`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.agentRoster`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{label:n(`common:loadingNamed`,{name:n(`activity:panels.agentRoster`)})}),children:(0,Z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:(0,Z.jsx)(lv,{})})})}),r===`context`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.contextDashboard`),children:(0,Z.jsx)(ym,{})}),r===`setup`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.setup`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(jv,{})})})}),r===`goal`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.goal`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(gv,{onClose:()=>Pa(`chat`)})})})}),r===`sddhub`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.sddHub`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Cv,{})})})}),r===`kanban`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.kanban`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(_v,{onClose:()=>Pa(`chat`)})})})}),r===`sessions`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.sessions`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(wv,{})})})}),r===`session-inspect`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.sessionInspect`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{label:n(`common:loadingNamed`,{name:n(`activity:panels.sessionInspect`)})}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Tv,{})})})}),r===`chronicle`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.chronicle`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(dv,{})})})}),r===`intake`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.requirementsIntake`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Sv,{})})})}),r===`prompts`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:nav.prompts`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{label:n(`common:loadingNamed`,{name:n(`activity:nav.prompts`)})}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(yv,{})})})}),r===`debug`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.debugDashboard`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(mv,{})})})}),r===`refresh-debug`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.refreshDebug`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(bv,{})})})}),r===`files`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.editor`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{label:n(`common:loadingNamed`,{name:n(`activity:panels.editor`)})}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(fv,{})})})}),r===`changes`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.changes`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{label:n(`common:loadingNamed`,{name:n(`activity:panels.changes`)})}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(uv,{className:`h-full min-h-0`})})})}),r===`mailbox`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.mailbox`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(vv,{className:`h-full min-h-0`})})})}),r===`design-gallery`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.designGallery`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(hv,{className:`h-full`})})})}),r===`skill`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.skill`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Ev,{className:`h-full`})})})}),r===`analytics`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.analytics`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(cv,{})})})}),r===`codemap`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.codemap`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{label:n(`common:loadingNamed`,{name:n(`activity:panels.codemap`)})}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(pv,{})})})}),r===`techstack`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.techstack`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{label:n(`common:loadingNamed`,{name:n(`activity:panels.techstack`)})}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(Dv,{})})})}),r===`deadcode`&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.deadcode`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{label:n(`common:loadingNamed`,{name:n(`activity:panels.deadcode`)})}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-y-auto`,children:(0,Z.jsx)(Ov,{})})})}),r===`chimera`&&(0,Z.jsx)(xs,{level:`panel`,name:`Chimera Reviews`,children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{}),children:(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,Z.jsx)(kv,{})})})}),i&&(0,Z.jsx)(xs,{level:`panel`,name:n(`activity:panels.terminal`),children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(bm,{label:n(`common:loadingNamed`,{name:n(`activity:panels.terminal`)})}),children:(0,Z.jsx)(Mv,{desktopShell:t,onClose:()=>a(!1)})})})]})}var jv=(0,X.lazy)(()=>G(()=>import(`./SetupScreen-huPJT0Bv.js`).then(e=>({default:e.SetupScreen})),__vite__mapDeps([63,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,19,20,21,22,23,24,25,31,32]))),Mv=(0,X.lazy)(()=>G(()=>import(`./TerminalPanel-cbM6oQWQ.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,20,21,19,22,65,66])));function Nv(){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 Pv(){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 Fv(){let e=Da(e=>e.snapshot),t=q(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:K(`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)(br,{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 Iv(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 Lv({variant:e}){return e===`success`?(0,Z.jsx)(ii,{className:`h-4 w-4 text-success shrink-0`}):e===`error`?(0,Z.jsx)(Fn,{className:`h-4 w-4 text-destructive shrink-0`}):e===`warn`?(0,Z.jsx)(Rr,{className:`h-4 w-4 text-warning shrink-0`}):(0,Z.jsx)(qt,{className:`h-4 w-4 text-info shrink-0`})}function Rv({item:e,onMarkAsRead:t,onRemove:n}){let{t:r}=U(),i=(0,X.useMemo)(()=>Iv(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:K(`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)(Lv,{variant:e.variant})}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0 pr-1`,children:[(0,Z.jsx)(`div`,{className:K(`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)(vn,{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)(ii,{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)(mr,{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 zv({defaultOpen:e,open:t,onOpenChange:n}={}){let{t:r}=U(),i=fe(e=>e.notifications),a=fe(e=>e.markAsRead),o=fe(e=>e.markAllAsRead),s=fe(e=>e.clearAll),c=fe(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]),m=(0,X.useCallback)(()=>{s()},[s]);return(0,Z.jsxs)(so,{defaultOpen:e,open:t,onOpenChange:n,children:[(0,Z.jsx)(co,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,"data-testid":`notification-menu-trigger`,className:K(`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)(Fr,{className:`h-3.5 w-3.5 text-primary`}):(0,Z.jsx)(Wt,{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)(fo,{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)(Ur,{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:m,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)(Lt,{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:K(`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:K(`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)(Oe,{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)(Rv,{item:e,onMarkAsRead:()=>a(e.id),onRemove:()=>c(e.id)},e.id))})]})]})}function Bv(e){return e.split(`-`).map(e=>e.slice(0,1).toUpperCase()+e.slice(1)).join(` `)}function Vv(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 Hv(){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 Uv({currentView:e,projectName:n,sessionLabel:r,isLoading:i,iteration:a,onPalette:o,onSettings:s}){let{t:c}=U(),{theme:l,setTheme:u,palette:d,setPalette:f}=Pu(),p=t(e=>e.wsConnected),m=j(e=>e.appVersion),h=j(e=>e.latestVersion),g=j(e=>e.updateAvailable),_=j(e=>e.droppedTools),v=l===`system`?typeof window<`u`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:l,y=(0,X.useCallback)(()=>{u(v===`dark`?`light`:`dark`)},[v,u]),b=q(e=>e.toggleSidebar),x=Nv(),S=Pv(),C=x.status===`connected`?`WrongProxy: Connected${x.latencyMs==null?``:` (${x.latencyMs}ms)`} · ${x.url}`:x.status===`error`?`WrongProxy: Unreachable · ${x.url}${x.error?` (${x.error})`:``}`:x.status===`checking`?`WrongProxy: Checking · ${x.url}`:`WrongProxy: Disabled`,w=S.status===`connected`?`HQ: Connected${S.latencyMs==null?``:` (${S.latencyMs}ms)`} · ${S.url}`:S.status===`error`?`HQ: Unreachable · ${S.url}${S.error?` (${S.error})`:``}`:S.status===`checking`?`HQ: Checking · ${S.url}`:`HQ: Disabled`,T=Hv(),E=T?T.memoryUsage.heapUsed/T.heapLimit:0,D=T?.codebaseIndexServer,O=D?.health,k=O?.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:b,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)(Xr,{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:n||`WrongStack`}),(0,Z.jsx)(`span`,{className:`rounded bg-muted/60 px-1 py-0.5 text-[10px] text-muted-foreground font-mono`,children:Bv(e)}),i&&(0,Z.jsx)(`span`,{className:`inline-flex items-center gap-0.5 text-[10px] font-medium text-primary`,children:(0,Z.jsx)(Pi,{className:`h-3 w-3 animate-pulse`})})]})})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,Z.jsx)(Ac,{}),(0,Z.jsx)(zv,{}),(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`,title:v===`dark`?`Switch to light theme`:`Switch to dark theme`,children:v===`dark`?(0,Z.jsx)(Yi,{className:`h-3.5 w-3.5`}):(0,Z.jsx)(ui,{className:`h-3.5 w-3.5`})}),(0,Z.jsxs)(so,{children:[(0,Z.jsx)(co,{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)(Fi,{className:`h-3.5 w-3.5`})})}),(0,Z.jsxs)(fo,{align:`end`,className:`w-48`,children:[(0,Z.jsxs)(po,{onSelect:o,className:`gap-2`,children:[(0,Z.jsx)(dt,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:c(`activity:topbar.command`)})]}),(0,Z.jsxs)(po,{onSelect:s,className:`gap-2`,children:[(0,Z.jsx)(mi,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:c(`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:K(`font-mono font-medium`,p?`text-success`:`text-warning`),children:p?`Connected`:`Offline`})]}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`span`,{children:`WrongProxy`}),(0,Z.jsx)(`span`,{className:K(`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.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`span`,{children:`HQ`}),(0,Z.jsx)(`span`,{className:K(`font-mono font-medium`,S.status===`connected`?`text-success`:S.status===`error`?`text-destructive`:`text-muted-foreground`),children:S.status===`connected`?`Connected`:S.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:n||`WrongStack`}),m?(0,Z.jsxs)(`span`,{className:K(`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-[11px] font-medium tabular-nums`,g&&h&&h!==m?`border-warning/40 bg-warning/10 text-warning`:`border-border/70 bg-muted/50 text-muted-foreground`),title:g&&h&&h!==m?`Update available: v${m} → v${h} — run wstack update`:`WrongStack v${m}`,children:[`v`,m,g&&h&&h!==m?(0,Z.jsxs)(`span`,{className:`text-[10px] opacity-80`,children:[`→ v`,h]}):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:Bv(e)}),(0,Z.jsxs)(`span`,{className:K(`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[11px] font-medium`,i?`bg-primary/10 text-primary`:`bg-muted text-muted-foreground`),children:[i?(0,Z.jsx)(Pi,{className:`h-3 w-3 animate-pulse`}):(0,Z.jsx)(Tt,{className:`h-3 w-3`}),i?`Running`:`Ready`,a?(0,Z.jsxs)(`span`,{className:`tabular`,children:[a.index,a.max>0?`/${a.max}`:``]}):null]}),(0,Z.jsx)(Ac,{showCountWhenZero:!0}),T?(0,Z.jsxs)(`span`,{className:K(`rounded-md border border-border/70 bg-muted/50 px-1.5 py-0.5 text-[11px] font-medium tabular-nums`,E>=.85?`text-destructive`:E>=.6?`text-warning`:`text-success`),title:`WebUI server PID ${T.pid} · heap ${Vv(T.memoryUsage.heapUsed)} / ${Vv(T.heapLimit)}`,children:[`RAM `,Vv(T.memoryUsage.rss)]}):null,D?(0,Z.jsxs)(`span`,{className:K(`rounded-md border border-border/70 bg-muted/50 px-1.5 py-0.5 text-[11px] font-medium tabular-nums`,D.status===`connected`?`text-success`:D.status===`unresponsive`||D.status===`error`?`text-destructive`:D.status===`degraded`||D.status===`connecting`||D.status===`stopping`?`text-warning`:`text-muted-foreground`),title:[`Codebase index: ${O?.status??D.status}`,D.pid?`PID ${D.pid}`:null,O?.latencyMs==null?null:`RTT ${O.latencyMs}ms`,k?`RAM ${Vv(k.memory.rss)}`:null,O?.missedHeartbeats?`missed ${O.missedHeartbeats}`:null].filter(Boolean).join(` · `),children:[`Index `,O?.status??D.status]}):null,_>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:`${_} tool(s) dropped from provider requests due to maxTools limit`,children:[`-`,_,` tools`]}):null]}),(0,Z.jsx)(`div`,{className:`mt-0.5 truncate text-[11px] text-muted-foreground`,children:r||`No named session`})]})}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:o,className:`inline-flex h-8 items-center gap-1.5 rounded-md border border-border/70 bg-background/60 px-2 text-xs text-muted-foreground hover:bg-accent/60 hover:text-foreground`,title:c(`activity:topbar.commandPalette`),children:[(0,Z.jsx)(dt,{className:`h-3.5 w-3.5`}),c(`activity:topbar.command`)]}),(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`,title:v===`dark`?`Switch to light theme`:`Switch to dark theme`,children:v===`dark`?(0,Z.jsx)(Yi,{className:`h-3.5 w-3.5`}):(0,Z.jsx)(ui,{className:`h-3.5 w-3.5`})}),(0,Z.jsxs)(so,{children:[(0,Z.jsx)(co,{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:`${c(`settings:general.paletteSwitcherTitle`)}: ${c(ie(d).labelKey)}`,"aria-label":`${c(`settings:general.paletteSwitcherTitle`)}: ${c(ie(d).labelKey)}`,children:(0,Z.jsx)(Fe,{className:`h-3.5 w-3.5`})})}),(0,Z.jsxs)(fo,{align:`end`,className:`w-56`,children:[(0,Z.jsx)(go,{children:c(`settings:general.paletteHeading`)}),me.map(e=>(0,Z.jsxs)(po,{onSelect:()=>f(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:c(e.labelKey)}),d===e.id?(0,Z.jsx)(ii,{className:`h-3.5 w-3.5 text-primary`,"aria-hidden":!0}):null]},e.id))]})]}),(0,Z.jsx)(Fv,{}),(0,Z.jsx)(zv,{}),(0,Z.jsx)(`button`,{type:`button`,onClick:s,className:K(`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":`wrongproxy-status-button`,children:(0,Z.jsx)(Gr,{className:`h-3.5 w-3.5`})}),(0,Z.jsx)(`button`,{type:`button`,onClick:s,className:K(`inline-flex h-8 w-8 items-center justify-center rounded-md border bg-background/60 transition-colors`,S.status===`connected`?`border-border/70 text-success hover:bg-accent/60`:S.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:w,"aria-label":w,"data-testid":`hq-status-button`,children:(0,Z.jsx)(un,{className:`h-3.5 w-3.5`})}),(0,Z.jsx)(`span`,{role:`status`,"aria-label":p?`Connected`:`Disconnected`,className:K(`inline-flex h-8 w-8 items-center justify-center rounded-md border border-border/70 bg-background/60`,p?`text-success`:`text-warning`),title:p?`Connected`:`Disconnected`,"data-testid":`ws-status-indicator`,children:p?(0,Z.jsx)(qr,{className:`h-3.5 w-3.5`}):(0,Z.jsx)(Sr,{className:`h-3.5 w-3.5`})}),(0,Z.jsx)(`button`,{type:`button`,onClick:s,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:c(`activity:topbar.settings`),children:(0,Z.jsx)(mi,{className:`h-3.5 w-3.5`})})]})]})})]})}(0,X.lazy)(()=>G(()=>import(`./AnalyticsDashboard-Dr67MeEY.js`).then(e=>({default:e.AnalyticsDashboard})),__vite__mapDeps([26,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,20,21,19,22]))),(0,X.lazy)(()=>G(()=>import(`./CodeMap-D34FOPgR.js`).then(e=>({default:e.CodeMap})),__vite__mapDeps([42,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,19,24]))),(0,X.lazy)(()=>G(()=>import(`./ChronicleDashboard-CzqPfaPc.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]))),(0,X.lazy)(()=>G(()=>import(`./GoalView-BZ62_vF-.js`).then(e=>({default:e.GoalView})),__vite__mapDeps([45,1,2,3,4,5,6,7,8,9,10,11,12,13,14,18,0,15,16,19,20,21,22,23,24,31,46,25,32]))),(0,X.lazy)(()=>G(()=>import(`./ChangesView-s7Mn7iE2.js`).then(e=>({default:e.ChangesView})),__vite__mapDeps([36,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,19,20,21,22,23,24,37,38])));var Wv=(0,X.lazy)(()=>G(()=>import(`./CronJobsPanel-CenxuaN9.js`).then(e=>({default:e.CronJobsPanel})),__vite__mapDeps([67,1,2,3,4,5,6,7,8,9,10,11,12,13,14,20,0,15,16,21,19,22,25])));(0,X.lazy)(()=>G(()=>import(`./CodeEditor-DXQoTSH5.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,19,20,21,22,23,37,38,41,31,33]))),(0,X.lazy)(()=>G(()=>import(`./DebugDashboard-DWaUg6e1.js`).then(e=>({default:e.DebugDashboard})),__vite__mapDeps([43,1,2,3,4,5,6,7,8,9,10,11,12,13,14]))),(0,X.lazy)(()=>G(()=>import(`./DesignGalleryView-BKtjn4px.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,18,19,20,21,22,23,24]))),(0,X.lazy)(()=>G(()=>import(`./MailboxDetailView-DS1P9DRT.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,22,23,37]))),(0,X.lazy)(()=>G(()=>import(`./SageTabs-YASyEFo6.js`).then(e=>({default:e.SageTabs})),__vite__mapDeps([52,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]))),(0,X.lazy)(()=>G(()=>import(`./AgentRosterView-VIctzKMy.js`).then(e=>({default:e.AgentRosterView})),__vite__mapDeps([27,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,21,20,19,22,23,28,18,24,29,30,25,31,32,33,34,35]))),(0,X.lazy)(()=>G(()=>import(`./KanbanView-DsWnTpxr.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,20,21,19,22,25,28,18,23,24,48]))),(0,X.lazy)(()=>G(()=>import(`./OfficeMapPanel-BqoCcniD.js`).then(e=>({default:e.OfficeMapPanel})),__vite__mapDeps([34,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,20,21,19,22,35])));var Gv=(0,X.lazy)(()=>G(()=>import(`./ProcessMonitor-CHNNqCk9.js`).then(e=>({default:e.ProcessMonitor})),__vite__mapDeps([17,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,19,20,21,22,23,24,25]))),Kv=(0,X.lazy)(()=>G(()=>import(`./QueuePanel-CzTXq6j4.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,21,20,19,22,25])));(0,X.lazy)(()=>G(()=>import(`./RefreshDebugView-d9iU3sFX.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,21]))),(0,X.lazy)(()=>G(()=>import(`./SddHub-rmGGEYZe.js`).then(e=>({default:e.SddHub})),__vite__mapDeps([54,1,2,3,4,5,6,7,8,9,10,11,12,13,14,18,0,15,16,19,20,21,22,23,24,25,31,28,48,55]))),(0,X.lazy)(()=>G(()=>import(`./SessionsDashboard-x3iyhrGl.js`).then(e=>({default:e.SessionsDashboard})),__vite__mapDeps([56,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,19,20,21,22,23,24,57,46,25,31,32]))),(0,X.lazy)(()=>G(()=>import(`./SetupScreen-huPJT0Bv.js`).then(e=>({default:e.SetupScreen})),__vite__mapDeps([63,1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,19,20,21,22,23,24,25,31,32]))),(0,X.lazy)(()=>G(()=>import(`./SkillDetailView-BcD9z7zG.js`).then(e=>({default:e.SkillDetailView})),__vite__mapDeps([59,1,2,3,4,5,6,7,8,9,10,11,12,13,14,18,0,15,16,19,20,21,22,23,24,25,37]))),(0,X.lazy)(()=>G(()=>import(`./SpecsView-ok8HZ8ws.js`).then(e=>({default:e.SpecsView})),__vite__mapDeps([55,1,2,3,4,5,6,7,8,9,10,11,12,13,14,18,0,15,16,19,20,21,22,23,24,31]))),(0,X.lazy)(()=>G(()=>import(`./TechStackView-DmMtwb4l.js`).then(e=>({default:e.TechStackView})),__vite__mapDeps([60,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,20,0,16,21,19,22,31,32]))),(0,X.lazy)(()=>G(()=>import(`./TerminalPanel-cbM6oQWQ.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,20,21,19,22,65,66])));function qv(){let{t:e}=U(),{theme:n}=Pu(),r=ta(),{currentView:i,sidebarOpen:a,toggleSidebar:o,setSearchOpen:s,setSidebarOpen:c,setInspectorTab:u,setPaletteOpen:d,setShortcutsOpen:f,setModelSwitcherOpen:p,setPromptLibraryOpen:m,toggleInspector:h,setFleetMonitorOpen:g,setAgentsMonitorOpen:_,processMonitorOpen:v,setProcessMonitorOpen:y,queuePanelOpen:b,setQueuePanelOpen:x,cronJobsOpen:C,setCronJobsOpen:w,setTerminalOpen:T}=q(jn(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}))),E=J(e=>e.isLoading),D=J(e=>e.messages.length),O=ye(e=>e.info),k=ye(e=>e.promptedThisSession);(0,X.useEffect)(()=>{!O||O.chosen||O.variants.length!==0&&(D>0||k||ye.getState().openPicker())},[O,D,k]);let A=j(e=>e.iteration),M=j(e=>e.projectName),ee=j(e=>e.session?.title),N=j(e=>e.session?.id),F=P()??N,I=q(e=>F?e.sessionNicknames[F]:void 0),te=q(e=>e.sideContextBreakdownOpen),L=q(e=>e.setSideContextBreakdownOpen);B(e=>e.agents),qo({setPaletteOpen:d,setSearchOpen:s,setShortcutsOpen:f,setModelSwitcherOpen:p,setPromptLibraryOpen:m,setFleetMonitorOpen:g,setAgentsMonitorOpen:_,setProcessMonitorOpen:y,setQueuePanelOpen:x,setCronJobsOpen:w,setTerminalOpen:T}),(0,X.useEffect)(()=>{typeof window>`u`||(window.location.pathname===`/debug`?Na(`debug`):window.location.pathname===`/analytics`?Na(`analytics`):window.location.pathname===`/refresh-debug`&&Na(`refresh-debug`))},[]),(0,X.useEffect)(()=>{let e=e=>{let{filePath:n}=e.detail;q.getState().setCurrentView(`files`);let r=V(t.getState().wsUrl);r&&r.send({type:`files.read`,payload:r.withSession({filePath:n})})};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=S.getState().openFiles.find(e=>e.path===n);if(!r)return;let i=V(t.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:R}=$i();(0,X.useEffect)(()=>{R&&q.getState().sidebarOpen&&c(!1)},[R,c]);let z=R&&a;return aa(),Zo(),Yo(),(0,X.useEffect)(()=>{let e=[];if(E){let t=A?` iter ${A.index}${A.max?`/${A.max}`:``}`:``;e.push(`●${t}`)}let t=I?.trim()||ee?.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`}},[E,A,M,ee,I]),Xo({toggleSidebar:o,setSearchOpen:s,toggleInspector:h,setInspectorTab:u}),(0,Z.jsxs)(`div`,{"data-shell":r?`desktop`:`browser`,className:K(`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)(Mo,{desktopShell:r}),a&&i!==`setup`&&(0,Z.jsx)(Au,{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`,...z?{inert:!0}:{},children:[i!==`setup`&&(0,Z.jsx)(Uv,{currentView:i,projectName:M,sessionLabel:I||ee||F||void 0,isLoading:E,iteration:A??null,onPalette:()=>d(!0),onSettings:()=>Fa(`settings`)}),i!==`setup`&&(0,Z.jsx)(`div`,{className:K(i!==`chat`&&`ws-view-parked`),...i===`chat`?{}:{inert:!0,"aria-hidden":!0},children:(0,Z.jsx)(al,{})}),i!==`setup`&&(0,Z.jsx)(us,{}),i!==`setup`&&(0,Z.jsx)(Iu,{}),(0,Z.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col`,children:(0,Z.jsx)(Av,{sessionId:F??null,desktopShell:r})})]}),i!==`setup`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(xs,{level:`panel`,name:e(`activity:panels.inspector`),children:(0,Z.jsx)(jc,{})}),F&&(0,Z.jsx)(xs,{level:`panel`,name:e(`activity:panels.workspaceInspector`),children:(0,Z.jsx)(ov,{sessionId:F})})]}),v&&(0,Z.jsx)(xs,{level:`panel`,name:e(`activity:panels.processMonitor`),children:(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)(Gv,{open:v,onClose:()=>y(!1)})})}),b&&(0,Z.jsx)(xs,{level:`panel`,name:e(`activity:panels.queue`),children:(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)(Kv,{open:b,onClose:()=>x(!1)})})}),C&&(0,Z.jsx)(xs,{level:`panel`,name:e(`activity:panels.cronJobs`),children:(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)(Wv,{open:C,onClose:()=>w(!1)})})}),(0,Z.jsx)(zc,{}),te&&(0,Z.jsx)(ys,{open:te,onClose:()=>L(!1)}),(0,Z.jsx)(ss,{}),(0,Z.jsx)(ju,{}),(0,Z.jsx)(Ja,{}),(0,Z.jsx)(ls,{}),(0,Z.jsx)(Ga,{}),(0,Z.jsx)(Go,{}),(0,Z.jsx)(sl,{}),(0,Z.jsx)(Xc,{}),(0,Z.jsx)(Ss,{}),(0,Z.jsx)(l,{})]})}function Jv(){return(0,Z.jsx)(xs,{children:(0,Z.jsx)(Nu,{defaultTheme:`system`,children:(0,Z.jsx)(qv,{})})})}eo.createRoot(d(document.getElementById(`root`))).render((0,Z.jsx)(X.StrictMode,{children:(0,Z.jsx)(Jv,{})}));export{so as A,Es as C,ws as D,Os as E,po as M,co as N,ns as O,dc as S,Ds as T,Pu as _,Fh as a,vc as b,Th as c,em as d,Vp as f,rp as g,ap as h,Ph as i,fo as j,es as k,sh as l,dp as m,Z_ as n,Nh as o,Mp as p,q_ as r,Eh as s,$_ as t,Pm as u,Nl as v,ks as w,_c as x,Al as y};